@websy/websy-designs 1.4.3 → 1.4.4

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')
@@ -5677,12 +5688,16 @@ class WebsyTable3 {
5677
5688
  if (typeof sizingColumns[sizeIndex] === 'undefined') {
5678
5689
  return // need to revisit this logic
5679
5690
  }
5680
- let style = `width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important; `
5681
- let divStyle = style
5691
+ let style = ''
5692
+ let divStyle = ''
5693
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
5694
+ style = `width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important; `
5695
+ divStyle = style
5696
+ }
5682
5697
  if (cell.style) {
5683
5698
  style += cell.style
5684
5699
  }
5685
- if (useWidths === true) {
5700
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
5686
5701
  style += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
5687
5702
  divStyle += `max-width: ${sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth}px!important;`
5688
5703
  }
@@ -5727,6 +5742,25 @@ class WebsyTable3 {
5727
5742
  class='websy-table-cell-collapse'
5728
5743
  >${WebsyDesigns.Icons.MinusFilled}</i>`
5729
5744
  }
5745
+ if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
5746
+ cell.value = `
5747
+ <a href='${cell.value}' target='${sizingColumns[sizeIndex].openInNewTab === true ? '_blank' : '_self'}'>${cell.displayText || sizingColumns[sizeIndex].linkText || cell.value}</a>
5748
+ `
5749
+ }
5750
+ if (sizingColumns[sizeIndex].showAsRouterLink === true && cell.value.trim() !== '') {
5751
+ cell.value = `
5752
+ <a data-view='${(cell.link || cell.value).replace(/'/g, '\'')}' class='websy-trigger'>${cell.value}</a>
5753
+ `
5754
+ }
5755
+ if (sizingColumns[sizeIndex].showAsImage === true) {
5756
+ cell.value = `
5757
+ <img
5758
+ style="width: ${sizingColumns[sizeIndex].imgWidth ? sizingColumns[sizeIndex].imgWidth : 'auto'}; height: ${sizingColumns[sizeIndex].imgHeight ? sizingColumns[sizeIndex].imgHeight : 'auto'};"
5759
+ src='${cell.value}'
5760
+ ${sizingColumns[sizeIndex].errorImage ? 'onerror="this.src=\'' + sizingColumns[sizeIndex].errorImage + '\'"' : ''}
5761
+ />
5762
+ `
5763
+ }
5730
5764
  bodyHtml += `
5731
5765
  ${cell.value}
5732
5766
  </div></td>`
@@ -6035,14 +6069,16 @@ class WebsyTable3 {
6035
6069
  this.mouseXStart = null
6036
6070
  }
6037
6071
  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
- }
6072
+ if (this.options.virtualScroll === true) {
6073
+ event.preventDefault()
6074
+ // console.log('scrollwheel', event)
6075
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6076
+ this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
6077
+ }
6078
+ else {
6079
+ this.scrollY(Math.max(-5, Math.min(5, event.deltaY)))
6080
+ }
6081
+ }
6046
6082
  }
6047
6083
  hideError () {
6048
6084
  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');
@@ -6174,14 +6186,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
6174
6186
  return; // need to revisit this logic
6175
6187
  }
6176
6188
 
6177
- var style = "width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important; ");
6178
- var divStyle = style;
6189
+ var style = '';
6190
+ var divStyle = '';
6191
+
6192
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
6193
+ style = "width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important; ");
6194
+ divStyle = style;
6195
+ }
6179
6196
 
6180
6197
  if (cell.style) {
6181
6198
  style += cell.style;
6182
6199
  }
6183
6200
 
6184
- if (useWidths === true) {
6201
+ if (useWidths === true && (+cell.colspan === 1 || !cell.colspan)) {
6185
6202
  style += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6186
6203
  divStyle += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6187
6204
  }
@@ -6216,6 +6233,18 @@ var WebsyTable3 = /*#__PURE__*/function () {
6216
6233
  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
6234
  }
6218
6235
 
6236
+ if (sizingColumns[sizeIndex].showAsLink === true && cell.value.trim() !== '') {
6237
+ 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 ");
6238
+ }
6239
+
6240
+ if (sizingColumns[sizeIndex].showAsRouterLink === true && cell.value.trim() !== '') {
6241
+ cell.value = "\n <a data-view='".concat((cell.link || cell.value).replace(/'/g, '\''), "' class='websy-trigger'>").concat(cell.value, "</a>\n ");
6242
+ }
6243
+
6244
+ if (sizingColumns[sizeIndex].showAsImage === true) {
6245
+ 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 ");
6246
+ }
6247
+
6219
6248
  bodyHtml += "\n ".concat(cell.value, "\n </div></td>");
6220
6249
  });
6221
6250
  bodyHtml += "</tr>";
@@ -6573,12 +6602,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6573
6602
  }, {
6574
6603
  key: "handleScrollWheel",
6575
6604
  value: function handleScrollWheel(event) {
6576
- event.preventDefault(); // console.log('scrollwheel', event)
6605
+ if (this.options.virtualScroll === true) {
6606
+ event.preventDefault(); // console.log('scrollwheel', event)
6577
6607
 
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)));
6608
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6609
+ this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
6610
+ } else {
6611
+ this.scrollY(Math.max(-5, Math.min(5, event.deltaY)));
6612
+ }
6582
6613
  }
6583
6614
  }
6584
6615
  }, {