@websy/websy-designs 1.2.4 → 1.2.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.
@@ -16,6 +16,7 @@
16
16
  WebsyLegend
17
17
  WebsyMap
18
18
  WebsyKPI
19
+ WebsyIcons
19
20
  WebsyPDFButton
20
21
  Switch
21
22
  WebsyTemplate
@@ -23,8 +24,9 @@
23
24
  ButtonGroup
24
25
  WebsyUtils
25
26
  Pager
27
+ ResponsiveText
26
28
  */
27
-
29
+ import WebsyDesignsQlikPlugins from '@websy/websy-designs-qlik-plugin/dist/websy-designs-qlik-plugin-es6'
28
30
  /* global XMLHttpRequest fetch ENV */
29
31
  class APIService {
30
32
  constructor (baseUrl = '', options = {}) {
@@ -213,6 +215,8 @@ class WebsyDatePicker {
213
215
  minAllowedYear: 1970,
214
216
  maxAllowedYear: new Date().getFullYear(),
215
217
  daysOfWeek: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
218
+ monthsOfYear: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
219
+ hours: new Array(24).fill(0).map((d, i) => (i < 10 ? '0' : '') + i + ':00'),
216
220
  mode: 'date',
217
221
  monthMap: {
218
222
  0: 'Jan',
@@ -278,7 +282,26 @@ class WebsyDatePicker {
278
282
  label: 'Last 10 Years',
279
283
  range: [new Date().getFullYear() - 9, DEFAULTS.maxAllowedYear]
280
284
  }
281
- ]
285
+ ],
286
+ monthyear: [
287
+ {
288
+ label: 'All',
289
+ range: [DEFAULTS.minAllowedDate, DEFAULTS.maxAllowedDate]
290
+ },
291
+ {
292
+ label: 'Last 12 Months',
293
+ range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 12))), this.floorDate(new Date(new Date().setDate(1)))]
294
+ },
295
+ {
296
+ label: 'Last 18 Months',
297
+ range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 18))), this.floorDate(new Date(new Date().setDate(1)))]
298
+ },
299
+ {
300
+ label: 'Last 24 Months',
301
+ range: [this.floorDate(new Date(new Date(new Date().setDate(1)).setMonth(new Date().getMonth() - 24))), this.floorDate(new Date(new Date().setDate(1)))]
302
+ }
303
+ ],
304
+ hour: []
282
305
  }
283
306
  this.options = Object.assign({}, DEFAULTS, options)
284
307
  this.selectedRange = this.options.defaultRange || 0
