@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.
@@ -1565,6 +1565,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1565
1565
  closeAfterSelection: true,
1566
1566
  customActions: [],
1567
1567
  customButtons: [],
1568
+ minWidth: 220,
1568
1569
  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>",
1569
1570
  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>",
1570
1571
  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>",
@@ -1632,6 +1633,15 @@ var WebsyDropdown = /*#__PURE__*/function () {
1632
1633
  }
1633
1634
  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 ");
1634
1635
  el.innerHTML = html;
1636
+ var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1637
+ if (maskEl) {
1638
+ maskEl.addEventListener('mousewheel', function (event) {
1639
+ if (event.target.classList.contains('websy-dropdown-mask')) {
1640
+ event.preventDefault();
1641
+ event.stopPropagation();
1642
+ }
1643
+ });
1644
+ }
1635
1645
  var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
1636
1646
  if (scrollEl) {
1637
1647
  scrollEl.addEventListener('scroll', this.handleScroll.bind(this));
@@ -1873,7 +1883,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1873
1883
  var contentPos = WebsyUtils.getElementPos(contentEl);
1874
1884
  if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1875
1885
  contentEl.style.right = "calc(100vw - ".concat(headerPos.right, "px)");
1876
- contentEl.style.width = "".concat(headerEl.clientWidth, "px");
1886
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, headerEl.clientWidth), "px");
1877
1887
  if (headerPos.bottom + contentPos.height > window.innerHeight) {
1878
1888
  // contentEl.classList.add('on-top')
1879
1889
  contentEl.style.bottom = "calc(100vh - ".concat(headerPos.top, "px)");
@@ -1883,7 +1893,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1883
1893
  } else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1884
1894
  var targetPos = WebsyUtils.getElementPos(event.target);
1885
1895
  contentEl.style.right = "calc(100vw - ".concat(targetPos.right, "px)");
1886
- contentEl.style.width = "".concat(targetPos.width, "px");
1896
+ contentEl.style.width = "".concat(Math.max(this.options.minWidth, targetPos.width), "px");
1887
1897
  }
1888
1898
  if (this.options.disableSearch !== true) {
1889
1899
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
@@ -3344,7 +3354,11 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3344
3354
  classes: [],
3345
3355
  wait: 0,
3346
3356
  buttonText: 'Download',
3347
- directDownload: false
3357
+ directDownload: false,
3358
+ preProcess: function preProcess(callbackFn) {
3359
+ return callbackFn(true);
3360
+ },
3361
+ onError: function onError() {}
3348
3362
  };
3349
3363
  this.elementId = elementId;
3350
3364
  this.options = _extends({}, DEFAULTS, options);
@@ -3375,80 +3389,87 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3375
3389
  var _this25 = this;
