@websy/websy-designs 1.2.33 → 1.3.1

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.
@@ -414,6 +414,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
414
414
  var _this2 = this;
415
415
 
416
416
  var isRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
417
+ console.trace();
417
418
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
418
419
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
419
420
  var el = document.getElementById(this.elementId);
@@ -435,9 +436,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
435
436
  hoursOut.push(this.options.hours[i]);
436
437
  }
437
438
 
438
- this.options.onChange(hoursOut, true);
439
+ this.options.onChange(hoursOut, true, this.selectedRange);
439
440
  } else {
440
- this.options.onChange(this.selectedRangeDates, true);
441
+ this.options.onChange(this.selectedRangeDates, true, this.selectedRange);
441
442
  }
442
443
  } else {
443
444
  if (this.options.mode === 'hour') {
@@ -445,9 +446,9 @@ var WebsyDatePicker = /*#__PURE__*/function () {
445
446
  return _this2.options.hours[h];
446
447
  });
447
448
 
448
- this.options.onChange(_hoursOut, true);
449
+ this.options.onChange(_hoursOut, true, this.selectedRange);
449
450
  } else {
450
- this.options.onChange(this.currentselection, isRange);
451
+ this.options.onChange(this.currentselection, isRange, this.selectedRange);
451
452
  }
452
453
  }
453
454
  }
@@ -470,9 +471,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
470
471
  value: function floorDate(d) {
471
472
  if (typeof d === 'number') {
472
473
  d = new Date(d);
473
- }
474
+ } // d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
475
+
474
476
 
475
- return new Date(d.setHours(0, 0, 0, 0));
477
+ return new Date(d.setUTCHours(12, 0, 0, 0));
476
478
  }
477
479
  }, {
478
480
  key: "handleClick",
@@ -489,11 +491,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
489
491
  var index = event.target.getAttribute('data-index');
490
492
  this.selectRange(index);
491
493
  this.updateRange(index);
492
- } else if (event.target.classList.contains('websy-dp-date')) {// if (event.target.classList.contains('websy-disabled-date')) {
493
- // return
494
- // }
495
- // const timestamp = event.target.id.split('_')[0]
496
- // this.selectDate(+timestamp)
494
+ } else if (event.target.classList.contains('websy-dp-date')) {//
497
495
  } else if (event.target.classList.contains('websy-dp-confirm')) {
498
496
  this.close(true);
499
497
  } else if (event.target.classList.contains('websy-dp-cancel')) {
@@ -527,7 +525,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
527
525
  value: function handleMouseDown(event) {
528
526
  if (this.shiftPressed === true && this.currentselection.length > 0) {
529
527
  this.mouseDownId = this.currentselection[this.currentselection.length - 1];
530
- this.selectDate(+event.target.id.split('_')[1]);
528
+ var dateId = event.target.getAttribute('data-id');
529
+ this.selectDate(+dateId);
531
530
  } else {
532
531
  this.mouseDown = true;
533
532
  this.dragging = false;
@@ -542,7 +541,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
542
541
  this.customRangeSelected = false;
543
542
  }
544
543
 
545
- this.mouseDownId = +event.target.id.split('_')[1];
544
+ this.mouseDownId = +event.target.getAttribute('data-id');
546
545
  this.selectDate(this.mouseDownId);
547
546
  }
548
547
  }
@@ -556,9 +555,11 @@ var WebsyDatePicker = /*#__PURE__*/function () {
556
555
  return;
557
556
  }
558
557
 
559
- if (event.target.id.split('_')[1] !== this.mouseDownId) {
558
+ var dateId = +event.target.getAttribute('data-id');
559
+
560
+ if (dateId !== this.mouseDownId) {
560
561
  this.dragging = true;
561
- this.selectDate(+event.target.id.split('_')[1]);
562
+ this.selectDate(dateId);
562
563
  }
563
564
  }
564
565
  }
@@ -614,6 +615,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
614
615
 
615
616
  if (this.options.mode === 'date') {
616
617
  d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + _i * this.oneDay));
618
+ d.setUTCHours(12, 0, 0, 0);
617
619
  d = d.getTime();
618
620
  rangeStart = this.selectedRangeDates[0].getTime();
619
621
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime();
@@ -669,9 +671,11 @@ var WebsyDatePicker = /*#__PURE__*/function () {
669
671
  dateEl = document.getElementById("".concat(_this3.elementId, "_").concat(d, "_hour"));
670
672
  }
671
673
 
672
- dateEl.classList.add('selected');
673
- dateEl.classList.add('first');
674
- dateEl.classList.add('last');
674
+ if (dateEl) {
675
+ dateEl.classList.add('selected');
676
+ dateEl.classList.add('first');
677
+ dateEl.classList.add('last');
678
+ }
675
679
  });
676
680
  }
677
681
  }
@@ -906,7 +910,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
906
910
  }
907
911
 
908
912
  html += months[key].map(function (d) {
909
- return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_date' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
913
+ return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_date' data-id='").concat(d.id, "' class='websy-dp-date ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.dayOfMonth, "</li>");
910
914
  }).join('');
911
915
  html += "\n </ul>\n </div>\n ";
912
916
  }
@@ -919,7 +923,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
919
923
 
920
924
  html += "<div id='".concat(this.elementId, "_dateList' class='websy-dp-date-list'><ul>");
921
925
  html += yearList.map(function (d) {
922
- return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_year' class='websy-dp-date websy-dp-year ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.year, "</li>");
926
+ return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_year' data-id='").concat(d.id, "' class='websy-dp-date websy-dp-year ").concat(d.disabled === true ? 'websy-disabled-date' : '', "'>").concat(d.year, "</li>");
923
927
  }).join('');
924
928
  html += "</ul></div>";
925
929
  } else if (this.options.mode === 'monthyear') {
@@ -939,7 +943,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
939
943
  }
940
944
 
941
945
  html += this.monthYears[year].map(function (d) {
942
- return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_monthyear' data-year='").concat(d.year, "' class='websy-dp-date websy-dp-monthyear'>").concat(d.month, "</li>");
946
+ return "<li id='".concat(_this4.elementId, "_").concat(d.id, "_monthyear' data-id='").concat(d.id, "' data-year='").concat(d.year, "' class='websy-dp-date websy-dp-monthyear'>").concat(d.month, "</li>");
943
947
  }).join('');
944
948
  html += "</ul>";
945
949
  }
@@ -1043,18 +1047,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1043
1047
 
1044
1048
  if (this.options.ranges[this.options.mode][index]) {
1045
1049
  this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
1046
- this.currentselection = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
1050
+ this.currentselection = this.options.ranges[this.options.mode][index].range.map(function (d) {
1051
+ return d.getTime();
1052
+ });
1047
1053
  this.selectedRange = +index;
1048
- var el = document.getElementById("".concat(this.elementId, "_header"));
1049
-
1050
- if (el) {
1051
- if (this.selectedRange === 0) {
1052
- el.classList.remove('range-selected');
1053
- } else {
1054
- el.classList.add('range-selected');
1055
- }
1056
- }
1057
-
1058
1054
  this.highlightRange();
1059
1055
  this.updateRange();
1060
1056
  this.close(confirm, true);
@@ -1066,16 +1062,17 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1066
1062
  var _this6 = this;
1067
1063
 
1068
1064
  this.selectedRange = -1;
1069
- var isContinuousRange = true;
1070
-
1071
- if (rangeInput.length === 1) {
1072
- this.selectedRangeDates = _toConsumableArray(rangeInput);
1073
- this.customRangeSelected = true;
1074
- } else if (rangeInput.length === 2) {
1075
- this.selectedRangeDates = _toConsumableArray(rangeInput);
1076
- this.customRangeSelected = true;
1077
- }
1065
+ var isContinuousRange = true; // if (rangeInput.length === 1) {
1066
+ // this.selectedRangeDates = [...rangeInput]
1067
+ // this.customRangeSelected = true
1068
+ // }
1069
+ // else if (rangeInput.length === 2) {
1070
+ // this.selectedRangeDates = [...rangeInput]
1071
+ // this.customRangeSelected = true
1072
+ // }
1078
1073
 
1074
+ this.selectedRangeDates = _toConsumableArray(rangeInput);
1075
+ this.customRangeSelected = true;
1079
1076
  rangeInput.forEach(function (r, i) {
1080
1077
  if (i > 0) {
1081
1078
  if (_this6.options.mode === 'date' || _this6.options.mode === 'monthyear') {
@@ -1229,6 +1226,16 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1229
1226
  if (labelEl) {
1230
1227
  labelEl.innerHTML = range.label;
1231
1228
  }
1229
+
1230
+ var headerEl = document.getElementById("".concat(this.elementId, "_header"));
1231
+
1232
+ if (headerEl) {
1233
+ if (this.selectedRange === 0) {
1234
+ headerEl.classList.remove('range-selected');
1235
+ } else {
1236
+ headerEl.classList.add('range-selected');
1237
+ }
1238
+ }
1232
1239
  }
1233
1240
  }]);
1234
1241
 
@@ -1248,7 +1255,8 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1248
1255
  var DEFAULTS = {
1249
1256
  items: [],
1250
1257
  orientation: 'horizontal',
1251
- dropPlaceholder: 'Drop item here'
1258
+ dropPlaceholder: 'Drop item here',
1259
+ accepts: 'application/wd-item'
1252
1260
  };
1253
1261
  this.busy = false;
1254
1262
  this.options = _extends({}, DEFAULTS, options);
@@ -1274,8 +1282,6 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1274
1282
  }
1275
1283
 
1276
1284
  GlobalPubSub.subscribe(this.elementId, 'requestForDDItem', this.handleRequestForItem.bind(this));
1277
- console.log('constructor dd');
1278
- console.trace();
1279
1285
  GlobalPubSub.subscribe(this.elementId, 'add', this.addItem.bind(this));
1280
1286
  this.render();
1281
1287
  }
@@ -1316,7 +1322,7 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1316
1322
  item.id = WebsyDesigns.Utils.createIdentity();
1317
1323
  }
1318
1324
 
1319
- var html = "\n <div id='".concat(item.id, "_item' class='websy-dragdrop-item' draggable='true' data-id='").concat(item.id, "'> \n <div id='").concat(item.id, "_itemInner' class='websy-dragdrop-item-inner' data-id='").concat(item.id, "'>\n ");
1325
+ var html = "\n <div id='".concat(item.id, "_item' class='websy-dragdrop-item ").concat((item.classes || []).join(' '), "' draggable='true' data-id='").concat(item.id, "'> \n <div id='").concat(item.id, "_itemInner' class='websy-dragdrop-item-inner' data-id='").concat(item.id, "'>\n ");
1320
1326
 