@@ -300,7 +323,7 @@ class WebsyDatePicker {
300
323
  document.addEventListener('keydown', this.handleKeyDown.bind(this))
301
324
  document.addEventListener('keyup', this.handleKeyUp.bind(this))
302
325
  let html = `
303
- <div class='websy-date-picker-container'>
326
+ <div class='websy-date-picker-container ${this.options.mode}'>
304
327
  <span class='websy-dropdown-header-label'>${this.options.label || 'Date'}</span>
305
328
  <div id="${this.elementId}_header" class='websy-date-picker-header ${this.options.allowClear === true ? 'allow-clear' : ''}'>
306
329
  <span id='${this.elementId}_selectedRange'>${this.options.ranges[this.options.mode][this.selectedRange].label}</span>
@@ -351,6 +374,8 @@ class WebsyDatePicker {
351
374
  contentEl.classList.remove('active')
352
375
  if (confirm === true) {
353
376
  if (this.options.onChange) {
377
+ console.log('confirm', this.selectedRangeDates)
378
+ console.log('confirm', this.currentselection)
354
379
  if (this.customRangeSelected === true) {
355
380
  this.options.onChange(this.selectedRangeDates, true)
356
381
  }
@@ -420,7 +445,7 @@ class WebsyDatePicker {
420
445
  handleMouseDown (event) {
421
446
  if (this.shiftPressed === true && this.currentselection.length > 0) {
422
447
  this.mouseDownId = this.currentselection[this.currentselection.length - 1]
423
- this.selectDate(+event.target.id.split('_')[0])
448
+ this.selectDate(+event.target.id.split('_')[1])
424
449
  }
425
450
  else {
426
451
  this.mouseDown = true
@@ -433,7 +458,7 @@ class WebsyDatePicker {
433
458
  this.currentselection = []
434
459
  this.customRangeSelected = false
435
460
  }
436
- this.mouseDownId = +event.target.id.split('_')[0]
461
+ this.mouseDownId = +event.target.id.split('_')[1]
437
462
  this.selectDate(this.mouseDownId)
438
463
  }
439
464
  }
@@ -444,9 +469,9 @@ class WebsyDatePicker {
444
469
  if (event.target.classList.contains('websy-disabled-date')) {
445
470
  return
446
471
  }
447
- if (event.target.id.split('_')[0] !== this.mouseDownId) {
472
+ if (event.target.id.split('_')[1] !== this.mouseDownId) {
448
473
  this.dragging = true
449
- this.selectDate(+event.target.id.split('_')[0])
474
+ this.selectDate(+event.target.id.split('_')[1])
450
475
  }
451
476
  }
452
477
  }
@@ -468,7 +493,8 @@ class WebsyDatePicker {
468
493
  return
469
494
  }
470
495
  if (this.customRangeSelected === true) {
471
- console.log('if date selection', this.currentselection)
496
+ console.log('if date selection', this.currentselection)
497
+ console.log('if month selection', this.currentselection.map(d => new Date(d)))
472
498
  let diff
473
499
  if (this.options.mode === 'date') {
474
500
  diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime() - this.selectedRangeDates[0].getTime()) / this.oneDay)
@@ -482,6 +508,15 @@ class WebsyDatePicker {
482
508
  // diff += 1
483
509
  }
484
510
  }
511
+ else if (this.options.mode === 'monthyear') {
512
+ let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
513
+ diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
514
+ console.log('year diff', yearDiff)
515
+ console.log('diff', diff)
516
+ }
517
+ else if (this.options.mode === 'hour') {
518
+ //
519
+ }
485
520
  for (let i = 0; i < diff + 1; i++) {
486
521
  let d
487
522
  let rangeStart
@@ -497,12 +532,29 @@ class WebsyDatePicker {
497
532
  rangeStart = this.selectedRangeDates[0]
498
533
  rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1]
499
534
  }
535
+ else if (this.options.mode === 'monthyear') {
536
+ d = new Date(this.selectedRangeDates[0].getTime()).setMonth(this.selectedRangeDates[0].getMonth() + i)
537
+ rangeStart = this.selectedRangeDates[0].getTime()
538
+ rangeEnd = this.selectedRangeDates[this.selectedRangeDates.length - 1].getTime()
539
+ }
540
+ else if (this.options.mode === 'hour') {
541
+ //
542
+ }
500
543
  let dateEl
501
544
  if (this.options.mode === 'date') {
502
- dateEl = document.getElementById(`${d}_date`)
545
+ dateEl = document.getElementById(`${this.elementId}_${d}_date`)
503
546
  }
504
547
  else if (this.options.mode === 'year') {
505
- dateEl = document.getElementById(`${d}_year`)
548
+ dateEl = document.getElementById(`${this.elementId}_${d}_year`)
549
+ }
550
+ else if (this.options.mode === 'monthyear') {
551
+ console.log('d', d)
552
+ console.log(this.selectedRangeDates)
553
+ console.log(rangeStart, rangeEnd)
554
+ dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
555
+ }
556
+ else if (this.options.mode === 'hour') {
557
+ //
506
558
  }
507
559
  if (dateEl) {
508
560
  dateEl.classList.add('selected')
@@ -519,10 +571,16 @@ class WebsyDatePicker {
519
571
  this.currentselection.forEach(d => {
520
572
  let dateEl
521
573
  if (this.options.mode === 'date') {
522
- dateEl = document.getElementById(`${d}_date`)
574
+ dateEl = document.getElementById(`${this.elementId}_${d}_date`)
523
575
  }
524
576
  else if (this.options.mode === 'year') {
525
- dateEl = document.getElementById(`${d}_year`)
577
+ dateEl = document.getElementById(`${this.elementId}_${d}_year`)
578
+ }
579
+ else if (this.options.mode === 'monthyear') {
580
+ dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
581
+ }
582
+ else if (this.options.mode === 'hour') {
583
+ //
526
584
  }
527
585
  dateEl.classList.add('selected')
528
586
  dateEl.classList.add('first')
@@ -564,6 +622,8 @@ class WebsyDatePicker {
564
622
  let disabled = []
565
623
  this.validDates = []
566
624
  this.validYears = []
625
+ this.monthYears = {}
626
+ this.monthYearMonths = []
567
627
  if (disabledDates) {
568
628
  disabled = disabledDates.map(d => {
569
629
  if (this.options.mode === 'date') {
@@ -572,6 +632,12 @@ class WebsyDatePicker {
572
632
  else if (this.options.mode === 'year') {
573
633
  return d
574
634
  }
635
+ else if (this.options.mode === 'monthyear') {
636
+ //
637
+ }
638
+ else if (this.options.mode === 'hour') {
639
+ //
640
+ }
575
641
  return d.getTime()
576
642
  })
577
643
  }
@@ -584,15 +650,34 @@ class WebsyDatePicker {
584
650
  else if (this.options.mode === 'year') {
585
651
  diff = (this.options.maxAllowedYear - this.options.minAllowedYear) + 1
586
652
  }
653
+ else if (this.options.mode === 'monthyear') {
654
+ diff = Math.ceil((this.options.maxAllowedDate.getTime() - this.options.minAllowedDate.getTime()) / this.oneDay) + 1
655
+ }
656
+ else if (this.options.mode === 'hour') {
657
+ //
658
+ }
587
659
  let months = {}
588
660
  let yearList = []
589
661
  for (let i = 0; i < diff; i++) {
590
- if (this.options.mode === 'date') {
662
+ if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
591
663
  let d = this.floorDate(new Date(this.options.minAllowedDate.getTime() + (i * this.oneDay)))
592
664
  let monthYear = `${this.options.monthMap[d.getMonth()]} ${d.getFullYear()}`
593
665
  if (!months[monthYear]) {
594
666
  months[monthYear] = []
595
667
  }
668
+ if (!this.monthYears[d.getFullYear()]) {
669
+ this.monthYears[d.getFullYear()] = []
670
+ }
671
+ if (this.monthYearMonths.indexOf(`${d.getMonth()}-${d.getFullYear()}`) === -1) {
672
+ this.monthYearMonths.push(`${d.getMonth()}-${d.getFullYear()}`)
673
+ this.monthYears[d.getFullYear()].push({
674
+ date: new Date(d.setDate(1)),
675
+ month: this.options.monthMap[d.getMonth()],
676
+ monthNum: d.getMonth(),
677
+ year: d.getFullYear(),
678
+ id: d.setDate(1)
679
+ })
680
+ }
596
681
  if (disabled.indexOf(d.getTime()) === -1) {
597
682
  this.validDates.push(d.getTime())
598
683
  }
@@ -605,11 +690,14 @@ class WebsyDatePicker {
605
690
  this.validYears.push(d)
606
691
  }
607
692
  }
693
+ else if (this.options.mode === 'hour') {
694
+ //
695
+ }
608
696
  }
609
697
  // check each range to see if it can be enabled
610
698
  for (let i = 0; i < this.options.ranges[this.options.mode].length; i++) {
611
699
  const r = this.options.ranges[this.options.mode][i]
612
- if (this.options.mode === 'date') {
700
+ if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
613
701
  // check the first date
614
702
  if (this.validDates.indexOf(r.range[0].getTime()) !== -1) {
615
703
  r.disabled = false
@@ -649,6 +737,12 @@ class WebsyDatePicker {
649
737
  }
650
738
  }
651
739
  }
740
+ }
741
+ else if (this.options.mode === 'monthyear') {
742
+ //
743
+ }
744
+ else if (this.options.mode === 'hour') {
745
+ //
652
746
  }
653
747
  }
654
748
  let html = ''
@@ -674,7 +768,7 @@ class WebsyDatePicker {
674
768
  }
675
769
  html += paddedDays.join('')
676
770
  }
677
- html += months[key].map(d => `<li id='${d.id}_date' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
771
+ html += months[key].map(d => `<li id='${this.elementId}_${d.id}_date' class='websy-dp-date ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.dayOfMonth}</li>`).join('')
678
772
  html += `
679
773
  </ul>
680
774
  </div>
@@ -687,8 +781,30 @@ class WebsyDatePicker {
687
781
  yearList.reverse()
688
782
  }
689
783
  html += `<div id='${this.elementId}_dateList' class='websy-dp-date-list'><ul>`
690
- html += yearList.map(d => `<li id='${d.id}_year' class='websy-dp-date websy-dp-year ${d.disabled === true ? 'websy-disabled-date' : ''}'>${d.year}</li>`).join('')
784
+ 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('')
691
785
  html += `</ul></div>`
786
+ }
787
+ else if (this.options.mode === 'monthyear') {
788
+ html += `<div id='${this.elementId}_dateList' class='websy-dp-monthyear-container'>`
789
+ for (const year in this.monthYears) {
790
+ html += `
791
+ <ul>
792
+ <li>${year}</li>
793
+ `
794
+ if (this.monthYears[year][0].monthNum > 0) {
795
+ let paddedMonths = []
796
+ for (let i = 0; i < this.monthYears[year][0].monthNum; i++) {
797
+ paddedMonths.push(`<li>&nbsp;</li>`)
798
+ }
799
+ html += paddedMonths.join('')
800
+ }
801
+ 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('')
802
+ html += `</ul>`
803
+ }
804
+ html += `</div>`
805
+ }
806
+ else if (this.options.mode === 'hour') {
807
+ //
692
808
  }
693
809
  return html
694
810
  }
@@ -701,16 +817,22 @@ class WebsyDatePicker {
701
817
  if (this.selectedRangeDates[0]) {
702
818
  let el
703
819
  if (this.options.mode === 'date') {
704
- el = document.getElementById(`${this.selectedRangeDates[0].getTime()}_date`)
820
+ el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[0].getTime()}_date`)
705
821
  }
