@websy/websy-designs 1.2.18 → 1.2.19

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.
@@ -948,22 +948,44 @@ class WebsyDatePicker {
948
948
  this.close(confirm)
949
949
  }
950
950
  }
951
- selectCustomRange (range, isRange = true) {
951
+ selectCustomRange (rangeInput) {
952
952
  this.selectedRange = -1
953
- this.selectedRangeDates = range
954
- if (isRange === true) {
955
- this.currentselection = []
956
- }
953
+ let isContinuousRange = true
954
+ if (rangeInput.length === 1) {
955
+ this.selectedRangeDates = [...rangeInput]
956
+ this.customRangeSelected = [...rangeInput]
957
+ }
958
+ else if (rangeInput.length === 2) {
959
+ this.selectedRangeDates = [...rangeInput]
960
+ this.customRangeSelected = [...rangeInput]
961
+ }
962
+ rangeInput.forEach((r, i) => {
963
+ if (i > 0) {
964
+ if (this.options.mode === 'date' || this.options.mode === 'monthyear') {
965
+ if ((r.getTime() / this.oneDay) - (rangeInput[i - 1] / this.oneDay) > 1) {
966
+ isContinuousRange = false
967
+ }
968
+ }
969
+ else if (this.options.mode === 'hour' || this.options.mode === 'year') {
970
+ if (r - rangeInput[i - 1] > 1) {
971
+ isContinuousRange = false
972
+ }
973
+ }
974
+ }
975
+ })
976
+ if (rangeInput.length > 2 && isContinuousRange === true) {
977
+ this.selectedRangeDates = [rangeInput[0], rangeInput[rangeInput.length - 1]]
978
+ }
957
979
  // check if the custom range matches a configured range
958
980
  for (let i = 0; i < this.options.ranges[this.options.mode].length; i++) {
959
981
  if (this.options.ranges[this.options.mode][i].range.length === 1) {
960
- if (this.options.ranges[this.options.mode][i].range[0] === range[0]) {
982
+ if (this.options.ranges[this.options.mode][i].range[0] === rangeInput[0]) {
961
983
  this.selectedRange = i
962
984
  break
963
985
  }
964
986
  }
965
987
  else if (this.options.ranges[this.options.mode][i].range.length === 2) {
966
- if (this.options.ranges[this.options.mode][i].range[0] === range[0] && this.options.ranges[this.options.mode][i].range[1] === range[1]) {
988
+ if (this.options.ranges[this.options.mode][i].range[0] === rangeInput[0] && this.options.ranges[this.options.mode][i].range[1] === rangeInput[1]) {
967
989
  this.selectedRange = i
968
990
  break
969
991
  }