@websy/websy-designs 1.4.3 → 1.4.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.
@@ -158,7 +158,9 @@ class ButtonGroup {
158
158
  const DEFAULTS = {
159
159
  style: 'button',
160
160
  subscribers: {},
161
- activeItem: 0
161
+ activeItem: -1,
162
+ tag: 'div',
163
+ allowNone: false
162
164
  }
163
165
  this.options = Object.assign({}, DEFAULTS, options)
164
166
  const el = document.getElementById(this.elementId)
@@ -171,7 +173,7 @@ class ButtonGroup {
171
173
  if (event.target.classList.contains('websy-button-group-item')) {
172
174
  const index = +event.target.getAttribute('data-index')
173
175
  if (this.options.activeItem !== index) {
174
- if (this.options.onDeactivate) {
176
+ if (this.options.onDeactivate && this.options.activeItem !== -1) {
175
177
  this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem)
176
178
  }
177
179
  this.options.activeItem = index
@@ -187,7 +189,14 @@ class ButtonGroup {
187
189
  })
188
190
  event.target.classList.remove('inactive')
189
191
  event.target.classList.add('active')
190
- }
192
+ }
193
+ else if (this.options.activeItem === index && this.options.allowNone === true) {
194
+ if (this.options.onDeactivate) {
195
+ this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem)
196
+ }
197
+ this.options.activeItem = -1
198
+ event.target.classList.remove('active')
199
+ }
191
200
  }
192
201
  }
193
202
  on (event, fn) {
@@ -210,7 +219,7 @@ class ButtonGroup {
210
219
  activeClass = i === this.options.activeItem ? 'active' : 'inactive'
211
220
  }
212
221
  return `
213
- <div ${(t.attributes || []).join(' ')} data-id="${t.id || t.label}" data-index="${i}" class="websy-button-group-item ${(t.classes || []).join(' ')} ${this.options.style}-style ${activeClass}">${t.label}</div>
222
+ <${this.options.tag} ${(t.attributes || []).join(' ')} data-id="${t.id || t.label}" data-index="${i}" class="websy-button-group-item ${(t.classes || []).join(' ')} ${this.options.style}-style ${activeClass}">${t.label}</${this.options.tag}>
214
223
  `
215
224
  }).join('')
216
225
  }
@@ -1606,7 +1615,9 @@ class WebsyDropdown {
1606
1615
  if (el) {
1607
1616
  el.style.zIndex = ''
1608
1617
  }
1609
- scrollEl.scrollTop = 0
1618
+ if (scrollEl) {
1619
+ scrollEl.scrollTo(0, 0)
1620
+ }
1610
1621
  maskEl.classList.remove('active')
1611
1622
  contentEl.classList.remove('active')
1612
1623
  contentEl.classList.remove('on-top')
@@ -3686,6 +3697,26 @@ class WebsyRouter {
3686
3697
  this.navigate(`${inputPath}?${path}`, 'main', null, noHistory)
3687
3698
  }
3688
3699
  }