706
822
  else if (this.options.mode === 'year') {
707
823
  if (this.options.sortDirection === 'desc') {
708
- el = document.getElementById(`${this.selectedRangeDates[this.selectedRangeDates.length - 1]}_year`)
824
+ el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[this.selectedRangeDates.length - 1]}_year`)
709
825
  }
710
826
  else {
711
- el = document.getElementById(`${this.selectedRangeDates[0]}_year`)
827
+ el = document.getElementById(`${this.elementId}_${this.selectedRangeDates[0]}_year`)
712
828
  }
713
829
  }
830
+ else if (this.options.mode === 'monthyear') {
831
+ //
832
+ }
833
+ else if (this.options.mode === 'hour') {
834
+ //
835
+ }
714
836
  const parentEl = document.getElementById(`${this.elementId}_dateList`)
715
837
  if (el && parentEl) {
716
838
  parentEl.scrollTo(0, el.offsetTop)
@@ -731,6 +853,7 @@ class WebsyDatePicker {
731
853
  this.currentselection.splice(0, 0, timestamp)
732
854
  }
733
855
  this.customRangeSelected = true
856
+ console.log('current selection', this.currentselection)
734
857
  }
735
858
  else {
736
859
  this.currentselection.push(timestamp)
@@ -738,12 +861,19 @@ class WebsyDatePicker {
738
861
  this.customRangeSelected = false
739
862
  }
740
863
  }
741
- if (this.options.mode === 'date') {
864
+ if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
742
865
  this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])]
866
+ console.log('selected range', this.selectedRangeDates)
743
867
  }
744
868
  else if (this.options.mode === 'year') {
745
869
  this.selectedRangeDates = [this.currentselection[0], this.currentselection[1] || this.currentselection[0]]
746
870
  }
871
+ else if (this.options.mode === 'monthyear') {
872
+ //
873
+ }
874
+ else if (this.options.mode === 'hour') {
875
+ //
876
+ }
747
877
  // if (this.currentselection.length === 2) {
748
878
  // this.currentselection = []
749
879
  // }
@@ -790,7 +920,7 @@ class WebsyDatePicker {
790
920
  this.updateRange()
791
921
  }
792
922
  setDateBounds (range) {
793
- if (['All Dates', 'All Years'].indexOf(this.options.ranges[this.options.mode][0].label) !== -1) {
923
+ if (['All Dates', 'All Years', 'All'].indexOf(this.options.ranges[this.options.mode][0].label) !== -1) {
794
924
  this.options.ranges[this.options.mode][0].range = [range[0], range[1] || range[0]]
795
925
  }
796
926
  if (this.options.mode === 'date') {
@@ -800,6 +930,13 @@ class WebsyDatePicker {
800
930
  else if (this.options.mode === 'year') {
801
931
  this.options.minAllowedYear = range[0]
802
932
  this.options.maxAllowedYear = range[1] || range[0]
933
+ }
934
+ else if (this.options.mode === 'monthyear') {
935
+ this.options.minAllowedDate = range[0]
936
+ this.options.maxAllowedDate = range[1] || range[0]
937
+ }
938
+ else if (this.options.mode === 'hour') {
939
+ //
803
940
  }
804
941
  }
805
942
  updateRange () {
@@ -815,6 +952,15 @@ class WebsyDatePicker {
815
952
  else if (this.options.mode === 'year') {
816
953
  return d
817
954
  }
955
+ else if (this.options.mode === 'monthyear') {
956
+ if (!d.getMonth) {
957
+ d = new Date(d)
958
+ }
959
+ return `${this.options.monthMap[d.getMonth()]} ${d.getFullYear()}`
960
+ }
961
+ else if (this.options.mode === 'hour') {
962
+ //
963
+ }
818
964
  })
819
965
  let start = list[0]
820
966
  let end = ''
@@ -861,7 +1007,8 @@ class WebsyDropdown {
861
1007
  disabled: false,
862
1008
  minSearchCharacters: 2,
863
1009
  showCompleteSelectedList: false,
864
- closeAfterSelection: true
1010
+ closeAfterSelection: true,
1011
+ customActions: []
865
1012
  }
866
1013
  this.options = Object.assign({}, DEFAULTS, options)
867
1014
  if (this.options.items.length > 0) {
@@ -887,7 +1034,7 @@ class WebsyDropdown {
887
1034
  const headerLabel = this.selectedItems.map(s => this.options.items[s].label || this.options.items[s].value).join(this.options.multiValueDelimiter)
888
1035
  const headerValue = this.selectedItems.map(s => this.options.items[s].value || this.options.items[s].label).join(this.options.multiValueDelimiter)
889
1036
  let html = `
890
- <div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style}'>
1037
+ <div id='${this.elementId}_container' class='websy-dropdown-container ${this.options.disabled ? 'disabled' : ''} ${this.options.disableSearch !== true ? 'with-search' : ''} ${this.options.style} ${this.options.customActions.length > 0 ? 'with-actions' : ''}'>
891
1038
  <div id='${this.elementId}_header' class='websy-dropdown-header ${this.selectedItems.length === 1 ? 'one-selected' : ''} ${this.options.allowClear === true ? 'allow-clear' : ''}'>
