@websy/websy-designs 1.10.0 → 1.10.2

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.
@@ -1459,6 +1459,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1459
1459
  closeAfterSelection: true,
1460
1460
  customActions: [],
1461
1461
  customButtons: [],
1462
+ minWidth: 220,
1462
1463
  searchIcon: "<svg width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>",
1463
1464
  clearIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 512 512\"><title>ionicons-v5-l</title><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
1464
1465
  arrowIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>",
@@ -1526,6 +1527,15 @@ var WebsyDropdown = /*#__PURE__*/function () {
1526
1527
  }
1527
1528
  html += "\n <div id='".concat(this.elementId, "_itemsContainer' class='websy-dropdown-items'>\n <ul id='").concat(this.elementId, "_items'> \n </ul>\n </div><!--\n --><div class='websy-dropdown-custom'></div>\n </div>\n </div>\n ");
1528
1529
  el.innerHTML = html;
1530
+ var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1531
+ if (maskEl) {
1532
+ maskEl.addEventListener('mousewheel', function (event) {
1533
+ if (event.target.classList.contains('websy-dropdown-mask')) {
1534
+ event.preventDefault();
1535
+ event.stopPropagation();
1536
+ }
1537
+ });
1538
+ }
1529
1539
  var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
1530
1540
  if (scrollEl) {
1531
1541
  scrollEl.addEventListener('scroll', this.handleScroll.bind(this));
@@ -1767,7 +1777,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1767
1777
  var contentPos = WebsyUtils.getElementPos(contentEl);
1768
1778
  if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1769
1779
  contentEl.style.right = "calc(100vw - ".concat(headerPos.right, "px)");
1770
- contentEl.style.width = "".concat(headerEl.clientWidth, "px");
1780
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, headerEl.clientWidth), "px");
1771
1781
  if (headerPos.bottom + contentPos.height > window.innerHeight) {
1772
1782
  // contentEl.classList.add('on-top')
1773
1783
  contentEl.style.bottom = "calc(100vh - ".concat(headerPos.top, "px)");
@@ -1777,7 +1787,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1777
1787
  } else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1778
1788
  var targetPos = WebsyUtils.getElementPos(event.target);
1779
1789
  contentEl.style.right = "calc(100vw - ".concat(targetPos.right, "px)");
1780
- contentEl.style.width = "".concat(targetPos.width, "px");
1790
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, targetPos.width), "px");
1781
1791
  }
1782
1792
  if (this.options.disableSearch !== true) {
1783
1793
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
@@ -3585,7 +3595,11 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3585
3595
  classes: [],
3586
3596
  wait: 0,
3587
3597
  buttonText: 'Download',
3588
- directDownload: false
3598
+ directDownload: false,
3599
+ preProcess: function preProcess(callbackFn) {
3600
+ return callbackFn(true);
3601
+ },
3602
+ onError: function onError() {}
3589
3603
  };
3590
3604
  this.elementId = elementId;
3591
3605
  this.options = _extends({}, DEFAULTS, options);
@@ -3616,80 +3630,87 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3616
3630
  var _this27 = this;
