neo.mjs 5.12.0 → 5.12.1

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.12.0'
23
+ * @member {String} version='5.12.1'
24
24
  */
25
- version: '5.12.0'
25
+ version: '5.12.1'
26
26
  }
27
27
 
28
28
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.12.0'
23
+ * @member {String} version='5.12.1'
24
24
  */
25
- version: '5.12.0'
25
+ version: '5.12.1'
26
26
  }
27
27
 
28
28
  /**
@@ -170,6 +170,9 @@ class MainContainer extends ConfigurationViewport {
170
170
  }];
171
171
  }
172
172
 
173
+ /**
174
+ * @returns {Neo.component.Base}
175
+ */
173
176
  createExampleComponent() {
174
177
  return Neo.create({
175
178
  module : Button,
@@ -45,7 +45,7 @@ class MainContainer extends ConfigurationViewport {
45
45
  createExampleComponent() {
46
46
  return Neo.create({
47
47
  module : MenuList,
48
- displayField: 'name',
48
+ displayField: 'text',
49
49
  store : MainStore
50
50
  });
51
51
  }
@@ -17,48 +17,48 @@ class MainStore extends Store {
17
17
  data: [{
18
18
  iconCls: 'fa fa-user',
19
19
  id : 1,
20
- name : 'Item 1'
20
+ text : 'Item 1'
21
21
  }, {
22
22
  iconCls: 'fa fa-home',
23
23
  id : 2,
24
- name : 'Group 1',
24
+ text : 'Group 1',
25
25
  items : [{
26
26
  iconCls: 'fa fa-home',
27
27
  id : 6,
28
- name : 'Item 1'
28
+ text : 'Item 1'
29
29
  }, {
30
30
  iconCls: 'fa fa-home',
31
31
  id : 7,
32
- name : 'Item 2'
32
+ text : 'Item 2'
33
33
  }, {
34
34
  iconCls: 'fa fa-home',
35
35
  id : 8,
36
- name : 'Item 3'
36
+ text : 'Item 3'
37
37
  }]
38
38
  }, {
39
39
  iconCls: 'fa fa-cog',
40
40
  id : 3,
41
- name : 'Item 2'
41
+ text : 'Item 2'
42
42
  }, {
43
43
  iconCls: 'far fa-calendar',
44
44
  id : 4,
45
- name : 'Item 3'
45
+ text : 'Item 3'
46
46
  }, {
47
47
  iconCls: 'far fa-clock',
48
48
  id : 5,
49
- name : 'Group 2',
49
+ text : 'Group 2',
50
50
  items : [{
51
51
  iconCls: 'fa fa-clock',
52
52
  id : 9,
53
- name : 'Item 1'
53
+ text : 'Item 1'
54
54
  }, {
55
55
  iconCls: 'fa fa-clock',
56
56
  id : 10,
57
- name : 'Item 2'
57
+ text : 'Item 2'
58
58
  }, {
59
59
  iconCls: 'fa fa-clock',
60
60
  id : 11,
61
- name : 'Item 3'
61
+ text : 'Item 3'
62
62
  }]
63
63
  }]
64
64
  }
@@ -56,70 +56,70 @@ class MainContainer extends ConfigurationViewport {
56
56
  module: Menu,
57
57
 
58
58
  listConfig: {
59
- displayField: 'name'
59
+ displayField: 'text'
60
60
  },
61
61
 
62
62
  listItems: [{
63
63
  iconCls: 'fa fa-user',
64
64
  id : 1,
65
- name : 'Item 1'
65
+ text : 'Item 1'
66
66
  }, {
67
67
  iconCls: 'fa fa-home',
68
68
  id : 2,
69
- name : 'Group 1',
69
+ text : 'Group 1',
70
70
  items : [{
71
71
  iconCls: 'fa fa-home',
72
72
  id : 6,
73
- name : 'Item 1'
73
+ text : 'Item 1'
74
74
  }, {
75
75
  iconCls: 'fa fa-home',
76
76
  id : 7,
77
- name : 'Item 2'
77
+ text : 'Item 2'
78
78
  }, {
79
79
  iconCls: 'fa fa-home',
80
80
  id : 8,
81
- name : 'Item 3'
81
+ text : 'Item 3'
82
82
  }]
83
83
  }, {
84
84
  iconCls: 'fa fa-cog',
85
85
  id : 3,
86
- name : 'Item 2'
86
+ text : 'Item 2'
87
87
  }, {
88
88
  iconCls: 'far fa-calendar',
89
89
  id : 4,
90
- name : 'Item 3'
90
+ text : 'Item 3'
91
91
  }, {
92
92
  iconCls: 'far fa-clock',
93
93
  id : 5,
94
- name : 'Group 2',
94
+ text : 'Group 2',
95
95
  items : [{
96
96
  iconCls: 'fa fa-clock',
97
97
  id : 9,
98
- name : 'Item 1'
98
+ text : 'Item 1'
99
99
  }, {
100
100
  iconCls: 'fa fa-clock',
101
101
  id : 10,
102
- name : 'Item 2'
102
+ text : 'Item 2'
103
103
  }, {
104
104
  iconCls: 'fa fa-clock',
105
105
  id : 11,
106
- name : 'Group 1',
106
+ text : 'Group 1',
107
107
  items : [{
108
108
  iconCls: 'far fa-clock',
109
109
  id : 12,
110
- name : 'Item 1'
110
+ text : 'Item 1'
111
111
  }, {
112
112
  iconCls: 'far fa-clock',
113
113
  id : 13,
114
- name : 'Item 2'
114
+ text : 'Item 2'
115
115
  }, {
116
116
  iconCls: 'far fa-clock',
117
117
  id : 14,
118
- name : 'Item 3'
118
+ text : 'Item 3'
119
119
  }]
120
120
  }]
121
121
  }]
122
- });
122
+ })
123
123
  }