1321
1327
  if (item.component) {
1322
1328
  html += "<div id='".concat(item.id, "_component'></div>");
@@ -1346,35 +1352,38 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1346
1352
  value: function handleDragStart(event) {
1347
1353
  this.draggedId = event.target.getAttribute('data-id');
1348
1354
  event.dataTransfer.effectAllowed = 'move';
1349
- event.dataTransfer.setData('application/wd-item', JSON.stringify({
1355
+ event.dataTransfer.setData(this.options.accepts, JSON.stringify({
1350
1356
  el: event.target.id,
1351
1357
  id: this.elementId,
1352
1358
  itemId: this.draggedId
1353
1359
  }));
1354
- console.log('drag start', event);
1355
- event.target.style.opacity = 0.5;
1360
+ event.target.classList.add('dragging'); // event.target.style.opacity = 0.5
1361
+
1356
1362
  this.dragging = true;
1357
1363
  }
1358
1364
  }, {
1359
1365
  key: "handleDragOver",
1360
1366
  value: function handleDragOver(event) {
1361
- console.log('drag over', event.target.classList);
1362
-
1363
1367
  if (event.preventDefault) {
1364
1368
  event.preventDefault();
1365
1369
  }
1366
1370
 
1371
+ console.log('drag', event.target.classList);
1372
+
1367
1373
  if (!event.target.classList.contains('droppable')) {
1368
1374
  return;
1369
1375
  }
1370
1376
 
1377
+ if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
1378
+ return;
1379
+ }
1380
+
1371
1381
  event.target.classList.add('drag-over');
1372
1382
  }
1373
1383
  }, {
1374
1384
  key: "handleDragLeave",
1375
1385
  value: function handleDragLeave(event) {
1376
- console.log('drag leave', event.target.classList);
1377
-
1386
+ // console.log('drag leave', event.target.classList)
1378
1387
  if (!event.target.classList.contains('droppable')) {
1379
1388
  return;
1380
1389
  }
@@ -1387,9 +1396,9 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1387
1396
  }, {
1388
1397
  key: "handleDrop",
1389
1398
  value: function handleDrop(event) {
1390
- console.log('drag drop');
1391
- console.log(event.dataTransfer.getData('application/wd-item'));
1392
- var data = JSON.parse(event.dataTransfer.getData('application/wd-item'));
1399
+ // console.log('drag drop')
1400
+ // console.log(event.dataTransfer.getData('application/wd-item'))
1401
+ var data = JSON.parse(event.dataTransfer.getData(this.options.accepts));
1393
1402
 
1394
1403
  if (event.preventDefault) {
1395
1404
  event.preventDefault();
@@ -1399,6 +1408,10 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1399
1408
  return;
1400
1409
  }
1401
1410
 
1411
+ if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
1412
+ return;
1413
+ }
1414
+
1402
1415
  var side = event.target.getAttribute('data-side');
1403
1416
  var id = event.target.getAttribute('data-id');
1404
1417
  var index = this.getItemIndex(id);
@@ -1410,7 +1423,7 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1410
1423
  }
1411
1424
 
1412
1425
  if (draggedIndex === -1) {
1413
- console.log('requestForDDItem');
1426
+ // console.log('requestForDDItem')
1414
1427
  GlobalPubSub.publish(data.id, 'requestForDDItem', {
1415
1428
  group: this.options.group,
1416
1429
  source: data.id,
@@ -1454,8 +1467,9 @@ var WebsyDragDrop = /*#__PURE__*/function () {
1454
1467
  }, {
1455
1468
  key: "handleDragEnd",
1456
1469
  value: function handleDragEnd(event) {
1457
- console.log('drag end');
1470
+ // console.log('drag end')
1458
1471
  event.target.style.opacity = 1;
1472
+ event.target.classList.remove('dragging');
1459
1473
  this.draggedId = null;
1460
1474
  this.dragging = false;
1461
1475
  var startEl = document.getElementById("".concat(this.elementId, "start_item"));
@@ -1913,14 +1927,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
1913
1927
  }, {
1914
1928
  key: "updateHeader",
1915
1929
  value: function updateHeader(item) {
1916
- var _this11 = this;
1917
-
1918
1930
  var el = document.getElementById(this.elementId);
1919
1931
  var headerEl = document.getElementById("".concat(this.elementId, "_header"));
1920
1932
  var headerLabelEl = document.getElementById("".concat(this.elementId, "_headerLabel"));
1921
1933
  var labelEl = document.getElementById("".concat(this.elementId, "_selectedItems"));
1922
1934
  var inputEl = document.getElementById("".concat(this.elementId, "_input"));
1923
1935
  var itemEls = el.querySelectorAll(".websy-dropdown-item");
1936
+ var dataToUse = this._originalData;
1937
+
1938
+ if (this.options.onSearch) {
1939
+ dataToUse = this.options.items;
1940
+ }
1924
1941
 
1925
1942
  for (var i = 0; i < itemEls.length; i++) {
1926
1943
  itemEls[i].classList.remove('active');
@@ -1960,17 +1977,17 @@ var WebsyDropdown = /*#__PURE__*/function () {
1960
1977
  } else if (this.selectedItems.length > 1) {
1961
1978
  if (this.options.showCompleteSelectedList === true) {
1962
1979
  var selectedLabels = this.selectedItems.map(function (s) {
1963
- return _this11.options.items[s].label || _this11.options.items[s].value;
1980
+ return dataToUse[s].label || dataToUse[s].value;
1964
1981
  }).join(this.options.multiValueDelimiter);
1965
1982
  var selectedValues = this.selectedItems.map(function (s) {
1966
- return _this11.options.items[s].value || _this11.options.items[s].label;
1983
+ return dataToUse[s].value || dataToUse[s].label;
1967
1984
  }).join(this.options.multiValueDelimiter);
1968
1985
  labelEl.innerHTML = selectedLabels;
1969
1986
  labelEl.setAttribute('data-info', selectedLabels);
1970
1987
  inputEl.value = selectedValues;
1971
1988
  } else {
1972
1989
  var _selectedValues = this.selectedItems.map(function (s) {
1973
- return _this11.options.items[s].value || _this11.options.items[s].label;
1990
+ return dataToUse[s].value || dataToUse[s].label;
1974
1991
  }).join(this.options.multiValueDelimiter);
1975
1992
 
1976
1993
  labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
@@ -1987,6 +2004,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
1987
2004
  }, {
1988
2005
  key: "updateSelected",
1989
2006
  value: function updateSelected(index) {
2007
+ var dataToUse = this._originalData && this._originalData.length > 0 ? this._originalData : this.options.items;
2008
+
2009
+ if (this.options.onSearch) {
2010
+ dataToUse = this.options.items;
2011
+ }
2012
+
1990
2013
  if (typeof index !== 'undefined' && index !== null) {
1991
2014
  var pos = this.selectedItems.indexOf(index);
1992
2015
 
@@ -2002,11 +2025,11 @@ var WebsyDropdown = /*#__PURE__*/function () {
2002
2025
  } // const item = this.options.items[index]
2003
2026
 
2004
2027
 
2005
- var item = this._originalData[index] || this.options.items[index];
2028
+ var item = dataToUse[index];
2006
2029
  this.updateHeader(item);
2007
2030
 
2008
2031
  if (item && this.options.onItemSelected) {
2009
- this.options.onItemSelected(item, this.selectedItems, this._originalData || this.options.items, this.options);
2032
+ this.options.onItemSelected(item, this.selectedItems, dataToUse, this.options);
2010
2033
  }
2011
2034
 
2012
2035
  if (this.options.closeAfterSelection === true) {
@@ -2026,6 +2049,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
2026
2049
  d.index = i;
2027
2050
  }
2028
2051
 
2052
+ d.currentIndex = i;
2029
2053
  return d;
2030
2054
  });
2031
2055
  var headerEl = document.getElementById("".concat(this.elementId, "_header"));
@@ -2036,16 +2060,18 @@ var WebsyDropdown = /*#__PURE__*/function () {
2036
2060
 
2037
2061
  var el = document.getElementById("".concat(this.elementId, "_items"));
2038
2062
 
2039
- if (el.childElementCount === 0) {
2040
- this.render();
2041
- } else {
2042
- if (this.options.items.length === 0) {
2043
- this.options.items = [{
2044
- label: this.options.noItemsText || 'No Items'
2045
- }];
2046
- }
2063
+ if (el) {
2064
+ if (el.childElementCount === 0) {
2065
+ this.render();
2066
+ } else {
2067
+ if (this.options.items.length === 0) {
2068
+ this.options.items = [{
2069
+ label: this.options.noItemsText || 'No Items'
2070
+ }];
2071
+ }
2047
2072
 
2048
- this.renderItems();
2073
+ this.renderItems();
2074
+ }
2049
2075
  }
2050
2076
  },
2051
2077
  get: function get() {
@@ -2114,16 +2140,16 @@ var WebsyForm = /*#__PURE__*/function () {
2114
2140
  }, {
2115
2141
  key: "checkRecaptcha",
2116
2142
  value: function checkRecaptcha() {
2117
- var _this12 = this;
2143
+ var _this11 = this;
2118
2144
 
2119
2145
  return new Promise(function (resolve, reject) {
2120
- if (_this12.options.useRecaptcha === true) {
2146
+ if (_this11.options.useRecaptcha === true) {
2121
2147
  // if (this.recaptchaValue) {
2122
2148
  grecaptcha.ready(function () {
2123
2149
  grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, {
2124
2150
  action: 'submit'
2125
2151
  }).then(function (token) {
2126
- _this12.apiService.add('google/checkrecaptcha', {
2152
+ _this11.apiService.add('google/checkrecaptcha', {
2127
2153
  grecaptcharesponse: token
2128
2154
  }).then(function (response) {
2129
2155
  if (response.success && response.success === true) {
@@ -2186,14 +2212,14 @@ var WebsyForm = /*#__PURE__*/function () {
2186
2212
  }, {
2187
2213
  key: "processComponents",
2188
2214
  value: function processComponents(components, callbackFn) {
2189
- var _this13 = this;
2215
+ var _this12 = this;
2190
2216
 
2191
2217
  if (components.length === 0) {
2192
2218
  callbackFn();
2193
2219
  } else {
2194
2220
  components.forEach(function (c) {
2195
2221
  if (typeof WebsyDesigns[c.component] !== 'undefined') {
2196
- c.instance = new WebsyDesigns[c.component]("".concat(_this13.elementId, "_input_").concat(c.field, "_component"), c.options);
2222
+ c.instance = new WebsyDesigns[c.component]("".concat(_this12.elementId, "_input_").concat(c.field, "_component"), c.options);
2197
2223
  } else {// some user feedback here
2198
2224
  }
2199
2225
  });
@@ -2214,7 +2240,7 @@ var WebsyForm = /*#__PURE__*/function () {
2214
2240
  }, {
2215
2241
  key: "render",
2216
2242
  value: function render(update, data) {
2217
- var _this14 = this;
2243
+ var _this13 = this;
2218
2244
 
2219
2245
  var el = document.getElementById(this.elementId);
2220
2246
  var componentsToProcess = [];
@@ -2224,11 +2250,11 @@ var WebsyForm = /*#__PURE__*/function () {
2224
2250
  this.options.fields.forEach(function (f, i) {
2225
2251
  if (f.component) {
2226
2252
  componentsToProcess.push(f);
2227
- html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this14.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
2253
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this13.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
2228
2254
  } else if (f.type === 'longtext') {
2229
- html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this14.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
2255
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this13.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
2230
2256
  } else {
2231
- html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this14.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
2257
+ html += "\n ".concat(i > 0 ? '-->' : '', "<div class='").concat(f.classes || '', "'>\n ").concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this13.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
2232
2258
  }
2233
2259
  });
2234
2260
  html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes || '', "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
@@ -2245,7 +2271,7 @@ var WebsyForm = /*#__PURE__*/function () {
2245
2271
 
2246
2272
  el.innerHTML = html;
2247
2273
  this.processComponents(componentsToProcess, function () {
2248
- if (_this14.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {// this.recaptchaReady()
2274
+ if (_this13.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {// this.recaptchaReady()
2249
2275
  }
2250
2276
  });
2251
2277
  }
@@ -2253,7 +2279,7 @@ var WebsyForm = /*#__PURE__*/function () {
2253
2279
  }, {
2254
2280
  key: "submitForm",
2255
2281
  value: function submitForm() {
2256
- var _this15 = this;
2282
+ var _this14 = this;
2257
2283
 
2258
2284
  var formEl = document.getElementById("".concat(this.elementId, "Form"));
2259
2285
 
@@ -2267,32 +2293,32 @@ var WebsyForm = /*#__PURE__*/function () {
2267
2293
  data[key] = value;
2268
2294
  });
2269
2295
 
2270
- if (_this15.options.url) {
2271
- var _this15$apiService;
2296
+ if (_this14.options.url) {
2297
+ var _this14$apiService;
2272
2298
 
2273
- var params = [_this15.options.url];
2299
+ var params = [_this14.options.url];
2274
2300
 
2275
- if (_this15.options.mode === 'update') {
2276
- params.push(_this15.options.id);
2301
+ if (_this14.options.mode === 'update') {
2302
+ params.push(_this14.options.id);
2277
2303
  }
2278
2304
 
2279
2305
  params.push(data);
2280
2306
 
2281
- (_this15$apiService = _this15.apiService)[_this15.options.mode].apply(_this15$apiService, params).then(function (result) {
2282
- if (_this15.options.clearAfterSave === true) {
2307
+ (_this14$apiService = _this14.apiService)[_this14.options.mode].apply(_this14$apiService, params).then(function (result) {
2308
+ if (_this14.options.clearAfterSave === true) {
2283
2309
  // this.render()
2284
2310
  formEl.reset();
2285
2311
  }
2286
2312
 
2287
- _this15.options.onSuccess.call(_this15, result);
2313
+ _this14.options.onSuccess.call(_this14, result);
2288
2314
  }, function (err) {
2289
2315
  console.log('Error submitting form data:', err);
2290
2316
 
2291
- _this15.options.onError.call(_this15, err);
2317
+ _this14.options.onError.call(_this14, err);
2292
2318
  });
2293
- } else if (_this15.options.submitFn) {
2294
- _this15.options.submitFn(data, function () {
2295
- if (_this15.options.clearAfterSave === true) {
2319
+ } else if (_this14.options.submitFn) {
2320
+ _this14.options.submitFn(data, function () {
2321
+ if (_this14.options.clearAfterSave === true) {
2296
2322
  // this.render()
2297
2323
  formEl.reset();
2298
2324
  }
@@ -2312,17 +2338,17 @@ var WebsyForm = /*#__PURE__*/function () {
2312
2338
  }, {
2313
2339
  key: "data",
2314
2340
  set: function set(d) {
2315
- var _this16 = this;
2341
+ var _this15 = this;
2316
2342
 
2317
2343
  if (!this.options.fields) {
2318
2344
  this.options.fields = [];
2319
2345
  }
2320
2346
 
2321
2347
  var _loop = function _loop(key) {
2322
- _this16.options.fields.forEach(function (f) {
2348
+ _this15.options.fields.forEach(function (f) {
2323
2349
  if (f.field === key) {
2324
2350
  f.value = d[key];
2325
- var el = document.getElementById("".concat(_this16.elementId, "_input_").concat(f.field));
2351
+ var el = document.getElementById("".concat(_this15.elementId, "_input_").concat(f.field));
2326
2352
  el.value = f.value;
2327
2353
  }
2328
2354
  });
@@ -2634,7 +2660,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2634
2660
 
2635
2661
  var Pager = /*#__PURE__*/function () {
2636
2662
  function Pager(elementId, options) {
2637
- var _this17 = this;
2663
+ var _this16 = this;
2638
2664
 
2639
2665
  _classCallCheck(this, Pager);
2640
2666
 
@@ -2687,8 +2713,8 @@ var Pager = /*#__PURE__*/function () {
2687
2713
  allowClear: false,
2688
2714
  disableSearch: true,
2689
2715
  onItemSelected: function onItemSelected(selectedItem) {
2690
- if (_this17.options.onChangePageSize) {
2691
- _this17.options.onChangePageSize(selectedItem.value);
2716
+ if (_this16.options.onChangePageSize) {
2717
+ _this16.options.onChangePageSize(selectedItem.value);
2692
2718
  }
2693
2719
  }
2694
2720
  });
@@ -2712,13 +2738,13 @@ var Pager = /*#__PURE__*/function () {
2712
2738
  }, {
2713
2739
  key: "render",
2714
2740
  value: function render() {
2715
- var _this18 = this;
2741
+ var _this17 = this;
2716
2742
 
2717
2743
  var el = document.getElementById("".concat(this.elementId, "_pageList"));
2718
2744
 
2719
2745
  if (el) {
2720
2746
  var pages = this.options.pages.map(function (item, index) {
2721
- return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this18.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
2747
+ return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this17.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
2722
2748
  });
2723
2749
  var startIndex = 0;
2724
2750
 
@@ -2786,58 +2812,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2786
2812
  _createClass(WebsyPDFButton, [{
2787
2813
  key: "handleClick",
2788
2814
  value: function handleClick(event) {
2789
- var _this19 = this;
2815
+ var _this18 = this;
2790
2816
 
2791
2817
  if (event.target.classList.contains('websy-pdf-button')) {
2792
2818
  this.loader.show();
2793
2819
  setTimeout(function () {
2794
- if (_this19.options.targetId) {
2795
- var el = document.getElementById(_this19.options.targetId);
2820
+ if (_this18.options.targetId) {
2821
+ var el = document.getElementById(_this18.options.targetId);
2796
2822
 
2797
2823
  if (el) {
2798
2824
  var pdfData = {
2799
2825
  options: {}
2800
2826
  };
2801
2827
 
2802
- if (_this19.options.pdfOptions) {
2803
- pdfData.options = _extends({}, _this19.options.pdfOptions);
2828
+ if (_this18.options.pdfOptions) {
2829
+ pdfData.options = _extends({}, _this18.options.pdfOptions);
2804
2830
  }
2805
2831
 
2806
- if (_this19.options.header) {
2807
- if (_this19.options.header.elementId) {
2808
- var headerEl = document.getElementById(_this19.options.header.elementId);
2832
+ if (_this18.options.header) {
2833
+ if (_this18.options.header.elementId) {
2834
+ var headerEl = document.getElementById(_this18.options.header.elementId);
2809
2835
 
2810
2836
  if (headerEl) {
2811
2837
  pdfData.header = headerEl.outerHTML;
2812
2838
 
2813
- if (_this19.options.header.css) {
2814
- pdfData.options.headerCSS = _this19.options.header.css;
2839
+ if (_this18.options.header.css) {
2840
+ pdfData.options.headerCSS = _this18.options.header.css;
2815
2841
  }
2816
2842
  }
2817
- } else if (_this19.options.header.html) {
2818
- pdfData.header = _this19.options.header.html;
2843
+ } else if (_this18.options.header.html) {
2844
+ pdfData.header = _this18.options.header.html;
2819
2845
 
2820
- if (_this19.options.header.css) {
2821
- pdfData.options.headerCSS = _this19.options.header.css;
2846
+ if (_this18.options.header.css) {
2847
+ pdfData.options.headerCSS = _this18.options.header.css;
2822
2848
  }
2823
2849
  } else {
2824
- pdfData.header = _this19.options.header;
2850
+ pdfData.header = _this18.options.header;
2825
2851
  }
2826
2852
  }
2827
2853
 
2828
- if (_this19.options.footer) {
2829
- if (_this19.options.footer.elementId) {
2830
- var footerEl = document.getElementById(_this19.options.footer.elementId);
2854
+ if (_this18.options.footer) {
2855
+ if (_this18.options.footer.elementId) {
2856
+ var footerEl = document.getElementById(_this18.options.footer.elementId);
2831
2857
 
2832
2858
  if (footerEl) {
2833
2859
  pdfData.footer = footerEl.outerHTML;
2834
2860
 
2835
- if (_this19.options.footer.css) {
2836
- pdfData.options.footerCSS = _this19.options.footer.css;
2861
+ if (_this18.options.footer.css) {
2862
+ pdfData.options.footerCSS = _this18.options.footer.css;
2837
2863
  }
2838
2864
  }
2839
2865
  } else {
2840
- pdfData.footer = _this19.options.footer;
2866
+ pdfData.footer = _this18.options.footer;
2841
2867
  }
2842
2868
  }
2843
2869
 
@@ -2846,31 +2872,31 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2846
2872
  // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
2847
2873
  // document.getElementById(`${this.elementId}_form`).submit()
2848
2874
 
2849
- _this19.service.add('', pdfData, {
2875
+ _this18.service.add('', pdfData, {
2850
2876
  responseType: 'blob'
2851
2877
  }).then(function (response) {
2852
- _this19.loader.hide();
2878
+ _this18.loader.hide();
2853
2879
 
2854
2880
  var blob = new Blob([response], {
2855
2881
  type: 'application/pdf'
2856
2882
  });
2857
2883
  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 ");
2858
2884
 
2859
- if (_this19.options.directDownload === true) {
2885
+ if (_this18.options.directDownload === true) {
2860
2886
  var fileName;
2861
2887
 
2862
- if (typeof _this19.options.fileName === 'function') {
2863
- fileName = _this19.options.fileName() || 'Export';
2888
+ if (typeof _this18.options.fileName === 'function') {
2889
+ fileName = _this18.options.fileName() || 'Export';
2864
2890
  } else {
2865
- fileName = _this19.options.fileName || 'Export';
2891
+ fileName = _this18.options.fileName || 'Export';
2866
2892
  }
2867
2893
 
2868
2894
  msg += "download='".concat(fileName, ".pdf'");
2869
2895
  }
2870
2896
 
2871
- msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this19.options.buttonText, "</button>\n </a>\n </div>\n ");
2897
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this18.options.buttonText, "</button>\n </a>\n </div>\n ");
2872
2898
 
2873
- _this19.popup.show({
2899
+ _this18.popup.show({
2874
2900
  message: msg,
2875
2901
  mask: true
2876
2902
  });
@@ -3038,9 +3064,9 @@ var WebsyPubSub = /*#__PURE__*/function () {
3038
3064
  this.subscriptions[id][method](data);
3039
3065
  }
3040
3066
  } else {
3041
- if (this.subscriptions[method]) {
3042
- this.subscriptions[method].forEach(function (fn) {
3043
- fn(data);
3067
+ if (this.subscriptions[id]) {
3068
+ this.subscriptions[id].forEach(function (fn) {
3069
+ fn(method);
3044
3070
  });
3045
3071
  }
3046
3072
  }
@@ -3057,11 +3083,11 @@ var WebsyPubSub = /*#__PURE__*/function () {
3057
3083
  this.subscriptions[id][method] = fn;
3058
3084
  }
3059
3085
  } else {
3060
- if (!this.subscriptions[method]) {
3061
- this.subscriptions[method] = [];
3086
+ if (!this.subscriptions[id]) {
3087
+ this.subscriptions[id] = [];
3062
3088
  }
3063
3089
 
3064
- this.subscriptions[method].push(fn);
3090
+ this.subscriptions[id].push(method);
3065
3091
  }
3066
3092
  }
3067
3093
  }]);
@@ -3071,7 +3097,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
3071
3097
 
3072
3098
  var ResponsiveText = /*#__PURE__*/function () {
3073
3099
  function ResponsiveText(elementId, options) {
3074
- var _this20 = this;
3100
+ var _this19 = this;
3075
3101
 
3076
3102
  _classCallCheck(this, ResponsiveText);
3077
3103
 
@@ -3084,7 +3110,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3084
3110
  this.elementId = elementId;
3085
3111
  this.canvas = document.createElement('canvas');
3086
3112
  window.addEventListener('resize', function () {
3087
- return _this20.render();
3113
+ return _this19.render();
3088
3114
  });
3089
3115
  var el = document.getElementById(this.elementId);
3090
3116
 
@@ -3303,7 +3329,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3303
3329
 
3304
3330
  var WebsyResultList = /*#__PURE__*/function () {
3305
3331
  function WebsyResultList(elementId, options) {
3306
- var _this21 = this;
3332
+ var _this20 = this;
3307
3333
 
3308
3334
  _classCallCheck(this, WebsyResultList);
3309
3335
 
@@ -3331,9 +3357,9 @@ var WebsyResultList = /*#__PURE__*/function () {
3331
3357
 
3332
3358
  if (_typeof(options.template) === 'object' && options.template.url) {
3333
3359
  this.templateService.get(options.template.url).then(function (templateString) {
3334
- _this21.options.template = templateString;
3360
+ _this20.options.template = templateString;
3335
3361
 
3336
- _this21.render();
3362
+ _this20.render();
3337
3363
  });
3338
3364
  } else {
3339
3365
  this.render();
@@ -3352,7 +3378,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3352
3378
  }, {
3353
3379
  key: "buildHTML",
3354
3380
  value: function buildHTML(d) {
3355
- var _this22 = this;
3381
+ var _this21 = this;
3356
3382
 
3357
3383
  var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3358
3384
  var html = "";
@@ -3360,7 +3386,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3360
3386
  if (this.options.template) {
3361
3387
  if (d.length > 0) {
3362
3388
  d.forEach(function (row, ix) {
3363
- var template = "".concat(ix > 0 ? '-->' : '').concat(_this22.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
3389
+ var template = "".concat(ix > 0 ? '-->' : '').concat(_this21.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
3364
3390
 
3365
3391
  var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
3366
3392
 
@@ -3480,7 +3506,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3480
3506
  }, {
3481
3507
  key: "handleClick",
3482
3508
  value: function handleClick(event) {
3483
- var _this23 = this;
3509
+ var _this22 = this;
3484
3510
 
3485
3511
  if (event.target.classList.contains('clickable')) {
3486
3512
  var l = event.target.getAttribute('data-event');
@@ -3498,8 +3524,8 @@ var WebsyResultList = /*#__PURE__*/function () {
3498
3524
  l = l[0];
3499
3525
  params = params.map(function (p) {
3500
3526
  if (typeof p !== 'string' && typeof p !== 'number') {
3501
- if (_this23.rows[+id]) {
3502
- p = _this23.rows[+id][p];
3527
+ if (_this22.rows[+id]) {
3528
+ p = _this22.rows[+id][p];
3503
3529
  }
3504
3530
  } else if (typeof p === 'string') {
3505
3531
  p = p.replace(/"/g, '').replace(/'/g, '');
@@ -3521,13 +3547,13 @@ var WebsyResultList = /*#__PURE__*/function () {
3521
3547
  }, {
3522
3548
  key: "render",
3523
3549
  value: function render() {
3524
- var _this24 = this;
3550
+ var _this23 = this;
3525
3551
 
3526
3552
  if (this.options.entity) {
3527
3553
  this.apiService.get(this.options.entity).then(function (results) {
3528
- _this24.rows = results.rows;
3554
+ _this23.rows = results.rows;
3529
3555
 
3530
- _this24.resize();
3556
+ _this23.resize();
3531
3557
  });
3532
3558
  } else {
3533
3559
  this.resize();
@@ -3606,14 +3632,14 @@ var WebsyRouter = /*#__PURE__*/function () {
3606
3632
  _createClass(WebsyRouter, [{
3607
3633
  key: "addGroup",
3608
3634
  value: function addGroup(group) {
3609
- var _this25 = this;
3635
+ var _this24 = this;
3610
3636
 
3611
3637
  if (!this.groups[group]) {
3612
3638
  var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
3613
3639
 
3614
3640
  if (els) {
3615
3641
  this.getClosestParent(els[0], function (parent) {
3616
- _this25.groups[group] = {
3642
+ _this24.groups[group] = {
3617
3643
  activeView: '',
3618
3644
  views: [],
3619
3645
  parent: parent.getAttribute('data-view')
@@ -3938,12 +3964,12 @@ var WebsyRouter = /*#__PURE__*/function () {
3938
3964
  }, {
3939
3965
  key: "showComponents",
3940
3966
  value: function showComponents(view) {
3941
- var _this26 = this;
3967
+ var _this25 = this;
3942
3968
 
3943
3969
  if (this.options.views && this.options.views[view] && this.options.views[view].components) {
3944
3970
  this.options.views[view].components.forEach(function (c) {
3945
3971
  if (typeof c.instance === 'undefined') {
3946
- _this26.prepComponent(c.elementId, c.options);
3972
+ _this25.prepComponent(c.elementId, c.options);
3947
3973
 
3948
3974
  c.instance = new c.Component(c.elementId, c.options);
3949
3975
  } else if (c.instance.render) {
@@ -4312,7 +4338,7 @@ var Switch = /*#__PURE__*/function () {
4312
4338
 
4313
4339
  var WebsyTemplate = /*#__PURE__*/function () {
4314
4340
  function WebsyTemplate(elementId, options) {
4315
- var _this27 = this;
4341
+ var _this26 = this;
4316
4342
 
4317
4343
  _classCallCheck(this, WebsyTemplate);
4318
4344
 
@@ -4338,9 +4364,9 @@ var WebsyTemplate = /*#__PURE__*/function () {
4338
4364
 
4339
4365
  if (_typeof(options.template) === 'object' && options.template.url) {
4340
4366
  this.templateService.get(options.template.url).then(function (templateString) {
4341
- _this27.options.template = templateString;
4367
+ _this26.options.template = templateString;
4342
4368
 
4343
- _this27.render();
4369
+ _this26.render();
4344
4370
  });
4345
4371
  } else {
4346
4372
  this.render();
@@ -4350,7 +4376,7 @@ var WebsyTemplate = /*#__PURE__*/function () {
4350
4376
  _createClass(WebsyTemplate, [{
4351
4377
  key: "buildHTML",
4352
4378
  value: function buildHTML() {
4353
- var _this28 = this;
4379
+ var _this27 = this;
4354
4380
 
4355
4381
  var html = "";
4356
4382
 
@@ -4412,14 +4438,14 @@ var WebsyTemplate = /*#__PURE__*/function () {
4412
4438
  }
4413
4439
 
4414
4440
  if (polarity === true) {
4415
- if (typeof _this28.options.data[parts[0]] !== 'undefined' && _this28.options.data[parts[0]] === parts[1]) {
4441
+ if (typeof _this27.options.data[parts[0]] !== 'undefined' && _this27.options.data[parts[0]] === parts[1]) {
4416
4442
  // remove the <if> tags
4417
4443
  removeAll = false;
4418
4444
  } else if (parts[0] === parts[1]) {
4419
4445
  removeAll = false;
4420
4446
  }
4421
4447
  } else if (polarity === false) {
4422
- if (typeof _this28.options.data[parts[0]] !== 'undefined' && _this28.options.data[parts[0]] !== parts[1]) {
4448
+ if (typeof _this27.options.data[parts[0]] !== 'undefined' && _this27.options.data[parts[0]] !== parts[1]) {
4423
4449
  // remove the <if> tags
4424
4450
  removeAll = false;
4425
4451
  }
@@ -4515,6 +4541,7 @@ var WebsyUtils = {
4515
4541
  var red = 0;
4516
4542
  var green = 0;
4517
4543
  var blue = 0;
4544
+ var alpha = 1;
4518
4545
 
4519
4546
  if (backgroundColor.indexOf('#') !== -1) {
4520
4547
  // hex color
@@ -4526,14 +4553,16 @@ var WebsyUtils = {
4526
4553
  blue = parseInt(colorParts[4] + colorParts[5], 16);
4527
4554
  } else if (backgroundColor.toLowerCase().indexOf('rgb') !== -1) {
4528
4555
  // rgb color
4529
- colorParts = backgroundColor.replace(/rgb\(/gi, '').replace(/\)/gi, '');
4556
+ colorParts = backgroundColor.replace(/rgba\(/gi, '').replace(/\)/gi, '');
4557
+ colorParts = colorParts.replace(/rgb\(/gi, '');
4530
4558
  colorParts = colorParts.split(',');
4531
4559
  red = colorParts[0];
4532
4560
  green = colorParts[1];
4533
4561
  blue = colorParts[2];
4562
+ alpha = colorParts[3] || 1;
4534
4563
  }
4535
4564
 
4536
- return red * 0.299 + green * 0.587 + blue * 0.114 > 186 ? darkColor : lightColor;
4565
+ return (red * 0.299 + green * 0.587 + blue * 0.114) / alpha > 186 ? darkColor : lightColor;
4537
4566
  },
4538
4567
  measureText: function measureText(text) {
4539
4568
  var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -4706,7 +4735,7 @@ var WebsyUtils = {
4706
4735
 
4707
4736
  var WebsyTable = /*#__PURE__*/function () {
4708
4737
  function WebsyTable(elementId, options) {
4709
- var _this29 = this;
4738
+ var _this28 = this;
4710
4739
 
4711
4740
  _classCallCheck(this, WebsyTable);
4712
4741
 
@@ -4744,8 +4773,8 @@ var WebsyTable = /*#__PURE__*/function () {
4744
4773
  allowClear: false,
4745
4774
  disableSearch: true,
4746
4775
  onItemSelected: function onItemSelected(selectedItem) {
4747
- if (_this29.options.onChangePageSize) {
4748
- _this29.options.onChangePageSize(selectedItem.value);
4776
+ if (_this28.options.onChangePageSize) {
4777
+ _this28.options.onChangePageSize(selectedItem.value);
4749
4778
  }
4750
4779
  }
4751
4780
  });
@@ -4766,7 +4795,7 @@ var WebsyTable = /*#__PURE__*/function () {
4766
4795
  _createClass(WebsyTable, [{
4767
4796
  key: "appendRows",
4768
4797
  value: function appendRows(data) {
4769
- var _this30 = this;
4798
+ var _this29 = this;
4770
4799
 
4771
4800
  this.hideError();
4772
4801
  var bodyHTML = '';
@@ -4774,15 +4803,15 @@ var WebsyTable = /*#__PURE__*/function () {
4774
4803
  if (data) {
4775
4804
  bodyHTML += data.map(function (r, rowIndex) {
4776
4805
  return '<tr>' + r.map(function (c, i) {
4777
- if (_this30.options.columns[i].show !== false) {
4806
+ if (_this29.options.columns[i].show !== false) {
4778
4807
  var style = '';
4779
4808
 
4780
4809
  if (c.style) {
4781
4810
  style += c.style;
4782
4811
  }
4783
4812
 
4784
- if (_this30.options.columns[i].width) {
4785
- style += "width: ".concat(_this30.options.columns[i].width, "; ");
4813
+ if (_this29.options.columns[i].width) {
4814
+ style += "width: ".concat(_this29.options.columns[i].width, "; ");
4786
4815
  }
4787
4816
 
4788
4817
  if (c.backgroundColor) {
@@ -4797,18 +4826,18 @@ var WebsyTable = /*#__PURE__*/function () {
4797
4826
  style += "color: ".concat(c.color, "; ");
4798
4827
  }
4799
4828
 
4800
- if (_this30.options.columns[i].showAsLink === true && c.value.trim() !== '') {
4801
- return "\n <td \n data-row-index='".concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this30.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this30.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
4802
- } else if ((_this30.options.columns[i].showAsNavigatorLink === true || _this30.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
4803
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this30.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this30.options.columns[i].linkText || c.value, "</td>\n ");
4829
+ if (_this29.options.columns[i].showAsLink === true && c.value.trim() !== '') {
4830
+ return "\n <td \n data-row-index='".concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this29.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
4831
+ } else if ((_this29.options.columns[i].showAsNavigatorLink === true || _this29.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
4832
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this29.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</td>\n ");
4804
4833
  } else {
4805
4834
  var info = c.value;
4806
4835
 
4807
- if (_this30.options.columns[i].showAsImage === true) {
4836
+ if (_this29.options.columns[i].showAsImage === true) {
4808
4837
  c.value = "\n <img src='".concat(c.value, "'>\n ");
4809
4838
  }
4810
4839
 
4811
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this30.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this30.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
4840
+ return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
4812
4841
  }
4813
4842
  }
4814
4843
  }).join('') + '</tr>';
@@ -4980,7 +5009,7 @@ var WebsyTable = /*#__PURE__*/function () {
4980
5009
  }, {
4981
5010
  key: "render",
4982
5011
  value: function render(data) {
4983
- var _this31 = this;
5012
+ var _this30 = this;
4984
5013
 
4985
5014
  if (!this.options.columns) {
4986
5015
  return;
@@ -5005,7 +5034,17 @@ var WebsyTable = /*#__PURE__*/function () {
5005
5034
 
5006
5035
  var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
5007
5036
  if (c.show !== false) {
5008
- return "\n <th ".concat(c.width ? 'style="width: ' + (c.width || 'auto') + ';"' : '', ">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this31.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
5037
+ var style = '';
5038
+
5039
+ if (c.style) {
5040
+ style += c.style;
5041
+ }
5042
+
5043
+ if (c.width) {
5044
+ style += "width: ".concat(c.width || 'auto', ";");
5045
+ }
5046
+
5047
+ return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n <!--").concat(c.searchable === true ? _this30.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
5009
5048
  }
5010
5049
  }).join('') + '</tr>';
5011
5050
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -5024,7 +5063,7 @@ var WebsyTable = /*#__PURE__*/function () {
5024
5063
 
5025
5064
  if (pagingEl) {
5026
5065
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
5027
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this31.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5066
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this30.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5028
5067
  });
5029
5068
  var startIndex = 0;
5030
5069
 
@@ -5092,7 +5131,7 @@ var WebsyTable = /*#__PURE__*/function () {
5092
5131
 
5093
5132
  var WebsyTable2 = /*#__PURE__*/function () {
5094
5133
  function WebsyTable2(elementId, options) {
5095
- var _this32 = this;
5134
+ var _this31 = this;
5096
5135
 
5097
5136
  _classCallCheck(this, WebsyTable2);
5098
5137
 
@@ -5133,8 +5172,8 @@ var WebsyTable2 = /*#__PURE__*/function () {
5133
5172
  allowClear: false,
5134
5173
  disableSearch: true,
5135
5174
  onItemSelected: function onItemSelected(selectedItem) {
5136
- if (_this32.options.onChangePageSize) {
5137
- _this32.options.onChangePageSize(selectedItem.value);
5175
+ if (_this31.options.onChangePageSize) {
5176
+ _this31.options.onChangePageSize(selectedItem.value);
5138
5177
  }
5139
5178
  }
5140
5179
  });
@@ -5158,7 +5197,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5158
5197
  _createClass(WebsyTable2, [{
5159
5198
  key: "appendRows",
5160
5199
  value: function appendRows(data) {
5161
- var _this33 = this;
5200
+ var _this32 = this;
5162
5201
 
5163
5202
  this.hideError();
5164
5203
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
@@ -5167,15 +5206,15 @@ var WebsyTable2 = /*#__PURE__*/function () {
5167
5206
  if (data) {
5168
5207
  bodyHTML += data.map(function (r, rowIndex) {
5169
5208
  return '<tr>' + r.map(function (c, i) {
5170
- if (_this33.options.columns[i].show !== false) {
5171
- var style = "height: ".concat(_this33.options.cellSize, "px; line-height: ").concat(_this33.options.cellSize, "px;");
5209
+ if (_this32.options.columns[i].show !== false) {
5210
+ var style = "height: ".concat(_this32.options.cellSize, "px; line-height: ").concat(_this32.options.cellSize, "px;");
5172
5211
 
5173
5212
  if (c.style) {
5174
5213
  style += c.style;
5175
5214
  }
5176
5215
 
5177
- if (_this33.options.columns[i].width) {
5178
- style += "width: ".concat(_this33.options.columns[i].width, "; ");
5216
+ if (_this32.options.columns[i].width) {
5217
+ style += "width: ".concat(_this32.options.columns[i].width, "; ");
5179
5218
  }
5180
5219
 
5181
5220
  if (c.backgroundColor) {
@@ -5190,18 +5229,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
5190
5229
  style += "color: ".concat(c.color, "; ");
5191
5230
  }
5192
5231
 
5193
- if (_this33.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5194
- return "\n <td \n data-row-index='".concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this33.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this33.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5195
- } else if ((_this33.options.columns[i].showAsNavigatorLink === true || _this33.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5196
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this33.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this33.options.columns[i].linkText || c.value, "</td>\n ");
5232
+ if (_this32.options.columns[i].showAsLink === true && c.value.trim() !== '') {
5233
+ return "\n <td \n data-row-index='".concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this32.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
5234
+ } else if ((_this32.options.columns[i].showAsNavigatorLink === true || _this32.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
5235
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this32.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this32.options.columns[i].linkText || c.value, "</td>\n ");
5197
5236
  } else {
5198
5237
  var info = c.value;
5199
5238
 
5200
- if (_this33.options.columns[i].showAsImage === true) {
5239
+ if (_this32.options.columns[i].showAsImage === true) {
5201
5240
  c.value = "\n <img src='".concat(c.value, "'>\n ");
5202
5241
  }
5203
5242
 
5204
- return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this33.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this33.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5243
+ return "\n <td \n data-info='".concat(info, "' \n data-row-index='").concat(_this32.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this32.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.value, "</td>\n ");
5205
5244
  }
5206
5245
  }
5207
5246
  }).join('') + '</tr>';
@@ -5464,7 +5503,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5464
5503
  }, {
5465
5504
  key: "render",
5466
5505
  value: function render(data) {
5467
- var _this34 = this;
5506
+ var _this33 = this;
5468
5507
 
5469
5508
  if (!this.options.columns) {
5470
5509
  return;
@@ -5500,7 +5539,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5500
5539
  style += "width: ".concat(c.width || 'auto', "; ");
5501
5540
  }
5502
5541
 
5503
- return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this34.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5542
+ return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-sort-index=\"").concat(c.sortIndex || i, "\"\n data-index=\"").concat(i, "\"\n data-sort=\"").concat(c.sort, "\"\n style=\"").concat(c.style || '', "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this33.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5504
5543
  }
5505
5544
  }).join('') + '</tr>';
5506
5545
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -5511,7 +5550,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5511
5550
  var dropdownHTML = "";
5512
5551
  this.options.columns.forEach(function (c, i) {
5513
5552
  if (c.searchable && c.searchField) {
5514
- dropdownHTML += "\n <div id=\"".concat(_this34.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
5553
+ dropdownHTML += "\n <div id=\"".concat(_this33.elementId, "_columnSearch_").concat(i, "\" class=\"websy-modal-dropdown\"></div>\n ");
5515
5554
  }
5516
5555
  });
5517
5556
  dropdownEl.innerHTML = dropdownHTML;
@@ -5533,7 +5572,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5533
5572
 
5534
5573
  if (pagingEl) {
5535
5574
  var pages = new Array(this.options.pageCount).fill('').map(function (item, index) {
5536
- return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this34.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5575
+ return "<li data-page=\"".concat(index, "\" class=\"websy-page-num ").concat(_this33.options.pageNum === index ? 'active' : '', "\">").concat(index + 1, "</li>");
5537
5576
  });
5538
5577
  var startIndex = 0;
5539
5578
 
@@ -5624,7 +5663,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
5624
5663
  }, {
5625
5664
  key: "getColumnParameters",
5626
5665
  value: function getColumnParameters(values) {
5627
- var _this35 = this;
5666
+ var _this34 = this;
5628
5667
 
5629
5668
  var tableEl = document.getElementById("".concat(this.elementId, "_table"));
5630
5669
  tableEl.style.tableLayout = 'auto';
@@ -5632,10 +5671,10 @@ var WebsyTable2 = /*#__PURE__*/function () {
5632
5671
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
5633
5672
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
5634
5673
  headEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c, i) {
5635
- return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this35.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5674
+ return "\n <th>\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField\" \n >\n ".concat(c.value || 'nbsp;', "\n </div>\n </div> \n ").concat(c.searchable === true ? _this34.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
5636
5675
  }).join('') + '</tr>';
5637
5676
  bodyEl.innerHTML = '<tr style="visibility: hidden;">' + values.map(function (c) {
5638
- return "\n <td \n style='height: ".concat(_this35.options.cellSize, "px; line-height: ").concat(_this35.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
5677
+ return "\n <td \n style='height: ".concat(_this34.options.cellSize, "px; line-height: ").concat(_this34.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
5639
5678
  }).join('') + '</tr>'; // get height of the first data cell
5640
5679
 
5641
5680
  var cells = bodyEl.querySelectorAll("tr:first-of-type td");
@@ -5693,7 +5732,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
5693
5732
  showTotalsAbove: true,
5694
5733
  minHandleSize: 20,
5695
5734
  maxColWidth: '50%',
5696
- allowPivoting: false
5735
+ allowPivoting: false,
5736
+ searchIcon: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><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>"
5697
5737
  };
5698
5738
  this.options = _extends({}, DEFAULTS, options);
5699
5739
  this.sizes = {};
@@ -5781,7 +5821,34 @@ var WebsyTable3 = /*#__PURE__*/function () {
5781
5821
  data.forEach(function (row) {
5782
5822
  bodyHtml += "<tr class=\"websy-table-row\">";
5783
5823
  row.forEach(function (cell, cellIndex) {
5784
- bodyHtml += "<td \n class='websy-table-cell'\n style='".concat(cell.style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
5824
+ if (typeof sizingColumns[cellIndex] === 'undefined') {
5825
+ return; // need to revisit this logic
5826
+ }
5827
+
5828
+ var style = '';
5829
+
5830
+ if (cell.style) {
5831
+ style += cell.style;
5832
+ }
5833
+
5834
+ if (useWidths === true) {
5835
+ style += "max-width: ".concat(sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth, "px!important;");
5836
+ }
5837
+
5838
+ if (cell.backgroundColor) {
5839
+ style += "background-color: ".concat(cell.backgroundColor, "; ");
5840
+
5841
+ if (!cell.color) {
5842
+ style += "color: ".concat(WebsyDesigns.Utils.getLightDark(cell.backgroundColor), "; ");
5843
+ }
5844
+ }
5845
+
5846
+ if (cell.color) {
5847
+ style += "color: ".concat(cell.color, "; ");
5848
+ }
5849
+
5850
+ console.log('rowspan', cell.rowspan);
5851
+ bodyHtml += "<td \n class='websy-table-cell ".concat((cell.classes || []).join(' '), "'\n style='").concat(style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n "); // if (useWidths === true) {
5785
5852
  // bodyHtml += `
5786
5853
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
5787
5854
  // width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
@@ -5798,7 +5865,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
5798
5865
  }, {
5799
5866
  key: "buildHeaderHtml",
5800
5867
  value: function buildHeaderHtml() {
5801
- var _this36 = this;
5868
+ var _this35 = this;
5802
5869
 
5803
5870
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
5804
5871
  var headerHtml = '';
@@ -5813,13 +5880,13 @@ var WebsyTable3 = /*#__PURE__*/function () {
5813
5880
  }
5814
5881
 
5815
5882
  this.options.columns.forEach(function (row, rowIndex) {
5816
- if (useWidths === false && rowIndex !== _this36.options.columns.length - 1) {
5883
+ if (useWidths === false && rowIndex !== _this35.options.columns.length - 1) {
5817
5884
  // if we're calculating the size we only want to render the last row of column headers
5818
5885
  return;
5819
5886
  }
5820
5887
 
5821
5888
  headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
5822
- row.forEach(function (col) {
5889
+ row.forEach(function (col, colIndex) {
5823
5890
  headerHtml += "<td \n class='websy-table-cell' \n style='".concat(col.style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
5824
5891
  // headerHtml += `
5825
5892
  // style='width: ${col.width || col.actualWidth}px'
@@ -5827,16 +5894,34 @@ var WebsyTable3 = /*#__PURE__*/function () {
5827
5894
  // `
5828
5895
  // }
5829
5896
 
5830
- headerHtml += " \n >\n ".concat(col.name, "\n </td>");
5897
+ headerHtml += " \n >\n <div>\n ".concat(col.name, "\n ").concat(col.searchable === true ? _this35.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
5831
5898
  });
5832
5899
  headerHtml += "</tr>";
5833
5900
  });
5901
+ var dropdownEl = document.getElementById("".concat(this.elementId, "_dropdownContainer"));
5902
+ this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
5903
+ if (c.searchable && c.isExternalSearch === true) {
5904
+ var testEl = document.getElementById("".concat(_this35.elementId, "_columnSearch_").concat(c.dimId || i));
5905
+
5906
+ if (!testEl) {
5907
+ var newE = document.createElement('div');
5908
+ newE.id = "".concat(_this35.elementId, "_columnSearch_").concat(c.dimId || i);
5909
+ newE.className = 'websy-modal-dropdown';
5910
+ dropdownEl.appendChild(newE);
5911
+ }
5912
+ }
5913
+ });
5834
5914
  return headerHtml;
5835
5915
  }
5916
+ }, {
5917
+ key: "buildSearchIcon",
5918
+ value: function buildSearchIcon(col, index) {
5919
+ return "\n <div class=\"websy-table-search-icon\" data-col-id=\"".concat(col.dimId, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><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>\n </div>\n ");
5920
+ }
5836
5921
  }, {
5837
5922
  key: "buildTotalHtml",
5838
5923
  value: function buildTotalHtml() {
5839
- var _this37 = this;
5924
+ var _this36 = this;
5840
5925
 
5841
5926
  var useWidths = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
5842
5927
 
@@ -5849,7 +5934,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
5849
5934
  totalHtml += "<td \n class='websy-table-cell'\n colspan='".concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n ");
5850
5935
 
5851
5936
  if (useWidths === true) {
5852
- totalHtml += "\n style='width: ".concat(_this37.options.columns[_this37.options.columns.length - 1][colIndex].width || _this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
5937
+ totalHtml += "\n style='width: ".concat(_this36.options.columns[_this36.options.columns.length - 1][colIndex].width || _this36.options.columns[_this36.options.columns.length - 1][colIndex].actualWidth, "px'\n width='").concat(col.width || col.actualWidth, "'\n ");
5853
5938
  }
5854
5939
 
5855
5940
  totalHtml += " \n >\n ".concat(col.value, "\n </td>");
@@ -5860,7 +5945,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
5860
5945
  }, {
5861
5946
  key: "calculateSizes",
5862
5947
  value: function calculateSizes() {
5863
- var _this38 = this;
5948
+ var _this37 = this;
5864
5949
 
5865
5950
  var sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
5866
5951
  var totalRowCount = arguments.length > 1 ? arguments[1] : undefined;
@@ -5902,30 +5987,36 @@ var WebsyTable3 = /*#__PURE__*/function () {
5902
5987
  rows.forEach(function (row, rowIndex) {
5903
5988
  Array.from(row.children).forEach(function (col, colIndex) {
5904
5989
  var colSize = col.getBoundingClientRect();
5905
- _this38.sizes.cellHeight = colSize.height;
5990
+ _this37.sizes.cellHeight = colSize.height;
5906
5991
 
5907
- if (_this38.options.columns[_this38.options.columns.length - 1][colIndex]) {
5908
- if (!_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth) {
5909
- _this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth = 0;
5992
+ if (_this37.options.columns[_this37.options.columns.length - 1][colIndex]) {
5993
+ if (!_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth) {
5994
+ _this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth = 0;
5910
5995
  }
5911
5996
 
5912
- _this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this38.options.columns[_this38.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
5913
- _this38.options.columns[_this38.options.columns.length - 1][colIndex].cellHeight = colSize.height;
5997
+ _this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this37.options.columns[_this37.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
5998
+ _this37.options.columns[_this37.options.columns.length - 1][colIndex].cellHeight = colSize.height;
5914
5999
  }
5915
6000
  });
5916
6001
  });
5917
6002
  this.options.columns[this.options.columns.length - 1].forEach(function (col, colIndex) {
5918
- if (colIndex < _this38.pinnedColumns) {
5919
- _this38.sizes.scrollableWidth -= col.actualWidth;
6003
+ if (colIndex < _this37.pinnedColumns) {
6004
+ _this37.sizes.scrollableWidth -= col.actualWidth;
5920
6005
  }
5921
6006
  });
5922
6007
  this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce(function (a, b) {
5923
6008
  return a + (b.width || b.actualWidth);
5924
6009
  }, 0);
6010
+ this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter(function (c, i) {
6011
+ return i >= _this37.pinnedColumns;
6012
+ }).reduce(function (a, b) {
6013
+ return a + (b.width || b.actualWidth);
6014
+ }, 0);
5925
6015
  var outerSize = outerEl.getBoundingClientRect();
5926
6016
 
5927
6017
  if (this.sizes.totalWidth < outerSize.width) {
5928
6018
  this.sizes.totalWidth = 0;
6019
+ this.sizes.totalNonPinnedWidth = 0;
5929
6020
  var equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length;
5930
6021
  this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
5931
6022
  if (!c.width) {
@@ -5935,8 +6026,13 @@ var WebsyTable3 = /*#__PURE__*/function () {
5935
6026
  }
5936
6027
  }
5937
6028
 
5938
- _this38.sizes.totalWidth += c.width || c.actualWidth;
5939
- equalWidth = (outerSize.width - _this38.sizes.totalWidth) / (_this38.options.columns[_this38.options.columns.length - 1].length - (i + 1));
6029
+ _this37.sizes.totalWidth += c.width || c.actualWidth;
6030
+
6031
+ if (i < _this37.pinnedColumns) {
6032
+ _this37.sizes.totalNonPinnedWidth += c.width || c.actualWidth;
6033
+ }
6034
+
6035
+ equalWidth = (outerSize.width - _this37.sizes.totalWidth) / (_this37.options.columns[_this37.options.columns.length - 1].length - (i + 1));
5940
6036
  });
5941
6037
  } // take the height of the last cell as the official height for data cells
5942
6038
  // this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
@@ -5957,10 +6053,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
5957
6053
 
5958
6054
  if (this.sizes.rowsToRender < this.totalRowCount) {
5959
6055
  this.vScrollRequired = true;
6056
+ } else {
6057
+ this.vScrollRequired = false;
5960
6058
  }
5961
6059
 
5962
6060
  if (this.sizes.totalWidth > this.sizes.outer.width) {
5963
6061
  this.hScrollRequired = true;
6062
+ } else {
6063
+ this.hScrollRequired = false;
5964
6064
  }
5965
6065
 
5966
6066
  this.options.allColumns = this.options.columns.map(function (c) {
@@ -6000,7 +6100,16 @@ var WebsyTable3 = /*#__PURE__*/function () {
6000
6100
  }
6001
6101
  }, {
6002
6102
  key: "handleClick",
6003
- value: function handleClick(event) {}
6103
+ value: function handleClick(event) {
6104
+ if (event.target.classList.contains('websy-table-search-icon')) {
6105
+ console.log('clicked on search icon');
6106
+ var colIndex = +event.target.getAttribute('data-col-index');
6107
+
6108
+ if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6109
+ this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
6110
+ }
6111
+ }
6112
+ }
6004
6113
  }, {
6005
6114
  key: "handleMouseDown",
6006
6115
  value: function handleMouseDown(event) {
@@ -6124,20 +6233,26 @@ var WebsyTable3 = /*#__PURE__*/function () {
6124
6233
 
6125
6234
  if (this.options.virtualScroll === true) {
6126
6235
  // set the scroll element positions
6236
+ var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
6237
+ var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
6238
+
6127
6239
  if (this.vScrollRequired === true) {
6128
- var vScrollEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
6129
- var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
6130
6240
  vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
6131
6241
  vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
6132
6242
  vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px';
6243
+ } else {
6244
+ vHandleEl.style.height = '0px';
6133
6245
  }
6134
6246
 
6247
+ var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
6248
+ var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
6249
+
6135
6250
  if (this.hScrollRequired === true) {
6136
- var hScrollEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
6137
- var hHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
6138
6251
  hScrollEl.style.left = "".concat(this.sizes.table.width - this.sizes.scrollableWidth, "px");
6139
6252
  hScrollEl.style.width = "".concat(this.sizes.scrollableWidth - 20, "px");
6140
- hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalWidth)) + 'px';
6253
+ hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px';
6254
+ } else {
6255
+ hHandleEl.style.width = '0px';
6141
6256
  }
6142
6257
  }
6143
6258
  }
@@ -6178,8 +6293,6 @@ var WebsyTable3 = /*#__PURE__*/function () {
6178
6293
  el.classList.add('has-error');
6179
6294
  }
6180
6295
 
6181
- var tableEl = document.getElementById("".concat(this.elementId, "_tableInner"));
6182
- tableEl.classList.add('hidden');
6183
6296
  var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
6184
6297
 
6185
6298
  if (containerEl) {
@@ -6205,6 +6318,24 @@ var WebsyTable3 = /*#__PURE__*/function () {
6205
6318
  }, {
6206
6319
  key: "scrollX",
6207
6320
  value: function scrollX(diff) {
6321
+ var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
6322
+
6323
+ if (!el.classList.contains('scrolling')) {
6324
+ el.classList.add('scrolling');
6325
+ }
6326
+
6327
+ if (this.scrollTimeoutFn) {
6328
+ clearTimeout(this.scrollTimeoutFn);
6329
+ }
6330
+
6331
+ this.scrollTimeoutFn = setTimeout(function () {
6332
+ el.classList.remove('scrolling');
6333
+ }, 200);
6334
+
6335
+ if (this.hScrollRequired === false) {
6336
+ return;
6337
+ }
6338
+
6208
6339
  var scrollContainerEl = document.getElementById("".concat(this.elementId, "_hScrollContainer"));
6209
6340
  var scrollHandleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
6210
6341
  var handlePos;
@@ -6220,14 +6351,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6220
6351
  scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
6221
6352
 
6222
6353
  if (this.options.onScroll) {
6223
- var actualLeft = (this.sizes.totalWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
6354
+ var actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace);
6224
6355
  var cumulativeWidth = 0;
6225
6356
  this.startCol = 0;
6226
6357
  this.endCol = 0;
6227
6358
 
6228
- for (var i = 0; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
6359
+ for (var i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
6229
6360
  cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
6230
- console.log(actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
6361
+ console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
6231
6362
 
6232
6363
  if (actualLeft < cumulativeWidth) {
6233
6364
  this.startCol = i;
@@ -6260,6 +6391,24 @@ var WebsyTable3 = /*#__PURE__*/function () {
6260
6391
  }, {
6261
6392
  key: "scrollY",
6262
6393
  value: function scrollY(diff) {
6394
+ var el = document.getElementById("".concat(this.elementId, "_tableContainer"));
6395
+
6396
+ if (!el.classList.contains('scrolling')) {
6397
+ el.classList.add('scrolling');
6398
+ }
6399
+
6400
+ if (this.scrollTimeoutFn) {
6401
+ clearTimeout(this.scrollTimeoutFn);
6402
+ }
6403
+
6404
+ this.scrollTimeoutFn = setTimeout(function () {
6405
+ el.classList.remove('scrolling');
6406
+ }, 200);
6407
+
6408
+ if (this.vScrollRequired === false) {
6409
+ return;
6410
+ }
6411
+
6263
6412
  var scrollContainerEl = document.getElementById("".concat(this.elementId, "_vScrollContainer"));
6264
6413
  var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
6265
6414
  var handlePos;
@@ -6312,7 +6461,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6312
6461
 
6313
6462
  var WebsyChart = /*#__PURE__*/function () {
6314
6463
  function WebsyChart(elementId, options) {
6315
- var _this39 = this;
6464
+ var _this38 = this;
6316
6465
 
6317
6466
  _classCallCheck(this, WebsyChart);
6318
6467
 
@@ -6361,22 +6510,22 @@ var WebsyChart = /*#__PURE__*/function () {
6361
6510
  this.invertOverride = function (input, input2) {
6362
6511
  var xAxis = 'bottomAxis';
6363
6512
 
6364
- if (_this39.options.orientation === 'horizontal') {
6513
+ if (_this38.options.orientation === 'horizontal') {
6365
6514
  xAxis = 'leftAxis';
6366
6515
  }
6367
6516
 
6368
- var width = _this39[xAxis].step();
6517
+ var width = _this38[xAxis].step();
6369
6518
 
6370
6519
  var output;
6371
6520
 
6372
- var domain = _toConsumableArray(_this39[xAxis].domain());
6521
+ var domain = _toConsumableArray(_this38[xAxis].domain());
6373
6522
 
6374
- if (_this39.options.orientation === 'horizontal') {
6523
+ if (_this38.options.orientation === 'horizontal') {
6375
6524
  domain = domain.reverse();
6376
6525
  }
6377
6526
 
6378
6527
  for (var j = 0; j < domain.length; j++) {
6379
- var breakA = _this39[xAxis](domain[j]) - width / 2;
6528
+ var breakA = _this38[xAxis](domain[j]) - width / 2;
6380
6529
  var breakB = breakA + width;
6381
6530
 
6382
6531
  if (input > breakA && input <= breakB) {
@@ -6476,10 +6625,10 @@ var WebsyChart = /*#__PURE__*/function () {
6476
6625
  }, {
6477
6626
  key: "handleEventMouseMove",
6478
6627
  value: function handleEventMouseMove(event, d) {
6479
- var _this40 = this;
6628
+ var _this39 = this;
6480
6629
 
6481
6630
  var bisectDate = d3.bisector(function (d) {
6482
- return _this40.parseX(d.x.value);
6631
+ return _this39.parseX(d.x.value);
6483
6632
  }).left;
6484
6633
 
6485
6634
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
@@ -6518,8 +6667,8 @@ var WebsyChart = /*#__PURE__*/function () {
6518
6667
  }
6519
6668
 
6520
6669
  this.options.data.series.forEach(function (s) {
6521
- if (_this40.options.data[xData].scale !== 'Time') {
6522
- xPoint = _this40[xAxis](_this40.parseX(xLabel));
6670
+ if (_this39.options.data[xData].scale !== 'Time') {
6671
+ xPoint = _this39[xAxis](_this39.parseX(xLabel));
6523
6672
  s.data.forEach(function (d) {
6524
6673
  if (d.x.value === xLabel) {
6525
6674
  if (!tooltipTitle) {
@@ -6538,13 +6687,13 @@ var WebsyChart = /*#__PURE__*/function () {
6538
6687
  var pointA = s.data[index - 1];
6539
6688
  var pointB = s.data[index];
6540
6689
 
6541
- if (_this40.options.orientation === 'horizontal') {
6690
+ if (_this39.options.orientation === 'horizontal') {
6542
6691
  pointA = _toConsumableArray(s.data).reverse()[index - 1];
6543
6692
  pointB = _toConsumableArray(s.data).reverse()[index];
6544
6693
  }
6545
6694
 
6546
6695
  if (pointA && !pointB) {
6547
- xPoint = _this40[xAxis](_this40.parseX(pointA.x.value));
6696
+ xPoint = _this39[xAxis](_this39.parseX(pointA.x.value));
6548
6697
  tooltipTitle = pointA.x.value;
6549
6698
 
6550
6699
  if (!pointA.y.color) {
@@ -6554,12 +6703,12 @@ var WebsyChart = /*#__PURE__*/function () {
6554
6703
  tooltipData.push(pointA.y);
6555
6704
 
6556
6705
  if (typeof pointA.x.value.getTime !== 'undefined') {
6557
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointA.x.value);
6706
+ tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointA.x.value);
6558
6707
  }
6559
6708
  }
6560
6709
 
6561
6710
  if (pointB && !pointA) {
6562
- xPoint = _this40[xAxis](_this40.parseX(pointB.x.value));
6711
+ xPoint = _this39[xAxis](_this39.parseX(pointB.x.value));
6563
6712
  tooltipTitle = pointB.x.value;
6564
6713
 
6565
6714
  if (!pointB.y.color) {
@@ -6569,14 +6718,14 @@ var WebsyChart = /*#__PURE__*/function () {
6569
6718
  tooltipData.push(pointB.y);
6570
6719
 
6571
6720
  if (typeof pointB.x.value.getTime !== 'undefined') {
6572
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
6721
+ tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
6573
6722
  }
6574
6723
  }
6575
6724
 
6576
6725
  if (pointA && pointB) {
6577
- var d0 = _this40[xAxis](_this40.parseX(pointA.x.value));
6726
+ var d0 = _this39[xAxis](_this39.parseX(pointA.x.value));
6578
6727
 
6579
- var d1 = _this40[xAxis](_this40.parseX(pointB.x.value));
6728
+ var d1 = _this39[xAxis](_this39.parseX(pointB.x.value));
6580
6729
 
6581
6730
  var mid = Math.abs(d0 - d1) / 2;
6582
6731
 
@@ -6585,7 +6734,7 @@ var WebsyChart = /*#__PURE__*/function () {
6585
6734
  tooltipTitle = pointB.x.value;
6586
6735
 
6587
6736
  if (typeof pointB.x.value.getTime !== 'undefined') {
6588
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
6737
+ tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
6589
6738
  }
6590
6739
 
6591
6740
  if (!pointB.y.color) {
@@ -6598,7 +6747,7 @@ var WebsyChart = /*#__PURE__*/function () {
6598
6747
  tooltipTitle = pointA.x.value;
6599
6748
 
6600
6749
  if (typeof pointB.x.value.getTime !== 'undefined') {
6601
- tooltipTitle = d3.timeFormat(_this40.options.dateFormat || _this40.options.calculatedTimeFormatPattern)(pointB.x.value);
6750
+ tooltipTitle = d3.timeFormat(_this39.options.dateFormat || _this39.options.calculatedTimeFormatPattern)(pointB.x.value);
6602
6751
  }
6603
6752
 
6604
6753
  if (!pointA.y.color) {
@@ -6703,7 +6852,7 @@ var WebsyChart = /*#__PURE__*/function () {
6703
6852
  }, {
6704
6853
  key: "render",
6705
6854
  value: function render(options) {
6706
- var _this41 = this;
6855
+ var _this40 = this;
6707
6856
 
6708
6857
  /* global d3 options WebsyUtils */
6709
6858
  if (typeof options !== 'undefined') {
@@ -6772,7 +6921,7 @@ var WebsyChart = /*#__PURE__*/function () {
6772
6921
  var legendData = this.options.data.series.map(function (s, i) {
6773
6922
  return {
6774
6923
  value: s.label || s.key,
6775
- color: s.color || _this41.options.colors[i % _this41.options.colors.length]
6924
+ color: s.color || _this40.options.colors[i % _this40.options.colors.length]
6776
6925
  };
6777
6926
  });
6778
6927
 
@@ -7024,7 +7173,7 @@ var WebsyChart = /*#__PURE__*/function () {
7024
7173
 
7025
7174
  if (this.options.data.bottom.formatter) {
7026
7175
  bAxisFunc.tickFormat(function (d) {
7027
- return _this41.options.data.bottom.formatter(d);
7176
+ return _this40.options.data.bottom.formatter(d);
7028
7177
  });
7029
7178
  }
7030
7179
 
@@ -7050,8 +7199,8 @@ var WebsyChart = /*#__PURE__*/function () {
7050
7199
 
7051
7200
  if (this.options.margin.axisLeft > 0) {
7052
7201
  this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
7053
- if (_this41.options.data.left.formatter) {
7054
- d = _this41.options.data.left.formatter(d);
7202
+ if (_this40.options.data.left.formatter) {
7203
+ d = _this40.options.data.left.formatter(d);
7055
7204
  }
7056
7205
 
7057
7206
  return d;
@@ -7088,8 +7237,8 @@ var WebsyChart = /*#__PURE__*/function () {
7088
7237
 
7089
7238
  if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
7090
7239
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
7091
- if (_this41.options.data.right.formatter) {
7092
- d = _this41.options.data.right.formatter(d);
7240
+ if (_this40.options.data.right.formatter) {
7241
+ d = _this40.options.data.right.formatter(d);
7093
7242
  }
7094
7243
 
7095
7244
  return d;
@@ -7115,16 +7264,16 @@ var WebsyChart = /*#__PURE__*/function () {
7115
7264
 
7116
7265
  this.options.data.series.forEach(function (series, index) {
7117
7266
  if (!series.key) {
7118
- series.key = _this41.createIdentity();
7267
+ series.key = _this40.createIdentity();
7119
7268
  }
7120
7269
 
7121
7270
  if (!series.color) {
7122
- series.color = _this41.options.colors[index % _this41.options.colors.length];
7271
+ series.color = _this40.options.colors[index % _this40.options.colors.length];
7123
7272
  }
7124
7273
 
7125
- _this41["render".concat(series.type || 'bar')](series, index);
7274
+ _this40["render".concat(series.type || 'bar')](series, index);
7126
7275
 
7127
- _this41.renderLabels(series, index);
7276
+ _this40.renderLabels(series, index);
7128
7277
  });
7129
7278
  }
7130
7279
  }
@@ -7132,17 +7281,17 @@ var WebsyChart = /*#__PURE__*/function () {
7132
7281
  }, {
7133
7282
  key: "renderarea",
7134
7283
  value: function renderarea(series, index) {
7135
- var _this42 = this;
7284
+ var _this41 = this;
7136
7285
 
7137
7286
  /* global d3 series index */
7138
7287
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
7139
7288
  return d3.area().x(function (d) {
7140
- return _this42[xAxis](_this42.parseX(d.x.value));
7289
+ return _this41[xAxis](_this41.parseX(d.x.value));
7141
7290
  }).y0(function (d) {
7142
- return _this42[yAxis](0);
7291
+ return _this41[yAxis](0);
7143
7292
  }).y1(function (d) {
7144
- return _this42[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7145
- }).curve(d3[curveStyle || _this42.options.curveStyle]);
7293
+ return _this41[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7294
+ }).curve(d3[curveStyle || _this41.options.curveStyle]);
7146
7295
  };
7147
7296
 
7148
7297
  var xAxis = 'bottomAxis';
@@ -7246,11 +7395,11 @@ var WebsyChart = /*#__PURE__*/function () {
7246
7395
 
7247
7396
  bars.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
7248
7397
  bars.attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)).transition(this.transition).attr('fill', function (d) {
7249
- return d.color || series.color;
7398
+ return d.y.color || d.color || series.color;
7250
7399
  });
7251
7400
  bars.enter().append('rect').attr('width', getBarWidth.bind(this)).attr('height', getBarHeight.bind(this)).attr('x', getBarX.bind(this)).attr('y', getBarY.bind(this)) // .transition(this.transition)
7252
7401
  .attr('fill', function (d) {
7253
- return d.color || series.color;
7402
+ return d.y.color || d.color || series.color;
7254
7403
  }).attr('class', function (d) {
7255
7404
  return "bar bar_".concat(series.key);
7256
7405
  });
@@ -7258,7 +7407,7 @@ var WebsyChart = /*#__PURE__*/function () {
7258
7407
  }, {
7259
7408
  key: "renderLabels",
7260
7409
  value: function renderLabels(series, index) {
7261
- var _this43 = this;
7410
+ var _this42 = this;
7262
7411
 
7263
7412
  /* global series index d3 WebsyDesigns */
7264
7413
  var xAxis = 'bottomAxis';
@@ -7270,20 +7419,36 @@ var WebsyChart = /*#__PURE__*/function () {
7270
7419
  yAxis = 'bottomAxis';
7271
7420
  }
7272
7421
 
7273
- if (this.options.showLabels) {
7422
+ if (this.options.showLabels === true || series.showLabels === true) {
7274
7423
  // need to add logic to handle positioning options
7275
7424
  // e.g. Inside, Outide, Auto (this will also affect the available plot space)
7276
7425
  // We currently only support 'Auto'
7277
7426
  var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
7278
7427
  labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
7279
- labels.attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('class', "label_".concat(series.key)).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill', function (d) {
7280
- return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
7281
- }).transition(this.transition).text(function (d) {
7428
+ labels.attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
7429
+ return _this42.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7430
+ }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
7282
7431
  return d.y.label || d.y.value;
7432
+ }).each(function (d, i) {
7433
+ if (that.options.orientation === 'horizontal') {
7434
+ if (that.options.grouping === 'stacked') {
7435
+ this.setAttribute('text-anchor', 'middle');
7436
+ } else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7437
+ this.setAttribute('text-anchor', 'end');
7438
+ this.setAttribute('x', +this.getAttribute('x') - 8);
7439
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
7440
+ } else {
7441
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7442
+ }
7443
+ } else {
7444
+ if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
7445
+ this.setAttribute('y', +this.getAttribute('y') + 8);
7446
+ }
7447
+ }
7283
7448
  });
7284
- labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).style('fill', function (d) {
7285
- return _this43.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.color || series.color);
7286
- }).text(function (d) {
7449
+ labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', getLabelX.bind(this)).attr('y', getLabelY.bind(this)).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
7450
+ return _this42.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
7451
+ }).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
7287
7452
  return d.y.label || d.y.value;
7288
7453
  }).each(function (d, i) {
7289
7454
  if (that.options.orientation === 'horizontal') {
@@ -7292,6 +7457,9 @@ var WebsyChart = /*#__PURE__*/function () {
7292
7457
  } else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
7293
7458
  this.setAttribute('text-anchor', 'end');
7294
7459
  this.setAttribute('x', +this.getAttribute('x') - 8);
7460
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color));
7461
+ } else {
7462
+ this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'));
7295
7463
  }
7296
7464
  } else {
7297
7465
  if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
@@ -7327,15 +7495,15 @@ var WebsyChart = /*#__PURE__*/function () {
7327
7495
  }, {
7328
7496
  key: "renderline",
7329
7497
  value: function renderline(series, index) {
7330
- var _this44 = this;
7498
+ var _this43 = this;
7331
7499
 
7332
7500
  /* global series index d3 */
7333
7501
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
7334
7502
  return d3.line().x(function (d) {
7335
- return _this44[xAxis](_this44.parseX(d.x.value));
7503
+ return _this43[xAxis](_this43.parseX(d.x.value));
7336
7504
  }).y(function (d) {
7337
- return _this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7338
- }).curve(d3[curveStyle || _this44.options.curveStyle]);
7505
+ return _this43[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
7506
+ }).curve(d3[curveStyle || _this43.options.curveStyle]);
7339
7507
  };
7340
7508
 
7341
7509
  var xAxis = 'bottomAxis';
@@ -7373,14 +7541,14 @@ var WebsyChart = /*#__PURE__*/function () {
7373
7541
  }, {
7374
7542
  key: "rendersymbol",
7375
7543
  value: function rendersymbol(series, index) {
7376
- var _this45 = this;
7544
+ var _this44 = this;
7377
7545
 
7378
7546
  /* global d3 series index series.key */
7379
7547
  var drawSymbol = function drawSymbol(size) {
7380
7548
  return d3.symbol() // .type(d => {
7381
7549
  // return d3.symbols[0]
7382
7550
  // })
7383
- .size(size || _this45.options.symbolSize);
7551
+ .size(size || _this44.options.symbolSize);
7384
7552
  };
7385
7553
 
7386
7554
  var xAxis = 'bottomAxis';
@@ -7398,7 +7566,7 @@ var WebsyChart = /*#__PURE__*/function () {
7398
7566
  symbols.attr('d', function (d) {
7399
7567
  return drawSymbol(d.y.size || series.symbolSize)(d);
7400
7568
  }).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
7401
- return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
7569
+ return "translate(".concat(_this44[xAxis](_this44.parseX(d.x.value)), ", ").concat(_this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
7402
7570
  }); // Enter
7403
7571
 
7404
7572
  symbols.enter().append('path').attr('d', function (d) {
@@ -7407,7 +7575,7 @@ var WebsyChart = /*#__PURE__*/function () {
7407
7575
  .attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
7408
7576
  return "symbol symbol_".concat(series.key);
7409
7577
  }).attr('transform', function (d) {
7410
- return "translate(".concat(_this45[xAxis](_this45.parseX(d.x.value)), ", ").concat(_this45[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
7578
+ return "translate(".concat(_this44[xAxis](_this44.parseX(d.x.value)), ", ").concat(_this44[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
7411
7579
  });
7412
7580
  }
7413
7581
  }, {
@@ -7562,7 +7730,7 @@ var WebsyLegend = /*#__PURE__*/function () {
7562
7730
  }, {
7563
7731
  key: "resize",
7564
7732
  value: function resize() {
7565
- var _this46 = this;
7733
+ var _this45 = this;
7566
7734
 
7567
7735
  var el = document.getElementById(this.elementId);
7568
7736
 
@@ -7575,7 +7743,7 @@ var WebsyLegend = /*#__PURE__*/function () {
7575
7743
  // }
7576
7744
  var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
7577
7745
  html += this._data.map(function (d, i) {
7578
- return _this46.getLegendItemHTML(d);
7746
+ return _this45.getLegendItemHTML(d);
7579
7747
  }).join('');
7580
7748
  html += "\n <div>\n ";
7581
7749
  el.innerHTML = html;
@@ -7747,7 +7915,7 @@ var WebsyMap = /*#__PURE__*/function () {
7747
7915
  }, {
7748
7916
  key: "render",
7749
7917
  value: function render() {
7750
- var _this47 = this;
7918
+ var _this46 = this;
7751
7919
 
7752
7920
  var mapEl = document.getElementById("".concat(this.elementId, "_map"));
7753
7921
  var legendEl = document.getElementById("".concat(this.elementId, "_map"));
@@ -7756,7 +7924,7 @@ var WebsyMap = /*#__PURE__*/function () {
7756
7924
  var legendData = this.options.data.polygons.map(function (s, i) {
7757
7925
  return {
7758
7926
  value: s.label || s.key,
7759
- color: s.color || _this47.options.colors[i % _this47.options.colors.length]
7927
+ color: s.color || _this46.options.colors[i % _this46.options.colors.length]
7760
7928
  };
7761
7929
  });
7762
7930
  var longestValue = legendData.map(function (s) {
@@ -7820,7 +7988,7 @@ var WebsyMap = /*#__PURE__*/function () {
7820
7988
 
7821
7989
  if (this.polygons) {
7822
7990
  this.polygons.forEach(function (p) {
7823
- return _this47.map.removeLayer(p);
7991
+ return _this46.map.removeLayer(p);
7824
7992
  });
7825
7993
  }
7826
7994
 
@@ -7878,18 +8046,18 @@ var WebsyMap = /*#__PURE__*/function () {
7878
8046
  }
7879
8047
 
7880
8048
  if (!p.options.color) {
7881
- p.options.color = _this47.options.colors[i % _this47.options.colors.length];
8049
+ p.options.color = _this46.options.colors[i % _this46.options.colors.length];
7882
8050
  }
7883
8051
 
7884
8052
  var pol = L.polygon(p.data.map(function (c) {
7885
8053
  return c.map(function (d) {
7886
8054
  return [d.Latitude, d.Longitude];
7887
8055
  });
7888
- }), p.options).addTo(_this47.map);
8056
+ }), p.options).addTo(_this46.map);
7889
8057
 
7890
- _this47.polygons.push(pol);
8058
+ _this46.polygons.push(pol);
7891
8059
 
7892
- _this47.map.fitBounds(pol.getBounds());
8060
+ _this46.map.fitBounds(pol.getBounds());
7893
8061
  });
7894
8062
  } // if (this.data.markers.length > 0) {
7895
8063
  // el.classList.remove('hidden')