@websy/websy-designs 1.2.17 → 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.
@@ -396,7 +396,7 @@ class WebsyDatePicker {
396
396
  }
397
397
  else {
398
398
  if (this.options.mode === 'hour') {
399
- let hoursOut = this.selectedRangeDates.map(h => this.options.hours[h])
399
+ let hoursOut = this.currentselection.map(h => this.options.hours[h])
400
400
  this.options.onChange(hoursOut, true)
401
401
  }
402
402
  else {
@@ -948,20 +948,44 @@ class WebsyDatePicker {
948
948
  this.close(confirm)
949
949
  }
950
950
  }
951
- selectCustomRange (range) {
951
+ selectCustomRange (rangeInput) {
952
952
  this.selectedRange = -1
953
- this.selectedRangeDates = range
954
- this.currentselection = []
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
+ }
955
979
  // check if the custom range matches a configured range
956
980
  for (let i = 0; i < this.options.ranges[this.options.mode].length; i++) {
957
981
  if (this.options.ranges[this.options.mode][i].range.length === 1) {
958
- 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]) {
959
983
  this.selectedRange = i
960
984
  break
961
985
  }
962
986
  }
963
987
  else if (this.options.ranges[this.options.mode][i].range.length === 2) {
964
- 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]) {
965
989
  this.selectedRange = i
966
990
  break
967
991
  }
@@ -1019,6 +1043,7 @@ class WebsyDatePicker {
1019
1043
  if (this.customRangeSelected === true) {
1020
1044
  end = ` - ${list[list.length - 1]}`
1021
1045
  if (this.options.mode === 'hour') {
1046
+ start = this.options.hours[start].text
1022
1047
  end = `${this.customRangeSelected === true ? ' - ' : ''}${this.options.hours[list[list.length - 1]].text}`
1023
1048
  }
1024
1049
  }