@wavemaker/app-ng-runtime 11.4.0-next.25701 → 11.4.0-next.25703

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.
Files changed (59) hide show
  1. app-ng-runtime/build-task/basic/tree/tree.build.d.ts +2 -1
  2. app-ng-runtime/build-task/bundles/index.umd.js +9 -7
  3. app-ng-runtime/build-task/bundles/index.umd.js.map +1 -1
  4. app-ng-runtime/build-task/esm2015/basic/tree/tree.build.js +4 -3
  5. app-ng-runtime/build-task/esm2015/navigation/popover/popover.build.js +3 -3
  6. app-ng-runtime/build-task/fesm2015/index.js +9 -7
  7. app-ng-runtime/build-task/fesm2015/index.js.map +1 -1
  8. app-ng-runtime/components/base/bundles/index.umd.js +3 -6
  9. app-ng-runtime/components/base/bundles/index.umd.js.map +1 -1
  10. app-ng-runtime/components/base/esm2015/utils/widget-utils.js +4 -7
  11. app-ng-runtime/components/base/fesm2015/index.js +3 -6
  12. app-ng-runtime/components/base/fesm2015/index.js.map +1 -1
  13. app-ng-runtime/components/base/utils/widget-utils.d.ts +1 -1
  14. app-ng-runtime/components/basic/tree/bundles/index.umd.js +256 -280
  15. app-ng-runtime/components/basic/tree/bundles/index.umd.js.map +1 -1
  16. app-ng-runtime/components/basic/tree/esm2015/public_api.js +2 -2
  17. app-ng-runtime/components/basic/tree/esm2015/tree.directive.js +310 -0
  18. app-ng-runtime/components/basic/tree/esm2015/tree.module.js +3 -3
  19. app-ng-runtime/components/basic/tree/fesm2015/index.js +248 -260
  20. app-ng-runtime/components/basic/tree/fesm2015/index.js.map +1 -1
  21. app-ng-runtime/components/basic/tree/index.metadata.json +1 -1
  22. app-ng-runtime/components/basic/tree/public_api.d.ts +1 -1
  23. app-ng-runtime/components/basic/tree/tree.directive.d.ts +35 -0
  24. app-ng-runtime/components/data/list/bundles/index.umd.js +4 -28
  25. app-ng-runtime/components/data/list/bundles/index.umd.js.map +1 -1
  26. app-ng-runtime/components/data/list/esm2015/list.component.js +5 -29
  27. app-ng-runtime/components/data/list/fesm2015/index.js +4 -28
  28. app-ng-runtime/components/data/list/fesm2015/index.js.map +1 -1
  29. app-ng-runtime/components/data/list/index.metadata.json +1 -1
  30. app-ng-runtime/components/dialogs/default/bundles/index.umd.js.map +1 -1
  31. app-ng-runtime/components/dialogs/default/esm2015/base-dialog.js +1 -1
  32. app-ng-runtime/components/dialogs/default/fesm2015/index.js.map +1 -1
  33. app-ng-runtime/components/dialogs/default/index.metadata.json +1 -1
  34. app-ng-runtime/components/input/epoch/bundles/index.umd.js +21 -39
  35. app-ng-runtime/components/input/epoch/bundles/index.umd.js.map +1 -1
  36. app-ng-runtime/components/input/epoch/esm2015/base-date-time.component.js +25 -43
  37. app-ng-runtime/components/input/epoch/esm2015/date/date.component.js +3 -3
  38. app-ng-runtime/components/input/epoch/esm2015/date-time/date-time.component.js +2 -2
  39. app-ng-runtime/components/input/epoch/fesm2015/index.js +27 -45
  40. app-ng-runtime/components/input/epoch/fesm2015/index.js.map +1 -1
  41. app-ng-runtime/components/input/epoch/index.metadata.json +1 -1
  42. app-ng-runtime/components/navigation/popover/bundles/index.umd.js +4 -3
  43. app-ng-runtime/components/navigation/popover/bundles/index.umd.js.map +1 -1
  44. app-ng-runtime/components/navigation/popover/esm2015/popover.component.js +6 -5
  45. app-ng-runtime/components/navigation/popover/fesm2015/index.js +5 -4
  46. app-ng-runtime/components/navigation/popover/fesm2015/index.js.map +1 -1
  47. app-ng-runtime/package.json +1 -1
  48. app-ng-runtime/scripts/datatable/datatable.js +23 -23
  49. app-ng-runtime/variables/bundles/index.umd.js +4 -14
  50. app-ng-runtime/variables/bundles/index.umd.js.map +1 -1
  51. app-ng-runtime/variables/esm2015/manager/action/notification-action.manager.js +6 -5
  52. app-ng-runtime/variables/esm2015/service/variables.service.js +1 -8
  53. app-ng-runtime/variables/fesm2015/index.js +5 -11
  54. app-ng-runtime/variables/fesm2015/index.js.map +1 -1
  55. app-ng-runtime/variables/index.metadata.json +1 -1
  56. app-ng-runtime/variables/service/variables.service.d.ts +0 -4
  57. app-ng-runtime/components/basic/tree/esm2015/tree.component.js +0 -322
  58. app-ng-runtime/components/basic/tree/tree.component.d.ts +0 -34
  59. app-ng-runtime/scripts/tree-keyboard-navigation/keyboard-navigation.js +0 -251
