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

Function alignStart

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

Source from the content-addressed store, hash-verified

52}
53
54export function alignStart(
55 date: CalendarDate,
56 duration: DateDuration,
57 locale: string,
58 minValue?: DateValue | null,
59 maxValue?: DateValue | null
60): CalendarDate {
61 // align to the start of the largest unit
62 let aligned = date;
63 if (duration.years) {
64 aligned = startOfYear(date);
65 } else if (duration.months) {
66 aligned = startOfMonth(date);
67 } else if (duration.weeks || (duration.days && duration.days > 7)) {
68 aligned = startOfWeek(date, locale);
69 }
70
71 return constrainStart(date, aligned, duration, locale, minValue, maxValue);
72}
73
74export function alignEnd(
75 date: CalendarDate,

Callers 7

getStartDateFunction · 0.90
useCalendarStateFunction · 0.90
focusNextPageFunction · 0.90
focusPreviousPageFunction · 0.90
alignCenterFunction · 0.85
alignEndFunction · 0.85
constrainStartFunction · 0.85

Calls 4

startOfYearFunction · 0.90
startOfMonthFunction · 0.90
startOfWeekFunction · 0.90
constrainStartFunction · 0.85

Tested by

no test coverage detected