neo.mjs 5.2.10 → 5.2.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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.2.10'
23
+ * @member {String} version='5.2.12'
24
24
  */
25
- version: '5.2.10'
25
+ version: '5.2.12'
26
26
  }
27
27
 
28
28
  /**
@@ -1,5 +1,5 @@
1
1
  import FormPageContainer from '../FormPageContainer.mjs';
2
- import TextField from '../../../../src/form/field/Text.mjs';
2
+ import Radio from '../../../../src/form/field/Radio.mjs';
3
3
 
4
4
  /**
5
5
  * @class Form.view.pages.Page5
@@ -12,6 +12,15 @@ class Page5 extends FormPageContainer {
12
12
  * @protected
13
13
  */
14
14
  className: 'Form.view.pages.Page5',
15
+ /**
16
+ * @member {Object} itemDefaults
17
+ */
18
+ itemDefaults: {
19
+ module : Radio,
20
+ labelText : null,
21
+ labelWidth: 70,
22
+ name : 'fruits'
23
+ },
15
24
  /**
16
25
  * @member {String} formGroup='page5'
17
26
  */
@@ -20,15 +29,22 @@ class Page5 extends FormPageContainer {
20
29
  * @member {Object[]} items
21
30
  */
22
31
  items: [{
23
- module : TextField,
24
- labelText: 'Page 5 Field 1',
25
- name : 'field1',
26
- required : true,
27
- value : 'bar'
32
+ labelText : 'Fruits',
33
+ value : 'apple',
34
+ valueLabelText: 'Apple'
35
+ }, {
36
+ value : 'banana',
37
+ valueLabelText: 'Banana'
38
+ }, {
39
+ checked : true,
40
+ value : 'lemon',
41
+ valueLabelText: 'Lemon'
42
+ }, {
43
+ value : 'orange',
44
+ valueLabelText: 'Orange'
28
45
  }, {
29
- module : TextField,
30
- labelText: 'Page 5 Field 2',
31
- name : 'field2'
46
+ value : 'strawberry',
47
+ valueLabelText: 'Strawberry'
32
48
  }]
33
49
  }
34
50
  }
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.2.10'
23
+ * @member {String} version='5.2.12'
24
24
  */
25
- version: '5.2.10'
25
+ version: '5.2.12'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.2.10",
3
+ "version": "5.2.12",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -44,7 +44,7 @@
44
44
  "@fortawesome/fontawesome-free": "^6.3.0",
45
45
  "@material/mwc-button": "^0.27.0",
46
46
  "@material/mwc-textfield": "^0.27.0",
47
- "autoprefixer": "^10.4.13",
47
+ "autoprefixer": "^10.4.14",
48
48
  "chalk": "^5.2.0",
49
49
  "clean-webpack-plugin": "^4.0.0",
50
50
  "commander": "^10.0.0",
@@ -56,8 +56,8 @@
56
56
  "neo-jsdoc": "^1.0.1",
57
57
  "neo-jsdoc-x": "^1.0.5",
58
58
  "postcss": "^8.4.21",
59
- "sass": "^1.58.3",
60
- "webpack": "^5.75.0",
59
+ "sass": "^1.59.2",
60
+ "webpack": "^5.76.1",
61
61
  "webpack-cli": "^5.0.1",
62
62
  "webpack-dev-server": "4.11.1",
63
63
  "webpack-hook-plugin": "^1.0.7",
@@ -8,7 +8,7 @@
8
8
  {"id": 4, "cardIndex": 2, "isHeader": false, "isValid": null, "name": "Page 3"},
9
9
  {"id": 5, "cardIndex": null, "isHeader": true, "isValid": null, "name": "2. Personal data"},
10
10
  {"id": 6, "cardIndex": 3, "isHeader": false, "isValid": null, "name": "CheckBoxes"},
11
- {"id": 7, "cardIndex": 4, "isHeader": false, "isValid": null, "name": "Page 5"},
11
+ {"id": 7, "cardIndex": 4, "isHeader": false, "isValid": null, "name": "Radios"},
12
12
  {"id": 8, "cardIndex": 5, "isHeader": false, "isValid": null, "name": "Page 6"},
13
13
  {"id": 9, "cardIndex": 6, "isHeader": false, "isValid": null, "name": "Fieldsets"},
14
14
  {"id": 10, "cardIndex": null, "isHeader": true, "isValid": null, "name": "3. More data"},
@@ -237,12 +237,12 @@ const DefaultConfig = {
237
237
  useVdomWorker: true,
238
238
  /**
239
239
  * buildScripts/injectPackageVersion.mjs will update this value
240
- * @default '5.2.10'
240
+ * @default '5.2.12'
241
241
  * @memberOf! module:Neo
242
242
  * @name config.version
243
243
  * @type String
244
244
  */
245
- version: '5.2.10'
245
+ version: '5.2.12'
246
246
  };
247
247
 
