MCPcopy Create free account
hub / github.com/adobe/react-spectrum / constrainStart

Function constrainStart

packages/react-stately/src/calendar/utils.ts:97–120  ·  view source on GitHub ↗
(
  date: CalendarDate,
  aligned: CalendarDate,
  duration: DateDuration,
  locale: string,
  minValue?: DateValue | null,
  maxValue?: DateValue | null
)

Source from the content-addressed store, hash-verified

95}
96
97export function constrainStart(
98 date: CalendarDate,
99 aligned: CalendarDate,
100 duration: DateDuration,
101 locale: string,
102 minValue?: DateValue | null,
103 maxValue?: DateValue | null
104): CalendarDate {
105 if (minValue && date.compare(minValue) >= 0) {
106 let newDate = maxDate(aligned, alignStart(toCalendarDate(minValue), duration, locale));
107 if (newDate) {
108 aligned = newDate;
109 }
110 }
111
112 if (maxValue && date.compare(maxValue) <= 0) {
113 let newDate = minDate(aligned, alignEnd(toCalendarDate(maxValue), duration, locale));
114 if (newDate) {
115 aligned = newDate;
116 }
117 }
118
119 return aligned;
120}
121
122export function constrainValue(
123 date: CalendarDate,

Callers 5

focusNextPageFunction · 0.90
focusPreviousPageFunction · 0.90
alignCenterFunction · 0.85
alignStartFunction · 0.85
alignEndFunction · 0.85

Calls 6

maxDateFunction · 0.90
toCalendarDateFunction · 0.90
minDateFunction · 0.90
alignStartFunction · 0.85
alignEndFunction · 0.85
compareMethod · 0.45

Tested by

no test coverage detected