@websy/websy-designs 1.3.3 → 1.3.5

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.
@@ -2719,7 +2719,7 @@ var WebsyLogin = /*#__PURE__*/function () {
2719
2719
 
2720
2720
  return WebsyLogin;
2721
2721
  }();
2722
- /* global */
2722
+ /* global WebsyDesigns */
2723
2723
 
2724
2724
 
2725
2725
  var WebsyNavigationMenu = /*#__PURE__*/function () {
@@ -2731,7 +2731,11 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2731
2731
  orientation: 'horizontal',
2732
2732
  parentMap: {},
2733
2733
  childIndentation: 10,
2734
- activeSymbol: 'none'
2734
+ activeSymbol: 'none',
2735
+ enableSearch: false,
2736
+ searchProp: 'text',
2737
+ menuIcon: "<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>",
2738
+ searchOptions: {}
2735
2739
  }, options);
2736
2740
 
2737
2741
  if (!elementId) {
@@ -2739,6 +2743,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2739
2743
  return;
2740
2744
  }
2741
2745
 
2746
+ this.maxLevel = 0;
2742
2747
  var el = document.getElementById(elementId);
2743
2748
 
2744
2749
  if (el) {
@@ -2747,7 +2752,6 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2747
2752
  this.flatItems = [];
2748
2753
  this.itemMap = {};
2749
2754
  this.flattenItems(0, this.options.items);
2750
- console.log(this.flatItems);
2751
2755
  el.classList.add("websy-".concat(this.options.orientation, "-list-container"));
2752
2756
  el.classList.add('websy-menu');
2753
2757
 
@@ -2774,25 +2778,28 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2774
2778
  key: "flattenItems",
2775
2779
  value: function flattenItems(index, items) {
2776
2780
  var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2781
+ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2777
2782
 
2778
2783
  if (items[index]) {
2779
2784
  this.lowestLevel = Math.max(level, this.lowestLevel);
2780
2785
  items[index].id = items[index].id || "".concat(this.elementId, "_").concat(this.normaliseString(items[index].text));
2781
- this.itemMap[items[index].id] = items[index];
2782
2786
  items[index].level = level;
2787
+ items[index].hasChildren = items[index].items && items[index].items.length > 0;
2788
+ items[index].path = path !== '' ? "".concat(path, "::").concat(items[index].id) : items[index].id;
2789
+ this.itemMap[items[index].id] = _extends({}, items[index]);
2783
2790
  this.flatItems.push(items[index]);
2784
2791
 
2785
2792
  if (items[index].items) {
2786
- this.flattenItems(0, items[index].items, level + 1);
2793
+ this.flattenItems(0, items[index].items, level + 1, items[index].path);
2787
2794
  }
2788
2795
 
2789
- this.flattenItems(++index, items, level);
2796
+ this.flattenItems(++index, items, level, path);
2790
2797
  }
2791
2798
  }
2792
2799
  }, {
2793
2800
  key: "handleClick",
2794
2801
  value: function handleClick(event) {
2795
- if (event.target.classList.contains('websy-menu-icon') || event.target.nodeName === 'svg' || event.target.nodeName === 'rect') {
2802
+ if (event.target.classList.contains('websy-menu-icon')) {
2796
2803
  this.toggleMobileMenu();
2797
2804
  }
2798
2805
 
@@ -2803,7 +2810,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2803
2810
  this.toggleMobileMenu('remove');
2804
2811
  }
2805
2812
 
2806
- if (item.items) {
2813
+ if (item.hasChildren === true) {
2807
2814
  event.target.classList.toggle('menu-open');
2808
2815
  this.toggleMenu(item.id);
2809
2816
  }
@@ -2813,6 +2820,60 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2813
2820
  this.toggleMobileMenu();
2814
2821
  }
2815
2822
  }
2823
+ }, {
2824
+ key: "handleSearch",
2825
+ value: function handleSearch(searchText) {
2826
+ var _this18 = this;
2827
+
2828
+ var el = document.getElementById(this.elementId);
2829
+ var lowestItems = this.flatItems.filter(function (d) {
2830
+ return d.level === _this18.maxLevel;
2831
+ });
2832
+ var visibleItems = lowestItems;
2833
+ var defaultMethod = 'remove';
2834
+
2835
+ if (searchText.length > 1) {
2836
+ defaultMethod = 'add';
2837
+ visibleItems = lowestItems.filter(function (d) {
2838
+ return d[_this18.options.searchProp].toLowerCase().indexOf(searchText.toLowerCase()) !== -1;
2839
+ });
2840
+ } // hide everything
2841
+
2842
+
2843
+ var textEls = el.querySelectorAll("div.websy-menu-header");
2844
+
2845
+ for (var t = 0; t < textEls.length; t++) {
2846
+ textEls[t].classList[defaultMethod]('websy-hidden');
2847
+ }
2848
+
2849
+ var listEls = el.querySelectorAll("ul.websy-child-list");
2850
+
2851
+ for (var l = 0; l < listEls.length; l++) {
2852
+ listEls[l].classList.add('websy-menu-collapsed');
2853
+ }
2854
+
2855
+ if (searchText.length > 1) {
2856
+ visibleItems.forEach(function (d) {
2857
+ // show the item and open the list
2858
+ var pathParts = d.path.split('::');
2859
+ pathParts.forEach(function (p) {
2860
+ var textEl = document.getElementById(p);
2861
+
2862
+ if (textEl) {
2863
+ textEl.classList.remove('websy-hidden');
2864
+ }
2865
+
2866
+ var listEl = document.getElementById("".concat(p, "_list"));
2867
+
2868
+ if (listEl) {
2869
+ listEl.classList.remove('websy-menu-collapsed');
2870
+ }
2871
+ });
2872
+ });
2873
+ }
2874
+
2875
+ console.log('visibleItems', visibleItems);
2876
+ }
2816
2877
  }, {
2817
2878
  key: "normaliseString",
2818
2879
  value: function normaliseString(text) {
@@ -2827,7 +2888,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2827
2888
  var html = "";
2828
2889
 
2829
2890
  if (this.options.collapsible === true) {
2830
- 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 ");
2891
+ html += "\n <div id='".concat(this.elementId, "_menuIcon' class='websy-menu-icon'>\n ").concat(this.options.menuIcon, "\n </div>\n ");
2831
2892
  }
2832
2893
 
2833
2894
  if (this.options.logo) {
@@ -2838,16 +2899,27 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2838
2899
  html += " \n <div \n class='logo ".concat(this.options.logo.classes || '', "'\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 ");
2839
2900
  }
2840
2901
 
2841
- html += this.renderBlock(this.options.items, 'main', 0);
2902
+ if (this.options.enableSearch === true) {
2903
+ html += "\n <div id='".concat(this.elementId, "_search' class='websy-menu-search'></div>\n ");
2904
+ }
2905
+
2906
+ html += this.renderBlock(this.elementId, this.elementId, this.options.items, 'main', 0);
2842
2907
  html += "</div>";
2843
2908
  el.innerHTML = html;
2909
+
2910
+ if (this.options.enableSearch === true) {
2911
+ this.search = new WebsyDesigns.Search("".concat(this.elementId, "_search"), _extends({}, {
2912
+ onSearch: this.handleSearch.bind(this)
2913
+ }, this.options.searchOptions));
2914
+ }
2844
2915
  }
2845
2916
  }