124
124
  }
125
125
 
@@ -79,9 +79,10 @@ class MainContainer extends ConfigurationViewport {
79
79
  valueLabelText: 'Cell & Column & Row'
80
80
  }, {
81
81
  module : Checkbox,
82
+ checked : me.exampleComponent.sortable,
82
83
  labelText: 'sortable',
83
84
  listeners: {change: me.onConfigChange.bind(me, 'sortable')},
84
- value : me.exampleComponent.sortable
85
+ style : {marginTop: '10px'}
85
86
  }];
86
87
  }
87
88
 
@@ -90,7 +91,6 @@ class MainContainer extends ConfigurationViewport {
90
91
  */
91
92
  createExampleComponent() {
92
93
  return Neo.create(TableContainer, {
93
- autoRender : false,
94
94
  id : 'myTableStoreContainer',
95
95
  selectionModel: CellModel,
96
96
  store : MainStore,
@@ -101,6 +101,7 @@ class MainContainer extends ConfigurationViewport {
101
101
  {dataField: 'githubId', text: 'Github Id'},
102
102
  {dataField: 'country', text: 'Country'},
103
103
  {
104
+ text: 'Edit Action',
104
105
  renderer: data => {
105
106
  let button = Neo.create({
106
107
  module : Button,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.12.0",
3
+ "version": "5.12.1",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '5.12.0'
239
+ * @default '5.12.1'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '5.12.0'
244
+ version: '5.12.1'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
@@ -186,6 +186,11 @@ class Base extends Component {
186
186
  click: value,
187
187
  scope: me.handlerScope || me
188
188
  });
189
+
190
+ me.menu && me.addDomListeners({
191
+ click: me.toggleMenu,
192
+ scope: me
193
+ })
189
194
  }
190
195
 
191
196
  /**
@@ -201,7 +206,7 @@ class Base extends Component {
201
206
  NeoArray.add( iconNode.cls, value);
202
207
 
203
208
  iconNode.removeDom = !value || value === '';
204
- this.update();
209
+ this.update()
205
210
  }
206
211
 
207
212
  /**
@@ -222,7 +227,7 @@ class Base extends Component {
222
227
  }
223
228
 
224
229
  iconNode.style.color = value;
225
- this.update();
230
+ this.update()
226
231
  }
227
232
 
228
233
  /**
@@ -249,20 +254,51 @@ class Base extends Component {
249
254
  afterSetMenu(value, oldValue) {
250
255
  if (value) {
251
256
  import('../menu/List.mjs').then(module => {
252
- let list = Neo.create({
253
- module : module.default,
254
- appName : this.appName,
255
- floating: true,
256
- items : value
257
+ let me = this;
258
+
259
+ me.menuList = Neo.create({
260
+ module : module.default,
261
+ appName : me.appName,
262
+ displayField: 'text',
263
+ floating : true,
264
+ hidden : true,
265
+ items : value,
266
+ parentId : me.id
257
267
  });
258
268
 
259
- list.render(true);
260
-
261
- console.log('afterSetMenu', list);
269
+ me.vdom.cn.push(me.menuList.vdom)
262
270
  })
263
271
  }
264
272
  }
265
273
 
274
+ /**
275
+ * Triggered after the mounted config got changed
276
+ * @param {Boolean} value
277
+ * @param {Boolean} oldValue
278
+ * @protected
279
+ */
280
+ afterSetMounted(value, oldValue) {
281
+ super.afterSetMounted(value, oldValue);
282
+
283
+ let me = this,
284
+ style;
285
+
286
+ if (value && me.menu) {
287
+ setTimeout(() => {
288
+ me.getDomRect().then(rect => {
289
+ style = me.menuList.style || {};
290
+
291
+ Object.assign(style, {
292
+ right: 0,
293
+ top : rect.height + 'px'
294
+ });
295
+
296
+ me.menuList.style = style
297
+ })
298
+ }, 50)
299
+ }
300
+ }
301
+
266
302
  /**
267
303
  * Triggered after the pressed config got changed
268
304
  * @param {Boolean} value
@@ -288,7 +324,7 @@ class Base extends Component {
288
324
  value && me.addDomListeners({
289
325
  click: me.changeRoute,
290
326
  scope: me
291
- });
327
+ })
292
328
  }
293
329
 
294
330
  /**
@@ -504,6 +540,23 @@ class Base extends Component {
504
540
  }
505
541
  }, rippleEffectDuration);
506
542
  }
543
+
544
+ /**
545
+ *
546
+ */
547
+ toggleMenu() {
548
+ let menuList = this.menuList,
549
+ hidden = !menuList.hidden;
550
+
551
+ menuList.hidden = hidden;
552
+
553
+ if (!hidden) {
554
+ setTimeout(() => {
555
+ console.log('focus'); // todo: does not activate the key nav
556
+ menuList.focus()
557
+ }, 500)
558
+ }
559
+ }
507
560
  }
508
561
 
509
562
  Neo.applyClassConfig(Base);
@@ -1106,14 +1106,11 @@ class Base extends CoreBase {
1106
1106
  * @param {String} id=this.id
1107
1107
  */
1108
1108
  focus(id=this.id) {
1109
- let me = this;
1110
-
1111
- // remote method access
1112
1109
  Neo.main.DomAccess.focus({
1113
- id: id || me.id
1110
+ id
1114
1111
  }).catch(err => {
1115
- console.log('Error attempting to receive focus for component', err, me);
1116
- });
1112
+ console.log('Error attempting to receive focus for component', err, this);
1113
+ })
1117
1114
  }
1118
1115
 
1119
1116
  /**
@@ -1191,7 +1188,7 @@ class Base extends CoreBase {
1191
1188
  getMountedParentId() {
1192
1189
  let parentId = this.parentId,
1193
1190
  parent = Neo.getComponent(parentId),
1194
- itemsRoot = parent?.getVdomItemsRoot();
1191
+ itemsRoot = parent?.getVdomItemsRoot?.();
1195
1192
 
1196
1193
  return itemsRoot ? itemsRoot.id : parentId
1197
1194
  }
@@ -1442,21 +1442,19 @@ class Text extends Base {
1442
1442
  }
1443
1443
  }
1444
1444
 
1445
- if (required && isEmpty) {
1446
- me._error = me.errorTextRequired;
1447
- returnValue = false;
1448
- } else if (Neo.isNumber(maxLength) && valueLength > maxLength) {
1449
- if (required || !isEmpty) {
1450
- me._error = me.errorTextMaxLength(errorParam);
1445
+ if (isEmpty) {
1446
+ if (required) {
1447
+ me._error = me.errorTextRequired;
1451
1448
  returnValue = false;
1452
1449
  }
1453
- } else if (Neo.isNumber(minLength) && valueLength < minLength) {
1454
- if (required || !isEmpty) {
1450
+ } else {
1451
+ if (Neo.isNumber(maxLength) && valueLength > maxLength) {
1452
+ me._error = me.errorTextMaxLength(errorParam);
1453
+ returnValue = false;
1454
+ } else if (Neo.isNumber(minLength) && valueLength < minLength) {
1455
1455
  me._error = me.errorTextMinLength(errorParam);
1456
1456
  returnValue = false;
1457
- }
1458
- } else if (inputPattern && !inputPattern.test(value)) {
1459
- if (required || !isEmpty) {
1457
+ } else if (inputPattern && !inputPattern.test(value)) {
1460
1458
  me._error = me.errorTextInputPattern(errorParam);
1461
1459
  returnValue = false;
1462
1460
  }
@@ -127,12 +127,12 @@ class DeltaUpdates extends Base {
127
127
  startTag = `<!-- ${delta.id} -->`;
128
128
  reg = new RegExp(startTag + '[\\s\\S]*?<!-- \/neo-vtext -->');
129
129
 
130
- node.innerHTML = node.innerHTML.replace(reg, '');
130
+ node.innerHTML = node.innerHTML.replace(reg, '')
131
131
  } else {
132
132
  // console.warn('du_removeNode: dom node not found for id', delta.id);
133
133
  }
134
134
  } else {
135
- node.parentNode.removeChild(node);
135
+ node.remove()
136
136
  }
137
137
  }
138
138
 
@@ -106,7 +106,7 @@ class DomEvent extends Base {
106
106
 
107
107
  if (!preventFire) {
108
108
  // multiple listeners would change the reference of data.component
109
- data = Neo.clone(data, true);
109
+ data = Neo.clone(data, true, true);
110
110
 
111
111
  data.component = component;
112
112
  listener.fn.apply(listener.scope || globalThis, [data]);
package/src/menu/List.mjs CHANGED
@@ -96,7 +96,12 @@ class List extends BaseList {
96
96
  * We are applying a z-index style which is 1 number higher to each sub-menu
97
97
  * @member {Number} zIndex_=100
98
98
  */
99
- zIndex_: 100
99
+ zIndex_: 100,
100
+ /**
101
+ * @member {Object} _vdom
102
+ */
103
+ _vdom:
104
+ {tag: 'ul', tabIndex: -1, cn: []}
100
105
  }
101
106
 
102
107
  /**
@@ -138,6 +143,7 @@ class List extends BaseList {
138
143
  if (me.isRoot) {
139
144
  if (!value) {
140
145
  me.focusTimeoutId = setTimeout(() => {
146
+ console.log('unmount'); // todo: does not hide a top-level floating menu
141
147
  me[me.floating ? 'unmount' : 'hideSubMenu']();
142
148
  }, 20);
143
149
  } else {
@@ -305,26 +311,27 @@ class List extends BaseList {
305
311
 
306
312
  Object.assign(menuStyle, style);
307
313
 
308
- subMenu.setSilent({style: menuStyle});
314
+ subMenu.setSilent({style: menuStyle})
309
315
  } else {
310
316
  subMenuMap[subMenuMapId] = subMenu = Neo.create({
311
- module : List,
312
- appName : me.appName,
313
- floating : true,
314
- items : record.items,
315
- isRoot : false,
316
- parentId : Neo.apps[me.appName].mainView.id,
317
- parentIndex: store.indexOf(record),
318
- parentMenu : me,
317
+ module : List,
318
+ appName : me.appName,
319
+ displayField: me.displayField,
320
+ floating : true,
321
+ items : record.items,
322
+ isRoot : false,
323
+ parentId : Neo.apps[me.appName].mainView.id,
324
+ parentIndex : store.indexOf(record),
325
+ parentMenu : me,
319
326
  style,
320
- zIndex : me.zIndex + 1
321
- });
327
+ zIndex : me.zIndex + 1
328
+ })
322
329
  }
323
330
 
324
331
  me.activeSubMenu = subMenu;
325
332
  me.subMenuMap = subMenuMap;
326
333
 
327
- subMenu.render(true);
334
+ subMenu.render(true)
328
335
  });
329
336
  }
330
337
 
@@ -335,7 +342,7 @@ class List extends BaseList {
335
342
  this.selectionModel.deselectAll(true); // silent update
336
343
  this.hideSubMenu();
337
344
 
338
- super.unmount();
345
+ super.unmount()
339
346
  }
340
347
  }
341
348
 
@@ -28,7 +28,7 @@ class Model extends BaseModel {
28
28
  name: 'items', // optional
29
29
  type: 'Array'
30
30
  }, {
31
- name: 'name',
31
+ name: 'text',
32
32
  type: 'String'
33
33
  }]
34
34
  }