3700
+ removeAllUrlParams (reloadView = false, noHistory = true) {
3701
+ // const output = {
3702
+ // path: '',
3703
+ // items: {}
3704
+ // }
3705
+ // this.currentParams = output
3706
+ let inputPath = this.currentView
3707
+ if (this.options.urlPrefix) {
3708
+ inputPath = `/${this.options.urlPrefix}/${inputPath}`
3709
+ }
3710
+ if (reloadView === true) {
3711
+ this.navigate(`${inputPath}`, 'main', null, noHistory)
3712
+ }
3713
+ else {
3714
+ this.currentParams = {
3715
+ path: '',
3716
+ items: {}
3717
+ }
3718
+ }
3719
+ }
3689
3720
  buildUrlPath (params) {
3690
3721
  let path = []
3691
3722
  for (let key in params) {
@@ -3706,6 +3737,9 @@ class WebsyRouter {
3706
3737
  if (!this.groups[g]) {
3707
3738
  this.addGroup(g)
3708
3739
  }
3740
+ if (els[i].classList.contains(this.options.activeClass)) {
3741
+ this.groups[g].activeView = v
3742
+ }
3709
3743
  if (this.groups[g].views.indexOf(v) === -1) {
3710
3744
  this.groups[g].views.push(v)
3711
3745
  }
@@ -3749,9 +3783,9 @@ class WebsyRouter {
3749
3783
  if (this.groups[g].activeView) {
3750
3784
  views.push({view: this.groups[g].activeView, group: g})
3751
3785
  }
3752
- else {
3753
- views.push({view: this.groups[g].views[0], group: g})
3754
- }
3786
+ // else {
3787
+ // views.push({view: this.groups[g].views[0], group: g})
3788
+ // }
3755
3789
  }
3756
3790
  }
3757
3791
  return views
@@ -3924,12 +3958,12 @@ class WebsyRouter {
3924
3958
  <article id='${elementId}_content' class='websy-content-article'></article>
3925
3959
  <div id='${elementId}_loading' class='websy-loading-container'><div class='websy-ripple'><div></div><div></div></div></div>
3926
3960
  `
3927
- if (options.help && options.help !== '') {
3961
+ if (options && options.help && options.help !== '') {
3928
3962
  html += `
3929
3963
  <Help not yet supported>
3930
3964
  `
3931
3965
  }
3932
- if (options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
3966
+ if (options && options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
3933
3967
  html += `
3934
3968
  <div class="websy-info ${this.options.tooltip.classes.join(' ') || ''}" data-info="${this.options.tooltip.value}">
3935
3969
  <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>
@@ -4035,7 +4069,7 @@ class WebsyRouter {
4035
4069
  this.addGroup(group)
4036
4070
  }
4037
4071
  if (toggle === true && this.groups[group].activeView !== '') {
4038
- newPath = ''
4072
+ newPath = inputPath === this.groups[group].activeView ? '' : inputPath
4039
4073
  }
4040
4074
  this.previousView = this.currentView
4041
4075
  this.previousPath = this.currentPath
@@ -5677,12 +5711,16 @@ class WebsyTable3 {
5677
5711
  if (typeof sizingColumns[sizeIndex] === 'undefined') {
5678
5712
  return // need to revisit this logic
5679
5713
  }
5680
- let style = `width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important; `
5681
- let divStyle = style
5714
+ let style = ''
5715
+ let divStyle = ''
5716
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
5717
+ style = `width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important; `
5718
+ divStyle = style
5719
+ }
5682
5720
  if (cell.style) {
5683
5721
  style += cell.style
5684
5722
  }
5685
- if (useWidths === true) {
5723
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
5686
5724
  style += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
5687
5725
  divStyle += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
5688
5726
  }
@@ -5727,6 +5765,25 @@ class WebsyTable3 {
5727
5765
  class='websy-table-cell-collapse'
5728
5766
  >${WebsyDesigns.Icons.MinusFilled}</i>`
5729
5767
  }
5768
+ if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
5769
+ cell.value = `
5770
+ <a href='${cell.value}' target='${sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self'}'>${cell.displayText || sizingColumns[sizeIndex].linkText || cell.value}</a>
5771
+ `
5772
+ }
5773
+ if (sizingColumns[sizeIndex].showAsRouterLink === true && cell.value.trim() !== '') {
5774
+ cell.value = `
5775
+ <a data-view='${(cell.link || cell.value).replace(/'/g, '\'')}' class='websy-trigger'>${cell.value}</a>
5776
+ `
5777
+ }
5778
+ if (sizingColumns[sizeIndex].showAsImage === true) {
5779
+ cell.value = `
5780
+ <img
5781
+ style="width: ${sizingColumns[sizeIndex].imgWidth ? sizingColumns[sizeIndex].imgWidth : 'auto'}; height: ${sizingColumns[sizeIndex].imgHeight ? sizingColumns[sizeIndex].imgHeight : 'auto'};"
5782
+ src='${cell.value}'
5783
+ ${sizingColumns[sizeIndex].errorImage ? 'onerror="this.src=\'' + sizingColumns[sizeIndex].errorImage + '\'"' : ''}
5784
+ />
5785
+ `
5786
+ }
5730
5787
  bodyHtml += `
5731
5788
  ${cell.value}
5732
5789
  </div></td>`
@@ -6035,14 +6092,16 @@ class WebsyTable3 {
6035
6092
  this.mouseXStart = null
6036
6093
  }
6037
6094
  handleScrollWheel (event) {
6038
- event.preventDefault()
6039
- // console.log('scrollwheel', event)
6040
- if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6041
- this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
6042
- }
6043
- else {
6044
- this.scrollY(Math.max(-5, Math.min(5, event.deltaY)))
6045
- }
6095
+ if (this.options.virtualScroll === true) {
6096
+ event.preventDefault()
6097
+ // console.log('scrollwheel', event)
6098
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6099
+ this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
6100
+ }
6101
+ else {
6102
+ this.scrollY(Math.max(-5, Math.min(5, event.deltaY)))
6103
+ }
6104
+ }
6046
6105
  }
6047
6106
  hideError () {
6048
6107
  const el = document.getElementById(`${this.elementId}_tableContainer`)
@@ -206,7 +206,9 @@ var ButtonGroup = /*#__PURE__*/function () {
206
206
  var DEFAULTS = {
207
207
  style: 'button',
208
208
  subscribers: {},
209
- activeItem: 0
209
+ activeItem: -1,
210
+ tag: 'div',
211
+ allowNone: false
210
212
  };
211
213
  this.options = _extends({}, DEFAULTS, options);
212
214
  var el = document.getElementById(this.elementId);
@@ -224,7 +226,7 @@ var ButtonGroup = /*#__PURE__*/function () {
224
226
  var index = +event.target.getAttribute('data-index');
225
227
 
226
228
  if (this.options.activeItem !== index) {
227
- if (this.options.onDeactivate) {
229
+ if (this.options.onDeactivate && this.options.activeItem !== -1) {
228
230
  this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem);
229
231
  }
230
232
 
@@ -243,6 +245,13 @@ var ButtonGroup = /*#__PURE__*/function () {
243
245
  });
244
246
  event.target.classList.remove('inactive');
245
247
  event.target.classList.add('active');
248
+ } else if (this.options.activeItem === index && this.options.allowNone === true) {
249
+ if (this.options.onDeactivate) {
250
+ this.options.onDeactivate(this.options.items[this.options.activeItem], this.options.activeItem);
251
+ }
252
+
253
+ this.options.activeItem = -1;
254
+ event.target.classList.remove('active');
246
255
  }
247
256
  }
248
257
  }
@@ -277,7 +286,7 @@ var ButtonGroup = /*#__PURE__*/function () {
277
286
  activeClass = i === _this.options.activeItem ? 'active' : 'inactive';
278
287
  }
279
288
 
280
- return "\n <div ".concat((t.attributes || []).join(' '), " data-id=\"").concat(t.id || t.label, "\" data-index=\"").concat(i, "\" class=\"websy-button-group-item ").concat((t.classes || []).join(' '), " ").concat(_this.options.style, "-style ").concat(activeClass, "\">").concat(t.label, "</div>\n ");
289
+ return "\n <".concat(_this.options.tag, " ").concat((t.attributes || []).join(' '), " data-id=\"").concat(t.id || t.label, "\" data-index=\"").concat(i, "\" class=\"websy-button-group-item ").concat((t.classes || []).join(' '), " ").concat(_this.options.style, "-style ").concat(activeClass, "\">").concat(t.label, "</").concat(_this.options.tag, ">\n ");
281
290
  }).join('');
282
291
  }
283
292
  }
@@ -1739,7 +1748,10 @@ var WebsyDropdown = /*#__PURE__*/function () {
1739
1748
  el.style.zIndex = '';
1740
1749
  }
1741
1750
 
1742
- scrollEl.scrollTop = 0;
1751
+ if (scrollEl) {
1752
+ scrollEl.scrollTo(0, 0);
1753
+ }
1754
+
1743
1755
  maskEl.classList.remove('active');
1744
1756
  contentEl.classList.remove('active');
1745
1757
  contentEl.classList.remove('on-top');
@@ -3982,6 +3994,31 @@ var WebsyRouter = /*#__PURE__*/function () {
3982
3994
  this.navigate("".concat(inputPath, "?").concat(path), 'main', null, noHistory);
3983
3995
  }
3984
3996
  }
3997
+ }, {
3998
+ key: "removeAllUrlParams",
3999
+ value: function removeAllUrlParams() {
4000
+ var reloadView = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4001
+ var noHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4002
+ // const output = {
4003
+ // path: '',
4004
+ // items: {}
4005
+ // }
4006
+ // this.currentParams = output
4007
+ var inputPath = this.currentView;
4008
+
4009
+ if (this.options.urlPrefix) {
4010
+ inputPath = "/".concat(this.options.urlPrefix, "/").concat(inputPath);
4011
+ }
4012
+
4013
+ if (reloadView === true) {
4014
+ this.navigate("".concat(inputPath), 'main', null, noHistory);
4015
+ } else {
4016
+ this.currentParams = {
4017
+ path: '',
4018
+ items: {}
4019
+ };
4020
+ }
4021
+ }
3985
4022
  }, {
3986
4023
  key: "buildUrlPath",
3987
4024
  value: function buildUrlPath(params) {
@@ -4013,6 +4050,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4013
4050
  this.addGroup(g);
4014
4051
  }
4015
4052
 
4053
+ if (els[i].classList.contains(this.options.activeClass)) {
4054
+ this.groups[g].activeView = v;
4055
+ }
4056
+
4016
4057
  if (this.groups[g].views.indexOf(v) === -1) {
4017
4058
  this.groups[g].views.push(v);
4018
4059
  }
@@ -4072,12 +4113,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4072
4113
  view: this.groups[g].activeView,
4073
4114
  group: g
4074
4115
  });
4075
- } else {
4076
- views.push({
4077
- view: this.groups[g].views[0],
4078
- group: g
4079
- });
4080
- }
4116
+ } // else {
4117
+ // views.push({view: this.groups[g].views[0], group: g})
4118
+ // }
4119
+
4081
4120
  }
4082
4121
  }
4083
4122
 
@@ -4286,11 +4325,11 @@ var WebsyRouter = /*#__PURE__*/function () {
4286
4325
 
4287
4326
  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 ");
4288
4327
 
4289
- if (options.help && options.help !== '') {
4328
+ if (options && options.help && options.help !== '') {
4290
4329
  html += "\n <Help not yet supported>\n ";
4291
4330
  }
4292
4331
 
4293
- if (options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4332
+ if (options && options.tooltip && options.tooltip.value && options.tooltip.value !== '') {
4294
4333
  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 ");
4295
4334
  }
4296
4335
 
@@ -4417,7 +4456,7 @@ var WebsyRouter = /*#__PURE__*/function () {
4417
4456
  }
4418
4457
 
4419
4458
  if (toggle === true && this.groups[group].activeView !== '') {
4420
- newPath = '';
4459
+ newPath = inputPath === this.groups[group].activeView ? '' : inputPath;
4421
4460
  }
4422
4461
 
4423
4462
  this.previousView = this.currentView;
@@ -6174,14 +6213,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
6174
6213
  return; // need to revisit this logic
6175
6214
  }
6176
6215
 
6177
- var style = "width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important; ");
6178
- var divStyle = style;
6216
+ var style = '';
6217
+ var divStyle = '';
6218
+
6219
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
6220
+ style = "width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important; ");
6221
+ divStyle = style;
6222
+ }
6179
6223
 
6180
6224
  if (cell.style) {
6181
6225
  style += cell.style;
6182
6226
  }
6183
6227
 
6184
- if (useWidths === true) {
6228
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
6185
6229
  style += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6186
6230
  divStyle += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6187
6231
  }
@@ -6216,6 +6260,18 @@ var WebsyTable3 = /*#__PURE__*/function () {
6216
6260
  bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(WebsyDesigns.Icons.MinusFilled, "</i>");
6217
6261
  }
6218
6262
 
6263
+ if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
6264
+ cell.value = "\n <a href='".concat(cell.value, "' target='").concat(sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self', "'>").concat(cell.displayText || sizingColumns[sizeIndex].linkText || cell.value, "</a>\n ");
6265
+ }
6266
+
6267
+ if (sizingColumns[sizeIndex].showAsRouterLink === true && cell.value.trim() !== '') {
6268
+ cell.value = "\n <a data-view='".concat((cell.link || cell.value).replace(/'/g, '\''), "' class='websy-trigger'>").concat(cell.value, "</a>\n ");
6269
+ }
6270
+
6271
+ if (sizingColumns[sizeIndex].showAsImage === true) {
6272
+ cell.value = "\n <img \n style=\"width: ".concat(sizingColumns[sizeIndex].imgWidth ? sizingColumns[sizeIndex].imgWidth : 'auto', "; height: ").concat(sizingColumns[sizeIndex].imgHeight ? sizingColumns[sizeIndex].imgHeight : 'auto', ";\" \n src='").concat(cell.value, "'\n ").concat(sizingColumns[sizeIndex].errorImage ? 'onerror="this.src=\'' + sizingColumns[sizeIndex].errorImage + '\'"' : '', "\n />\n ");
6273
+ }
6274
+
6219
6275
  bodyHtml += "\n ".concat(cell.value, "\n </div></td>");
6220
6276
  });
6221
6277
  bodyHtml += "</tr>";
@@ -6573,12 +6629,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6573
6629
  }, {
6574
6630
  key: "handleScrollWheel",
6575
6631
  value: function handleScrollWheel(event) {
6576
- event.preventDefault(); // console.log('scrollwheel', event)
6632
+ if (this.options.virtualScroll === true) {
6633
+ event.preventDefault(); // console.log('scrollwheel', event)
6577
6634
 
6578
- if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6579
- this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
6580
- } else {
6581
- this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
6635
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6636
+ this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
6637
+ } else {
6638
+ this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
6639
+ }
6582
6640
  }
6583
6641
  }
6584
6642
  }, {