@react-stately/calendar 3.0.0-alpha.3 → 3.0.0-alpha.4

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.
package/src/utils.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import {
13
13
  CalendarDate,
14
- Duration,
14
+ DateDuration,
15
15
  maxDate,
16
16
  minDate,
17
17
  startOfMonth,
@@ -26,8 +26,8 @@ export function isInvalid(date: CalendarDate, minValue: DateValue, maxValue: Dat
26
26
  (maxValue != null && date.compare(maxValue) > 0);
27
27
  }
28
28
 
29
- export function alignCenter(date: CalendarDate, duration: Duration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
30
- let halfDuration: Duration = {};
29
+ export function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
30
+ let halfDuration: DateDuration = {};
31
31
  for (let key in duration) {
32
32
  halfDuration[key] = Math.floor(duration[key] / 2);
33
33
  if (halfDuration[key] > 0 && duration[key] % 2 === 0) {
@@ -39,7 +39,7 @@ export function alignCenter(date: CalendarDate, duration: Duration, locale: stri
39
39
  return constrainStart(date, aligned, duration, locale, minValue, maxValue);
40
40
  }
41
41
 
42
- export function alignStart(date: CalendarDate, duration: Duration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
42
+ export function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
43
43
  // align to the start of the largest unit
44
44
  let aligned = date;
45
45
  if (duration.years) {
@@ -53,7 +53,7 @@ export function alignStart(date: CalendarDate, duration: Duration, locale: strin
53
53
  return constrainStart(date, aligned, duration, locale, minValue, maxValue);
54
54
  }
55
55
 
56
- export function alignEnd(date: CalendarDate, duration: Duration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
56
+ export function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {
57
57
  let d = {...duration};
58
58
  // subtract 1 from the smallest unit
59
59
  if (duration.days) {
@@ -73,7 +73,7 @@ export function alignEnd(date: CalendarDate, duration: Duration, locale: string,
73
73
  export function constrainStart(
74
74
  date: CalendarDate,
75
75
  aligned: CalendarDate,
76
- duration: Duration,
76
+ duration: DateDuration,
77
77
  locale: string,
78
78
  minValue: DateValue,
79
79
  maxValue: DateValue) {