@instructure/ui-calendar 10.2.3-snapshot-10 → 10.2.3-snapshot-13
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 +5 -2
- package/es/Calendar/index.js +17 -10
- package/lib/Calendar/index.js +17 -10
- package/package.json +20 -20
- package/src/Calendar/index.tsx +39 -14
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Calendar/index.d.ts +1 -1
- package/types/Calendar/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [10.2.3-snapshot-
|
|
6
|
+
## [10.2.3-snapshot-13](https://github.com/instructure/instructure-ui/compare/v10.2.2...v10.2.3-snapshot-13) (2024-10-02)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-calendar,ui-date-input:** update DateInput2 api, add placeholder hint ([ee9dfab](https://github.com/instructure/instructure-ui/commit/ee9dfab8cb5cff76d829bd24163d2052a7da46a9))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Calendar/index.js
CHANGED
|
@@ -132,17 +132,18 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
132
132
|
this.handleYearChange = (e, year) => {
|
|
133
133
|
const withYearPicker = this.props.withYearPicker;
|
|
134
134
|
const visibleMonth = this.state.visibleMonth;
|
|
135
|
+
const yearNumber = Number(DateTime.parse(year, this.locale(), this.timezone()).locale('en').format('YYYY'));
|
|
135
136
|
const newDate = visibleMonth.clone();
|
|
136
137
|
if (withYearPicker !== null && withYearPicker !== void 0 && withYearPicker.onRequestYearChange) {
|
|
137
|
-
withYearPicker.onRequestYearChange(e,
|
|
138
|
+
withYearPicker.onRequestYearChange(e, yearNumber);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
newDate.year(
|
|
141
|
+
newDate.year(yearNumber);
|
|
141
142
|
this.setState({
|
|
142
143
|
visibleMonth: newDate
|
|
143
144
|
});
|
|
144
145
|
};
|
|
145
|
-
// date is returned
|
|
146
|
+
// date is returned as an ISO string, like 2021-09-14T22:00:00.000Z
|
|
146
147
|
this.handleDayClick = (event, {
|
|
147
148
|
date
|
|
148
149
|
}) => {
|
|
@@ -173,14 +174,18 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
173
174
|
return this.props.role === 'listbox' ? this.props.role : void 0;
|
|
174
175
|
}
|
|
175
176
|
get hasPrevMonth() {
|
|
176
|
-
|
|
177
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
178
|
+
const yearNumber = Number(this.state.visibleMonth.clone().locale('en').subtract({
|
|
177
179
|
months: 1
|
|
178
|
-
}).format('YYYY'))
|
|
180
|
+
}).format('YYYY'));
|
|
181
|
+
return !this.props.withYearPicker || this.props.withYearPicker && yearNumber >= this.props.withYearPicker.startYear;
|
|
179
182
|
}
|
|
180
183
|
get hasNextMonth() {
|
|
181
|
-
|
|
184
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
185
|
+
const yearNumber = Number(this.state.visibleMonth.clone().locale('en').add({
|
|
182
186
|
months: 1
|
|
183
|
-
}).format('YYYY'))
|
|
187
|
+
}).format('YYYY'));
|
|
188
|
+
return !this.props.withYearPicker || this.props.withYearPicker && yearNumber <= this.props.withYearPicker.endYear;
|
|
184
189
|
}
|
|
185
190
|
renderHeader() {
|
|
186
191
|
const _this$props5 = this.props,
|
|
@@ -200,7 +205,8 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
200
205
|
const startYear = withYearPicker.startYear,
|
|
201
206
|
endYear = withYearPicker.endYear;
|
|
202
207
|
for (let year = endYear; year >= startYear; year--) {
|
|
203
|
-
|
|
208
|
+
// add the years to the list with the correct locale
|
|
209
|
+
yearList.push(DateTime.parse(year.toString(), this.locale(), this.timezone()).format('YYYY'));
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
212
|
return jsx("div", null, jsx("div", {
|
|
@@ -210,11 +216,12 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
210
216
|
}, jsx(SimpleSelect, {
|
|
211
217
|
width: "90px",
|
|
212
218
|
renderLabel: "",
|
|
219
|
+
placeholder: "--",
|
|
213
220
|
assistiveText: withYearPicker.screenReaderLabel,
|
|
214
|
-
value:
|
|
221
|
+
value: visibleMonth.format('YYYY'),
|
|
215
222
|
onChange: (e, {
|
|
216
223
|
value
|
|
217
|
-
}) => this.handleYearChange(e,
|
|
224
|
+
}) => this.handleYearChange(e, `${value}`)
|
|
218
225
|
}, yearList.map(year => jsx(SimpleSelect.Option, {
|
|
219
226
|
key: year,
|
|
220
227
|
id: `opt-${year}`,
|
package/lib/Calendar/index.js
CHANGED
|
@@ -143,17 +143,18 @@ let Calendar = exports.Calendar = (_dec = (0, _emotion.withStyle)(_styles.defaul
|
|
|
143
143
|
this.handleYearChange = (e, year) => {
|
|
144
144
|
const withYearPicker = this.props.withYearPicker;
|
|
145
145
|
const visibleMonth = this.state.visibleMonth;
|
|
146
|
+
const yearNumber = Number(_DateTime.DateTime.parse(year, this.locale(), this.timezone()).locale('en').format('YYYY'));
|
|
146
147
|
const newDate = visibleMonth.clone();
|
|
147
148
|
if (withYearPicker !== null && withYearPicker !== void 0 && withYearPicker.onRequestYearChange) {
|
|
148
|
-
withYearPicker.onRequestYearChange(e,
|
|
149
|
+
withYearPicker.onRequestYearChange(e, yearNumber);
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
151
|
-
newDate.year(
|
|
152
|
+
newDate.year(yearNumber);
|
|
152
153
|
this.setState({
|
|
153
154
|
visibleMonth: newDate
|
|
154
155
|
});
|
|
155
156
|
};
|
|
156
|
-
// date is returned
|
|
157
|
+
// date is returned as an ISO string, like 2021-09-14T22:00:00.000Z
|
|
157
158
|
this.handleDayClick = (event, {
|
|
158
159
|
date
|
|
159
160
|
}) => {
|
|
@@ -184,14 +185,18 @@ let Calendar = exports.Calendar = (_dec = (0, _emotion.withStyle)(_styles.defaul
|
|
|
184
185
|
return this.props.role === 'listbox' ? this.props.role : void 0;
|
|
185
186
|
}
|
|
186
187
|
get hasPrevMonth() {
|
|
187
|
-
|
|
188
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
189
|
+
const yearNumber = Number(this.state.visibleMonth.clone().locale('en').subtract({
|
|
188
190
|
months: 1
|
|
189
|
-
}).format('YYYY'))
|
|
191
|
+
}).format('YYYY'));
|
|
192
|
+
return !this.props.withYearPicker || this.props.withYearPicker && yearNumber >= this.props.withYearPicker.startYear;
|
|
190
193
|
}
|
|
191
194
|
get hasNextMonth() {
|
|
192
|
-
|
|
195
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
196
|
+
const yearNumber = Number(this.state.visibleMonth.clone().locale('en').add({
|
|
193
197
|
months: 1
|
|
194
|
-
}).format('YYYY'))
|
|
198
|
+
}).format('YYYY'));
|
|
199
|
+
return !this.props.withYearPicker || this.props.withYearPicker && yearNumber <= this.props.withYearPicker.endYear;
|
|
195
200
|
}
|
|
196
201
|
renderHeader() {
|
|
197
202
|
const _this$props5 = this.props,
|
|
@@ -211,7 +216,8 @@ let Calendar = exports.Calendar = (_dec = (0, _emotion.withStyle)(_styles.defaul
|
|
|
211
216
|
const startYear = withYearPicker.startYear,
|
|
212
217
|
endYear = withYearPicker.endYear;
|
|
213
218
|
for (let year = endYear; year >= startYear; year--) {
|
|
214
|
-
|
|
219
|
+
// add the years to the list with the correct locale
|
|
220
|
+
yearList.push(_DateTime.DateTime.parse(year.toString(), this.locale(), this.timezone()).format('YYYY'));
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
return (0, _emotion.jsx)("div", null, (0, _emotion.jsx)("div", {
|
|
@@ -221,11 +227,12 @@ let Calendar = exports.Calendar = (_dec = (0, _emotion.withStyle)(_styles.defaul
|
|
|
221
227
|
}, (0, _emotion.jsx)(_SimpleSelect.SimpleSelect, {
|
|
222
228
|
width: "90px",
|
|
223
229
|
renderLabel: "",
|
|
230
|
+
placeholder: "--",
|
|
224
231
|
assistiveText: withYearPicker.screenReaderLabel,
|
|
225
|
-
value:
|
|
232
|
+
value: visibleMonth.format('YYYY'),
|
|
226
233
|
onChange: (e, {
|
|
227
234
|
value
|
|
228
|
-
}) => this.handleYearChange(e,
|
|
235
|
+
}) => this.handleYearChange(e, `${value}`)
|
|
229
236
|
}, yearList.map(year => (0, _emotion.jsx)(_SimpleSelect.SimpleSelect.Option, {
|
|
230
237
|
key: year,
|
|
231
238
|
id: `opt-${year}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-calendar",
|
|
3
|
-
"version": "10.2.3-snapshot-
|
|
3
|
+
"version": "10.2.3-snapshot-13",
|
|
4
4
|
"description": "A calendar component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,31 +23,31 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "10.2.3-snapshot-
|
|
27
|
-
"@instructure/ui-color-utils": "10.2.3-snapshot-
|
|
28
|
-
"@instructure/ui-test-locator": "10.2.3-snapshot-
|
|
29
|
-
"@instructure/ui-test-utils": "10.2.3-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "10.2.3-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "10.2.3-snapshot-13",
|
|
27
|
+
"@instructure/ui-color-utils": "10.2.3-snapshot-13",
|
|
28
|
+
"@instructure/ui-test-locator": "10.2.3-snapshot-13",
|
|
29
|
+
"@instructure/ui-test-utils": "10.2.3-snapshot-13",
|
|
30
|
+
"@instructure/ui-themes": "10.2.3-snapshot-13",
|
|
31
31
|
"@testing-library/jest-dom": "^6.4.6",
|
|
32
32
|
"@testing-library/react": "^15.0.7",
|
|
33
33
|
"vitest": "^2.0.2"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.24.5",
|
|
37
|
-
"@instructure/console": "10.2.3-snapshot-
|
|
38
|
-
"@instructure/emotion": "10.2.3-snapshot-
|
|
39
|
-
"@instructure/shared-types": "10.2.3-snapshot-
|
|
40
|
-
"@instructure/ui-a11y-content": "10.2.3-snapshot-
|
|
41
|
-
"@instructure/ui-buttons": "10.2.3-snapshot-
|
|
42
|
-
"@instructure/ui-i18n": "10.2.3-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "10.2.3-snapshot-
|
|
44
|
-
"@instructure/ui-prop-types": "10.2.3-snapshot-
|
|
45
|
-
"@instructure/ui-react-utils": "10.2.3-snapshot-
|
|
46
|
-
"@instructure/ui-simple-select": "10.2.3-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "10.2.3-snapshot-
|
|
48
|
-
"@instructure/ui-utils": "10.2.3-snapshot-
|
|
49
|
-
"@instructure/ui-view": "10.2.3-snapshot-
|
|
50
|
-
"@instructure/uid": "10.2.3-snapshot-
|
|
37
|
+
"@instructure/console": "10.2.3-snapshot-13",
|
|
38
|
+
"@instructure/emotion": "10.2.3-snapshot-13",
|
|
39
|
+
"@instructure/shared-types": "10.2.3-snapshot-13",
|
|
40
|
+
"@instructure/ui-a11y-content": "10.2.3-snapshot-13",
|
|
41
|
+
"@instructure/ui-buttons": "10.2.3-snapshot-13",
|
|
42
|
+
"@instructure/ui-i18n": "10.2.3-snapshot-13",
|
|
43
|
+
"@instructure/ui-icons": "10.2.3-snapshot-13",
|
|
44
|
+
"@instructure/ui-prop-types": "10.2.3-snapshot-13",
|
|
45
|
+
"@instructure/ui-react-utils": "10.2.3-snapshot-13",
|
|
46
|
+
"@instructure/ui-simple-select": "10.2.3-snapshot-13",
|
|
47
|
+
"@instructure/ui-testable": "10.2.3-snapshot-13",
|
|
48
|
+
"@instructure/ui-utils": "10.2.3-snapshot-13",
|
|
49
|
+
"@instructure/ui-view": "10.2.3-snapshot-13",
|
|
50
|
+
"@instructure/uid": "10.2.3-snapshot-13",
|
|
51
51
|
"prop-types": "^15.8.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
package/src/Calendar/index.tsx
CHANGED
|
@@ -145,22 +145,34 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
get hasPrevMonth() {
|
|
148
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
149
|
+
const yearNumber = Number(
|
|
150
|
+
this.state.visibleMonth
|
|
151
|
+
.clone()
|
|
152
|
+
.locale('en')
|
|
153
|
+
.subtract({ months: 1 })
|
|
154
|
+
.format('YYYY')
|
|
155
|
+
)
|
|
148
156
|
return (
|
|
149
157
|
!this.props.withYearPicker ||
|
|
150
158
|
(this.props.withYearPicker &&
|
|
151
|
-
|
|
152
|
-
this.state.visibleMonth.clone().subtract({ months: 1 }).format('YYYY')
|
|
153
|
-
) >= this.props.withYearPicker.startYear)
|
|
159
|
+
yearNumber >= this.props.withYearPicker.startYear)
|
|
154
160
|
)
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
get hasNextMonth() {
|
|
164
|
+
// this is needed for locales that doesn't use the latin script for numbers e.g.: arabic
|
|
165
|
+
const yearNumber = Number(
|
|
166
|
+
this.state.visibleMonth
|
|
167
|
+
.clone()
|
|
168
|
+
.locale('en')
|
|
169
|
+
.add({ months: 1 })
|
|
170
|
+
.format('YYYY')
|
|
171
|
+
)
|
|
158
172
|
return (
|
|
159
173
|
!this.props.withYearPicker ||
|
|
160
174
|
(this.props.withYearPicker &&
|
|
161
|
-
|
|
162
|
-
this.state.visibleMonth.clone().add({ months: 1 }).format('YYYY')
|
|
163
|
-
) <= this.props.withYearPicker.endYear)
|
|
175
|
+
yearNumber <= this.props.withYearPicker.endYear)
|
|
164
176
|
)
|
|
165
177
|
}
|
|
166
178
|
|
|
@@ -227,16 +239,21 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
227
239
|
|
|
228
240
|
handleYearChange = (
|
|
229
241
|
e: React.SyntheticEvent<Element, Event>,
|
|
230
|
-
year:
|
|
242
|
+
year: string
|
|
231
243
|
) => {
|
|
232
244
|
const { withYearPicker } = this.props
|
|
233
245
|
const { visibleMonth } = this.state
|
|
246
|
+
const yearNumber = Number(
|
|
247
|
+
DateTime.parse(year, this.locale(), this.timezone())
|
|
248
|
+
.locale('en')
|
|
249
|
+
.format('YYYY')
|
|
250
|
+
)
|
|
234
251
|
const newDate = visibleMonth.clone()
|
|
235
252
|
if (withYearPicker?.onRequestYearChange) {
|
|
236
|
-
withYearPicker.onRequestYearChange(e,
|
|
253
|
+
withYearPicker.onRequestYearChange(e, yearNumber)
|
|
237
254
|
return
|
|
238
255
|
}
|
|
239
|
-
newDate.year(
|
|
256
|
+
newDate.year(yearNumber)
|
|
240
257
|
this.setState({ visibleMonth: newDate })
|
|
241
258
|
}
|
|
242
259
|
|
|
@@ -261,12 +278,19 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
261
278
|
...(prevButton || nextButton ? [styles?.navigationWithButtons] : [])
|
|
262
279
|
]
|
|
263
280
|
|
|
264
|
-
const yearList:
|
|
281
|
+
const yearList: string[] = []
|
|
265
282
|
|
|
266
283
|
if (withYearPicker) {
|
|
267
284
|
const { startYear, endYear } = withYearPicker
|
|
268
285
|
for (let year = endYear; year >= startYear!; year--) {
|
|
269
|
-
|
|
286
|
+
// add the years to the list with the correct locale
|
|
287
|
+
yearList.push(
|
|
288
|
+
DateTime.parse(
|
|
289
|
+
year.toString(),
|
|
290
|
+
this.locale(),
|
|
291
|
+
this.timezone()
|
|
292
|
+
).format('YYYY')
|
|
293
|
+
)
|
|
270
294
|
}
|
|
271
295
|
}
|
|
272
296
|
|
|
@@ -294,8 +318,9 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
294
318
|
<SimpleSelect
|
|
295
319
|
width="90px"
|
|
296
320
|
renderLabel=""
|
|
321
|
+
placeholder="--"
|
|
297
322
|
assistiveText={withYearPicker.screenReaderLabel}
|
|
298
|
-
value={
|
|
323
|
+
value={visibleMonth.format('YYYY')}
|
|
299
324
|
onChange={(
|
|
300
325
|
e: React.SyntheticEvent<Element, Event>,
|
|
301
326
|
{
|
|
@@ -304,7 +329,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
304
329
|
value?: string | number | undefined
|
|
305
330
|
id?: string | undefined
|
|
306
331
|
}
|
|
307
|
-
) => this.handleYearChange(e,
|
|
332
|
+
) => this.handleYearChange(e, `${value}`)}
|
|
308
333
|
>
|
|
309
334
|
{yearList.map((year) => (
|
|
310
335
|
<SimpleSelect.Option key={year} id={`opt-${year}`} value={year}>
|
|
@@ -441,7 +466,7 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
441
466
|
return DateTime.browserTimeZone()
|
|
442
467
|
}
|
|
443
468
|
|
|
444
|
-
// date is returned
|
|
469
|
+
// date is returned as an ISO string, like 2021-09-14T22:00:00.000Z
|
|
445
470
|
handleDayClick = (event: MouseEvent<any>, { date }: { date: string }) => {
|
|
446
471
|
if (this.props.onDateSelected) {
|
|
447
472
|
const parsedDate = DateTime.parse(date, this.locale(), this.timezone())
|