@instructure/ui-calendar 11.0.1-snapshot-1 → 11.0.1-snapshot-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [11.0.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v11.0.0...v11.0.1-snapshot-1) (2025-10-08)
6
+ ## [11.0.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v11.0.0...v11.0.1-snapshot-2) (2025-10-10)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-calendar
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-calendar",
3
- "version": "11.0.1-snapshot-1",
3
+ "version": "11.0.1-snapshot-2",
4
4
  "description": "A calendar component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "11.0.1-snapshot-1",
27
- "@instructure/ui-color-utils": "11.0.1-snapshot-1",
28
- "@instructure/ui-themes": "11.0.1-snapshot-1",
26
+ "@instructure/ui-babel-preset": "11.0.1-snapshot-2",
27
+ "@instructure/ui-color-utils": "11.0.1-snapshot-2",
28
+ "@instructure/ui-themes": "11.0.1-snapshot-2",
29
29
  "@testing-library/jest-dom": "^6.6.3",
30
30
  "@testing-library/react": "15.0.7",
31
31
  "@testing-library/user-event": "^14.6.1",
@@ -33,18 +33,18 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.27.6",
36
- "@instructure/console": "11.0.1-snapshot-1",
37
- "@instructure/emotion": "11.0.1-snapshot-1",
38
- "@instructure/shared-types": "11.0.1-snapshot-1",
39
- "@instructure/ui-a11y-content": "11.0.1-snapshot-1",
40
- "@instructure/ui-buttons": "11.0.1-snapshot-1",
41
- "@instructure/ui-i18n": "11.0.1-snapshot-1",
42
- "@instructure/ui-icons": "11.0.1-snapshot-1",
43
- "@instructure/ui-react-utils": "11.0.1-snapshot-1",
44
- "@instructure/ui-simple-select": "11.0.1-snapshot-1",
45
- "@instructure/ui-utils": "11.0.1-snapshot-1",
46
- "@instructure/ui-view": "11.0.1-snapshot-1",
47
- "@instructure/uid": "11.0.1-snapshot-1"
36
+ "@instructure/console": "11.0.1-snapshot-2",
37
+ "@instructure/emotion": "11.0.1-snapshot-2",
38
+ "@instructure/shared-types": "11.0.1-snapshot-2",
39
+ "@instructure/ui-a11y-content": "11.0.1-snapshot-2",
40
+ "@instructure/ui-buttons": "11.0.1-snapshot-2",
41
+ "@instructure/ui-i18n": "11.0.1-snapshot-2",
42
+ "@instructure/ui-icons": "11.0.1-snapshot-2",
43
+ "@instructure/ui-react-utils": "11.0.1-snapshot-2",
44
+ "@instructure/ui-simple-select": "11.0.1-snapshot-2",
45
+ "@instructure/ui-utils": "11.0.1-snapshot-2",
46
+ "@instructure/ui-view": "11.0.1-snapshot-2",
47
+ "@instructure/uid": "11.0.1-snapshot-2"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": ">=18 <=19"
@@ -19,35 +19,10 @@ type: example
19
19
 
20
20
  ### Default config with additional props
21
21
 
22
- - ```js
23
- class Example extends React.Component {
24
- state = {
25
- selectedDate: '',
26
- visibleMonth: '2025-05'
27
- }
28
-
29
- render = () => (
30
- <Calendar
31
- visibleMonth={this.state.visibleMonth}
32
- currentDate="2023-12-15"
33
- disabledDates={['2023-12-22', '2023-12-12', '2023-12-11']}
34
- selectedDate={this.state.selectedDate}
35
- onRequestRenderNextMonth={(_e, requestedMonth) =>
36
- this.setState({ visibleMonth: requestedMonth })
37
- }
38
- onRequestRenderPrevMonth={(_e, requestedMonth) =>
39
- this.setState({ visibleMonth: requestedMonth })
40
- }
41
- onDateSelected={(date) => {
42
- this.setState({ selectedDate: date })
43
- }}
44
- />
45
- )
46
- }
47
- render(<Example />)
48
- ```
49
-
50
- - ```js
22
+ ```js
23
+ ---
24
+ type: example
25
+ ---
51
26
  const Example = () => {
52
27
  const [selectedDate, setSelectedDate] = useState('')
53
28
  const [visibleMonth, setVisibleMonth] = useState('2025-05')
@@ -71,45 +46,14 @@ type: example
71
46
  )
72
47
  }
73
48
  render(<Example />)
74
- ```
49
+ ```
75
50
 
76
51
  ### With year picker
77
52
 
78
- - ```js
79
- class Example extends React.Component {
80
- state = {
81
- selectedDate: '',
82
- visibleMonth: '2024-02'
83
- }
84
-
85
- render = () => (
86
- <Calendar
87
- visibleMonth={this.state.visibleMonth}
88
- currentDate="2024-02-29"
89
- disabledDates={['2023-12-22', '2023-12-12', '2023-12-11']}
90
- selectedDate={this.state.selectedDate}
91
- onRequestRenderNextMonth={(_e, requestedMonth) =>
92
- this.setState({ visibleMonth: requestedMonth })
93
- }
94
- onRequestRenderPrevMonth={(_e, requestedMonth) =>
95
- this.setState({ visibleMonth: requestedMonth })
96
- }
97
- onDateSelected={(date) => {
98
- this.setState({ selectedDate: date })
99
- }}
100
- withYearPicker={{
101
- screenReaderLabel: 'Year picker',
102
- startYear: 1999,
103
- endYear: 2024,
104
- maxHeight: '200px'
105
- }}
106
- />
107
- )
108
- }
109
- render(<Example />)
110
- ```
111
-
112
- - ```js
53
+ ```js
54
+ ---
55
+ type: example
56
+ ---
113
57
  const Example = () => {
114
58
  const [selectedDate, setSelectedDate] = useState('')
115
59
  const [visibleMonth, setVisibleMonth] = useState('2024-02')
@@ -139,7 +83,7 @@ type: example
139
83
  )
