neo.mjs 7.16.0 → 8.0.0-alpha.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.
- package/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/view/ViewportController.mjs +1 -1
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/realworld/view/HomeComponent.mjs +13 -14
- package/apps/realworld/view/user/ProfileComponent.mjs +1 -1
- package/apps/realworld/view/user/SignUpComponent.mjs +1 -2
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/table/container/MainContainer.mjs +17 -12
- package/examples/table/nestedRecordFields/MainContainer.mjs +3 -1
- package/examples/todoList/version1/MainComponent.mjs +1 -1
- package/package.json +5 -5
- package/src/DefaultConfig.mjs +2 -2
- package/src/button/Base.mjs +8 -8
- package/src/calendar/view/SettingsContainer.mjs +4 -0
- package/src/calendar/view/calendars/ColorsList.mjs +6 -6
- package/src/calendar/view/calendars/Container.mjs +1 -1
- package/src/calendar/view/calendars/List.mjs +6 -2
- package/src/calendar/view/month/Component.mjs +1 -1
- package/src/calendar/view/week/Component.mjs +7 -7
- package/src/calendar/view/week/EventDragZone.mjs +1 -1
- package/src/calendar/view/week/TimeAxisComponent.mjs +2 -2
- package/src/calendar/view/week/plugin/DragDrop.mjs +3 -3
- package/src/collection/Base.mjs +4 -3
- package/src/component/Base.mjs +81 -36
- package/src/component/Circle.mjs +1 -3
- package/src/component/DateSelector.mjs +1 -1
- package/src/container/Accordion.mjs +1 -1
- package/src/container/Base.mjs +18 -6
- package/src/core/Base.mjs +10 -9
- package/src/draggable/list/DragZone.mjs +1 -1
- package/src/draggable/toolbar/DragZone.mjs +1 -1
- package/src/draggable/toolbar/SortZone.mjs +1 -1
- package/src/draggable/tree/DragZone.mjs +1 -1
- package/src/form/Fieldset.mjs +2 -0
- package/src/form/field/Color.mjs +4 -4
- package/src/form/field/ComboBox.mjs +2 -2
- package/src/form/field/Date.mjs +2 -1
- package/src/form/field/Picker.mjs +2 -1
- package/src/form/field/Text.mjs +8 -8
- package/src/layout/Card.mjs +1 -0
- package/src/list/Chip.mjs +3 -2
- package/src/list/Circle.mjs +2 -1
- package/src/list/Component.mjs +5 -0
- package/src/manager/Component.mjs +158 -4
- package/src/manager/DomEvent.mjs +2 -2
- package/src/menu/List.mjs +3 -4
- package/src/menu/Panel.mjs +1 -1
- package/src/selection/Model.mjs +1 -1
- package/src/selection/grid/BaseModel.mjs +61 -0
- package/src/selection/grid/CellColumnModel.mjs +2 -2
- package/src/selection/grid/CellColumnRowModel.mjs +2 -2
- package/src/selection/grid/CellModel.mjs +4 -4
- package/src/selection/grid/CellRowModel.mjs +9 -3
- package/src/selection/grid/ColumnModel.mjs +15 -26
- package/src/selection/grid/RowModel.mjs +15 -25
- package/src/selection/table/BaseModel.mjs +61 -0
- package/src/selection/table/CellColumnModel.mjs +2 -2
- package/src/selection/table/CellColumnRowModel.mjs +2 -2
- package/src/selection/table/CellModel.mjs +4 -4
- package/src/selection/table/CellRowModel.mjs +9 -3
- package/src/selection/table/ColumnModel.mjs +7 -8
- package/src/selection/table/RowModel.mjs +7 -7
- package/src/table/Container.mjs +1 -0
- package/src/table/View.mjs +102 -80
- package/src/table/header/Button.mjs +3 -5
- package/src/table/header/Toolbar.mjs +1 -0
- package/src/tree/List.mjs +1 -1
- package/src/util/VDom.mjs +42 -11
- package/src/util/VNode.mjs +33 -11
- package/src/vdom/Helper.mjs +36 -16
- package/src/vdom/VNode.mjs +1 -1
@@ -1,4 +1,5 @@
|
|
1
1
|
import Base from './Base.mjs';
|
2
|
+
import VDomUtil from '../util/VDom.mjs';
|
2
3
|
import VNodeUtil from '../util/VNode.mjs';
|
3
4
|
|
4
5
|
/**
|
@@ -20,6 +21,11 @@ class Component extends Base {
|
|
20
21
|
singleton: true
|
21
22
|
}
|
22
23
|
|
24
|
+
/**
|
25
|
+
* @member {Map} wrapperNodes=new Map()
|
26
|
+
*/
|
27
|
+
wrapperNodes = new Map()
|
28
|
+
|
23
29
|
/**
|
24
30
|
* @param {Object} config
|
25
31
|
*/
|
@@ -32,6 +38,58 @@ class Component extends Base {
|
|
32
38
|
Neo.getComponent = me.getById.bind(me) // alias
|
33
39
|
}
|
34
40
|
|
41
|
+
/**
|
42
|
+
* Flattens a given vnode tree by replacing component based subtrees with componentId based references
|
43
|
+
* @param {Object} vnode
|
44
|
+
* @param {String} ownerId We do not want to replace the own id => wrapped items
|
45
|
+
* @returns {Object}
|
46
|
+
*/
|
47
|
+
addVnodeComponentReferences(vnode, ownerId) {
|
48
|
+
vnode = {...vnode}; // shallow copy
|
49
|
+
|
50
|
+
let me = this,
|
51
|
+
childNodes = vnode?.childNodes ? [...vnode.childNodes] : [],
|
52
|
+
childNodeId, component, componentId, parentRef, referenceNode;
|
53
|
+
|
54
|
+
vnode.childNodes = childNodes;
|
55
|
+
|
56
|
+
childNodes.forEach((childNode, index) => {
|
57
|
+
childNodeId = childNode.id;
|
58
|
+
|
59
|
+
if (!childNode.componentId && childNodeId !== ownerId) {
|
60
|
+
component = me.get(childNodeId);
|
61
|
+
|
62
|
+
if (!component) {
|
63
|
+
// searching for wrapped components as a fallback
|
64
|
+
component = me.wrapperNodes.get(childNodeId);
|
65
|
+
|
66
|
+
if (component) {
|
67
|
+
// update the parent component reference => assign the wrapper id
|
68
|
+
componentId = component.id;
|
69
|
+
parentRef = VDomUtil.find(component.parent.vdom, {componentId}, false);
|
70
|
+
|
71
|
+
if (parentRef) {
|
72
|
+
parentRef.vdom.id = childNodeId
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
if (component) {
|
78
|
+
componentId = component.id;
|
79
|
+
referenceNode = {componentId};
|
80
|
+
|
81
|
+
if (componentId !== childNodeId) {
|
82
|
+
referenceNode.id = childNodeId
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
childNodes[index] = component ? referenceNode : me.addVnodeComponentReferences(childNode, ownerId)
|
88
|
+
});
|
89
|
+
|
90
|
+
return vnode
|
91
|
+
}
|
92
|
+
|
35
93
|
/**
|
36
94
|
* Returns the first component which matches the config-selector moving down the component items tree.
|
37
95
|
* Use returnFirstMatch=false to get an array of all matching items instead.
|
@@ -144,11 +202,11 @@ class Component extends Base {
|
|
144
202
|
/**
|
145
203
|
* todo: replace all calls of this method to calls using the util.VNode class
|
146
204
|
* Get the ids of all child nodes of the given vnode
|
147
|
-
* @param vnode
|
148
|
-
* @param childIds
|
149
|
-
* @returns {
|
205
|
+
* @param {Object} vnode
|
206
|
+
* @param {String[]} childIds=[]
|
207
|
+
* @returns {String[]} childIds
|
150
208
|
*/
|
151
|
-
getChildIds(vnode, childIds) {
|
209
|
+
getChildIds(vnode, childIds=[]) {
|
152
210
|
return VNodeUtil.getChildIds(vnode, childIds)
|
153
211
|
}
|
154
212
|
|
@@ -318,6 +376,79 @@ class Component extends Base {
|
|
318
376
|
return parents
|
319
377
|
}
|
320
378
|
|
379
|
+
/**
|
380
|
+
* Copies a given vdom tree and replaces child component references with the vdom of their matching components
|
381
|
+
* @param {Object} vdom
|
382
|
+
* @param {Number} depth=-1
|
383
|
+
* The component replacement depth.
|
384
|
+
* -1 will parse the full tree, 1 top level only, 2 include children, 3 include grandchildren
|
385
|
+
* @returns {Object}
|
386
|
+
*/
|
387
|
+
getVdomTree(vdom, depth=-1) {
|
388
|
+
let output = {...vdom}, // shallow copy
|
389
|
+
childDepth;
|
390
|
+
|
391
|
+
if (vdom.cn) {
|
392
|
+
output.cn = [];
|
393
|
+
|
394
|
+
childDepth = depth === -1 ? -1 : depth > 1 ? depth-1 : 1;
|
395
|
+
|
396
|
+
vdom.cn.forEach(item => {
|
397
|
+
childDepth = depth;
|
398
|
+
|
399
|
+
if (item.componentId) {
|
400
|
+
childDepth = depth === -1 ? -1 : depth > 1 ? depth-1 : 1;
|
401
|
+
|
402
|
+
if (depth === -1 || depth > 1) {
|
403
|
+
item = this.get(item.componentId).vdom
|
404
|
+
}
|
405
|
+
}
|
406
|
+
|
407
|
+
output.cn.push(this.getVdomTree(item, childDepth))
|
408
|
+
})
|
409
|
+
}
|
410
|
+
|
411
|
+
return output
|
412
|
+
}
|
413
|
+
|
414
|
+
/**
|
415
|
+
* Copies a given vnode tree and replaces child component references with the vnode of their matching components
|
416
|
+
* @param {Object} vnode
|
417
|
+
* @param {Number} depth=-1
|
418
|
+
* The component replacement depth.
|
419
|
+
* -1 will parse the full tree, 1 top level only, 2 include children, 3 include grandchildren
|
420
|
+
* @returns {Object}
|
421
|
+
*/
|
422
|
+
getVnodeTree(vnode, depth=-1) {
|
423
|
+
let output = {...vnode}, // shallow copy
|
424
|
+
childDepth, component;
|
425
|
+
|
426
|
+
if (vnode.childNodes) {
|
427
|
+
output.childNodes = [];
|
428
|
+
|
429
|
+
vnode.childNodes.forEach(item => {
|
430
|
+
childDepth = depth;
|
431
|
+
|
432
|
+
if (item.componentId) {
|
433
|
+
childDepth = depth === -1 ? -1 : depth > 1 ? depth-1 : 1;
|
434
|
+
|
435
|
+
if (depth === -1 || depth > 1) {
|
436
|
+
component = this.get(item.componentId);
|
437
|
+
|
438
|
+
// keep references in case there is no vnode (cmp not mounted)
|
439
|
+
if (component.vnode) {
|
440
|
+
item = component.vnode
|
441
|
+
}
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
output.childNodes.push(this.getVnodeTree(item, childDepth))
|
446
|
+
})
|
447
|
+
}
|
448
|
+
|
449
|
+
return output
|
450
|
+
}
|
451
|
+
|
321
452
|
/**
|
322
453
|
* Check if the component had a property of any value somewhere in the Prototype chain
|
323
454
|
*
|
@@ -338,6 +469,29 @@ class Component extends Base {
|
|
338
469
|
return false
|
339
470
|
}
|
340
471
|
|
472
|
+
/**
|
473
|
+
* @param {String} wrapperId
|
474
|
+
* @param {Neo.component.Base} component
|
475
|
+
*/
|
476
|
+
registerWrapperNode(wrapperId, component) {
|
477
|
+
this.wrapperNodes.set(wrapperId, component)
|
478
|
+
}
|
479
|
+
|
480
|
+
/**
|
481
|
+
* @param {Neo.component.Base|String} item
|
482
|
+
*/
|
483
|
+
unregister(item) {
|
484
|
+
if (item) {
|
485
|
+
if (Neo.isString(item)) {
|
486
|
+
this.wrapperNodes.delete(item)
|
487
|
+
} else if (item.id !== item.vdom.id) {
|
488
|
+
this.wrapperNodes.delete(item.vdom.id)
|
489
|
+
}
|
490
|
+
}
|
491
|
+
|
492
|
+
super.unregister(item)
|
493
|
+
}
|
494
|
+
|
341
495
|
/**
|
342
496
|
* Returns the first component which matches the config-selector.
|
343
497
|
* Use returnFirstMatch=false to get an array of all matching items instead.
|
package/src/manager/DomEvent.mjs
CHANGED
@@ -522,11 +522,11 @@ class DomEvent extends Base {
|
|
522
522
|
delegationVdom;
|
523
523
|
|
524
524
|
if (targetId && targetId !== delegationTargetId) {
|
525
|
-
delegationVdom = VDomUtil.
|
525
|
+
delegationVdom = VDomUtil.find(component.vdom, delegationTargetId);
|
526
526
|
|
527
527
|
// delegationVdom can be undefined when dragging a proxy over the node.
|
528
528
|
// see issues/1137 for details.
|
529
|
-
if (!delegationVdom || delegationVdom.vdom && VDomUtil.
|
529
|
+
if (!delegationVdom || delegationVdom.vdom && VDomUtil.find(delegationVdom.vdom, targetId)) {
|
530
530
|
return false
|
531
531
|
}
|
532
532
|
}
|
package/src/menu/List.mjs
CHANGED
@@ -251,12 +251,11 @@ class List extends BaseList {
|
|
251
251
|
*
|
252
252
|
*/
|
253
253
|
hideSubMenu() {
|
254
|
-
let
|
255
|
-
activeSubMenu = me.activeSubMenu;
|
254
|
+
let {activeSubMenu} = this;
|
256
255
|
|
257
256
|
if (activeSubMenu) {
|
258
257
|
activeSubMenu.unmount();
|
259
|
-
|
258
|
+
this.activeSubMenu = null
|
260
259
|
}
|
261
260
|
}
|
262
261
|
|
@@ -402,7 +401,7 @@ class List extends BaseList {
|
|
402
401
|
recordId = record[me.getKeyProperty()],
|
403
402
|
submenu = me.subMenuMap?.[me.getMenuMapId(recordId)];
|
404
403
|
|
405
|
-
if (!submenu
|
404
|
+
if (!submenu?.mounted) {
|
406
405
|
me.showSubMenu(nodeId, record)
|
407
406
|
} else {
|
408
407
|
me.hideSubMenu()
|
package/src/menu/Panel.mjs
CHANGED
package/src/selection/Model.mjs
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
import Model from '../Model.mjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Abstract base class for all grid related selection models
|
5
|
+
* @class Neo.selection.grid.BaseModel
|
6
|
+
* @extends Neo.selection.Model
|
7
|
+
* @abstract
|
8
|
+
*/
|
9
|
+
class BaseModel extends Model {
|
10
|
+
static config = {
|
11
|
+
/**
|
12
|
+
* @member {String} className='Neo.selection.grid.BaseModel'
|
13
|
+
* @protected
|
14
|
+
*/
|
15
|
+
className: 'Neo.selection.grid.BaseModel'
|
16
|
+
}
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @param {Object} item
|
20
|
+
* @param {Boolean} [silent] true to prevent a vdom update
|
21
|
+
* @param {Object[]|String[]} itemCollection=this.items
|
22
|
+
* @param {String} [selectedCls]
|
23
|
+
*/
|
24
|
+
deselect(item, silent, itemCollection=this.items, selectedCls) {
|
25
|
+
let {view} = this;
|
26
|
+
|
27
|
+
if (!silent) {
|
28
|
+
view.updateDepth = 2
|
29
|
+
}
|
30
|
+
|
31
|
+
super.deselect(item, silent, itemCollection, selectedCls)
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @param {Boolean} [silent] true to prevent a vdom update
|
36
|
+
*/
|
37
|
+
deselectAll(silent) {
|
38
|
+
let {view} = this;
|
39
|
+
|
40
|
+
if (!silent) {
|
41
|
+
view.updateDepth = 2
|
42
|
+
}
|
43
|
+
|
44
|
+
super.deselectAll(silent)
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* @param {Object} args
|
49
|
+
*/
|
50
|
+
select(...args) {
|
51
|
+
let {view} = this;
|
52
|
+
|
53
|
+
if (!view.silentSelect) {
|
54
|
+
view.updateDepth = 2
|
55
|
+
}
|
56
|
+
|
57
|
+
super.select(...args)
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
export default Neo.setupClass(BaseModel);
|
@@ -69,7 +69,7 @@ class CellColumnModel extends CellModel {
|
|
69
69
|
|
70
70
|
if (id) {
|
71
71
|
index = ColumnModel.getColumnIndex(id, me.view.items[0].items);
|
72
|
-
tbodyNode = VDomUtil.
|
72
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
73
73
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, index);
|
74
74
|
|
75
75
|
me.deselectAllCells(true);
|
@@ -96,7 +96,7 @@ class CellColumnModel extends CellModel {
|
|
96
96
|
newIndex += fields.length
|
97
97
|
}
|
98
98
|
|
99
|
-
tbodyNode = VDomUtil.
|
99
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
100
100
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
101
101
|
|
102
102
|
me.deselectAllCells(true);
|
@@ -69,7 +69,7 @@ class CellColumnRowModel extends CellRowModel {
|
|
69
69
|
|
70
70
|
if (id) {
|
71
71
|
index = ColumnModel.getColumnIndex(id, me.view.items[0].items);
|
72
|
-
tbodyNode = VDomUtil.
|
72
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
73
73
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, index);
|
74
74
|
|
75
75
|
me.deselectAllCells(true);
|
@@ -96,7 +96,7 @@ class CellColumnRowModel extends CellRowModel {
|
|
96
96
|
newIndex += fields.length
|
97
97
|
}
|
98
98
|
|
99
|
-
tbodyNode = VDomUtil.
|
99
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
100
100
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
101
101
|
|
102
102
|
me.deselectAllCells(true);
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import BaseModel from './BaseModel.mjs';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* @class Neo.selection.grid.CellModel
|
5
|
-
* @extends Neo.selection.
|
5
|
+
* @extends Neo.selection.grid.BaseModel
|
6
6
|
*/
|
7
|
-
class CellModel extends
|
7
|
+
class CellModel extends BaseModel {
|
8
8
|
static config = {
|
9
9
|
/**
|
10
10
|
* @member {String} className='Neo.selection.grid.CellModel'
|
@@ -40,7 +40,7 @@ class CellModel extends Model {
|
|
40
40
|
|
41
41
|
me.view.un('cellClick', me.onCellClick, me);
|
42
42
|
|
43
|
-
super.destroy(...args)
|
43
|
+
super.destroy(...args)
|
44
44
|
}
|
45
45
|
|
46
46
|
/**
|
@@ -73,7 +73,10 @@ class CellRowModel extends CellModel {
|
|
73
73
|
|
74
74
|
NeoArray.remove(me.selectedRowIds, rowId);
|
75
75
|
|
76
|
-
!silent
|
76
|
+
if (!silent) {
|
77
|
+
view.updateDepth = 2;
|
78
|
+
view.update()
|
79
|
+
}
|
77
80
|
}
|
78
81
|
|
79
82
|
/**
|
@@ -103,7 +106,7 @@ class CellRowModel extends CellModel {
|
|
103
106
|
node = RowModel.getRowNode(data.path),
|
104
107
|
{view} = me,
|
105
108
|
{store} = view,
|
106
|
-
vdomNode = VDomUtil.
|
109
|
+
vdomNode = VDomUtil.find(view.vdom, node.id),
|
107
110
|
newIndex = (vdomNode.index + step) % store.getCount(),
|
108
111
|
{parentNode} = vdomNode,
|
109
112
|
id;
|
@@ -138,7 +141,10 @@ class CellRowModel extends CellModel {
|
|
138
141
|
me.selectedRowIds.push(id)
|
139
142
|
}
|
140
143
|
|
141
|
-
!silent
|
144
|
+
if (!silent) {
|
145
|
+
view.updateDepth = 2;
|
146
|
+
view.update()
|
147
|
+
}
|
142
148
|
}
|
143
149
|
|
144
150
|
/**
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import
|
2
|
-
import VDomUtil
|
1
|
+
import BaseModel from './BaseModel.mjs';
|
2
|
+
import VDomUtil from '../../util/VDom.mjs';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* @class Neo.selection.grid.ColumnModel
|
6
|
-
* @extends Neo.selection.
|
6
|
+
* @extends Neo.selection.grid.BaseModel
|
7
7
|
*/
|
8
|
-
class ColumnModel extends
|
8
|
+
class ColumnModel extends BaseModel {
|
9
9
|
static config = {
|
10
10
|
/**
|
11
11
|
* @member {String} className='Neo.selection.grid.ColumnModel'
|
@@ -41,7 +41,7 @@ class ColumnModel extends Model {
|
|
41
41
|
|
42
42
|
me.view.un('cellClick', me.onCellClick, me);
|
43
43
|
|
44
|
-
super.destroy(...args)
|
44
|
+
super.destroy(...args)
|
45
45
|
}
|
46
46
|
|
47
47
|
/**
|
@@ -87,7 +87,7 @@ class ColumnModel extends Model {
|
|
87
87
|
|
88
88
|
if (id) {
|
89
89
|
index = ColumnModel.getColumnIndex(id, me.view.items[0].items);
|
90
|
-
tbodyNode = VDomUtil.
|
90
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
91
91
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, index);
|
92
92
|
|
93
93
|
me.select(columnNodeIds)
|
@@ -128,7 +128,7 @@ class ColumnModel extends Model {
|
|
128
128
|
idArray[2] = fields[newIndex];
|
129
129
|
id = idArray.join('__');
|
130
130
|
|
131
|
-
tbodyNode = VDomUtil.
|
131
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {cls: 'neo-grid-view'}).vdom;
|
132
132
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
133
133
|
|
134
134
|
me.select(columnNodeIds);
|
@@ -143,33 +143,22 @@ class ColumnModel extends Model {
|
|
143
143
|
|
144
144
|
let {id, view} = this;
|
145
145
|
|
146
|
-
view.keys?._keys.push(
|
147
|
-
fn
|
148
|
-
key
|
149
|
-
|
150
|
-
}, {
|
151
|
-
fn : 'onKeyDownRight',
|
152
|
-
key : 'Right',
|
153
|
-
scope: id
|
154
|
-
})
|
146
|
+
view.keys?._keys.push(
|
147
|
+
{fn: 'onKeyDownLeft', key: 'Left', scope: id},
|
148
|
+
{fn: 'onKeyDownRight', key: 'Right', scope: id}
|
149
|
+
)
|
155
150
|
}
|
156
151
|
|
157
|
-
|
158
152
|
/**
|
159
153
|
*
|
160
154
|
*/
|
161
155
|
unregister() {
|
162
156
|
let {id, view} = this;
|
163
157
|
|
164
|
-
view.keys?.removeKeys([
|
165
|
-
fn
|
166
|
-
key
|
167
|
-
|
168
|
-
}, {
|
169
|
-
fn : 'onKeyDownRight',
|
170
|
-
key : 'Right',
|
171
|
-
scope: id
|
172
|
-
}]);
|
158
|
+
view.keys?.removeKeys([
|
159
|
+
{fn: 'onKeyDownLeft', key: 'Left', scope: id},
|
160
|
+
{fn: 'onKeyDownRight', key: 'Right', scope: id}
|
161
|
+
]);
|
173
162
|
|
174
163
|
super.unregister()
|
175
164
|
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import
|
2
|
-
import VDomUtil
|
1
|
+
import BaseModel from './BaseModel.mjs';
|
2
|
+
import VDomUtil from '../../util/VDom.mjs';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* @class Neo.selection.grid.RowModel
|
6
|
-
* @extends Neo.selection.
|
6
|
+
* @extends Neo.selection.grid.BaseModel
|
7
7
|
*/
|
8
|
-
class RowModel extends
|
8
|
+
class RowModel extends BaseModel {
|
9
9
|
static config = {
|
10
10
|
/**
|
11
11
|
* @member {String} className='Neo.selection.grid.RowModel'
|
@@ -41,7 +41,7 @@ class RowModel extends Model {
|
|
41
41
|
|
42
42
|
me.view.un('rowClick', me.onRowClick, me);
|
43
43
|
|
44
|
-
super.destroy(...args)
|
44
|
+
super.destroy(...args)
|
45
45
|
}
|
46
46
|
|
47
47
|
/**
|
@@ -100,7 +100,7 @@ class RowModel extends Model {
|
|
100
100
|
node = RowModel.getRowNode(data.path),
|
101
101
|
{view} = me,
|
102
102
|
{store} = view,
|
103
|
-
vdomNode = VDomUtil.
|
103
|
+
vdomNode = VDomUtil.find(view.vdom, node.id),
|
104
104
|
newIndex = (vdomNode.index + step) % store.getCount(),
|
105
105
|
{parentNode} = vdomNode,
|
106
106
|
id;
|
@@ -134,7 +134,7 @@ class RowModel extends Model {
|
|
134
134
|
me.toggleSelection(id);
|
135
135
|
|
136
136
|
isSelected = me.isSelected(id);
|
137
|
-
record = view.store.getAt(VDomUtil.
|
137
|
+
record = view.store.getAt(VDomUtil.find(view.vdom, id).index);
|
138
138
|
|
139
139
|
!isSelected && view.onDeselect?.(record);
|
140
140
|
|
@@ -152,15 +152,10 @@ class RowModel extends Model {
|
|
152
152
|
|
153
153
|
let {id, view} = this;
|
154
154
|
|
155
|
-
view.keys?._keys.push(
|
156
|
-
fn
|
157
|
-
key
|
158
|
-
|
159
|
-
}, {
|
160
|
-
fn : 'onKeyDownUp',
|
161
|
-
key : 'Up',
|
162
|
-
scope: id
|
163
|
-
})
|
155
|
+
view.keys?._keys.push(
|
156
|
+
{fn: 'onKeyDownDown', key: 'Down', scope: id},
|
157
|
+
{fn: 'onKeyDownUp', key: 'Up', scope: id}
|
158
|
+
)
|
164
159
|
}
|
165
160
|
|
166
161
|
/**
|
@@ -169,15 +164,10 @@ class RowModel extends Model {
|
|
169
164
|
unregister() {
|
170
165
|
let {id, view} = this;
|
171
166
|
|
172
|
-
view.keys?.removeKeys([
|
173
|
-
fn
|
174
|
-
key
|
175
|
-
|
176
|
-
}, {
|
177
|
-
fn : 'onKeyDownUp',
|
178
|
-
key : 'Up',
|
179
|
-
scope: id
|
180
|
-
}]);
|
167
|
+
view.keys?.removeKeys([
|
168
|
+
{fn: 'onKeyDownDown', key: 'Down', scope: id},
|
169
|
+
{fn: 'onKeyDownUp', key: 'Up', scope: id}
|
170
|
+
]);
|
181
171
|
|
182
172
|
super.unregister()
|
183
173
|
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import Model from '../Model.mjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Abstract base class for all table related selection models
|
5
|
+
* @class Neo.selection.table.BaseModel
|
6
|
+
* @extends Neo.selection.Model
|
7
|
+
* @abstract
|
8
|
+
*/
|
9
|
+
class BaseModel extends Model {
|
10
|
+
static config = {
|
11
|
+
/**
|
12
|
+
* @member {String} className='Neo.selection.table.BaseModel'
|
13
|
+
* @protected
|
14
|
+
*/
|
15
|
+
className: 'Neo.selection.table.BaseModel'
|
16
|
+
}
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @param {Object} item
|
20
|
+
* @param {Boolean} [silent] true to prevent a vdom update
|
21
|
+
* @param {Object[]|String[]} itemCollection=this.items
|
22
|
+
* @param {String} [selectedCls]
|
23
|
+
*/
|
24
|
+
deselect(item, silent, itemCollection=this.items, selectedCls) {
|
25
|
+
let {view} = this;
|
26
|
+
|
27
|
+
if (!silent) {
|
28
|
+
view.updateDepth = 2
|
29
|
+
}
|
30
|
+
|
31
|
+
super.deselect(item, silent, itemCollection, selectedCls)
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @param {Boolean} [silent] true to prevent a vdom update
|
36
|
+
*/
|
37
|
+
deselectAll(silent) {
|
38
|
+
let {view} = this;
|
39
|
+
|
40
|
+
if (!silent) {
|
41
|
+
view.updateDepth = 2
|
42
|
+
}
|
43
|
+
|
44
|
+
super.deselectAll(silent)
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* @param {Object} args
|
49
|
+
*/
|
50
|
+
select(...args) {
|
51
|
+
let {view} = this;
|
52
|
+
|
53
|
+
if (!view.silentSelect) {
|
54
|
+
view.updateDepth = 2
|
55
|
+
}
|
56
|
+
|
57
|
+
super.select(...args)
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
export default Neo.setupClass(BaseModel);
|
@@ -69,7 +69,7 @@ class CellColumnModel extends CellModel {
|
|
69
69
|
|
70
70
|
if (id) {
|
71
71
|
index = ColumnModel.getColumnIndex(id, me.view.items[0].items);
|
72
|
-
tbodyNode = VDomUtil.
|
72
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {tag: 'tbody'}).vdom;
|
73
73
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, index);
|
74
74
|
|
75
75
|
me.deselectAllCells(true);
|
@@ -96,7 +96,7 @@ class CellColumnModel extends CellModel {
|
|
96
96
|
newIndex += dataFields.length
|
97
97
|
}
|
98
98
|
|
99
|
-
tbodyNode = VDomUtil.
|
99
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {tag: 'tbody'}).vdom;
|
100
100
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
101
101
|
|
102
102
|
me.deselectAllCells(true);
|
@@ -69,7 +69,7 @@ class CellColumnRowModel extends CellRowModel {
|
|
69
69
|
|
70
70
|
if (id) {
|
71
71
|
index = ColumnModel.getColumnIndex(id, me.view.items[0].items);
|
72
|
-
tbodyNode = VDomUtil.
|
72
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {tag: 'tbody'}).vdom;
|
73
73
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, index);
|
74
74
|
|
75
75
|
me.deselectAllCells(true);
|
@@ -96,7 +96,7 @@ class CellColumnRowModel extends CellRowModel {
|
|
96
96
|
newIndex += dataFields.length
|
97
97
|
}
|
98
98
|
|
99
|
-
tbodyNode = VDomUtil.
|
99
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {tag: 'tbody'}).vdom;
|
100
100
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
101
101
|
|
102
102
|
me.deselectAllCells(true);
|