tsichart-core 1.0.4 → 2.0.0-beta.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.
Files changed (133) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +80 -0
  3. package/dist/index.d.ts +1744 -0
  4. package/dist/index.js +14284 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +14209 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/{tsiclient.css → styles/index.css} +9388 -9387
  9. package/dist/styles/index.css.map +1 -0
  10. package/package.json +115 -125
  11. package/README.MD +0 -171
  12. package/dist/AggregateExpression.d.ts +0 -13
  13. package/dist/AggregateExpression.js +0 -70
  14. package/dist/AvailabilityChart-vciRThEz.js +0 -488
  15. package/dist/AvailabilityChart.d.ts +0 -59
  16. package/dist/AvailabilityChart.js +0 -26
  17. package/dist/ChartComponent-BxPbycj0.js +0 -302
  18. package/dist/ChartComponent-L_dR-Eny.d.ts +0 -80
  19. package/dist/ChartComponentData-ClzAtU_E.d.ts +0 -47
  20. package/dist/ChartDataOptions-DBu_M5gU.d.ts +0 -38
  21. package/dist/ChartDataOptions-rcIzlQJO.js +0 -49
  22. package/dist/ChartVisualizationComponent-CswB2P7Z.d.ts +0 -8
  23. package/dist/ChartVisualizationComponent-NsvZCsc-.js +0 -23
  24. package/dist/ColorPicker-CUZt1uup.js +0 -120
  25. package/dist/ColorPicker.d.ts +0 -28
  26. package/dist/ColorPicker.js +0 -6
  27. package/dist/Component-C9fQU2ia.js +0 -401
  28. package/dist/Component-CdI_Pyko.d.ts +0 -226
  29. package/dist/ContextMenu-CP1qV7pP.js +0 -197
  30. package/dist/DateTimeButton-Ck71nL87.d.ts +0 -16
  31. package/dist/DateTimeButton-DnqhATyX.js +0 -38
  32. package/dist/DateTimeButtonRange-CT1zOoCf.js +0 -71
  33. package/dist/DateTimeButtonRange.d.ts +0 -19
  34. package/dist/DateTimeButtonRange.js +0 -15
  35. package/dist/DateTimeButtonSingle-DZk5fW35.js +0 -48
  36. package/dist/DateTimeButtonSingle.d.ts +0 -17
  37. package/dist/DateTimeButtonSingle.js +0 -14
  38. package/dist/DateTimePicker-CuGwz86U.js +0 -532
  39. package/dist/DateTimePicker.d.ts +0 -69
  40. package/dist/DateTimePicker.js +0 -13
  41. package/dist/EllipsisMenu-CNWSo-qQ.js +0 -116
  42. package/dist/EllipsisMenu.d.ts +0 -20
  43. package/dist/EllipsisMenu.js +0 -6
  44. package/dist/Enums-CEhu18PC.d.ts +0 -12
  45. package/dist/EventsTable-mjoOfc0E.js +0 -553
  46. package/dist/EventsTable.d.ts +0 -34
  47. package/dist/EventsTable.js +0 -10
  48. package/dist/GeoProcessGraphic-CSsTL4zj.js +0 -145
  49. package/dist/GeoProcessGraphic.d.ts +0 -34
  50. package/dist/GeoProcessGraphic.js +0 -7
  51. package/dist/Grid-ByDh3Qdn.js +0 -874
  52. package/dist/Grid.d.ts +0 -43
  53. package/dist/Grid.js +0 -6
  54. package/dist/GroupedBarChart-DrSrSHNj.js +0 -579
  55. package/dist/GroupedBarChart.d.ts +0 -22
  56. package/dist/GroupedBarChart.js +0 -17
  57. package/dist/GroupedBarChartData-CpJKvTDQ.js +0 -121
  58. package/dist/GroupedBarChartData-DK30DLVh.d.ts +0 -20
  59. package/dist/Heatmap-BbWcAgp6.js +0 -524
  60. package/dist/Heatmap.d.ts +0 -31
  61. package/dist/Heatmap.js +0 -14
  62. package/dist/Hierarchy-BsvoKnCY.js +0 -260
  63. package/dist/Hierarchy.d.ts +0 -39
  64. package/dist/Hierarchy.js +0 -6
  65. package/dist/HierarchyNavigation-C5yoj--u.js +0 -336
  66. package/dist/HierarchyNavigation.d.ts +0 -34
  67. package/dist/HierarchyNavigation.js +0 -6
  68. package/dist/HistoryPlayback-DIhAsAOi.d.ts +0 -68
  69. package/dist/HistoryPlayback-DiflRzRf.js +0 -175
  70. package/dist/Interfaces-CdAVFIA6.d.ts +0 -6
  71. package/dist/Legend-CQ5yaF8f.js +0 -497
  72. package/dist/LineChart-DcUenMrZ.js +0 -3181
  73. package/dist/LineChart.d.ts +0 -163
  74. package/dist/LineChart.js +0 -18
  75. package/dist/ModelAutocomplete-sxVy4m65.js +0 -100
  76. package/dist/ModelAutocomplete.d.ts +0 -12
  77. package/dist/ModelAutocomplete.js +0 -7
  78. package/dist/ModelSearch-DEg5KwKw.js +0 -189
  79. package/dist/ModelSearch.d.ts +0 -23
  80. package/dist/ModelSearch.js +0 -9
  81. package/dist/PieChart-DDxMXcXE.js +0 -258
  82. package/dist/PieChart.d.ts +0 -26
  83. package/dist/PieChart.js +0 -17
  84. package/dist/PlaybackControls-DSoUncDP.js +0 -195
  85. package/dist/PlaybackControls.d.ts +0 -39
  86. package/dist/PlaybackControls.js +0 -13
  87. package/dist/ProcessGraphic-1f-FoGDy.js +0 -154
  88. package/dist/ProcessGraphic.d.ts +0 -31
  89. package/dist/ProcessGraphic.js +0 -7
  90. package/dist/README.MD +0 -171
  91. package/dist/ScatterPlot-BAn6r8ml.js +0 -924
  92. package/dist/ScatterPlot.d.ts +0 -115
  93. package/dist/ScatterPlot.js +0 -17
  94. package/dist/SingleDateTimePicker-BrFB5iPu.js +0 -213
  95. package/dist/SingleDateTimePicker.d.ts +0 -45
  96. package/dist/SingleDateTimePicker.js +0 -12
  97. package/dist/Slider-BpNCqoBD.js +0 -186
  98. package/dist/Slider.d.ts +0 -31
  99. package/dist/Slider.js +0 -6
  100. package/dist/TemporalXAxisComponent-BsTQyVO6.js +0 -129
  101. package/dist/TemporalXAxisComponent-DohbI08i.d.ts +0 -23
  102. package/dist/TimezonePicker-DHkC2iKE.js +0 -58
  103. package/dist/TimezonePicker.d.ts +0 -16
  104. package/dist/TimezonePicker.js +0 -10
  105. package/dist/Tooltip-B-mIKo4g.js +0 -104
  106. package/dist/TsqExpression.d.ts +0 -36
  107. package/dist/TsqExpression.js +0 -89
  108. package/dist/UXClient-BTulvzpq.js +0 -230
  109. package/dist/UXClient.d.ts +0 -74
  110. package/dist/UXClient.js +0 -47
  111. package/dist/Utils-CdKMmmwx.js +0 -1138
  112. package/dist/Utils-ChzaAbch.d.ts +0 -104
  113. package/dist/Utils.d.ts +0 -7
  114. package/dist/Utils.js +0 -7
  115. package/dist/_tslib-DYvz7dIO.js +0 -96
  116. package/dist/package.json +0 -125
  117. package/dist/pikaday-C_DS7oEN.js +0 -1252
  118. package/dist/tsiclient.cjs.js +0 -3
  119. package/dist/tsiclient.cjs.js.LICENSE.txt +0 -19
  120. package/dist/tsiclient.cjs.js.map +0 -1
  121. package/dist/tsiclient.d.ts +0 -46
  122. package/dist/tsiclient.esm.js +0 -3
  123. package/dist/tsiclient.esm.js.LICENSE.txt +0 -19
  124. package/dist/tsiclient.esm.js.map +0 -1
  125. package/dist/tsiclient.js +0 -58
  126. package/dist/tsiclient.min.css +0 -6
  127. package/dist/tsiclient.min.css.map +0 -1
  128. package/dist/tsiclient.umd.js +0 -3
  129. package/dist/tsiclient.umd.js.LICENSE.txt +0 -19
  130. package/dist/tsiclient.umd.js.map +0 -1
  131. package/dist/tsiclient.umd.min.js +0 -3
  132. package/dist/tsiclient.umd.min.js.LICENSE.txt +0 -19
  133. package/dist/tsiclient.umd.min.js.map +0 -1
