logitude-dashboard-library 3.2.55 → 3.2.57

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.
@@ -2538,6 +2538,7 @@ var quarters = ["Q", "Q1", "Q2", "Q3", "Q4"];
2538
2538
  function getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget) {
2539
2539
  if (seriesMeasuresIsEmpty(seriesMeasures)) return null;
2540
2540
  handelNullLabels(seriesMeasures);
2541
+ setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget);
2541
2542
  return {
2542
2543
  chart: chartInfo,
2543
2544
  categories: buildCategories(seriesMeasures, widget),
@@ -2547,6 +2548,7 @@ function getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget) {
2547
2548
  function getStackedDataSource(chartInfo, seriesMeasures, widget) {
2548
2549
  if (seriesMeasuresIsEmpty(seriesMeasures)) return null;
2549
2550
  handelNullLabels(seriesMeasures);
2551
+ setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget);
2550
2552
  return {
2551
2553
  chart: chartInfo,
2552
2554
  categories: buildStackedCategories(seriesMeasures, widget),
@@ -2579,6 +2581,66 @@ function seriesMeasuresIsEmpty(seriesMeasures) {
2579
2581
  return !hasValue;
2580
2582
  }
2581
2583
 
2584
+ function setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget) {
2585
+ if (!isColumnOrBarChart(widget)) return;
2586
+ var maxMeasureValue = getMaxMeasureValue(seriesMeasures, widget);
2587
+ if (maxMeasureValue === null) return;
2588
+ var safeYAxisMaxValue = Math.max(1, Math.ceil(maxMeasureValue * 1.2));
2589
+ chartInfo.yAxisMaxValue = safeYAxisMaxValue.toString();
2590
+ }
2591
+
2592
+ function getMaxMeasureValue(seriesMeasures, widget) {
2593
+ if (!seriesMeasures || seriesMeasures.length === 0) return null;
2594
+
2595
+ if (widget !== null && widget !== void 0 && widget.IsStacked) {
2596
+ var stackedTotalsByGroupId = new Map();
2597
+ seriesMeasures.forEach(function (seriesMeasure) {
2598
+ var _seriesMeasure$Values;
2599
+
2600
+ seriesMeasure === null || seriesMeasure === void 0 ? void 0 : (_seriesMeasure$Values = seriesMeasure.Values) === null || _seriesMeasure$Values === void 0 ? void 0 : _seriesMeasure$Values.forEach(function (valueItem) {
2601
+ var numericValue = toNumericValue(valueItem === null || valueItem === void 0 ? void 0 : valueItem.Value);
2602
+ if (numericValue === null) return;
2603
+ var groupId = valueItem === null || valueItem === void 0 ? void 0 : valueItem.GroupById;
2604
+ var currentTotal = stackedTotalsByGroupId.get(groupId) || 0;
2605
+ stackedTotalsByGroupId.set(groupId, currentTotal + numericValue);
2606
+ });
2607
+ });
2608
+ var maxStackedTotal = null;
2609
+ stackedTotalsByGroupId.forEach(function (total) {
2610
+ if (maxStackedTotal === null || total > maxStackedTotal) {
2611
+ maxStackedTotal = total;
2612
+ }
2613
+ });
2614
+ return maxStackedTotal;
2615
+ }
2616
+
2617
+ var maxValue = null;
2618
+ seriesMeasures.forEach(function (seriesMeasure) {
2619
+ var _seriesMeasure$Values2;
2620
+
2621
+ seriesMeasure === null || seriesMeasure === void 0 ? void 0 : (_seriesMeasure$Values2 = seriesMeasure.Values) === null || _seriesMeasure$Values2 === void 0 ? void 0 : _seriesMeasure$Values2.forEach(function (valueItem) {
2622
+ var numericValue = toNumericValue(valueItem === null || valueItem === void 0 ? void 0 : valueItem.Value);
2623
+ if (numericValue === null) return;
2624
+
2625
+ if (maxValue === null || numericValue > maxValue) {
2626
+ maxValue = numericValue;
2627
+ }
2628
+ });
2629
+ });
2630
+ return maxValue;
2631
+ }
2632
+
2633
+ function toNumericValue(value) {
2634
+ if (value === null || value === undefined || value === "") return null;
2635
+ var numericValue = typeof value === "number" ? value : Number(value);
2636
+ if (!Number.isFinite(numericValue)) return null;
2637
+ return numericValue;
2638
+ }
2639
+
2640
+ function isColumnOrBarChart(widget) {
2641
+ return (widget === null || widget === void 0 ? void 0 : widget.TypeCode) === "column" || (widget === null || widget === void 0 ? void 0 : widget.TypeCode) === "bar";
2642
+ }
2643
+
2582
2644
  function buildDataSource(values, widget) {
2583
2645
  var data = [];
2584
2646
  if (!values || !values[0]) return data;
@@ -3048,11 +3110,15 @@ function getDefaultChartInfo(widget) {
3048
3110
  chart.valuePosition = widget.ShowValue && widget.ValuePosition ? widget.ValuePosition : 'Outside';
3049
3111
  var isValuePositionInside = widget.ShowValue && widget.ValuePosition && widget.ValuePosition.toLowerCase() == 'inside';
3050
3112
 
3051
- if (widget.ShowValue && widget.ValuePosition && isColumnOrBarChart(widget)) {
3113
+ if (isColumnOrBarChart$1(widget)) {
3114
+ chart.canvasTopPadding = "40";
3115
+ }
3116
+
3117
+ if (widget.ShowValue && widget.ValuePosition && isColumnOrBarChart$1(widget)) {
3052
3118
  chart.placeValuesInside = widget.ValuePosition.toLowerCase() == 'inside' ? "1" : "0";
3053
3119
  }
3054
3120
 
3055
- if (widget.IsStacked && isValuePositionInside && isColumnOrBarChart(widget)) {
3121
+ if (widget.IsStacked && isValuePositionInside && isColumnOrBarChart$1(widget)) {
3056
3122
  chart.minPlotHeightForValue = "15";
3057
3123
  }
3058
3124
 
@@ -3120,7 +3186,7 @@ function getWidgetLegendPosition(widget) {
3120
3186
  return widget.TypeCode == 'pie' || widget.TypeCode == 'donut' ? "right" : "bottom";
3121
3187
  }
3122
3188
 
3123
- function isColumnOrBarChart(widget) {
3189
+ function isColumnOrBarChart$1(widget) {
3124
3190
  if (!widget) return false;
3125
3191
  return widget.TypeCode == 'column' || widget.TypeCode == 'bar';
3126
3192
  }
@@ -4024,7 +4090,7 @@ var FusionChart$1 = forwardRef(function (props, comRef) {
4024
4090
  });
4025
4091
 
4026
4092
  var WidgetCard = forwardRef(function (props, comRef) {
4027
- var _widget$current13, _widget$current14, _widget$current15;
4093
+ var _widget$current15, _widget$current16, _widget$current17, _widget$current18;
4028
4094
 
4029
4095
  var widget = useRef();
4030
4096
 
@@ -4046,15 +4112,39 @@ var WidgetCard = forwardRef(function (props, comRef) {
4046
4112
  headerErrorMessages = _useState4[0],
4047
4113
  setHeaderErrorMessages = _useState4[1];
4048
4114
 
4115
+ var _useState5 = useState(false),
4116
+ showCopiedNotification = _useState5[0],
4117
+ setShowCopiedNotification = _useState5[1];
4118
+
4119
+ var copyPopupRef = useRef(null);
4120
+ var copiedNotificationTimer = useRef(null);
4121
+
4049
4122
  var editWidget = function editWidget() {
4050
4123
  props.editBtnClicked(widget.current);
4051
4124
  };
4052
4125
 
4053
- var copyWidget = function copyWidget() {
4054
- if (props && props.copyBtnClicked) {
4126
+ var duplicateWidget = function duplicateWidget() {
4127
+ if (props && props.duplicateBtnClicked) {
4055
4128
  var _widget$current;
4056
4129
 
4057
- props.copyBtnClicked((_widget$current = widget.current) === null || _widget$current === void 0 ? void 0 : _widget$current.key);
4130
+ props.duplicateBtnClicked((_widget$current = widget.current) === null || _widget$current === void 0 ? void 0 : _widget$current.key);
4131
+ } else if (props && props.copyBtnClicked) {
4132
+ var _widget$current2;
4133
+
4134
+ props.copyBtnClicked((_widget$current2 = widget.current) === null || _widget$current2 === void 0 ? void 0 : _widget$current2.key);
4135
+ }
4136
+ };
4137
+
4138
+ var copyWidgetToClipboard = function copyWidgetToClipboard() {
4139
+ if (props && props.copyToClipboardBtnClicked && widget.current) {
4140
+ var _widget$current3;
4141
+
4142
+ props.copyToClipboardBtnClicked((_widget$current3 = widget.current) === null || _widget$current3 === void 0 ? void 0 : _widget$current3.key, widget.current);
4143
+ setShowCopiedNotification(true);
4144
+ if (copiedNotificationTimer.current) clearTimeout(copiedNotificationTimer.current);
4145
+ copiedNotificationTimer.current = setTimeout(function () {
4146
+ setShowCopiedNotification(false);
4147
+ }, 700);
4058
4148
  }
4059
4149
  };
4060
4150
 
@@ -4063,20 +4153,23 @@ var WidgetCard = forwardRef(function (props, comRef) {
4063
4153
 
4064
4154
  widget.current = props.widget;
4065
4155
  (_props$dataBinding = props.dataBinding) === null || _props$dataBinding === void 0 ? void 0 : _props$dataBinding.onEditWidget.subscribe(function (e) {
4066
- var _widget$current2;
4156
+ var _widget$current4;
4067
4157
 
4068
- if ((e === null || e === void 0 ? void 0 : e.key) != ((_widget$current2 = widget.current) === null || _widget$current2 === void 0 ? void 0 : _widget$current2.key)) return;
4158
+ if ((e === null || e === void 0 ? void 0 : e.key) != ((_widget$current4 = widget.current) === null || _widget$current4 === void 0 ? void 0 : _widget$current4.key)) return;
4069
4159
  setIsLoading(true);
4070
4160
  widget.current = _extends({}, e);
4071
4161
  setIsLoading(false);
4072
4162
  });
4073
4163
  (_props$dataBinding2 = props.dataBinding) === null || _props$dataBinding2 === void 0 ? void 0 : _props$dataBinding2.widgetUpdated.subscribe(function (updatedWidget) {
4074
- var _widget$current3;
4164
+ var _widget$current5;
4075
4165
 
4076
- if ((updatedWidget === null || updatedWidget === void 0 ? void 0 : updatedWidget.key) != ((_widget$current3 = widget.current) === null || _widget$current3 === void 0 ? void 0 : _widget$current3.key)) return;
4166
+ if ((updatedWidget === null || updatedWidget === void 0 ? void 0 : updatedWidget.key) != ((_widget$current5 = widget.current) === null || _widget$current5 === void 0 ? void 0 : _widget$current5.key)) return;
4077
4167
  widget.current = _extends({}, updatedWidget);
4078
4168
  setTriggerId(v4());
4079
4169
  });
4170
+ return function () {
4171
+ if (copiedNotificationTimer.current) clearTimeout(copiedNotificationTimer.current);
4172
+ };
4080
4173
  }, []);
4081
4174
  useImperativeHandle(comRef, function () {
4082
4175
  return {
@@ -4101,10 +4194,10 @@ var WidgetCard = forwardRef(function (props, comRef) {
4101
4194
  };
4102
4195
 
4103
4196
  var GetChartComponent = function GetChartComponent() {
4104
- var _widget$current4, _widget$current5, _widget$current6, _widget$current7, _widget$current8;
4197
+ var _widget$current6, _widget$current7, _widget$current8, _widget$current9, _widget$current10;
4105
4198
 
4106
- if (isLoading || !((_widget$current4 = widget.current) !== null && _widget$current4 !== void 0 && _widget$current4.TypeCode)) return "";
4107
- if (((_widget$current5 = widget.current) === null || _widget$current5 === void 0 ? void 0 : _widget$current5.TypeCode) == "kpi") return React__default.createElement(CustomChart, {
4199
+ if (isLoading || !((_widget$current6 = widget.current) !== null && _widget$current6 !== void 0 && _widget$current6.TypeCode)) return "";
4200
+ if (((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "kpi") return React__default.createElement(CustomChart, {
4108
4201
  isInEditMode: props.isInEditMode,
4109
4202
  isPreviewModeActive: props.isPreviewModeActive,
4110
4203
  dataBinding: props.dataBinding,
@@ -4115,7 +4208,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4115
4208
  return showErrorMsg(errorMsg);
4116
4209
  }
4117
4210
  });
4118
- if (((_widget$current6 = widget.current) === null || _widget$current6 === void 0 ? void 0 : _widget$current6.TypeCode) == "table" || ((_widget$current7 = widget.current) === null || _widget$current7 === void 0 ? void 0 : _widget$current7.TypeCode) == "pivot") return React__default.createElement(CustomChart, {
4211
+ if (((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.TypeCode) == "table" || ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.TypeCode) == "pivot") return React__default.createElement(CustomChart, {
4119
4212
  isInEditMode: props.isInEditMode,
4120
4213
  isPreviewModeActive: props.isPreviewModeActive,
4121
4214
  dataBinding: props.dataBinding,
@@ -4123,7 +4216,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4123
4216
  widgetRef: props.widgetRef,
4124
4217
  onSelectDataPoint: props.onSelectDataPoint
4125
4218
  });
4126
- if (((_widget$current8 = widget.current) === null || _widget$current8 === void 0 ? void 0 : _widget$current8.TypeCode) == "gauge") return React__default.createElement(FusionChart$1, {
4219
+ if (((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.TypeCode) == "gauge") return React__default.createElement(FusionChart$1, {
4127
4220
  ref: fusionChartRef,
4128
4221
  dataBinding: props.dataBinding,
4129
4222
  widget: widget.current,
@@ -4182,15 +4275,15 @@ var WidgetCard = forwardRef(function (props, comRef) {
4182
4275
  };
4183
4276
 
4184
4277
  var isThereTitle = function isThereTitle() {
4185
- var _widget$current9, _widget$current10;
4278
+ var _widget$current11, _widget$current12;
4186
4279
 
4187
- return ((_widget$current9 = widget.current) === null || _widget$current9 === void 0 ? void 0 : _widget$current9.Title) && ((_widget$current10 = widget.current) === null || _widget$current10 === void 0 ? void 0 : _widget$current10.Title.length) > 0;
4280
+ return ((_widget$current11 = widget.current) === null || _widget$current11 === void 0 ? void 0 : _widget$current11.Title) && ((_widget$current12 = widget.current) === null || _widget$current12 === void 0 ? void 0 : _widget$current12.Title.length) > 0;
4188
4281
  };
4189
4282
 
4190
4283
  var isThereSubtitle = function isThereSubtitle() {
4191
- var _widget$current11, _widget$current12;
4284
+ var _widget$current13, _widget$current14;
4192
4285
 
4193
- return ((_widget$current11 = widget.current) === null || _widget$current11 === void 0 ? void 0 : _widget$current11.Subtitle) && ((_widget$current12 = widget.current) === null || _widget$current12 === void 0 ? void 0 : _widget$current12.Subtitle.length) > 0;
4286
+ return ((_widget$current13 = widget.current) === null || _widget$current13 === void 0 ? void 0 : _widget$current13.Subtitle) && ((_widget$current14 = widget.current) === null || _widget$current14 === void 0 ? void 0 : _widget$current14.Subtitle.length) > 0;
4194
4287
  };
4195
4288
 
4196
4289
  var tableHintMessage = function tableHintMessage() {
@@ -4239,7 +4332,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4239
4332
  color: getCSSPropertyValue(widget.current, 'TitleFontColor', ''),
4240
4333
  textAlign: getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined)
4241
4334
  }
4242
- }, (_widget$current13 = widget.current) === null || _widget$current13 === void 0 ? void 0 : _widget$current13.Title),
4335
+ }, (_widget$current15 = widget.current) === null || _widget$current15 === void 0 ? void 0 : _widget$current15.Title),
4243
4336
  position: ['top center'],
4244
4337
  arrowStyle: {
4245
4338
  color: '#19395C'
@@ -4248,7 +4341,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4248
4341
  on: ['hover', 'focus']
4249
4342
  }, React__default.createElement("span", {
4250
4343
  className: "widget-title-tooltip-text"
4251
- }, (_widget$current14 = widget.current) === null || _widget$current14 === void 0 ? void 0 : _widget$current14.Title))), isTableOrPivotWidget() && isThereTitle() && isThereSubtitle() && React__default.createElement("div", {
4344
+ }, (_widget$current16 = widget.current) === null || _widget$current16 === void 0 ? void 0 : _widget$current16.Title))), isTableOrPivotWidget() && isThereTitle() && isThereSubtitle() && React__default.createElement("div", {
4252
4345
  className: "titles-vertical-seeparator"
4253
4346
  }), React__default.createElement("div", {
4254
4347
  className: isThereSubtitle() ? "subtitle" : "subtitle margin-top-4",
@@ -4258,25 +4351,57 @@ var WidgetCard = forwardRef(function (props, comRef) {
4258
4351
  color: getCSSPropertyValue(widget.current, 'SubtitleFontColor', ''),
4259
4352
  minWidth: isThereSubtitle() && isTableOrPivotWidget() ? '5%' : undefined
4260
4353
  }
4261
- }, (_widget$current15 = widget.current) === null || _widget$current15 === void 0 ? void 0 : _widget$current15.Subtitle)), !isTitleAligmentRight() && isTableOrPivotWidget() && tableHintMessage(), props.isInEditMode && React__default.createElement("div", {
4354
+ }, (_widget$current17 = widget.current) === null || _widget$current17 === void 0 ? void 0 : _widget$current17.Subtitle)), !isTitleAligmentRight() && isTableOrPivotWidget() && tableHintMessage(), props.isInEditMode && React__default.createElement("div", {
4262
4355
  className: isThereTitle() ? "widget-options-container" : "widget-options-container margin-top-6"
4263
4356
  }, React__default.createElement("div", null, " ", React__default.createElement(SvgEditIcon, {
4264
4357
  className: "widget-card-edit-icon",
4265
4358
  onClick: function onClick() {
4266
4359
  return editWidget();
4267
4360
  }
4268
- }), " "), React__default.createElement("div", null, " ", React__default.createElement(SvgCopyIcon, {
4269
- className: "widget-card-copy-icon",
4361
+ }), " "), React__default.createElement(Popup, {
4362
+ ref: copyPopupRef,
4363
+ className: "widget-copy-dropdown-container",
4364
+ trigger: React__default.createElement("div", null, React__default.createElement(SvgCopyIcon, {
4365
+ className: "widget-card-copy-icon"
4366
+ })),
4367
+ position: ['bottom left', 'bottom center'],
4368
+ closeOnDocumentClick: true,
4369
+ closeOnEscape: true,
4370
+ arrow: false,
4371
+ offsetY: 2
4372
+ }, React__default.createElement("div", {
4373
+ className: "widget-copy-dropdown-menu"
4374
+ }, React__default.createElement("div", {
4375
+ className: "widget-copy-dropdown-item",
4270
4376
  onClick: function onClick() {
4271
- return copyWidget();
4377
+ var _copyPopupRef$current;
4378
+
4379
+ (_copyPopupRef$current = copyPopupRef.current) === null || _copyPopupRef$current === void 0 ? void 0 : _copyPopupRef$current.close();
4380
+ duplicateWidget();
4272
4381
  }
4273
- }), " "), React__default.createElement("div", null, " ", React__default.createElement(SvgDeleteIcon, {
4382
+ }, "Duplicate"), React__default.createElement("div", {
4383
+ className: "widget-copy-dropdown-item",
4384
+ onClick: function onClick() {
4385
+ var _copyPopupRef$current2;
4386
+
4387
+ (_copyPopupRef$current2 = copyPopupRef.current) === null || _copyPopupRef$current2 === void 0 ? void 0 : _copyPopupRef$current2.close();
4388
+ copyWidgetToClipboard();
4389
+ }
4390
+ }, "Copy"))), React__default.createElement("div", null, " ", React__default.createElement(SvgDeleteIcon, {
4274
4391
  onClick: function onClick() {
4275
4392
  var _props$widget;
4276
4393
 
4277
4394
  return props.deleteBtnClicked((_props$widget = props.widget) === null || _props$widget === void 0 ? void 0 : _props$widget.key);
4278
4395
  }
4279
- }), " ")), !props.isInEditMode && showHeaderErrorMessages && React__default.createElement("div", {
4396
+ }), " ")), showCopiedNotification && React__default.createElement("div", {
4397
+ className: "widget-copied-notification"
4398
+ }, React__default.createElement("span", {
4399
+ className: "widget-copied-notification-check"
4400
+ }, "\u2713"), React__default.createElement("span", {
4401
+ className: "widget-copied-notification-title"
4402
+ }, (_widget$current18 = widget.current) === null || _widget$current18 === void 0 ? void 0 : _widget$current18.Title), React__default.createElement("span", {
4403
+ className: "widget-copied-notification-text"
4404
+ }, "widget copied")), !props.isInEditMode && showHeaderErrorMessages && React__default.createElement("div", {
4280
4405
  className: "header-message-error"
4281
4406
  }, React__default.createElement(Popup, {
4282
4407
  className: "header-message-error-tooltip-container",
@@ -4452,6 +4577,12 @@ var DashboardDesigner = function DashboardDesigner(props) {
4452
4577
  }
4453
4578
  }
4454
4579
 
4580
+ function copyWidgetToClipboard(key, widget) {
4581
+ if (props && props.onCopyWidgetToClipboard) {
4582
+ props.onCopyWidgetToClipboard(key, widget);
4583
+ }
4584
+ }
4585
+
4455
4586
  function UpdatePlaceholderDimensions(layouts) {
4456
4587
  if (!layouts) return;
4457
4588
  var max = minimumPlaceholderRowsCount;
@@ -4524,7 +4655,8 @@ var DashboardDesigner = function DashboardDesigner(props) {
4524
4655
  editBtnClicked: editWidget,
4525
4656
  deleteBtnClicked: confirmDeleteWidget,
4526
4657
  onSelectDataPoint: props.onSelectDataPoint,
4527
- copyBtnClicked: copyWidget,
4658
+ duplicateBtnClicked: copyWidget,
4659
+ copyToClipboardBtnClicked: copyWidgetToClipboard,
4528
4660
  ref: function ref(el) {
4529
4661
  var _widget$Layout3;
4530
4662
 
@@ -4606,6 +4738,12 @@ var Dashboard = function Dashboard(props) {
4606
4738
  }
4607
4739
  };
4608
4740
 
4741
+ var copyWidgetToClipboard = function copyWidgetToClipboard(key, widget) {
4742
+ if (props && props.onCopyWidgetToClipboard) {
4743
+ props.onCopyWidgetToClipboard(key, widget);
4744
+ }
4745
+ };
4746
+
4609
4747
  var updateWidgets = function updateWidgets(layouts) {
4610
4748
  var layoutsDic = {};
4611
4749
  Object.keys(layouts).forEach(function (sizeType) {
@@ -4673,6 +4811,7 @@ var Dashboard = function Dashboard(props) {
4673
4811
  return props.openDeleteWidgetConfirmWindow(deleteProps);
4674
4812
  },
4675
4813
  onCopyWidget: copyWidget,
4814
+ onCopyWidgetToClipboard: copyWidgetToClipboard,
4676
4815
  openEditWidget: function openEditWidget(widget) {
4677
4816
  return props.openEditWidget(widget);
4678
4817
  }