@@ -2193,7 +2193,7 @@ export class Datetime implements ComponentInterface {
21932193 </ div >
21942194 ) ;
21952195 }
2196- private renderMonth ( month : number , year : number ) {
2196+ private renderMonth ( month : number , year : number , theme : Theme ) {
21972197 const { disabled, readonly } = this ;
21982198
21992199 const yearAllowed = this . parsedYearValues === undefined || this . parsedYearValues . includes ( year ) ;
@@ -2234,10 +2234,35 @@ export class Datetime implements ComponentInterface {
22342234 } }
22352235 >
22362236 < div class = "calendar-month-grid" >
2237- { getDaysOfMonth ( month , year , this . firstDayOfWeek % 7 ) . map ( ( dateObject , index ) => {
2238- const { day, dayOfWeek } = dateObject ;
2237+ { getDaysOfMonth ( month , year , this . firstDayOfWeek % 7 , theme === 'ionic' ) . map ( ( dateObject , index ) => {
2238+ const { day, dayOfWeek, hiddenDay } = dateObject ;
22392239 const { el, highlightedDates, isDateEnabled, multiple } = this ;
2240- const referenceParts = { month, day, year } ;
2240+ let _month = month ;
2241+ let _year = year ;
2242+
2243+ if ( theme === 'ionic' ) {
2244+ if ( hiddenDay && day !== null && day > 20 ) {
2245+ // Leading with the hidden day from the previous month
2246+ // if its a hidden day and is higher than '20' (last week even in feb)
2247+ if ( month === 1 ) {
2248+ _year = year - 1 ;
2249+ _month = 12 ;
2250+ } else {
2251+ _month = month - 1 ;
2252+ }
2253+ } else if ( hiddenDay && day !== null && day < 15 ) {
2254+ // Leading with the hidden day from the next month
2255+ // if its a hidden day and is lower than '15' (first two weeks)
2256+ if ( month === 12 ) {
2257+ _year = year + 1 ;
2258+ _month = 1 ;
2259+ } else {
2260+ _month = month + 1 ;
2261+ }
2262+ }
2263+ }
2264+
2265+ const referenceParts = { month :_month , day, year :_year } ;
22412266 const isCalendarPadding = day === null ;
22422267 const {
22432268 isActive,
@@ -2258,7 +2283,7 @@ export class Datetime implements ComponentInterface {
22582283
22592284 const dateIsoString = convertDataToISO ( referenceParts ) ;
22602285
2261- let isCalDayDisabled = isCalMonthDisabled || isDayDisabled ;
2286+ let isCalDayDisabled = isCalMonthDisabled || isDayDisabled || hiddenDay ;
22622287
22632288 if ( ! isCalDayDisabled && isDateEnabled !== undefined ) {
22642289 try {
@@ -2292,7 +2317,7 @@ export class Datetime implements ComponentInterface {
22922317 * Custom highlight styles should not override the style for selected dates,
22932318 * nor apply to "filler days" at the start of the grid.
22942319 */
2295- if ( highlightedDates !== undefined && ! isActive && day !== null ) {
2320+ if ( highlightedDates !== undefined && ! isActive && day !== null && ! hiddenDay ) {
22962321 dateStyle = getHighlightStyles ( highlightedDates , dateIsoString , el ) ;
22972322 }
22982323
@@ -2327,8 +2352,8 @@ export class Datetime implements ComponentInterface {
23272352 } }
23282353 tabindex = "-1"
23292354 data-day = { day }
2330- data-month = { month }
2331- data-year = { year }
2355+ data-month = { _month }
2356+ data-year = { _year }
23322357 data-index = { index }
23332358 data-day-of-week = { dayOfWeek }
23342359 disabled = { isButtonDisabled }
@@ -2384,11 +2409,11 @@ export class Datetime implements ComponentInterface {
23842409 </ div >
23852410 ) ;
23862411 }
2387- private renderCalendarBody ( ) {
2412+ private renderCalendarBody ( theme : Theme ) {
23882413 return (
23892414 < div class = "calendar-body ion-focusable" ref = { ( el ) => ( this . calendarBodyRef = el ) } tabindex = "0" >
23902415 { generateMonths ( this . workingParts , this . forceRenderDate ) . map ( ( { month, year } ) => {
2391- return this . renderMonth ( month , year ) ;
2416+ return this . renderMonth ( month , year , theme ) ;
23922417 } ) }
23932418 </ div >
23942419 ) ;
@@ -2397,7 +2422,7 @@ export class Datetime implements ComponentInterface {
23972422 return (
23982423 < div class = "datetime-calendar" key = "datetime-calendar" >
23992424 { this . renderCalendarHeader ( theme ) }
2400- { this . renderCalendarBody ( ) }
2425+ { this . renderCalendarBody ( theme ) }
24012426 </ div >
24022427 ) ;
24032428 }
0 commit comments