@@ -1,260 +0,0 @@
1
- import { _ as __extends } from './_tslib-DYvz7dIO.js';
2
- import * as d3 from 'd3';
3
- import { U as Utils } from './Utils-CdKMmmwx.js';
4
- import { C as Component } from './Component-C9fQU2ia.js';
5
-
6
- var HierarchyNode = /** @class */ (function () {
7
- function HierarchyNode(name, level) {
8
- this.children = [];
9
- this.isExpanded = false;
10
- this.isSelected = false;
11
- this.isLeaf = false;
12
- this.childrenInFilter = false;
13
- this.selfInFilter = false;
14
- this.color = function () { return null; };
15
- this.click = function (n) { };
16
- this.isLeafParent = false; // used in the event of context menut to denote that we should use a context menu for children
17
- this.name = name;
18
- this.level = level;
19
- this.markedName = name;
20
- }
21
- HierarchyNode.prototype.filter = function (filterText) {
22
- var regExp = new RegExp(filterText, 'i');
23
- var isInFilter = function (node) {
24
- var childrenInFilter = node.children.reduce(function (p, c) {
25
- p = isInFilter(c) || p;
26
- return p;
27
- }, false);
28
- var selfInFilter = regExp.test(node.name);
29
- node.markedName = selfInFilter ? Utils.mark(filterText, node.name) : node.name;
30
- if (node.parent != null)
31
- node.parent.childrenInFilter = (selfInFilter || childrenInFilter) && filterText.length > 0;
32
- node.selfInFilter = selfInFilter && filterText.length > 0;
33
- node.childrenInFilter = childrenInFilter && filterText.length > 0;
34
- return childrenInFilter || selfInFilter;
35
- };
36
- isInFilter(this);
37
- };
38
- HierarchyNode.prototype.traverse = function (condition) {
39
- var traversal = [];
40
- if (condition(this))
41
- traversal.push(this);
42
- this.children.forEach(function (n) {
43
- traversal = traversal.concat(n.traverse(condition));
44
- });
45
- return traversal;
46
- };
47
- HierarchyNode.prototype.colorify = function (el) {
48
- if (this.isLeaf && this.isSelected && this.color(this))
49
- el.style('background-color', this.color(this));
50
- if (!this.isSelected && this.isLeaf)
51
- el.style('background-color', null);
52
- };
53
- return HierarchyNode;
54
- }());
55
-
56
- var Hierarchy = /** @class */ (function (_super) {
57
- __extends(Hierarchy, _super);
58
- function Hierarchy(renderTarget) {
59
- var _this = _super.call(this, renderTarget) || this;
60
- _this.filterText = '';
61
- _this.withContextMenu = false;
62
- _this.expandCollapseList = function (node, el, isFromClick, event) {
63
- if (isFromClick === void 0) { isFromClick = false; }
64
- _this.closeContextMenu();
65
- if (el.classed('tsi-expanded') && !(_this.withContextMenu && node.isLeafParent)) {
66
- el.selectAll('ul').remove();
67
- el.classed('tsi-expanded', false);
68
- node.isExpanded = false;
69
- }
70
- else {
71
- if (_this.withContextMenu && node.isLeafParent) {
72
- if (_this.clickedNode != el.node()) {
73
- _this.clickedNode = el.node();
74
- _this.contextMenu = _this.hierarchyList.append('div');
75
- node.children.filter(function (n) { return n.name[0] !== '~'; }).forEach(function (n) {
76
- _this.contextMenu.append('div').text("".concat(n.name)).on('click', function () { return n.click(n); });
77
- });
78
- _this.contextMenu.append('div').classed('tsi-break', true);
79
- node.children.filter(function (n) { return n.name[0] === '~'; }).forEach(function (n) {
80
- var noTildeName = n.name.slice(1);
81
- _this.contextMenu.append('div').text("".concat(noTildeName)).on('click', function () { return n.click(n); });
82
- });
83
- _this.contextMenu.classed('tsi-hierarchyContextMenu', true);
84
- if (event) {
85
- var mouseWrapper_1 = d3.pointer(event, _this.hierarchyList.node());
86
- var mouseElt_1 = d3.pointer(event, el.node());
87
- _this.contextMenu.attr('style', function () { return "top: ".concat(mouseWrapper_1[1] - mouseElt_1[1], "px"); });
88
- }
89
- el.classed('tsi-resultSelected', true);
90
- _this.hierarchyList.selectAll('.tsi-noPad').on('scroll', function () { _this.closeContextMenu(); });
91
- }
92
- else {
93
- _this.clickedNode = null;
94
- }
95
- }
96
- else {
97
- var list = el.append('ul');
98
- node.children.forEach(function (n) {
99
- if (isFromClick || n.selfInFilter || n.childrenInFilter || (node.isExpanded && _this.filterText.length == 0)) {
100
- var self = _this;
101
- var clickMethod = function () {
102
- if (n.isLeaf) {
103
- var parent = n.parent;
104
- while (parent != this.root) {
105
- parent.isExpanded = true;
106
- parent = parent.parent;
107
- }
108
- n.isSelected = !n.isSelected;
109
- n.click(n);
110
- var selector = d3.select(this);
111
- n.colorify(selector);
112
- selector.classed('tsi-selected', n.isSelected);
113
- }
114
- else {
115
- self.expandCollapseList(n, d3.select(this), true, event);
116
- }
117
- event.stopPropagation();
118
- };
119
- var li = list.append('li').classed('tsi-leaf', n.isLeaf)
120
- .classed('tsi-leafParent', n.isLeafParent && _this.withContextMenu)
121
- .classed('tsi-selected', n.isSelected).on('click', clickMethod);
122
- li.append('span').classed('tsi-caret', true).attr('style', "left: ".concat((n.level - 1) * 18, "px"));
123
- li.append('span').classed('tsi-markedName', true).html(n.markedName) // known unsafe usage of .html
124
- .attr('style', "padding-left: ".concat(40 + (n.level - 1) * 18 - (n.isLeafParent && _this.withContextMenu ? 16 : 0), "px"))
125
- .attr('title', n.isLeafParent && _this.withContextMenu ? n.name : '');
126
- n.colorify(li);
127
- if ((n.isExpanded || n.childrenInFilter) && !n.isLeaf) {
128
- _this.expandCollapseList(n, li, isFromClick, event);
129
- }
130
- }
131
- });
132
- node.isExpanded = (node.isExpanded || isFromClick) || (node == _this.root);
133
- el.classed('tsi-expanded', true);
134
- }
135
- }
136
- };
137
- return _this;
138
- }
139
- Hierarchy.prototype.render = function (data, options) {
140
- var _this = this;
141
- var self = this;
142
- var targetElement = d3.select(this.renderTarget).classed('tsi-hierarchy', true);
143
- targetElement.html('');
144
- this.chartOptions.setOptions(options);
145
- _super.prototype.themify.call(this, targetElement, this.chartOptions.theme);
146
- this.withContextMenu = this.chartOptions.withContextMenu;
147
- this.root = this.buildTree(data);
148
- this.root.isExpanded = true;
149
- d3.select("html").on("click." + Utils.guid(), function (event) {
150
- if (_this.clickedNode && event.target != _this.clickedNode && _this.contextMenu) {
151
- _this.closeContextMenu();
152
- _this.clickedNode = null;
153
- }
154
- });
155
- var inputDebounceTimeout;
156
- var filter = targetElement.append('div').classed('tsi-filterWrapper', true).append('input').attr('placeholder', 'Search...').on('input', function (event) {
157
- var _this = this;
158
- clearTimeout(inputDebounceTimeout);
159
- inputDebounceTimeout = setTimeout(function () {
160
- self.filterText = _this.value.trim();
161
- if (self.filterText.length == 1)
162
- return; // quick return for small sets
163
- var splitFilterText = self.filterText.split('/');
164
- self.root.filter(splitFilterText[0]);
165
- if (splitFilterText.length > 1) {
166
- for (var i = 1; i < splitFilterText.length; i++) {
167
- if (splitFilterText[i].length) {
168
- var nodesInFilter = self.root.traverse(function (n) { return n.selfInFilter; });
169
- nodesInFilter.forEach(function (n) {
170
- var markedName = n.markedName;
171
- n.filter(splitFilterText[i], false);
172
- n.markedName = markedName;
173
- });
174
- nodesInFilter.forEach(function (n) {
175
- if (!n.childrenInFilter)
176
- n.selfInFilter = false;
177
- });
178
- }
179
- }
180
- }
181
- list.selectAll('ul').remove();
182
- list.classed('tsi-expanded', false);
183
- self.root.childrenInFilter = self.root.childrenInFilter || self.filterText.length == 0;
184
- if (self.root.childrenInFilter == false)
185
- list.append('ul').append('div').text(self.getString('No filter results'));
186
- else
187
- self.expandCollapseList(self.root, list, false, event);
188
- list.select('ul').classed('tsi-noPad', true);
189
- }, 250);
190
- });
191
- var navTabs = targetElement.append('div').classed('tsi-navTabWrapper', true);
192
- var allTab = navTabs.append('div').classed('tsi-navTab tsi-selected', true).text(this.getString('All hierarchies'));
193
- var selectedTab = navTabs.append('div').classed('tsi-navTab', true).text(this.getString('Selected'));
194
- var list = targetElement.append('div').classed('tsi-hierarchyList', true);
195
- this.hierarchyList = list;
196
- allTab.on('click', function (event) {
197
- if (!allTab.classed('tsi-selected')) {
198
- allTab.classed('tsi-selected', true);
199
- selectedTab.classed('tsi-selected', false);
200
- list.html('').classed('tsi-expanded', false);
201
- _this.expandCollapseList(_this.root, list, true, event);
202
- list.select('ul').classed('tsi-noPad', true);
203
- filter.attr('disabled', null);
204
- }
205
- });
206
- selectedTab.on('click', function () {
207
- if (!selectedTab.classed('tsi-selected')) {
208
- allTab.classed('tsi-selected', false);
209
- selectedTab.classed('tsi-selected', true);
210
- list.html('');
211
- var ul = list.append('ul').classed('tsi-noPad', true);
212
- var leafs = _this.root.traverse(function (n) { return n.isSelected; });
213
- leafs.forEach(function (n) {
214
- var li = ul.append('li').classed('tsi-leaf', n.isLeaf).classed('tsi-selected', n.isSelected).on('click', function () {
215
- n.isSelected = !n.isSelected;
216
- d3.select(this).classed('tsi-selected', n.isSelected);
217
- n.click(n);
218
- n.colorify(d3.select(this));
219
- });
220
- li.append('span').text(n.name).classed('tsi-markedName', true);
221
- n.colorify(li);
222
- });
223
- filter.attr('disabled', true);
224
- }
225
- });
226
- this.expandCollapseList(this.root, list, false);
227
- list.select('ul').classed('tsi-noPad', true);
228
- };
229
- Hierarchy.prototype.buildTree = function (data) {
230
- var traverse = function (data, key, level, parent) {
231
- if (parent === void 0) { parent = null; }
232
- var node = new HierarchyNode(key, level);
233
- node.parent = parent;
234
- if (data.hasOwnProperty('$leaf')) {
235
- node.isLeaf = true;
236
- if (data.hasOwnProperty('click'))
237
- node.click = data.click;
238
- if (data.hasOwnProperty('color'))
239
- node.color = data.color;
240
- node.parent.isLeafParent = true;
241
- }
242
- else {
243
- Object.keys(data).sort().forEach(function (k) {
244
- node.children.push(traverse(data[k], k, level + 1, node));
245
- });
246
- }
247
- return node;
248
- };
249
- return traverse(data, '', 0);
250
- };
251
- Hierarchy.prototype.closeContextMenu = function () {
252
- if (this.contextMenu) {
253
- this.contextMenu.remove();
254
- }
255
- d3.selectAll('.tsi-resultSelected').classed('tsi-resultSelected', false);
256
- };
257
- return Hierarchy;
258
- }(Component));
259
-
260
- export { Hierarchy as H };
@@ -1,39 +0,0 @@
1
- import { C as Component } from './Component-CdI_Pyko.js';
2
- import './Enums-CEhu18PC.js';
3
- import './Interfaces-CdAVFIA6.js';
4
-
5
- declare class HierarchyNode {
6
- name: string;
7
- markedName: string;
8
- children: Array<HierarchyNode>;
9
- parent: HierarchyNode;
10
- isExpanded: boolean;
11
- isSelected: boolean;
12
- isLeaf: boolean;
13
- childrenInFilter: boolean;
14
- selfInFilter: boolean;
15
- color: (n: HierarchyNode) => string;
16
- click: (n: any) => void;
17
- isLeafParent: boolean;
18
- level: number;
19
- constructor(name: string, level: number);
20
- filter(filterText: any): void;
21
- traverse(condition: (n: HierarchyNode) => boolean): any[];
22
- colorify(el: any): void;
23
- }
24
-
25
- declare class Hierarchy extends Component {
26
- private filterText;
27
- private root;
28
- private withContextMenu;
29
- private contextMenu;
30
- private clickedNode;
31
- private hierarchyList;
32
- constructor(renderTarget: Element);
33
- render(data: any, options: any): void;
34
- expandCollapseList: (node: HierarchyNode, el: any, isFromClick?: boolean, event?: any) => void;
35
- buildTree(data: any): HierarchyNode;
36
- private closeContextMenu;
37
- }
38
-
39
- export { Hierarchy as default };
package/dist/Hierarchy.js DELETED
@@ -1,6 +0,0 @@
1
- export { H as default } from './Hierarchy-BsvoKnCY.js';
2
- import './_tslib-DYvz7dIO.js';
3
- import 'd3';
4
- import './Utils-CdKMmmwx.js';
5
- import 'moment-timezone';
6
- import './Component-C9fQU2ia.js';
@@ -1,336 +0,0 @@
1
- import { _ as __extends, a as __assign, b as __awaiter, c as __generator } from './_tslib-DYvz7dIO.js';
2
- import * as d3 from 'd3';
3
- import { U as Utils } from './Utils-CdKMmmwx.js';
4
- import { C as Component } from './Component-C9fQU2ia.js';
5
-
6
- var HierarchyNavigation = /** @class */ (function (_super) {
7
- __extends(HierarchyNavigation, _super);
8
- function HierarchyNavigation(renderTarget) {
9
- var _this = _super.call(this, renderTarget) || this;
10
- _this.path = [];
11
- //selectedIds
12
- _this.selectedIds = [];
13
- _this.searchEnabled = true;
14
- _this.renderSearchResult = function (r, payload, target) {
15
- var _a, _b, _c, _d, _e, _f;
16
- var hierarchyData = ((_b = (_a = r.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b.length)
17
- ? _this.fillDataRecursively(r.hierarchyNodes, payload, payload)
18
- : {};
19
- var instancesData = ((_d = (_c = r.instances) === null || _c === void 0 ? void 0 : _c.hits) === null || _d === void 0 ? void 0 : _d.length)
20
- ? r.instances.hits.reduce(function (acc, i) {
21
- acc[_this.instanceNodeIdentifier(i)] = new InstanceNode(i.timeSeriesId, i.name, payload.path.length - _this.path.length, i.id, i.description);
22
- return acc;
23
- }, {})
24
- : {};
25
- if ((_f = (_e = r.hierarchyNodes) === null || _e === void 0 ? void 0 : _e.hits) === null || _f === void 0 ? void 0 : _f.length) {
26
- var hitCountElem = target.select(".tsi-hitCount");
27
- if (hitCountElem.size() === 0) {
28
- hitCountElem = target.append('span').classed('tsi-hitCount', true).text('');
29
- }
30
- hitCountElem.text(r.hierarchyNodes.hitCount);
31
- }
32
- _this.renderTree(__assign(__assign({}, hierarchyData), instancesData), target);
33
- };
34
- _this.hierarchyNodeIdentifier = function (hName) {
35
- return hName ? hName : '(' + _this.getString("Empty") + ')';
36
- };
37
- _this.instanceNodeIdentifier = function (instance) {
38
- return "instance-".concat(Utils.getInstanceKey(instance));
39
- };
40
- _this.instanceNodeStringToDisplay = function (instance) {
41
- var _a;
42
- return ((_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.name) || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
43
- || instance.name || Utils.getTimeSeriesIdToDisplay(instance, _this.getString('Empty'));
44
- };
45
- _this.instanceNodeString = function (instance) {
46
- return instance.name || Utils.getTimeSeriesIdString(instance);
47
- };
48
- return _this;
49
- }
50
- HierarchyNavigation.prototype.render = function (searchF_1) {
51
- return __awaiter(this, arguments, void 0, function (searchF, hierarchyNavOptions, preselectedIds) {
52
- var targetElement, results;
53
- if (hierarchyNavOptions === void 0) { hierarchyNavOptions = {}; }
54
- return __generator(this, function (_a) {
55
- this.chartOptions.setOptions(hierarchyNavOptions);
56
- this.searchFunction = searchF;
57
- targetElement = d3.select(this.renderTarget).text('');
58
- this.hierarchyNavWrapper = this.createHierarchyNavWrapper(targetElement);
59
- this.selectedIds = preselectedIds;
60
- //render search wrapper
61
- //this.renderSearchBox()
62
- _super.prototype.themify.call(this, this.hierarchyNavWrapper, this.chartOptions.theme);
63
- results = this.createResultsWrapper(this.hierarchyNavWrapper);
64
- this.hierarchyElem = this.createHierarchyElem(results);
65
- this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
66
- return [2 /*return*/];
67
- });
68
- });
69
- };
70
- HierarchyNavigation.prototype.createHierarchyNavWrapper = function (targetElement) {
71
- return targetElement.append('div').attr('class', 'tsi-hierarchy-nav-wrapper');
72
- };
73
- HierarchyNavigation.prototype.createResultsWrapper = function (hierarchyNavWrapper) {
74
- return hierarchyNavWrapper.append('div').classed('tsi-hierarchy-or-list-wrapper', true);
75
- };
76
- HierarchyNavigation.prototype.createHierarchyElem = function (results) {
77
- return results.append('div').classed('tsi-hierarchy', true).attr("role", "navigation").on('scroll', function () { });
78
- };
79
- // prepares the parameters for search request
80
- HierarchyNavigation.prototype.requestPayload = function (hierarchy) {
81
- var _a;
82
- if (hierarchy === void 0) { hierarchy = null; }
83
- var path = (_a = hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.path) !== null && _a !== void 0 ? _a : this.path;
84
- return { path: path, hierarchy: hierarchy };
85
- };
86
- // renders tree for both 'Navigate' and 'Filter' mode (with Hierarchy View option selected), locInTarget refers to the 'show more' element -either hierarchy or instance- within the target
87
- HierarchyNavigation.prototype.renderTree = function (data, target) {
88
- var _this = this;
89
- var list = target.append('ul').attr("role", target === this.hierarchyElem ? "tree" : "group");
90
- Object.keys(data).forEach(function (el) {
91
- var nodeNameToCheckIfExists = data[el] instanceof InstanceNode ? _this.instanceNodeString(data[el]) : el;
92
- var li;
93
- if (list.selectAll(".tsi-name").nodes().find(function (e) { return e.innerText === nodeNameToCheckIfExists; })) {
94
- li = null;
95
- }
96
- else {
97
- li = list.append('li').classed('tsi-leaf', data[el].isLeaf);
98
- //if the node is already selected, we want to highlight it
99
- if (_this.selectedIds && _this.selectedIds.includes(data[el].id)) {
100
- li.classed('tsi-selected', true);
101
- }
102
- }
103
- if (!li)
104
- return;
105
- li.attr("role", "none");
106
- var newListElem = _this.createHierarchyItemElem(data[el], el);
107
- li.node().appendChild(newListElem.node());
108
- data[el].node = li;
109
- if (data[el].children) {
110
- data[el].isExpanded = true;
111
- data[el].node.classed('tsi-expanded', true);
112
- _this.renderTree(data[el].children, data[el].node);
113
- }
114
- });
115
- };
116
- HierarchyNavigation.prototype.renderSearchBox = function () {
117
- var _this = this;
118
- this.searchWrapperElem = this.hierarchyNavWrapper.append('div').classed('tsi-hierarchy-search', true);
119
- var inputWrapper = this.searchWrapperElem.append("div").attr("class", "tsi-search");
120
- inputWrapper.append("i").classed("tsi-search-icon", true);
121
- var input = inputWrapper
122
- .append("input")
123
- .attr("class", "tsi-searchInput")
124
- .attr("aria-label", this.getString("Search Time Series Instances"))
125
- .attr("aria-describedby", "tsi-search-desc")
126
- .attr("role", "combobox")
127
- .attr("aria-owns", "tsi-search-results")
128
- .attr("aria-expanded", "false")
129
- .attr("aria-haspopup", "listbox")
130
- .attr("placeholder", this.getString("Search Time Series Instances") + "...");
131
- var self = this;
132
- input.on("keydown", function (event) {
133
- _this.chartOptions.onKeydown(event, _this.ap);
134
- });
135
- var searchText;
136
- input.on("input", function (event) {
137
- searchText = event.target.value;
138
- if (searchText.length === 0) {
139
- //clear the tree
140
- self.hierarchyElem.selectAll('ul').remove();
141
- self.pathSearchAndRenderResult({ search: { payload: self.requestPayload() }, render: { target: self.hierarchyElem } });
142
- }
143
- else {
144
- //filter the tree
145
- self.filterTree(searchText);
146
- }
147
- });
148
- };
149
- HierarchyNavigation.prototype.pathSearchAndRenderResult = function (_a) {
150
- return __awaiter(this, arguments, void 0, function (_b) {
151
- var result, err_1;
152
- var _c = _b.search, payload = _c.payload, _d = _c.bubbleUpReject, bubbleUpReject = _d === void 0 ? false : _d, _e = _b.render, target = _e.target; _e.locInTarget;
153
- return __generator(this, function (_g) {
154
- switch (_g.label) {
155
- case 0:
156
- _g.trys.push([0, 2, , 3]);
157
- return [4 /*yield*/, this.searchFunction(payload)];
158
- case 1:
159
- result = _g.sent();
160
- if (result.error) {
161
- throw result.error;
162
- }
163
- this.renderSearchResult(result, payload, target);
164
- return [3 /*break*/, 3];
165
- case 2:
166
- err_1 = _g.sent();
167
- this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err_1 instanceof XMLHttpRequest ? err_1 : null);
168
- if (bubbleUpReject) {
169
- throw err_1;
170
- }
171
- return [3 /*break*/, 3];
172
- case 3: return [2 /*return*/];
173
- }
174
- });
175
- });
176
- };
177
- HierarchyNavigation.prototype.filterTree = function (searchText) {
178
- var tree = this.hierarchyElem.selectAll('ul').nodes()[0];
179
- var list = tree.querySelectorAll('li');
180
- list.forEach(function (li) {
181
- var name = li.querySelector('.tsi-name').innerText;
182
- if (name.toLowerCase().includes(searchText.toLowerCase())) {
183
- li.style.display = 'block';
184
- }
185
- else {
186
- li.style.display = 'none';
187
- }
188
- });
189
- };
190
- // creates in-depth data object using the server response for hierarchyNodes to show in the tree all expanded, considering UntilChildren
191
- HierarchyNavigation.prototype.fillDataRecursively = function (hierarchyNodes, payload, payloadForContinuation) {
192
- var _this = this;
193
- if (payloadForContinuation === void 0) { payloadForContinuation = null; }
194
- var data = {};
195
- hierarchyNodes.hits.forEach(function (h) {
196
- var _a;
197
- var hierarchy = new HierarchyNode(h.name, payload.path, payload.path.length - _this.path.length, h.cumulativeInstanceCount, h.id);
198
- hierarchy.expand = function () {
199
- hierarchy.isExpanded = true;
200
- hierarchy.node.classed('tsi-expanded', true);
201
- return _this.pathSearchAndRenderResult({
202
- search: { payload: _this.requestPayload(hierarchy), bubbleUpReject: true },
203
- render: { target: hierarchy.node }
204
- });
205
- };
206
- data[_this.hierarchyNodeIdentifier(h.name)] = hierarchy;
207
- if ((_a = h.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits.length) {
208
- hierarchy.children = _this.fillDataRecursively(h.hierarchyNodes, _this.requestPayload(hierarchy), payloadForContinuation);
209
- }
210
- });
211
- return data;
212
- };
213
- //returns the dom element of one hierarchy level item for tree rendering
214
- HierarchyNavigation.prototype.createHierarchyItemElem = function (hORi, key) {
215
- var self = this;
216
- var isHierarchyNode = hORi instanceof HierarchyNode;
217
- var hierarchyItemElem = d3.create('div').classed('tsi-hierarchyItem', true)
218
- .attr('style', "padding-left: ".concat(hORi.isLeaf ? hORi.level * 18 + 20 : (hORi.level + 1) * 18 + 20, "px"))
219
- .attr('tabindex', 0)
220
- //.attr('arialabel', isHierarchyNode ? key : Utils.getTimeSeriesIdString(hORi))
221
- .attr('arialabel', isHierarchyNode ? key : self.getAriaLabel(hORi))
222
- .attr('title', isHierarchyNode ? key : self.getAriaLabel(hORi))
223
- .attr("role", "treeitem").attr('aria-expanded', hORi.isExpanded)
224
- .on('click keydown', function (event) {
225
- return __awaiter(this, void 0, void 0, function () {
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0:
229
- if (Utils.isKeyDownAndNotEnter(event)) {
230
- return [2 /*return*/];
231
- }
232
- if (!!isHierarchyNode) return [3 /*break*/, 1];
233
- event.stopPropagation();
234
- //we want to store clicked instance and hightlight it in the hierarchy
235
- //if the instance is already selected, we want to deselect it
236
- if (self.chartOptions.onInstanceClick) {
237
- if (self.selectedIds && self.selectedIds.includes(hORi.id)) {
238
- self.selectedIds = self.selectedIds.filter(function (id) { return id !== hORi.id; });
239
- hORi.node.classed('tsi-selected', false);
240
- }
241
- else {
242
- self.selectedIds.push(hORi.id);
243
- hORi.node.classed('tsi-selected', true);
244
- }
245
- }
246
- self.chartOptions.onInstanceClick(hORi);
247
- return [3 /*break*/, 4];
248
- case 1:
249
- if (!hORi.isExpanded) return [3 /*break*/, 2];
250
- hORi.collapse();
251
- return [3 /*break*/, 4];
252
- case 2: return [4 /*yield*/, hORi.expand()];
253
- case 3:
254
- _a.sent();
255
- _a.label = 4;
256
- case 4: return [2 /*return*/];
257
- }
258
- });
259
- });
260
- });
261
- if (isHierarchyNode) {
262
- hierarchyItemElem.append('span').classed('tsi-caret-icon', true).attr('style', "left: ".concat((hORi.level) * 18 + 20, "px"));
263
- hierarchyItemElem.append('span').classed('tsi-name', true).text(key);
264
- hierarchyItemElem.append('span').classed('tsi-instanceCount', true).text(hORi.cumulativeInstanceCount);
265
- hierarchyItemElem.append('span').classed('tsi-hitCount', true).text(''); // hit count is the number of hierarchy nodes below, it is filled after expand is clicked for this node (after search is done for this path)
266
- }
267
- else {
268
- var spanElem = hierarchyItemElem.append('span').classed('tsi-name', true);
269
- Utils.appendFormattedElementsFromString(spanElem, this.instanceNodeStringToDisplay(hORi));
270
- }
271
- return hierarchyItemElem;
272
- };
273
- HierarchyNavigation.prototype.getAriaLabel = function (hORi) {
274
- if (hORi instanceof HierarchyNode) {
275
- return hORi.name;
276
- }
277
- //check description first then name then id
278
- return hORi.description || hORi.name || hORi.id || Utils.getTimeSeriesIdString(hORi);
279
- };
280
- return HierarchyNavigation;
281
- }(Component));
282
- var HierarchyNode = /** @class */ (function () {
283
- function HierarchyNode(name, parentPath, level, cumulativeInstanceCount, id) {
284
- if (cumulativeInstanceCount === void 0) { cumulativeInstanceCount = null; }
285
- if (id === void 0) { id = null; }
286
- this.name = name;
287
- this.id = id;
288
- this.path = parentPath.concat([name]);
289
- this.level = level;
290
- this.cumulativeInstanceCount = cumulativeInstanceCount;
291
- this.node = null;
292
- this.children = null;
293
- this.isExpanded = false;
294
- }
295
- HierarchyNode.prototype.expand = function () { };
296
- HierarchyNode.prototype.collapse = function () {
297
- this.isExpanded = false;
298
- this.node.classed('tsi-expanded', false);
299
- this.node.selectAll('ul').remove();
300
- };
301
- return HierarchyNode;
302
- }());
303
- var InstanceNode = /** @class */ (function () {
304
- function InstanceNode(tsId, name, level, id, description) {
305
- if (name === void 0) { name = null; }
306
- if (id === void 0) { id = null; }
307
- if (description === void 0) { description = null; }
308
- this.timeSeriesId = tsId;
309
- this.name = name;
310
- this.suppressDrawContextMenu = false;
311
- this.isLeaf = true;
312
- this.level = level;
313
- this.node = null;
314
- this.id = id;
315
- this.description = description;
316
- }
317
- return InstanceNode;
318
- }());
319
- var HierarchySelectionValues;
320
- (function (HierarchySelectionValues) {
321
- HierarchySelectionValues["All"] = "0";
322
- HierarchySelectionValues["Unparented"] = "-1";
323
- })(HierarchySelectionValues || (HierarchySelectionValues = {}));
324
- var ViewType;
325
- (function (ViewType) {
326
- ViewType[ViewType["Hierarchy"] = 0] = "Hierarchy";
327
- ViewType[ViewType["List"] = 1] = "List";
328
- })(ViewType || (ViewType = {}));
329
- var State;
330
- (function (State) {
331
- State[State["Navigate"] = 0] = "Navigate";
332
- State[State["Search"] = 1] = "Search";
333
- State[State["Filter"] = 2] = "Filter";
334
- })(State || (State = {}));
335
-
336
- export { HierarchyNavigation as H };