248
248
  Object.assign(DefaultConfig, {
@@ -376,7 +376,7 @@ class Base extends Component {
376
376
  items = me.items,
377
377
  i, len, returnArray;
378
378
 
379
- if (Neo.typeOf(item) === 'Array') {
379
+ if (Array.isArray(item)) {
380
380
  i = 0;
381
381
  len = item.length;
382
382
  returnArray = [];
@@ -110,7 +110,7 @@ class Container extends BaseContainer {
110
110
  ns = values;
111
111
  }
112
112
 
113
- if (Object.hasOwn(ns, key)) {
113
+ if (Object.hasOwn(ns, key) && value !== undefined) {
114
114
  if (ns[key] === null) {
115
115
  ns[key] = []
116
116
  } else if (!Array.isArray(ns[key])) {
@@ -118,8 +118,8 @@ class Container extends BaseContainer {
118
118
  }
119
119
 
120
120
  value !== null && ns[key].unshift(value)
121
- } else {
122
- ns[key] = value;
121
+ } else if (value !== undefined) {
122
+ ns[key] = value
123
123
  }
124
124
  });
125
125
 
@@ -44,6 +44,13 @@ class Radio extends CheckBox {
44
44
  value && this.uncheckGroupItems()
45
45
  }
46
46
 
47
+ /**
48
+ * @returns {String|null}
49
+ */
50
+ getValue() {
51
+ return this.checked ? this.value : undefined
52
+ }
53
+
47
54
  /**
48
55
  * Radios do not fire a change event for "uncheck", so we need to iterate over other radios with the same name.
49
56
  */
@@ -408,25 +408,27 @@ class Container extends BaseContainer {
408
408
  * Inserts an item or array of items at a specific index
409
409
  * @param {Number} index
410
410
  * @param {Object|Object[]} item
411
+ * @param {Boolean} silent=false
411
412
  * @returns {Neo.component.Base|Neo.component.Base[]}
412
413
  */
413
- insert(index, item) {
414
+ insert(index, item, silent=false) {
414
415
  let me = this,
415
416
  cardContainer = me.getCardContainer(),
416
417
  tabBar = me.getTabBar(),
417
418
  hasItem = false,
418
- i, len, superItem, tab, tabButtonConfig;
419
+ i, len, returnArray, superItem, tab, tabButtonConfig;
419
420
 
420
421
  if (Array.isArray(item)) {
421
- i = 0;
422
- len = item.length;
422
+ i = 0;
423
+ len = item.length;
424
+ returnArray = [];
423
425
 
424
426
  for (; i < len; i++) {
425
- // todo: render is async, ensure the order of items is correct
426
-
427
427
  // insert the array backwards
428
- item[i] = me.insert(item[len - 1], index);
428
+ returnArray.unshift(me.insert(index, item[len - 1 - i], true));
429
429
  }
430
+
431
+ superItem = returnArray;
430
432
  } else if (typeof item === 'object') {
431
433
  i = 0;
432
434
  len = cardContainer.items.length;
@@ -435,38 +437,46 @@ class Container extends BaseContainer {
435
437
  if (cardContainer.items[i].id === item.id) {
436
438
  hasItem = true;
437
439
  superItem = cardContainer.items[i];
438
- me.activeIndex = i;
440
+
441
+ if (me.activateInsertedTabs) {
442
+ me.activeIndex = i;
443
+ }
444
+
439
445
  break;
440
446
  }
441
447
  }
442
- }
443
-
444
- if (!hasItem) {
445
- tabButtonConfig = item.tabButtonConfig;
446
448
 
447
- tab = tabBar.insert(index, me.getTabButtonConfig(tabButtonConfig, index));
449
+ if (!hasItem) {
450
+ tabButtonConfig = item.tabButtonConfig;
448
451
 
449
- // todo: non index based matching of tab buttons and cards
450
- i = 0;
451
- len = tabBar.items.length;
452
+ tab = tabBar.insert(index, me.getTabButtonConfig(tabButtonConfig, index));
452
453
 
453
- for (; i < len; i++) {
454
- tabBar.items[i].index = i;
454
+ // todo: non index based matching of tab buttons and cards
455
+ i = 0;
456
+ len = tabBar.items.length;
455
457
 
456
- }
458
+ for (; i < len; i++) {
459
+ tabBar.items[i].index = i;
460
+ }
457
461
 
458
- item.flex = 1;
459
- superItem = cardContainer.insert(index, item);
462
+ item.flex = 1;
463
+ superItem = cardContainer.insert(index, item, silent);
460
464
 
461
- if (me.activateInsertedTabs) {
462
- if (!me.vnode) {
463
- me.activeIndex = index;
464
- } else {
465
- tab.on('mounted', me.onTabButtonMounted, me);
465
+ if (me.activateInsertedTabs) {
466
+ if (!me.vnode) {
467
+ me.activeIndex = index;
468
+ } else {
469
+ tab.on('mounted', me.onTabButtonMounted, me);
470
+ }
466
471
  }
467
472
  }
468
473
  }
469
474
 
475
+ if (!silent) {
476
+ me.updateTabButtons()
477
+ me.update();
478
+ }
479
+
470
480
  return superItem
471
481
  }
472
482