tsichart-core 2.0.0-beta.3 → 2.0.0-beta.6

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/dist/index.js CHANGED
@@ -1071,8 +1071,7 @@ Utils.getTimeSeriesIdToDisplay = (instance, emptyDisplayString) => {
1071
1071
  return Utils.instanceHasEmptyTSID(instance) ? emptyDisplayString : instance.timeSeriesId.map(id => id === null ? Utils.guidForNullTSID : id).join(', ');
1072
1072
  };
1073
1073
  Utils.getHighlightedTimeSeriesIdToDisplay = (instance) => {
1074
- var _a;
1075
- return (_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.timeSeriesId.map((id, idx) => instance.timeSeriesId[idx] === null ? Utils.guidForNullTSID : id).join(', ');
1074
+ return instance.highlights?.timeSeriesId.map((id, idx) => instance.timeSeriesId[idx] === null ? Utils.guidForNullTSID : id).join(', ');
1076
1075
  };
1077
1076
  Utils.instanceHasEmptyTSID = (instance) => {
1078
1077
  return !instance.timeSeriesId || instance.timeSeriesId.length === 0;
@@ -1505,10 +1504,10 @@ class Component {
1505
1504
  }
1506
1505
  themify(targetElement, theme) {
1507
1506
  var theme = Utils.getTheme(theme);
1508
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed(this.currentTheme, false);
1509
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed('tsi-light', false);
1510
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed('tsi-dark', false);
1511
- targetElement === null || targetElement === void 0 ? void 0 : targetElement.classed(theme, true);
1507
+ targetElement?.classed(this.currentTheme, false);
1508
+ targetElement?.classed('tsi-light', false);
1509
+ targetElement?.classed('tsi-dark', false);
1510
+ targetElement?.classed(theme, true);
1512
1511
  this.currentTheme = theme;
1513
1512
  }
1514
1513
  tooltipFormat(d, text, measureFormat, xyrMeasures = null) {
@@ -1731,7 +1730,7 @@ class Legend extends Component {
1731
1730
  }
1732
1731
  labelMouseoutWrapper(labelMouseout, svgSelection, event) {
1733
1732
  return (svgSelection, aggKey) => {
1734
- event === null || event === void 0 ? void 0 : event.stopPropagation();
1733
+ event?.stopPropagation();
1735
1734
  svgSelection.selectAll(".tsi-valueElement")
1736
1735
  .filter(function () { return !d3__namespace.select(this).classed("tsi-valueEnvelope"); })
1737
1736
  .attr("stroke-opacity", 1)
@@ -2097,7 +2096,7 @@ class ChartComponentData {
2097
2096
  let aggKeys = Utils.getAggKeys(this.data);
2098
2097
  this.data = this.data.map((aggregate, i) => {
2099
2098
  var aggName = Object.keys(aggregate)[0];
2100
- let aggregateCopy = Object.assign({}, aggregate);
2099
+ let aggregateCopy = { ...aggregate };
2101
2100
  let aggKey = aggKeys[i];
2102
2101
  this.data[i].aggKey = aggKey;
2103
2102
  aggregateCopy.aggKey = aggKey;
@@ -4034,7 +4033,7 @@ class LinePlot extends Plot {
4034
4033
  }
4035
4034
  let envelopeData = {};
4036
4035
  if ((self.chartComponentData.displayState[aggKey].includeEnvelope || self.chartOptions.includeEnvelope) && self.chartComponentData.isPossibleEnvelope(aggKey, splitBy)) {
4037
- envelopeData = self.chartComponentData.timeArrays[aggKey][splitBy].map((d) => (Object.assign(Object.assign({}, d), { isEnvelope: true })));
4036
+ envelopeData = self.chartComponentData.timeArrays[aggKey][splitBy].map((d) => ({ ...d, isEnvelope: true }));
4038
4037
  }
4039
4038
  let envelope = d3__namespace.select(this).selectAll(".tsi-valueEnvelope")
4040
4039
  .data([envelopeData]);
@@ -6124,7 +6123,6 @@ class LineChart extends TemporalXAxisComponent {
6124
6123
  let visibleCDOs = this.aggregateExpressionOptions.filter((cDO) => this.chartComponentData.displayState[cDO.aggKey]["visible"]);
6125
6124
  const markerList = [];
6126
6125
  const pushMarker = (cDO, marker, markerList) => {
6127
- var _a, _b;
6128
6126
  if (this.chartOptions.yAxisState === YAxisStates.Overlap) {
6129
6127
  return;
6130
6128
  }
@@ -6133,10 +6131,10 @@ class LineChart extends TemporalXAxisComponent {
6133
6131
  this.swimlaneYExtents[0];
6134
6132
  // filter out markers not in the y range of that lane and in lanes that have overlap axis
6135
6133
  if (domain &&
6136
- ((_b = (_a = this.chartOptions.swimLaneOptions) === null || _a === void 0 ? void 0 : _a[cDO.swimLane]) === null || _b === void 0 ? void 0 : _b.yAxisType) !== YAxisStates.Overlap &&
6134
+ this.chartOptions.swimLaneOptions?.[cDO.swimLane]?.yAxisType !== YAxisStates.Overlap &&
6137
6135
  marker.value >= domain[0] &&
6138
6136
  marker.value <= domain[1]) {
6139
- markerList.push(Object.assign({ yScale: this.yMap[cDO.aggKey] }, marker));
6137
+ markerList.push({ yScale: this.yMap[cDO.aggKey], ...marker });
6140
6138
  }
6141
6139
  };
6142
6140
  visibleCDOs.forEach((cDO) => {
@@ -6152,9 +6150,8 @@ class LineChart extends TemporalXAxisComponent {
6152
6150
  };
6153
6151
  if (this.chartOptions.yAxisState !== YAxisStates.Overlap && this.chartOptions.swimLaneOptions) {
6154
6152
  Object.keys(this.chartOptions.swimLaneOptions).forEach((swimlaneNumber) => {
6155
- var _a;
6156
6153
  const swimlaneOptions = this.chartOptions.swimLaneOptions[swimlaneNumber];
6157
- (_a = swimlaneOptions.horizontalMarkers) === null || _a === void 0 ? void 0 : _a.forEach((horizontalMarkerParams) => {
6154
+ swimlaneOptions.horizontalMarkers?.forEach((horizontalMarkerParams) => {
6158
6155
  const firstVisibleCDO = findFirstVisibleCDO(Number(swimlaneNumber));
6159
6156
  if (firstVisibleCDO) {
6160
6157
  pushMarker(firstVisibleCDO, horizontalMarkerParams, markerList);
@@ -6223,17 +6220,16 @@ class LineChart extends TemporalXAxisComponent {
6223
6220
  current height of the lane.
6224
6221
  */
6225
6222
  const useAggForLaneLabel = (aggGroup) => {
6226
- var _a, _b, _c, _d, _e, _f;
6227
6223
  let swimLane = aggGroup.swimLane;
6228
6224
  let aggIndex = visibleCDOs.findIndex(el => el.aggKey === aggGroup.aggKey);
6229
6225
  let onClick = null;
6230
- if (typeof ((_c = (_b = (_a = this.chartOptions) === null || _a === void 0 ? void 0 : _a.swimLaneOptions) === null || _b === void 0 ? void 0 : _b[swimLane]) === null || _c === void 0 ? void 0 : _c.onClick) === 'function') {
6231
- onClick = () => { var _a, _b, _c, _d; return (_d = (_c = (_b = (_a = this.chartOptions) === null || _a === void 0 ? void 0 : _a.swimLaneOptions) === null || _b === void 0 ? void 0 : _b[swimLane]) === null || _c === void 0 ? void 0 : _c.onClick) === null || _d === void 0 ? void 0 : _d.call(_c, swimLane); };
6226
+ if (typeof this.chartOptions?.swimLaneOptions?.[swimLane]?.onClick === 'function') {
6227
+ onClick = () => this.chartOptions?.swimLaneOptions?.[swimLane]?.onClick?.(swimLane);
6232
6228
  }
6233
6229
  swimLaneLabels[swimLane] = {
6234
6230
  offset: offsetsAndHeights[aggIndex][0],
6235
6231
  height: offsetsAndHeights[aggIndex][1],
6236
- label: (_f = (_e = (_d = this.chartOptions) === null || _d === void 0 ? void 0 : _d.swimLaneOptions) === null || _e === void 0 ? void 0 : _e[swimLane]) === null || _f === void 0 ? void 0 : _f.label,
6232
+ label: this.chartOptions?.swimLaneOptions?.[swimLane]?.label,
6237
6233
  onClick
6238
6234
  };
6239
6235
  };
@@ -6245,13 +6241,12 @@ class LineChart extends TemporalXAxisComponent {
6245
6241
  });
6246
6242
  // Then, map over any non-numeric dataType and increment heights if they're sharing a lane
6247
6243
  visibleCDOs.filter(aggGroup => aggGroup.dataType !== DataTypes.Numeric).forEach(aggGroup => {
6248
- var _a, _b, _c;
6249
6244
  let aggIndex = visibleCDOs.findIndex(el => el.aggKey === aggGroup.aggKey);
6250
6245
  if (!(aggGroup.swimLane in swimLaneLabels)) { // Only add swimlanes once to swimLaneLabels map
6251
6246
  useAggForLaneLabel(aggGroup);
6252
6247
  }
6253
6248
  else { // if lane contains non-numeric data and is being added to another lane
6254
- if (!((_c = (_b = (_a = this.chartOptions) === null || _a === void 0 ? void 0 : _a.swimLaneOptions) === null || _b === void 0 ? void 0 : _b[aggGroup.swimLane]) === null || _c === void 0 ? void 0 : _c.collapseEvents)) { // Only increment event heights if collapseEvents === false
6249
+ if (!this.chartOptions?.swimLaneOptions?.[aggGroup.swimLane]?.collapseEvents) { // Only increment event heights if collapseEvents === false
6255
6250
  swimLaneLabels[aggGroup.swimLane].height += offsetsAndHeights[aggIndex][1]; // add heights (non-numerics don't share Y axis)
6256
6251
  }
6257
6252
  }
@@ -6309,6 +6304,7 @@ class LineChart extends TemporalXAxisComponent {
6309
6304
  });
6310
6305
  }
6311
6306
  render(data, options, aggregateExpressionOptions) {
6307
+ console.log('LineChart render called a');
6312
6308
  super.render(data, options, aggregateExpressionOptions);
6313
6309
  this.originalSwimLanes = this.aggregateExpressionOptions.map((aEO) => {
6314
6310
  return aEO.swimLane;
@@ -6363,7 +6359,7 @@ class LineChart extends TemporalXAxisComponent {
6363
6359
  .attr("type", "button")
6364
6360
  .on("click", function () {
6365
6361
  self.overwriteSwimLanes();
6366
- self.render(self.data, Object.assign(Object.assign({}, self.chartOptions), { yAxisState: self.nextStackedState() }), self.aggregateExpressionOptions);
6362
+ self.render(self.data, { ...self.chartOptions, yAxisState: self.nextStackedState() }, self.aggregateExpressionOptions);
6367
6363
  d3__namespace.select(this).attr("aria-label", () => self.getString("set axis state to") + ' ' + self.nextStackedState());
6368
6364
  setTimeout(() => d3__namespace.select(this).node().focus(), 200);
6369
6365
  });
@@ -6453,8 +6449,7 @@ class LineChart extends TemporalXAxisComponent {
6453
6449
  this.aggregateExpressionOptions.filter((aggExpOpt) => {
6454
6450
  return this.chartComponentData.displayState[aggExpOpt.aggKey]["visible"];
6455
6451
  }).forEach(visibleAgg => {
6456
- var _a, _b;
6457
- if ((_b = (_a = this.originalSwimLaneOptions) === null || _a === void 0 ? void 0 : _a[visibleAgg.swimLane]) === null || _b === void 0 ? void 0 : _b.label) {
6452
+ if (this.originalSwimLaneOptions?.[visibleAgg.swimLane]?.label) {
6458
6453
  isLabelVisible = true;
6459
6454
  }
6460
6455
  });
@@ -6611,7 +6606,6 @@ class LineChart extends TemporalXAxisComponent {
6611
6606
  return self.chartOptions.isArea ? null : 'translate(0,' + offsetsAndHeights[i][0] + ')';
6612
6607
  })
6613
6608
  .each(function (agg, i) {
6614
- var _a, _b, _c;
6615
6609
  let yExtent;
6616
6610
  let aggVisible = true;
6617
6611
  var aggValues = [];
@@ -6651,8 +6645,8 @@ class LineChart extends TemporalXAxisComponent {
6651
6645
  }
6652
6646
  let axisState = new AxisState(self.getAggAxisType(agg), yExtent, positionInGroup);
6653
6647
  let yAxisOnClick = null;
6654
- if (typeof ((_c = (_b = (_a = self.chartOptions) === null || _a === void 0 ? void 0 : _a.swimLaneOptions) === null || _b === void 0 ? void 0 : _b[swimLane]) === null || _c === void 0 ? void 0 : _c.onClick) === 'function') {
6655
- yAxisOnClick = () => { var _a, _b; return (_b = (_a = self.chartOptions.swimLaneOptions[swimLane]).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, swimLane); };
6648
+ if (typeof self.chartOptions?.swimLaneOptions?.[swimLane]?.onClick === 'function') {
6649
+ yAxisOnClick = () => self.chartOptions.swimLaneOptions[swimLane].onClick?.(swimLane);
6656
6650
  }
6657
6651
  self.plotComponents[aggKey].render(self.chartOptions, visibleNumericI, agg, true, d3__namespace.select(this), self.chartComponentData, axisState, self.chartHeight, self.visibleAggCount, self.colorMap, self.previousAggregateData, self.x, self.areaPath, self.strokeOpacity, self.y, self.yMap, defs, visibleCDOs[i], self.previousIncludeDots, offsetsAndHeights[i], g, mouseoverFunction, mouseoutFunction, yAxisOnClick);
6658
6652
  //increment index of visible numerics if appropriate
@@ -8580,7 +8574,7 @@ class DateTimePicker extends ChartComponent {
8580
8574
  const MAXCARD = 150000;
8581
8575
  class AggregateExpression extends ChartDataOptions {
8582
8576
  constructor(predicateObject, measureObject, measureTypes, searchSpan, splitByObject = null, colorOrOptionsObject, alias, contextMenu) {
8583
- super((typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject) ? Object.assign(Object.assign({}, colorOrOptionsObject), { searchSpan: searchSpan, measureTypes: measureTypes }) : { color: colorOrOptionsObject, searchSpan: searchSpan, measureTypes: measureTypes, alias: alias, contextMenu: contextMenu });
8577
+ super((typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject) ? { ...colorOrOptionsObject, searchSpan: searchSpan, measureTypes: measureTypes } : { color: colorOrOptionsObject, searchSpan: searchSpan, measureTypes: measureTypes, alias: alias, contextMenu: contextMenu });
8584
8578
  this.visibleSplitByCap = 10;
8585
8579
  this.predicate = predicateObject;
8586
8580
  this.splitByObject = splitByObject;
@@ -8767,16 +8761,18 @@ class AvailabilityChart extends ChartComponent {
8767
8761
  event.preventDefault && event.preventDefault();
8768
8762
  }
8769
8763
  setChartOptions(chartOptions) {
8770
- this.chartOptions.setOptions(Object.assign(Object.assign({}, chartOptions), {
8771
- keepBrush: true,
8772
- isArea: true,
8773
- noAnimate: true,
8774
- minutesForTimeLabels: true,
8775
- aggTopMargin: 0,
8776
- yAxisHidden: true,
8777
- focusHidden: true,
8778
- singleLineXAxisLabel: false
8779
- }));
8764
+ this.chartOptions.setOptions({
8765
+ ...chartOptions, ...{
8766
+ keepBrush: true,
8767
+ isArea: true,
8768
+ noAnimate: true,
8769
+ minutesForTimeLabels: true,
8770
+ aggTopMargin: 0,
8771
+ yAxisHidden: true,
8772
+ focusHidden: true,
8773
+ singleLineXAxisLabel: false
8774
+ }
8775
+ });
8780
8776
  }
8781
8777
  dateTimePickerAction(fromMillis, toMillis) {
8782
8778
  this.setBrush(fromMillis, toMillis, true);
@@ -9138,12 +9134,14 @@ class AvailabilityChart extends ChartComponent {
9138
9134
  this.zoomedToMillis = toMillis;
9139
9135
  var visibileAvailability = this.createDisplayBuckets(fromMillis, toMillis);
9140
9136
  this.chartOptions.keepBrush = true;
9141
- var aeWithNewTimeSpan = Object.assign(Object.assign({}, this.ae[0]), {
9142
- searchSpan: {
9143
- from: (new Date(fromMillis)),
9144
- to: (new Date(toMillis))
9137
+ var aeWithNewTimeSpan = {
9138
+ ...this.ae[0], ...{
9139
+ searchSpan: {
9140
+ from: (new Date(fromMillis)),
9141
+ to: (new Date(toMillis))
9142
+ }
9145
9143
  }
9146
- });
9144
+ };
9147
9145
  this.timePickerLineChart.render(visibileAvailability, this.chartOptions, [aeWithNewTimeSpan]);
9148
9146
  this.setTicks();
9149
9147
  this.drawWarmRange();
@@ -9586,7 +9584,7 @@ class PieChart extends ChartVisualizationComponent {
9586
9584
  var yPos = mousePosition[1];
9587
9585
  tooltip.render(self.chartOptions.theme);
9588
9586
  let color = Utils.colorSplitBy(self.chartComponentData.displayState, d.data.splitByI, d.data.aggKey, self.chartOptions.keepSplitByColor);
9589
- tooltip.draw(d, self.chartComponentData, xPos, yPos, Object.assign(Object.assign({}, self.chartMargins), { top: 0, bottom: 0 }), (text) => {
9587
+ tooltip.draw(d, self.chartComponentData, xPos, yPos, { ...self.chartMargins, top: 0, bottom: 0 }, (text) => {
9590
9588
  self.tooltipFormat(self.convertToTimeValueFormat(d.data), text, TooltipMeasureFormat.SingleValue);
9591
9589
  }, null, 20, 20, color);
9592
9590
  }
@@ -10130,8 +10128,7 @@ class ScatterPlot extends ChartVisualizationComponent {
10130
10128
  let connectedSeriesMap = {};
10131
10129
  // Find measure by which to connect series of points
10132
10130
  const getPointConnectionMeasure = (point => {
10133
- var _a;
10134
- let pConMes = (_a = this.aggregateExpressionOptions[point.aggregateKeyI]) === null || _a === void 0 ? void 0 : _a.pointConnectionMeasure;
10131
+ let pConMes = this.aggregateExpressionOptions[point.aggregateKeyI]?.pointConnectionMeasure;
10135
10132
  return pConMes && pConMes in point.measures ? pConMes : null;
10136
10133
  });
10137
10134
  // Map data into groups of connected points, if connectedPoints enabled for agg
@@ -11793,7 +11790,7 @@ class Heatmap extends TemporalXAxisComponent {
11793
11790
  super.render(data, chartOptions, aggregateExpressionOptions);
11794
11791
  // override visibleSplitByCap
11795
11792
  this.aggregateExpressionOptions = this.aggregateExpressionOptions.map((aE) => {
11796
- return Object.assign(Object.assign({}, aE), { visibleSplitByCap: 10000 });
11793
+ return { ...aE, visibleSplitByCap: 10000 };
11797
11794
  });
11798
11795
  this.chartOptions.setOptions(chartOptions);
11799
11796
  var targetElement = d3__namespace.select(this.renderTarget).classed("tsi-heatmapComponent", true);
@@ -12564,9 +12561,13 @@ class ModelSearch extends Component {
12564
12561
  }
12565
12562
  };
12566
12563
  let modelAutocomplete = new ModelAutocomplete(inputWrapper.node());
12567
- modelAutocomplete.render(environmentFqdn, getToken, Object.assign({ onInput: autocompleteOnInput, onKeydown: (event, ap) => {
12564
+ modelAutocomplete.render(environmentFqdn, getToken, {
12565
+ onInput: autocompleteOnInput,
12566
+ onKeydown: (event, ap) => {
12568
12567
  this.handleKeydown(event, ap);
12569
- } }, chartOptions));
12568
+ },
12569
+ ...chartOptions,
12570
+ });
12570
12571
  modelAutocomplete.ap;
12571
12572
  let results = this.wrapper
12572
12573
  .append("div")
@@ -12601,7 +12602,10 @@ class ModelSearch extends Component {
12601
12602
  .append("div")
12602
12603
  .attr("class", "tsi-hierarchyWrapper");
12603
12604
  let hierarchy = new Hierarchy(hierarchyElement.node());
12604
- hierarchy.render(hierarchyData, Object.assign(Object.assign({}, this.chartOptions), { withContextMenu: true }));
12605
+ hierarchy.render(hierarchyData, {
12606
+ ...this.chartOptions,
12607
+ withContextMenu: true,
12608
+ });
12605
12609
  let searchInstances = (searchText, ct = null) => {
12606
12610
  var self = this;
12607
12611
  if (ct === "END")
@@ -12700,13 +12704,18 @@ class TsqExpression extends ChartDataOptions {
12700
12704
  // new TsqExpression(instanceObject, variableObject, searchSpan, color, alias, contextMenu)
12701
12705
  // Here we differentiate between both and call the parent class's constructor as appropriate.
12702
12706
  let optionsObject = (typeof (colorOrOptionsObject) === 'object' && !!colorOrOptionsObject)
12703
- ? Object.assign(Object.assign({}, colorOrOptionsObject), { searchSpan: searchSpan, measureTypes: Object.keys(variableObject) }) : {
12704
- color: colorOrOptionsObject,
12705
- searchSpan: searchSpan,
12706
- measureTypes: Object.keys(variableObject),
12707
- alias: alias,
12708
- contextMenu: contextMenu
12709
- };
12707
+ ? {
12708
+ ...colorOrOptionsObject,
12709
+ searchSpan: searchSpan,
12710
+ measureTypes: Object.keys(variableObject)
12711
+ }
12712
+ : {
12713
+ color: colorOrOptionsObject,
12714
+ searchSpan: searchSpan,
12715
+ measureTypes: Object.keys(variableObject),
12716
+ alias: alias,
12717
+ contextMenu: contextMenu
12718
+ };
12710
12719
  super(optionsObject);
12711
12720
  this.instanceObject = instanceObject;
12712
12721
  this.variableObject = variableObject;
@@ -12729,13 +12738,13 @@ class TsqExpression extends ChartDataOptions {
12729
12738
  return { getEvents: tsq };
12730
12739
  }
12731
12740
  else if (getSeries) {
12732
- tsq['inlineVariables'] = Object.assign({}, this.variableObject);
12741
+ tsq['inlineVariables'] = { ...this.variableObject };
12733
12742
  tsq['projectedVariables'] = Object.keys(this.variableObject);
12734
12743
  return { getSeries: tsq };
12735
12744
  }
12736
12745
  else {
12737
12746
  tsq['interval'] = Utils.bucketSizeToTsqInterval(this.searchSpan.bucketSize);
12738
- tsq['inlineVariables'] = Object.assign({}, this.variableObject);
12747
+ tsq['inlineVariables'] = { ...this.variableObject };
12739
12748
  tsq['projectedVariables'] = Object.keys(this.variableObject);
12740
12749
  return { aggregateSeries: tsq };
12741
12750
  }
@@ -12764,38 +12773,6 @@ class TsqExpression extends ChartDataOptions {
12764
12773
  }
12765
12774
  }
12766
12775
 
12767
- /******************************************************************************
12768
- Copyright (c) Microsoft Corporation.
12769
-
12770
- Permission to use, copy, modify, and/or distribute this software for any
12771
- purpose with or without fee is hereby granted.
12772
-
12773
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12774
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12775
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12776
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12777
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12778
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12779
- PERFORMANCE OF THIS SOFTWARE.
12780
- ***************************************************************************** */
12781
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
12782
-
12783
-
12784
- function __awaiter(thisArg, _arguments, P, generator) {
12785
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12786
- return new (P || (P = Promise))(function (resolve, reject) {
12787
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12788
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12789
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12790
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12791
- });
12792
- }
12793
-
12794
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
12795
- var e = new Error(message);
12796
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
12797
- };
12798
-
12799
12776
  class HierarchyNavigation extends Component {
12800
12777
  constructor(renderTarget) {
12801
12778
  super(renderTarget);
@@ -12804,24 +12781,23 @@ class HierarchyNavigation extends Component {
12804
12781
  this.selectedIds = [];
12805
12782
  this.searchEnabled = true;
12806
12783
  this.renderSearchResult = (r, payload, target) => {
12807
- var _a, _b, _c, _d, _e, _f;
12808
- const hierarchyData = ((_b = (_a = r.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits) === null || _b === void 0 ? void 0 : _b.length)
12784
+ const hierarchyData = r.hierarchyNodes?.hits?.length
12809
12785
  ? this.fillDataRecursively(r.hierarchyNodes, payload, payload)
12810
12786
  : {};
12811
- const instancesData = ((_d = (_c = r.instances) === null || _c === void 0 ? void 0 : _c.hits) === null || _d === void 0 ? void 0 : _d.length)
12787
+ const instancesData = r.instances?.hits?.length
12812
12788
  ? r.instances.hits.reduce((acc, i) => {
12813
12789
  acc[this.instanceNodeIdentifier(i)] = new InstanceNode(i.timeSeriesId, i.name, payload.path.length - this.path.length, i.id, i.description);
12814
12790
  return acc;
12815
12791
  }, {})
12816
12792
  : {};
12817
- if ((_f = (_e = r.hierarchyNodes) === null || _e === void 0 ? void 0 : _e.hits) === null || _f === void 0 ? void 0 : _f.length) {
12793
+ if (r.hierarchyNodes?.hits?.length) {
12818
12794
  let hitCountElem = target.select(".tsi-hitCount");
12819
12795
  if (hitCountElem.size() === 0) {
12820
12796
  hitCountElem = target.append('span').classed('tsi-hitCount', true).text('');
12821
12797
  }
12822
12798
  hitCountElem.text(r.hierarchyNodes.hitCount);
12823
12799
  }
12824
- this.renderTree(Object.assign(Object.assign({}, hierarchyData), instancesData), target);
12800
+ this.renderTree({ ...hierarchyData, ...instancesData }, target);
12825
12801
  };
12826
12802
  this.hierarchyNodeIdentifier = (hName) => {
12827
12803
  return hName ? hName : '(' + this.getString("Empty") + ')';
@@ -12830,31 +12806,25 @@ class HierarchyNavigation extends Component {
12830
12806
  return `instance-${Utils.getInstanceKey(instance)}`;
12831
12807
  };
12832
12808
  this.instanceNodeStringToDisplay = (instance) => {
12833
- var _a;
12834
- return ((_a = instance.highlights) === null || _a === void 0 ? void 0 : _a.name) || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
12809
+ return instance.highlights?.name || Utils.getHighlightedTimeSeriesIdToDisplay(instance)
12835
12810
  || instance.name || Utils.getTimeSeriesIdToDisplay(instance, this.getString('Empty'));
12836
12811
  };
12837
12812
  this.instanceNodeString = (instance) => {
12838
12813
  return instance.name || Utils.getTimeSeriesIdString(instance);
12839
12814
  };
12840
12815
  }
12841
- render(searchF_1) {
12842
- const _super = Object.create(null, {
12843
- themify: { get: () => super.themify }
12844
- });
12845
- return __awaiter(this, arguments, void 0, function* (searchF, hierarchyNavOptions = {}, preselectedIds) {
12846
- this.chartOptions.setOptions(hierarchyNavOptions);
12847
- this.searchFunction = searchF;
12848
- const targetElement = d3__namespace.select(this.renderTarget).text('');
12849
- this.hierarchyNavWrapper = this.createHierarchyNavWrapper(targetElement);
12850
- this.selectedIds = preselectedIds;
12851
- //render search wrapper
12852
- //this.renderSearchBox()
12853
- _super.themify.call(this, this.hierarchyNavWrapper, this.chartOptions.theme);
12854
- const results = this.createResultsWrapper(this.hierarchyNavWrapper);
12855
- this.hierarchyElem = this.createHierarchyElem(results);
12856
- this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
12857
- });
12816
+ async render(searchF, hierarchyNavOptions = {}, preselectedIds) {
12817
+ this.chartOptions.setOptions(hierarchyNavOptions);
12818
+ this.searchFunction = searchF;
12819
+ const targetElement = d3__namespace.select(this.renderTarget).text('');
12820
+ this.hierarchyNavWrapper = this.createHierarchyNavWrapper(targetElement);
12821
+ this.selectedIds = preselectedIds;
12822
+ //render search wrapper
12823
+ //this.renderSearchBox()
12824
+ super.themify(this.hierarchyNavWrapper, this.chartOptions.theme);
12825
+ const results = this.createResultsWrapper(this.hierarchyNavWrapper);
12826
+ this.hierarchyElem = this.createHierarchyElem(results);
12827
+ this.pathSearchAndRenderResult({ search: { payload: this.requestPayload() }, render: { target: this.hierarchyElem } });
12858
12828
  }
12859
12829
  createHierarchyNavWrapper(targetElement) {
12860
12830
  return targetElement.append('div').attr('class', 'tsi-hierarchy-nav-wrapper');
@@ -12867,8 +12837,7 @@ class HierarchyNavigation extends Component {
12867
12837
  }
12868
12838
  // prepares the parameters for search request
12869
12839
  requestPayload(hierarchy = null) {
12870
- var _a;
12871
- const path = (_a = hierarchy === null || hierarchy === void 0 ? void 0 : hierarchy.path) !== null && _a !== void 0 ? _a : this.path;
12840
+ const path = hierarchy?.path ?? this.path;
12872
12841
  return { path, hierarchy };
12873
12842
  }
12874
12843
  // 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
@@ -12932,22 +12901,20 @@ class HierarchyNavigation extends Component {
12932
12901
  }
12933
12902
  });
12934
12903
  }
12935
- pathSearchAndRenderResult(_a) {
12936
- return __awaiter(this, arguments, void 0, function* ({ search: { payload, bubbleUpReject = false }, render: { target, locInTarget = null } }) {
12937
- try {
12938
- const result = yield this.searchFunction(payload);
12939
- if (result.error) {
12940
- throw result.error;
12941
- }
12942
- this.renderSearchResult(result, payload, target);
12904
+ async pathSearchAndRenderResult({ search: { payload, bubbleUpReject = false }, render: { target, locInTarget = null } }) {
12905
+ try {
12906
+ const result = await this.searchFunction(payload);
12907
+ if (result.error) {
12908
+ throw result.error;
12943
12909
  }
12944
- catch (err) {
12945
- this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null);
12946
- if (bubbleUpReject) {
12947
- throw err;
12948
- }
12910
+ this.renderSearchResult(result, payload, target);
12911
+ }
12912
+ catch (err) {
12913
+ this.chartOptions.onError("Error in hierarchy navigation", "Failed to complete search", err instanceof XMLHttpRequest ? err : null);
12914
+ if (bubbleUpReject) {
12915
+ throw err;
12949
12916
  }
12950
- });
12917
+ }
12951
12918
  }
12952
12919
  filterTree(searchText) {
12953
12920
  let tree = this.hierarchyElem.selectAll('ul').nodes()[0];
@@ -12966,7 +12933,6 @@ class HierarchyNavigation extends Component {
12966
12933
  fillDataRecursively(hierarchyNodes, payload, payloadForContinuation = null) {
12967
12934
  let data = {};
12968
12935
  hierarchyNodes.hits.forEach((h) => {
12969
- var _a;
12970
12936
  let hierarchy = new HierarchyNode(h.name, payload.path, payload.path.length - this.path.length, h.cumulativeInstanceCount, h.id);
12971
12937
  hierarchy.expand = () => {
12972
12938
  hierarchy.isExpanded = true;
@@ -12977,7 +12943,7 @@ class HierarchyNavigation extends Component {
12977
12943
  });
12978
12944
  };
12979
12945
  data[this.hierarchyNodeIdentifier(h.name)] = hierarchy;
12980
- if ((_a = h.hierarchyNodes) === null || _a === void 0 ? void 0 : _a.hits.length) {
12946
+ if (h.hierarchyNodes?.hits.length) {
12981
12947
  hierarchy.children = this.fillDataRecursively(h.hierarchyNodes, this.requestPayload(hierarchy), payloadForContinuation);
12982
12948
  }
12983
12949
  });
@@ -12994,36 +12960,34 @@ class HierarchyNavigation extends Component {
12994
12960
  .attr('arialabel', isHierarchyNode ? key : self.getAriaLabel(hORi))
12995
12961
  .attr('title', isHierarchyNode ? key : self.getAriaLabel(hORi))
12996
12962
  .attr("role", "treeitem").attr('aria-expanded', hORi.isExpanded)
12997
- .on('click keydown', function (event) {
12998
- return __awaiter(this, void 0, void 0, function* () {
12999
- if (Utils.isKeyDownAndNotEnter(event)) {
13000
- return;
13001
- }
13002
- if (!isHierarchyNode) { // means it is an instance
13003
- event.stopPropagation();
13004
- //we want to store clicked instance and hightlight it in the hierarchy
13005
- //if the instance is already selected, we want to deselect it
13006
- if (self.chartOptions.onInstanceClick) {
13007
- if (self.selectedIds && self.selectedIds.includes(hORi.id)) {
13008
- self.selectedIds = self.selectedIds.filter(id => id !== hORi.id);
13009
- hORi.node.classed('tsi-selected', false);
13010
- }
13011
- else {
13012
- self.selectedIds.push(hORi.id);
13013
- hORi.node.classed('tsi-selected', true);
13014
- }
13015
- }
13016
- self.chartOptions.onInstanceClick(hORi);
13017
- }
13018
- else {
13019
- if (hORi.isExpanded) {
13020
- hORi.collapse();
12963
+ .on('click keydown', async function (event) {
12964
+ if (Utils.isKeyDownAndNotEnter(event)) {
12965
+ return;
12966
+ }
12967
+ if (!isHierarchyNode) { // means it is an instance
12968
+ event.stopPropagation();
12969
+ //we want to store clicked instance and hightlight it in the hierarchy
12970
+ //if the instance is already selected, we want to deselect it
12971
+ if (self.chartOptions.onInstanceClick) {
12972
+ if (self.selectedIds && self.selectedIds.includes(hORi.id)) {
12973
+ self.selectedIds = self.selectedIds.filter(id => id !== hORi.id);
12974
+ hORi.node.classed('tsi-selected', false);
13021
12975
  }
13022
12976
  else {
13023
- yield hORi.expand();
12977
+ self.selectedIds.push(hORi.id);
12978
+ hORi.node.classed('tsi-selected', true);
13024
12979
  }
13025
12980
  }
13026
- });
12981
+ self.chartOptions.onInstanceClick(hORi);
12982
+ }
12983
+ else {
12984
+ if (hORi.isExpanded) {
12985
+ hORi.collapse();
12986
+ }
12987
+ else {
12988
+ await hORi.expand();
12989
+ }
12990
+ }
13027
12991
  });
13028
12992
  if (isHierarchyNode) {
13029
12993
  hierarchyItemElem.append('span').classed('tsi-caret-icon', true).attr('style', `left: ${(hORi.level) * 18 + 20}px`);