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,10 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import BaseModel from './BaseModel.mjs';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* @class Neo.selection.table.CellModel
|
5
|
-
* @extends Neo.selection.
|
5
|
+
* @extends Neo.selection.table.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.table.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.parentNode,
|
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.table.ColumnModel
|
6
|
-
* @extends Neo.selection.
|
6
|
+
* @extends Neo.selection.table.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.table.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, {tag: 'tbody'}).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] = dataFields[newIndex];
|
129
129
|
id = idArray.join('__');
|
130
130
|
|
131
|
-
tbodyNode = VDomUtil.
|
131
|
+
tbodyNode = VDomUtil.find(me.view.vdom, {tag: 'tbody'}).vdom;
|
132
132
|
columnNodeIds = VDomUtil.getColumnNodesIds(tbodyNode, newIndex);
|
133
133
|
|
134
134
|
me.select(columnNodeIds);
|
@@ -149,7 +149,6 @@ class ColumnModel extends Model {
|
|
149
149
|
)
|
150
150
|
}
|
151
151
|
|
152
|
-
|
153
152
|
/**
|
154
153
|
*
|
155
154
|
*/
|
@@ -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.table.RowModel
|
6
|
-
* @extends Neo.selection.
|
6
|
+
* @extends Neo.selection.table.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.table.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
|
|
package/src/table/Container.mjs
CHANGED
@@ -231,6 +231,7 @@ class Container extends BaseContainer {
|
|
231
231
|
if (me.dockRightMargin) {
|
232
232
|
cssRules.push('#' + id + '::-webkit-scrollbar-track:horizontal {margin-right: ' + me.dockRightMargin + 'px;}')
|
233
233
|
}
|
234
|
+
|
234
235
|
if (cssRules.length > 0) {
|
235
236
|
CssUtil.insertRules(me.appName, cssRules)
|
236
237
|
}
|
package/src/table/View.mjs
CHANGED
@@ -55,6 +55,19 @@ class View extends Component {
|
|
55
55
|
{tag: 'tbody', cn: []}
|
56
56
|
}
|
57
57
|
|
58
|
+
/**
|
59
|
+
* @member {String[]} selectedRows
|
60
|
+
*/
|
61
|
+
get selectedRows() {
|
62
|
+
let tableContainer = this.parent;
|
63
|
+
|
64
|
+
if (tableContainer.selectionModel.ntype === 'selection-table-rowmodel') {
|
65
|
+
return tableContainer.selectionModel.items
|
66
|
+
}
|
67
|
+
|
68
|
+
return []
|
69
|
+
}
|
70
|
+
|
58
71
|
/**
|
59
72
|
* @param config
|
60
73
|
*/
|
@@ -167,98 +180,106 @@ class View extends Component {
|
|
167
180
|
}
|
168
181
|
|
169
182
|
/**
|
170
|
-
* @param {Object
|
183
|
+
* @param {Object} opts
|
184
|
+
* @param {Object} opts.record
|
185
|
+
* @param {Number} opts.rowIndex
|
186
|
+
* @returns {Object}
|
171
187
|
*/
|
172
|
-
|
173
|
-
let me
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
188
|
+
createTableRow({record, rowIndex}) {
|
189
|
+
let me = this,
|
190
|
+
tableContainer = me.parent,
|
191
|
+
colspan = record[me.colspanField],
|
192
|
+
colspanKeys = colspan && Object.keys(colspan),
|
193
|
+
columns = tableContainer.items[0].items,
|
194
|
+
colCount = columns.length,
|
195
|
+
dockLeftMargin = 0,
|
196
|
+
dockRightMargin = 0,
|
197
|
+
id = me.getRowId(record, rowIndex),
|
198
|
+
{selectedRows} = me,
|
199
|
+
trCls = me.getTrClass(record, rowIndex),
|
200
|
+
config, column, columnIndex, i, tableRow;
|
201
|
+
|
202
|
+
me.recordVnodeMap[id] = rowIndex;
|
203
|
+
|
204
|
+
if (selectedRows && Neo.ns(me.selectedRecordField, false, record)) {
|
205
|
+
NeoArray.add(selectedRows, id)
|
185
206
|
}
|
186
207
|
|
187
|
-
|
188
|
-
|
189
|
-
colspan = record[me.colspanField];
|
190
|
-
colspanKeys = colspan && Object.keys(colspan);
|
191
|
-
id = me.getRowId(record, i);
|
208
|
+
if (selectedRows?.includes(id)) {
|
209
|
+
trCls.push('neo-selected');
|
192
210
|
|
193
|
-
me.
|
211
|
+
me.parent.fire('select', {
|
212
|
+
record
|
213
|
+
})
|
214
|
+
}
|
194
215
|
|
195
|
-
|
216
|
+
tableRow = {
|
217
|
+
tag : 'tr',
|
218
|
+
id,
|
219
|
+
cls : trCls,
|
220
|
+
cn : [],
|
221
|
+
tabIndex: '-1'
|
222
|
+
};
|
196
223
|
|
197
|
-
|
198
|
-
|
199
|
-
}
|
224
|
+
for (i=0; i < colCount; i++) {
|
225
|
+
column = columns[i];
|
226
|
+
config = me.applyRendererOutput({column, record, index: rowIndex, tableContainer});
|
200
227
|
|
201
|
-
if (
|
202
|
-
|
228
|
+
if (column.dock) {
|
229
|
+
config.cls = ['neo-locked', ...config.cls || []];
|
203
230
|
|
204
|
-
|
205
|
-
|
206
|
-
|
231
|
+
if (column.dock === 'left') {
|
232
|
+
config.style.left = dockLeftMargin + 'px';
|
233
|
+
dockLeftMargin += (column.width + 1) // todo: borders fix
|
234
|
+
}
|
207
235
|
}
|
208
236
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
cls : trCls,
|
213
|
-
cn : [],
|
214
|
-
tabIndex: '-1'
|
215
|
-
});
|
237
|
+
if (column.flex) {
|
238
|
+
config.style.width = '100%'
|
239
|
+
}
|
216
240
|
|
217
|
-
|
218
|
-
dockRightMargin = 0;
|
241
|
+
tableRow.cn.push(config);
|
219
242
|
|
220
|
-
|
221
|
-
|
222
|
-
|
243
|
+
if (colspanKeys?.includes(column.dataField)) {
|
244
|
+
i += (colspan[column.dataField] - 1)
|
245
|
+
}
|
246
|
+
}
|
223
247
|
|
224
|
-
|
225
|
-
|
248
|
+
for (i=0; i < colCount; i++) {
|
249
|
+
columnIndex = colCount - i -1;
|
250
|
+
column = columns[columnIndex];
|
226
251
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
if (column.flex) {
|
234
|
-
config.style.width = '100%'
|
235
|
-
}
|
236
|
-
|
237
|
-
data[i].cn.push(config);
|
252
|
+
if (column.dock === 'right') {
|
253
|
+
tableRow.cn[columnIndex].style.right = dockRightMargin + 'px';
|
254
|
+
dockRightMargin += (column.width + 1) // todo: borders fix
|
255
|
+
}
|
238
256
|
|
239
|
-
|
240
|
-
|
241
|
-
}
|
257
|
+
if (colspanKeys?.includes(column.dataField)) {
|
258
|
+
i += (colspan[column.dataField] - 1)
|
242
259
|
}
|
260
|
+
}
|
243
261
|
|
244
|
-
|
245
|
-
|
246
|
-
column = columns[index];
|
262
|
+
// the dock margins are the same for each row
|
263
|
+
rowIndex === 0 && Object.assign(tableContainer, {dockLeftMargin, dockRightMargin});
|
247
264
|
|
248
|
-
|
249
|
-
|
250
|
-
dockRightMargin += (column.width + 1) // todo: borders fix
|
251
|
-
}
|
265
|
+
return tableRow
|
266
|
+
}
|
252
267
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
268
|
+
/**
|
269
|
+
* @param {Object[]} inputData
|
270
|
+
*/
|
271
|
+
createViewData(inputData) {
|
272
|
+
let me = this,
|
273
|
+
amountRows = inputData.length,
|
274
|
+
i = 0,
|
275
|
+
rows = [],
|
276
|
+
{selectedRows} = me;
|
258
277
|
|
259
|
-
|
278
|
+
for (; i < amountRows; i++) {
|
279
|
+
rows.push(me.createTableRow({record: inputData[i], rowIndex: i}))
|
280
|
+
}
|
260
281
|
|
261
|
-
|
282
|
+
me.vdom.cn = rows;
|
262
283
|
|
263
284
|
me.promiseUpdate().then(() => {
|
264
285
|
if (selectedRows?.length > 0) {
|
@@ -440,9 +461,9 @@ class View extends Component {
|
|
440
461
|
* @param {Neo.data.Model} opts.model The model instance of the changed record
|
441
462
|
* @param {Object} opts.record
|
442
463
|
*/
|
443
|
-
onStoreRecordChange(
|
464
|
+
onStoreRecordChange({fields, model, record}) {
|
444
465
|
let me = this,
|
445
|
-
fieldNames =
|
466
|
+
fieldNames = fields.map(field => field.name),
|
446
467
|
needsUpdate = false,
|
447
468
|
tableContainer = me.parent,
|
448
469
|
{selectionModel} = tableContainer,
|
@@ -450,17 +471,18 @@ class View extends Component {
|
|
450
471
|
cellId, cellNode, column, index, scope;
|
451
472
|
|
452
473
|
if (fieldNames.includes(me.colspanField)) {
|
453
|
-
|
454
|
-
me.
|
474
|
+
index = me.store.indexOf(record);
|
475
|
+
me.vdom.cn[index] = me.createTableRow({record, rowIndex: index});
|
476
|
+
me.update()
|
455
477
|
} else {
|
456
|
-
|
478
|
+
fields.forEach(field => {
|
457
479
|
if (field.name === me.selectedRecordField) {
|
458
480
|
if (selectionModel.ntype === 'selection-table-rowmodel') {
|
459
|
-
selectionModel[
|
481
|
+
selectionModel[field.value ? 'select' : 'deselect'](me.getRowId(record))
|
460
482
|
}
|
461
483
|
} else {
|
462
|
-
cellId = me.getCellId(
|
463
|
-
cellNode = VDomUtil.
|
484
|
+
cellId = me.getCellId(record, field.name);
|
485
|
+
cellNode = VDomUtil.find(vdom, cellId);
|
464
486
|
|
465
487
|
// the vdom might not exist yet => nothing to do in this case
|
466
488
|
if (cellNode?.vdom) {
|
@@ -469,7 +491,7 @@ class View extends Component {
|
|
469
491
|
needsUpdate = true;
|
470
492
|
scope = column.rendererScope || tableContainer;
|
471
493
|
|
472
|
-
cellNode.parentNode.cn[index] = me.applyRendererOutput({cellId, column, record
|
494
|
+
cellNode.parentNode.cn[index] = me.applyRendererOutput({cellId, column, record, index, tableContainer})
|
473
495
|
}
|
474
496
|
}
|
475
497
|
})
|
@@ -204,6 +204,7 @@ class Button extends BaseButton {
|
|
204
204
|
flag : 'filter-field',
|
205
205
|
hideLabel: true,
|
206
206
|
parentId : me.id,
|
207
|
+
style : {marginLeft: '.5em', marginRight: '.5em'},
|
207
208
|
windowId : me.windowId,
|
208
209
|
|
209
210
|
listeners: {
|
@@ -212,14 +213,10 @@ class Button extends BaseButton {
|
|
212
213
|
scope : me
|
213
214
|
},
|
214
215
|
|
215
|
-
style: {
|
216
|
-
marginLeft : '.5em',
|
217
|
-
marginRight: '.5em'
|
218
|
-
},
|
219
216
|
...me.editorConfig
|
220
217
|
});
|
221
218
|
|
222
|
-
me.vdom.cn.push(me.filterField.
|
219
|
+
me.vdom.cn.push(me.filterField.createVdomReference())
|
223
220
|
} else {
|
224
221
|
delete me.filterField.vdom.removeDom
|
225
222
|
}
|
@@ -227,6 +224,7 @@ class Button extends BaseButton {
|
|
227
224
|
me.filterField.vdom.removeDom = true
|
228
225
|
}
|
229
226
|
|
227
|
+
me.updateDepth = 2;
|
230
228
|
me.update()
|
231
229
|
}
|
232
230
|
|
package/src/tree/List.mjs
CHANGED
@@ -475,7 +475,7 @@ class Tree extends Base {
|
|
475
475
|
onStoreRecordChange(data) {
|
476
476
|
let me = this,
|
477
477
|
{record} = data,
|
478
|
-
{index, parentNode} = VDomUtil.
|
478
|
+
{index, parentNode} = VDomUtil.find(me.vdom, me.getItemId(record.id));
|
479
479
|
|
480
480
|
parentNode.cn[index] = me.createItem(record);
|
481
481
|
|
package/src/util/VDom.mjs
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import Base
|
1
|
+
import Base from '../core/Base.mjs';
|
2
|
+
import ComponentManager from '../manager/Component.mjs';
|
2
3
|
|
3
4
|
/**
|
4
5
|
* @class Neo.util.VDom
|
@@ -38,6 +39,7 @@ class VDom extends Base {
|
|
38
39
|
* Search vdom child nodes by id or opts object for a given vdom tree
|
39
40
|
* @param {Object} vdom
|
40
41
|
* @param {Object|String} opts Either an object containing vdom node attributes or a string based id
|
42
|
+
* @param {Boolean} replaceComponentRefs=true
|
41
43
|
* @param {Number} [index] Internal flag, do not use it
|
42
44
|
* @param {Object} [parentNode] Internal flag, do not use it
|
43
45
|
* @returns {Object}
|
@@ -45,10 +47,14 @@ class VDom extends Base {
|
|
45
47
|
* {String} parentId
|
46
48
|
* {Object} vdom
|
47
49
|
*/
|
48
|
-
static
|
50
|
+
static find(vdom, opts, replaceComponentRefs=true, index, parentNode) {
|
49
51
|
index = index || 0;
|
50
52
|
opts = !Neo.isString(opts) ? opts : {id: opts};
|
51
53
|
|
54
|
+
if (replaceComponentRefs) {
|
55
|
+
vdom = VDom.getVdom(vdom)
|
56
|
+
}
|
57
|
+
|
52
58
|
let child = null,
|
53
59
|
matchArray = [],
|
54
60
|
styleMatch = true,
|
@@ -72,7 +78,7 @@ class VDom extends Base {
|
|
72
78
|
}
|
73
79
|
} else if (Neo.isArray(value) && Neo.isArray(vdom[key])) {
|
74
80
|
// todo: either search the vdom array for all keys or compare if the arrays are equal.
|
75
|
-
throw new Error('
|
81
|
+
throw new Error('find: cls matching not supported for target & source types of Arrays')
|
76
82
|
}
|
77
83
|
break
|
78
84
|
case 'style':
|
@@ -91,7 +97,7 @@ class VDom extends Base {
|
|
91
97
|
matchArray.push(true)
|
92
98
|
}
|
93
99
|
} else {
|
94
|
-
throw new Error('
|
100
|
+
throw new Error('find: style matching not supported for mixed target & source types (Object VS String)')
|
95
101
|
}
|
96
102
|
break
|
97
103
|
default:
|
@@ -110,7 +116,7 @@ class VDom extends Base {
|
|
110
116
|
if (vdom.cn) {
|
111
117
|
for (; i < len; i++) {
|
112
118
|
if (vdom.cn[i]) {
|
113
|
-
subChild = VDom.
|
119
|
+
subChild = VDom.find(vdom.cn[i], opts, replaceComponentRefs, i, vdom);
|
114
120
|
|
115
121
|
if (subChild) {
|
116
122
|
child = {
|
@@ -128,14 +134,13 @@ class VDom extends Base {
|
|
128
134
|
}
|
129
135
|
|
130
136
|
/**
|
131
|
-
* Convenience shortcut for
|
137
|
+
* Convenience shortcut for find(vdom, {flag: flag});
|
132
138
|
* @param {Object} vdom
|
133
139
|
* @param {String} flag The flag reference specified on the target vdom child node
|
134
140
|
* @returns {Object} vdom
|
135
141
|
*/
|
136
142
|
static getByFlag(vdom, flag) {
|
137
|
-
|
138
|
-
return node?.vdom
|
143
|
+
return VDom.find(vdom, {flag})?.vdom
|
139
144
|
}
|
140
145
|
|
141
146
|
/**
|
@@ -145,6 +150,8 @@ class VDom extends Base {
|
|
145
150
|
* @returns {Array} childIds
|
146
151
|
*/
|
147
152
|
static getChildIds(vdom, childIds=[]) {
|
153
|
+
vdom = VDom.getVdom(vdom);
|
154
|
+
|
148
155
|
let childNodes = vdom?.cn || [];
|
149
156
|
|
150
157
|
childNodes.forEach(childNode => {
|
@@ -164,6 +171,8 @@ class VDom extends Base {
|
|
164
171
|
* @returns {Array}
|
165
172
|
*/
|
166
173
|
static getColumnNodes(vdom, index) {
|
174
|
+
vdom = VDom.getVdom(vdom);
|
175
|
+
|
167
176
|
let columnNodes = [];
|
168
177
|
|
169
178
|
vdom.cn?.forEach(row => {
|
@@ -191,6 +200,8 @@ class VDom extends Base {
|
|
191
200
|
* @returns {Array} an array of vdom nodes which match the flag
|
192
201
|
*/
|
193
202
|
static getFlags(vdom, flag, matchArray) {
|
203
|
+
vdom = VDom.getVdom(vdom);
|
204
|
+
|
194
205
|
if (!matchArray) {
|
195
206
|
matchArray = [];
|
196
207
|
|
@@ -217,6 +228,8 @@ class VDom extends Base {
|
|
217
228
|
* @returns {Array}
|
218
229
|
*/
|
219
230
|
static getParentNodes(vdom, id, topLevel=true) {
|
231
|
+
vdom = VDom.getVdom(vdom);
|
232
|
+
|
220
233
|
let parents = null,
|
221
234
|
i = 0,
|
222
235
|
len = vdom.cn?.length || 0;
|
@@ -241,6 +254,19 @@ class VDom extends Base {
|
|
241
254
|
return parents
|
242
255
|
}
|
243
256
|
|
257
|
+
/**
|
258
|
+
* Convenience shortcut using manager.Component to replace vdom references if needed
|
259
|
+
* @param {Object} vdom
|
260
|
+
* @returns {Object}
|
261
|
+
*/
|
262
|
+
static getVdom(vdom) {
|
263
|
+
if (vdom.componentId) {
|
264
|
+
vdom = ComponentManager.get(vdom.componentId).vdom
|
265
|
+
}
|
266
|
+
|
267
|
+
return vdom
|
268
|
+
}
|
269
|
+
|
244
270
|
/**
|
245
271
|
* Insert a given nodeToInsert after a targetNode inside a given vdom tree
|
246
272
|
* @param {Object} vdom The vdom tree containing the targetNode
|
@@ -276,7 +302,7 @@ class VDom extends Base {
|
|
276
302
|
targetNodeId = targetNodeId.id
|
277
303
|
}
|
278
304
|
|
279
|
-
let targetNode = VDom.
|
305
|
+
let targetNode = VDom.find(vdom, targetNodeId),
|
280
306
|
index;
|
281
307
|
|
282
308
|
if (targetNode) {
|
@@ -295,7 +321,7 @@ class VDom extends Base {
|
|
295
321
|
* @returns {Boolean} true in case the node was found & removed
|
296
322
|
*/
|
297
323
|
static removeVdomChild(vdom, opts) {
|
298
|
-
let child = VDom.
|
324
|
+
let child = VDom.find(vdom, opts);
|
299
325
|
|
300
326
|
if (child) {
|
301
327
|
child.parentNode.cn.splice(child.index, 1);
|
@@ -313,6 +339,8 @@ class VDom extends Base {
|
|
313
339
|
* @returns {Boolean} true in case the node was found and replaced
|
314
340
|
*/
|
315
341
|
static replaceVdomChild(vdom, id, newChildNode) {
|
342
|
+
vdom = VDom.getVdom(vdom);
|
343
|
+
|
316
344
|
let cn = vdom.cn || [],
|
317
345
|
i = 0,
|
318
346
|
len = cn.length,
|
@@ -347,6 +375,8 @@ class VDom extends Base {
|
|
347
375
|
*/
|
348
376
|
static syncVdomIds(vnode, vdom, force=false) {
|
349
377
|
if (vnode && vdom) {
|
378
|
+
vdom = VDom.getVdom(vdom);
|
379
|
+
|
350
380
|
let childNodes = vdom.cn,
|
351
381
|
cn, i, len;
|
352
382
|
|
@@ -363,7 +393,8 @@ class VDom extends Base {
|
|
363
393
|
}
|
364
394
|
|
365
395
|
if (childNodes) {
|
366
|
-
cn = childNodes.
|
396
|
+
cn = childNodes.map(item => VDom.getVdom(item));
|
397
|
+
cn = cn.filter(item => item.removeDom !== true);
|
367
398
|
i = 0;
|
368
399
|
len = cn?.length || 0;
|
369
400
|
|