@websy/websy-designs 1.3.0 → 1.3.2
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.
- package/dist/server/helpers/v1/pdfHelper.js +13 -4
- package/dist/server/routes/v1/shop.js +52 -15
- package/dist/websy-designs-es6.debug.js +154 -62
- package/dist/websy-designs-es6.js +168 -60
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +154 -62
- package/dist/websy-designs.js +168 -60
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -562,6 +562,7 @@ class WebsyDatePicker {
|
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
564
|
close (confirm, isRange = false) {
|
|
565
|
+
console.trace()
|
|
565
566
|
const maskEl = document.getElementById(`${this.elementId}_mask`)
|
|
566
567
|
const contentEl = document.getElementById(`${this.elementId}_content`)
|
|
567
568
|
const el = document.getElementById(this.elementId)
|
|
@@ -578,19 +579,19 @@ class WebsyDatePicker {
|
|
|
578
579
|
for (let i = this.selectedRangeDates[0]; i < this.selectedRangeDates[1] + 1; i++) {
|
|
579
580
|
hoursOut.push(this.options.hours[i])
|
|
580
581
|
}
|
|
581
|
-
this.options.onChange(hoursOut, true)
|
|
582
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
582
583
|
}
|
|
583
584
|
else {
|
|
584
|
-
this.options.onChange(this.selectedRangeDates, true)
|
|
585
|
+
this.options.onChange(this.selectedRangeDates, true, this.selectedRange)
|
|
585
586
|
}
|
|
586
587
|
}
|
|
587
588
|
else {
|
|
588
589
|
if (this.options.mode === 'hour') {
|
|
589
590
|
let hoursOut = this.currentselection.map(h => this.options.hours[h])
|
|
590
|
-
this.options.onChange(hoursOut, true)
|
|
591
|
+
this.options.onChange(hoursOut, true, this.selectedRange)
|
|
591
592
|
}
|
|
592
593
|
else {
|
|
593
|
-
this.options.onChange(this.currentselection, isRange)
|
|
594
|
+
this.options.onChange(this.currentselection, isRange, this.selectedRange)
|
|
594
595
|
}
|
|
595
596
|
}
|
|
596
597
|
}
|
|
@@ -613,7 +614,7 @@ class WebsyDatePicker {
|
|
|
613
614
|
d = new Date(d)
|
|
614
615
|
}
|
|
615
616
|
// d.setTime(d.getTime() + d.getTimezoneOffset() * 60000)
|
|
616
|
-
return new Date(d.
|
|
617
|
+
return new Date(d.setUTCHours(12, 0, 0, 0))
|
|
617
618
|
}
|
|
618
619
|
handleClick (event) {
|
|
619
620
|
if (event.target.classList.contains('websy-date-picker-header')) {
|
|
@@ -736,8 +737,9 @@ class WebsyDatePicker {
|
|
|
736
737
|
let rangeEnd
|
|
737
738
|
if (this.options.mode === 'date') {
|
|
738
739
|
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime() + (i * this.oneDay)))
|
|
739
|
-
d.
|
|
740
|
+
// d.setUTCHours(12, 0, 0, 0)
|
|
740
741
|
d = d.getTime()
|
|
742
|
+
// console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
741
743
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
742
744
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
743
745
|
}
|
|
@@ -746,8 +748,10 @@ class WebsyDatePicker {
|
|
|
746
748
|
rangeStart = this.selectedRangeDates[0]
|
|
747
749
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
|
|
748
750
|
}
|
|
749
|
-
else if (this.options.mode === 'monthyear') {
|
|
750
|
-
d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i)
|
|
751
|
+
else if (this.options.mode === 'monthyear') {
|
|
752
|
+
d = this.floorDate(new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i))
|
|
753
|
+
d = d.getTime()
|
|
754
|
+
console.log('highlighting', this.selectedRangeDates[0].getTime(), d)
|
|
751
755
|
rangeStart = this.selectedRangeDates[0].getTime()
|
|
752
756
|
rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
|
|
753
757
|
}
|
|
@@ -795,9 +799,11 @@ class WebsyDatePicker {
|
|
|
795
799
|
else if (this.options.mode === 'hour') {
|
|
796
800
|
dateEl = document.getElementById(`${this.elementId}_${d}_hour`)
|
|
797
801
|
}
|
|
798
|
-
dateEl
|
|
799
|
-
|
|
800
|
-
|
|
802
|
+
if (dateEl) {
|
|
803
|
+
dateEl.classList.add('selected')
|
|
804
|
+
dateEl.classList.add('first')
|
|
805
|
+
dateEl.classList.add('last')
|
|
806
|
+
}
|
|
801
807
|
})
|
|
802
808
|
}
|
|
803
809
|
}
|
|
@@ -1019,7 +1025,7 @@ class WebsyDatePicker {
|
|
|
1019
1025
|
yearList.reverse()
|
|
1020
1026
|
}
|
|
1021
1027
|
html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
|
|
1022
|
-
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
1028
|
+
html += yearList.map(d => `<li id='${this.elementId}_${d.id}_year' data-id='${d.id}' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
|
|
1023
1029
|
html += `</ul></div>`
|
|
1024
1030
|
}
|
|
1025
1031
|
else if (this.options.mode === 'monthyear') {
|
|
@@ -1036,7 +1042,7 @@ class WebsyDatePicker {
|
|
|
1036
1042
|
}
|
|
1037
1043
|
html += paddedMonths.join('')
|
|
1038
1044
|
}
|
|
1039
|
-
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
1045
|
+
html += this.monthYears[year].map(d => `<li id='${this.elementId}_${d.id}_monthyear' data-id='${d.id}' data-year='${d.year}' class='websy-dp-date websy-dp-monthyear'>${d.month}</li>`).join('')
|
|
1040
1046
|
html += `</ul>`
|
|
1041
1047
|
}
|
|
1042
1048
|
html += `</div>`
|
|
@@ -1129,15 +1135,6 @@ class WebsyDatePicker {
|
|
|
1129
1135
|
this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
|
|
1130
1136
|
this.currentselection = this.options.ranges[this.options.mode][index].range.map(d => d.getTime())
|
|
1131
1137
|
this.selectedRange = +index
|
|
1132
|
-
const el = document.getElementById(`${this.elementId}_header`)
|
|
1133
|
-
if (el) {
|
|
1134
|
-
if (this.selectedRange === 0) {
|
|
1135
|
-
el.classList.remove('range-selected')
|
|
1136
|
-
}
|
|
1137
|
-
else {
|
|
1138
|
-
el.classList.add('range-selected')
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
1138
|
this.highlightRange()
|
|
1142
1139
|
this.updateRange()
|
|
1143
1140
|
this.close(confirm, true)
|
|
@@ -1146,14 +1143,16 @@ class WebsyDatePicker {
|
|
|
1146
1143
|
selectCustomRange (rangeInput) {
|
|
1147
1144
|
this.selectedRange = -1
|
|
1148
1145
|
let isContinuousRange = true
|
|
1149
|
-
if (rangeInput.length === 1) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
else if (rangeInput.length === 2) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
}
|
|
1146
|
+
// if (rangeInput.length === 1) {
|
|
1147
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
1148
|
+
// this.customRangeSelected = true
|
|
1149
|
+
// }
|
|
1150
|
+
// else if (rangeInput.length === 2) {
|
|
1151
|
+
// this.selectedRangeDates = [...rangeInput]
|
|
1152
|
+
// this.customRangeSelected = true
|
|
1153
|
+
// }
|
|
1154
|
+
this.selectedRangeDates = [...rangeInput]
|
|
1155
|
+
this.customRangeSelected = true
|
|
1157
1156
|
rangeInput.forEach((r, i) => {
|
|
1158
1157
|
if (i > 0) {
|
|
1159
1158
|
if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
|
|
@@ -1291,6 +1290,15 @@ class WebsyDatePicker {
|
|
|
1291
1290
|
if (labelEl) {
|
|
1292
1291
|
labelEl.innerHTML = range.label
|
|
1293
1292
|
}
|
|
1293
|
+
const headerEl = document.getElementById(`${this.elementId}_header`)
|
|
1294
|
+
if (headerEl) {
|
|
1295
|
+
if (this.selectedRange === 0) {
|
|
1296
|
+
headerEl.classList.remove('range-selected')
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
headerEl.classList.add('range-selected')
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1294
1302
|
}
|
|
1295
1303
|
}
|
|
1296
1304
|
|
|
@@ -1767,7 +1775,8 @@ class WebsyDragDrop {
|
|
|
1767
1775
|
const DEFAULTS = {
|
|
1768
1776
|
items: [],
|
|
1769
1777
|
orientation: 'horizontal',
|
|
1770
|
-
dropPlaceholder: 'Drop item here'
|
|
1778
|
+
dropPlaceholder: 'Drop item here',
|
|
1779
|
+
accepts: 'application/wd-item'
|
|
1771
1780
|
}
|
|
1772
1781
|
this.busy = false
|
|
1773
1782
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
@@ -1826,7 +1835,7 @@ class WebsyDragDrop {
|
|
|
1826
1835
|
item.id = WebsyDesigns.Utils.createIdentity()
|
|
1827
1836
|
}
|
|
1828
1837
|
let html = `
|
|
1829
|
-
<div id='${item.id}_item' class='websy-dragdrop-item' draggable='true' data-id='${item.id}'>
|
|
1838
|
+
<div id='${item.id}_item' class='websy-dragdrop-item ${(item.classes || []).join(' ')}' draggable='true' data-id='${item.id}'>
|
|
1830
1839
|
<div id='${item.id}_itemInner' class='websy-dragdrop-item-inner' data-id='${item.id}'>
|
|
1831
1840
|
`
|
|
1832
1841
|
if (item.component) {
|
|
@@ -1855,20 +1864,23 @@ class WebsyDragDrop {
|
|
|
1855
1864
|
}
|
|
1856
1865
|
handleDragStart (event) {
|
|
1857
1866
|
this.draggedId = event.target.getAttribute('data-id')
|
|
1858
|
-
event.dataTransfer.effectAllowed = 'move'
|
|
1859
|
-
event.dataTransfer.setData(
|
|
1860
|
-
|
|
1861
|
-
event.target.style.opacity = 0.5
|
|
1867
|
+
event.dataTransfer.effectAllowed = 'move'
|
|
1868
|
+
event.dataTransfer.setData(this.options.accepts, JSON.stringify({el: event.target.id, id: this.elementId, itemId: this.draggedId}))
|
|
1869
|
+
event.target.classList.add('dragging')
|
|
1870
|
+
// event.target.style.opacity = 0.5
|
|
1862
1871
|
this.dragging = true
|
|
1863
1872
|
}
|
|
1864
|
-
handleDragOver (event) {
|
|
1865
|
-
// console.log('drag over', event.target.classList)
|
|
1873
|
+
handleDragOver (event) {
|
|
1866
1874
|
if (event.preventDefault) {
|
|
1867
1875
|
event.preventDefault()
|
|
1868
1876
|
}
|
|
1877
|
+
console.log('drag', event.target.classList)
|
|
1869
1878
|
if (!event.target.classList.contains('droppable')) {
|
|
1870
1879
|
return
|
|
1871
1880
|
}
|
|
1881
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1882
|
+
return
|
|
1883
|
+
}
|
|
1872
1884
|
event.target.classList.add('drag-over')
|
|
1873
1885
|
}
|
|
1874
1886
|
handleDragLeave (event) {
|
|
@@ -1884,14 +1896,17 @@ class WebsyDragDrop {
|
|
|
1884
1896
|
}
|
|
1885
1897
|
handleDrop (event) {
|
|
1886
1898
|
// console.log('drag drop')
|
|
1887
|
-
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1888
|
-
const data = JSON.parse(event.dataTransfer.getData(
|
|
1899
|
+
// console.log(event.dataTransfer.getData('application/wd-item'))
|
|
1900
|
+
const data = JSON.parse(event.dataTransfer.getData(this.options.accepts))
|
|
1889
1901
|
if (event.preventDefault) {
|
|
1890
1902
|
event.preventDefault()
|
|
1891
1903
|
}
|
|
1892
1904
|
if (!event.target.classList.contains('droppable')) {
|
|
1893
1905
|
return
|
|
1894
1906
|
}
|
|
1907
|
+
if (event.dataTransfer.types.indexOf(this.options.accepts) === -1) {
|
|
1908
|
+
return
|
|
1909
|
+
}
|
|
1895
1910
|
let side = event.target.getAttribute('data-side')
|
|
1896
1911
|
let id = event.target.getAttribute('data-id')
|
|
1897
1912
|
let index = this.getItemIndex(id)
|
|
@@ -1941,6 +1956,7 @@ class WebsyDragDrop {
|
|
|
1941
1956
|
handleDragEnd (event) {
|
|
1942
1957
|
// console.log('drag end')
|
|
1943
1958
|
event.target.style.opacity = 1
|
|
1959
|
+
event.target.classList.remove('dragging')
|
|
1944
1960
|
this.draggedId = null
|
|
1945
1961
|
this.dragging = false
|
|
1946
1962
|
const startEl = document.getElementById(`${this.elementId}start_item`)
|
|
@@ -5619,10 +5635,16 @@ class WebsyTable3 {
|
|
|
5619
5635
|
data.forEach(row => {
|
|
5620
5636
|
bodyHtml += `<tr class="websy-table-row">`
|
|
5621
5637
|
row.forEach((cell, cellIndex) => {
|
|
5638
|
+
if (typeof sizingColumns[cellIndex] === 'undefined') {
|
|
5639
|
+
return // need to revisit this logic
|
|
5640
|
+
}
|
|
5622
5641
|
let style = ''
|
|
5623
5642
|
if (cell.style) {
|
|
5624
5643
|
style += cell.style
|
|
5625
5644
|
}
|
|
5645
|
+
if (useWidths === true) {
|
|
5646
|
+
style += `max-width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important;`
|
|
5647
|
+
}
|
|
5626
5648
|
if (cell.backgroundColor) {
|
|
5627
5649
|
style += `background-color: ${cell.backgroundColor}; `
|
|
5628
5650
|
if (!cell.color) {
|
|
@@ -5632,8 +5654,9 @@ class WebsyTable3 {
|
|
|
5632
5654
|
if (cell.color) {
|
|
5633
5655
|
style += `color: ${cell.color}; `
|
|
5634
5656
|
}
|
|
5657
|
+
console.log('rowspan', cell.rowspan)
|
|
5635
5658
|
bodyHtml += `<td
|
|
5636
|
-
class='websy-table-cell'
|
|
5659
|
+
class='websy-table-cell ${(cell.classes || []).join(' ')}'
|
|
5637
5660
|
style='${style}'
|
|
5638
5661
|
data-info='${cell.value}'
|
|
5639
5662
|
colspan='${cell.colspan || 1}'
|
|
@@ -5792,11 +5815,13 @@ class WebsyTable3 {
|
|
|
5792
5815
|
}
|
|
5793
5816
|
})
|
|
5794
5817
|
this.sizes.totalWidth = this.options.columns[this.options.columns.length - 1].reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5818
|
+
this.sizes.totalNonPinnedWidth = this.options.columns[this.options.columns.length - 1].filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
|
|
5795
5819
|
const outerSize = outerEl.getBoundingClientRect()
|
|
5796
5820
|
if (this.sizes.totalWidth < outerSize.width) {
|
|
5797
5821
|
this.sizes.totalWidth = 0
|
|
5822
|
+
this.sizes.totalNonPinnedWidth = 0
|
|
5798
5823
|
let equalWidth = outerSize.width / this.options.columns[this.options.columns.length - 1].length
|
|
5799
|
-
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5824
|
+
this.options.columns[this.options.columns.length - 1].forEach((c, i) => {
|
|
5800
5825
|
if (!c.width) {
|
|
5801
5826
|
if (c.actualWidth < equalWidth) {
|
|
5802
5827
|
// adjust the width
|
|
@@ -5804,6 +5829,9 @@ class WebsyTable3 {
|
|
|
5804
5829
|
}
|
|
5805
5830
|
}
|
|
5806
5831
|
this.sizes.totalWidth += c.width || c.actualWidth
|
|
5832
|
+
if (i < this.pinnedColumns) {
|
|
5833
|
+
this.sizes.totalNonPinnedWidth += c.width || c.actualWidth
|
|
5834
|
+
}
|
|
5807
5835
|
equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
|
|
5808
5836
|
})
|
|
5809
5837
|
}
|
|
@@ -5824,9 +5852,15 @@ class WebsyTable3 {
|
|
|
5824
5852
|
if (this.sizes.rowsToRender < this.totalRowCount) {
|
|
5825
5853
|
this.vScrollRequired = true
|
|
5826
5854
|
}
|
|
5855
|
+
else {
|
|
5856
|
+
this.vScrollRequired = false
|
|
5857
|
+
}
|
|
5827
5858
|
if (this.sizes.totalWidth > this.sizes.outer.width) {
|
|
5828
5859
|
this.hScrollRequired = true
|
|
5829
5860
|
}
|
|
5861
|
+
else {
|
|
5862
|
+
this.hScrollRequired = false
|
|
5863
|
+
}
|
|
5830
5864
|
this.options.allColumns = this.options.columns.map(c => c)
|
|
5831
5865
|
console.log('sizes', this.sizes)
|
|
5832
5866
|
return this.sizes
|
|
@@ -5971,10 +6005,10 @@ class WebsyTable3 {
|
|
|
5971
6005
|
if (this.hScrollRequired === true) {
|
|
5972
6006
|
hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
|
|
5973
6007
|
hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
|
|
5974
|
-
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.
|
|
6008
|
+
hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px'
|
|
5975
6009
|
}
|
|
5976
6010
|
else {
|
|
5977
|
-
hHandleEl.style.
|
|
6011
|
+
hHandleEl.style.width = '0px'
|
|
5978
6012
|
}
|
|
5979
6013
|
}
|
|
5980
6014
|
}
|
|
@@ -6004,9 +6038,7 @@ class WebsyTable3 {
|
|
|
6004
6038
|
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6005
6039
|
if (el) {
|
|
6006
6040
|
el.classList.add('has-error')
|
|
6007
|
-
}
|
|
6008
|
-
const tableEl = document.getElementById(`${this.elementId}_tableInner`)
|
|
6009
|
-
tableEl.classList.add('hidden')
|
|
6041
|
+
}
|
|
6010
6042
|
const containerEl = document.getElementById(`${this.elementId}_errorContainer`)
|
|
6011
6043
|
if (containerEl) {
|
|
6012
6044
|
containerEl.classList.add('active')
|
|
@@ -6025,6 +6057,19 @@ class WebsyTable3 {
|
|
|
6025
6057
|
}
|
|
6026
6058
|
}
|
|
6027
6059
|
scrollX (diff) {
|
|
6060
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6061
|
+
if (!el.classList.contains('scrolling')) {
|
|
6062
|
+
el.classList.add('scrolling')
|
|
6063
|
+
}
|
|
6064
|
+
if (this.scrollTimeoutFn) {
|
|
6065
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
6066
|
+
}
|
|
6067
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
6068
|
+
el.classList.remove('scrolling')
|
|
6069
|
+
}, 200)
|
|
6070
|
+
if (this.hScrollRequired === false) {
|
|
6071
|
+
return
|
|
6072
|
+
}
|
|
6028
6073
|
const scrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
|
|
6029
6074
|
const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
6030
6075
|
let handlePos
|
|
@@ -6038,11 +6083,11 @@ class WebsyTable3 {
|
|
|
6038
6083
|
console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
|
|
6039
6084
|
scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px'
|
|
6040
6085
|
if (this.options.onScroll) {
|
|
6041
|
-
let actualLeft = (this.sizes.
|
|
6086
|
+
let actualLeft = (this.sizes.totalNonPinnedWidth - this.sizes.scrollableWidth) * (Math.min(scrollableSpace, Math.max(0, handlePos)) / scrollableSpace)
|
|
6042
6087
|
let cumulativeWidth = 0
|
|
6043
6088
|
this.startCol = 0
|
|
6044
6089
|
this.endCol = 0
|
|
6045
|
-
for (let i =
|
|
6090
|
+
for (let i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
|
|
6046
6091
|
cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
|
|
6047
6092
|
console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
|
|
6048
6093
|
if (actualLeft < cumulativeWidth) {
|
|
@@ -6068,6 +6113,19 @@ class WebsyTable3 {
|
|
|
6068
6113
|
}
|
|
6069
6114
|
}
|
|
6070
6115
|
scrollY (diff) {
|
|
6116
|
+
const el = document.getElementById(`${this.elementId}_tableContainer`)
|
|
6117
|
+
if (!el.classList.contains('scrolling')) {
|
|
6118
|
+
el.classList.add('scrolling')
|
|
6119
|
+
}
|
|
6120
|
+
if (this.scrollTimeoutFn) {
|
|
6121
|
+
clearTimeout(this.scrollTimeoutFn)
|
|
6122
|
+
}
|
|
6123
|
+
this.scrollTimeoutFn = setTimeout(() => {
|
|
6124
|
+
el.classList.remove('scrolling')
|
|
6125
|
+
}, 200)
|
|
6126
|
+
if (this.vScrollRequired === false) {
|
|
6127
|
+
return
|
|
6128
|
+
}
|
|
6071
6129
|
const scrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
|
|
6072
6130
|
const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
6073
6131
|
let handlePos
|
|
@@ -7019,7 +7077,7 @@ bars
|
|
|
7019
7077
|
.attr('x', getBarX.bind(this))
|
|
7020
7078
|
.attr('y', getBarY.bind(this))
|
|
7021
7079
|
.transition(this.transition)
|
|
7022
|
-
.attr('fill', d => d.color || series.color)
|
|
7080
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7023
7081
|
|
|
7024
7082
|
bars
|
|
7025
7083
|
.enter()
|
|
@@ -7029,7 +7087,7 @@ bars
|
|
|
7029
7087
|
.attr('x', getBarX.bind(this))
|
|
7030
7088
|
.attr('y', getBarY.bind(this))
|
|
7031
7089
|
// .transition(this.transition)
|
|
7032
|
-
.attr('fill', d => d.color || series.color)
|
|
7090
|
+
.attr('fill', d => d.y.color || d.color || series.color)
|
|
7033
7091
|
.attr('class', d => {
|
|
7034
7092
|
return `bar bar_${series.key}`
|
|
7035
7093
|
})
|
|
@@ -7044,7 +7102,7 @@ if (this.options.orientation === 'horizontal') {
|
|
|
7044
7102
|
xAxis = 'leftAxis'
|
|
7045
7103
|
yAxis = 'bottomAxis'
|
|
7046
7104
|
}
|
|
7047
|
-
if (this.options.showLabels) {
|
|
7105
|
+
if (this.options.showLabels === true || series.showLabels === true) {
|
|
7048
7106
|
// need to add logic to handle positioning options
|
|
7049
7107
|
// e.g. Inside, Outide, Auto (this will also affect the available plot space)
|
|
7050
7108
|
// We currently only support 'Auto'
|
|
@@ -7058,10 +7116,35 @@ if (this.options.showLabels) {
|
|
|
7058
7116
|
.attr('x', getLabelX.bind(this))
|
|
7059
7117
|
.attr('y', getLabelY.bind(this))
|
|
7060
7118
|
.attr('class', `label_${series.key}`)
|
|
7061
|
-
.
|
|
7062
|
-
.style('
|
|
7119
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7120
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7063
7121
|
.transition(this.transition)
|
|
7064
7122
|
.text(d => d.y.label || d.y.value)
|
|
7123
|
+
.each(function (d, i) {
|
|
7124
|
+
if (that.options.orientation === 'horizontal') {
|
|
7125
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
7126
|
+
this.setAttribute('text-anchor', 'middle')
|
|
7127
|
+
}
|
|
7128
|
+
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7129
|
+
this.setAttribute('text-anchor', 'end')
|
|
7130
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7131
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7132
|
+
}
|
|
7133
|
+
else if (series.labelPosition === 'outside') {
|
|
7134
|
+
this.setAttribute('text-anchor', 'start')
|
|
7135
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
7136
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7137
|
+
}
|
|
7138
|
+
else {
|
|
7139
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7140
|
+
}
|
|
7141
|
+
}
|
|
7142
|
+
else {
|
|
7143
|
+
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
7144
|
+
this.setAttribute('y', +(this.getAttribute('y')) + 8)
|
|
7145
|
+
}
|
|
7146
|
+
}
|
|
7147
|
+
})
|
|
7065
7148
|
|
|
7066
7149
|
labels
|
|
7067
7150
|
.enter()
|
|
@@ -7071,18 +7154,27 @@ if (this.options.showLabels) {
|
|
|
7071
7154
|
.attr('y', getLabelY.bind(this))
|
|
7072
7155
|
.attr('alignment-baseline', 'central')
|
|
7073
7156
|
.attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
|
|
7074
|
-
.
|
|
7075
|
-
.style('
|
|
7157
|
+
.attr('fill', d => this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7158
|
+
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7076
7159
|
.text(d => d.y.label || d.y.value)
|
|
7077
7160
|
.each(function (d, i) {
|
|
7078
7161
|
if (that.options.orientation === 'horizontal') {
|
|
7079
|
-
if (that.options.grouping === 'stacked') {
|
|
7162
|
+
if (that.options.grouping === 'stacked' && series.labelPosition !== 'outside') {
|
|
7080
7163
|
this.setAttribute('text-anchor', 'middle')
|
|
7081
7164
|
}
|
|
7082
7165
|
else if (that.plotWidth - getLabelX.call(that, d) < this.getComputedTextLength()) {
|
|
7083
7166
|
this.setAttribute('text-anchor', 'end')
|
|
7084
|
-
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7167
|
+
this.setAttribute('x', +(this.getAttribute('x')) - 8)
|
|
7168
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color))
|
|
7085
7169
|
}
|
|
7170
|
+
else if (series.labelPosition === 'outside') {
|
|
7171
|
+
this.setAttribute('text-anchor', 'start')
|
|
7172
|
+
this.setAttribute('x', +(this.getAttribute('x')) + 8)
|
|
7173
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7174
|
+
}
|
|
7175
|
+
else {
|
|
7176
|
+
this.setAttribute('fill', that.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark('#ffffff'))
|
|
7177
|
+
}
|
|
7086
7178
|
}
|
|
7087
7179
|
else {
|
|
7088
7180
|
if (that.plotheight - getLabelX.call(that, d) < (that.options.labelSize || that.options.fontSize)) {
|
|
@@ -7092,10 +7184,10 @@ if (this.options.showLabels) {
|
|
|
7092
7184
|
})
|
|
7093
7185
|
}
|
|
7094
7186
|
|
|
7095
|
-
function getLabelX (d) {
|
|
7187
|
+
function getLabelX (d, labelPosition = 'inside') {
|
|
7096
7188
|
if (this.options.orientation === 'horizontal') {
|
|
7097
7189
|
if (this.options.grouping === 'stacked') {
|
|
7098
|
-
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / 2)
|
|
7190
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
7099
7191
|
}
|
|
7100
7192
|
else {
|
|
7101
7193
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4
|
|
@@ -7105,13 +7197,13 @@ function getLabelX (d) {
|
|
|
7105
7197
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
7106
7198
|
}
|
|
7107
7199
|
}
|
|
7108
|
-
function getLabelY (d) {
|
|
7200
|
+
function getLabelY (d, labelPosition = 'inside') {
|
|
7109
7201
|
if (this.options.orientation === 'horizontal') {
|
|
7110
7202
|
return this[xAxis](this.parseX(d.x.value)) + (this[xAxis].bandwidth() / 2)
|
|
7111
7203
|
}
|
|
7112
7204
|
else {
|
|
7113
7205
|
if (this.options.grouping === 'stacked') {
|
|
7114
|
-
|
|
7206
|
+
return this[yAxis](d.y.accumulative) + (this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1))
|
|
7115
7207
|
}
|
|
7116
7208
|
else {
|
|
7117
7209
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) - 4
|