logitude-dashboard-library 3.2.56 → 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.
@@ -2598,12 +2598,10 @@ function getMaxMeasureValue(seriesMeasures, widget) {
2598
2598
  var _seriesMeasure$Values;
2599
2599
 
2600
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 _stackedTotalsByGroup;
2602
-
2603
2601
  var numericValue = toNumericValue(valueItem === null || valueItem === void 0 ? void 0 : valueItem.Value);
2604
2602
  if (numericValue === null) return;
2605
2603
  var groupId = valueItem === null || valueItem === void 0 ? void 0 : valueItem.GroupById;
2606
- var currentTotal = (_stackedTotalsByGroup = stackedTotalsByGroupId.get(groupId)) != null ? _stackedTotalsByGroup : 0;
2604
+ var currentTotal = stackedTotalsByGroupId.get(groupId) || 0;
2607
2605
  stackedTotalsByGroupId.set(groupId, currentTotal + numericValue);
2608
2606
  });
2609
2607
  });
@@ -4092,7 +4090,7 @@ var FusionChart$1 = forwardRef(function (props, comRef) {
4092
4090
  });
4093
4091
 
4094
4092
  var WidgetCard = forwardRef(function (props, comRef) {
4095
- var _widget$current13, _widget$current14, _widget$current15;
4093
+ var _widget$current15, _widget$current16, _widget$current17, _widget$current18;
4096
4094
 
4097
4095
  var widget = useRef();
4098
4096
 
@@ -4114,15 +4112,39 @@ var WidgetCard = forwardRef(function (props, comRef) {
4114
4112
  headerErrorMessages = _useState4[0],
4115
4113
  setHeaderErrorMessages = _useState4[1];
4116
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
+
4117
4122
  var editWidget = function editWidget() {
4118
4123
  props.editBtnClicked(widget.current);
4119
4124
  };
4120
4125
 
4121
- var copyWidget = function copyWidget() {
4122
- if (props && props.copyBtnClicked) {
4126
+ var duplicateWidget = function duplicateWidget() {
4127
+ if (props && props.duplicateBtnClicked) {
4123
4128
  var _widget$current;
4124
4129
 
4125
- 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);
4126
4148
  }
4127
4149
  };
4128
4150
 
@@ -4131,20 +4153,23 @@ var WidgetCard = forwardRef(function (props, comRef) {
4131
4153
 
4132
4154
  widget.current = props.widget;
4133
4155
  (_props$dataBinding = props.dataBinding) === null || _props$dataBinding === void 0 ? void 0 : _props$dataBinding.onEditWidget.subscribe(function (e) {
4134
- var _widget$current2;
4156
+ var _widget$current4;
4135
4157
 
4136
- 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;
4137
4159
  setIsLoading(true);
4138
4160
  widget.current = _extends({}, e);
4139
4161
  setIsLoading(false);
4140
4162
  });
4141
4163
  (_props$dataBinding2 = props.dataBinding) === null || _props$dataBinding2 === void 0 ? void 0 : _props$dataBinding2.widgetUpdated.subscribe(function (updatedWidget) {
4142
- var _widget$current3;
4164
+ var _widget$current5;
4143
4165
 
4144
- 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;
4145
4167
  widget.current = _extends({}, updatedWidget);
4146
4168
  setTriggerId(v4());
4147
4169
  });
4170
+ return function () {
4171
+ if (copiedNotificationTimer.current) clearTimeout(copiedNotificationTimer.current);
4172
+ };
4148
4173
  }, []);
4149
4174
  useImperativeHandle(comRef, function () {
4150
4175
  return {
@@ -4169,10 +4194,10 @@ var WidgetCard = forwardRef(function (props, comRef) {
4169
4194
  };
4170
4195
 
4171
4196
  var GetChartComponent = function GetChartComponent() {
4172
- var _widget$current4, _widget$current5, _widget$current6, _widget$current7, _widget$current8;
4197
+ var _widget$current6, _widget$current7, _widget$current8, _widget$current9, _widget$current10;
4173
4198
 
4174
- if (isLoading || !((_widget$current4 = widget.current) !== null && _widget$current4 !== void 0 && _widget$current4.TypeCode)) return "";
4175
- 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, {
4176
4201
  isInEditMode: props.isInEditMode,
4177
4202
  isPreviewModeActive: props.isPreviewModeActive,
4178
4203
  dataBinding: props.dataBinding,
@@ -4183,7 +4208,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4183
4208
  return showErrorMsg(errorMsg);
4184
4209
  }
4185
4210
  });
4186
- 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, {
4187
4212
  isInEditMode: props.isInEditMode,
4188
4213
  isPreviewModeActive: props.isPreviewModeActive,
4189
4214
  dataBinding: props.dataBinding,
@@ -4191,7 +4216,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4191
4216
  widgetRef: props.widgetRef,
4192
4217
  onSelectDataPoint: props.onSelectDataPoint
4193
4218
  });
4194
- 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, {
4195
4220
  ref: fusionChartRef,
4196
4221
  dataBinding: props.dataBinding,
4197
4222
  widget: widget.current,
@@ -4250,15 +4275,15 @@ var WidgetCard = forwardRef(function (props, comRef) {
4250
4275
  };
4251
4276
 
4252
4277
  var isThereTitle = function isThereTitle() {
4253
- var _widget$current9, _widget$current10;
4278
+ var _widget$current11, _widget$current12;
4254
4279
 
4255
- 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;
4256
4281
  };
4257
4282
 
4258
4283
  var isThereSubtitle = function isThereSubtitle() {
4259
- var _widget$current11, _widget$current12;
4284
+ var _widget$current13, _widget$current14;
4260
4285
 
4261
- 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;
4262
4287
  };
4263
4288
 
4264
4289
  var tableHintMessage = function tableHintMessage() {
@@ -4307,7 +4332,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4307
4332
  color: getCSSPropertyValue(widget.current, 'TitleFontColor', ''),
4308
4333
  textAlign: getCSSPropertyValue(widget === null || widget === void 0 ? void 0 : widget.current, 'TitleAlignment', '', undefined)
4309
4334
  }
4310
- }, (_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),
4311
4336
  position: ['top center'],
4312
4337
  arrowStyle: {
4313
4338
  color: '#19395C'
@@ -4316,7 +4341,7 @@ var WidgetCard = forwardRef(function (props, comRef) {
4316
4341
  on: ['hover', 'focus']
4317
4342
  }, React__default.createElement("span", {
4318
4343
  className: "widget-title-tooltip-text"
4319
- }, (_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", {
4320
4345
  className: "titles-vertical-seeparator"
4321
4346
  }), React__default.createElement("div", {
4322
4347
  className: isThereSubtitle() ? "subtitle" : "subtitle margin-top-4",
@@ -4326,25 +4351,57 @@ var WidgetCard = forwardRef(function (props, comRef) {
4326
4351
  color: getCSSPropertyValue(widget.current, 'SubtitleFontColor', ''),
4327
4352
  minWidth: isThereSubtitle() && isTableOrPivotWidget() ? '5%' : undefined
4328
4353
  }
4329
- }, (_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", {
4330
4355
  className: isThereTitle() ? "widget-options-container" : "widget-options-container margin-top-6"
4331
4356
  }, React__default.createElement("div", null, " ", React__default.createElement(SvgEditIcon, {
4332
4357
  className: "widget-card-edit-icon",
4333
4358
  onClick: function onClick() {
4334
4359
  return editWidget();
4335
4360
  }
4336
- }), " "), React__default.createElement("div", null, " ", React__default.createElement(SvgCopyIcon, {
4337
- 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",
4338
4376
  onClick: function onClick() {
4339
- return copyWidget();
4377
+ var _copyPopupRef$current;
4378
+
4379
+ (_copyPopupRef$current = copyPopupRef.current) === null || _copyPopupRef$current === void 0 ? void 0 : _copyPopupRef$current.close();
4380
+ duplicateWidget();
4381
+ }
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();
4340
4389
  }
4341
- }), " "), React__default.createElement("div", null, " ", React__default.createElement(SvgDeleteIcon, {
4390
+ }, "Copy"))), React__default.createElement("div", null, " ", React__default.createElement(SvgDeleteIcon, {
4342
4391
  onClick: function onClick() {
4343
4392
  var _props$widget;
4344
4393
 
4345
4394
  return props.deleteBtnClicked((_props$widget = props.widget) === null || _props$widget === void 0 ? void 0 : _props$widget.key);
4346
4395
  }
4347
- }), " ")), !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", {
4348
4405
  className: "header-message-error"
4349
4406
  }, React__default.createElement(Popup, {
4350
4407
  className: "header-message-error-tooltip-container",
@@ -4520,6 +4577,12 @@ var DashboardDesigner = function DashboardDesigner(props) {
4520
4577
  }
4521
4578
  }
4522
4579
 
4580
+ function copyWidgetToClipboard(key, widget) {
4581
+ if (props && props.onCopyWidgetToClipboard) {
4582
+ props.onCopyWidgetToClipboard(key, widget);
4583
+ }
4584
+ }
4585
+
4523
4586
  function UpdatePlaceholderDimensions(layouts) {
4524
4587
  if (!layouts) return;
4525
4588
  var max = minimumPlaceholderRowsCount;
@@ -4592,7 +4655,8 @@ var DashboardDesigner = function DashboardDesigner(props) {
4592
4655
  editBtnClicked: editWidget,
4593
4656
  deleteBtnClicked: confirmDeleteWidget,
4594
4657
  onSelectDataPoint: props.onSelectDataPoint,
4595
- copyBtnClicked: copyWidget,
4658
+ duplicateBtnClicked: copyWidget,
4659
+ copyToClipboardBtnClicked: copyWidgetToClipboard,
4596
4660
  ref: function ref(el) {
4597
4661
  var _widget$Layout3;
4598
4662
 
@@ -4674,6 +4738,12 @@ var Dashboard = function Dashboard(props) {
4674
4738
  }
4675
4739
  };
4676
4740
 
4741
+ var copyWidgetToClipboard = function copyWidgetToClipboard(key, widget) {
4742
+ if (props && props.onCopyWidgetToClipboard) {
4743
+ props.onCopyWidgetToClipboard(key, widget);
4744
+ }
4745
+ };
4746
+
4677
4747
  var updateWidgets = function updateWidgets(layouts) {
4678
4748
  var layoutsDic = {};
4679
4749
  Object.keys(layouts).forEach(function (sizeType) {
@@ -4741,6 +4811,7 @@ var Dashboard = function Dashboard(props) {
4741
4811
  return props.openDeleteWidgetConfirmWindow(deleteProps);
4742
4812
  },
4743
4813
  onCopyWidget: copyWidget,
4814
+ onCopyWidgetToClipboard: copyWidgetToClipboard,
4744
4815
  openEditWidget: function openEditWidget(widget) {
4745
4816
  return props.openEditWidget(widget);
4746
4817
  }