@websy/websy-designs 1.1.12 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -154,7 +154,8 @@ var APIService = /*#__PURE__*/function () {
154
154
  xhr.withCredentials = true;
155
155
 
156
156
  xhr.onload = function () {
157
- if (xhr.status === 401 || xhr.status === 403) {
157
+ if (xhr.status === 401) {
158
+ // || xhr.status === 403) {
158
159
  if (ENV && ENV.AUTH_REDIRECT) {
159
160
  window.location = ENV.AUTH_REDIRECT;
160
161
  } else {
@@ -304,6 +305,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
304
305
  this.shiftPressed = false;
305
306
  var DEFAULTS = {
306
307
  defaultRange: 0,
308
+ allowClear: true,
307
309
  minAllowedDate: this.floorDate(new Date(new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setDate(1))),
308
310
  maxAllowedDate: this.floorDate(new Date(new Date())),
309
311
  minAllowedYear: 1970,
@@ -385,7 +387,13 @@ var WebsyDatePicker = /*#__PURE__*/function () {
385
387
  el.addEventListener('mouseup', this.handleMouseUp.bind(this));
386
388
  document.addEventListener('keydown', this.handleKeyDown.bind(this));
387
389
  document.addEventListener('keyup', this.handleKeyUp.bind(this));
388
- var html = "\n <div class='websy-date-picker-container'>\n <span class='websy-dropdown-header-label'>".concat(this.options.label || 'Date', "</span>\n <div class='websy-date-picker-header'>\n <span id='").concat(this.elementId, "_selectedRange'>").concat(this.options.ranges[this.options.mode][this.selectedRange].label, "</span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n </div>\n <div id='").concat(this.elementId, "_mask' class='websy-date-picker-mask'></div>\n <div id='").concat(this.elementId, "_content' class='websy-date-picker-content'>\n <div class='websy-date-picker-ranges'>\n <ul id='").concat(this.elementId, "_rangelist'>\n ").concat(this.renderRanges(), "\n </ul>\n </div><!--\n --><div id='").concat(this.elementId, "_datelist' class='websy-date-picker-custom'>").concat(this.renderDates(), "</div>\n <div class='websy-dp-button-container'>\n <span class=\"dp-footnote\">Click and drag or hold Shift and click to select a range of values</span>\n <button class='").concat(this.options.cancelBtnClasses || '', " websy-btn websy-dp-cancel'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n <button class='").concat(this.options.confirmBtnClasses || '', " websy-btn websy-dp-confirm'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><polyline points=\"416 128 192 384 96 288\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n </div>\n </div> \n </div>\n ");
390
+ var html = "\n <div class='websy-date-picker-container'>\n <span class='websy-dropdown-header-label'>".concat(this.options.label || 'Date', "</span>\n <div id=\"").concat(this.elementId, "_header\" class='websy-date-picker-header ").concat(this.options.allowClear === true ? 'allow-clear' : '', "'>\n <span id='").concat(this.elementId, "_selectedRange'>").concat(this.options.ranges[this.options.mode][this.selectedRange].label, "</span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M23.677 18.52c.914 1.523-.183 3.472-1.967 3.472h-19.414c-1.784 0-2.881-1.949-1.967-3.472l9.709-16.18c.891-1.483 3.041-1.48 3.93 0l9.709 16.18z\"/></svg>\n ");
391
+
392
+ if (this.options.allowClear === true) {
393
+ html += "\n <svg class='clear-selection' 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 ";
394
+ }
395
+
396
+ html += "\n </div>\n <div id='".concat(this.elementId, "_mask' class='websy-date-picker-mask'></div>\n <div id='").concat(this.elementId, "_content' class='websy-date-picker-content'>\n <div class='websy-date-picker-ranges'>\n <ul id='").concat(this.elementId, "_rangelist'>\n ").concat(this.renderRanges(), "\n </ul>\n </div><!--\n --><div id='").concat(this.elementId, "_datelist' class='websy-date-picker-custom'>").concat(this.renderDates(), "</div>\n <div class='websy-dp-button-container'>\n <span class=\"dp-footnote\">Click and drag or hold Shift and click to select a range of values</span>\n <button class='").concat(this.options.cancelBtnClasses || '', " websy-btn websy-dp-cancel'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n <button class='").concat(this.options.confirmBtnClasses || '', " websy-btn websy-dp-confirm'>\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"30\" height=\"30\" viewBox=\"0 0 512 512\"><polyline points=\"416 128 192 384 96 288\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>\n </button>\n </div>\n </div> \n </div>\n ");
389
397
  el.innerHTML = html;
390
398
  this.render();
391
399
  } else {
@@ -398,6 +406,12 @@ var WebsyDatePicker = /*#__PURE__*/function () {
398
406
  value: function close(confirm) {
399
407
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
400
408
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
409
+ var el = document.getElementById(this.elementId);
410
+
411
+ if (el) {
412
+ el.style.zIndex = '';
413
+ }
414
+
401
415
  maskEl.classList.remove('active');
402
416
  contentEl.classList.remove('active');
403
417
 
@@ -452,13 +466,14 @@ var WebsyDatePicker = /*#__PURE__*/function () {
452
466
  this.close(true);
453
467
  } else if (event.target.classList.contains('websy-dp-cancel')) {
454
468
  this.close();
469
+ } else if (event.target.classList.contains('clear-selection')) {
470
+ this.selectRange(0);
471
+ this.updateRange(0);
455
472
  }
456
473
  }
457
474
  }, {
458
475
  key: "handleKeyDown",
459
476
  value: function handleKeyDown(event) {
460
- console.log('key down', event);
461
-
462
477
  if (event.key === 'Shift') {
463
478
  this.dragging = true;
464
479
  this.shiftPressed = true;
@@ -537,14 +552,13 @@ var WebsyDatePicker = /*#__PURE__*/function () {
537
552
  }
538
553
 
539
554
  if (this.customRangeSelected === true) {
555
+ console.log('if date selection', this.currentselection);
540
556
  var diff;
541
557
 
542
558
  if (this.options.mode === 'date') {
543
- diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay);
544
-
545
- if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
546
- diff += 1;
547
- }
559
+ diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay); // if (this.selectedRangeDates[0].getMonth() !== this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth()) {
560
+ // diff += 1
561
+ // }
548
562
  } else if (this.options.mode === 'year') {
549
563
  diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0];
550
564
 
@@ -610,6 +624,12 @@ var WebsyDatePicker = /*#__PURE__*/function () {
610
624
  var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
611
625
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
612
626
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
627
+ var el = document.getElementById(this.elementId);
628
+
629
+ if (el) {
630
+ el.style.zIndex = 999;
631
+ }
632
+
613
633
  maskEl.classList.add('active');
614
634
  contentEl.classList.add('active');
615
635
  this.priorSelectedDates = _toConsumableArray(this.selectedRangeDates);
@@ -873,6 +893,16 @@ var WebsyDatePicker = /*#__PURE__*/function () {
873
893
  this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
874
894
  this.currentselection = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
875
895
  this.selectedRange = +index;
896
+ var el = document.getElementById("".concat(this.elementId, "_header"));
897
+
898
+ if (el) {
899
+ if (this.selectedRange === 0) {
900
+ el.classList.remove('range-selected');
901
+ } else {
902
+ el.classList.add('range-selected');
903
+ }
904
+ }
905
+
876
906
  this.highlightRange();
877
907
  this.close(true);
878
908
  }
@@ -1060,6 +1090,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
1060
1090
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1061
1091
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1062
1092
  var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
1093
+ var el = document.getElementById(this.elementId);
1094
+
1095
+ if (el) {
1096
+ el.style.zIndex = '';
1097
+ }
1098
+
1063
1099
  scrollEl.scrollTop = 0;
1064
1100
  maskEl.classList.remove('active');
1065
1101
  contentEl.classList.remove('active');
@@ -1191,6 +1227,12 @@ var WebsyDropdown = /*#__PURE__*/function () {
1191
1227
  var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1192
1228
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1193
1229
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1230
+ var el = document.getElementById(this.elementId);
1231
+
1232
+ if (el) {
1233
+ el.style.zIndex = 999;
1234
+ }
1235
+
1194
1236
  maskEl.classList.add('active');
1195
1237
  contentEl.classList.add('active');
1196
1238
 
@@ -1421,8 +1463,10 @@ var WebsyForm = /*#__PURE__*/function () {
1421
1463
  text: 'Save',
1422
1464
  classes: ''
1423
1465
  },
1466
+ useRecaptcha: false,
1424
1467
  clearAfterSave: false,
1425
1468
  fields: [],
1469
+ mode: 'add',
1426
1470
  onSuccess: function onSuccess(data) {},
1427
1471
  onError: function onError(err) {
1428
1472
  console.log('Error submitting form data:', err);
@@ -1470,19 +1514,27 @@ var WebsyForm = /*#__PURE__*/function () {
1470
1514
 
1471
1515
  return new Promise(function (resolve, reject) {
1472
1516
  if (_this9.options.useRecaptcha === true) {
1473
- if (_this9.recaptchaValue) {
1474
- _this9.apiService.add('/google/checkrecaptcha', JSON.stringify({
1475
- grecaptcharesponse: _this9.recaptchaValue
1476
- })).then(function (response) {
1477
- if (response.success && response.success === true) {
1478
- resolve(true);
1479
- } else {
1480
- reject(false);
1481
- }
1517
+ // if (this.recaptchaValue) {
1518
+ grecaptcha.ready(function () {
1519
+ grecaptcha.execute(ENVIRONMENT.RECAPTCHA_KEY, {
1520
+ action: 'submit'
1521
+ }).then(function (token) {
1522
+ _this9.apiService.add('google/checkrecaptcha', {
1523
+ grecaptcharesponse: token
1524
+ }).then(function (response) {
1525
+ if (response.success && response.success === true) {
1526
+ resolve(true);
1527
+ } else {
1528
+ reject(false);
1529
+ }
1530
+ });
1531
+ }, function (err) {
1532
+ reject(err);
1482
1533
  });
1483
- } else {
1484
- reject(false);
1485
- }
1534
+ }); // }
1535
+ // else {
1536
+ // reject(false)
1537
+ // }
1486
1538
  } else {
1487
1539
  resolve(true);
1488
1540
  }
@@ -1564,15 +1616,15 @@ var WebsyForm = /*#__PURE__*/function () {
1564
1616
  var componentsToProcess = [];
1565
1617
 
1566
1618
  if (el) {
1567
- var html = "\n <form id=\"".concat(this.elementId, "Form\" class=\"").concat(this.options.classes || '', "\">\n ");
1619
+ var html = "\n <form id=\"".concat(this.elementId, "Form\" class=\"websy-form ").concat(this.options.classes || '', "\">\n ");
1568
1620
  this.options.fields.forEach(function (f, i) {
1569
1621
  if (f.component) {
1570
1622
  componentsToProcess.push(f);
1571
1623
  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(_this11.elementId, "_input_").concat(f.field, "_component' class='form-component'></div>\n </div><!--\n ");
1572
1624
  } else if (f.type === 'longtext') {
1573
- 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(_this11.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 ");
1625
+ 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(_this11.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n placeholder=\"").concat(f.placeholder || '', "\"\n name=\"").concat(f.field, "\" \n ").concat((f.attributes || []).join(' '), "\n class=\"websy-input websy-textarea\"\n ></textarea>\n </div><!--\n ");
1574
1626
  } else {
1575
- 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(_this11.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 valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
1627
+ 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(_this11.elementId, "_input_").concat(f.field, "\"\n ").concat(f.required === true ? 'required' : '', " \n type=\"").concat(f.type || 'text', "\" \n class=\"websy-input\" \n ").concat((f.attributes || []).join(' '), "\n name=\"").concat(f.field, "\" \n placeholder=\"").concat(f.placeholder || '', "\"\n value=\"").concat(f.value || '', "\"\n valueAsDate=\"").concat(f.type === 'date' ? f.value : '', "\"\n oninvalidx=\"this.setCustomValidity('").concat(f.invalidMessage || 'Please fill in this field.', "')\"\n />\n </div><!--\n ");
1576
1628
  }
1577
1629
  });
1578
1630
  html += "\n --><button class=\"websy-btn submit ".concat(this.options.submit.classes || '', "\">").concat(this.options.submit.text || 'Save', "</button>").concat(this.options.cancel ? '<!--' : '', "\n ");
@@ -1589,8 +1641,7 @@ var WebsyForm = /*#__PURE__*/function () {
1589
1641
 
1590
1642
  el.innerHTML = html;
1591
1643
  this.processComponents(componentsToProcess, function () {
1592
- if (_this11.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {
1593
- _this11.recaptchaReady();
1644
+ if (_this11.options.useRecaptcha === true && typeof grecaptcha !== 'undefined') {// this.recaptchaReady()
1594
1645
  }
1595
1646
  });
1596
1647
  }
@@ -1613,7 +1664,17 @@ var WebsyForm = /*#__PURE__*/function () {
1613
1664
  });
1614
1665
 
1615
1666
  if (_this12.options.url) {
1616
- _this12.apiService.add(_this12.options.url, data).then(function (result) {
1667
+ var _this12$apiService;
1668
+
1669
+ var params = [_this12.options.url];
1670
+
1671
+ if (_this12.options.mode === 'update') {
1672
+ params.push(_this12.options.id);
1673
+ }
1674
+
1675
+ params.push(data);
1676
+
1677
+ (_this12$apiService = _this12.apiService)[_this12.options.mode].apply(_this12$apiService, params).then(function (result) {
1617
1678
  if (_this12.options.clearAfterSave === true) {
1618
1679
  // this.render()
1619
1680
  formEl.reset();
@@ -1883,7 +1944,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
1883
1944
  items[i].classes = items[i].classes.join(' ');
1884
1945
  }
1885
1946
 
1886
- 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 || '', " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(blockId, "' \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 ");
1947
+ html += "\n\t\t\t<li class='websy-".concat(this.options.orientation, "-list-item ").concat(items[i].alwaysOpen === true ? 'always-open' : '', "'>\n\t\t\t\t<div class='websy-menu-header ").concat(items[i].classes || '', " ").concat(selected, " ").concat(active, "' \n\t\t\t\t\t\t id='").concat(blockId, "' \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 ");
1887
1948
 
1888
1949
  if (this.options.orientation === 'horizontal') {
1889
1950
  html += items[i].text;
@@ -2225,7 +2286,9 @@ var WebsyPopupDialog = /*#__PURE__*/function () {
2225
2286
  _classCallCheck(this, WebsyPopupDialog);
2226
2287
 
2227
2288
  this.DEFAULTS = {
2228
- buttons: []
2289
+ buttons: [],
2290
+ classes: [],
2291
+ style: ''
2229
2292
  };
2230
2293
  this.options = _extends({}, this.DEFAULTS, options);
2231
2294
 
@@ -2289,7 +2352,7 @@ var WebsyPopupDialog = /*#__PURE__*/function () {
2289
2352
  html += "<div class='websy-mask'></div>";
2290
2353
  }
2291
2354
 
2292
- html += "\n\t\t\t<div class='websy-popup-dialog-container'>\n\t\t\t\t<div class='websy-popup-dialog'>\n\t\t";
2355
+ html += "\n\t\t\t<div class='websy-popup-dialog-container'>\n\t\t\t\t<div class='websy-popup-dialog ".concat(this.options.classes.join(' '), "' style='").concat(this.options.style, "'>\n\t\t");
2293
2356
 
2294
2357
  if (this.options.title) {
2295
2358
  html += "<h1>".concat(this.options.title, "</h1>");
@@ -2687,7 +2750,6 @@ var WebsyRouter = /*#__PURE__*/function () {
2687
2750
  var els = document.querySelectorAll(".websy-view[data-group=\"".concat(group, "\"]"));
2688
2751
 
2689
2752
  if (els) {
2690
- console.log('els', els);
2691
2753
  this.getClosestParent(els[0], function (parent) {
2692
2754
  _this21.groups[group] = {
2693
2755
  activeView: '',
@@ -3184,8 +3246,10 @@ var WebsyRouter = /*#__PURE__*/function () {
3184
3246
  var historyUrl = inputPath;
3185
3247
 
3186
3248
  if (this.options.urlPrefix) {
3187
- historyUrl = "/".concat(this.options.urlPrefix, "/").concat(historyUrl);
3188
- inputPath = "/".concat(this.options.urlPrefix, "/").concat(inputPath);
3249
+ historyUrl = historyUrl === '/' ? '' : "/".concat(historyUrl);
3250
+ inputPath = inputPath === '/' ? '' : "/".concat(inputPath);
3251
+ historyUrl = "/".concat(this.options.urlPrefix).concat(historyUrl).replace(/\/\//g, '/');
3252
+ inputPath = "/".concat(this.options.urlPrefix).concat(inputPath).replace(/\/\//g, '/');
3189
3253
  }
3190
3254
 
3191
3255
  if (this.currentParams && this.currentParams.path) {
@@ -3609,6 +3673,25 @@ var WebsyUtils = {
3609
3673
 
3610
3674
  return red * 0.299 + green * 0.587 + blue * 0.114 > 186 ? darkColor : lightColor;
3611
3675
  },
3676
+ measureText: function measureText(text) {
3677
+ var rotation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3678
+ var fontSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '12px';
3679
+
3680
+ if (!isNaN(fontSize)) {
3681
+ fontSize = "".concat(fontSize, "px");
3682
+ }
3683
+
3684
+ var html = "<div style='display: inline-block; width: auto; font-size: ".concat(fontSize, "'>").concat(text, "</div>");
3685
+ var el = document.createElement('div');
3686
+ el.style.position = 'absolute';
3687
+ el.style.visibility = 'hidden';
3688
+ el.style.transform = "rotate(".concat(rotation, "deg)");
3689
+ el.innerHTML = html;
3690
+ document.body.appendChild(el);
3691
+ var w = el.getBoundingClientRect();
3692
+ el.remove();
3693
+ return w;
3694
+ },
3612
3695
  parseUrlParams: function parseUrlParams() {
3613
3696
  var queryString = window.location.search.replace('?', '');
3614
3697
  var params = {};
@@ -3855,7 +3938,7 @@ var WebsyTable = /*#__PURE__*/function () {
3855
3938
  if (_this26.options.columns[i].showAsLink === true && c.value.trim() !== '') {
3856
3939
  return "\n <td \n data-row-index='".concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this26.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this26.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this26.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
3857
3940
  } else if ((_this26.options.columns[i].showAsNavigatorLink === true || _this26.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
3858
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='trigger-item ").concat(_this26.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this26.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this26.options.columns[i].linkText || c.value, "</td>\n ");
3941
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this26.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this26.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this26.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this26.options.columns[i].linkText || c.value, "</td>\n ");
3859
3942
  } else {
3860
3943
  var info = c.value;
3861
3944
 
@@ -3919,21 +4002,34 @@ var WebsyTable = /*#__PURE__*/function () {
3919
4002
  }, function () {
3920
4003
  event.target.classList.remove('active');
3921
4004
  });
3922
- } else if (event.target.classList.contains('clickable')) {
3923
- var _colIndex = +event.target.getAttribute('data-col-index');
4005
+ } // else if (event.target.classList.contains('clickable')) {
4006
+ // const colIndex = +event.target.getAttribute('data-col-index')
4007
+ // const rowIndex = +event.target.getAttribute('data-row-index')
4008
+ // if (this.options.onClick) {
4009
+ // this.options.onClick(event, this.data[rowIndex][colIndex], this.data[rowIndex], this.options.columns[colIndex])
4010
+ // }
4011
+ // }
4012
+ else if (event.target.classList.contains('websy-page-num')) {
4013
+ var pageNum = +event.target.getAttribute('data-page');
3924
4014
 
3925
- var rowIndex = +event.target.getAttribute('data-row-index');
4015
+ if (this.options.onSetPage) {
4016
+ this.options.onSetPage(pageNum);
4017
+ }
4018
+ } else {
4019
+ var _colIndex = +event.target.getAttribute('data-col-index');
3926
4020
 
3927
- if (this.options.onClick) {
3928
- this.options.onClick(event, this.data[rowIndex][_colIndex], this.data[rowIndex], this.options.columns[_colIndex]);
3929
- }
3930
- } else if (event.target.classList.contains('websy-page-num')) {
3931
- var pageNum = +event.target.getAttribute('data-page');
4021
+ var rowIndex = +event.target.getAttribute('data-row-index');
3932
4022
 
3933
- if (this.options.onSetPage) {
3934
- this.options.onSetPage(pageNum);
4023
+ if (this.options.onClick) {
4024
+ this.options.onClick(event, {
4025
+ cell: this.data[rowIndex][_colIndex],
4026
+ row: this.data[rowIndex],
4027
+ column: this.options.columns[_colIndex],
4028
+ colIndex: _colIndex,
4029
+ rowIndex: rowIndex
4030
+ });
4031
+ }
3935
4032
  }
3936
- }
3937
4033
  }
3938
4034
  }, {
3939
4035
  key: "handleMouseMove",
@@ -4235,7 +4331,7 @@ var WebsyTable2 = /*#__PURE__*/function () {
4235
4331
  if (_this29.options.columns[i].showAsLink === true && c.value.trim() !== '') {
4236
4332
  return "\n <td \n data-row-index='".concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >\n <a href='").concat(c.value, "' target='").concat(_this29.options.columns[i].openInNewTab === true ? '_blank' : '_self', "'>").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</a>\n </td>\n ");
4237
4333
  } else if ((_this29.options.columns[i].showAsNavigatorLink === true || _this29.options.columns[i].showAsRouterLink === true) && c.value.trim() !== '') {
4238
- return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='trigger-item ").concat(_this29.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</td>\n ");
4334
+ return "\n <td \n data-view='".concat(c.value, "' \n data-row-index='").concat(_this29.rowCount + rowIndex, "' \n data-col-index='").concat(i, "' \n class='websy-trigger trigger-item ").concat(_this29.options.columns[i].clickable === true ? 'clickable' : '', " ").concat(_this29.options.columns[i].classes || '', "' \n style='").concat(style, "'\n colspan='").concat(c.colspan || 1, "'\n rowspan='").concat(c.rowspan || 1, "'\n >").concat(c.displayText || _this29.options.columns[i].linkText || c.value, "</td>\n ");
4239
4335
  } else {
4240
4336
  var info = c.value;
4241
4337
 
@@ -4333,6 +4429,18 @@ var WebsyTable2 = /*#__PURE__*/function () {
4333
4429
  if (this.options.onSetPage) {
4334
4430
  this.options.onSetPage(pageNum);
4335
4431
  }
4432
+ } else if (event.target.classList.contains('websy-h-scroll-container')) {
4433
+ console.log('scroll handle clicked', event);
4434
+ var clickX = event.clientX;
4435
+ var elX = event.target.getBoundingClientRect().left;
4436
+ var handleEl = document.getElementById("".concat(this.elementId, "_hScrollHandle"));
4437
+ var startPoint = clickX - elX - handleEl.clientWidth / 2;
4438
+ startPoint = Math.max(0, Math.min(startPoint, event.target.clientWidth - handleEl.clientWidth));
4439
+ handleEl.style.left = "".concat(startPoint, "px");
4440
+
4441
+ if (this.options.onScrollX) {
4442
+ this.options.onScrollX(startPoint);
4443
+ }
4336
4444
  }
4337
4445
  }
4338
4446
  }, {
@@ -4512,7 +4620,17 @@ var WebsyTable2 = /*#__PURE__*/function () {
4512
4620
 
4513
4621
  var headHTML = '<tr>' + this.options.columns.map(function (c, i) {
4514
4622
  if (c.show !== false) {
4515
- 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 ? _this30.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
4623
+ var style = '';
4624
+
4625
+ if (c.style) {
4626
+ style += c.style;
4627
+ }
4628
+
4629
+ if (c.width) {
4630
+ style += "width: ".concat(c.width || 'auto', "; ");
4631
+ }
4632
+
4633
+ return "\n <th style=\"".concat(style, "\">\n <div class =\"tableHeader\">\n <div class=\"leftSection\">\n <div\n class=\"tableHeaderField ").concat(['asc', 'desc'].indexOf(c.sort) !== -1 ? 'sortable-column' : '', "\"\n data-index=\"").concat(i, "\" \n data-sort=\"").concat(c.sort, "\" \n >\n ").concat(c.name, "\n </div>\n </div>\n <div class=\"").concat(c.activeSort ? c.sort + ' sortOrder' : '', "\"></div>\n ").concat(c.searchable === true ? _this30.buildSearchIcon(i) : '', "\n </div>\n </th>\n ");
4516
4634
  }
4517
4635
  }).join('') + '</tr>';
4518
4636
  var headEl = document.getElementById("".concat(this.elementId, "_head"));
@@ -4639,13 +4757,14 @@ var WebsyTable2 = /*#__PURE__*/function () {
4639
4757
  tableEl.style.width = 'auto';
4640
4758
  var bodyEl = document.getElementById("".concat(this.elementId, "_body"));
4641
4759
  bodyEl.innerHTML = '<tr>' + values.map(function (c) {
4642
- return "\n <td \n style='height: ".concat(_this31.options.cellSize, "px; line-height: ").concat(_this31.options.cellSize, "px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
4760
+ return "\n <td \n style='height: ".concat(_this31.options.cellSize, "px; line-height: ").concat(_this31.options.cellSize, "px; padding: 10px 5px;'\n >").concat(c.value || '&nbsp;', "</td>\n ");
4643
4761
  }).join('') + '</tr>'; // get height of the first data cell
4644
4762
 
4645
4763
  var cells = bodyEl.querySelectorAll("tr:first-of-type td");
4646
4764
  var tableContainerEl = document.getElementById("".concat(this.elementId, "_tableContainer"));
4647
4765
  var cellHeight = cells[0].offsetHeight || cells[0].clientHeight;
4648
4766
  var cellWidths = [];
4767
+ var accWidth = 0;
4649
4768
  var nonScrollableWidth = 0;
4650
4769
 
4651
4770
  for (var i = 0; i < cells.length; i++) {
@@ -4654,6 +4773,14 @@ var WebsyTable2 = /*#__PURE__*/function () {
4654
4773
  }
4655
4774
 
4656
4775
  cellWidths.push(values[i].width || cells[i].offsetWidth || cells[i].clientWidth);
4776
+ accWidth += values[i].width || cells[i].offsetWidth || cells[i].clientWidth;
4777
+ } // if the table doesn't fill the available space we adjust the space so that the columns grow
4778
+
4779
+
4780
+ if (accWidth < (tableContainerEl.offsetWidth || tableContainerEl.clientWidth) - nonScrollableWidth) {
4781
+ for (var _i7 = this.options.leftColumns; _i7 < cellWidths.length; _i7++) {
4782
+ cellWidths[_i7] = ((tableContainerEl.offsetWidth || tableContainerEl.clientWidth) - nonScrollableWidth) / (cellWidths.length - this.options.leftColumns);
4783
+ }
4657
4784
  } // const cellWidth = firstDataCell.offsetWidth || firstDataCell.clientWidth
4658
4785
  // tableEl.style.width = ''
4659
4786
 
@@ -4699,6 +4826,7 @@ var WebsyChart = /*#__PURE__*/function () {
4699
4826
  legendRight: 0,
4700
4827
  legendTop: 0
4701
4828
  },
4829
+ axis: {},
4702
4830
  orientation: 'vertical',
4703
4831
  colors: ['#5e4fa2', '#3288bd', '#66c2a5', '#abdda4', '#e6f598', '#fee08b', '#fdae61', '#f46d43', '#d53e4f', '#9e0142'],
4704
4832
  transitionDuration: 650,
@@ -5072,7 +5200,7 @@ var WebsyChart = /*#__PURE__*/function () {
5072
5200
  value: function render(options) {
5073
5201
  var _this34 = this;
5074
5202
 
5075
- /* global d3 options */
5203
+ /* global d3 options WebsyUtils */
5076
5204
  if (typeof options !== 'undefined') {
5077
5205
  this.options = _extends({}, this.options, options);
5078
5206
  }
@@ -5195,10 +5323,10 @@ var WebsyChart = /*#__PURE__*/function () {
5195
5323
  }
5196
5324
 
5197
5325
  if (this.options.data.bottom && typeof this.options.data.bottom.max !== 'undefined') {
5198
- this.longestBottom = this.options.data.bottom.max.toString().length;
5326
+ this.longestBottom = this.options.data.bottom.max.toString();
5199
5327
 
5200
5328
  if (this.options.data.bottom.formatter) {
5201
- this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString().length;
5329
+ this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
5202
5330
  }
5203
5331
  }
5204
5332
 
@@ -5220,10 +5348,10 @@ var WebsyChart = /*#__PURE__*/function () {
5220
5348
  }
5221
5349
 
5222
5350
  if (this.options.data.left && typeof this.options.data.left.max !== 'undefined') {
5223
- this.longestLeft = this.options.data.left.max.toString().length;
5351
+ this.longestLeft = this.options.data.left.max.toString();
5224
5352
 
5225
5353
  if (this.options.data.left.formatter) {
5226
- this.longestLeft = this.options.data.left.formatter(this.options.data.left.max).toString().length;
5354
+ this.longestLeft = this.options.data.left.formatter(this.options.data.left.max).toString();
5227
5355
  }
5228
5356
  }
5229
5357
 
@@ -5233,17 +5361,23 @@ var WebsyChart = /*#__PURE__*/function () {
5233
5361
  }
5234
5362
 
5235
5363
  if (this.options.data.right && typeof this.options.data.right.max !== 'undefined') {
5236
- this.longestRight = this.options.data.right.max.toString().length;
5364
+ this.longestRight = this.options.data.right.max.toString();
5237
5365
 
5238
5366
  if (this.options.data.right.formatter) {
5239
- this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString().length;
5367
+ this.longestRight = this.options.data.right.formatter(this.options.data.right.max).toString();
5240
5368
  }
5241
5369
  } // establish the space needed for the various axes
5370
+ // this.options.margin.axisLeft = this.longestLeft * ((this.options.data.left && this.options.data.left.fontSize) || this.options.fontSize) * 0.7
5371
+ // this.options.margin.axisRight = this.longestRight * ((this.options.data.right && this.options.data.right.fontSize) || this.options.fontSize) * 0.7
5372
+ // this.options.margin.axisBottom = ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize) + 10
5242
5373
 
5243
5374
 
5244
- this.options.margin.axisLeft = this.longestLeft * (this.options.data.left && this.options.data.left.fontSize || this.options.fontSize) * 0.7;
5245
- this.options.margin.axisRight = this.longestRight * (this.options.data.right && this.options.data.right.fontSize || this.options.fontSize) * 0.7;
5246
- this.options.margin.axisBottom = (this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize) + 10;
5375
+ var longestLeftBounds = WebsyUtils.measureText(this.longestLeft, 0, this.options.data.left && this.options.data.left.fontSize || this.options.fontSize);
5376
+ var longestRightBounds = WebsyUtils.measureText(this.longestRight, 0, this.options.data.right && this.options.data.right.fontSize || this.options.fontSize);
5377
+ var longestBottomBounds = WebsyUtils.measureText(this.longestBottom, this.options.data.bottom && this.options.data.bottom.rotate || 0, this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize);
5378
+ this.options.margin.axisLeft = longestLeftBounds.width;
5379
+ this.options.margin.axisRight = longestRightBounds.width;
5380
+ this.options.margin.axisBottom = longestBottomBounds.height + 10;
5247
5381
  this.options.margin.axisTop = 0; // adjust axis margins based on title options
5248
5382
 
5249
5383
  if (this.options.data.left && this.options.data.left.showTitle === true) {
@@ -5262,10 +5396,18 @@ var WebsyChart = /*#__PURE__*/function () {
5262
5396
  }
5263
5397
  }
5264
5398
 
5265
- if (this.options.data.bottom.rotate) {
5266
- // this.options.margin.bottom = this.longestBottom * ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)
5267
- this.options.margin.axisBottom = this.longestBottom * (this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize) * 0.4; // this.options.margin.bottom = this.options.margin.bottom * (1 + this.options.data.bottom.rotate / 100)
5268
- } // hide the margin if necessary
5399
+ if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 && this.options.axis.hideBottom !== true) {
5400
+ this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2);
5401
+ } else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) < 0 && this.options.axis.hideBottom !== true) {
5402
+ this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width);
5403
+ } else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) > 0 && this.options.axis.hideBottom !== true) {
5404
+ this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width);
5405
+ } // if (this.options.data.bottom.rotate) {
5406
+ // // this.options.margin.bottom = this.longestBottom * ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize)
5407
+ // this.options.margin.axisBottom = this.longestBottom * ((this.options.data.bottom && this.options.data.bottom.fontSize) || this.options.fontSize) * 0.4
5408
+ // // this.options.margin.bottom = this.options.margin.bottom * (1 + this.options.data.bottom.rotate / 100)
5409
+ // }
5410
+ // hide the margin if necessary
5269
5411
 
5270
5412
 
5271
5413
  if (this.options.axis) {
@@ -5372,9 +5514,8 @@ var WebsyChart = /*#__PURE__*/function () {
5372
5514
 
5373
5515
  this.options.calculatedTimeFormatPattern = timeFormatPattern;
5374
5516
  var bAxisFunc = d3.axisBottom(this.bottomAxis) // .ticks(this.options.data.bottom.ticks || Math.min(this.options.data.bottom.data.length, 5))
5375
- .ticks(tickDefinition);
5376
- console.log('tickDefinition', tickDefinition);
5377
- console.log(bAxisFunc);
5517
+ .ticks(tickDefinition); // console.log('tickDefinition', tickDefinition)
5518
+ // console.log(bAxisFunc)
5378
5519
 
5379
5520
  if (this.options.data.bottom.formatter) {
5380
5521
  bAxisFunc.tickFormat(function (d) {
@@ -5382,11 +5523,10 @@ var WebsyChart = /*#__PURE__*/function () {
5382
5523
  });
5383
5524
  }
5384
5525
 
5385
- this.bottomAxisLayer.call(bAxisFunc);
5386
- console.log(this.bottomAxisLayer.ticks);
5526
+ this.bottomAxisLayer.call(bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
5387
5527
 
5388
5528
  if (this.options.data.bottom.rotate) {
5389
- this.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(this.options.data.bottom.rotate, ")")).style('text-anchor', 'end');
5529
+ this.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(this.options.data.bottom && this.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize, "px"));
5390
5530
  }
5391
5531
  } // Configure the left axis
5392
5532