@@ -11,7 +11,7 @@ const months = [...Array(12).keys()].map((key) =>
11
11
) ;
12
12
13
13
/**
14
- * Calendars display a grid of days in one or more months and allow users to select a single date.
14
+ * Calendars display a grid of days in one or more months and allow users to select a single date or a range of dates .
15
15
*/
16
16
export default {
17
17
title : "Calendar" ,
@@ -27,6 +27,9 @@ export default {
27
27
options : months ,
28
28
control : "select" ,
29
29
} ,
30
+ // The date selection controls don't update the story, so they are removed from the table.
31
+ // TODO: We may have to refactor some of the template to create a working controls for the
32
+ // selectable dates.
30
33
selectedDay : {
31
34
name : "Selected date or range start (date)" ,
32
35
description :
@@ -35,19 +38,33 @@ export default {
35
38
table : {
36
39
type : { summary : "datetime" } ,
37
40
category : "Content" ,
41
+ disable : true ,
38
42
} ,
39
43
control : "date" ,
40
44
if : { arg : "isDisabled" , truthy : false } ,
41
45
} ,
46
+ isRangeSelection : {
47
+ name : "Range selection" ,
48
+ description : "Allow users to select a range of dates." ,
49
+ type : { name : "boolean" } ,
50
+ table : {
51
+ type : { summary : "boolean" } ,
52
+ category : "Content" ,
53
+ disable : true ,
54
+ } ,
55
+ control : "boolean" ,
56
+ } ,
42
57
lastDay : {
43
58
name : "Range end (date)" ,
44
59
description : "Defines the end of a date range." ,
45
60
type : { name : "number" } ,
46
61
table : {
47
62
type : { summary : "datetime" } ,
48
63
category : "Content" ,
64
+ disable : true ,
49
65
} ,
50
66
control : "date" ,
67
+ if : { arg : "isRangeSelection" , truthy : true }
51
68
} ,
52
69
year : {
53
70
name : "Year" ,
@@ -69,7 +86,8 @@ export default {
69
86
control : "boolean" ,
70
87
} ,
71
88
useDOWAbbrev : {
72
- name : "Use 3 letter abbreviation for day of week" ,
89
+ name : "Days of the week" ,
90
+ description : "Use 3 letter abbreviation for day of week." ,
73
91
type : { name : "boolean" } ,
74
92
table : {
75
93
type : { summary : "boolean" } ,
@@ -89,6 +107,7 @@ export default {
89
107
isFocused : false ,
90
108
useDOWAbbrev : false ,
91
109
buttonSize : ActionButtonStories . args . size ,
110
+ isRangeSelection : false ,
92
111
} ,
93
112
parameters : {
94
113
actions : {
@@ -99,45 +118,52 @@ export default {
99
118
packageJson,
100
119
metadata,
101
120
} ,
102
- tags : [ "!autodocs" ] ,
103
121
} ;
104
122
105
123
export const Default = CalendarGroup . bind ( { } ) ;
106
124
Default . args = {
107
125
month : months [ 6 ] ,
108
- selectedDay : new Date ( 2023 , 6 , 3 ) ,
109
- year : 2023 ,
126
+ selectedDay : new Date ( 2025 , 6 , 3 ) ,
127
+ year : 2025 ,
110
128
} ;
111
129
112
130
// ********* DOCS ONLY ********* //
113
131
export const AbbreviatedWeekdays = Template . bind ( { } ) ;
114
132
AbbreviatedWeekdays . args = {
133
+ ...Default . args ,
115
134
useDOWAbbrev : true ,
116
135
} ;
117
136
AbbreviatedWeekdays . tags = [ "!dev" ] ;
118
137
AbbreviatedWeekdays . parameters = {
119
138
chromatic : { disableSnapshot : true } ,
120
139
} ;
140
+ AbbreviatedWeekdays . storyName = "Abbreviated weekdays" ;
141
+
142
+ /**
143
+ * For calendars with a selectable range:
121
144
145
+ - The `.is-range-start` and `.is-range-selection` classes go on the first day in the selection.
146
+ - The `.is-range-end` and `.is-range-selection` classes go on the last day of the selection.
147
+ - The `.is-range-selection` class goes on all days in the middle of the selection.
148
+ */
122
149
export const RangeSelection = Template . bind ( { } ) ;
123
150
RangeSelection . args = {
151
+ isRangeSelection : true ,
124
152
month : months [ 6 ] ,
125
- selectedDay : new Date ( 2023 , 6 , 3 ) ,
126
- year : 2023 ,
127
- lastDay : new Date ( 2023 , 6 , 7 ) ,
128
- useDOWAbbrev : true ,
153
+ selectedDay : new Date ( 2025 , 6 , 3 ) ,
154
+ year : 2025 ,
155
+ lastDay : new Date ( 2025 , 6 , 7 ) ,
129
156
isPadded : true ,
130
157
} ;
131
- RangeSelection . tags = [ "!dev" ] ;
132
158
RangeSelection . parameters = {
133
159
chromatic : { disableSnapshot : true } ,
134
160
} ;
161
+ RangeSelection . storyName = "Range selection" ;
135
162
136
163
export const Focused = Template . bind ( { } ) ;
137
164
Focused . args = {
138
- month : undefined ,
165
+ ... Default . args ,
139
166
selectedDay : undefined ,
140
- year : undefined ,
141
167
isFocused : true ,
142
168
} ;
143
169
Focused . tags = [ "!dev" ] ;
@@ -148,6 +174,7 @@ Focused.parameters = {
148
174
export const Disabled = Template . bind ( { } ) ;
149
175
Disabled . tags = [ "!dev" ] ;
150
176
Disabled . args = {
177
+ ...Default . args ,
151
178
isDisabled : true
152
179
} ;
153
180
Disabled . parameters = {
0 commit comments