@websy/websy-designs 1.4.4 → 1.4.6

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.
@@ -3956,6 +3956,26 @@ class WebsyRouter {
3956
3956
  this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
3957
3957
  }
3958
3958
  }
3959
+ removeAllUrlParams (reloadView = false, noHistory = true) {
3960
+ // const output = {
3961
+ // path: '',
3962
+ // items: {}
3963
+ // }
3964
+ // this.currentParams = output
3965
+ let inputPath = this.currentView
3966
+ if (this.options.urlPrefix) {
3967
+ inputPath = `/${this.options.urlPrefix}/${inputPath}`
3968
+ }
3969
+ if (reloadView === true) {
3970
+ this.navigate(`${inputPath}`, 'main', null, noHistory)
3971
+ }
3972
+ else {
3973
+ this.currentParams = {
3974
+ path: '',
3975
+ items: {}
3976
+ }
3977
+ }
3978
+ }
3959
3979
  buildUrlPath (params) {
3960
3980
  let path = []
3961
3981
  for (let key in params) {
@@ -3976,6 +3996,9 @@ class WebsyRouter {
3976
3996
  if (!this.groups[g]) {
3977
3997
  this.addGroup(g)
3978
3998
  }
3999
+ if (els[i].classList.contains(this.options.activeClass)) {
4000
+ this.groups[g].activeView = v
4001
+ }
3979
4002
  if (this.groups[g].views.indexOf(v) === -1) {
3980
4003
  this.groups[g].views.push(v)
3981
4004
  }
@@ -4019,9 +4042,9 @@ class WebsyRouter {
4019
4042
  if (this.groups[g].activeView) {
4020
4043
  views.push({view: this.groups[g].activeView, group: g})
4021
4044
  }
4022
- else {
4023
- views.push({view: this.groups[g].views[0], group: g})
4024
- }
4045
+ // else {
4046
+ // views.push({view: this.groups[g].views[0], group: g})
4047
+ // }
4025
4048
  }
4026
4049
  }
4027
4050
  return views
@@ -4194,12 +4217,12 @@ class WebsyRouter {
4194
4217
  <article id='${elementId}_content' class='websy-content-article'></article>
4195
4218
  <div id='${elementId}_loading' class='websy-loading-container'><div class='websy-ripple'><div></div><div></div></div></div>
4196
4219
  `
4197
- if (options.help && options.help !== '') {
4220
+ if (options && options.help && options.help !== '') {
4198
4221
  html += `
4199
4222
  <Help not yet supported>
4200
4223
  `
4201
4224
  }
4202
- if (options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4225
+ if (options && options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4203
4226
  html += `
4204
4227
  <div class="websy-info ${this.options.tooltip.classes.join(' ') || ''}" data-info="${this.options.tooltip.value}">
4205
4228
  <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><title>ionicons-v5-e</title><path d="M256,56C145.72,56,56,145.72,56,256s89.72,200,200,200,200-89.72,200-200S366.28,56,256,56Zm0,82a26,26,0,1,1-26,26A26,26,0,0,1,256,138Zm48,226H216a16,16,0,0,1,0-32h28V244H228a16,16,0,0,1,0-32h32a16,16,0,0,1,16,16V332h28a16,16,0,0,1,0,32Z"/></svg>
@@ -4305,7 +4328,7 @@ class WebsyRouter {
4305
4328
  this.addGroup(group)
4306
4329
  }
4307
4330
  if (toggle === true && this.groups[group].activeView !== '') {
4308
- newPath = ''
4331
+ newPath = inputPath === this.groups[group].activeView ? '' : inputPath
4309
4332
  }
4310
4333
  this.previousView = this.currentView
4311
4334
  this.previousPath = this.currentPath
@@ -4460,6 +4483,7 @@ class WebsySearch {
4460
4483
  const DEFAULTS = {
4461
4484
  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>`,
4462
4485
  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>`,
4486
+ clearAlwaysOn: false,
4463
4487
  placeholder: 'Search',
4464
4488
  searchTimeout: 500,
4465
4489
  minLength: 2
@@ -4476,7 +4500,7 @@ class WebsySearch {
4476
4500
  <div class='websy-search-input-container'>
4477
4501
  ${this.options.searchIcon}
4478
4502
  <input id='${this.elementId}_search' class='websy-search-input' placeholder='${this.options.placeholder || 'Search'}'>
4479
- <div class='clear websy-hidden' id='${this.elementId}_clear'>
4503
+ <div class='clear ${this.options.clearAlwaysOn === true ? '' : 'websy-hidden'}' id='${this.elementId}_clear'>
4480
4504
  ${this.options.clearIcon}
4481
4505
  </div>
4482
4506
  </div>
@@ -4512,12 +4536,14 @@ class WebsySearch {
4512
4536
  clearTimeout(this.searchTimeoutFn)
4513
4537
  }
4514
4538
  const clearEl = document.getElementById(`${this.elementId}_clear`)
4515
- if (event.target.value.length > 0) {
4516
- clearEl.classList.remove('websy-hidden')
4517
- }
4518
- else {
4519
- clearEl.classList.add('websy-hidden')
4520
- }
4539
+ if (this.options.clearAlwaysOn === false) {
4540
+ if (event.target.value.length > 0) {
4541
+ clearEl.classList.remove('websy-hidden')
4542
+ }
4543
+ else {
4544
+ clearEl.classList.add('websy-hidden')
4545
+ }
4546
+ }
4521
4547
  if (event.target.value.length >= this.options.minLength) {
4522
4548
  this.searchTimeoutFn = setTimeout(() => {
4523
4549
  if (this.options.onSearch) {
@@ -4527,8 +4553,8 @@ class WebsySearch {
4527
4553
  }
4528
4554
  else {
4529
4555
  if (this.options.onSearch && (event.key === 'Delete' || event.key === 'Backspace')) {
4530
- if (this.options.onClear) {
4531
- this.options.onClear()
4556
+ if (this.options.onSearch) {
4557
+ this.options.onSearch('')
4532
4558
  }
4533
4559
  }
4534
4560
  }
@@ -4296,6 +4296,31 @@ var WebsyRouter = /*#__PURE__*/function () {
4296
4296
  this.navigate("".concat(inputPath, "?").concat(path), 'main', null, noHistory);
4297
4297
  }
4298
4298
  }
4299
+ }, {
4300
+ key: "removeAllUrlParams",
4301
+ value: function removeAllUrlParams() {
4302
+ var reloadView = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4303
+ var noHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4304
+ // const output = {
4305
+ // path: '',
4306
+ // items: {}
4307
+ // }
4308
+ // this.currentParams = output
4309
+ var inputPath = this.currentView;
4310
+
4311
+ if (this.options.urlPrefix) {
4312
+ inputPath = "/".concat(this.options.urlPrefix, "/").concat(inputPath);
4313
+ }
4314
+
4315
+ if (reloadView === true) {
4316
+ this.navigate("".concat(inputPath), 'main', null, noHistory);
4317
+ } else {
4318
+ this.currentParams = {
4319
+ path: '',
4320
+ items: {}
4321
+ };
4322
+ }
4323
+ }
4299
4324
  }, {
4300
4325
  key: "buildUrlPath",
4301
4326
  value: function buildUrlPath(params) {
@@ -4327,6 +4352,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4327
4352
  this.addGroup(g);
4328
4353
  }
4329
4354
 
4355
+ if (els[i].classList.contains(this.options.activeClass)) {
4356
+ this.groups[g].activeView = v;
4357
+ }
4358
+
4330
4359
  if (this.groups[g].views.indexOf(v) === -1) {
4331
4360
  this.groups[g].views.push(v);
4332
4361
  }
@@ -4386,12 +4415,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4386
4415
  view: this.groups[g].activeView,
4387
4416
  group: g
4388
4417
  });
4389
- } else {
4390
- views.push({
4391
- view: this.groups[g].views[0],
4392
- group: g
4393
- });
4394
- }
4418
+ } // else {
4419
+ // views.push({view: this.groups[g].views[0], group: g})
4420
+ // }
4421
+
4395
4422
  }
4396
4423
  }
4397
4424
 
@@ -4600,11 +4627,11 @@ var WebsyRouter = /*#__PURE__*/function () {
4600
4627
 
4601
4628
  var html = "\n <article id='".concat(elementId, "_content' class='websy-content-article'></article>\n <div id='").concat(elementId, "_loading' class='websy-loading-container'><div class='websy-ripple'><div></div><div></div></div></div>\n ");
4602
4629
 
4603
- if (options.help && options.help !== '') {
4630
+ if (options && options.help && options.help !== '') {
4604
4631
  html += "\n <Help not yet supported>\n ";
4605
4632
  }
4606
4633
 
4607
- if (options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4634
+ if (options && options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4608
4635
  html += "\n <div class=\"websy-info ".concat(this.options.tooltip.classes.join(' ') || '', "\" data-info=\"").concat(this.options.tooltip.value, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-e</title><path d=\"M256,56C145.72,56,56,145.72,56,256s89.72,200,200,200,200-89.72,200-200S366.28,56,256,56Zm0,82a26,26,0,1,1-26,26A26,26,0,0,1,256,138Zm48,226H216a16,16,0,0,1,0-32h28V244H228a16,16,0,0,1,0-32h32a16,16,0,0,1,16,16V332h28a16,16,0,0,1,0,32Z\"/></svg>\n </div> \n ");
4609
4636
  }
4610
4637
 
@@ -4731,7 +4758,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4731
4758
  }
4732
4759
 
4733
4760
  if (toggle === true && this.groups[group].activeView !== '') {
4734
- newPath = '';
4761
+ newPath = inputPath === this.groups[group].activeView ? '' : inputPath;
4735
4762
  }
4736
4763
 
4737
4764
  this.previousView = this.currentView;
@@ -4930,6 +4957,7 @@ var WebsySearch = /*#__PURE__*/function () {
4930
4957
  var DEFAULTS = {
4931
4958
  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>",
4932
4959
  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>",
4960
+ clearAlwaysOn: false,
4933
4961
  placeholder: 'Search',
4934
4962
  searchTimeout: 500,
4935
4963
  minLength: 2
@@ -4943,7 +4971,7 @@ var WebsySearch = /*#__PURE__*/function () {
4943
4971
  el.addEventListener('click', this.handleClick.bind(this));
4944
4972
  el.addEventListener('keyup', this.handleKeyUp.bind(this));
4945
4973
  el.addEventListener('keyup', this.handleKeyDown.bind(this));
4946
- 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 ");
4974
+ 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 ").concat(this.options.clearAlwaysOn === true ? '' : 'websy-hidden', "' id='").concat(this.elementId, "_clear'>\n ").concat(this.options.clearIcon, "\n </div>\n </div>\n ");
4947
4975
  } else {
4948
4976
  console.log('No element found with Id', elementId);
4949
4977
  }
@@ -4985,10 +5013,12 @@ var WebsySearch = /*#__PURE__*/function () {
4985
5013
 
4986
5014
  var clearEl = document.getElementById("".concat(this.elementId, "_clear"));
4987
5015
 
4988
- if (event.target.value.length > 0) {
4989
- clearEl.classList.remove('websy-hidden');
4990
- } else {
4991
- clearEl.classList.add('websy-hidden');
5016
+ if (this.options.clearAlwaysOn === false) {
5017
+ if (event.target.value.length > 0) {
5018
+ clearEl.classList.remove('websy-hidden');
5019
+ } else {
5020
+ clearEl.classList.add('websy-hidden');
5021
+ }
4992
5022
  }
4993
5023
 
4994
5024
  if (event.target.value.length >= this.options.minLength) {
@@ -4999,8 +5029,8 @@ var WebsySearch = /*#__PURE__*/function () {
4999
5029
  }, this.options.searchTimeout);
5000
5030
  } else {
5001
5031
  if (this.options.onSearch && (event.key === 'Delete' || event.key === 'Backspace')) {
5002
- if (this.options.onClear) {
5003
- this.options.onClear();
5032
+ if (this.options.onSearch) {
5033
+ this.options.onSearch('');
5004
5034
  }
5005
5035
  }
5006
5036
  }