2846
2917
  }, {
2847
2918
  key: "renderBlock",
2848
- value: function renderBlock(items, block) {
2849
- var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2850
- var html = "\n\t\t <ul class='websy-".concat(this.options.orientation, "-list ").concat(level > 0 ? 'websy-child-list' : '', " ").concat(block !== 'main' ? 'websy-menu-collapsed' : '', "' id='").concat(this.elementId, "_").concat(block, "_list'\n\t ");
2919
+ value: function renderBlock(id, path, items, block) {
2920
+ var level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
2921
+ this.maxLevel = Math.max(this.maxLevel, level);
2922
+ var html = "\n\t\t <ul class='websy-".concat(this.options.orientation, "-list ").concat(level > 0 ? 'websy-child-list' : '', " ").concat(block !== 'main' ? 'websy-menu-collapsed' : '', "' id='").concat(id, "_list' data-path='").concat(path, "'\n\t ");
2851
2923
 
2852
2924
  if (block !== 'main') {
2853
2925
  html += " data-collapsed='".concat(block !== 'main' ? 'true' : 'false', "'");
@@ -2867,7 +2939,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2867
2939
  items[i].classes = items[i].classes.join(' ');
2868
2940
  }
2869
2941
 
2870
- 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].isLink !== true ? 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 ");
2942
+ 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 id='").concat(blockId, "' \n data-id='").concat(currentBlock, "'\n data-path='").concat(items[i].path, "'\n data-menu-id='").concat(this.elementId, "_").concat(currentBlock, "_list'\n data-popout-id='").concat(level > 1 ? block : currentBlock, "'\n data-text='").concat(items[i].isLink !== true ? items[i].text : '', "'\n style='padding-left: ").concat(level * this.options.childIndentation, "px'\n ").concat(items[i].attributes && items[i].attributes.join(' ') || '', "\n >\n ");
2871
2943
 
2872
2944
  if (this.options.orientation === 'horizontal') {
2873
2945
  html += items[i].text;
@@ -2883,8 +2955,9 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2883
2955
 
2884
2956
  html += " \n <span class='".concat(items[i].items && items[i].items.length > 0 ? 'menu-carat' : '', "'></span>\n ");
2885
2957
 
2886
- if (this.options.orientation === 'vertical') {
2887
- html += "\n &nbsp;\n ";
2958
+ if (this.options.orientation === 'vertical') {// html += `
2959
+ // &nbsp;
2960
+ // `
2888
2961
  }
2889
2962
 
2890
2963
  if (items[i].isLink === true && items[i].href) {
@@ -2894,7 +2967,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2894
2967
  html += " \n\t\t\t\t</div>\n\t\t ";
2895
2968
 
2896
2969
  if (items[i].items) {
2897
- html += this.renderBlock(items[i].items, currentBlock, items[i].level + 1);
2970
+ html += this.renderBlock(blockId, items[i].path, items[i].items, currentBlock, items[i].level + 1);
2898
2971
  } // map the item to it's parent
2899
2972
 
2900
2973
 
@@ -2913,7 +2986,8 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2913
2986
  }, {
2914
2987
  key: "toggleMenu",
2915
2988
  value: function toggleMenu(id) {
2916
- var el = document.getElementById("".concat(id, "_list"));
2989
+ var el = document.getElementById("".concat(id, "_list")); // const menuId = el.getAttribute('data-menu-id')
2990
+ // const menuEl = document.getElementById(menuId)
2917
2991
 
2918
2992
  if (el) {
2919
2993
  el.classList.toggle('websy-menu-collapsed');
@@ -2945,7 +3019,7 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2945
3019
 
2946
3020
  var Pager = /*#__PURE__*/function () {
2947
3021
  function Pager(elementId, options) {
2948
- var _this18 = this;
3022
+ var _this19 = this;
2949
3023
 
2950
3024
  _classCallCheck(this, Pager);
2951
3025
 
@@ -2998,8 +3072,8 @@ var Pager = /*#__PURE__*/function () {
2998
3072
  allowClear: false,
2999
3073
  disableSearch: true,
3000
3074
  onItemSelected: function onItemSelected(selectedItem) {
3001
- if (_this18.options.onChangePageSize) {
3002
- _this18.options.onChangePageSize(selectedItem.value);
3075
+ if (_this19.options.onChangePageSize) {
3076
+ _this19.options.onChangePageSize(selectedItem.value);
3003
3077
  }
3004
3078
  }
3005
3079
  });
@@ -3023,13 +3097,13 @@ var Pager = /*#__PURE__*/function () {
3023
3097
  }, {
3024
3098
  key: "render",
3025
3099
  value: function render() {
3026
- var _this19 = this;
3100
+ var _this20 = this;
3027
3101
 
3028
3102
  var el = document.getElementById("".concat(this.elementId, "_pageList"));
3029
3103
 
3030
3104
  if (el) {
3031
3105
  var pages = this.options.pages.map(function (item, index) {
3032
- return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this19.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
3106
+ return "<li data-index=\"".concat(index, "\" class=\"websy-page-num ").concat(_this20.options.activePage === index ? 'active' : '', "\">").concat(index + 1, "</li>");
3033
3107
  });
3034
3108
  var startIndex = 0;
3035
3109
 
@@ -3097,58 +3171,58 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3097
3171
  _createClass(WebsyPDFButton, [{
3098
3172
  key: "handleClick",
3099
3173
  value: function handleClick(event) {
3100
- var _this20 = this;
3174
+ var _this21 = this;
3101
3175
 
3102
3176
  if (event.target.classList.contains('websy-pdf-button')) {
3103
3177
  this.loader.show();
3104
3178
  setTimeout(function () {
3105
- if (_this20.options.targetId) {
3106
- var el = document.getElementById(_this20.options.targetId);
3179
+ if (_this21.options.targetId) {
3180
+ var el = document.getElementById(_this21.options.targetId);
3107
3181
 
3108
3182
  if (el) {
3109
3183
  var pdfData = {
3110
3184
  options: {}
3111
3185
  };
3112
3186
 
3113
- if (_this20.options.pdfOptions) {
3114
- pdfData.options = _extends({}, _this20.options.pdfOptions);
3187
+ if (_this21.options.pdfOptions) {
3188
+ pdfData.options = _extends({}, _this21.options.pdfOptions);
3115
3189
  }
3116
3190
 
3117
- if (_this20.options.header) {
3118
- if (_this20.options.header.elementId) {
3119
- var headerEl = document.getElementById(_this20.options.header.elementId);
3191
+ if (_this21.options.header) {
3192
+ if (_this21.options.header.elementId) {
3193
+ var headerEl = document.getElementById(_this21.options.header.elementId);
3120
3194
 
3121
3195
  if (headerEl) {
3122
3196
  pdfData.header = headerEl.outerHTML;
3123
3197
 
3124
- if (_this20.options.header.css) {
3125
- pdfData.options.headerCSS = _this20.options.header.css;
3198
+ if (_this21.options.header.css) {
3199
+ pdfData.options.headerCSS = _this21.options.header.css;
3126
3200
  }
3127
3201
  }
3128
- } else if (_this20.options.header.html) {
3129
- pdfData.header = _this20.options.header.html;
3202
+ } else if (_this21.options.header.html) {
3203
+ pdfData.header = _this21.options.header.html;
3130
3204
 
3131
- if (_this20.options.header.css) {
3132
- pdfData.options.headerCSS = _this20.options.header.css;
3205
+ if (_this21.options.header.css) {
3206
+ pdfData.options.headerCSS = _this21.options.header.css;
3133
3207
  }
3134
3208
  } else {
3135
- pdfData.header = _this20.options.header;
3209
+ pdfData.header = _this21.options.header;
3136
3210
  }
3137
3211
  }
3138
3212
 
3139
- if (_this20.options.footer) {
3140
- if (_this20.options.footer.elementId) {
3141
- var footerEl = document.getElementById(_this20.options.footer.elementId);
3213
+ if (_this21.options.footer) {
3214
+ if (_this21.options.footer.elementId) {
3215
+ var footerEl = document.getElementById(_this21.options.footer.elementId);
3142
3216
 
3143
3217
  if (footerEl) {
3144
3218
  pdfData.footer = footerEl.outerHTML;
3145
3219
 
3146
- if (_this20.options.footer.css) {
3147
- pdfData.options.footerCSS = _this20.options.footer.css;
3220
+ if (_this21.options.footer.css) {
3221
+ pdfData.options.footerCSS = _this21.options.footer.css;
3148
3222
  }
3149
3223
  }
3150
3224
  } else {
3151
- pdfData.footer = _this20.options.footer;
3225
+ pdfData.footer = _this21.options.footer;
3152
3226
  }
3153
3227
  }
3154
3228
 
@@ -3157,31 +3231,31 @@ var WebsyPDFButton = /*#__PURE__*/function () {
3157
3231
  // document.getElementById(`${this.elementId}_pdfFooter`).value = pdfData.footer
3158
3232
  // document.getElementById(`${this.elementId}_form`).submit()
3159
3233
 
3160
- _this20.service.add('', pdfData, {
3234
+ _this21.service.add('', pdfData, {
3161
3235
  responseType: 'blob'
3162
3236
  }).then(function (response) {
3163
- _this20.loader.hide();
3237
+ _this21.loader.hide();
3164
3238
 
3165
3239
  var blob = new Blob([response], {
3166
3240
  type: 'application/pdf'
3167
3241
  });
3168
3242
  var msg = "\n <div class='text-center websy-pdf-download'>\n <div>Your file is ready to download</div>\n <a href='".concat(URL.createObjectURL(blob), "' target='_blank'\n ");
3169
3243
 
3170
- if (_this20.options.directDownload === true) {
3244
+ if (_this21.options.directDownload === true) {
3171
3245
  var fileName;
3172
3246
 
3173
- if (typeof _this20.options.fileName === 'function') {
3174
- fileName = _this20.options.fileName() || 'Export';
3247
+ if (typeof _this21.options.fileName === 'function') {
3248
+ fileName = _this21.options.fileName() || 'Export';
3175
3249
  } else {
3176
- fileName = _this20.options.fileName || 'Export';
3250
+ fileName = _this21.options.fileName || 'Export';
3177
3251
  }
3178
3252
 
3179
3253
  msg += "download='".concat(fileName, ".pdf'");
3180
3254
  }
3181
3255
 
3182
- msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this20.options.buttonText, "</button>\n </a>\n </div>\n ");
3256
+ msg += "\n >\n <button class='websy-btn download-pdf'>".concat(_this21.options.buttonText, "</button>\n </a>\n </div>\n ");
3183
3257
 
3184
- _this20.popup.show({
3258
+ _this21.popup.show({
3185
3259
  message: msg,
3186
3260
  mask: true
3187
3261
  });
@@ -3382,7 +3456,7 @@ var WebsyPubSub = /*#__PURE__*/function () {
3382
3456
 
3383
3457
  var ResponsiveText = /*#__PURE__*/function () {
3384
3458
  function ResponsiveText(elementId, options) {
3385
- var _this21 = this;
3459
+ var _this22 = this;
3386
3460
 
3387
3461
  _classCallCheck(this, ResponsiveText);
3388
3462
 
@@ -3395,7 +3469,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3395
3469
  this.elementId = elementId;
3396
3470
  this.canvas = document.createElement('canvas');
3397
3471
  window.addEventListener('resize', function () {
3398
- return _this21.render();
3472
+ return _this22.render();
3399
3473
  });
3400
3474
  var el = document.getElementById(this.elementId);
3401
3475
 
@@ -3614,7 +3688,7 @@ var ResponsiveText = /*#__PURE__*/function () {
3614
3688
 
3615
3689
  var WebsyResultList = /*#__PURE__*/function () {
3616
3690
  function WebsyResultList(elementId, options) {
3617
- var _this22 = this;
3691
+ var _this23 = this;
3618
3692
 
3619
3693
  _classCallCheck(this, WebsyResultList);
3620
3694
 
@@ -3643,9 +3717,9 @@ var WebsyResultList = /*#__PURE__*/function () {
3643
3717
 
3644
3718
  if (_typeof(options.template) === 'object' && options.template.url) {
3645
3719
  this.templateService.get(options.template.url).then(function (templateString) {
3646
- _this22.options.template = templateString;
3720
+ _this23.options.template = templateString;
3647
3721
 
3648
- _this22.render();
3722
+ _this23.render();
3649
3723
  });
3650
3724
  } else {
3651
3725
  this.render();
@@ -3665,16 +3739,17 @@ var WebsyResultList = /*#__PURE__*/function () {
3665
3739
  }, {
3666
3740
  key: "buildHTML",
3667
3741
  value: function buildHTML(d) {
3668
- var _this23 = this;
3742
+ var _this24 = this;
3669
3743
 
3670
3744
  var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3671
3745
  var inputTemplate = arguments.length > 2 ? arguments[2] : undefined;
3746
+ var locator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
3672
3747
  var html = "";
3673
3748
 
3674
3749
  if (this.options.template) {
3675
3750
  if (d.length > 0) {
3676
3751
  d.forEach(function (row, ix) {
3677
- var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this23.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
3752
+ var template = "".concat(ix > 0 ? '-->' : '').concat(inputTemplate || _this24.options.template).concat(ix < d.length - 1 ? '<!--' : ''); // find conditional elements
3678
3753
 
3679
3754
  var ifMatches = _toConsumableArray(template.matchAll(/<\s*if[^>]*>([\s\S]*?)<\s*\/\s*if>/g));
3680
3755
 
@@ -3779,7 +3854,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3779
3854
  parts.forEach(function (p) {
3780
3855
  items = items[p];
3781
3856
  });
3782
- template = template.replace(m[0], _this23.buildHTML(items, 0, withoutFor));
3857
+ template = template.replace(m[0], _this24.buildHTML(items, 0, withoutFor, [].concat(_toConsumableArray(locator), ["".concat(startIndex + ix, ":").concat(c)])));
3783
3858
  }
3784
3859
  });
3785
3860
 
@@ -3787,11 +3862,11 @@ var WebsyResultList = /*#__PURE__*/function () {
3787
3862
 
3788
3863
  tagMatches.forEach(function (m) {
3789
3864
  if (m[0] && m.index > -1) {
3790
- template = template.replace(m[0], "".concat(m[0], " data-id=").concat(startIndex + ix));
3865
+ template = template.replace(m[0], "".concat(m[0], " data-id=").concat(startIndex + ix, " data-locator='").concat(locator.join(';'), "'"));
3791
3866
  }
3792
3867
  });
3793
3868
 
3794
- var flatRow = _this23.flattenObject(row);
3869
+ var flatRow = _this24.flattenObject(row);
3795
3870
 
3796
3871
  for (var key in flatRow) {
3797
3872
  var rg = new RegExp("{".concat(key, "}"), 'gm');
@@ -3849,8 +3924,6 @@ var WebsyResultList = /*#__PURE__*/function () {
3849
3924
  }, {
3850
3925
  key: "handleClick",
3851
3926
  value: function handleClick(event) {
3852
- var _this24 = this;
3853
-
3854
3927
  if (event.target.classList.contains('clickable')) {
3855
3928
  var l = event.target.getAttribute('data-event');
3856
3929
 
@@ -3858,6 +3931,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3858
3931
  l = l.split('(');
3859
3932
  var params = [];
3860
3933
  var id = event.target.getAttribute('data-id');
3934
+ var locator = event.target.getAttribute('data-locator');
3861
3935
 
3862
3936
  if (l[1]) {
3863
3937
  l[1] = l[1].replace(')', '');
@@ -3865,10 +3939,27 @@ var WebsyResultList = /*#__PURE__*/function () {
3865
3939
  }
3866
3940
 
3867
3941
  l = l[0];
3942
+ var data = this.rows;
3943
+
3944
+ if (locator !== '') {
3945
+ var locatorItems = locator.split(';');
3946
+ locatorItems.forEach(function (loc) {
3947
+ var locatorParts = loc.split(':');
3948
+
3949
+ if (data[locatorParts[0]]) {
3950
+ data = data[locatorParts[0]];
3951
+ var parts = locatorParts[1].split('.');
3952
+ parts.forEach(function (p) {
3953
+ data = data[p];
3954
+ });
3955
+ }
3956
+ });
3957
+ }
3958
+
3868
3959
  params = params.map(function (p) {
3869
3960
  if (typeof p !== 'string' && typeof p !== 'number') {
3870
- if (_this24.rows[+id]) {
3871
- p = _this24.rows[+id][p];
3961
+ if (data[+id]) {
3962
+ p = data[+id][p];
3872
3963
  }
3873
3964
  } else if (typeof p === 'string') {
3874
3965
  p = p.replace(/"/g, '').replace(/'/g, '');
@@ -3882,7 +3973,7 @@ var WebsyResultList = /*#__PURE__*/function () {
3882
3973
 
3883
3974
  event.stopPropagation();
3884
3975
 
3885
- (_this$options$listene = this.options.listeners.click[l]).call.apply(_this$options$listene, [this, event, this.rows[+id]].concat(_toConsumableArray(params)));
3976
+ (_this$options$listene = this.options.listeners.click[l]).call.apply(_this$options$listene, [this, event, data[+id]].concat(_toConsumableArray(params)));
3886
3977
  }
3887
3978
  }
3888
3979
  }
@@ -3951,7 +4042,14 @@ var WebsyRouter = /*#__PURE__*/function () {
3951
4042
  this.previousView = '';
3952
4043
  this.currentView = '';
3953
4044
  this.currentViewMain = '';
3954
- this.currentParams = {};
4045
+ this.currentParams = {
4046
+ path: '',
4047
+ items: {}
4048
+ };
4049
+ this.previousParams = {
4050
+ path: '',
4051
+ items: {}
4052
+ };
3955
4053
  this.controlPressed = false;
3956
4054
  this.usesHTMLSuffix = window.location.pathname.indexOf('.htm') !== -1;
3957
4055
  window.addEventListener('popstate', this.onPopState.bind(this));
@@ -4004,10 +4102,13 @@ var WebsyRouter = /*#__PURE__*/function () {
4004
4102
  }, {
4005
4103
  key: "addUrlParams",
4006
4104
  value: function addUrlParams(params) {
4105
+ var reloadView = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4106
+
4007
4107
  if (typeof params === 'undefined') {
4008
4108
  return;
4009
4109
  }
4010
4110
 
4111
+ this.previousParams = _extends({}, this.currentParams);
4011
4112
  var output = {
4012
4113
  path: '',
4013
4114
  items: {}
@@ -4032,6 +4133,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4032
4133
  history.pushState({
4033
4134
  inputPath: inputPath
4034
4135
  }, inputPath, "".concat(inputPath, "?").concat(path));
4136
+
4137
+ if (reloadView === true) {
4138
+ this.showView(this.currentView, this.currentParams, 'main');
4139
+ }
4035
4140
  }
4036
4141
  }, {
4037
4142
  key: "buildUrlPath",
@@ -4073,6 +4178,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4073
4178
  }, {
4074
4179
  key: "formatParams",
4075
4180
  value: function formatParams(params) {
4181
+ this.previousParams = _extends({}, this.currentParams);
4076
4182
  var output = {
4077
4183
  path: params,
4078
4184
  items: {}
@@ -4338,6 +4444,11 @@ var WebsyRouter = /*#__PURE__*/function () {
4338
4444
  this.showComponents(view);
4339
4445
  this.publish('show', [view, params, group]);
4340
4446
  }
4447
+
4448
+ if (this.previousView === this.currentView && this.previousParams.path !== this.currentParams.path) {
4449
+ this.showComponents(view);
4450
+ this.publish('show', [view, params, group]);
4451
+ }
4341
4452
  }
4342
4453
  }, {
4343
4454
  key: "reloadCurrentView",
@@ -4362,7 +4473,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4362
4473
  var params = {};
4363
4474
  var newPath = inputPath;
4364
4475
 
4365
- if (inputPath === this.options.defaultView && this.usesHTMLSuffix === false) {
4476
+ if (inputPath.split('?')[0] === this.options.defaultView && this.usesHTMLSuffix === false) {
4366
4477
  inputPath = inputPath.replace(this.options.defaultView, '/');
4367
4478
  }
4368
4479
 
@@ -4370,8 +4481,6 @@ var WebsyRouter = /*#__PURE__*/function () {
4370
4481
  if (inputPath.indexOf('?') === -1 && this.queryParams) {
4371
4482
  inputPath += "?".concat(this.queryParams);
4372
4483
  }
4373
- } else {
4374
- this.currentParams = {};
4375
4484
  }
4376
4485
 
4377
4486
  if (this.usesHTMLSuffix === true) {
@@ -4395,7 +4504,11 @@ var WebsyRouter = /*#__PURE__*/function () {
4395
4504
  params = this.formatParams(parts[1]);
4396
4505
  inputPath = parts[0];
4397
4506
  } else if (group === this.options.defaultGroup) {
4398
- this.currentParams = {};
4507
+ this.previousParams = _extends({}, this.currentParams);
4508
+ this.currentParams = {
4509
+ path: '',
4510
+ items: {}
4511
+ };
4399
4512
  }
4400
4513
 
4401
4514
  if (event) {
@@ -4610,7 +4723,7 @@ var WebsySearch = /*#__PURE__*/function () {
4610
4723
  this.elementId = elementId;
4611
4724
  var DEFAULTS = {
4612
4725
  searchIcon: "<svg class='search' width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>",
4613
- clearIcon: "<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>",
4726
+ clearIcon: "<svg 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>",
4614
4727
  placeholder: 'Search',
4615
4728
  searchTimeout: 500,
4616
4729
  minLength: 2
@@ -4621,14 +4734,24 @@ var WebsySearch = /*#__PURE__*/function () {
4621
4734
 
4622
4735
  if (el) {
4623
4736
  // el.addEventListener('click', this.handleClick.bind(this))
4737
+ el.addEventListener('click', this.handleClick.bind(this));
4624
4738
  el.addEventListener('keyup', this.handleKeyUp.bind(this));
4625
- el.innerHTML = "\n <div class='websy-search-input-container'>\n ".concat(this.options.searchIcon, "\n <input id='").concat(this.elementId, "_search' class='websy-search-input' placeholder='").concat(this.options.placeholder || 'Search', "'>\n ").concat(this.options.clearIcon, "\n </div>\n ");
4739
+ el.innerHTML = "\n <div class='websy-search-input-container'>\n ".concat(this.options.searchIcon, "\n <input id='").concat(this.elementId, "_search' class='websy-search-input' placeholder='").concat(this.options.placeholder || 'Search', "'>\n <div class='clear websy-hidden' id='").concat(this.elementId, "_clear'>\n ").concat(this.options.clearIcon, "\n </div>\n </div>\n ");
4626
4740
  } else {
4627
4741
  console.log('No element found with Id', elementId);
4628
4742
  }
4629
4743
  }
4630
4744
 
4631
4745
  _createClass(WebsySearch, [{
4746
+ key: "handleClick",
4747
+ value: function handleClick(event) {
4748
+ if (event.target.classList.contains('clear')) {
4749
+ var inputEl = document.getElementById("".concat(this.elementId, "_search"));
4750
+ inputEl.value = '';
4751
+ this.options.onSearch('');
4752
+ }
4753
+ }
4754
+ }, {
4632
4755
  key: "handleKeyUp",
4633
4756
  value: function handleKeyUp(event) {
4634
4757
  var _this28 = this;
@@ -4638,6 +4761,14 @@ var WebsySearch = /*#__PURE__*/function () {
4638
4761
  clearTimeout(this.searchTimeoutFn);
4639
4762
  }
4640
4763
 
4764
+ var clearEl = document.getElementById("".concat(this.elementId, "_clear"));
4765
+
4766
+ if (event.target.value.length > 0) {
4767
+ clearEl.classList.remove('websy-hidden');
4768
+ } else {
4769
+ clearEl.classList.add('websy-hidden');
4770
+ }
4771
+
4641
4772
  if (event.target.value.length >= this.options.minLength) {
4642
4773
  this.searchTimeoutFn = setTimeout(function () {
4643
4774
  if (_this28.options.onSearch) {