@websy/websy-designs 1.2.13 → 1.2.15

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.
@@ -206,10 +206,11 @@ class WebsyDatePicker {
206
206
  this.validDates = []
207
207
  this.validYears = []
208
208
  this.validHours = []
209
- this.customRangeSelected = true
209
+ this.customRangeSelected = true
210
210
  this.shiftPressed = false
211
211
  const DEFAULTS = {
212
212
  defaultRange: 0,
213
+ dateFormat: '%_m/%_d/%Y',
213
214
  allowClear: true,
214
215
  hideRanges: false,
215
216
  minAllowedDate: this.floorDate(new Date(new Date((new Date().setFullYear(new Date().getFullYear() - 1))).setDate(1))),
@@ -380,9 +381,7 @@ class WebsyDatePicker {
380
381
  maskEl.classList.remove('active')
381
382
  contentEl.classList.remove('active')
382
383
  if (confirm === true) {
383
- if (this.options.onChange) {
384
- console.log('confirm', this.selectedRangeDates)
385
- console.log('confirm', this.currentselection)
384
+ if (this.options.onChange) {
386
385
  if (this.customRangeSelected === true) {
387
386
  if (this.options.mode === 'hour') {
388
387
  let hoursOut = []
@@ -408,10 +407,10 @@ class WebsyDatePicker {
408
407
  this.updateRange()
409
408
  }
410
409
  else {
411
- this.selectedRangeDates = [...this.priorSelectedDates]
410
+ this.selectedRangeDates = [...(this.priorSelectedDates || [])]
412
411
  this.selectedRange = this.priorSelectedRange
413
412
  this.customRangeSelected = this.priorCustomRangeSelected
414
- this.currentselection = [...this.priorselection]
413
+ this.currentselection = [...(this.priorselection || [])]
415
414
  this.highlightRange()
416
415
  }
417
416
  }
@@ -533,9 +532,7 @@ class WebsyDatePicker {
533
532
  }
534
533
  else if (this.options.mode === 'monthyear') {
535
534
  let yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12
536
- diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
537
- console.log('year diff', yearDiff)
538
- console.log('diff', diff)
535
+ diff = Math.floor((this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth())) + yearDiff
539
536
  }
540
537
  else if (this.options.mode === 'hour') {
541
538
  diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0]
@@ -572,10 +569,7 @@ class WebsyDatePicker {
572
569
  else if (this.options.mode === 'year') {
573
570
  dateEl = document.getElementById(`${this.elementId}_${d}_year`)
574
571
  }
575
- else if (this.options.mode === 'monthyear') {
576
- console.log('d', d)
577
- console.log(this.selectedRangeDates)
578
- console.log(rangeStart, rangeEnd)
572
+ else if (this.options.mode === 'monthyear') {
579
573
  dateEl = document.getElementById(`${this.elementId}_${d}_monthyear`)
580
574
  }
581
575
  else if (this.options.mode === 'hour') {
@@ -904,8 +898,7 @@ class WebsyDatePicker {
904
898
  else {
905
899
  this.currentselection.splice(0, 0, timestamp)
906
900
  }
907
- this.customRangeSelected = true
908
- console.log('current selection', this.currentselection)
901
+ this.customRangeSelected = true
909
902
  }
910
903
  else {
911
904
  let index = this.currentselection.indexOf(timestamp)
@@ -920,8 +913,7 @@ class WebsyDatePicker {
920
913
  }
921
914
  }
922
915
  if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
923
- this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])]
924
- console.log('selected range', this.selectedRangeDates)
916
+ this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])]
925
917
  }
926
918
  else if (this.options.mode === 'year') {
927
919
  this.selectedRangeDates = [this.currentselection[0], this.currentselection[1] || this.currentselection[0]]
@@ -283,6 +283,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
283
283
  this.shiftPressed = false;
284
284
  var DEFAULTS = {
285
285
  defaultRange: 0,
286
+ dateFormat: '%_m/%_d/%Y',
286
287
  allowClear: true,
287
288
  hideRanges: false,
288
289
  minAllowedDate: this.floorDate(new Date(new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setDate(1))),
@@ -422,9 +423,6 @@ var WebsyDatePicker = /*#__PURE__*/function () {
422
423
 
423
424
  if (confirm === true) {
424
425
  if (this.options.onChange) {
425
- console.log('confirm', this.selectedRangeDates);
426
- console.log('confirm', this.currentselection);
427
-
428
426
  if (this.customRangeSelected === true) {
429
427
  if (this.options.mode === 'hour') {
430
428
  var hoursOut = [];
@@ -452,10 +450,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
452
450
 
453
451
  this.updateRange();
454
452
  } else {
455
- this.selectedRangeDates = _toConsumableArray(this.priorSelectedDates);
453
+ this.selectedRangeDates = _toConsumableArray(this.priorSelectedDates || []);
456
454
  this.selectedRange = this.priorSelectedRange;
457
455
  this.customRangeSelected = this.priorCustomRangeSelected;
458
- this.currentselection = _toConsumableArray(this.priorselection);
456
+ this.currentselection = _toConsumableArray(this.priorselection || []);
459
457
  this.highlightRange();
460
458
  }
461
459
  }
@@ -597,8 +595,6 @@ var WebsyDatePicker = /*#__PURE__*/function () {
597
595
  } else if (this.options.mode === 'monthyear') {
598
596
  var yearDiff = (this.selectedRangeDates[this.selectedRangeDates.length - 1].getFullYear() - this.selectedRangeDates[0].getFullYear()) * 12;
599
597
  diff = Math.floor(this.selectedRangeDates[this.selectedRangeDates.length - 1].getMonth() - this.selectedRangeDates[0].getMonth()) + yearDiff;
600
- console.log('year diff', yearDiff);
601
- console.log('diff', diff);
602
598
  } else if (this.options.mode === 'hour') {
603
599
  diff = this.selectedRangeDates[this.selectedRangeDates.length - 1] - this.selectedRangeDates[0];
604
600
  }
@@ -634,9 +630,6 @@ var WebsyDatePicker = /*#__PURE__*/function () {
634
630
  } else if (this.options.mode === 'year') {
635
631
  dateEl = document.getElementById("".concat(this.elementId, "_").concat(d, "_year"));
636
632
  } else if (this.options.mode === 'monthyear') {
637
- console.log('d', d);
638
- console.log(this.selectedRangeDates);
639
- console.log(rangeStart, rangeEnd);
640
633
  dateEl = document.getElementById("".concat(this.elementId, "_").concat(d, "_monthyear"));
641
634
  } else if (this.options.mode === 'hour') {
642
635
  dateEl = document.getElementById("".concat(this.elementId, "_").concat(d, "_hour"));
@@ -1004,7 +997,6 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1004
997
  }
1005
998
 
1006
999
  this.customRangeSelected = true;
1007
- console.log('current selection', this.currentselection);
1008
1000
  } else {
1009
1001
  var index = this.currentselection.indexOf(timestamp);
1010
1002
 
@@ -1023,7 +1015,6 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1023
1015
 
1024
1016
  if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
1025
1017
  this.selectedRangeDates = [new Date(this.currentselection[0]), new Date(this.currentselection[1] || this.currentselection[0])];
1026
- console.log('selected range', this.selectedRangeDates);
1027
1018
  } else if (this.options.mode === 'year') {
1028
1019
  this.selectedRangeDates = [this.currentselection[0], this.currentselection[1] || this.currentselection[0]];
1029
1020
  } else if (this.options.mode === 'monthyear') {//