@websy/websy-designs 0.0.114 → 0.0.118

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.
@@ -39,7 +39,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
39
39
  WebsyMap
40
40
  WebsyKPI
41
41
  WebsyPDFButton
42
+ WebsyTemplate
42
43
  APIService
44
+ WebsyUtils
43
45
  */
44
46
  var WebsyPopupDialog = /*#__PURE__*/function () {
45
47
  function WebsyPopupDialog(elementId, options) {
@@ -395,6 +397,16 @@ var WebsyForm = /*#__PURE__*/function () {
395
397
  }
396
398
 
397
399
  _createClass(WebsyForm, [{
400
+ key: "cancelForm",
401
+ value: function cancelForm() {
402
+ var formEl = document.getElementById("".concat(this.elementId, "Form"));
403
+ formEl.reset();
404
+
405
+ if (this.options.cancelFn) {
406
+ this.options.cancelFn(this.elementId);
407
+ }
408
+ }
409
+ }, {
398
410
  key: "checkRecaptcha",
399
411
  value: function checkRecaptcha() {
400
412
  var _this = this;
@@ -440,8 +452,12 @@ var WebsyForm = /*#__PURE__*/function () {
440
452
  }, {
441
453
  key: "handleClick",
442
454
  value: function handleClick(event) {
455
+ event.preventDefault();
456
+
443
457
  if (event.target.classList.contains('submit')) {
444
458
  this.submitForm();
459
+ } else if (event.target.classList.contains('cancel')) {
460
+ this.cancelForm();
445
461
  }
446
462
  }
447
463
  }, {
@@ -492,23 +508,28 @@ var WebsyForm = /*#__PURE__*/function () {
492
508
 
493
509
  if (el) {
494
510
  var html = "\n <form id=\"".concat(this.elementId, "Form\">\n ");
495
- this.options.fields.forEach(function (f) {
511
+ this.options.fields.forEach(function (f, i) {
496
512
  if (f.component) {
497
513
  componentsToProcess.push(f);
498
- html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <div id='").concat(_this3.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n ");
514
+ 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(_this3.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
499
515
  } else if (f.type === 'longtext') {
500
- html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <textarea\n id=\"").concat(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n class=\"websy-input websy-textarea ").concat(f.classes, "\"\n ></textarea>\n ");
516
+ 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(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
501
517
  } else {
502
- html += "\n ".concat(f.label ? "<label for=\"".concat(f.field, "\">").concat(f.label, "</label>") : '', "\n <input \n id=\"").concat(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input ").concat(f.classes, "\" \n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n ");
518
+ 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(_this3.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
503
519
  }
504
520
  });
521
+ html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
522
+
523
+ if (this.options.cancel) {
524
+ html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes, "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
525
+ }
526
+
505
527
  html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
506
528
 
507
529
  if (this.options.useRecaptcha === true) {
508
530
  html += "\n <div id='".concat(this.elementId, "_recaptcha'></div>\n ");
509
531
  }
510
532
 
511
- html += "\n <button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>\n ");
512
533
  el.innerHTML = html;
513
534
  this.processComponents(componentsToProcess, function () {
514
535
  if (_this3.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
@@ -1009,6 +1030,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1009
1030
  Date.prototype.floor = function () {
1010
1031
  return new Date("".concat(this.getMonth() + 1, "/").concat(this.getDate(), "/").concat(this.getFullYear()));
1011
1032
  };
1033
+ /* global WebsyUtils */
1034
+
1012
1035
 
1013
1036
  var WebsyDropdown = /*#__PURE__*/function () {
1014
1037
  function WebsyDropdown(elementId, options) {
@@ -1021,8 +1044,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1021
1044
  style: 'plain',
1022
1045
  items: [],
1023
1046
  label: '',
1047
+ disabled: false,
1024
1048
  minSearchCharacters: 2,
1025
- showCompleteSelectedList: false
1049
+ showCompleteSelectedList: false,
1050
+ closeAfterSelection: true
1026
1051
  };
1027
1052
  this.options = _extends({}, DEFAULTS, options);
1028
1053
  this.tooltipTimeoutFn = null;
@@ -1065,6 +1090,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1065
1090
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1066
1091
  maskEl.classList.remove('active');
1067
1092
  contentEl.classList.remove('active');
1093
+ contentEl.classList.remove('on-top');
1068
1094
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
1069
1095
 
1070
1096
  if (searchEl) {
@@ -1078,6 +1104,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1078
1104
  }, {
1079
1105
  key: "handleClick",
1080
1106
  value: function handleClick(event) {
1107
+ if (this.options.disabled === true) {
1108
+ return;
1109
+ }
1110
+
1081
1111
  if (event.target.classList.contains('websy-dropdown-header')) {
1082
1112
  this.open();
1083
1113
  } else if (event.target.classList.contains('websy-dropdown-mask')) {
@@ -1176,6 +1206,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1176
1206
  maskEl.classList.add('active');
1177
1207
  contentEl.classList.add('active');
1178
1208
 
1209
+ if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
1210
+ contentEl.classList.add('on-top');
1211
+ }
1212
+
1179
1213
  if (this.options.disableSearch !== true) {
1180
1214
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
1181
1215
 
@@ -1195,10 +1229,13 @@ var WebsyDropdown = /*#__PURE__*/function () {
1195
1229
  }
1196
1230
 
1197
1231
  var el = document.getElementById(this.elementId);
1232
+ var headerLabel = this.selectedItems.map(function (s) {
1233
+ return _this7.options.items[s].label || _this7.options.items[s].value;
1234
+ }).join(this.options.multiValueDelimiter);
1198
1235
  var headerValue = this.selectedItems.map(function (s) {
1199
- return _this7.options.items[s].label;
1236
+ return _this7.options.items[s].value || _this7.options.items[s].label;
1200
1237
  }).join(this.options.multiValueDelimiter);
1201
- var html = "\n <div class='websy-dropdown-container ".concat(this.options.disableSearch !== true ? 'with-search' : '', "'>\n <div id='").concat(this.elementId, "_header' class='websy-dropdown-header ").concat(this.selectedItems.length === 1 ? 'one-selected' : '', " ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_headerLabel' class='websy-dropdown-header-label'>").concat(this.options.label, "</span>\n <span data-info='").concat(headerValue, "' class='websy-dropdown-header-value' id='").concat(this.elementId, "_selectedItems'>").concat(headerValue, "</span>\n <input class='dropdown-input' id='").concat(this.elementId, "_input' name='").concat(this.options.field || this.options.label, "' value='").concat(headerValue, "'>\n <svg class='arrow' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n ");
1238
+ var html = "\n <div class='websy-dropdown-container ".concat(this.options.disabled ? 'disabled' : '', " ").concat(this.options.disableSearch !== true ? 'with-search' : '', "'>\n <div id='").concat(this.elementId, "_header' class='websy-dropdown-header ").concat(this.selectedItems.length === 1 ? 'one-selected' : '', " ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_headerLabel' class='websy-dropdown-header-label'>").concat(this.options.label, "</span>\n <span data-info='").concat(headerLabel, "' class='websy-dropdown-header-value' id='").concat(this.elementId, "_selectedItems'>").concat(headerLabel, "</span>\n <input class='dropdown-input' id='").concat(this.elementId, "_input' name='").concat(this.options.field || this.options.label, "' value='").concat(headerValue, "'>\n <svg class='arrow' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n ");
1202
1239
 
1203
1240
  if (this.options.allowClear === true) {
1204
1241
  html += "\n <svg class='clear' xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 512 512\"><title>ionicons-v5-l</title><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n ";
@@ -1279,19 +1316,26 @@ var WebsyDropdown = /*#__PURE__*/function () {
1279
1316
  if (this.selectedItems.length === 1) {
1280
1317
  labelEl.innerHTML = item.label;
1281
1318
  labelEl.setAttribute('data-info', item.label);
1282
- inputEl.value = item.label;
1319
+ inputEl.value = item.value;
1283
1320
  } else if (this.selectedItems.length > 1) {
1284
1321
  if (this.options.showCompleteSelectedList === true) {
1322
+ var selectedLabels = this.selectedItems.map(function (s) {
1323
+ return _this9.options.items[s].label || _this9.options.items[s].value;
1324
+ }).join(this.options.multiValueDelimiter);
1285
1325
  var selectedValues = this.selectedItems.map(function (s) {
1286
- return _this9.options.items[s].label;
1326
+ return _this9.options.items[s].value || _this9.options.items[s].label;
1287
1327
  }).join(this.options.multiValueDelimiter);
1288
- labelEl.innerHTML = selectedValues;
1289
- labelEl.setAttribute('data-info', selectedValues);
1328
+ labelEl.innerHTML = selectedLabels;
1329
+ labelEl.setAttribute('data-info', selectedLabels);
1290
1330
  inputEl.value = selectedValues;
1291
1331
  } else {
1332
+ var _selectedValues = this.selectedItems.map(function (s) {
1333
+ return _this9.options.items[s].value || _this9.options.items[s].label;
1334
+ }).join(this.options.multiValueDelimiter);
1335
+
1292
1336
  labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
1293
1337
  labelEl.setAttribute('data-info', '');
1294
- inputEl.value = this.selectedItems.join(this.options.multiValueDelimiter);
1338
+ inputEl.value = _selectedValues;
1295
1339
  }
1296
1340
  } else {
1297
1341
  labelEl.innerHTML = '';
@@ -1324,7 +1368,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
1324
1368
  this.options.onItemSelected(item, this.selectedItems, this.options.items);
1325
1369
  }
1326
1370
 
1327
- this.close();
1371
+ if (this.options.closeAfterSelection === true) {
1372
+ this.close();
1373
+ }
1328
1374
  }
1329
1375
  }, {
1330
1376
  key: "selections",
@@ -1611,6 +1657,183 @@ var WebsyResultList = /*#__PURE__*/function () {
1611
1657
 
1612
1658
  return WebsyResultList;
1613
1659
  }();
1660
+ /* global WebsyDesigns */
1661
+
1662
+
1663
+ var WebsyTemplate = /*#__PURE__*/function () {
1664
+ function WebsyTemplate(elementId, options) {
1665
+ var _this14 = this;
1666
+
1667
+ _classCallCheck(this, WebsyTemplate);
1668
+
1669
+ var DEFAULTS = {
1670
+ listeners: {
1671
+ click: {}
1672
+ }
1673
+ };
1674
+ this.options = _extends({}, DEFAULTS, options);
1675
+ this.elementId = elementId;
1676
+ this.templateService = new WebsyDesigns.APIService('');
1677
+
1678
+ if (!elementId) {
1679
+ console.log('No element Id provided for Websy Template');
1680
+ return;
1681
+ }
1682
+
1683
+ var el = document.getElementById(elementId);
1684
+
1685
+ if (el) {
1686
+ el.addEventListener('click', this.handleClick.bind(this));
1687
+ }
1688
+
1689
+ if (_typeof(options.template) === 'object' && options.template.url) {
1690
+ this.templateService.get(options.template.url).then(function (templateString) {
1691
+ _this14.options.template = templateString;
1692
+
1693
+ _this14.render();
1694
+ });
1695
+ } else {
1696
+ this.render();
1697
+ }
1698
+ }
1699
+
1700
+ _createClass(WebsyTemplate, [{
1701
+ key: "buildHTML",
1702
+ value: function buildHTML() {
1703
+ var _this15 = this;
1704
+
1705
+ var html = "";
1706
+
1707
+ if (this.options.template) {
1708
+ var template = this.options.template; // find conditional elements
1709
+
1710
+ var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
1711
+
1712
+ ifMatches.forEach(function (m) {
1713
+ // get the condition
1714
+ if (m[0] && m.index > -1) {
1715
+ var conditionMatch = m[0].match(/(\scondition=["|']\w.+)["|']/g);
1716
+
1717
+ if (conditionMatch && conditionMatch[0]) {
1718
+ var c = conditionMatch[0].trim().replace('condition=', '');
1719
+
1720
+ if (c.split('')[0] === '"') {
1721
+ c = c.replace(/"/g, '');
1722
+ } else if (c.split('')[0] === '\'') {
1723
+ c = c.replace(/'/g, '');
1724
+ }
1725
+
1726
+ var parts = [];
1727
+ var polarity = true;
1728
+
1729
+ if (c.indexOf('===') !== -1) {
1730
+ parts = c.split('===');
1731
+ } else if (c.indexOf('!==') !== -1) {
1732
+ parts = c.split('!==');
1733
+ polarity = false;
1734
+ } else if (c.indexOf('==') !== -1) {
1735
+ parts = c.split('==');
1736
+ } else if (c.indexOf('!=') !== -1) {
1737
+ parts = c.split('!=');
1738
+ polarity = false;
1739
+ }
1740
+
1741
+ var removeAll = true;
1742
+
1743
+ if (parts.length === 2) {
1744
+ if (!isNaN(parts[1])) {
1745
+ parts[1] = +parts[1];
1746
+ }
1747
+
1748
+ if (parts[1] === 'true') {
1749
+ parts[1] = true;
1750
+ }
1751
+
1752
+ if (parts[1] === 'false') {
1753
+ parts[1] = false;
1754
+ }
1755
+
1756
+ if (typeof parts[1] === 'string') {
1757
+ if (parts[1].indexOf('"') !== -1) {
1758
+ parts[1] = parts[1].replace(/"/g, '');
1759
+ } else if (parts[1].indexOf('\'') !== -1) {
1760
+ parts[1] = parts[1].replace(/'/g, '');
1761
+ }
1762
+ }
1763
+
1764
+ if (polarity === true) {
1765
+ if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] === parts[1]) {
1766
+ // remove the <if> tags
1767
+ removeAll = false;
1768
+ } else if (parts[0] === parts[1]) {
1769
+ removeAll = false;
1770
+ }
1771
+ } else if (polarity === false) {
1772
+ if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] !== parts[1]) {
1773
+ // remove the <if> tags
1774
+ removeAll = false;
1775
+ }
1776
+ }
1777
+ }
1778
+
1779
+ if (removeAll === true) {
1780
+ // remove the whole markup
1781
+ template = template.replace(m[0], '');
1782
+ } else {
1783
+ // remove the <if> tags
1784
+ var newMarkup = m[0];
1785
+ newMarkup = newMarkup.replace('</if>', '').replace(/<\s*if[^>]*>/g, '');
1786
+ template = template.replace(m[0], newMarkup);
1787
+ }
1788
+ }
1789
+ }
1790
+ });
1791
+
1792
+ var tagMatches = _toConsumableArray(template.matchAll(/(\sdata-event=["|']\w.+)["|']/g));
1793
+
1794
+ tagMatches.forEach(function (m) {
1795
+ if (m[0] && m.index > -1) {
1796
+ template = template.replace(m[0], "".concat(m[0]));
1797
+ }
1798
+ });
1799
+
1800
+ for (var key in this.options.data) {
1801
+ var rg = new RegExp("{".concat(key, "}"), 'gm');
1802
+
1803
+ if (rg) {
1804
+ template = template.replace(rg, this.options.data[key]);
1805
+ }
1806
+ }
1807
+
1808
+ html = template;
1809
+ }
1810
+
1811
+ return html;
1812
+ }
1813
+ }, {
1814
+ key: "handleClick",
1815
+ value: function handleClick(event) {//
1816
+ }
1817
+ }, {
1818
+ key: "render",
1819
+ value: function render() {
1820
+ this.resize();
1821
+ }
1822
+ }, {
1823
+ key: "resize",
1824
+ value: function resize() {
1825
+ var html = this.buildHTML();
1826
+ var el = document.getElementById(this.elementId);
1827
+ el.innerHTML = html.replace(/\n/g, '');
1828
+
1829
+ if (this.options.readyCallbackFn) {
1830
+ this.options.readyCallbackFn();
1831
+ }
1832
+ }
1833
+ }]);
1834
+
1835
+ return WebsyTemplate;
1836
+ }();
1614
1837
 
1615
1838
  var WebsyPubSub = /*#__PURE__*/function () {
1616
1839
  function WebsyPubSub(elementId, options) {
@@ -2254,7 +2477,7 @@ var APIService = /*#__PURE__*/function () {
2254
2477
  query.push("id:".concat(id));
2255
2478
  }
2256
2479
 
2257
- return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "?where=".concat(query.join(';')) : '');
2480
+ return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "".concat(entity.indexOf('?') === -1 ? '?' : '&', "where=").concat(query.join(';')) : '');
2258
2481
  }
2259
2482
  }, {
2260
2483
  key: "delete",
@@ -2425,58 +2648,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2425
2648
  _createClass(WebsyPDFButton, [{
2426
2649
  key: "handleClick",
2427
2650
  value: function handleClick(event) {
2428
- var _this14 = this;
2651
+ var _this16 = this;
2429
2652
 
2430
2653
  if (event.target.classList.contains('websy-pdf-button')) {
2431
2654
  this.loader.show();
2432
2655
  setTimeout(function () {
2433
- if (_this14.options.targetId) {
2434
- var el = document.getElementById(_this14.options.targetId);
2656
+ if (_this16.options.targetId) {
2657
+ var el = document.getElementById(_this16.options.targetId);
2435
2658
 
2436
2659
  if (el) {
2437
2660
  var pdfData = {
2438
2661
  options: {}
2439
2662
  };
2440
2663
 
2441
- if (_this14.options.pdfOptions) {
2442
- pdfData.options = _extends({}, _this14.options.pdfOptions);
2664
+ if (_this16.options.pdfOptions) {
2665
+ pdfData.options = _extends({}, _this16.options.pdfOptions);
2443
2666
  }
2444
2667
 
2445
- if (_this14.options.header) {
2446
- if (_this14.options.header.elementId) {
2447
- var headerEl = document.getElementById(_this14.options.header.elementId);
2668
+ if (_this16.options.header) {
2669
+ if (_this16.options.header.elementId) {
2670
+ var headerEl = document.getElementById(_this16.options.header.elementId);
2448
2671
 
2449
2672
  if (headerEl) {
2450
2673
  pdfData.header = headerEl.outerHTML;
2451
2674
 
2452
- if (_this14.options.header.css) {
2453
- pdfData.options.headerCSS = _this14.options.header.css;
2675
+ if (_this16.options.header.css) {
2676
+ pdfData.options.headerCSS = _this16.options.header.css;
2454
2677
  }
2455
2678
  }
2456
- } else if (_this14.options.header.html) {
2457
- pdfData.header = _this14.options.header.html;
2679
+ } else if (_this16.options.header.html) {
2680
+ pdfData.header = _this16.options.header.html;
2458
2681
 
2459
- if (_this14.options.header.css) {
2460
- pdfData.options.headerCSS = _this14.options.header.css;
2682
+ if (_this16.options.header.css) {
2683
+ pdfData.options.headerCSS = _this16.options.header.css;
2461
2684
  }
2462
2685
  } else {
2463
- pdfData.header = _this14.options.header;
2686
+ pdfData.header = _this16.options.header;
2464
2687
  }
2465
2688
  }
2466
2689
 
2467
- if (_this14.options.footer) {
2468
- if (_this14.options.footer.elementId) {
2469
- var footerEl = document.getElementById(_this14.options.footer.elementId);
2690
+ if (_this16.options.footer) {
2691
+ if (_this16.options.footer.elementId) {
2692
+ var footerEl = document.getElementById(_this16.options.footer.elementId);
2470
2693
 
2471
2694
  if (footerEl) {
2472
2695
  pdfData.footer = footerEl.outerHTML;
2473
2696
 
2474
- if (_this14.options.footer.css) {
2475
- pdfData.options.footerCSS = _this14.options.footer.css;
2697
+ if (_this16.options.footer.css) {
2698
+ pdfData.options.footerCSS = _this16.options.footer.css;
2476
2699
  }
2477
2700
  }
2478
2701
  } else {
2479
- pdfData.footer = _this14.options.footer;
2702
+ pdfData.footer = _this16.options.footer;
2480
2703
  }
2481
2704
  }
2482
2705
 
@@ -2485,17 +2708,17 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2485
2708
  // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
2486
2709
  // document.getElementById(`${this.elementId}_form`).submit()
2487
2710
 
2488
- _this14.service.add('', pdfData, {
2711
+ _this16.service.add('', pdfData, {
2489
2712
  responseType: 'blob'
2490
2713
  }).then(function (response) {
2491
- _this14.loader.hide();
2714
+ _this16.loader.hide();
2492
2715
 
2493
2716
  var blob = new Blob([response], {
2494
2717
  type: 'application/pdf'
2495
2718
  });
2496
2719
 
2497
- _this14.popup.show({
2498
- message: "\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 <button class='websy-btn download-pdf'>").concat(_this14.options.buttonText, "</button>\n </a>\n </div>\n "),
2720
+ _this16.popup.show({
2721
+ message: "\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 <button class='websy-btn download-pdf'>").concat(_this16.options.buttonText, "</button>\n </a>\n </div>\n "),
2499
2722
  mask: true
2500
2723
  });
2501
2724
  }, function (err) {
@@ -2552,20 +2775,20 @@ var WebsyTable = /*#__PURE__*/function () {
2552
2775
  _createClass(WebsyTable, [{
2553
2776
  key: "appendRows",
2554
2777
  value: function appendRows(data) {
2555
- var _this15 = this;
2778
+ var _this17 = this;
2556
2779
 
2557
2780
  var bodyHTML = '';
2558
2781
 
2559
2782
  if (data) {
2560
2783
  bodyHTML += data.map(function (r, rowIndex) {
2561
2784
  return '<tr>' + r.map(function (c, i) {
2562
- if (_this15.options.columns[i].show !== false) {
2563
- if (_this15.options.columns[i].showAsLink === true && c.value.trim() !== '') {
2564
- return "\n <td data-row-index='".concat(_this15.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this15.options.columns[i].classes || '', "' ").concat(_this15.options.columns[i].width ? 'style="width: ' + _this15.options.columns[i].width + '"' : '', "><a href='").concat(c.value, "' target='").concat(_this15.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(_this15.options.columns[i].linkText || c.value, "</a></td>\n ");
2565
- } else if (_this15.options.columns[i].showAsNavigatorLink === true && c.value.trim() !== '') {
2566
- return "\n <td data-view='".concat(c.value, "' data-row-index='").concat(_this15.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='trigger-item ").concat(_this15.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this15.options.columns[i].classes || '', "' ").concat(_this15.options.columns[i].width ? 'style="width: ' + _this15.options.columns[i].width + '"' : '', ">").concat(_this15.options.columns[i].linkText || c.value, "</td>\n ");
2785
+ if (_this17.options.columns[i].show !== false) {
2786
+ if (_this17.options.columns[i].showAsLink === true && c.value.trim() !== '') {
2787
+ return "\n <td data-row-index='".concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + _this17.options.columns[i].width + '"' : '', "><a href='").concat(c.value, "' target='").concat(_this17.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(_this17.options.columns[i].linkText || c.value, "</a></td>\n ");
2788
+ } else if (_this17.options.columns[i].showAsNavigatorLink === true && c.value.trim() !== '') {
2789
+ return "\n <td data-view='".concat(c.value, "' data-row-index='").concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='trigger-item ").concat(_this17.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + _this17.options.columns[i].width + '"' : '', ">").concat(_this17.options.columns[i].linkText || c.value, "</td>\n ");
2567
2790
  } else {
2568
- return "\n <td data-info='".concat(c.value, "' data-row-index='").concat(_this15.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this15.options.columns[i].classes || '', "' ").concat(_this15.options.columns[i].width ? 'style="width: ' + (_this15.options.columns[i].width || 'auto') + '"' : '', ">").concat(c.value, "</td>\n ");
2791
+ return "\n <td data-info='".concat(c.value, "' data-row-index='").concat(_this17.rowCount + rowIndex, "' data-col-index='").concat(i, "' class='").concat(_this17.options.columns[i].classes || '', "' ").concat(_this17.options.columns[i].width ? 'style="width: ' + (_this17.options.columns[i].width || 'auto') + '"' : '', ">").concat(c.value, "</td>\n ");
2569
2792
  }
2570
2793
  }
2571
2794
  }).join('') + '</tr>';
@@ -2704,7 +2927,7 @@ var WebsyTable = /*#__PURE__*/function () {
2704
2927
  }, {
2705
2928
  key: "render",
2706
2929
  value: function render(data) {
2707
- var _this16 = this;
2930
+ var _this18 = this;
2708
2931
 
2709
2932
  if (!this.options.columns) {
2710
2933
  return;
@@ -2727,7 +2950,7 @@ var WebsyTable = /*#__PURE__*/function () {
2727
2950
 
2728
2951
  var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
2729
2952
  if (c.show !== false) {
2730
- 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 ? _this16.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
2953
+ 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 ? _this18.buildSearchIcon(c.qGroupFieldDefs[0]) : '', "-->\n </div>\n </th>\n ");
2731
2954
  }
2732
2955
  }).join('') + '</tr>';
2733
2956
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -2862,11 +3085,11 @@ var WebsyChart = /*#__PURE__*/function () {
2862
3085
  }, {
2863
3086
  key: "handleEventMouseMove",
2864
3087
  value: function handleEventMouseMove(event, d) {
2865
- var _this17 = this;
3088
+ var _this19 = this;
2866
3089
 
2867
3090
  // console.log('mouse move', event, d, d3.pointer(event))
2868
3091
  var bisectDate = d3.bisector(function (d) {
2869
- return _this17.parseX(d.x.value);
3092
+ return _this19.parseX(d.x.value);
2870
3093
  }).left;
2871
3094
 
2872
3095
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
@@ -2885,18 +3108,18 @@ var WebsyChart = /*#__PURE__*/function () {
2885
3108
  var pointB = s.data[index];
2886
3109
 
2887
3110
  if (pointA) {
2888
- xPoint = _this17.bottomAxis(_this17.parseX(pointA.x.value));
3111
+ xPoint = _this19.bottomAxis(_this19.parseX(pointA.x.value));
2889
3112
  tooltipTitle = pointA.x.value;
2890
3113
 
2891
3114
  if (typeof pointA.x.value.getTime !== 'undefined') {
2892
- tooltipTitle = d3.timeFormat(_this17.options.dateFormat)(pointA.x.value);
3115
+ tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointA.x.value);
2893
3116
  }
2894
3117
  }
2895
3118
 
2896
3119
  if (pointA && pointB) {
2897
- var d0 = _this17.bottomAxis(_this17.parseX(pointA.x.value));
3120
+ var d0 = _this19.bottomAxis(_this19.parseX(pointA.x.value));
2898
3121
 
2899
- var d1 = _this17.bottomAxis(_this17.parseX(pointB.x.value));
3122
+ var d1 = _this19.bottomAxis(_this19.parseX(pointB.x.value));
2900
3123
 
2901
3124
  var mid = Math.abs(d0 - d1) / 2;
2902
3125
 
@@ -2905,7 +3128,7 @@ var WebsyChart = /*#__PURE__*/function () {
2905
3128
  tooltipTitle = pointB.x.value;
2906
3129
 
2907
3130
  if (typeof pointB.x.value.getTime !== 'undefined') {
2908
- tooltipTitle = d3.timeFormat(_this17.options.dateFormat)(pointB.x.value);
3131
+ tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointB.x.value);
2909
3132
  }
2910
3133
 
2911
3134
  tooltipData.push(pointB.y);
@@ -2967,7 +3190,7 @@ var WebsyChart = /*#__PURE__*/function () {
2967
3190
  }, {
2968
3191
  key: "render",
2969
3192
  value: function render(options) {
2970
- var _this18 = this;
3193
+ var _this20 = this;
2971
3194
 
2972
3195
  /* global d3 options */
2973
3196
  if (typeof options !== 'undefined') {
@@ -3200,7 +3423,7 @@ var WebsyChart = /*#__PURE__*/function () {
3200
3423
 
3201
3424
  if (this.options.data.bottom.formatter) {
3202
3425
  bAxisFunc.tickFormat(function (d) {
3203
- return _this18.options.data.bottom.formatter(d);
3426
+ return _this20.options.data.bottom.formatter(d);
3204
3427
  });
3205
3428
  }
3206
3429
 
@@ -3226,8 +3449,8 @@ var WebsyChart = /*#__PURE__*/function () {
3226
3449
 
3227
3450
  if (this.options.margin.axisLeft > 0) {
3228
3451
  this.leftAxisLayer.call(d3.axisLeft(this.leftAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
3229
- if (_this18.options.data.left.formatter) {
3230
- d = _this18.options.data.left.formatter(d);
3452
+ if (_this20.options.data.left.formatter) {
3453
+ d = _this20.options.data.left.formatter(d);
3231
3454
  }
3232
3455
 
3233
3456
  return d;
@@ -3262,8 +3485,8 @@ var WebsyChart = /*#__PURE__*/function () {
3262
3485
 
3263
3486
  if (this.options.margin.axisRight > 0) {
3264
3487
  this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.left.ticks || 5).tickFormat(function (d) {
3265
- if (_this18.options.data.right.formatter) {
3266
- d = _this18.options.data.right.formatter(d);
3488
+ if (_this20.options.data.right.formatter) {
3489
+ d = _this20.options.data.right.formatter(d);
3267
3490
  }
3268
3491
 
3269
3492
  return d;
@@ -3289,14 +3512,14 @@ var WebsyChart = /*#__PURE__*/function () {
3289
3512
 
3290
3513
  this.options.data.series.forEach(function (series, index) {
3291
3514
  if (!series.key) {
3292
- series.key = _this18.createIdentity();
3515
+ series.key = _this20.createIdentity();
3293
3516
  }
3294
3517
 
3295
3518
  if (!series.color) {
3296
- series.color = _this18.options.colors[index % _this18.options.colors.length];
3519
+ series.color = _this20.options.colors[index % _this20.options.colors.length];
3297
3520
  }
3298
3521
 
3299
- _this18["render".concat(series.type || 'bar')](series, index);
3522
+ _this20["render".concat(series.type || 'bar')](series, index);
3300
3523
  });
3301
3524
  }
3302
3525
  }
@@ -3304,17 +3527,17 @@ var WebsyChart = /*#__PURE__*/function () {
3304
3527
  }, {
3305
3528
  key: "renderarea",
3306
3529
  value: function renderarea(series, index) {
3307
- var _this19 = this;
3530
+ var _this21 = this;
3308
3531
 
3309
3532
  /* global d3 series index */
3310
3533
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
3311
3534
  return d3.area().x(function (d) {
3312
- return _this19[xAxis](_this19.parseX(d.x.value));
3535
+ return _this21[xAxis](_this21.parseX(d.x.value));
3313
3536
  }).y0(function (d) {
3314
- return _this19[yAxis](0);
3537
+ return _this21[yAxis](0);
3315
3538
  }).y1(function (d) {
3316
- return _this19[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3317
- }).curve(d3[curveStyle || _this19.options.curveStyle]);
3539
+ return _this21[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3540
+ }).curve(d3[curveStyle || _this21.options.curveStyle]);
3318
3541
  };
3319
3542
 
3320
3543
  var xAxis = 'bottomAxis';
@@ -3403,15 +3626,15 @@ var WebsyChart = /*#__PURE__*/function () {
3403
3626
  }, {
3404
3627
  key: "renderline",
3405
3628
  value: function renderline(series, index) {
3406
- var _this20 = this;
3629
+ var _this22 = this;
3407
3630
 
3408
3631
  /* global series index d3 */
3409
3632
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
3410
3633
  return d3.line().x(function (d) {
3411
- return _this20[xAxis](_this20.parseX(d.x.value));
3634
+ return _this22[xAxis](_this22.parseX(d.x.value));
3412
3635
  }).y(function (d) {
3413
- return _this20[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3414
- }).curve(d3[curveStyle || _this20.options.curveStyle]);
3636
+ return _this22[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3637
+ }).curve(d3[curveStyle || _this22.options.curveStyle]);
3415
3638
  };
3416
3639
 
3417
3640
  var xAxis = 'bottomAxis';
@@ -3449,14 +3672,14 @@ var WebsyChart = /*#__PURE__*/function () {
3449
3672
  }, {
3450
3673
  key: "rendersymbol",
3451
3674
  value: function rendersymbol(series, index) {
3452
- var _this21 = this;
3675
+ var _this23 = this;
3453
3676
 
3454
3677
  /* global d3 series index series.key */
3455
3678
  var drawSymbol = function drawSymbol(size) {
3456
3679
  return d3.symbol() // .type(d => {
3457
3680
  // return d3.symbols[0]
3458
3681
  // })
3459
- .size(size || _this21.options.symbolSize);
3682
+ .size(size || _this23.options.symbolSize);
3460
3683
  };
3461
3684
 
3462
3685
  var xAxis = 'bottomAxis';
@@ -3474,7 +3697,7 @@ var WebsyChart = /*#__PURE__*/function () {
3474
3697
  symbols.attr('d', function (d) {
3475
3698
  return drawSymbol(d.y.size || series.symbolSize)(d);
3476
3699
  }).transition(this.transition).attr('fill', 'white').attr('stroke', series.color).attr('transform', function (d) {
3477
- return "translate(".concat(_this21[xAxis](_this21.parseX(d.x.value)), ", ").concat(_this21[yAxis](d.y.value), ")");
3700
+ return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](d.y.value), ")");
3478
3701
  }); // Enter
3479
3702
 
3480
3703
  symbols.enter().append('path').attr('d', function (d) {
@@ -3483,7 +3706,7 @@ var WebsyChart = /*#__PURE__*/function () {
3483
3706
  .attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
3484
3707
  return "symbol symbol_".concat(series.key);
3485
3708
  }).attr('transform', function (d) {
3486
- return "translate(".concat(_this21[xAxis](_this21.parseX(d.x.value)), ", ").concat(_this21[yAxis](d.y.value), ")");
3709
+ return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](d.y.value), ")");
3487
3710
  });
3488
3711
  }
3489
3712
  }, {
@@ -3689,7 +3912,7 @@ var WebsyMap = /*#__PURE__*/function () {
3689
3912
  }, {
3690
3913
  key: "render",
3691
3914
  value: function render() {
3692
- var _this22 = this;
3915
+ var _this24 = this;
3693
3916
 
3694
3917
  var el = document.getElementById("".concat(this.options.elementId, "_map"));
3695
3918
  var t = L.tileLayer(this.options.tileUrl, {
@@ -3756,30 +3979,30 @@ var WebsyMap = /*#__PURE__*/function () {
3756
3979
  if (r.Latitude.qNum !== 0 && r.Longitude.qNum !== 0) {
3757
3980
  var markerOptions = {};
3758
3981
 
3759
- if (_this22.options.simpleMarker === true) {
3982
+ if (_this24.options.simpleMarker === true) {
3760
3983
  markerOptions.icon = L.divIcon({
3761
3984
  className: 'simple-marker'
3762
3985
  });
3763
3986
  }
3764
3987
 
3765
- if (_this22.options.markerUrl) {
3988
+ if (_this24.options.markerUrl) {
3766
3989
  markerOptions.icon = L.icon({
3767
- iconUrl: _this22.options.markerUrl
3990
+ iconUrl: _this24.options.markerUrl
3768
3991
  });
3769
3992
  }
3770
3993
 
3771
3994
  markerOptions.data = r;
3772
3995
  var m = L.marker([r.Latitude.qText, r.Longitude.qText], markerOptions);
3773
- m.on('click', _this22.handleMapClick.bind(_this22));
3996
+ m.on('click', _this24.handleMapClick.bind(_this24));
3774
3997
 
3775
- if (_this22.options.useClustering === false) {
3776
- m.addTo(_this22.map);
3998
+ if (_this24.options.useClustering === false) {
3999
+ m.addTo(_this24.map);
3777
4000
  }
3778
4001
 
3779
- _this22.markers.push(m);
4002
+ _this24.markers.push(m);
3780
4003
 
3781
- if (_this22.options.useClustering === true) {
3782
- _this22.cluster.addLayer(m);
4004
+ if (_this24.options.useClustering === true) {
4005
+ _this24.cluster.addLayer(m);
3783
4006
  }
3784
4007
  }
3785
4008
  });
@@ -3864,6 +4087,30 @@ var WebsyChartTooltip = /*#__PURE__*/function () {
3864
4087
  return WebsyChartTooltip;
3865
4088
  }();
3866
4089
 
4090
+ var WebsyUtils = {
4091
+ createIdentity: function createIdentity() {
4092
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6;
4093
+ var text = '';
4094
+ var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
4095
+
4096
+ for (var i = 0; i < size; i++) {
4097
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
4098
+ }
4099
+
4100
+ return text;
4101
+ },
4102
+ getElementPos: function getElementPos(el) {
4103
+ var rect = el.getBoundingClientRect();
4104
+ var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
4105
+ var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
4106
+ return {
4107
+ top: rect.top + scrollTop,
4108
+ left: rect.left + scrollLeft,
4109
+ bottom: rect.top + scrollTop + el.clientHeight,
4110
+ right: rect.left + scrollLeft + el.clientWidth
4111
+ };
4112
+ }
4113
+ };
3867
4114
  var WebsyDesigns = {
3868
4115
  WebsyPopupDialog: WebsyPopupDialog,
3869
4116
  WebsyLoadingDialog: WebsyLoadingDialog,
@@ -3872,6 +4119,7 @@ var WebsyDesigns = {
3872
4119
  WebsyDatePicker: WebsyDatePicker,
3873
4120
  WebsyDropdown: WebsyDropdown,
3874
4121
  WebsyResultList: WebsyResultList,
4122
+ WebsyTemplate: WebsyTemplate,
3875
4123
  WebsyPubSub: WebsyPubSub,
3876
4124
  WebsyRouter: WebsyRouter,
3877
4125
  WebsyTable: WebsyTable,
@@ -3881,7 +4129,8 @@ var WebsyDesigns = {
3881
4129
  WebsyKPI: WebsyKPI,
3882
4130
  WebsyPDFButton: WebsyPDFButton,
3883
4131
  PDFButton: WebsyPDFButton,
3884
- APIService: APIService
4132
+ APIService: APIService,
4133
+ WebsyUtils: WebsyUtils
3885
4134
  };
3886
4135
  var GlobalPubSub = new WebsyPubSub('empty', {});
3887
4136