@websy/websy-designs 1.7.19 → 1.8.0

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.
@@ -1644,8 +1644,8 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1644
1644
  el.innerHTML = html;
1645
1645
  this.options.items.forEach(function (item, i) {
1646
1646
  if (item.component) {
1647
- if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
1648
- item.instance = new WebsyDesigns.QlikPlugin[item.component]("".concat(item.id, "_component"), item.options);
1647
+ if (item.isQlikPlugin && WebsyDesigns.QlikPlugins[item.component]) {
1648
+ item.instance = new WebsyDesigns.QlikPlugins[item.component]("".concat(item.id, "_component"), item.options);
1649
1649
  } else if (WebsyDesigns[item.component]) {
1650
1650
  item.instance = new WebsyDesigns[item.component]("".concat(item.id, "_component"), item.options);
1651
1651
  } else {
@@ -5157,13 +5157,25 @@ var Switch = /*#__PURE__*/function () {
5157
5157
  key: "disable",
5158
5158
  value: function disable() {
5159
5159
  this.options.enabled = false;
5160
- this.render();
5160
+ var method = this.options.enabled === true ? 'add' : 'remove';
5161
+ var el = document.getElementById("".concat(this.elementId, "_switch"));
5162
+ el.classList[method]('enabled');
5163
+
5164
+ if (this.options.onToggle) {
5165
+ this.options.onToggle(this.options.enabled);
5166
+ }
5161
5167
  }
5162
5168
  }, {
5163
5169
  key: "enable",
5164
5170
  value: function enable() {
5165
5171
  this.options.enabled = true;
5166
- this.render();
5172
+ var method = this.options.enabled === true ? 'add' : 'remove';
5173
+ var el = document.getElementById("".concat(this.elementId, "_switch"));
5174
+ el.classList[method]('enabled');
5175
+
5176
+ if (this.options.onToggle) {
5177
+ this.options.onToggle(this.options.enabled);
5178
+ }
5167
5179
  }
5168
5180
  }, {
5169
5181
  key: "handleClick",
@@ -6637,7 +6649,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6637
6649
  var el = document.getElementById(this.elementId);
6638
6650
 
6639
6651
  if (el) {
6640
- var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', "'>\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 <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n ");
6652
+ var html = "\n <div id='".concat(this.elementId, "_tableContainer' class='websy-vis-table-3 ").concat(this.options.paging === 'pages' ? 'with-paging' : '', " ").concat(this.options.virtualScroll === true ? 'with-virtual-scroll' : '', " ").concat(this.isTouchDevice === true && this.options.virtualScroll === true ? 'touch-device' : '', "'>\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 <div id=\"").concat(this.elementId, "_tableInner\" class=\"websy-table-inner-container\">\n <table id=\"").concat(this.elementId, "_tableHeader\" class=\"websy-table-header\"></table>\n <table id=\"").concat(this.elementId, "_tableBody\" class=\"websy-table-body\"></table>\n <table id=\"").concat(this.elementId, "_tableFooter\" class=\"websy-table-footer\"></table>\n <div id=\"").concat(this.elementId, "_vScrollContainer\" class=\"websy-v-scroll-container\">\n <div id=\"").concat(this.elementId, "_vScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-y\"></div>\n </div>\n <div id=\"").concat(this.elementId, "_hScrollContainer\" class=\"websy-h-scroll-container\">\n <div id=\"").concat(this.elementId, "_hScrollHandle\" class=\"websy-scroll-handle websy-scroll-handle-x\"></div>\n </div>\n ");
6641
6653
 
6642
6654
  if (this.isTouchDevice === true && this.options.virtualScroll === true) {
6643
6655
  html += "\n <div id=\"".concat(this.elementId, "_touchScroller\" class=\"websy-table-touch-scroller\"></div>\n ");
@@ -7061,9 +7073,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
7061
7073
  }
7062
7074
 
7063
7075
  this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
7064
- this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
7065
- this.startRow = 0;
7066
- this.endRow = this.sizes.rowsToRender;
7076
+ this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight; // this.startRow = 0
7077
+
7078
+ this.endRow = this.startRow + this.sizes.rowsToRender;
7067
7079
  this.startCol = 0;
7068
7080
  this.endCol = this.options.columns[this.options.columns.length - 1].length;
7069
7081
 
@@ -7165,7 +7177,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7165
7177
  }, {
7166
7178
  key: "handleMouseDown",
7167
7179
  value: function handleMouseDown(event) {
7168
- if (this.isTouchDevice === true) {
7180
+ if (this.isTouchDevice) {
7169
7181
  return;
7170
7182
  }
7171
7183
 
@@ -7178,6 +7190,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
7178
7190
  this.mouseYStart = event.pageY; // console.log('mouse down', this.handleYStart, this.mouseYStart)
7179
7191
  // console.log(scrollHandleEl.offsetTop)
7180
7192
  } else if (event.target.classList.contains('websy-scroll-handle-x')) {
7193
+ if (this.isTouchDevice) {
7194
+ event.preventDefault();
7195
+ }
7196
+
7181
7197
  this.scrollDragging = true;
7182
7198
  this.scrollDirection = 'x';
7183
7199
 
@@ -7192,6 +7208,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
7192
7208
  value: function handleMouseMove(event) {
7193
7209
  // event.preventDefault()
7194
7210
  if (this.scrollDragging === true) {
7211
+ if (this.isTouchDevice) {
7212
+ event.preventDefault();
7213
+ }
7214
+
7195
7215
  if (this.scrollDirection === 'y') {
7196
7216
  var diff = event.pageY - this.mouseYStart;
7197
7217
  this.scrollY(diff);
@@ -7263,12 +7283,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
7263
7283
  key: "handleTouchEnd",
7264
7284
  value: function handleTouchEnd(event) {
7265
7285
  // console.log('touch end fired')
7266
- if (typeof event.targetTouches !== 'undefined') {
7267
- this.isTouchScrolling = false;
7268
- this.touchEndTime = new Date().getTime();
7269
- this.isPerpetual = true; // this.perpetualScroll()
7286
+ this.scrollDragging = false;
7287
+ this.cellDragging = false;
7288
+ this.handleYStart = null;
7289
+ this.mouseYStart = null;
7290
+ this.handleXStart = null;
7291
+ this.mouseXStart = null;
7270
7292
 
7271
- this.touchStartTime = null; // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
7293
+ if (typeof event.targetTouches !== 'undefined') {
7294
+ this.isTouchScrolling = false; // this.touchEndTime = (new Date()).getTime()
7295
+ // this.isPerpetual = true
7296
+ // this.perpetualScroll()
7297
+ // this.touchStartTime = null
7298
+ // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
7272
7299
  // touchScrollEl.classList.add('hidden')
7273
7300
  }
7274
7301
  }
@@ -7281,46 +7308,70 @@ var WebsyTable3 = /*#__PURE__*/function () {
7281
7308
  event.stopPropagation();
7282
7309
 
7283
7310
  if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
7284
- var deltaX = this.mouseXStart - event.targetTouches[0].pageX;
7285
- var deltaY = this.mouseYStart - event.targetTouches[0].pageY;
7286
- var hScrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
7287
- var vScrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
7288
- var hScrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
7289
- var vScrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
7290
- var translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width);
7291
- var translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height); // need to adjust the delta so that it scrolls at a reasonable speed/distance
7292
-
7293
- var scrollHandleXEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
7294
- var scrollHandleYEl = document.getElementById("".concat(this.elementId, "_vScrollHandle")); // if (Math.abs(deltaY) > this.sizes.cellHeight) {
7295
- // this.isTouchScrolling = true
7296
- // }
7297
- // else {
7298
- // this.isTouchScrolling = false
7299
- // }
7300
- // console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
7301
- // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
7302
- // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
7303
- // console.log('delta', deltaY)
7304
- // NW
7305
- // else if (Math.abs(deltaX) > 50) {
7306
- // this.isTouchScrolling = false
7307
- // }
7311
+ event.deltaX = this.touchXStart - event.targetTouches[0].pageX;
7312
+ event.deltaY = this.touchYStart - event.targetTouches[0].pageY;
7313
+
7314
+ if (Math.abs(event.deltaY) > 50) {
7315
+ event.deltaX = 0;
7316
+ this.handleScrollWheel(event);
7317
+ } else if (Math.abs(event.deltaX) > 50) {
7318
+ event.deltaY = 0;
7319
+ this.handleScrollWheel(event);
7320
+ } // let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
7321
+ // let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
7322
+ // const hScrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
7323
+ // const vScrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
7324
+ // const hScrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
7325
+ // const vScrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
7326
+ // let translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width)
7327
+ // let translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height)
7328
+ // // need to adjust the delta so that it scrolls at a reasonable speed/distance
7329
+ // const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
7330
+ // const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
7331
+ // // if (Math.abs(deltaY) > this.sizes.cellHeight) {
7332
+ // // this.isTouchScrolling = true
7333
+ // // }
7334
+ // // else {
7335
+ // // this.isTouchScrolling = false
7336
+ // // }
7337
+ // // console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
7338
+ // // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
7339
+ // // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
7340
+ // // console.log('delta', deltaY)
7341
+ // // NW
7342
+ // // else if (Math.abs(deltaX) > 50) {
7343
+ // // this.isTouchScrolling = false
7344
+ // // }
7345
+ // this.currentClientY = event.targetTouches[0].pageY
7346
+ // this.currentTouchtime = (new Date()).getTime()
7347
+ // // end
7348
+ // // delta = Math.min(10, delta)
7349
+ // // delta = Math.max(-10, delta)
7350
+ // if (this.isTouchScrolling === true) {
7351
+ // // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
7352
+ // if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
7353
+ // // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
7354
+ // this.scrollX(translatedDeltaX)
7355
+ // }
7356
+ // else if (deltaY > 20) {
7357
+ // // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
7358
+ // this.scrollY(translatedDeltaY)
7359
+ // }
7360
+ // }
7308
7361
 
7309
- this.currentClientY = event.targetTouches[0].pageY;
7310
- this.currentTouchtime = new Date().getTime(); // end
7311
- // delta = Math.min(10, delta)
7312
- // delta = Math.max(-10, delta)
7313
-
7314
- if (this.isTouchScrolling === true) {
7315
- // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
7316
- if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
7317
- // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
7318
- this.scrollX(translatedDeltaX);
7319
- } else if (deltaY > 20) {
7320
- // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
7321
- this.scrollY(translatedDeltaY);
7322
- }
7323
- }
7362
+ }
7363
+ }
7364
+
7365
+ if (this.scrollDragging === true) {
7366
+ event.preventDefault();
7367
+
7368
+ if (this.scrollDirection === 'y') {
7369
+ var diff = event.targetTouches[0].pageY - this.mouseYStart;
7370
+ this.scrollY(diff);
7371
+ } else if (this.scrollDirection === 'x') {
7372
+ var _diff2 = event.targetTouches[0].pageX - this.mouseXStart;
7373
+
7374
+ this.scrollX(_diff2);
7324
7375
  }
7325
7376
  }
7326
7377
  }
@@ -7336,19 +7387,44 @@ var WebsyTable3 = /*#__PURE__*/function () {
7336
7387
  } // console.log(event.target.classList)
7337
7388
 
7338
7389
 
7339
- if (this.options.virtualScroll === true) {
7340
- this.touchStartTime = new Date().getTime();
7341
- this.isTouchScrolling = true;
7342
- this.isPerpetual = false;
7343
- this.mouseYStart = event.targetTouches[0].pageY;
7344
- this.mouseXStart = event.targetTouches[0].pageX; // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
7345
- // touchScrollEl.classList.remove('hidden')
7390
+ if (event.target.classList.contains('websy-table-touch-scroller')) {
7391
+ if (this.options.virtualScroll === true) {
7392
+ // this.touchStartTime = (new Date()).getTime()
7393
+ this.isTouchScrolling = true; // this.isPerpetual = false
7346
7394
 
7347
- var handleYEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
7348
- this.handleYStart = handleYEl.offsetTop;
7349
- var handleXEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
7350
- this.handleXStart = handleXEl.offsetLeft;
7395
+ this.touchYStart = event.targetTouches[0].pageY;
7396
+ this.touchXStart = event.targetTouches[0].pageX;
7397
+ }
7351
7398
  }
7399
+
7400
+ if (event.target.classList.contains('websy-scroll-handle-y')) {
7401
+ // set up the scroll start values
7402
+ this.scrollDragging = true;
7403
+ this.scrollDirection = 'y';
7404
+ var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
7405
+ this.handleYStart = scrollHandleEl.offsetTop;
7406
+ this.mouseYStart = event.targetTouches[0].pageY; // console.log('mouse down', this.handleYStart, this.mouseYStart)
7407
+ // console.log(scrollHandleEl.offsetTop)
7408
+ } else if (event.target.classList.contains('websy-scroll-handle-x')) {
7409
+ if (this.isTouchDevice) {
7410
+ event.preventDefault();
7411
+ }
7412
+
7413
+ this.scrollDragging = true;
7414
+ this.scrollDirection = 'x';
7415
+
7416
+ var _scrollHandleEl3 = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
7417
+
7418
+ this.handleXStart = _scrollHandleEl3.offsetLeft;
7419
+ this.mouseXStart = event.targetTouches[0].pageX;
7420
+ } // // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
7421
+ // // touchScrollEl.classList.remove('hidden')
7422
+ // const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
7423
+ // this.handleYStart = handleYEl.offsetTop
7424
+ // const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
7425
+ // this.handleXStart = handleXEl.offsetLeft
7426
+ // }
7427
+
7352
7428
  }
7353
7429
  }, {
7354
7430
  key: "hideError",
@@ -7484,6 +7560,11 @@ var WebsyTable3 = /*#__PURE__*/function () {
7484
7560
  vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
7485
7561
  vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
7486
7562
  vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
7563
+
7564
+ if (this.startRow !== 0) {
7565
+ var scrollableSpace = vScrollEl.getBoundingClientRect().height - vHandleEl.getBoundingClientRect().height;
7566
+ vHandleEl.style.top = Math.round(this.startRow / (this.totalRowCount - this.sizes.rowsToRender) * scrollableSpace) + 'px';
7567
+ }
7487
7568
  } else {
7488
7569
  vHandleEl.style.height = '0px';
7489
7570
  }
@@ -7493,7 +7574,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7493
7574
 
7494
7575
  if (this.hScrollRequired === true) {
7495
7576
  hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
7496
- hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
7577
+ hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - (this.isTouchDevice ? 30 : 20), "px");
7497
7578
  hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px';
7498
7579
  } else {
7499
7580
  hHandleEl.style.width = '0px';
@@ -7682,7 +7763,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7682
7763
  this.startRow += 1;
7683
7764
  }
7684
7765
 
7685
- this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
7766
+ this.options.onScroll('y', this.startRow, this.endRow, Math.max(0, this.startCol - this.pinnedColumns), this.endCol - this.pinnedColumns);
7686
7767
  }
7687
7768
  }
7688
7769
  }, {
@@ -9469,7 +9550,9 @@ var WebsyChart = /*#__PURE__*/function () {
9469
9550
  key: "removebar",
9470
9551
  value: function removebar(key) {
9471
9552
  /* global key d3 */
9472
- var bars = this.barLayer.selectAll(".bar_".concat(key)).transition(this.transition).style('fill-opacity', 1e-6).remove();
9553
+ this.barLayer.selectAll(".bar_".concat(key)).transition(this.transition).style('fill-opacity', 1e-6).remove(); // remove from the brush as well
9554
+
9555
+ this.brushArea.selectAll(".bar_".concat(key)).transition(this.transition).style('fill-opacity', 1e-6).remove();
9473
9556
  }
9474
9557
  }, {
9475
9558
  key: "renderLabels",