MCPcopy
hub / github.com/ionic-team/ionic-framework / renderMonth

Method renderMonth

core/src/components/datetime/datetime.tsx:2308–2523  ·  view source on GitHub ↗
(month: number, year: number)

Source from the content-addressed store, hash-verified

2306 );
2307 }
2308 private renderMonth(month: number, year: number) {
2309 const { disabled, readonly } = this;
2310
2311 const yearAllowed = this.parsedYearValues === undefined || this.parsedYearValues.includes(year);
2312 const monthAllowed = this.parsedMonthValues === undefined || this.parsedMonthValues.includes(month);
2313 const isCalMonthDisabled = !yearAllowed || !monthAllowed;
2314 const isDatetimeDisabled = disabled || readonly;
2315 const swipeDisabled =
2316 disabled ||
2317 isMonthDisabled(
2318 {
2319 month,
2320 year,
2321 day: null,
2322 },
2323 {
2324 // The day is not used when checking if a month is disabled.
2325 // Users should be able to access the min or max month, even if the
2326 // min/max date is out of bounds (e.g. min is set to Feb 15, Feb should not be disabled).
2327 minParts: { ...this.minParts, day: null },
2328 maxParts: { ...this.maxParts, day: null },
2329 }
2330 );
2331 // The working month should never have swipe disabled.
2332 // Otherwise the CSS scroll snap will not work and the user
2333 // can free-scroll the calendar.
2334 const isWorkingMonth = this.workingParts.month === month && this.workingParts.year === year;
2335
2336 const activePart = this.getActivePartsWithFallback();
2337
2338 return (
2339 <div
2340 // Non-visible months should be hidden from screen readers
2341 aria-hidden={!isWorkingMonth ? 'true' : null}
2342 class={{
2343 'calendar-month': true,
2344 // Prevents scroll snap swipe gestures for months outside of the min/max bounds
2345 'calendar-month-disabled': !isWorkingMonth && swipeDisabled,
2346 }}
2347 >
2348 <div class="calendar-month-grid">
2349 {getDaysOfMonth(month, year, this.firstDayOfWeek % 7, this.showAdjacentDays).map((dateObject, index) => {
2350 const { day, dayOfWeek, isAdjacentDay } = dateObject;
2351 const { el, highlightedDates, isDateEnabled, multiple, showAdjacentDays } = this;
2352 let _month = month;
2353 let _year = year;
2354 if (showAdjacentDays && isAdjacentDay && day !== null) {
2355 if (day > 20) {
2356 // Leading with the adjacent day from the previous month
2357 // if its a adjacent day and is higher than '20' (last week even in feb)
2358 if (month === 1) {
2359 _year = year - 1;
2360 _month = 12;
2361 } else {
2362 _month = month - 1;
2363 }
2364 } else if (day < 15) {
2365 // Leading with the adjacent day from the next month

Callers 1

renderCalendarBodyMethod · 0.95

Calls 7

confirmMethod · 0.95
isMonthDisabledFunction · 0.90
getDaysOfMonthFunction · 0.90
getCalendarDayStateFunction · 0.90
convertDataToISOFunction · 0.90
printIonErrorFunction · 0.90
getHighlightStylesFunction · 0.90

Tested by

no test coverage detected