@websy/websy-designs 1.2.12 → 1.2.14

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.
@@ -392,10 +392,11 @@ class WebsyDatePicker {
392
392
  this.validDates = []
393
393
  this.validYears = []
394
394
  this.validHours = []
395
- this.customRangeSelected = true
395
+ this.customRangeSelected = true
396
396
  this.shiftPressed = false
397
397
  const DEFAULTS = {
398
398
  defaultRange: 0,
399
+ dateFormat: '%_m/%_d/%Y',
399
400
  allowClear: true,
400
401
  hideRanges: false,
401
402
  minAllowedDate: this.floorDate(new Date(new Date((new Date().setFullYear(new Date().getFullYear() - 1))).setDate(1))),
@@ -594,10 +595,10 @@ class WebsyDatePicker {
594
595
  this.updateRange()
595
596
  }
596
597
  else {
597
- this.selectedRangeDates = [...this.priorSelectedDates]
598
+ this.selectedRangeDates = [...(this.priorSelectedDates || [])]
598
599
  this.selectedRange = this.priorSelectedRange
599
600
  this.customRangeSelected = this.priorCustomRangeSelected
600
- this.currentselection = [...this.priorselection]
601
+ this.currentselection = [...(this.priorselection || [])]
601
602
  this.highlightRange()
602
603
  }
603
604
  }
@@ -636,7 +637,10 @@ class WebsyDatePicker {
636
637
  this.close()
637
638
  }
638
639
  else if (event.target.classList.contains('clear-selection')) {
639
- this.selectRange(0)
640
+ this.selectRange(0, false)
641
+ if (this.options.onClear) {
642
+ this.options.onClear()
643
+ }
640
644
  this.updateRange(0)
641
645
  }
642
646
  }
@@ -1121,7 +1125,7 @@ class WebsyDatePicker {
1121
1125
  this.selectedRange = -1
1122
1126
  this.highlightRange()
1123
1127
  }
1124
- selectRange (index) {
1128
+ selectRange (index, confirm = true) {
1125
1129
  if (this.options.ranges[this.options.mode][index]) {
1126
1130
  this.selectedRangeDates = [...this.options.ranges[this.options.mode][index].range]
1127
1131
  this.currentselection = [...this.options.ranges[this.options.mode][index].range]
@@ -1136,7 +1140,7 @@ class WebsyDatePicker {
1136
1140
  }
1137
1141
  }
1138
1142
  this.highlightRange()
1139
- this.close(true)
1143
+ this.close(confirm)
1140
1144
  }
1141
1145
  }
1142
1146
  selectCustomRange (range) {
@@ -495,6 +495,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
495
495
  this.shiftPressed = false;
496
496
  var DEFAULTS = {
497
497
  defaultRange: 0,
498
+ dateFormat: '%_m/%_d/%Y',
498
499
  allowClear: true,
499
500
  hideRanges: false,
500
501
  minAllowedDate: this.floorDate(new Date(new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setDate(1))),
@@ -664,10 +665,10 @@ var WebsyDatePicker = /*#__PURE__*/function () {
664
665
 
665
666
  this.updateRange();
666
667
  } else {
667
- this.selectedRangeDates = _toConsumableArray(this.priorSelectedDates);
668
+ this.selectedRangeDates = _toConsumableArray(this.priorSelectedDates || []);
668
669
  this.selectedRange = this.priorSelectedRange;
669
670
  this.customRangeSelected = this.priorCustomRangeSelected;
670
- this.currentselection = _toConsumableArray(this.priorselection);
671
+ this.currentselection = _toConsumableArray(this.priorselection || []);
671
672
  this.highlightRange();
672
673
  }
673
674
  }
@@ -705,7 +706,12 @@ var WebsyDatePicker = /*#__PURE__*/function () {
705
706
  } else if (event.target.classList.contains('websy-dp-cancel')) {
706
707
  this.close();
707
708
  } else if (event.target.classList.contains('clear-selection')) {
708
- this.selectRange(0);
709
+ this.selectRange(0, false);
710
+
711
+ if (this.options.onClear) {
712
+ this.options.onClear();
713
+ }
714
+
709
715
  this.updateRange(0);
710
716
  }
711
717
  }
@@ -1247,6 +1253,8 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1247
1253
  }, {
1248
1254
  key: "selectRange",
1249
1255
  value: function selectRange(index) {
1256
+ var confirm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1257
+
1250
1258
  if (this.options.ranges[this.options.mode][index]) {
1251
1259
  this.selectedRangeDates = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
1252
1260
  this.currentselection = _toConsumableArray(this.options.ranges[this.options.mode][index].range);
@@ -1262,7 +1270,7 @@ var WebsyDatePicker = /*#__PURE__*/function () {
1262
1270
  }
1263
1271
 
1264
1272
  this.highlightRange();
1265
- this.close(true);
1273
+ this.close(confirm);
1266
1274
  }
1267
1275
  }
1268
1276
  }, {