3617
3631
  if (event.target.classList.contains('websy-pdf-button')) {
3618
3632
  this.loader.show();
3619
- setTimeout(function () {
3620
- if (_this27.options.targetId) {
3621
- var el = document.getElementById(_this27.options.targetId);
3622
- if (el) {
3623
- var pdfData = {
3624
- options: {}
3625
- };
3626
- if (_this27.options.pdfOptions) {
3627
- pdfData.options = _extends({}, _this27.options.pdfOptions);
3628
- }
3629
- if (_this27.options.header) {
3630
- if (_this27.options.header.elementId) {
3631
- var headerEl = document.getElementById(_this27.options.header.elementId);
3632
- if (headerEl) {
3633
- pdfData.header = headerEl.outerHTML;
3634
- if (_this27.options.header.css) {
3635
- pdfData.options.headerCSS = _this27.options.header.css;
3636
- }
3633
+ this.options.preProcess(function (proceed) {
3634
+ if (proceed === true) {
3635
+ setTimeout(function () {
3636
+ if (_this27.options.targetId) {
3637
+ var el = document.getElementById(_this27.options.targetId);
3638
+ if (el) {
3639
+ var pdfData = {
3640
+ options: {}
3641
+ };
3642
+ if (_this27.options.pdfOptions) {
3643
+ pdfData.options = _extends({}, _this27.options.pdfOptions);
3637
3644
  }
3638
- } else if (_this27.options.header.html) {
3639
- pdfData.header = _this27.options.header.html;
3640
- if (_this27.options.header.css) {
3641
- pdfData.options.headerCSS = _this27.options.header.css;
3645
+ if (_this27.options.header) {
3646
+ if (_this27.options.header.elementId) {
3647
+ var headerEl = document.getElementById(_this27.options.header.elementId);
3648
+ if (headerEl) {
3649
+ pdfData.header = headerEl.outerHTML;
3650
+ if (_this27.options.header.css) {
3651
+ pdfData.options.headerCSS = _this27.options.header.css;
3652
+ }
3653
+ }
3654
+ } else if (_this27.options.header.html) {
3655
+ pdfData.header = _this27.options.header.html;
3656
+ if (_this27.options.header.css) {
3657
+ pdfData.options.headerCSS = _this27.options.header.css;
3658
+ }
3659
+ } else {
3660
+ pdfData.header = _this27.options.header;
3661
+ }
3642
3662
  }
3643
- } else {
3644
- pdfData.header = _this27.options.header;
3645
- }
3646
- }
3647
- if (_this27.options.footer) {
3648
- if (_this27.options.footer.elementId) {
3649
- var footerEl = document.getElementById(_this27.options.footer.elementId);
3650
- if (footerEl) {
3651
- pdfData.footer = footerEl.outerHTML;
3652
- if (_this27.options.footer.css) {
3653
- pdfData.options.footerCSS = _this27.options.footer.css;
3663
+ if (_this27.options.footer) {
3664
+ if (_this27.options.footer.elementId) {
3665
+ var footerEl = document.getElementById(_this27.options.footer.elementId);
3666
+ if (footerEl) {
3667
+ pdfData.footer = footerEl.outerHTML;
3668
+ if (_this27.options.footer.css) {
3669
+ pdfData.options.footerCSS = _this27.options.footer.css;
3670
+ }
3671
+ }
3672
+ } else {
3673
+ pdfData.footer = _this27.options.footer;
3654
3674
  }
3655
3675
  }
3656
- } else {
3657
- pdfData.footer = _this27.options.footer;
3676
+ pdfData.html = el.outerHTML;
3677
+ // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3678
+ // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3679
+ // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3680
+ // document.getElementById(`${this.elementId}_form`).submit()
3681
+ _this27.service.add('', pdfData, {
3682
+ responseType: 'blob'
3683
+ }).then(function (response) {
3684
+ _this27.loader.hide();
3685
+ var blob = new Blob([response], {
3686
+ type: 'application/pdf'
3687
+ });
3688
+ var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
3689
+ if (_this27.options.directDownload === true) {
3690
+ var fileName;
3691
+ if (typeof _this27.options.fileName === 'function') {
3692
+ fileName = _this27.options.fileName() || 'Export';
3693
+ } else {
3694
+ fileName = _this27.options.fileName || 'Export';
3695
+ }
3696
+ msg += "download='".concat(fileName, ".pdf'");
3697
+ }
3698
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this27.options.buttonText, "</button>\n </a>\n </div>\n ");
3699
+ _this27.popup.show({
3700
+ message: msg,
3701
+ mask: true
3702
+ });
3703
+ }, function (err) {
3704
+ console.error(err);
3705
+ });
3658
3706
  }
3659
3707
  }
3660
- pdfData.html = el.outerHTML;
3661
- // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3662
- // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3663
- // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3664
- // document.getElementById(`${this.elementId}_form`).submit()
3665
- _this27.service.add('', pdfData, {
3666
- responseType: 'blob'
3667
- }).then(function (response) {
3668
- _this27.loader.hide();
3669
- var blob = new Blob([response], {
3670
- type: 'application/pdf'
3671
- });
3672
- var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
3673
- if (_this27.options.directDownload === true) {
3674
- var fileName;
3675
- if (typeof _this27.options.fileName === 'function') {
3676
- fileName = _this27.options.fileName() || 'Export';
3677
- } else {
3678
- fileName = _this27.options.fileName || 'Export';
3679
- }
3680
- msg += "download='".concat(fileName, ".pdf'");
3681
- }
3682
- msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this27.options.buttonText, "</button>\n </a>\n </div>\n ");
3683
- _this27.popup.show({
3684
- message: msg,
3685
- mask: true
3686
- });
3687
- }, function (err) {
3688
- console.error(err);
3689
- });
3690
- }
3708
+ }, _this27.options.wait);
3709
+ } else {
3710
+ _this27.loader.hide();
3711
+ _this27.options.onError();
3691
3712
  }
3692
- }, this.options.wait);
3713
+ });
3693
3714
  } else if (event.target.classList.contains('download-pdf')) {
3694
3715
  this.popup.hide();
3695
3716
  if (this.options.onClose) {
@@ -5521,10 +5542,14 @@ var WebsyUtils = {
5521
5542
  var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
5522
5543
  var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
5523
5544
  return {
5524
- top: rect.top + scrollTop,
5525
- left: rect.left + scrollLeft,
5526
- bottom: rect.top + scrollTop + el.clientHeight,
5527
- right: rect.left + scrollLeft + el.clientWidth,
5545
+ top: rect.top,
5546
+ // + scrollTop,
5547
+ left: rect.left,
5548
+ // + scrollLeft,
5549
+ // bottom: rect.top + scrollTop + el.clientHeight,
5550
+ bottom: rect.top + el.clientHeight,
5551
+ // right: rect.left + scrollLeft + el.clientWidth,
5552
+ right: rect.left + el.clientWidth,
5528
5553
  width: rect.width,
5529
5554
  height: rect.height
5530
5555
  };
@@ -5722,6 +5747,7 @@ var WebsyTable = /*#__PURE__*/function () {
5722
5747
  this.busy = false;
5723
5748
  this.tooltipTimeoutFn = null;
5724
5749
  this.data = [];
5750
+ this._isRendered = false;
5725
5751
  var el = document.getElementById(this.elementId);
5726
5752
  if (el) {
5727
5753
  var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table ").concat(this.options.paging === 'pages' ? 'with-paging' : '', "'>\n <!--<div class=\"download-button\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z\"/></svg>\n </div>-->\n <table>\n <thead id=\"").concat(this.elementId, "_head\">\n </thead>\n <tbody id=\"").concat(this.elementId, "_body\">\n </tbody>\n <tfoot id=\"").concat(this.elementId, "_foot\">\n </tfoot>\n </table> \n <div id=\"").concat(this.elementId, "_errorContainer\" class='websy-vis-error-container'>\n <div>\n <div id=\"").concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div> \n </div>\n <div id=\"").concat(this.elementId, "_loadingContainer\"></div>\n </div>\n ");
@@ -5760,9 +5786,15 @@ var WebsyTable = /*#__PURE__*/function () {
5760
5786
  }
5761
5787
  }
5762
5788
  _createClass(WebsyTable, [{
5789
+ key: "isRendered",
5790
+ get: function get() {
5791
+ return this._isRendered;
5792
+ }
5793
+ }, {
5763
5794
  key: "appendRows",
5764
5795
  value: function appendRows(data) {
5765
5796
  var _this39 = this;
5797
+ this._isRendered = false;
5766
5798
  this.hideError();
5767
5799
  var bodyHTML = '';
5768
5800
  if (data) {
@@ -5804,6 +5836,7 @@ var WebsyTable = /*#__PURE__*/function () {
5804
5836
  }
5805
5837
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5806
5838
  bodyEl.innerHTML += bodyHTML;
5839
+ this._isRendered = true;
5807
5840
  }
5808
5841
  }, {
5809
5842
  key: "buildSearchIcon",
@@ -5954,6 +5987,7 @@ var WebsyTable = /*#__PURE__*/function () {
5954
5987
  key: "render",
5955
5988
  value: function render(data) {
5956
5989
  var _this40 = this;
5990
+ this._isRendered = false;
5957
5991
  if (!this.options.columns) {
5958
5992
  return;
5959
5993
  }
@@ -6584,6 +6618,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6584
6618
  autoFitColumns: true
6585
6619
  };
6586
6620
  this.options = _extends({}, DEFAULTS, options);
6621
+ this._isRendered = false;
6587
6622
  this.isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
6588
6623
  if (this.options.disableTouch === true) {
6589
6624
  this.isTouchDevice = false;
@@ -6644,6 +6679,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
6644
6679
  }
6645
6680
  }
6646
6681
  _createClass(WebsyTable3, [{
6682
+ key: "isRendered",
6683
+ get: function get() {
6684
+ return this._isRendered;
6685
+ }
6686
+ }, {
6647
6687
  key: "columns",
6648
6688
  set: function set(columns) {
6649
6689
  this.options.columns = columns;
@@ -6658,6 +6698,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6658
6698
  }, {
6659
6699
  key: "appendRows",
6660
6700
  value: function appendRows(data) {
6701
+ this._isRendered = false;
6661
6702
  this.hideError();
6662
6703
  var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
6663
6704
  if (bodyEl) {
@@ -6669,6 +6710,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6669
6710
  bodyEl.querySelector('tbody').innerHTML += this.buildBodyHtml(data, true, true);
6670
6711
  } else {
6671
6712
  bodyEl.innerHTML += this.buildBodyHtml(data, true);
6713
+ this._isRendered = true;
6672
6714
  }
6673
6715
  this.currentData = this.currentData.concat(data);
6674
6716
  }
@@ -7674,10 +7716,12 @@ var WebsyChart = /*#__PURE__*/function () {
7674
7716
  maxBandWidth: 100,
7675
7717
  allowUnevenBands: true,
7676
7718
  allowBrushing: true,
7677
- balancedMinMax: false
7719
+ balancedMinMax: false,
7720
+ onRendered: function onRendered() {}
7678
7721
  };
7679
7722
  this.elementId = elementId;
7680
7723
  this.options = _extends({}, DEFAULTS, options);
7724
+ this._isRendered = false;
7681
7725
  this.leftAxis = null;
7682
7726
  this.rightAxis = null;
7683
7727
  this.topAxis = null;
@@ -7716,21 +7760,6 @@ var WebsyChart = /*#__PURE__*/function () {
7716
7760
  }
7717
7761
  }
7718
7762
  }
7719
- // }
7720
- // else {
7721
- // let domain = [...this[xAxis].domain()]
7722
- // if (this.options.orientation === 'horizontal') {
7723
- // domain = domain.reverse()
7724
- // }
7725
- // for (let j = 0; j < domain.length; j++) {
7726
- // let breakA = this[xAxis](domain[j]) - (width / 2)
7727
- // let breakB = breakA + width
7728
- // if (input > breakA && input <= breakB) {
7729
- // output = j
7730
- // break
7731
- // }
7732
- // }
7733
- // }
7734
7763
  return output;
7735
7764
  };
7736
7765
  var that = this;
@@ -7805,6 +7834,11 @@ var WebsyChart = /*#__PURE__*/function () {
7805
7834
  this.options.data = d;
7806
7835
  this.render();
7807
7836
  }
7837
+ }, {
7838
+ key: "isRendered",
7839
+ get: function get() {
7840
+ return this._isRendered;
7841
+ }
7808
7842
  }, {
7809
7843
  key: "close",
7810
7844
  value: function close() {
@@ -8110,6 +8144,7 @@ var WebsyChart = /*#__PURE__*/function () {
8110
8144
  value: function render(options) {
8111
8145
  var _this53 = this;
8112
8146
  /* global d3 options WebsyUtils */
8147
+ this._isRendered = false;
8113
8148
  if (typeof options !== 'undefined') {
8114
8149
  this.options = _extends({}, this.options, options);
8115
8150
  if (this.options.legendOptions) {
@@ -8850,6 +8885,7 @@ var WebsyChart = /*#__PURE__*/function () {
8850
8885
  return _this54.renderRefLine(l);
8851
8886
  });
8852
8887
  }
8888
+ this._isRendered = true;
8853
8889
  }
8854
8890
  }, {
8855
8891
  key: "renderarea",
@@ -10193,11 +10229,18 @@ var WebsyKPI = /*#__PURE__*/function () {
10193
10229
  };
10194
10230
  this.elementId = elementId;
10195
10231
  this.options = _extends({}, DEFAULTS, options);
10232
+ this._isRendered = false;
10196
10233
  this.render();
10197
10234
  }
10198
10235
  _createClass(WebsyKPI, [{
10236
+ key: "isRendered",
10237
+ get: function get() {
10238
+ return this._isRendered;
10239
+ }
10240
+ }, {
10199
10241
  key: "render",
10200
10242
  value: function render(options) {
10243
+ this._isRendered = false;
10201
10244
  this.options = _extends({}, this.options, options);
10202
10245
  if (!this.options.label.classes) {
10203
10246
  this.options.label.classes = [];
@@ -10232,6 +10275,7 @@ var WebsyKPI = /*#__PURE__*/function () {
10232
10275
  }
10233
10276
  html += " \n </div>\n </div>\n ";
10234
10277
  el.innerHTML = html;
10278
+ this._isRendered = true;
10235
10279
  }
10236
10280
  }
10237
10281
  }]);
@@ -10255,6 +10299,7 @@ var WebsyMap = /*#__PURE__*/function () {
10255
10299
  };
10256
10300
  this.elementId = elementId;
10257
10301
  this.options = _extends({}, DEFAULTS, options);
10302
+ this._isRendered = false;
10258
10303
  if (!elementId) {
10259
10304
  console.log('No element Id provided for Websy Map');
10260
10305
  return;
@@ -10284,6 +10329,11 @@ var WebsyMap = /*#__PURE__*/function () {
10284
10329
  }
10285
10330
  }
10286
10331
  _createClass(WebsyMap, [{
10332
+ key: "isRendered",
10333
+ get: function get() {
10334
+ return this._isRendered;
10335
+ }
10336
+ }, {
10287
10337
  key: "handleClick",
10288
10338
  value: function handleClick(event) {}
10289
10339
  }, {
@@ -10293,6 +10343,7 @@ var WebsyMap = /*#__PURE__*/function () {
10293
10343
  key: "render",
10294
10344
  value: function render() {
10295
10345
  var _this61 = this;
10346
+ this._isRendered = false;
10296
10347
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
10297
10348
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
10298
10349
  if (this.options.showLegend === true && this.options.data.polygons) {
@@ -10434,6 +10485,7 @@ var WebsyMap = /*#__PURE__*/function () {
10434
10485
  } else if (this.options.center) {
10435
10486
  this.map.setView(this.options.center, this.options.zoom || null);
10436
10487
  }
10488
+ this._isRendered = true;
10437
10489
  }
10438
10490
  }]);
10439
10491
  return WebsyMap;