Skip to content

Commit cd8d509

Browse files
authored
feat(datetime): add disabled part (#28134)
1 parent 79b005d commit cd8d509

21 files changed

+18
-1
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ ion-datetime,css-prop,--wheel-fade-background-rgb
430430
ion-datetime,css-prop,--wheel-highlight-background
431431
ion-datetime,part,calendar-day
432432
ion-datetime,part,calendar-day active
433+
ion-datetime,part,calendar-day disabled
433434
ion-datetime,part,calendar-day today
434435
ion-datetime,part,month-year-button
435436
ion-datetime,part,time-button

core/src/components/datetime/datetime.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {
9090
* calendar.
9191
* @part calendar-day active - The currently selected calendar day.
9292
* @part calendar-day today - The calendar day that contains the current day.
93+
* @part calendar-day disabled - The calendar day that is disabled.
9394
*/
9495
@Component({
9596
tag: 'ion-datetime',
@@ -2126,7 +2127,9 @@ export class Datetime implements ComponentInterface {
21262127
// "Filler days" at the beginning of the grid should not get the calendar day
21272128
// CSS parts added to them
21282129
if (!isCalendarPadding) {
2129-
dateParts = `calendar-day${isActive ? ' active' : ''}${isToday ? ' today' : ''}`;
2130+
dateParts = `calendar-day${isActive ? ' active' : ''}${isToday ? ' today' : ''}${
2131+
isCalDayDisabled ? ' disabled' : ''
2132+
}`;
21302133
}
21312134

21322135
return (

core/src/components/datetime/test/custom/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
box-shadow: 0px 0px 0px 4px rgb(154 209 98 / 0.2);
100100
}
101101

102+
#custom-calendar-days::part(calendar-day disabled) {
103+
background: rgba(0 0 0 / 0.2);
104+
color: black;
105+
}
106+
102107
/*
103108
* Custom Material Design Datetime Day Parts
104109
* -------------------------------------------
@@ -190,6 +195,14 @@ <h2>Grid Style</h2>
190195
backgroundColor: 'lightblue',
191196
},
192197
];
198+
199+
customDatetime.isDateEnabled = (date) => {
200+
if (date === '2023-06-22') {
201+
return false;
202+
}
203+
204+
return true;
205+
};
193206
</script>
194207
</body>
195208
</html>

0 commit comments

Comments
 (0)