3376
3390
  if (event.target.classList.contains('websy-pdf-button')) {
3377
3391
  this.loader.show();
3378
- setTimeout(function () {
3379
- if (_this25.options.targetId) {
3380
- var el = document.getElementById(_this25.options.targetId);
3381
- if (el) {
3382
- var pdfData = {
3383
- options: {}
3384
- };
3385
- if (_this25.options.pdfOptions) {
3386
- pdfData.options = _extends({}, _this25.options.pdfOptions);
3387
- }
3388
- if (_this25.options.header) {
3389
- if (_this25.options.header.elementId) {
3390
- var headerEl = document.getElementById(_this25.options.header.elementId);
3391
- if (headerEl) {
3392
- pdfData.header = headerEl.outerHTML;
3393
- if (_this25.options.header.css) {
3394
- pdfData.options.headerCSS = _this25.options.header.css;
3395
- }
3392
+ this.options.preProcess(function (proceed) {
3393
+ if (proceed === true) {
3394
+ setTimeout(function () {
3395
+ if (_this25.options.targetId) {
3396
+ var el = document.getElementById(_this25.options.targetId);
3397
+ if (el) {
3398
+ var pdfData = {
3399
+ options: {}
3400
+ };
3401
+ if (_this25.options.pdfOptions) {
3402
+ pdfData.options = _extends({}, _this25.options.pdfOptions);
3396
3403
  }
3397
- } else if (_this25.options.header.html) {
3398
- pdfData.header = _this25.options.header.html;
3399
- if (_this25.options.header.css) {
3400
- pdfData.options.headerCSS = _this25.options.header.css;
3404
+ if (_this25.options.header) {
3405
+ if (_this25.options.header.elementId) {
3406
+ var headerEl = document.getElementById(_this25.options.header.elementId);
3407
+ if (headerEl) {
3408
+ pdfData.header = headerEl.outerHTML;
3409
+ if (_this25.options.header.css) {
3410
+ pdfData.options.headerCSS = _this25.options.header.css;
3411
+ }
3412
+ }
3413
+ } else if (_this25.options.header.html) {
3414
+ pdfData.header = _this25.options.header.html;
3415
+ if (_this25.options.header.css) {
3416
+ pdfData.options.headerCSS = _this25.options.header.css;
3417
+ }
3418
+ } else {
3419
+ pdfData.header = _this25.options.header;
3420
+ }
3401
3421
  }
3402
- } else {
3403
- pdfData.header = _this25.options.header;
3404
- }
3405
- }
3406
- if (_this25.options.footer) {
3407
- if (_this25.options.footer.elementId) {
3408
- var footerEl = document.getElementById(_this25.options.footer.elementId);
3409
- if (footerEl) {
3410
- pdfData.footer = footerEl.outerHTML;
3411
- if (_this25.options.footer.css) {
3412
- pdfData.options.footerCSS = _this25.options.footer.css;
3422
+ if (_this25.options.footer) {
3423
+ if (_this25.options.footer.elementId) {
3424
+ var footerEl = document.getElementById(_this25.options.footer.elementId);
3425
+ if (footerEl) {
3426
+ pdfData.footer = footerEl.outerHTML;
3427
+ if (_this25.options.footer.css) {
3428
+ pdfData.options.footerCSS = _this25.options.footer.css;
3429
+ }
3430
+ }
3431
+ } else {
3432
+ pdfData.footer = _this25.options.footer;
3413
3433
  }
3414
3434
  }
3415
- } else {
3416
- pdfData.footer = _this25.options.footer;
3435
+ pdfData.html = el.outerHTML;
3436
+ // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3437
+ // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3438
+ // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3439
+ // document.getElementById(`${this.elementId}_form`).submit()
3440
+ _this25.service.add('', pdfData, {
3441
+ responseType: 'blob'
3442
+ }).then(function (response) {
3443
+ _this25.loader.hide();
3444
+ var blob = new Blob([response], {
3445
+ type: 'application/pdf'
3446
+ });
3447
+ 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 ");
3448
+ if (_this25.options.directDownload === true) {
3449
+ var fileName;
3450
+ if (typeof _this25.options.fileName === 'function') {
3451
+ fileName = _this25.options.fileName() || 'Export';
3452
+ } else {
3453
+ fileName = _this25.options.fileName || 'Export';
3454
+ }
3455
+ msg += "download='".concat(fileName, ".pdf'");
3456
+ }
3457
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this25.options.buttonText, "</button>\n </a>\n </div>\n ");
3458
+ _this25.popup.show({
3459
+ message: msg,
3460
+ mask: true
3461
+ });
3462
+ }, function (err) {
3463
+ console.error(err);
3464
+ });
3417
3465
  }
3418
3466
  }
3419
- pdfData.html = el.outerHTML;
3420
- // document.getElementById(`${this.elementId}_pdfHeader`).value = pdfData.header
3421
- // document.getElementById(`${this.elementId}_pdfHTML`).value = pdfData.html
3422
- // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3423
- // document.getElementById(`${this.elementId}_form`).submit()
3424
- _this25.service.add('', pdfData, {
3425
- responseType: 'blob'
3426
- }).then(function (response) {
3427
- _this25.loader.hide();
3428
- var blob = new Blob([response], {
3429
- type: 'application/pdf'
3430
- });
3431
- 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 ");
3432
- if (_this25.options.directDownload === true) {
3433
- var fileName;
3434
- if (typeof _this25.options.fileName === 'function') {
3435
- fileName = _this25.options.fileName() || 'Export';
3436
- } else {
3437
- fileName = _this25.options.fileName || 'Export';
3438
- }
3439
- msg += "download='".concat(fileName, ".pdf'");
3440
- }
3441
- msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this25.options.buttonText, "</button>\n </a>\n </div>\n ");
3442
- _this25.popup.show({
3443
- message: msg,
3444
- mask: true
3445
- });
3446
- }, function (err) {
3447
- console.error(err);
3448
- });
3449
- }
3467
+ }, _this25.options.wait);
3468
+ } else {
3469
+ _this25.loader.hide();
3470
+ _this25.options.onError();
3450
3471
  }
3451
- }, this.options.wait);
3472
+ });
3452
3473
  } else if (event.target.classList.contains('download-pdf')) {
3453
3474
  this.popup.hide();
3454
3475
  if (this.options.onClose) {
@@ -5127,10 +5148,14 @@ var WebsyUtils = {
5127
5148
  var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
5128
5149
  var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
5129
5150
  return {
5130
- top: rect.top + scrollTop,
5131
- left: rect.left + scrollLeft,
5132
- bottom: rect.top + scrollTop + el.clientHeight,
5133
- right: rect.left + scrollLeft + el.clientWidth,
5151
+ top: rect.top,
5152
+ // + scrollTop,
5153
+ left: rect.left,
5154
+ // + scrollLeft,
5155
+ // bottom: rect.top + scrollTop + el.clientHeight,
5156
+ bottom: rect.top + el.clientHeight,
5157
+ // right: rect.left + scrollLeft + el.clientWidth,
5158
+ right: rect.left + el.clientWidth,
5134
5159
  width: rect.width,
5135
5160
  height: rect.height
5136
5161
  };
@@ -5328,6 +5353,7 @@ var WebsyTable = /*#__PURE__*/function () {
5328
5353
  this.busy = false;
5329
5354
  this.tooltipTimeoutFn = null;
5330
5355
  this.data = [];
5356
+ this._isRendered = false;
5331
5357
  var el = document.getElementById(this.elementId);
5332
5358
  if (el) {
5333
5359
  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 ");
@@ -5366,9 +5392,15 @@ var WebsyTable = /*#__PURE__*/function () {
5366
5392
  }
5367
5393
  }
5368
5394
  _createClass(WebsyTable, [{
5395
+ key: "isRendered",
5396
+ get: function get() {
5397
+ return this._isRendered;
5398
+ }
5399
+ }, {
5369
5400
  key: "appendRows",
5370
5401
  value: function appendRows(data) {
5371
5402
  var _this36 = this;
5403
+ this._isRendered = false;
5372
5404
  this.hideError();
5373
5405
  var bodyHTML = '';
5374
5406
  if (data) {
@@ -5410,6 +5442,7 @@ var WebsyTable = /*#__PURE__*/function () {
5410
5442
  }
5411
5443
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5412
5444
  bodyEl.innerHTML += bodyHTML;
5445
+ this._isRendered = true;
5413
5446
  }
5414
5447
  }, {
5415
5448
  key: "buildSearchIcon",
@@ -5560,6 +5593,7 @@ var WebsyTable = /*#__PURE__*/function () {
5560
5593
  key: "render",
5561
5594
  value: function render(data) {
5562
5595
  var _this37 = this;
5596
+ this._isRendered = false;
5563
5597
  if (!this.options.columns) {
5564
5598
  return;
5565
5599
  }
@@ -6190,6 +6224,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6190
6224
  autoFitColumns: true
6191
6225
  };
6192
6226
  this.options = _extends({}, DEFAULTS, options);
6227
+ this._isRendered = false;
6193
6228
  this.isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
6194
6229
  if (this.options.disableTouch === true) {
6195
6230
  this.isTouchDevice = false;
@@ -6250,6 +6285,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
6250
6285
  }
6251
6286
  }
6252
6287
  _createClass(WebsyTable3, [{
6288
+ key: "isRendered",
6289
+ get: function get() {
6290
+ return this._isRendered;
6291
+ }
6292
+ }, {
6253
6293
  key: "columns",
6254
6294
  set: function set(columns) {
6255
6295
  this.options.columns = columns;
@@ -6264,6 +6304,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6264
6304
  }, {
6265
6305
  key: "appendRows",
6266
6306
  value: function appendRows(data) {
6307
+ this._isRendered = false;
6267
6308
  this.hideError();
6268
6309
  var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody"));
6269
6310
  if (bodyEl) {
@@ -6275,6 +6316,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6275
6316
  bodyEl.querySelector('tbody').innerHTML += this.buildBodyHtml(data, true, true);
6276
6317
  } else {
6277
6318
  bodyEl.innerHTML += this.buildBodyHtml(data, true);
6319
+ this._isRendered = true;
6278
6320
  }
6279
6321
  this.currentData = this.currentData.concat(data);
6280
6322
  }
@@ -7280,10 +7322,12 @@ var WebsyChart = /*#__PURE__*/function () {
7280
7322
  maxBandWidth: 100,
7281
7323
  allowUnevenBands: true,
7282
7324
  allowBrushing: true,
7283
- balancedMinMax: false
7325
+ balancedMinMax: false,
7326
+ onRendered: function onRendered() {}
7284
7327
  };
7285
7328
  this.elementId = elementId;
7286
7329
  this.options = _extends({}, DEFAULTS, options);
7330
+ this._isRendered = false;
7287
7331
  this.leftAxis = null;
7288
7332
  this.rightAxis = null;
7289
7333
  this.topAxis = null;
@@ -7322,21 +7366,6 @@ var WebsyChart = /*#__PURE__*/function () {
7322
7366
  }
7323
7367
  }
7324
7368
  }
7325
- // }
7326
- // else {
7327
- // let domain = [...this[xAxis].domain()]
7328
- // if (this.options.orientation === 'horizontal') {
7329
- // domain = domain.reverse()
7330
- // }
7331
- // for (let j = 0; j < domain.length; j++) {
7332
- // let breakA = this[xAxis](domain[j]) - (width / 2)
7333
- // let breakB = breakA + width
7334
- // if (input > breakA && input <= breakB) {
7335
- // output = j
7336
- // break
7337
- // }
7338
- // }
7339
- // }
7340
7369
  return output;
7341
7370
  };
7342
7371
  var that = this;
@@ -7411,6 +7440,11 @@ var WebsyChart = /*#__PURE__*/function () {
7411
7440
  this.options.data = d;
7412
7441
  this.render();
7413
7442
  }
7443
+ }, {
7444
+ key: "isRendered",
7445
+ get: function get() {
7446
+ return this._isRendered;
7447
+ }
7414
7448
  }, {
7415
7449
  key: "close",
7416
7450
  value: function close() {
@@ -7716,6 +7750,7 @@ var WebsyChart = /*#__PURE__*/function () {
7716
7750
  value: function render(options) {
7717
7751
  var _this50 = this;
7718
7752
  /* global d3 options WebsyUtils */
7753
+ this._isRendered = false;
7719
7754
  if (typeof options !== 'undefined') {
7720
7755
  this.options = _extends({}, this.options, options);
7721
7756
  if (this.options.legendOptions) {
@@ -8456,6 +8491,7 @@ var WebsyChart = /*#__PURE__*/function () {
8456
8491
  return _this51.renderRefLine(l);
8457
8492
  });
8458
8493
  }
8494
+ this._isRendered = true;
8459
8495
  }
8460
8496
  }, {
8461
8497
  key: "renderarea",
@@ -9372,11 +9408,18 @@ var WebsyKPI = /*#__PURE__*/function () {
9372
9408
  };
9373
9409
  this.elementId = elementId;
9374
9410
  this.options = _extends({}, DEFAULTS, options);
9411
+ this._isRendered = false;
9375
9412
  this.render();
9376
9413
  }
9377
9414
  _createClass(WebsyKPI, [{
9415
+ key: "isRendered",
9416
+ get: function get() {
9417
+ return this._isRendered;
9418
+ }
9419
+ }, {
9378
9420
  key: "render",
9379
9421
  value: function render(options) {
9422
+ this._isRendered = false;
9380
9423
  this.options = _extends({}, this.options, options);
9381
9424
  if (!this.options.label.classes) {
9382
9425
  this.options.label.classes = [];
@@ -9411,6 +9454,7 @@ var WebsyKPI = /*#__PURE__*/function () {
9411
9454
  }
9412
9455
  html += " \n </div>\n </div>\n ";
9413
9456
  el.innerHTML = html;
9457
+ this._isRendered = true;
9414
9458
  }
9415
9459
  }
9416
9460
  }]);
@@ -9434,6 +9478,7 @@ var WebsyMap = /*#__PURE__*/function () {
9434
9478
  };
9435
9479
  this.elementId = elementId;
9436
9480
  this.options = _extends({}, DEFAULTS, options);
9481
+ this._isRendered = false;
9437
9482
  if (!elementId) {
9438
9483
  console.log('No element Id provided for Websy Map');
9439
9484
  return;
@@ -9463,6 +9508,11 @@ var WebsyMap = /*#__PURE__*/function () {
9463
9508
  }
9464
9509
  }
9465
9510
  _createClass(WebsyMap, [{
9511
+ key: "isRendered",
9512
+ get: function get() {
9513
+ return this._isRendered;
9514
+ }
9515
+ }, {
9466
9516
  key: "handleClick",
9467
9517
  value: function handleClick(event) {}
9468
9518
  }, {
@@ -9472,6 +9522,7 @@ var WebsyMap = /*#__PURE__*/function () {
9472
9522
  key: "render",
9473
9523
  value: function render() {
9474
9524
  var _this58 = this;
9525
+ this._isRendered = false;
9475
9526
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
9476
9527
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
9477
9528
  if (this.options.showLegend === true && this.options.data.polygons) {
@@ -9613,6 +9664,7 @@ var WebsyMap = /*#__PURE__*/function () {
9613
9664
  } else if (this.options.center) {
9614
9665
  this.map.setView(this.options.center, this.options.zoom || null);
9615
9666
  }
9667
+ this._isRendered = true;
9616
9668
  }
9617
9669
  }]);
9618
9670
  return WebsyMap;