neo.mjs 5.12.5 → 5.13.0
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/apps/ServiceWorker.mjs +2 -2
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/button/base/MainContainer.mjs +29 -1
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/button/Base.mjs +13 -17
- package/src/component/Base.mjs +1 -0
- package/src/main/addon/ScrollSync.mjs +1 -1
- package/src/menu/List.mjs +60 -31
- package/src/table/View.mjs +1 -1
package/apps/ServiceWorker.mjs
CHANGED
@@ -197,7 +197,35 @@ class MainContainer extends ConfigurationViewport {
|
|
197
197
|
}, {
|
198
198
|
handler: data => console.log('menu item 3 click =>', data),
|
199
199
|
iconCls: 'fa fa-play',
|
200
|
-
text : 'Item 3'
|
200
|
+
text : 'Item 3',
|
201
|
+
|
202
|
+
items: [{
|
203
|
+
handler: data => console.log('menu item 4 click =>', data),
|
204
|
+
iconCls: 'fa fa-home',
|
205
|
+
text : 'Item 4'
|
206
|
+
}, {
|
207
|
+
handler: data => console.log('menu item 5 click =>', data),
|
208
|
+
iconCls: 'fa fa-user',
|
209
|
+
text : 'Item 5'
|
210
|
+
}, {
|
211
|
+
handler: data => console.log('menu item 6 click =>', data),
|
212
|
+
iconCls: 'fa fa-play',
|
213
|
+
text : 'Item 6',
|
214
|
+
|
215
|
+
items: [{
|
216
|
+
handler: data => console.log('menu item 7 click =>', data),
|
217
|
+
iconCls: 'fa fa-home',
|
218
|
+
text : 'Item 7'
|
219
|
+
}, {
|
220
|
+
handler: data => console.log('menu item 8 click =>', data),
|
221
|
+
iconCls: 'fa fa-user',
|
222
|
+
text : 'Item 8'
|
223
|
+
}, {
|
224
|
+
handler: data => console.log('menu item 9 click =>', data),
|
225
|
+
iconCls: 'fa fa-play',
|
226
|
+
text : 'Item 9'
|
227
|
+
}]
|
228
|
+
}]
|
201
229
|
}]
|
202
230
|
|
203
231
|
/*tooltips: [{
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -236,12 +236,12 @@ const DefaultConfig = {
|
|
236
236
|
useVdomWorker: true,
|
237
237
|
/**
|
238
238
|
* buildScripts/injectPackageVersion.mjs will update this value
|
239
|
-
* @default '5.
|
239
|
+
* @default '5.13.0'
|
240
240
|
* @memberOf! module:Neo
|
241
241
|
* @name config.version
|
242
242
|
* @type String
|
243
243
|
*/
|
244
|
-
version: '5.
|
244
|
+
version: '5.13.0'
|
245
245
|
};
|
246
246
|
|
247
247
|
Object.assign(DefaultConfig, {
|
package/src/button/Base.mjs
CHANGED
@@ -272,7 +272,7 @@ class Base extends Component {
|
|
272
272
|
afterSetPressed(value, oldValue) {
|
273
273
|
let cls = this.cls;
|
274
274
|
|
275
|
-
NeoArray
|
275
|
+
NeoArray.toggle(cls, 'pressed', value === true);
|
276
276
|
this.cls = cls;
|
277
277
|
}
|
278
278
|
|
@@ -284,18 +284,16 @@ class Base extends Component {
|
|
284
284
|
*/
|
285
285
|
afterSetText(value, oldValue) {
|
286
286
|
let me = this,
|
287
|
+
isEmpty = !value || value === '',
|
287
288
|
vdomRoot = me.getVdomRoot(),
|
288
289
|
textNode = vdomRoot.cn[1];
|
289
290
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
NeoArray.remove(vdomRoot.cls, 'no-text');
|
297
|
-
textNode.removeDom = false;
|
298
|
-
textNode.innerHTML = value;
|
291
|
+
NeoArray.toggle(me._cls, 'no-text', isEmpty);
|
292
|
+
NeoArray.toggle(vdomRoot.cls, 'no-text', isEmpty);
|
293
|
+
textNode.removeDom = isEmpty;
|
294
|
+
|
295
|
+
if (!isEmpty) {
|
296
|
+
textNode.innerHTML = value
|
299
297
|
}
|
300
298
|
|
301
299
|
me.update()
|
@@ -400,7 +398,7 @@ class Base extends Component {
|
|
400
398
|
* @protected
|
401
399
|
*/
|
402
400
|
beforeSetIconPosition(value, oldValue) {
|
403
|
-
return this.beforeSetEnumValue(value, oldValue, 'iconPosition')
|
401
|
+
return this.beforeSetEnumValue(value, oldValue, 'iconPosition')
|
404
402
|
}
|
405
403
|
|
406
404
|
/**
|
@@ -490,23 +488,21 @@ class Base extends Component {
|
|
490
488
|
rippleWrapper.removeDom = true;
|
491
489
|
me.update()
|
492
490
|
}
|
493
|
-
}, rippleEffectDuration)
|
491
|
+
}, rippleEffectDuration)
|
494
492
|
}
|
495
493
|
|
496
494
|
/**
|
497
495
|
*
|
498
496
|
*/
|
499
|
-
toggleMenu() {
|
497
|
+
async toggleMenu() {
|
500
498
|
let menuList = this.menuList,
|
501
499
|
hidden = !menuList.hidden;
|
502
500
|
|
503
501
|
menuList.hidden = hidden;
|
504
502
|
|
505
503
|
if (!hidden) {
|
506
|
-
|
507
|
-
|
508
|
-
menuList.focus()
|
509
|
-
}, 500)
|
504
|
+
await Neo.timeout(50);
|
505
|
+
menuList.focus()
|
510
506
|
}
|
511
507
|
}
|
512
508
|
}
|
package/src/component/Base.mjs
CHANGED
package/src/menu/List.mjs
CHANGED
@@ -39,6 +39,11 @@ class List extends BaseList {
|
|
39
39
|
* @protected
|
40
40
|
*/
|
41
41
|
focusTimeoutId: null,
|
42
|
+
/**
|
43
|
+
* Hides a floating list on leaf item click, in case it has a parentComponent
|
44
|
+
* @member {Boolean} hideOnLeafItemClick=true
|
45
|
+
*/
|
46
|
+
hideOnLeafItemClick: true,
|
42
47
|
/**
|
43
48
|
* Optionally pass menu.Store data directly
|
44
49
|
* @member {Object[]|null} items_=null
|
@@ -109,11 +114,6 @@ class List extends BaseList {
|
|
109
114
|
* @member {Neo.component.Base|null} parentComponent=null
|
110
115
|
*/
|
111
116
|
parentComponent = null
|
112
|
-
/**
|
113
|
-
* If the menu is floating, it will anchor itself to the parentRect
|
114
|
-
* @member {Object|null} parentRect=null
|
115
|
-
*/
|
116
|
-
parentRect = null
|
117
117
|
|
118
118
|
/**
|
119
119
|
* Triggered after the floating config got changed
|
@@ -154,7 +154,6 @@ class List extends BaseList {
|
|
154
154
|
if (me.isRoot) {
|
155
155
|
if (!value) {
|
156
156
|
me.focusTimeoutId = setTimeout(() => {
|
157
|
-
console.log('unmount'); // todo: does not hide a top-level floating menu
|
158
157
|
me[me.floating ? 'unmount' : 'hideSubMenu']();
|
159
158
|
}, 20);
|
160
159
|
} else {
|
@@ -177,23 +176,31 @@ class List extends BaseList {
|
|
177
176
|
afterSetMounted(value, oldValue) {
|
178
177
|
super.afterSetMounted(value, oldValue);
|
179
178
|
|
180
|
-
let me
|
181
|
-
|
179
|
+
let me = this,
|
180
|
+
id = me.id,
|
181
|
+
parentId = me.parentComponent?.id;
|
182
182
|
|
183
|
-
if (
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
183
|
+
if (parentId) {
|
184
|
+
if (value) {
|
185
|
+
Neo.main.addon.ScrollSync.register({
|
186
|
+
sourceId: parentId,
|
187
|
+
targetId: id
|
188
|
+
});
|
188
189
|
|
189
|
-
|
190
|
-
|
190
|
+
!me.parentMenu && me.getDomRect([id, parentId]).then(rects => {
|
191
|
+
let style = me.style || {};
|
191
192
|
|
192
|
-
|
193
|
-
|
193
|
+
style.left = `${rects[1].right - rects[0].width}px`;
|
194
|
+
style.top = `${rects[1].bottom + 1}px`;
|
194
195
|
|
195
|
-
|
196
|
-
|
196
|
+
me.style = style
|
197
|
+
})
|
198
|
+
} else if (oldValue !== undefined) {
|
199
|
+
Neo.main.addon.ScrollSync.unregister({
|
200
|
+
sourceId: parentId,
|
201
|
+
targetId: id
|
202
|
+
})
|
203
|
+
}
|
197
204
|
}
|
198
205
|
}
|
199
206
|
|
@@ -310,7 +317,22 @@ class List extends BaseList {
|
|
310
317
|
* @param {Object[]} data.oldPath
|
311
318
|
*/
|
312
319
|
onFocusLeave(data) {
|
313
|
-
|
320
|
+
let insideParent = false,
|
321
|
+
parentId = this.parentComponent?.id,
|
322
|
+
item;
|
323
|
+
|
324
|
+
if (parentId) {
|
325
|
+
for (item of data.oldPath) {
|
326
|
+
if (item.id === parentId) {
|
327
|
+
insideParent = true;
|
328
|
+
break;
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
if (!insideParent) {
|
334
|
+
this.menuFocus = false
|
335
|
+
}
|
314
336
|
}
|
315
337
|
|
316
338
|
/**
|
@@ -320,7 +342,13 @@ class List extends BaseList {
|
|
320
342
|
onItemClick(node, data) {
|
321
343
|
super.onItemClick(node, data);
|
322
344
|
|
323
|
-
|
345
|
+
let me = this;
|
346
|
+
|
347
|
+
data.record.handler?.call(me, data);
|
348
|
+
|
349
|
+
if (me.hideOnLeafItemClick && !data.record.items) {
|
350
|
+
me.unmount()
|
351
|
+
}
|
324
352
|
}
|
325
353
|
|
326
354
|
/**
|
@@ -365,17 +393,18 @@ class List extends BaseList {
|
|
365
393
|
subMenu.setSilent({style: menuStyle})
|
366
394
|
} else {
|
367
395
|
subMenuMap[subMenuMapId] = subMenu = Neo.create({
|
368
|
-
module
|
369
|
-
appName
|
370
|
-
displayField: me.displayField,
|
371
|
-
floating
|
372
|
-
items
|
373
|
-
isRoot
|
374
|
-
|
375
|
-
|
376
|
-
|
396
|
+
module : List,
|
397
|
+
appName : me.appName,
|
398
|
+
displayField : me.displayField,
|
399
|
+
floating : true,
|
400
|
+
items : record.items,
|
401
|
+
isRoot : false,
|
402
|
+
parentComponent: me.parentComponent,
|
403
|
+
parentId : Neo.apps[me.appName].mainView.id,
|
404
|
+
parentIndex : store.indexOf(record),
|
405
|
+
parentMenu : me,
|
377
406
|
style,
|
378
|
-
zIndex
|
407
|
+
zIndex : me.zIndex + 1
|
379
408
|
})
|
380
409
|
}
|
381
410
|
|
package/src/table/View.mjs
CHANGED
@@ -345,7 +345,7 @@ class View extends Component {
|
|
345
345
|
cellNode = VDomUtil.findVdomChild(vdom, cellId);
|
346
346
|
|
347
347
|
// the vdom might not exist yet => nothing to do in this case
|
348
|
-
if (cellNode
|
348
|
+
if (cellNode?.vdom) {
|
349
349
|
column = me.getColumn(field.name);
|
350
350
|
index = cellNode.index;
|
351
351
|
needsUpdate = true;
|