140
84
  }
141
85
  render(<Example />)
142
- ```
86
+ ```
143
87
 
144
88
  ### Composing a Calendar in your Application
145
89
 
@@ -148,134 +92,10 @@ formats you use in your application. The following example demonstrates how a
148
92
  basic `Calendar` might be created using utilities from
149
93
  [Moment.js](https://momentjs.com/docs/#/parsing/).
150
94
 
151
- - ```js
152
- class Example extends React.Component {
153
- state = {
154
- todayDate: parseDate('2019-08-16').toISOString(),
155
- renderedDate: parseDate('2019-08-02').toISOString()
156
- }
157
-
158
- generateMonth = () => {
159
- const date = parseDate(this.state.renderedDate)
160
- .startOf('month')
161
- .startOf('week')
162
-
163
- return Array.apply(null, Array(Calendar.DAY_COUNT)).map(() => {
164
- const currentDate = date.clone()
165
- date.add({ days: 1 })
166
-
167
- // This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
168
- // in these cases adding 1 day results in 23 hours added instead,
169
- // so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
170
- // in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
171
- // which would cause duplicate dates in the calendar.
172
- // More info on the bug: https://github.com/moment/moment/issues/4743
173
- // Please note that this causes one hour of time difference in the affected timezones/dates and to
174
- // fully solve this bug we need to change to something like luxon which handles this properly
175
- if (currentDate.clone().format('HH') === '23') {
176
- return currentDate.clone().add({ hours: 1 })
177
- }
178
-
179
- return currentDate.clone()
180
- })
181
- }
182
-
183
- renderWeekdayLabels = () => {
184
- const date = parseDate(this.state.renderedDate).startOf('week')
185
-
186
- return Array.apply(null, Array(7)).map(() => {
187
- const currentDate = date.clone()
188
- date.add(1, 'day')
189
-
190
- return (
191
- <AccessibleContent alt={currentDate.format('dddd')}>
192
- {currentDate.format('dd')}
193
- </AccessibleContent>
194
- )
195
- })
196
- }
197
-
198
- handleRenderNextMonth = (event) => {
199
- this.modifyRenderedMonth(1)
200
- }
201
-
202
- handleRenderPrevMonth = (event) => {
203
- this.modifyRenderedMonth(-1)
204
- }
205
-
206
- modifyRenderedMonth = (step) => {
207
- this.setState(({ renderedDate }) => {
208
- const date = parseDate(renderedDate)
209
- date.add(step, 'month')
210
- return { renderedDate: date.toISOString() }
211
- })
212
- }
213
-
214
- renderDay(date) {
215
- const { renderedDate, todayDate } = this.state
216
-
217
- return (
218
- <Calendar.Day
219
- key={date.toISOString()}
220
- date={date.toISOString()}
221
- isOutsideMonth={!date.isSame(renderedDate, 'month')}
222
- isToday={date.isSame(todayDate, 'day')}
223
- label={`${date.format('D')} ${date.format('MMMM')} ${date.format(
224
- 'YYYY'
225
- )}`}
226
- >
227
- {date.format('D')}
228
- </Calendar.Day>
229
- )
230
- }
231
-
232
- render() {
233
- const date = parseDate(this.state.renderedDate)
234
-
235
- const buttonProps = (type = 'prev') => ({
236
- size: 'small',
237
- withBackground: false,
238
- withBorder: false,
239
- renderIcon:
240
- type === 'prev' ? (
241
- <IconArrowOpenStartSolid color="primary" />
242
- ) : (
243
- <IconArrowOpenEndSolid color="primary" />
244
- ),
245
- screenReaderLabel: type === 'prev' ? 'Previous month' : 'Next month'
246
- })
247
-
248
- return (
249
- <Calendar
250
- renderPrevMonthButton={<IconButton {...buttonProps('prev')} />}
251
- renderNextMonthButton={<IconButton {...buttonProps('next')} />}
252
- renderNavigationLabel={
253
- <span>
254
- <div>{date.format('MMMM')}</div>
255
- <div>{date.format('YYYY')}</div>
256
- </span>
257
- }
258
- renderWeekdayLabels={this.renderWeekdayLabels()}
259
- onRequestRenderNextMonth={this.handleRenderNextMonth}
260
- onRequestRenderPrevMonth={this.handleRenderPrevMonth}
261
- >
262
- {this.generateMonth().map((date) => this.renderDay(date))}
263
- </Calendar>
264
- )
265
- }
266
- }
267
-
268
- const locale = 'en-us'
269
- const timezone = 'America/Denver'
270
-
271
- const parseDate = (dateStr) => {
272
- return moment.tz(dateStr, [moment.ISO_8601], locale, timezone)
273
- }
274
-
275
- render(<Example />)
276
- ```
277
-
278
- - ```js
95
+ ```js
96
+ ---
97
+ type: example
98
+ ---
279
99
  const Example = () => {
280
100
  const [renderedDate, setRenderedDate] = useState(
281
101
  parseDate('2019-08-02').toISOString()
@@ -392,7 +212,7 @@ basic `Calendar` might be created using utilities from
392
212
  }
393
213
 
394
214
  render(<Example />)
395
- ```
215
+ ```
396
216
 
397
217
  #### Some dates to keep track of
398
218