@@ -6,6 +6,9 @@ component Ui.Calendar {
66 /* The change event handler. */
77 property onChange : Function (Time , Promise (Never , Void )) = Promise .never1
88
9+ /* The days to highlight as selected. */
10+ property selectedDays : Set (Time ) = Set .empty ()
11+
912 /* Whether or not to trigger the `onMonthChange` event if clicking on a day in an other month. */
1013 property changeMonthOnSelect : Bool = false
1114
@@ -24,6 +27,9 @@ component Ui.Calendar {
2427 /* Whether or not the component is disabled. */
2528 property disabled : Bool = false
2629
30+ /* Whether or not the component is readonly. */
31+ property readonly : Bool = false
32+
2733 /* Styles for the base. */
2834 style base {
2935 -moz-user-select : none ;
@@ -53,6 +59,8 @@ component Ui.Calendar {
5359 /* Style for the table. */
5460 style table {
5561 grid-template-columns : repeat (7 , 1fr );
62+ justify-items : center ;
63+ align-items : center ;
5664 grid-gap : 0.3125em ;
5765 display : grid ;
5866 width : 100% ;
@@ -88,7 +96,7 @@ component Ui.Calendar {
8896
8997 /* Style for the day names. */
9098 style dayNames {
91- justify-content : space-between ;
99+ justify-content : space-around ;
92100 white-space : nowrap ;
93101 display : flex ;
94102 line-height : 1 ;
@@ -185,11 +193,30 @@ component Ui.Calendar {
185193 }
186194
187195 for (cell of actualDays ) {
188- <Ui .Calendar .Cell
189- active = {Array .any ((item : Time ) : Bool { cell == item }, range )}
190- onClick = {handleCellClick }
191- selected = {day == cell }
192- day = {cell }/>
196+ try {
197+ normalizedDay =
198+ Time .startOf ("day" , day )
199+
200+ normalizedCell =
201+ Time .startOf ("day" , cell )
202+
203+ normalizedDays =
204+ Set .map (Time .startOf ("day" ), selectedDays )
205+
206+ selected =
207+ if (Set .size (normalizedDays ) == 0 ) {
208+ normalizedDay == normalizedCell
209+ } else {
210+ Set .has (normalizedCell , normalizedDays )
211+ }
212+
213+ <Ui .Calendar .Cell
214+ active = {Array .any ((item : Time ) : Bool { normalizedCell == item }, range )}
215+ onClick = {handleCellClick }
216+ day = {normalizedCell }
217+ selected = {selected }
218+ readonly = {readonly }/>
219+ }
193220 }
194221 }
195222 </div >
0 commit comments