@websy/websy-designs 0.0.116 → 0.0.120

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) {
@@ -210,8 +212,10 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
210
212
  _classCallCheck(this, WebsyNavigationMenu);
211
213
 
212
214
  this.options = _extends({}, {
215
+ collapsable: false,
213
216
  orientation: 'horizontal',
214
- parentMap: {}
217
+ parentMap: {},
218
+ childIndentation: 10
215
219
  }, options);
216
220
 
217
221
  if (!elementId) {
@@ -265,8 +269,12 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
265
269
  if (el) {
266
270
  var html = "";
267
271
 
272
+ if (this.options.collapsable === true) {
273
+ html += "\n <div id='".concat(this.elementId, "_menuIcon' class='websy-menu-icon'>\n <svg viewbox=\"0 0 40 40\" width=\"30\" height=\"40\"> \n <rect x=\"0\" y=\"0\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"12\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"24\" width=\"30\" height=\"4\" rx=\"2\"></rect>\n </svg>\n </div>\n ");
274
+ }
275
+
268
276
  if (this.options.logo) {
269
- html += "\n <div id='".concat(this.elementId, "_menuIcon' class='websy-menu-icon'>\n <svg viewbox=\"0 0 40 40\" width=\"40\" height=\"40\"> \n <rect x=\"0\" y=\"0\" width=\"40\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"12\" width=\"40\" height=\"4\" rx=\"2\"></rect>\n <rect x=\"0\" y=\"24\" width=\"40\" height=\"4\" rx=\"2\"></rect>\n </svg>\n </div>\n <div \n class='logo ").concat(this.options.logo.classes && this.options.logo.classes.join(' ') || '', "'\n ").concat(this.options.logo.attributes && this.options.logo.attributes.join(' '), "\n >\n <img src='").concat(this.options.logo.url, "'></img>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-menu-mask'></div>\n <div id=\"").concat(this.elementId, "_menuContainer\" class=\"websy-menu-block-container\">\n ");
277
+ html += " \n <div \n class='logo ".concat(this.options.logo.classes && this.options.logo.classes.join(' ') || '', "'\n ").concat(this.options.logo.attributes && this.options.logo.attributes.join(' '), "\n >\n <img src='").concat(this.options.logo.url, "'></img>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-menu-mask'></div>\n <div id=\"").concat(this.elementId, "_menuContainer\" class=\"websy-menu-block-container\">\n ");
270
278
  }
271
279
 
272
280
  html += this.renderBlock(this.options.items, 'main', 1);
@@ -295,7 +303,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
295
303
 
296
304
  var active = items[i]["default"] === true ? 'active' : '';
297
305
  var currentBlock = this.normaliseString(items[i].text);
298
- html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes && items[i].classes.join(' '), " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(this.elementId, "_").concat(currentBlock, "_label' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "' \n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.menuHPadding, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' '), "\n >\n ");
306
+ html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes && items[i].classes.join(' '), " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(this.elementId, "_").concat(currentBlock, "_label' \n\t\t\t\t\t\t data-id='").concat(currentBlock, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n\t\t\t\t\t\t data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n\t\t\t\t\t\t data-text='").concat(items[i].text, "'\n\t\t\t\t\t\t style='padding-left: ").concat(level * this.options.childIndentation, "px'\n\t\t\t\t\t\t ").concat(items[i].attributes && items[i].attributes.join(' '), "\n >\n ");
299
307
 
300
308
  if (this.options.orientation === 'horizontal') {
301
309
  html += items[i].text;
@@ -326,6 +334,9 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
326
334
  html += "</ul>";
327
335
  return html;
328
336
  }