892
1039
  <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>
893
1040
  <span id='${this.elementId}_headerLabel' class='websy-dropdown-header-label'>${this.options.label}</span>
@@ -905,6 +1052,24 @@ class WebsyDropdown {
905
1052
  <div id='${this.elementId}_mask' class='websy-dropdown-mask'></div>
906
1053
  <div id='${this.elementId}_content' class='websy-dropdown-content'>
907
1054
  `
1055
+ if (this.options.customActions.length > 0) {
1056
+ html += `
1057
+ <div class='websy-dropdown-action-container'>
1058
+ <button class='websy-dropdown-action-button'>
1059
+ <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 512 512">><circle cx="256" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="416" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/><circle cx="96" cy="256" r="32" style="fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px"/></svg>
1060
+ </button>
1061
+ <ul id='${this.elementId}_actionContainer'>
1062
+ `
1063
+ this.options.customActions.forEach((a, i) => {
1064
+ html += `
1065
+ <li class='websy-dropdown-custom-action' data-index='${i}'>${a.label}</li>
1066
+ `
1067
+ })
1068
+ html += `
1069
+ </ul>
1070
+ </div>
1071
+ `
1072
+ }
908
1073
  if (this.options.disableSearch !== true) {
909
1074
  html += `
910
1075
  <input id='${this.elementId}_search' class='websy-dropdown-search' placeholder='${this.options.searchPlaceholder || 'Search'}'>
@@ -966,6 +1131,10 @@ class WebsyDropdown {
966
1131
  const maskEl = document.getElementById(`${this.elementId}_mask`)
967
1132
  const contentEl = document.getElementById(`${this.elementId}_content`)
968
1133
  const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
1134
+ const actionEl = document.getElementById(`${this.elementId}_actionContainer`)
1135
+ if (actionEl) {
1136
+ actionEl.classList.remove('active')
1137
+ }
969
1138
  const el = document.getElementById(this.elementId)
970
1139
  if (el) {
971
1140
  el.style.zIndex = ''
@@ -1006,6 +1175,18 @@ class WebsyDropdown {
1006
1175
  const el = document.getElementById(`${this.elementId}_container`)
1007
1176
  el.classList.toggle('search-open')
1008
1177
  }
1178
+ else if (event.target.classList.contains('websy-dropdown-custom-action')) {
1179
+ const actionIndex = +event.target.getAttribute('data-index')
1180
+ if (this.options.customActions[actionIndex] && this.options.customActions[actionIndex].fn) {
1181
+ this.options.customActions[actionIndex].fn()
1182
+ }
1183
+ }
1184
+ else if (event.target.classList.contains('websy-dropdown-action-button')) {
1185
+ const el = document.getElementById(`${this.elementId}_actionContainer`)
1186
+ if (el) {
1187
+ el.classList.toggle('active')
1188
+ }
1189
+ }
1009
1190
  }
1010
1191
  handleKeyUp (event) {
1011
1192
  if (event.target.classList.contains('websy-dropdown-search')) {
@@ -1518,6 +1699,46 @@ class WebsyForm {
1518
1699
  }
1519
1700
  }
1520
1701
 
1702
+ /* global include */
1703
+ const WebsyIcons = {
1704
+ 'search-icon': `
1705
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1706
+ viewBox="0 0 500 500" xml:space="preserve">
1707
+ <path d="M481.4,468.6c-17.2-17.2-34.4-34.4-51.6-51.6c-27.4-27.4-54.8-54.8-82.2-82.2c-4.8-4.8-9.5-9.5-14.3-14.3
1708
+ c29.4-32.5,47.4-75.5,47.4-122.7C380.7,97,298.7,15,197.9,15S15,97,15,197.9s82,182.9,182.9,182.9c47.2,0,90.3-18,122.7-47.4
1709
+ c15.7,15.7,31.4,31.4,47.1,47.1c27.4,27.4,54.8,54.8,82.2,82.2c6.3,6.3,12.5,12.5,18.8,18.8C476.8,489.6,489.6,476.8,481.4,468.6z
1710
+ M35,197.9C35,108.1,108.1,35,197.9,35s162.9,73.1,162.9,162.9s-73.1,162.9-162.9,162.9S35,287.7,35,197.9z"/>
1711
+ </svg>
1712
+
1713
+ `,
1714
+ 'bag-icon': `
1715
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1716
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
1717
+ <path d="M456.6,472.3H43.4c-5.3,0-10.2-2.1-13.7-6c-3.6-3.9-5.2-9.2-4.5-14.4l37-285.4c1.2-9,9-15.9,18.2-15.9h339.2
1718
+ c9.2,0,17,6.8,18.2,15.8l37,285.4c0.7,5.2-1,10.5-4.5,14.4l0,0C466.8,470.1,461.9,472.3,456.6,472.3z M46.5,451.2h407l-36.3-279.6
1719
+ H82.8L46.5,451.2z"/>
1720
+ <g>
1721
+ <path d="M361.3,157.1C357.3,94.8,308.4,46,249.9,46c-28,0-54.8,11.1-75.4,31.4c-20.7,20.3-33.5,47.9-35.9,77.8l-21.5-1.6
1722
+ c2.8-34.8,17.7-67.1,42.1-91C183.9,38.3,216.1,25,249.9,25c34.2,0,66.6,13.6,91.5,38.3c24.5,24.3,39.2,57.2,41.5,92.5L361.3,157.1z
1723
+ "/>
1724
+ </g>
1725
+ </svg>
1726
+
1727
+ `,
1728
+ 'user-icon': `
1729
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
1730
+ viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
1731
+ <g>
1732
+ <path d="M248,260.5c-62,0-112.5-52.8-112.5-117.7S186,25,248,25s112.5,52.8,112.5,117.7S310,260.5,248,260.5z M248,45.9
1733
+ c-51,0-92.5,43.4-92.5,96.8s41.5,96.8,92.5,96.8c51,0,92.5-43.4,92.5-96.8S299,45.9,248,45.9z"/>
1734
+ </g>
1735
+ <path d="M45,475C45,475,45,475,45,475c0-118.3,92-214.5,205-214.5c113,0,205,96.2,205,214.5c0,0,0,0,0,0h20c0,0,0,0,0,0
1736
+ c0-62.9-23.4-122-65.9-166.5c-42.5-44.5-99-69-159.1-69s-116.6,24.5-159.1,69C48.4,353,25,412.1,25,475c0,0,0,0,0,0H45z"/>
1737
+ </svg>
1738
+
1739
+ `
1740
+ }
1741
+
1521
1742
  class WebsyLoadingDialog {
1522
1743
  constructor (elementId, options) {
1523
1744
  this.options = Object.assign({}, options)
@@ -2141,6 +2362,250 @@ class WebsyPubSub {
2141
2362
  }
2142
2363
  }
2143
2364
 
2365
+ class ResponsiveText {
2366
+ constructor (elementId, options) {
2367
+ const DEFAULTS = {
2368
+ textAlign: 'center',
2369
+ verticalAlign: 'flex-end',
2370
+ wrapText: false
2371
+ }
2372
+ this.options = Object.assign({}, DEFAULTS, options)
2373
+ this.elementId = elementId
2374
+ this.canvas = document.createElement('canvas')
2375
+ window.addEventListener('resize', () => this.render())
2376
+ const el = document.getElementById(this.elementId)
2377
+ if (el) {
2378
+ this.render()
2379
+ }
2380
+ }
2381
+ css (element, property) {
2382
+ return window.getComputedStyle(element, null).getPropertyValue(property)
2383
+ }
2384
+ render (text) {
2385
+ if (typeof text !== 'undefined') {
2386
+ this.options.text = text
2387
+ }
2388
+ if (this.options.text) {
2389
+ let wrappingRequired = false
2390
+ const el = document.getElementById(this.elementId)
2391
+ let cx = this.canvas.getContext('2d')
2392
+ let f = 0
2393
+ let fits = false
2394
+ // let el = document.getElementById(`${layout.qInfo.qId}_responsiveInner`)
2395
+ let height = el.clientHeight
2396
+ if (typeof this.options.maxHeight === 'string' && this.options.maxHeight.indexOf('%') !== -1) {
2397
+ let p = +this.options.maxHeight.replace('%', '')
2398
+ if (!isNaN(p)) {
2399
+ this.options.maxHeight = Math.floor(height * (p / 100))
2400
+ }
2401
+ }
2402
+ else if (
2403
+ typeof this.options.maxHeight === 'string' &&
2404
+ this.options.maxHeight.indexOf('px') !== -1
2405
+ ) {
2406
+ this.options.maxHeight = +this.options.maxHeight.replace('px', '')
2407
+ }
2408
+ if (typeof this.options.minHeight === 'string' && this.options.minHeight.indexOf('%') !== -1) {
2409
+ let p = +this.options.minHeight.replace('%', '')
2410
+ if (!isNaN(p)) {
2411
+ this.options.minHeight = Math.floor(height * (p / 100))
2412
+ }
2413
+ }
2414
+ else if (
2415
+ typeof this.options.minHeight === 'string' &&
2416
+ this.options.minHeight.indexOf('px') !== -1
2417
+ ) {
2418
+ this.options.minHeight = +this.options.minHeight.replace('px', '')
2419
+ }
2420
+
2421
+ const fontFamily = this.css(el, 'font-family')
2422
+ const fontWeight = this.css(el, 'font-weight')
2423
+ let allowedWidth = el.clientWidth
2424
+ if (allowedWidth === 0) {
2425
+ // check for a max-width property
2426
+ if (
2427
+ el.style.maxWidth &&
2428
+ el.style.maxWidth !== 'auto'
2429
+ ) {
2430
+ if (el.parentElement.clientWidth > 0) {
2431
+ let calc = el.style.maxWidth
2432
+ if (calc.indexOf('calc') !== -1) {
2433
+ // this logic currently only handles calc statements using % and px
2434
+ // and only + or - formulas
2435
+ calc = calc.replace('calc(', '').replace(')', '')
2436
+ calc = calc.split(' ')
2437
+ if (calc[0].indexOf('px') !== -1) {
2438
+ allowedWidth = calc[0].replace('px', '')
2439
+ }
2440
+ else if (calc[0].indexOf('%') !== -1) {
2441
+ allowedWidth = el.parentElement.clientWidth * (+calc[0].replace('%', '') / 100)
2442
+ }
2443
+ if (calc[2] && calc[4]) {
2444
+ // this means we have an operator and a second value
2445
+ // handle -
2446
+ if (calc[2] === '-') {
2447
+ if (calc[4].indexOf('px') !== -1) {
2448
+ allowedWidth -= +calc[4].replace('px', '')
2449
+ }
2450
+ }
2451
+ if (calc[2] === '+') {
2452
+ if (calc[4].indexOf('px') !== -1) {
2453
+ allowedWidth += +calc[4].replace('px', '')
2454
+ }
2455
+ }
2456
+ }
2457
+ }
2458
+ else if (calc.indexOf('px') !== -1) {
2459
+ allowedWidth = +calc.replace('px', '')
2460
+ }
2461
+ else if (calc.indexOf('%') !== -1) {
2462
+ allowedWidth =
2463
+ el.parentElement.clientWidth *
2464
+ (+calc.replace('%', '') / 100)
2465
+ }
2466
+ }
2467
+ }
2468
+ }
2469
+ // console.log('max height', this.options.maxHeight);
2470
+ let innerElHeight = el.clientHeight
2471
+ while (fits === false) {
2472
+ f++
2473
+ cx.font = `${fontWeight} ${f}px ${fontFamily}`
2474
+ let measurements = cx.measureText(this.options.text)
2475
+ // add support for safari where some elements end up with zero height
2476
+ if (navigator.userAgent.indexOf('Safari') !== -1) {
2477
+ // get the closest parent that has a height
2478
+ let heightFound = false
2479
+ let currEl = el
2480
+ while (heightFound === false) {
2481
+ if (currEl.clientHeight > 0) {
2482
+ innerElHeight = currEl.clientHeight
2483
+ heightFound = true
2484
+ }
2485
+ else if (currEl.parentNode) {
2486
+ currEl = currEl.parentNode
2487
+ }
2488
+ else {
2489
+ // prevent the loop from running indefinitely
2490
+ heightFound = true
2491
+ }
2492
+ }
2493
+ }
2494
+ if (typeof this.options.maxHeight !== 'undefined' && f === this.options.maxHeight) {
2495
+ f = this.options.maxHeight
2496
+ height = measurements.actualBoundingBoxAscent
2497
+ fits = true
2498
+ }
2499
+ else if (
2500
+ measurements.width > allowedWidth ||
2501
+ measurements.actualBoundingBoxAscent >= innerElHeight
2502
+ ) {
2503
+ f--
2504
+ height = measurements.actualBoundingBoxAscent
2505
+ fits = true
2506
+ }
2507
+ }
2508
+ if (this.options.minHeight === '') {
2509
+ this.options.minHeight = undefined
2510
+ }
2511
+ if (typeof this.options.minHeight !== 'undefined') {
2512
+ if (this.options.minHeight > f && this.options.wrapText === true) {
2513
+ // we run the process again but this time separating the words onto separate lines
2514
+ // this currently only supports wrapping onto 2 lines
2515
+ wrappingRequired = true
2516
+ fits = false
2517
+ f = this.options.minHeight
2518
+ let spaceCount = this.options.text.match(/ /g)
2519
+ if (spaceCount && spaceCount.length > 0) {
2520
+ spaceCount = spaceCount.length
2521
+ let words = this.options.text.split(' ')
2522
+ while (fits === false) {
2523
+ f++
2524
+ cx.font = `${fontWeight} ${f}px ${fontFamily}`
2525
+ for (let i = spaceCount; i > 0; i--) {
2526
+ let fitsCount = 0
2527
+ let lines = [
2528
+ words.slice(0, i).join(' '),
2529
+ words.slice(i, words.length).join(' ')
2530
+ ]
2531
+ let longestLine = lines.reduce(
2532
+ (a, b) => (a.length > b.length ? a : b),
2533
+ ''
2534
+ )
2535
+ // lines.forEach(l => {
2536
+ let measurements = cx.measureText(longestLine)
2537
+ // add support for safari where some elements end up with zero height
2538
+ if (navigator.userAgent.indexOf('Safari') !== -1) {
2539
+ // get the closest parent that has a height
2540
+ let heightFound = false
2541
+ let currEl = el
2542
+ while (heightFound === false) {
2543
+ if (currEl.clientHeight > 0) {
2544
+ innerElHeight = currEl.clientHeight
2545
+ heightFound = true
2546
+ }
2547
+ else if (currEl.parentNode) {
2548
+ currEl = currEl.parentNode
2549
+ }
2550
+ else {
2551
+ // prevent the loop from running indefinitely
2552
+ heightFound = true
2553
+ }
2554
+ }
2555
+ }
2556
+ if (typeof this.options.maxHeight !== 'undefined' && f === this.options.maxHeight) {
2557
+ f = this.options.maxHeight
2558
+ height = measurements.actualBoundingBoxAscent
2559
+ fits = true
2560
+ break
2561
+ }
2562
+ else if (
2563
+ measurements.width > allowedWidth ||
2564
+ measurements.actualBoundingBoxAscent >=
2565
+ (innerElHeight / 2) * 0.75
2566
+ ) {
2567
+ f--
2568
+ height = measurements.actualBoundingBoxAscent
2569
+ fits = true
2570
+ break
2571
+ }
2572
+ // })
2573
+ }
2574
+ }
2575
+ }
2576
+ if (typeof this.options.minHeight !== 'undefined' && this.options.minHeight > f) {
2577
+ f = this.options.minHeight
2578
+ }
2579
+ }
2580
+ else if (this.options.minHeight > f) {
2581
+ f = this.options.minHeight
2582
+ }
2583
+ }
2584
+ let spanHeight = Math.min(innerElHeight, height)
2585
+ el.innerHTML = `
2586
+ <div
2587
+ class='websy-responsive-text'
2588
+ style='
2589
+ justify-content: ${this.options.verticalAlign};
2590
+ font-size: ${f}px;
2591
+ font-weight: ${fontWeight || 'normal'};
2592
+ '
2593
+ >
2594
+ <span
2595
+ style='
2596
+ white-space: ${this.options.wrapText === true ? 'normal' : 'nowrap'};
2597
+ height: ${Math.floor(wrappingRequired === true ? spanHeight * ((1 * 1) / 3) * 2 : spanHeight)}px;
2598
+ line-height: ${Math.ceil(wrappingRequired === true ? f * 1.2 : spanHeight)}px;
2599
+ justify-content: ${this.options.textAlign};
2600
+ text-align: ${this.options.textAlign};
2601
+ '
2602
+ >${this.options.text}</span>
2603
+ </div>
2604
+ `
2605
+ }
2606
+ }
2607
+ }
2608
+
2144
2609
  /* global WebsyDesigns */
2145
2610
  class WebsyResultList {
2146
2611
  constructor (elementId, options) {
@@ -3929,7 +4394,9 @@ class WebsyTable2 {
3929
4394
  handleGlobalMouseUp (event) {
3930
4395
  this.scrolling = false
3931
4396
  const el = document.getElementById(this.elementId)
3932
- el.classList.remove('scrolling')
4397
+ if (el) {
4398
+ el.classList.remove('scrolling')
4399
+ }
3933
4400
  }
3934
4401
  handleMouseUp (event) {
3935
4402
  this.scrolling = false
@@ -5649,7 +6116,7 @@ class WebsyMap {
5649
6116
  const el = document.getElementById(this.elementId)
5650
6117
  if (el) {
5651
6118
  if (typeof d3 === 'undefined') {
5652
- console.error('d3 library has not been loaded')
6119
+ // console.error('d3 library has not been loaded')
5653
6120
  }
5654
6121
  if (typeof L === 'undefined') {
5655
6122
  console.error('Leaflet library has not been loaded')
@@ -5935,7 +6402,12 @@ const WebsyDesigns = {
5935
6402
  ButtonGroup,
5936
6403
  WebsySwitch: Switch,
5937
6404
  Pager,
5938
- Switch
6405
+ Switch,
6406
+ ResponsiveText,
6407
+ WebsyResponsiveText: ResponsiveText,
6408
+ QlikPlugin: WebsyDesignsQlikPlugins,
6409
+ Icons: WebsyIcons,
6410
+ WebsyIcons
5939
6411
  }
5940
6412
 
5941
6413
  WebsyDesigns.service = new WebsyDesigns.APIService('')