@@ -1,6 +1,7 @@
1
- import { Component, ViewEncapsulation, Injector, NgModule } from '@angular/core';
1
+ import { Directive, Injector, Attribute, NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { register, PROP_STRING, PROP_ANY, PROP_NUMBER, PROP_BOOLEAN, StylableComponent, styler, APPLY_STYLES_TYPE, getOrderedDataset, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
3
+ import { register, PROP_STRING, PROP_ANY, PROP_NUMBER, PROP_BOOLEAN, StylableComponent, styler, APPLY_STYLES_TYPE, getEvaluatedData, getOrderedDataset, provideAsWidgetRef, WmComponentsModule } from '@wm/components/base';
4
+ import { $parseExpr, getClonedObject, $appDigest, $parseEvent } from '@wm/core';
4
5
 
5
6
  const registerProps = () => {
6
7
  register('wm-tree', new Map([
@@ -22,327 +23,314 @@ const registerProps = () => {
22
23
  ]));
23
24
  };
24
25
 
25
- const WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
26
26
  const defaultTreeIconClass = 'plus-minus';
27
- class TreeComponent extends StylableComponent {
28
- constructor(inj) {
27
+ const ICON_CLASSES = {
28
+ 'folder': {
29
+ 'expanded': 'wi-folder-open',
30
+ 'collapsed': 'wi-folder'
31
+ },
32
+ 'circle-plus-minus': {
33
+ 'expanded': 'wi-remove-circle-outline',
34
+ 'collapsed': 'wi-add-circle-outline'
35
+ },
36
+ 'chevron': {
37
+ 'expanded': 'wi-keyboard-arrow-down',
38
+ 'collapsed': 'wi-keyboard-arrow-right'
39
+ },
40
+ 'menu': {
41
+ 'expanded': 'wi-arrow-down',
42
+ 'collapsed': 'wi-arrow-right'
43
+ },
44
+ 'triangle': {
45
+ 'expanded': 'wi-arrow-drop-down-circle',
46
+ 'collapsed': 'wi-play-circle-filled'
47
+ },
48
+ 'expand-collapse': {
49
+ 'expanded': 'wi-expand-less',
50
+ 'collapsed': 'wi-expand-more'
51
+ },
52
+ 'plus-minus': {
53
+ 'expanded': 'wi-minus',
54
+ 'collapsed': 'wi-plus'
55
+ }
56
+ };
57
+ const WIDGET_INFO = { widgetType: 'wm-tree', hostClass: 'app-tree' };
58
+ class TreeDirective extends StylableComponent {
59
+ constructor(inj, binddatavalue, bindnodelabel, bindnodeicon, bindnodechildren, bindnodeid) {
29
60
  super(inj, WIDGET_INFO);
30
- this.setting = {
31
- data: {
32
- simpleData: {
33
- enable: true
34
- },
35
- },
36
- view: {
37
- dblClickExpand: false,
38
- fontCss: {
39
- 'font-awesome': true
40
- },
41
- switchIcon: {},
42
- },
43
- check: {},
44
- callback: {}
45
- };
61
+ this.binddatavalue = binddatavalue;
62
+ this.bindnodelabel = bindnodelabel;
63
+ this.bindnodeicon = bindnodeicon;
64
+ this.bindnodechildren = bindnodechildren;
65
+ this.bindnodeid = bindnodeid;
46
66
  styler(this.nativeElement, this, APPLY_STYLES_TYPE.CONTAINER);
67
+ this.bindEvents();
47
68
  }
48
69
  onPropertyChange(key, nv, ov) {
49
70
  switch (key) {
50
71
  case 'dataset':
51
72
  this.nodes = this.getNodes(nv);
52
- if (this.level > 0) {
53
- this.expandTree(this.level, this.nodes, 0);
54
- }
73
+ this._selectNode = undefined;
55
74
  this.renderTree();
56
75
  break;
57
- case 'levels':
58
- if (nv > 0) {
59
- this.level = nv;
60
- }
61
- break;
62
- case 'treeicons':
63
- this.treeicon = nv;
64
- break;
76
+ case 'nodeicon':
65
77
  case 'nodelabel':
66
- this.nodelabel = nv;
67
- break;
68
- case 'icon':
69
- this.nodeicon = nv;
78
+ case 'nodechildren':
70
79
  case 'orderby':
71
80
  this.renderTree();
72
81
  break;
73
- case 'class':
74
- this.treeClass = nv;
82
+ case 'treeicons':
83
+ this.changeTreeIcons(nv, ov);
84
+ break;
85
+ case 'datavalue':
86
+ this.selectById(nv);
75
87
  break;
76
88
  default:
77
89
  super.onPropertyChange(key, nv, ov);
78
- break;
79
90
  }
80
91
  }
81
- // expands the tree nodes if the property is selected.
82
- expandTree(level, node, childLevel) {
83
- node.map(childNode => {
84
- if ("children" in childNode && !("open" in childNode) && childLevel < level) {
85
- childNode["open"] = true;
86
- this.expandTree(level, childNode.children, childLevel + 1);
92
+ constructNodes(nodes, parent, levels, deep, _evalDataValue) {
93
+ const $ul = $('<ul></ul>');
94
+ const _iconClses = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
95
+ const _expr = (this.binddatavalue || this.datavalue);
96
+ let _iconCls, _cls;
97
+ _cls = levels > 0 ? ' expanded ' : ' collapsed ';
98
+ _iconCls = _cls + (levels > 0 ? _iconClses.expanded : _iconClses.collapsed);
99
+ deep = deep || 0;
100
+ parent.append($ul);
101
+ nodes.forEach((node, idx) => {
102
+ const $li = $('<li></li>'), $iconNode = $('<i></i>'), nodeLabel = getEvaluatedData(node, { field: this.nodelabel, bindExpression: this.bindnodelabel }, this.viewParent) || node.label, nodeIcon = getEvaluatedData(node, { field: this.nodeicon, bindExpression: this.bindnodeicon }, this.viewParent) || node.icon, nodeChildren = getEvaluatedData(node, { field: this.nodechildren, bindExpression: this.bindnodechildren }, this.viewParent) || node.children;
103
+ let nodeIdValue = getEvaluatedData(node, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
104
+ if (nodeIdValue === undefined) {
105
+ nodeIdValue = node.children;
106
+ }
107
+ let isNodeMatched = false, expandCollapseIcon;
108
+ $li.data('nodedata', node)
109
+ .append($iconNode)
110
+ .append(`<span class="title">${nodeLabel}</span>`)
111
+ .appendTo($ul);
112
+ // if datavalue(ie, expr) is provided select the tree node accordingly
113
+ // if datavalue === 'FirstNode' -- select the FirstNode at level 0
114
+ // if datavalue === 'LastNode' -- select the LastNode at level 0
115
+ // if datavalue is a bind expression evaluate the expression for each node of the tree till the condition is satisfied.
116
+ // if node identifier is present then verify the datavalue is bound expr or static value and compare with the node model
117
+ if (this.bindnodeid || this.nodeid) {
118
+ isNodeMatched = this.binddatavalue ? nodeIdValue === _evalDataValue : nodeIdValue === _expr;
119
+ if (nodeIdValue !== undefined) {
120
+ $li.attr('id', nodeIdValue);
121
+ }
122
+ }
123
+ else if (this.binddatavalue) { // evaluate the expression only if it is bound (useExpression)
124
+ isNodeMatched = !!$parseExpr(_expr)(this, node);
125
+ }
126
+ // Perform LastNode check only at level 0.(ie, deep = 0);
127
+ if (!this._selectNode) {
128
+ if ((_expr === 'FirstNode' && idx === 0)
129
+ || (!deep && _expr === 'LastNode' && idx === nodes.length - 1)
130
+ || isNodeMatched) {
131
+ // save a reference of the node to be selected in `_selectNode`
132
+ this._selectNode = $li;
133
+ this.datavalue = nodeIdValue;
134
+ }
135
+ }
136
+ if (nodeIcon) {
137
+ $iconNode.addClass(nodeIcon);
138
+ }
139
+ if (nodeChildren && nodeChildren.length) { // parent node
140
+ $li.addClass(`parent-node ${_cls}`);
141
+ expandCollapseIcon = $(`<i class="wi ${_iconCls}"></i>`);
142
+ if (nodeIcon) {
143
+ $iconNode.addClass(nodeIcon);
144
+ }
145
+ $li.prepend(expandCollapseIcon);
146
+ this.constructNodes(nodeChildren, $li, levels - 1, deep + 1, _evalDataValue);
87
147
  }
88
148
  else {
89
- childLevel = 0;
90
- return;
149
+ if (!nodeIcon) {
150
+ $iconNode.addClass('leaf-node');
151
+ }
152
+ $li.addClass('leaf-node');
91
153
  }
92
154
  });
93
155
  }
94
- // sets the template for the tree based on the property selected.
95
- setTreeTemplate(value) {
96
- if (value === 'Classic') {
97
- this.setting.check["enable"] = false;
98
- }
99
- else if (value === 'Checkbox') {
100
- this.setting.check["enable"] = true;
101
- this.setting.check["chkStyle"] = 'checkbox';
102
- }
103
- else if (value === 'Radio') {
104
- this.setting.check["enable"] = true;
105
- this.setting.check["chkStyle"] = 'radio';
106
- this.setting.check["radioType"] = "all";
107
- }
108
- }
109
- // extracts nodes from string format
110
156
  getNodesFromString(value) {
111
157
  return value.split(',').map((item) => {
112
158
  return {
113
- 'name': item && item.trim()
159
+ 'label': item && item.trim()
114
160
  };
115
161
  });
116
162
  }
117
- // gets the nodes and orders the nodes if required
118
163
  getNodes(newVal) {
119
164
  let nodes;
120
- if (_.isArray(newVal)) {
121
- nodes = getOrderedDataset(newVal, this.orderby);
122
- }
123
- else if (_.isObject(newVal)) {
124
- nodes = [newVal];
125
- }
126
- else if (_.isString(newVal) && !_.isEmpty(newVal)) {
165
+ if (_.isString(newVal) && !_.isEmpty(newVal)) {
127
166
  newVal = newVal.trim();
128
167
  if (newVal) {
129
168
  nodes = this.getNodesFromString(newVal);
130
169
  }
131
170
  }
132
- return nodes;
133
- }
134
- // adds class to the nodes inorder to add icons to respective node.
135
- setNodeclasses(treeId, treeNode) {
136
- return treeNode.icon ? { add: [`${treeNode.icon}`] } : '';
137
- }
138
- ;
139
- // Sets the node label with any icon if bound to
140
- setNodeData(nodes, depth, level, parentNode, type) {
141
- if (depth === 0) {
142
- nodes.map(node => {
143
- if (node.children) {
144
- this.setNodeData(node.children, depth, level, parentNode, type);
145
- }
146
- if (node.icon && this.nodelabel == 'icon') {
147
- node[type] = node.icon;
148
- }
149
- else if (node.name && this.nodelabel == 'name') {
150
- node[type] = node.name;
151
- }
152
- else {
153
- return;
154
- }
155
- });
156
- }
157
- else {
158
- nodes.map(node => {
159
- if (node.children && level > 1) {
160
- if (depth === level) {
161
- parentNode = node;
162
- }
163
- this.setNodeData(node.children, depth, level - 1, parentNode, type);
164
- }
165
- if (level === 1 && (type === "name" ? this.nodelabel.includes("label") || this.nodelabel.includes("name") : this.nodeicon.includes("label") || this.nodeicon.includes("name"))) {
166
- parentNode[type] = node.name || node.label;
167
- return;
168
- }
169
- else if (level === 1 && (node.icon !== undefined) && (type === "name" ? this.nodelabel.includes("icon") : this.nodeicon.includes("icon"))) {
170
- parentNode[type] = node.icon;
171
- return;
172
- }
173
- else {
174
- return;
175
- }
176
- });
177
- }
178
- }
179
- // adds tree icons to the nodes on load of the tree
180
- changeTreeIcons(nv) {
181
- let eleClose = $('ul[name="' + this.name + '"] li span.button.switch');
182
- $(eleClose).map((idx, ele) => {
183
- $(ele).addClass(nv);
184
- $(ele).on("click", function (e) {
185
- setTimeout(() => {
186
- $(ele).addClass(nv);
187
- }, 0);
188
- });
189
- });
190
- }
191
- getPath(treeNode, path) {
192
- if (treeNode.getParentNode() === null) {
193
- path = "/" + treeNode.name + path;
171
+ else if (_.isArray(newVal)) {
172
+ newVal = getOrderedDataset(newVal, this.orderby);
173
+ nodes = newVal;
194
174
  }
195
- else {
196
- path = this.getPath(treeNode.getParentNode(), path) + "/" + treeNode.name;
175
+ else if (_.isObject(newVal)) {
176
+ nodes = [newVal];
197
177
  }
198
- return path;
199
- }
200
- // binds the click event to all nodes to open the child nodes
201
- onClick(event, treeId, treeNode, clickFlag) {
202
- var treeObj = $.fn.zTree.getZTreeObj(`${this.name}`);
203
- let path = this.getPath(treeNode, "");
204
- const eventParams = {
205
- '$event': event,
206
- "$item": treeNode,
207
- "$path": path
208
- };
209
- this.invokeEventCallback('select', eventParams);
178
+ return nodes;
210
179
  }
211
- // Adds tree icon classes to child nodes when expanded
212
- onExpand(event, treeId, treeNode) {
213
- let self = this;
214
- let path = this.getPath(treeNode, "");
215
- const eventParams = {
216
- '$event': event,
217
- "$item": treeNode,
218
- "$path": path
219
- };
220
- this.invokeEventCallback('expand', eventParams);
221
- treeNode.children ? treeNode.children.map((el) => {
222
- if (el.isParent) {
223
- let ele = $(`#${el.tId}_switch`);
224
- $(ele).addClass(self.treeicon || defaultTreeIconClass);
225
- $(ele).on("click", function (e) {
226
- setTimeout(() => {
227
- $(ele).addClass(self.treeicon || defaultTreeIconClass);
228
- }, 0);
229
- });
230
- }
231
- }) : '';
180
+ changeTreeIcons(nv, ov) {
181
+ const $el = $(this.nativeElement);
182
+ nv = nv || defaultTreeIconClass;
183
+ ov = ov || defaultTreeIconClass;
184
+ $el.find('i.expanded').removeClass(ICON_CLASSES[ov].expanded).addClass(ICON_CLASSES[nv].expanded);
185
+ $el.find('i.collapsed').removeClass(ICON_CLASSES[ov].collapsed).addClass(ICON_CLASSES[nv].collapsed);
232
186
  }
233
- onCollapse(event, treeId, treeNode) {
234
- let path = this.getPath(treeNode, "");
187
+ toggleExpandCollapseNode($event, $i, $li) {
188
+ const treeIcons = ICON_CLASSES[this.treeicons || defaultTreeIconClass];
189
+ const $liPath = this.findSelectedNodeParent($li);
190
+ let path = '';
191
+ // construct the path of the node
192
+ $liPath
193
+ .each((i, el) => {
194
+ const current = $(el).children('.title').text();
195
+ path = `/${current + path}`;
196
+ });
235
197
  const eventParams = {
236
- '$event': event,
237
- "$item": treeNode,
198
+ '$event': $event,
199
+ "$item": $li.data('nodedata'),
238
200
  "$path": path
239
201
  };
240
- this.invokeEventCallback('collapse', eventParams);
202
+ if ($i.hasClass('collapsed')) {
203
+ $i.removeClass(`collapsed ${treeIcons.collapsed}`).addClass(`expanded ${treeIcons.expanded}`);
204
+ $li.removeClass('collapsed').addClass('expanded');
205
+ this.invokeEventCallback('expand', eventParams);
206
+ }
207
+ else if ($i.hasClass('expanded')) {
208
+ $i.removeClass(`expanded ${treeIcons.expanded}`).addClass(`collapsed ${treeIcons.collapsed}`);
209
+ $li.removeClass('expanded').addClass('collapsed');
210
+ this.invokeEventCallback('collapse', eventParams);
211
+ }
241
212
  }
242
- // function to support backward compatibility of objects
243
- modifyObjects(array) {
244
- array.forEach(obj => {
245
- if (obj.label !== undefined) {
246
- obj.name = obj.label;
247
- delete obj.label;
248
- }
249
- if (obj.children !== undefined) {
250
- this.modifyObjects(obj.children);
213
+ renderTree(forceRender) {
214
+ let docFrag, $li, $liPath, data, path = '';
215
+ const levels = +this.nativeElement.getAttribute('levels') || 0, $el = $(this.nativeElement);
216
+ $el.empty();
217
+ if (forceRender) {
218
+ this._selectNode = undefined;
219
+ }
220
+ if (this.nodes && this.nodes.length) {
221
+ docFrag = document.createDocumentFragment();
222
+ this.constructNodes(this.nodes, $(docFrag), levels, 0, this.datavalue);
223
+ $el.append(docFrag);
224
+ }
225
+ if (this._selectNode) {
226
+ $li = this._selectNode;
227
+ $li.addClass('selected');
228
+ data = $li.data('nodedata');
229
+ $liPath = this.findSelectedNodeParent($li);
230
+ if (!$liPath.length) {
231
+ $liPath = $li;
251
232
  }
252
- });
253
- return array;
233
+ $liPath
234
+ .each((i, el) => {
235
+ const $current = $(el), $i = $current.children('i.collapsed'), $title = $current.children('.title');
236
+ this.toggleExpandCollapseNode(undefined, $i, $current);
237
+ path = `/${$title.text() + path}`;
238
+ });
239
+ this.selecteditem = getClonedObject(data) || {};
240
+ this.selecteditem.path = path;
241
+ this.invokeEventCallback('select', { $event: undefined, $item: data, $path: path });
242
+ $appDigest();
243
+ }
254
244
  }
255
- // sets the node children property to parent nodes
256
- setNodeChildren(nodes, depth, level, parentNode) {
257
- if (depth <= 0) {
258
- return nodes;
245
+ selectNode(evt, value) {
246
+ const target = evt && $(evt.target), $el = $(this.nativeElement), $li = _.isObject(value) ? value : $el.find(`li[id="${value}"]`).first();
247
+ let data, path = '', $liPath, nodeAction;
248
+ $el.find('.selected').removeClass('selected');
249
+ if (!$li.length) {
250
+ return;
259
251
  }
260
- for (let i = 0; i < nodes.length; i++) {
261
- const node = nodes[i];
262
- if (depth === level) {
263
- parentNode = nodes[i];
252
+ $li.addClass('selected');
253
+ data = $li.data('nodedata');
254
+ nodeAction = data[this.nodeaction || 'action'];
255
+ // if the selectNode is initiated by click event then use the nativeElement target from event
256
+ $liPath = target ? target.parents('.app-tree li') : this.findSelectedNodeParent($li);
257
+ // construct the path of the node
258
+ $liPath
259
+ .each((i, el) => {
260
+ const current = $(el).children('.title').text();
261
+ path = `/${current + path}`;
262
+ });
263
+ // expand the current node till the viewParent level which is collapsed
264
+ $li.parentsUntil($el, 'li.parent-node.collapsed')
265
+ .each((index, el) => {
266
+ const $current = $(el), $i = $current.children('i.collapsed');
267
+ this.toggleExpandCollapseNode(undefined, $i, $current);
268
+ });
269
+ this.selecteditem = getClonedObject(data) || {};
270
+ this.selecteditem.path = path;
271
+ if (target) {
272
+ if (this.nodeid || this.bindnodeid) {
273
+ this.datavalue = getEvaluatedData(data, { field: this.nodeid, bindExpression: this.bindnodeid }, this.viewParent);
264
274
  }
265
- if (node.children && node.children.length > 0) {
266
- if (level === 1) {
267
- parentNode.children = node.children.map(child => ({ name: child.name, children: child === null || child === void 0 ? void 0 : child.children }));
268
- return;
269
- }
270
- else {
271
- this.setNodeChildren(node.children, depth, level - 1, parentNode);
272
- }
275
+ else {
276
+ this.datavalue = getClonedObject(data) || {};
273
277
  }
274
278
  }
275
- return nodes;
276
- }
277
- countDepth(str) {
278
- const regex = /\[.*?\]/g;
279
- let matches = str.match(regex);
280
- let count = 1;
281
- if (matches === null)
282
- return count;
283
- for (let match of matches) {
284
- count++;
279
+ else {
280
+ this.datavalue = value;
281
+ }
282
+ //[Todo-CSP]: this data will be dynamic, can not generate function upfront
283
+ if (nodeAction) {
284
+ $parseEvent(nodeAction)(this);
285
285
  }
286
- return count;
286
+ this.invokeEventCallback('select', { $event: evt, $item: data, $path: path });
287
+ $appDigest();
287
288
  }
288
- // Renders the tree on to the dom
289
- renderTree() {
290
- console.log(this.nodes, 'this.nodes');
291
- if (this.nodes) {
292
- this.nativeElement.setAttribute('id', this.name);
293
- this.nodes = this.modifyObjects(this.nodes);
294
- this.setTreeTemplate(this.treeClass);
295
- if (this.nodelabel) {
296
- let depth = 0;
297
- if (this.nodelabel.includes("children")) {
298
- depth = this.countDepth(this.nodelabel);
299
- }
300
- this.setNodeData(this.nodes, depth, depth, null, "name");
289
+ // click event is added on the host nativeElement
290
+ bindEvents() {
291
+ $(this.nativeElement).on('click', (evt) => {
292
+ const target = $(evt.target), li = target.closest('li'), $i = target.is('i') ? target : target.siblings('i.collapsed,i.expanded');
293
+ evt.stopPropagation();
294
+ if (target.is('span.title')) { // select the node only if it is nodelabel
295
+ this.selecteditem = {};
296
+ this.selectNode(evt, li);
301
297
  }
302
- if (this.nodeicon) {
303
- let depth = 0;
304
- if (this.nodeicon.includes("children")) {
305
- depth = this.countDepth(this.nodeicon);
306
- }
307
- this.setNodeData(this.nodes, depth, depth, null, "icon");
308
- }
309
- if (this.nodechildren) {
310
- let depth = this.countDepth(this.nodechildren);
311
- if (depth > 1) {
312
- this.nodes = this.setNodeChildren(this.nodes, depth, depth, null);
313
- }
298
+ if (target.is('i') || (target.is('span.title') && this.nodeclick === 'expand')) {
299
+ this.toggleExpandCollapseNode(evt, $i, li);
314
300
  }
315
- }
316
- this.setting.view['nodeClasses'] = this.setNodeclasses;
317
- this.setting.callback["onClick"] = this.onClick.bind(this);
318
- this.setting.callback["onExpand"] = this.onExpand.bind(this);
319
- this.setting.callback["onCollapse"] = this.onCollapse.bind(this);
320
- let zTree = $.fn.zTree.init($('ul[name="' + this.name + '"]'), this.setting, this.nodes);
321
- $.fn.zTreeKeyboardNavigation(zTree, $('ul[name="' + this.name + '"]'), null, this.treeicon || defaultTreeIconClass);
301
+ });
302
+ }
303
+ findSelectedNodeParent($li) {
304
+ return $li.find('> span.title').parents('.app-tree li');
322
305
  }
323
- ngAfterViewInit() {
324
- setTimeout(() => {
325
- this.changeTreeIcons(this.treeicon || defaultTreeIconClass);
326
- }, 200);
306
+ selectById(value) {
307
+ this.selectNode(undefined, value);
308
+ }
309
+ deselectById(value) {
310
+ this.selecteditem = {};
311
+ this.selectById();
327
312
  }
328
313
  }
329
- TreeComponent.initializeProps = registerProps();
330
- TreeComponent.decorators = [
331
- { type: Component, args: [{
332
- selector: 'ul[wmTree]',
333
- template: "<ul #wmTree class=\"ztree\" id=\"ztree\"></ul> ",
314
+ TreeDirective.initializeProps = registerProps();
315
+ TreeDirective.decorators = [
316
+ { type: Directive, args: [{
317
+ selector: 'div[wmTree]',
334
318
  providers: [
335
- provideAsWidgetRef(TreeComponent)
336
- ],
337
- encapsulation: ViewEncapsulation.None
319
+ provideAsWidgetRef(TreeDirective)
320
+ ]
338
321
  },] }
339
322
  ];
340
- TreeComponent.ctorParameters = () => [
341
- { type: Injector }
323
+ TreeDirective.ctorParameters = () => [
324
+ { type: Injector },
325
+ { type: undefined, decorators: [{ type: Attribute, args: ['datavalue.bind',] }] },
326
+ { type: undefined, decorators: [{ type: Attribute, args: ['nodelabel.bind',] }] },
327
+ { type: undefined, decorators: [{ type: Attribute, args: ['nodeicon.bind',] }] },
328
+ { type: undefined, decorators: [{ type: Attribute, args: ['nodechildren.bind',] }] },
329
+ { type: undefined, decorators: [{ type: Attribute, args: ['nodeid.bind',] }] }
342
330
  ];
343
331
 
344
332
  const components = [
345
- TreeComponent
333
+ TreeDirective
346
334
  ];
347
335
  class TreeModule {
348
336
  }
@@ -362,5 +350,5 @@ TreeModule.decorators = [
362
350
  * Generated bundle index. Do not edit.
363
351
  */
364
352
 
365
- export { TreeComponent, TreeModule, registerProps as ɵa };
353
+ export { TreeDirective, TreeModule, registerProps as ɵa };
366
354
  //# sourceMappingURL=index.js.map