337
+ }, {
338
+ key: "toggleOpen",
339
+ value: function toggleOpen() {}
329
340
  }, {
330
341
  key: "toggleMobileMenu",
331
342
  value: function toggleMobileMenu(method) {
@@ -395,6 +406,16 @@ var WebsyForm = /*#__PURE__*/function () {
395
406
  }
396
407
 
397
408
  _createClass(WebsyForm, [{
409
+ key: "cancelForm",
410
+ value: function cancelForm() {
411
+ var formEl = document.getElementById("".concat(this.elementId, "Form"));
412
+ formEl.reset();
413
+
414
+ if (this.options.cancelFn) {
415
+ this.options.cancelFn(this.elementId);
416
+ }
417
+ }
418
+ }, {
398
419
  key: "checkRecaptcha",
399
420
  value: function checkRecaptcha() {
400
421
  var _this = this;
@@ -440,8 +461,12 @@ var WebsyForm = /*#__PURE__*/function () {
440
461
  }, {
441
462
  key: "handleClick",
442
463
  value: function handleClick(event) {
464
+ event.preventDefault();
465
+
443
466
  if (event.target.classList.contains('submit')) {
444
467
  this.submitForm();
468
+ } else if (event.target.classList.contains('cancel')) {
469
+ this.cancelForm();
445
470
  }
446
471
  }
447
472
  }, {
@@ -492,23 +517,28 @@ var WebsyForm = /*#__PURE__*/function () {
492
517
 
493
518
  if (el) {
494
519
  var html = "\n <form id=\"".concat(this.elementId, "Form\">\n ");
495
- this.options.fields.forEach(function (f) {
520
+ this.options.fields.forEach(function (f, i) {
496
521
  if (f.component) {
497
522
  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 ");
523
+ 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
524
  } 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 ");
525
+ 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
526
  } 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 ");
527
+ 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
528
  }
504
529
  });
530
+ html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
531
+
532
+ if (this.options.cancel) {
533
+ html += "\n --><button class=\"websy-btn cancel ".concat(this.options.cancel.classes, "\">").concat(this.options.cancel.text || 'Cancel', "</button>\n ");
534
+ }
535
+
505
536
  html += " \n </form>\n <div id=\"".concat(this.elementId, "_validationFail\" class=\"websy-validation-failure\"></div>\n ");
506
537
 
507
538
  if (this.options.useRecaptcha === true) {
508
539
  html += "\n <div id='".concat(this.elementId, "_recaptcha'></div>\n ");
509
540
  }
510
541
 
511
- html += "\n <button class=\"websy-btn submit ".concat(this.options.submit.classes, "\">").concat(this.options.submit.text || 'Save', "</button>\n ");
512
542
  el.innerHTML = html;
513
543
  this.processComponents(componentsToProcess, function () {
514
544
  if (_this3.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
@@ -1009,6 +1039,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1009
1039
  Date.prototype.floor = function () {
1010
1040
  return new Date("".concat(this.getMonth() + 1, "/").concat(this.getDate(), "/").concat(this.getFullYear()));
1011
1041
  };
1042
+ /* global WebsyUtils */
1043
+
1012
1044
 
1013
1045
  var WebsyDropdown = /*#__PURE__*/function () {
1014
1046
  function WebsyDropdown(elementId, options) {
@@ -1021,8 +1053,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1021
1053
  style: 'plain',
1022
1054
  items: [],
1023
1055
  label: '',
1056
+ disabled: false,
1024
1057
  minSearchCharacters: 2,
1025
- showCompleteSelectedList: false
1058
+ showCompleteSelectedList: false,
1059
+ closeAfterSelection: true
1026
1060
  };
1027
1061
  this.options = _extends({}, DEFAULTS, options);
1028
1062
  this.tooltipTimeoutFn = null;
@@ -1065,6 +1099,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1065
1099
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1066
1100
  maskEl.classList.remove('active');
1067
1101
  contentEl.classList.remove('active');
1102
+ contentEl.classList.remove('on-top');
1068
1103
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
1069
1104
 
1070
1105
  if (searchEl) {
@@ -1078,6 +1113,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1078
1113
  }, {
1079
1114
  key: "handleClick",
1080
1115
  value: function handleClick(event) {
1116
+ if (this.options.disabled === true) {
1117
+ return;
1118
+ }
1119
+
1081
1120
  if (event.target.classList.contains('websy-dropdown-header')) {
1082
1121
  this.open();
1083
1122
  } else if (event.target.classList.contains('websy-dropdown-mask')) {
@@ -1176,6 +1215,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1176
1215
  maskEl.classList.add('active');
1177
1216
  contentEl.classList.add('active');
1178
1217
 
1218
+ if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
1219
+ contentEl.classList.add('on-top');
1220
+ }
1221
+
1179
1222
  if (this.options.disableSearch !== true) {
1180
1223
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
1181
1224
 
@@ -1195,10 +1238,13 @@ var WebsyDropdown = /*#__PURE__*/function () {
1195
1238
  }
1196
1239
 
1197
1240
  var el = document.getElementById(this.elementId);
1241
+ var headerLabel = this.selectedItems.map(function (s) {
1242
+ return _this7.options.items[s].label || _this7.options.items[s].value;
1243
+ }).join(this.options.multiValueDelimiter);
1198
1244
  var headerValue = this.selectedItems.map(function (s) {
1199
- return _this7.options.items[s].label;
1245
+ return _this7.options.items[s].value || _this7.options.items[s].label;
1200
1246
  }).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 ");
1247
+ 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
1248
 
1203
1249
  if (this.options.allowClear === true) {
1204
1250
  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 +1325,26 @@ var WebsyDropdown = /*#__PURE__*/function () {
1279
1325
  if (this.selectedItems.length === 1) {
1280
1326
  labelEl.innerHTML = item.label;
1281
1327
  labelEl.setAttribute('data-info', item.label);
1282
- inputEl.value = item.label;
1328
+ inputEl.value = item.value;
1283
1329
  } else if (this.selectedItems.length > 1) {
1284
1330
  if (this.options.showCompleteSelectedList === true) {
1331
+ var selectedLabels = this.selectedItems.map(function (s) {
1332
+ return _this9.options.items[s].label || _this9.options.items[s].value;
1333
+ }).join(this.options.multiValueDelimiter);
1285
1334
  var selectedValues = this.selectedItems.map(function (s) {
1286
- return _this9.options.items[s].label;
1335
+ return _this9.options.items[s].value || _this9.options.items[s].label;
1287
1336
  }).join(this.options.multiValueDelimiter);
1288
- labelEl.innerHTML = selectedValues;
1289
- labelEl.setAttribute('data-info', selectedValues);
1337
+ labelEl.innerHTML = selectedLabels;
1338
+ labelEl.setAttribute('data-info', selectedLabels);
1290
1339
  inputEl.value = selectedValues;
1291
1340
  } else {
1341
+ var _selectedValues = this.selectedItems.map(function (s) {
1342
+ return _this9.options.items[s].value || _this9.options.items[s].label;
1343
+ }).join(this.options.multiValueDelimiter);
1344
+
1292
1345
  labelEl.innerHTML = "".concat(this.selectedItems.length, " selected");
1293
1346
  labelEl.setAttribute('data-info', '');
1294
- inputEl.value = this.selectedItems.join(this.options.multiValueDelimiter);
1347
+ inputEl.value = _selectedValues;
1295
1348
  }
1296
1349
  } else {
1297
1350
  labelEl.innerHTML = '';
@@ -1324,7 +1377,9 @@ var WebsyDropdown = /*#__PURE__*/function () {
1324
1377
  this.options.onItemSelected(item, this.selectedItems, this.options.items);
1325
1378
  }
1326
1379
 
1327
- this.close();
1380
+ if (this.options.closeAfterSelection === true) {
1381
+ this.close();
1382
+ }
1328
1383
  }
1329
1384
  }, {
1330
1385
  key: "selections",
@@ -1611,6 +1666,183 @@ var WebsyResultList = /*#__PURE__*/function () {
1611
1666
 
1612
1667
  return WebsyResultList;
1613
1668
  }();
1669
+ /* global WebsyDesigns */
1670
+
1671
+
1672
+ var WebsyTemplate = /*#__PURE__*/function () {
1673
+ function WebsyTemplate(elementId, options) {
1674
+ var _this14 = this;
1675
+
1676
+ _classCallCheck(this, WebsyTemplate);
1677
+
1678
+ var DEFAULTS = {
1679
+ listeners: {
1680
+ click: {}
1681
+ }
1682
+ };
1683
+ this.options = _extends({}, DEFAULTS, options);
1684
+ this.elementId = elementId;
1685
+ this.templateService = new WebsyDesigns.APIService('');
1686
+
1687
+ if (!elementId) {
1688
+ console.log('No element Id provided for Websy Template');
1689
+ return;
1690
+ }
1691
+
1692
+ var el = document.getElementById(elementId);
1693
+
1694
+ if (el) {
1695
+ el.addEventListener('click', this.handleClick.bind(this));
1696
+ }
1697
+
1698
+ if (_typeof(options.template) === 'object' && options.template.url) {
1699
+ this.templateService.get(options.template.url).then(function (templateString) {
1700
+ _this14.options.template = templateString;
1701
+
1702
+ _this14.render();
1703
+ });
1704
+ } else {
1705
+ this.render();
1706
+ }
1707
+ }
1708
+
1709
+ _createClass(WebsyTemplate, [{
1710
+ key: "buildHTML",
1711
+ value: function buildHTML() {
1712
+ var _this15 = this;
1713
+
1714
+ var html = "";
1715
+
1716
+ if (this.options.template) {
1717
+ var template = this.options.template; // find conditional elements
1718
+
1719
+ var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
1720
+
1721
+ ifMatches.forEach(function (m) {
1722
+ // get the condition
1723
+ if (m[0] && m.index > -1) {
1724
+ var conditionMatch = m[0].match(/(\scondition=["|']\w.+)["|']/g);
1725
+
1726
+ if (conditionMatch && conditionMatch[0]) {
1727
+ var c = conditionMatch[0].trim().replace('condition=', '');
1728
+
1729
+ if (c.split('')[0] === '"') {
1730
+ c = c.replace(/"/g, '');
1731
+ } else if (c.split('')[0] === '\'') {
1732
+ c = c.replace(/'/g, '');
1733
+ }
1734
+
1735
+ var parts = [];
1736
+ var polarity = true;
1737
+
1738
+ if (c.indexOf('===') !== -1) {
1739
+ parts = c.split('===');
1740
+ } else if (c.indexOf('!==') !== -1) {
1741
+ parts = c.split('!==');
1742
+ polarity = false;
1743
+ } else if (c.indexOf('==') !== -1) {
1744
+ parts = c.split('==');
1745
+ } else if (c.indexOf('!=') !== -1) {
1746
+ parts = c.split('!=');
1747
+ polarity = false;
1748
+ }
1749
+
1750
+ var removeAll = true;
1751
+
1752
+ if (parts.length === 2) {
1753
+ if (!isNaN(parts[1])) {
1754
+ parts[1] = +parts[1];
1755
+ }
1756
+
1757
+ if (parts[1] === 'true') {
1758
+ parts[1] = true;
1759
+ }
1760
+
1761
+ if (parts[1] === 'false') {
1762
+ parts[1] = false;
1763
+ }
1764
+
1765
+ if (typeof parts[1] === 'string') {
1766
+ if (parts[1].indexOf('"') !== -1) {
1767
+ parts[1] = parts[1].replace(/"/g, '');
1768
+ } else if (parts[1].indexOf('\'') !== -1) {
1769
+ parts[1] = parts[1].replace(/'/g, '');
1770
+ }
1771
+ }
1772
+
1773
+ if (polarity === true) {
1774
+ if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] === parts[1]) {
1775
+ // remove the <if> tags
1776
+ removeAll = false;
1777
+ } else if (parts[0] === parts[1]) {
1778
+ removeAll = false;
1779
+ }
1780
+ } else if (polarity === false) {
1781
+ if (typeof _this15.options.data[parts[0]] !== 'undefined' && _this15.options.data[parts[0]] !== parts[1]) {
1782
+ // remove the <if> tags
1783
+ removeAll = false;
1784
+ }
1785
+ }
1786
+ }
1787
+
1788
+ if (removeAll === true) {
1789
+ // remove the whole markup
1790
+ template = template.replace(m[0], '');
1791
+ } else {
1792
+ // remove the <if> tags
1793
+ var newMarkup = m[0];
1794
+ newMarkup = newMarkup.replace('</if>', '').replace(/<\s*if[^>]*>/g, '');
1795
+ template = template.replace(m[0], newMarkup);
1796
+ }
1797
+ }
1798
+ }
1799
+ });
1800
+
1801
+ var tagMatches = _toConsumableArray(template.matchAll(/(\sdata-event=["|']\w.+)["|']/g));
1802
+
1803
+ tagMatches.forEach(function (m) {
1804
+ if (m[0] && m.index > -1) {
1805
+ template = template.replace(m[0], "".concat(m[0]));
1806
+ }
1807
+ });
1808
+
1809
+ for (var key in this.options.data) {
1810
+ var rg = new RegExp("{".concat(key, "}"), 'gm');
1811
+
1812
+ if (rg) {
1813
+ template = template.replace(rg, this.options.data[key]);
1814
+ }
1815
+ }
1816
+
1817
+ html = template;
1818
+ }
1819
+
1820
+ return html;
1821
+ }
1822
+ }, {
1823
+ key: "handleClick",
1824
+ value: function handleClick(event) {//
1825
+ }
1826
+ }, {
1827
+ key: "render",
1828
+ value: function render() {
1829
+ this.resize();
1830
+ }
1831
+ }, {
1832
+ key: "resize",
1833
+ value: function resize() {
1834
+ var html = this.buildHTML();
1835
+ var el = document.getElementById(this.elementId);
1836
+ el.innerHTML = html.replace(/\n/g, '');
1837
+
1838
+ if (this.options.readyCallbackFn) {
1839
+ this.options.readyCallbackFn();
1840
+ }
1841
+ }
1842
+ }]);
1843
+
1844
+ return WebsyTemplate;
1845
+ }();
1614
1846
 
1615
1847
  var WebsyPubSub = /*#__PURE__*/function () {
1616
1848
  function WebsyPubSub(elementId, options) {
@@ -2254,7 +2486,7 @@ var APIService = /*#__PURE__*/function () {
2254
2486
  query.push("id:".concat(id));
2255
2487
  }
2256
2488
 
2257
- return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "?where=".concat(query.join(';')) : '');
2489
+ return "".concat(this.baseUrl, "/").concat(entity).concat(query.length > 0 ? "".concat(entity.indexOf('?') === -1 ? '?' : '&', "where=").concat(query.join(';')) : '');
2258
2490
  }
2259
2491
  }, {
2260
2492
  key: "delete",
@@ -2425,58 +2657,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2425
2657
  _createClass(WebsyPDFButton, [{
2426
2658
  key: "handleClick",
2427
2659
  value: function handleClick(event) {
2428
- var _this14 = this;
2660
+ var _this16 = this;
2429
2661
 
2430
2662
  if (event.target.classList.contains('websy-pdf-button')) {
2431
2663
  this.loader.show();
2432
2664
  setTimeout(function () {
2433
- if (_this14.options.targetId) {
2434
- var el = document.getElementById(_this14.options.targetId);
2665
+ if (_this16.options.targetId) {
2666
+ var el = document.getElementById(_this16.options.targetId);
2435
2667
 
2436
2668
  if (el) {
2437
2669
  var pdfData = {
2438
2670
  options: {}
2439
2671
  };
2440
2672
 
2441
- if (_this14.options.pdfOptions) {
2442
- pdfData.options = _extends({}, _this14.options.pdfOptions);
2673
+ if (_this16.options.pdfOptions) {
2674
+ pdfData.options = _extends({}, _this16.options.pdfOptions);
2443
2675
  }
2444
2676
 
2445
- if (_this14.options.header) {
2446
- if (_this14.options.header.elementId) {
2447
- var headerEl = document.getElementById(_this14.options.header.elementId);
2677
+ if (_this16.options.header) {
2678
+ if (_this16.options.header.elementId) {
2679
+ var headerEl = document.getElementById(_this16.options.header.elementId);
2448
2680
 
2449
2681
  if (headerEl) {
2450
2682
  pdfData.header = headerEl.outerHTML;
2451
2683
 
2452
- if (_this14.options.header.css) {
2453
- pdfData.options.headerCSS = _this14.options.header.css;
2684
+ if (_this16.options.header.css) {
2685
+ pdfData.options.headerCSS = _this16.options.header.css;
2454
2686
  }
2455
2687
  }
2456
- } else if (_this14.options.header.html) {
2457
- pdfData.header = _this14.options.header.html;
2688
+ } else if (_this16.options.header.html) {
2689
+ pdfData.header = _this16.options.header.html;
2458
2690
 
2459
- if (_this14.options.header.css) {
2460
- pdfData.options.headerCSS = _this14.options.header.css;
2691
+ if (_this16.options.header.css) {
2692
+ pdfData.options.headerCSS = _this16.options.header.css;
2461
2693
  }
2462
2694
  } else {
2463
- pdfData.header = _this14.options.header;
2695
+ pdfData.header = _this16.options.header;
2464
2696
  }
2465
2697
  }
2466
2698
 
2467
- if (_this14.options.footer) {
2468
- if (_this14.options.footer.elementId) {
2469
- var footerEl = document.getElementById(_this14.options.footer.elementId);
2699
+ if (_this16.options.footer) {
2700
+ if (_this16.options.footer.elementId) {
2701
+ var footerEl = document.getElementById(_this16.options.footer.elementId);
2470
2702
 
2471
2703
  if (footerEl) {
2472
2704
  pdfData.footer = footerEl.outerHTML;
2473
2705
 
2474
- if (_this14.options.footer.css) {
2475
- pdfData.options.footerCSS = _this14.options.footer.css;
2706
+ if (_this16.options.footer.css) {
2707
+ pdfData.options.footerCSS = _this16.options.footer.css;
2476
2708
  }
2477
2709
  }
2478
2710
  } else {
2479
- pdfData.footer = _this14.options.footer;
2711
+ pdfData.footer = _this16.options.footer;
2480
2712
  }
2481
2713
  }
2482
2714
 
@@ -2485,17 +2717,17 @@ var WebsyPDFButton = /*#__PURE__*/function () {
2485
2717
  // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
2486
2718
  // document.getElementById(`${this.elementId}_form`).submit()
2487
2719
 
2488
- _this14.service.add('', pdfData, {
2720
+ _this16.service.add('', pdfData, {
2489
2721
  responseType: 'blob'
2490
2722
  }).then(function (response) {
2491
- _this14.loader.hide();
2723
+ _this16.loader.hide();
2492
2724
 
2493
2725
  var blob = new Blob([response], {
2494
2726
  type: 'application/pdf'
2495
2727
  });
2496
2728
 
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 "),
2729
+ _this16.popup.show({
2730
+ 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
2731
  mask: true
2500
2732
  });
2501
2733
  }, function (err) {
@@ -2552,20 +2784,34 @@ var WebsyTable = /*#__PURE__*/function () {
2552
2784
  _createClass(WebsyTable, [{
2553
2785
  key: "appendRows",
2554
2786
  value: function appendRows(data) {
2555
- var _this15 = this;
2787
+ var _this17 = this;
2556
2788
 
2557
2789
  var bodyHTML = '';
2558
2790
 
2559
2791
  if (data) {
2560
2792
  bodyHTML += data.map(function (r, rowIndex) {
2561
2793
  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 ");
2794
+ if (_this17.options.columns[i].show !== false) {
2795
+ var style = '';
2796
+
2797
+ if (_this17.options.columns[i].width) {
2798
+ style += "width: ".concat(_this17.options.columns[i].width, "; ");
2799
+ }
2800
+
2801
+ if (c.backgroundColor) {
2802
+ style += "background-color: ".concat(c.backgroundColor, "; ");
2803
+ }
2804
+
2805
+ if (c.color) {
2806
+ style += "color: ".concat(c.color, "; ");
2807
+ }
2808
+
2809
+ if (_this17.options.columns[i].showAsLink === true && c.value.trim() !== '') {
2810
+ return "\n <td \n data-row-index='".concat(_this17.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this17.options.columns[i].classes || '', "' \n style='").concat(style, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this17.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(_this17.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
2811
+ } else if (_this17.options.columns[i].showAsNavigatorLink === true && c.value.trim() !== '') {
2812
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this17.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='trigger-item ").concat(_this17.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this17.options.columns[i].classes || '', "' \n style='").concat(style, "'\n >").concat(_this17.options.columns[i].linkText || c.value, "</td>\n ");
2567
2813
  } 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 ");
2814
+ return "\n <td \n data-info='".concat(c.value, "' \n data-row-index='").concat(_this17.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this17.options.columns[i].classes || '', "' \n style='").concat(style, "'>").concat(c.value, "</td>\n ");
2569
2815
  }
2570
2816
  }
2571
2817
  }).join('') + '</tr>';
@@ -2704,7 +2950,7 @@ var WebsyTable = /*#__PURE__*/function () {
2704
2950
  }, {
2705
2951
  key: "render",
2706
2952
  value: function render(data) {
2707
- var _this16 = this;
2953
+ var _this18 = this;
2708
2954
 
2709
2955
  if (!this.options.columns) {
2710
2956
  return;
@@ -2727,7 +2973,7 @@ var WebsyTable = /*#__PURE__*/function () {
2727
2973
 
2728
2974
  var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
2729
2975
  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 ");
2976
+ 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
2977
  }
2732
2978
  }).join('') + '</tr>';
2733
2979
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -2862,11 +3108,11 @@ var WebsyChart = /*#__PURE__*/function () {
2862
3108
  }, {
2863
3109
  key: "handleEventMouseMove",
2864
3110
  value: function handleEventMouseMove(event, d) {
2865
- var _this17 = this;
3111
+ var _this19 = this;
2866
3112
 
2867
3113
  // console.log('mouse move', event, d, d3.pointer(event))
2868
3114
  var bisectDate = d3.bisector(function (d) {
2869
- return _this17.parseX(d.x.value);
3115
+ return _this19.parseX(d.x.value);
2870
3116
  }).left;
2871
3117
 
2872
3118
  if (this.options.showTrackingLine === true && d3.pointer(event)) {
@@ -2885,18 +3131,18 @@ var WebsyChart = /*#__PURE__*/function () {
2885
3131
  var pointB = s.data[index];
2886
3132
 
2887
3133
  if (pointA) {
2888
- xPoint = _this17.bottomAxis(_this17.parseX(pointA.x.value));
3134
+ xPoint = _this19.bottomAxis(_this19.parseX(pointA.x.value));
2889
3135
  tooltipTitle = pointA.x.value;
2890
3136
 
2891
3137
  if (typeof pointA.x.value.getTime !== 'undefined') {
2892
- tooltipTitle = d3.timeFormat(_this17.options.dateFormat)(pointA.x.value);
3138
+ tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointA.x.value);
2893
3139
  }
2894
3140
  }
2895
3141
 
2896
3142
  if (pointA && pointB) {
2897
- var d0 = _this17.bottomAxis(_this17.parseX(pointA.x.value));
3143
+ var d0 = _this19.bottomAxis(_this19.parseX(pointA.x.value));
2898
3144
 
2899
- var d1 = _this17.bottomAxis(_this17.parseX(pointB.x.value));
3145
+ var d1 = _this19.bottomAxis(_this19.parseX(pointB.x.value));
2900
3146
 
2901
3147
  var mid = Math.abs(d0 - d1) / 2;
2902
3148
 
@@ -2905,7 +3151,7 @@ var WebsyChart = /*#__PURE__*/function () {
2905
3151
  tooltipTitle = pointB.x.value;
2906
3152
 
2907
3153
  if (typeof pointB.x.value.getTime !== 'undefined') {
2908
- tooltipTitle = d3.timeFormat(_this17.options.dateFormat)(pointB.x.value);
3154
+ tooltipTitle = d3.timeFormat(_this19.options.dateFormat)(pointB.x.value);
2909
3155
  }
2910
3156
 
2911
3157
  tooltipData.push(pointB.y);
@@ -2956,6 +3202,7 @@ var WebsyChart = /*#__PURE__*/function () {
2956
3202
  this.areaLayer = this.svg.append('g');
2957
3203
  this.lineLayer = this.svg.append('g');
2958
3204
  this.barLayer = this.svg.append('g');
3205
+ this.labelLayer = this.svg.append('g');
2959
3206
  this.symbolLayer = this.svg.append('g');
2960
3207
  this.trackingLineLayer = this.svg.append('g');
2961
3208
  this.trackingLineLayer.append('line').attr('class', 'tracking-line');
@@ -2967,7 +3214,7 @@ var WebsyChart = /*#__PURE__*/function () {
2967
3214
  }, {
2968
3215
  key: "render",
2969
3216
  value: function render(options) {
2970
- var _this18 = this;
3217
+ var _this20 = this;
2971
3218
 
2972
3219
  /* global d3 options */
2973
3220
  if (typeof options !== 'undefined') {
@@ -3150,6 +3397,7 @@ var WebsyChart = /*#__PURE__*/function () {
3150
3397
  this.areaLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3151
3398
  this.lineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3152
3399
  this.barLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3400
+ this.labelLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3153
3401
  this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3154
3402
  this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3155
3403
  this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
@@ -3200,7 +3448,7 @@ var WebsyChart = /*#__PURE__*/function () {
3200
3448
 
3201
3449
  if (this.options.data.bottom.formatter) {
3202
3450
  bAxisFunc.tickFormat(function (d) {
3203
- return _this18.options.data.bottom.formatter(d);
3451
+ return _this20.options.data.bottom.formatter(d);
3204
3452
  });
3205
3453
  }
3206
3454
 
@@ -3226,8 +3474,8 @@ var WebsyChart = /*#__PURE__*/function () {
3226
3474
 
3227
3475
  if (this.options.margin.axisLeft > 0) {
3228
3476
  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);
3477
+ if (_this20.options.data.left.formatter) {
3478
+ d = _this20.options.data.left.formatter(d);
3231
3479
  }
3232
3480
 
3233
3481
  return d;
@@ -3262,8 +3510,8 @@ var WebsyChart = /*#__PURE__*/function () {
3262
3510
 
3263
3511
  if (this.options.margin.axisRight > 0) {
3264
3512
  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);
3513
+ if (_this20.options.data.right.formatter) {
3514
+ d = _this20.options.data.right.formatter(d);
3267
3515
  }
3268
3516
 
3269
3517
  return d;
@@ -3289,14 +3537,16 @@ var WebsyChart = /*#__PURE__*/function () {
3289
3537
 
3290
3538
  this.options.data.series.forEach(function (series, index) {
3291
3539
  if (!series.key) {
3292
- series.key = _this18.createIdentity();
3540
+ series.key = _this20.createIdentity();
3293
3541
  }
3294
3542
 
3295
3543
  if (!series.color) {
3296
- series.color = _this18.options.colors[index % _this18.options.colors.length];
3544
+ series.color = _this20.options.colors[index % _this20.options.colors.length];
3297
3545
  }
3298
3546
 
3299
- _this18["render".concat(series.type || 'bar')](series, index);
3547
+ _this20["render".concat(series.type || 'bar')](series, index);
3548
+
3549
+ _this20.renderLabels(series, index);
3300
3550
  });
3301
3551
  }
3302
3552
  }
@@ -3304,17 +3554,17 @@ var WebsyChart = /*#__PURE__*/function () {
3304
3554
  }, {
3305
3555
  key: "renderarea",
3306
3556
  value: function renderarea(series, index) {
3307
- var _this19 = this;
3557
+ var _this21 = this;
3308
3558
 
3309
3559
  /* global d3 series index */
3310
3560
  var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
3311
3561
  return d3.area().x(function (d) {
3312
- return _this19[xAxis](_this19.parseX(d.x.value));
3562
+ return _this21[xAxis](_this21.parseX(d.x.value));
3313
3563
  }).y0(function (d) {
3314
- return _this19[yAxis](0);
3564
+ return _this21[yAxis](0);
3315
3565
  }).y1(function (d) {
3316
- return _this19[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3317
- }).curve(d3[curveStyle || _this19.options.curveStyle]);
3566
+ return _this21[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3567
+ }).curve(d3[curveStyle || _this21.options.curveStyle]);
3318
3568
  };
3319
3569
 
3320
3570
  var xAxis = 'bottomAxis';
@@ -3400,18 +3650,72 @@ var WebsyChart = /*#__PURE__*/function () {
3400
3650
  return "bar bar_".concat(series.key);
3401
3651
  });
3402
3652
  }
3653
+ }, {
3654
+ key: "renderLabels",
3655
+ value: function renderLabels(series, index) {
3656
+ /* global series index d3 */
3657
+ var xAxis = 'bottomAxis';
3658
+ var yAxis = 'leftAxis';
3659
+ var that = this;
3660
+
3661
+ if (this.options.orientation === 'horizontal') {
3662
+ xAxis = 'leftAxis';
3663
+ yAxis = 'bottomAxis';
3664
+ }
3665
+
3666
+ if (this.options.showLabels) {
3667
+ // need to add logic to handle positioning options
3668
+ // e.g. Inside, Outide, Auto (this will also affect the available plot space)
3669
+ // We currently only support 'Auto'
3670
+ var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
3671
+ labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
3672
+ 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")).transition(this.transition).text(function (d) {
3673
+ return d.y.label || d.y.value;
3674
+ });
3675
+ 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")).text(function (d) {
3676
+ return d.y.label || d.y.value;
3677
+ }).each(function (d, i) {
3678
+ if (that.options.orientation === 'horizontal') {
3679
+ if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
3680
+ this.setAttribute('text-anchor', 'end');
3681
+ this.setAttribute('x', +this.getAttribute('x') - 8);
3682
+ }
3683
+ } else {
3684
+ if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
3685
+ this.setAttribute('y', +this.getAttribute('y') + 8);
3686
+ }
3687
+ }
3688
+ });
3689
+ }
3690
+
3691
+ function getLabelX(d) {
3692
+ if (this.options.orientation === 'horizontal') {
3693
+ return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
3694
+ } else {
3695
+ return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
3696
+ }
3697
+ }
3698
+
3699
+ function getLabelY(d) {
3700
+ if (this.options.orientation === 'horizontal') {
3701
+ return this[xAxis](this.parseX(d.x.value)) + this[xAxis].bandwidth() / 2;
3702
+ } else {
3703
+ return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4;
3704
+ }
3705
+ }
3706
+ }
3403
3707
  }, {
3404
3708
  key: "renderline",
3405
3709
  value: function renderline(series, index) {
3406
- var _this20 = this;
3710
+ var _this22 = this;
3407
3711
 
3408
3712
  /* global series index d3 */
3409
3713
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
3410
3714
  return d3.line().x(function (d) {
3411
- return _this20[xAxis](_this20.parseX(d.x.value));
3715
+ return _this22[xAxis](_this22.parseX(d.x.value));
3412
3716
  }).y(function (d) {
3413
- return _this20[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3414
- }).curve(d3[curveStyle || _this20.options.curveStyle]);
3717
+ return _this22[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
3718
+ }).curve(d3[curveStyle || _this22.options.curveStyle]);
3415
3719
  };
3416
3720
 
3417
3721
  var xAxis = 'bottomAxis';
@@ -3449,14 +3753,14 @@ var WebsyChart = /*#__PURE__*/function () {
3449
3753
  }, {
3450
3754
  key: "rendersymbol",
3451
3755
  value: function rendersymbol(series, index) {
3452
- var _this21 = this;
3756
+ var _this23 = this;
3453
3757
 
3454
3758
  /* global d3 series index series.key */
3455
3759
  var drawSymbol = function drawSymbol(size) {
3456
3760
  return d3.symbol() // .type(d => {
3457
3761
  // return d3.symbols[0]
3458
3762
  // })
3459
- .size(size || _this21.options.symbolSize);
3763
+ .size(size || _this23.options.symbolSize);
3460
3764
  };
3461
3765
 
3462
3766
  var xAxis = 'bottomAxis';
@@ -3474,7 +3778,7 @@ var WebsyChart = /*#__PURE__*/function () {
3474
3778
  symbols.attr('d', function (d) {
3475
3779
  return drawSymbol(d.y.size || series.symbolSize)(d);
3476
3780
  }).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), ")");
3781
+ return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
3478
3782
  }); // Enter
3479
3783
 
3480
3784
  symbols.enter().append('path').attr('d', function (d) {
@@ -3483,7 +3787,7 @@ var WebsyChart = /*#__PURE__*/function () {
3483
3787
  .attr('fill', 'white').attr('stroke', series.color).attr('class', function (d) {
3484
3788
  return "symbol symbol_".concat(series.key);
3485
3789
  }).attr('transform', function (d) {
3486
- return "translate(".concat(_this21[xAxis](_this21.parseX(d.x.value)), ", ").concat(_this21[yAxis](d.y.value), ")");
3790
+ return "translate(".concat(_this23[xAxis](_this23.parseX(d.x.value)), ", ").concat(_this23[yAxis](isNaN(d.y.value) ? 0 : d.y.value), ")");
3487
3791
  });
3488
3792
  }
3489
3793
  }, {
@@ -3496,9 +3800,11 @@ var WebsyChart = /*#__PURE__*/function () {
3496
3800
  this.width = el.clientWidth;
3497
3801
  this.height = el.clientHeight;
3498
3802
  this.svg.attr('width', this.width).attr('height', this.height); // Define the plot height
3803
+ // this.plotWidth = this.width - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight
3804
+ // this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom
3499
3805
 
3500
3806
  this.plotWidth = this.width - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight;
3501
- this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom; // establish the space needed for the various axes
3807
+ this.plotHeight = this.height - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop; // establish the space needed for the various axes
3502
3808
 
3503
3809
  this.longestRight = 5;
3504
3810
  this.longestBottom = 5;
@@ -3531,17 +3837,42 @@ var WebsyChart = /*#__PURE__*/function () {
3531
3837
  this.options.margin.axisBottom = 0;
3532
3838
  }
3533
3839
  } // Translate the layers
3534
-
3535
-
3536
- this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3537
- this.rightAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3538
- this.bottomAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.plotHeight, ")"));
3539
- this.plotArea.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3540
- this.areaLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3541
- this.lineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3542
- this.barLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3543
- this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3544
- this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top, ")"));
3840
+ // this.leftAxisLayer
3841
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3842
+ // this.rightAxisLayer
3843
+ // .attr('transform', `translate(${this.options.margin.left + this.plotWidth + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3844
+ // this.bottomAxisLayer
3845
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top + this.plotHeight})`)
3846
+ // this.plotArea
3847
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3848
+ // this.areaLayer
3849
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3850
+ // this.lineLayer
3851
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3852
+ // this.barLayer
3853
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3854
+ // this.labelLayer
3855
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3856
+ // this.symbolLayer
3857
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3858
+ // this.trackingLineLayer
3859
+ // .attr('transform', `translate(${this.options.margin.left + this.options.margin.axisLeft}, ${this.options.margin.top})`)
3860
+
3861
+
3862
+ this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3863
+ this.rightAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3864
+ this.bottomAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight, ")"));
3865
+ this.leftAxisLabel.attr('transform', "translate(".concat(this.options.margin.left, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3866
+ this.rightAxisLabel.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft + this.options.margin.axisRight, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3867
+ this.bottomAxisLabel.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight, ")"));
3868
+ this.plotArea.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3869
+ this.areaLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3870
+ this.lineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3871
+ this.barLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3872
+ this.labelLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3873
+ this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3874
+ this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3875
+ this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
3545
3876
  }
3546
3877
  }
3547
3878
  }, {
@@ -3689,7 +4020,7 @@ var WebsyMap = /*#__PURE__*/function () {
3689
4020
  }, {
3690
4021
  key: "render",
3691
4022
  value: function render() {
3692
- var _this22 = this;
4023
+ var _this24 = this;
3693
4024
 
3694
4025
  var el = document.getElementById("".concat(this.options.elementId, "_map"));
3695
4026
  var t = L.tileLayer(this.options.tileUrl, {
@@ -3756,30 +4087,30 @@ var WebsyMap = /*#__PURE__*/function () {
3756
4087
  if (r.Latitude.qNum !== 0 && r.Longitude.qNum !== 0) {
3757
4088
  var markerOptions = {};
3758
4089
 
3759
- if (_this22.options.simpleMarker === true) {
4090
+ if (_this24.options.simpleMarker === true) {
3760
4091
  markerOptions.icon = L.divIcon({
3761
4092
  className: 'simple-marker'
3762
4093
  });
3763
4094
  }
3764
4095
 
3765
- if (_this22.options.markerUrl) {
4096
+ if (_this24.options.markerUrl) {
3766
4097
  markerOptions.icon = L.icon({
3767
- iconUrl: _this22.options.markerUrl
4098
+ iconUrl: _this24.options.markerUrl
3768
4099
  });
3769
4100
  }
3770
4101
 
3771
4102
  markerOptions.data = r;
3772
4103
  var m = L.marker([r.Latitude.qText, r.Longitude.qText], markerOptions);
3773
- m.on('click', _this22.handleMapClick.bind(_this22));
4104
+ m.on('click', _this24.handleMapClick.bind(_this24));
3774
4105
 
3775
- if (_this22.options.useClustering === false) {
3776
- m.addTo(_this22.map);
4106
+ if (_this24.options.useClustering === false) {
4107
+ m.addTo(_this24.map);
3777
4108
  }
3778
4109
 
3779
- _this22.markers.push(m);
4110
+ _this24.markers.push(m);
3780
4111
 
3781
- if (_this22.options.useClustering === true) {
3782
- _this22.cluster.addLayer(m);
4112
+ if (_this24.options.useClustering === true) {
4113
+ _this24.cluster.addLayer(m);
3783
4114
  }
3784
4115
  }
3785
4116
  });
@@ -3864,6 +4195,30 @@ var WebsyChartTooltip = /*#__PURE__*/function () {
3864
4195
  return WebsyChartTooltip;
3865
4196
  }();
3866
4197
 
4198
+ var WebsyUtils = {
4199
+ createIdentity: function createIdentity() {
4200
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6;
4201
+ var text = '';
4202
+ var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
4203
+
4204
+ for (var i = 0; i < size; i++) {
4205
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
4206
+ }
4207
+
4208
+ return text;
4209
+ },
4210
+ getElementPos: function getElementPos(el) {
4211
+ var rect = el.getBoundingClientRect();
4212
+ var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
4213
+ var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
4214
+ return {
4215
+ top: rect.top + scrollTop,
4216
+ left: rect.left + scrollLeft,
4217
+ bottom: rect.top + scrollTop + el.clientHeight,
4218
+ right: rect.left + scrollLeft + el.clientWidth
4219
+ };
4220
+ }
4221
+ };
3867
4222
  var WebsyDesigns = {
3868
4223
  WebsyPopupDialog: WebsyPopupDialog,
3869
4224
  WebsyLoadingDialog: WebsyLoadingDialog,
@@ -3872,6 +4227,7 @@ var WebsyDesigns = {
3872
4227
  WebsyDatePicker: WebsyDatePicker,
3873
4228
  WebsyDropdown: WebsyDropdown,
3874
4229
  WebsyResultList: WebsyResultList,
4230
+ WebsyTemplate: WebsyTemplate,
3875
4231
  WebsyPubSub: WebsyPubSub,
3876
4232
  WebsyRouter: WebsyRouter,
3877
4233
  WebsyTable: WebsyTable,
@@ -3881,7 +4237,8 @@ var WebsyDesigns = {
3881
4237
  WebsyKPI: WebsyKPI,
3882
4238
  WebsyPDFButton: WebsyPDFButton,
3883
4239
  PDFButton: WebsyPDFButton,
3884
- APIService: APIService
4240
+ APIService: APIService,
4241
+ WebsyUtils: WebsyUtils
3885
4242
  };
3886
4243
  var GlobalPubSub = new WebsyPubSub('empty', {});
3887
4244