@instructure/ui-calendar 10.16.1-snapshot-0 → 10.16.1
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 +1 -1
- package/es/Calendar/Day/__new-tests__/Day.test.js +89 -71
- package/es/Calendar/Day/index.js +13 -9
- package/es/Calendar/__new-tests__/Calendar.test.js +96 -62
- package/es/Calendar/index.js +94 -74
- package/lib/Calendar/Day/__new-tests__/Day.test.js +96 -78
- package/lib/Calendar/Day/index.js +12 -8
- package/lib/Calendar/__new-tests__/Calendar.test.js +112 -79
- package/lib/Calendar/index.js +93 -74
- package/package.json +20 -20
- package/src/Calendar/Day/__new-tests__/Day.test.tsx +16 -17
- package/src/Calendar/Day/index.tsx +1 -2
- package/src/Calendar/__new-tests__/Calendar.test.tsx +4 -8
- package/src/Calendar/index.tsx +4 -6
- package/src/Calendar/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Calendar/Day/__new-tests__/Day.test.d.ts.map +1 -1
- package/types/Calendar/Day/index.d.ts +1 -3
- package/types/Calendar/Day/index.d.ts.map +1 -1
- package/types/Calendar/index.d.ts +8 -10
- package/types/Calendar/index.d.ts.map +1 -1
- package/types/Calendar/props.d.ts +1 -1
- package/types/Calendar/props.d.ts.map +1 -1
package/es/Calendar/index.js
CHANGED
|
@@ -23,8 +23,7 @@ var _dec, _dec2, _class, _Calendar, _IconButton, _IconButton2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
import React, { Children, Component } from 'react';
|
|
26
|
+
import { Children, Component } from 'react';
|
|
28
27
|
import { View } from '@instructure/ui-view';
|
|
29
28
|
import { safeCloneElement, callRenderProp, omitProps } from '@instructure/ui-react-utils';
|
|
30
29
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
@@ -32,7 +31,7 @@ import { logError as error } from '@instructure/console';
|
|
|
32
31
|
import { uid } from '@instructure/uid';
|
|
33
32
|
import { AccessibleContent } from '@instructure/ui-a11y-content';
|
|
34
33
|
import { testable } from '@instructure/ui-testable';
|
|
35
|
-
import { withStyle
|
|
34
|
+
import { withStyle } from '@instructure/emotion';
|
|
36
35
|
import { Locale, DateTime, ApplyLocaleContext } from '@instructure/ui-i18n';
|
|
37
36
|
import generateStyle from './styles';
|
|
38
37
|
import generateComponentTheme from './theme';
|
|
@@ -47,6 +46,7 @@ import { SimpleSelect } from '@instructure/ui-simple-select';
|
|
|
47
46
|
category: components
|
|
48
47
|
---
|
|
49
48
|
**/
|
|
49
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
50
50
|
let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_Calendar = class Calendar extends Component {
|
|
51
51
|
constructor(props) {
|
|
52
52
|
super(props);
|
|
@@ -72,20 +72,20 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
72
72
|
renderNextMonthButton = _this$props.renderNextMonthButton,
|
|
73
73
|
renderPrevMonthButton = _this$props.renderPrevMonthButton;
|
|
74
74
|
return {
|
|
75
|
-
prevButton: renderPrevMonthButton ? callRenderProp(renderPrevMonthButton) : _IconButton || (_IconButton =
|
|
75
|
+
prevButton: renderPrevMonthButton ? callRenderProp(renderPrevMonthButton) : _IconButton || (_IconButton = _jsx(IconButton, {
|
|
76
76
|
size: "small",
|
|
77
77
|
withBackground: false,
|
|
78
78
|
withBorder: false,
|
|
79
|
-
renderIcon:
|
|
79
|
+
renderIcon: _jsx(IconArrowOpenStartSolid, {
|
|
80
80
|
color: "primary"
|
|
81
81
|
}),
|
|
82
82
|
screenReaderLabel: "Previous month"
|
|
83
83
|
})),
|
|
84
|
-
nextButton: renderNextMonthButton ? callRenderProp(renderNextMonthButton) : _IconButton2 || (_IconButton2 =
|
|
84
|
+
nextButton: renderNextMonthButton ? callRenderProp(renderNextMonthButton) : _IconButton2 || (_IconButton2 = _jsx(IconButton, {
|
|
85
85
|
size: "small",
|
|
86
86
|
withBackground: false,
|
|
87
87
|
withBorder: false,
|
|
88
|
-
renderIcon:
|
|
88
|
+
renderIcon: _jsx(IconArrowOpenEndSolid, {
|
|
89
89
|
color: "primary"
|
|
90
90
|
}),
|
|
91
91
|
screenReaderLabel: "Next month"
|
|
@@ -209,69 +209,87 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
209
209
|
yearList.push(DateTime.parse(year.toString(), this.locale(), this.timezone()).format('YYYY'));
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
return
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
212
|
+
return _jsxs("div", {
|
|
213
|
+
children: [_jsxs("div", {
|
|
214
|
+
css: style,
|
|
215
|
+
children: [prevButton && cloneButton(prevButton, this.handleMonthChange('prev')), renderNavigationLabel ? callRenderProp(renderNavigationLabel) : _jsxs("span", {
|
|
216
|
+
children: [_jsx("div", {
|
|
217
|
+
children: visibleMonth.format('MMMM')
|
|
218
|
+
}), !withYearPicker ? _jsx("div", {
|
|
219
|
+
children: visibleMonth.format('YYYY')
|
|
220
|
+
}) : null]
|
|
221
|
+
}), nextButton && cloneButton(nextButton, this.handleMonthChange('next'))]
|
|
222
|
+
}), withYearPicker ? _jsx("div", {
|
|
223
|
+
css: styles === null || styles === void 0 ? void 0 : styles.yearPicker,
|
|
224
|
+
children: _jsx(SimpleSelect, {
|
|
225
|
+
width: "90px",
|
|
226
|
+
renderLabel: "",
|
|
227
|
+
placeholder: "--",
|
|
228
|
+
assistiveText: withYearPicker.screenReaderLabel,
|
|
229
|
+
value: visibleMonth.format('YYYY'),
|
|
230
|
+
onChange: (e, {
|
|
231
|
+
value
|
|
232
|
+
}) => this.handleYearChange(e, `${value}`),
|
|
233
|
+
children: yearList.map(year => _jsx(SimpleSelect.Option, {
|
|
234
|
+
id: `opt-${year}`,
|
|
235
|
+
value: year,
|
|
236
|
+
children: `${year}`
|
|
237
|
+
}, year))
|
|
238
|
+
})
|
|
239
|
+
}) : null]
|
|
240
|
+
});
|
|
230
241
|
}
|
|
231
242
|
renderBody() {
|
|
232
|
-
return
|
|
233
|
-
role: this.role
|
|
234
|
-
|
|
243
|
+
return _jsxs("table", {
|
|
244
|
+
role: this.role,
|
|
245
|
+
children: [_jsx("thead", {
|
|
246
|
+
children: this.renderWeekdayHeaders()
|
|
247
|
+
}), _jsx("tbody", {
|
|
248
|
+
children: this.renderDays()
|
|
249
|
+
})]
|
|
250
|
+
});
|
|
235
251
|
}
|
|
236
252
|
renderWeekdayHeaders() {
|
|
237
253
|
const styles = this.props.styles;
|
|
238
254
|
const renderWeekdayLabels = this.props.renderWeekdayLabels || this.defaultWeekdays;
|
|
239
255
|
const length = renderWeekdayLabels.length;
|
|
240
256
|
error(length === 7, `[Calendar] \`renderWeekdayLabels\` should be an array with 7 labels (one for each weekday). ${length} provided.`);
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
257
|
+
return _jsx("tr", {
|
|
258
|
+
children: renderWeekdayLabels.map((label, i) => {
|
|
259
|
+
return _jsx("th", {
|
|
260
|
+
scope: "col",
|
|
261
|
+
css: styles === null || styles === void 0 ? void 0 : styles.weekdayHeader,
|
|
262
|
+
id: this._weekdayHeaderIds[i],
|
|
263
|
+
children: callRenderProp(label)
|
|
264
|
+
}, i);
|
|
265
|
+
})
|
|
266
|
+
});
|
|
249
267
|
}
|
|
250
268
|
get defaultWeekdays() {
|
|
251
269
|
const shortDayNames = DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'short');
|
|
252
270
|
const longDayNames = DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'long');
|
|
253
|
-
return [
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
},
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
},
|
|
271
|
+
return [_jsx(AccessibleContent, {
|
|
272
|
+
alt: longDayNames[0],
|
|
273
|
+
children: shortDayNames[0]
|
|
274
|
+
}, 1), _jsx(AccessibleContent, {
|
|
275
|
+
alt: longDayNames[1],
|
|
276
|
+
children: shortDayNames[1]
|
|
277
|
+
}, 2), _jsx(AccessibleContent, {
|
|
278
|
+
alt: longDayNames[2],
|
|
279
|
+
children: shortDayNames[2]
|
|
280
|
+
}, 3), _jsx(AccessibleContent, {
|
|
281
|
+
alt: longDayNames[3],
|
|
282
|
+
children: shortDayNames[3]
|
|
283
|
+
}, 4), _jsx(AccessibleContent, {
|
|
284
|
+
alt: longDayNames[4],
|
|
285
|
+
children: shortDayNames[4]
|
|
286
|
+
}, 5), _jsx(AccessibleContent, {
|
|
287
|
+
alt: longDayNames[5],
|
|
288
|
+
children: shortDayNames[5]
|
|
289
|
+
}, 6), _jsx(AccessibleContent, {
|
|
290
|
+
alt: longDayNames[6],
|
|
291
|
+
children: shortDayNames[6]
|
|
292
|
+
}, 7)];
|
|
275
293
|
}
|
|
276
294
|
renderDays() {
|
|
277
295
|
const children = this.props.children;
|
|
@@ -284,15 +302,15 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
284
302
|
if (!days[index]) days.push([]);
|
|
285
303
|
days[index].push(day);
|
|
286
304
|
return days; // 7xN 2D array of `Day`s
|
|
287
|
-
}, []).map(row =>
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
305
|
+
}, []).map(row => _jsx("tr", {
|
|
306
|
+
role: role,
|
|
307
|
+
children: row.map((day, i) => _jsx("td", {
|
|
308
|
+
role: role,
|
|
309
|
+
children: role === 'presentation' ? safeCloneElement(day, {
|
|
310
|
+
'aria-describedby': this._weekdayHeaderIds[i]
|
|
311
|
+
}) : day
|
|
312
|
+
}, day.props.date))
|
|
313
|
+
}, `row${row[0].props.date}`));
|
|
296
314
|
}
|
|
297
315
|
locale() {
|
|
298
316
|
if (this.props.locale) {
|
|
@@ -357,8 +375,7 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
357
375
|
}
|
|
358
376
|
return arr.map(date => {
|
|
359
377
|
const dateStr = date.toISOString();
|
|
360
|
-
return
|
|
361
|
-
key: dateStr,
|
|
378
|
+
return _jsx(Calendar.Day, {
|
|
362
379
|
date: dateStr,
|
|
363
380
|
isSelected: selectedDate ? date.isSame(selectedDate, 'day') : false,
|
|
364
381
|
isToday: date.isSame(today, 'day'),
|
|
@@ -366,19 +383,22 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
366
383
|
label: date.format('D MMMM YYYY') // used by screen readers
|
|
367
384
|
,
|
|
368
385
|
onClick: this.handleDayClick,
|
|
369
|
-
interaction: this.isDisabledDate(date) ? 'disabled' : 'enabled'
|
|
370
|
-
|
|
386
|
+
interaction: this.isDisabledDate(date) ? 'disabled' : 'enabled',
|
|
387
|
+
children: date.format('DD')
|
|
388
|
+
}, dateStr);
|
|
371
389
|
});
|
|
372
390
|
}
|
|
373
391
|
render() {
|
|
374
392
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Calendar.allowedProps), Calendar);
|
|
375
|
-
return
|
|
393
|
+
return _jsxs(View, {
|
|
394
|
+
...passthroughProps,
|
|
376
395
|
as: this.props.as,
|
|
377
396
|
display: "inline-block",
|
|
378
397
|
padding: "small",
|
|
379
398
|
background: "primary",
|
|
380
|
-
elementRef: this.handleRef
|
|
381
|
-
|
|
399
|
+
elementRef: this.handleRef,
|
|
400
|
+
children: [this.renderHeader(), this.renderBody()]
|
|
401
|
+
});
|
|
382
402
|
}
|
|
383
403
|
}, _Calendar.displayName = "Calendar", _Calendar.componentId = 'Calendar', _Calendar.contextType = ApplyLocaleContext, _Calendar.Day = Day, _Calendar.DAY_COUNT = 42, _Calendar.propTypes = propTypes, _Calendar.allowedProps = allowedProps, _Calendar.defaultProps = {
|
|
384
404
|
as: 'span',
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _react =
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
4
|
+
var _react = require("@testing-library/react");
|
|
6
5
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
7
6
|
var _vitest = require("vitest");
|
|
8
7
|
require("@testing-library/jest-dom");
|
|
@@ -10,6 +9,7 @@ var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yT
|
|
|
10
9
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
11
10
|
var _index = require("../index");
|
|
12
11
|
var _Day12 = _interopRequireDefault(require("../__examples__/Day.examples"));
|
|
12
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
13
|
var _Day, _Day2, _Day3, _Day4, _Day5, _Day6, _Day7, _Day8, _Day9, _Day10, _Day11;
|
|
14
14
|
/*
|
|
15
15
|
* The MIT License (MIT)
|
|
@@ -37,113 +37,125 @@ var _Day, _Day2, _Day3, _Day4, _Day5, _Day6, _Day7, _Day8, _Day9, _Day10, _Day11
|
|
|
37
37
|
// eslint-disable-next-line no-restricted-imports
|
|
38
38
|
describe('Day', () => {
|
|
39
39
|
it('should render children', async () => {
|
|
40
|
-
const _render = (0,
|
|
40
|
+
const _render = (0, _react.render)(_Day || (_Day = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
41
41
|
date: "2019-08-02",
|
|
42
|
-
label: "1 August 2019 Friday"
|
|
43
|
-
|
|
42
|
+
label: "1 August 2019 Friday",
|
|
43
|
+
children: "8"
|
|
44
|
+
}))),
|
|
44
45
|
rerender = _render.rerender;
|
|
45
|
-
const child =
|
|
46
|
+
const child = _react.screen.getByText('8');
|
|
46
47
|
expect(child).toBeInTheDocument();
|
|
47
|
-
rerender(_Day2 || (_Day2 =
|
|
48
|
+
rerender(_Day2 || (_Day2 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
48
49
|
date: "2019-08-02",
|
|
49
|
-
label: "1 August 2019 Friday"
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
label: "1 August 2019 Friday",
|
|
51
|
+
children: "31"
|
|
52
|
+
})));
|
|
53
|
+
const childUpdated = _react.screen.getByText('31');
|
|
52
54
|
expect(childUpdated).toBeInTheDocument();
|
|
53
55
|
});
|
|
54
56
|
it('should have an accessible label', async () => {
|
|
55
57
|
const label = '1 August 2019 Friday';
|
|
56
|
-
const _render2 = (0,
|
|
58
|
+
const _render2 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
57
59
|
date: "2019-08-02",
|
|
58
|
-
label: label
|
|
59
|
-
|
|
60
|
+
label: label,
|
|
61
|
+
children: "8"
|
|
62
|
+
})),
|
|
60
63
|
container = _render2.container;
|
|
61
|
-
const screenReaderContent = container.querySelector('[class
|
|
64
|
+
const screenReaderContent = container.querySelector('[class*="-screenReaderContent"]');
|
|
62
65
|
expect(screenReaderContent).toBeInTheDocument();
|
|
63
66
|
expect(screenReaderContent).toHaveTextContent(label);
|
|
64
67
|
});
|
|
65
68
|
it('should set aria-current="date" when `isToday`', async () => {
|
|
66
|
-
const _render3 = (0,
|
|
69
|
+
const _render3 = (0, _react.render)(_Day3 || (_Day3 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
67
70
|
date: "2019-08-02",
|
|
68
71
|
label: "1 August 2019 Friday",
|
|
69
|
-
isToday: true
|
|
70
|
-
|
|
72
|
+
isToday: true,
|
|
73
|
+
children: "8"
|
|
74
|
+
}))),
|
|
71
75
|
container = _render3.container,
|
|
72
76
|
rerender = _render3.rerender;
|
|
73
|
-
const today = container.querySelector('[class
|
|
77
|
+
const today = container.querySelector('[class*="-calendarDay"]');
|
|
74
78
|
expect(today).toHaveAttribute('aria-current', 'date');
|
|
75
|
-
rerender(_Day4 || (_Day4 =
|
|
79
|
+
rerender(_Day4 || (_Day4 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
76
80
|
date: "2019-08-02",
|
|
77
81
|
label: "1 August 2019 Friday",
|
|
78
|
-
isToday: false
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
isToday: false,
|
|
83
|
+
children: "8"
|
|
84
|
+
})));
|
|
85
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
81
86
|
expect(day).not.toHaveAttribute('aria-current', 'date');
|
|
82
87
|
});
|
|
83
88
|
it('should not set aria-selected without a role', async () => {
|
|
84
|
-
const _render4 = (0,
|
|
89
|
+
const _render4 = (0, _react.render)(_Day5 || (_Day5 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
85
90
|
date: "2019-08-02",
|
|
86
|
-
label: "1 August 2019 Friday"
|
|
87
|
-
|
|
91
|
+
label: "1 August 2019 Friday",
|
|
92
|
+
children: "8"
|
|
93
|
+
}))),
|
|
88
94
|
container = _render4.container,
|
|
89
95
|
rerender = _render4.rerender;
|
|
90
|
-
const day = container.querySelector('[class
|
|
96
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
91
97
|
expect(day).not.toHaveAttribute('aria-selected');
|
|
92
|
-
rerender(_Day6 || (_Day6 =
|
|
98
|
+
rerender(_Day6 || (_Day6 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
93
99
|
date: "2019-08-02",
|
|
94
100
|
label: "1 August 2019 Friday",
|
|
95
|
-
isSelected: true
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
isSelected: true,
|
|
102
|
+
children: "8"
|
|
103
|
+
})));
|
|
104
|
+
const daySelected = container.querySelector('[class*="-calendarDay"]');
|
|
98
105
|
expect(daySelected).not.toHaveAttribute('aria-selected');
|
|
99
106
|
});
|
|
100
107
|
it('should set aria-selected="true/false" when `isSelected` and `role` is `option` or `gridcell`', async () => {
|
|
101
|
-
const _render5 = (0,
|
|
108
|
+
const _render5 = (0, _react.render)(_Day7 || (_Day7 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
102
109
|
date: "2019-08-02",
|
|
103
110
|
label: "1 August 2019 Friday",
|
|
104
|
-
role: "option"
|
|
105
|
-
|
|
111
|
+
role: "option",
|
|
112
|
+
children: "8"
|
|
113
|
+
}))),
|
|
106
114
|
container = _render5.container,
|
|
107
115
|
rerender = _render5.rerender;
|
|
108
|
-
const day = container.querySelector('[class
|
|
116
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
109
117
|
expect(day).toHaveAttribute('aria-selected', 'false');
|
|
110
|
-
rerender(_Day8 || (_Day8 =
|
|
118
|
+
rerender(_Day8 || (_Day8 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
111
119
|
date: "2019-08-02",
|
|
112
120
|
label: "1 August 2019 Friday",
|
|
113
121
|
role: "option",
|
|
114
|
-
isSelected: true
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
isSelected: true,
|
|
123
|
+
children: "8"
|
|
124
|
+
})));
|
|
125
|
+
const daySelected = container.querySelector('[class*="-calendarDay"]');
|
|
117
126
|
expect(daySelected).toHaveAttribute('aria-selected', 'true');
|
|
118
|
-
rerender(_Day9 || (_Day9 =
|
|
127
|
+
rerender(_Day9 || (_Day9 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
119
128
|
date: "2019-08-02",
|
|
120
129
|
label: "1 August 2019 Friday",
|
|
121
130
|
role: "gridcell",
|
|
122
|
-
isSelected: false
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
isSelected: false,
|
|
132
|
+
children: "8"
|
|
133
|
+
})));
|
|
134
|
+
const dayCell = container.querySelector('[class*="-calendarDay"]');
|
|
125
135
|
expect(dayCell).toHaveAttribute('aria-selected', 'false');
|
|
126
|
-
rerender(_Day10 || (_Day10 =
|
|
136
|
+
rerender(_Day10 || (_Day10 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
127
137
|
date: "2019-08-02",
|
|
128
138
|
label: "1 August 2019 Friday",
|
|
129
139
|
role: "gridcell",
|
|
130
|
-
isSelected: true
|
|
131
|
-
|
|
132
|
-
|
|
140
|
+
isSelected: true,
|
|
141
|
+
children: "8"
|
|
142
|
+
})));
|
|
143
|
+
const dayCellSelected = container.querySelector('[class*="-calendarDay"]');
|
|
133
144
|
expect(dayCellSelected).toHaveAttribute('aria-selected', 'true');
|
|
134
145
|
});
|
|
135
146
|
it('should call onClick with date', async () => {
|
|
136
147
|
const onClick = _vitest.vi.fn();
|
|
137
148
|
const date = '2019-08-02';
|
|
138
|
-
const _render6 = (0,
|
|
149
|
+
const _render6 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
139
150
|
date: date,
|
|
140
151
|
label: "1 August 2019 Friday",
|
|
141
|
-
onClick: onClick
|
|
142
|
-
|
|
152
|
+
onClick: onClick,
|
|
153
|
+
children: "8"
|
|
154
|
+
})),
|
|
143
155
|
container = _render6.container;
|
|
144
|
-
const day = container.querySelector('[class
|
|
156
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
145
157
|
await _userEvent.default.click(day);
|
|
146
|
-
await (0,
|
|
158
|
+
await (0, _react.waitFor)(() => {
|
|
147
159
|
const args = onClick.mock.calls[0][1];
|
|
148
160
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
149
161
|
expect(args).toHaveProperty('date', date);
|
|
@@ -152,16 +164,17 @@ describe('Day', () => {
|
|
|
152
164
|
it('should call onKeyDown with date', async () => {
|
|
153
165
|
const onKeyDown = _vitest.vi.fn();
|
|
154
166
|
const date = '2019-08-02';
|
|
155
|
-
const _render7 = (0,
|
|
167
|
+
const _render7 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
156
168
|
date: date,
|
|
157
169
|
label: "1 August 2019 Friday",
|
|
158
170
|
onKeyDown: onKeyDown,
|
|
159
|
-
onClick: () => {}
|
|
160
|
-
|
|
171
|
+
onClick: () => {},
|
|
172
|
+
children: "8"
|
|
173
|
+
})),
|
|
161
174
|
container = _render7.container;
|
|
162
|
-
const day = container.querySelector('[class
|
|
175
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
163
176
|
_userEvent.default.type(day, '{enter}');
|
|
164
|
-
await (0,
|
|
177
|
+
await (0, _react.waitFor)(() => {
|
|
165
178
|
const args = onKeyDown.mock.calls[0][1];
|
|
166
179
|
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
167
180
|
expect(args).toHaveProperty('date', date);
|
|
@@ -169,16 +182,17 @@ describe('Day', () => {
|
|
|
169
182
|
});
|
|
170
183
|
it('should apply disabled when interaction is `disabled`', async () => {
|
|
171
184
|
const onClick = _vitest.vi.fn();
|
|
172
|
-
const _render8 = (0,
|
|
185
|
+
const _render8 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
173
186
|
date: "2019-08-02",
|
|
174
187
|
label: "1 August 2019 Friday",
|
|
175
188
|
onClick: onClick,
|
|
176
|
-
interaction: "disabled"
|
|
177
|
-
|
|
189
|
+
interaction: "disabled",
|
|
190
|
+
children: "8"
|
|
191
|
+
})),
|
|
178
192
|
container = _render8.container;
|
|
179
|
-
const day = container.querySelector('[class
|
|
193
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
180
194
|
_userEvent.default.click(day);
|
|
181
|
-
await (0,
|
|
195
|
+
await (0, _react.waitFor)(() => {
|
|
182
196
|
expect(onClick).not.toHaveBeenCalled();
|
|
183
197
|
expect(day).toHaveAttribute('disabled');
|
|
184
198
|
});
|
|
@@ -188,44 +202,48 @@ describe('Day', () => {
|
|
|
188
202
|
const elementRef = el => {
|
|
189
203
|
element = el;
|
|
190
204
|
};
|
|
191
|
-
const _render9 = (0,
|
|
205
|
+
const _render9 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
192
206
|
date: "2019-08-02",
|
|
193
207
|
label: "1 August 2019 Friday",
|
|
194
|
-
elementRef: elementRef
|
|
195
|
-
|
|
208
|
+
elementRef: elementRef,
|
|
209
|
+
children: "8"
|
|
210
|
+
})),
|
|
196
211
|
container = _render9.container;
|
|
197
|
-
const day = container.querySelector('[class
|
|
212
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
198
213
|
expect(day).toEqual(element);
|
|
199
214
|
});
|
|
200
215
|
describe('element type', () => {
|
|
201
216
|
it('should render as a span by default', async () => {
|
|
202
|
-
const _render10 = (0,
|
|
217
|
+
const _render10 = (0, _react.render)(_Day11 || (_Day11 = (0, _jsxRuntime.jsx)(_index.Day, {
|
|
203
218
|
date: "2019-08-02",
|
|
204
|
-
label: "1 August 2019 Friday"
|
|
205
|
-
|
|
219
|
+
label: "1 August 2019 Friday",
|
|
220
|
+
children: "8"
|
|
221
|
+
}))),
|
|
206
222
|
container = _render10.container;
|
|
207
|
-
const day = container.querySelector('[class
|
|
223
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
208
224
|
expect(day === null || day === void 0 ? void 0 : day.tagName).toEqual('SPAN');
|
|
209
225
|
});
|
|
210
226
|
it('should render as a button when onClick is provided', async () => {
|
|
211
|
-
const _render11 = (0,
|
|
227
|
+
const _render11 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
212
228
|
date: "2019-08-02",
|
|
213
229
|
label: "1 August 2019 Friday",
|
|
214
|
-
onClick: () => {}
|
|
215
|
-
|
|
230
|
+
onClick: () => {},
|
|
231
|
+
children: "8"
|
|
232
|
+
})),
|
|
216
233
|
container = _render11.container;
|
|
217
|
-
const day = container.querySelector('[class
|
|
234
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
218
235
|
expect(day === null || day === void 0 ? void 0 : day.tagName).toEqual('BUTTON');
|
|
219
236
|
});
|
|
220
237
|
it('default elementTypes should be overwritten when `as` prop is set', async () => {
|
|
221
|
-
const _render12 = (0,
|
|
238
|
+
const _render12 = (0, _react.render)((0, _jsxRuntime.jsx)(_index.Day, {
|
|
222
239
|
date: "2019-08-02",
|
|
223
240
|
label: "1 August 2019 Friday",
|
|
224
241
|
onClick: () => {},
|
|
225
|
-
as: "li"
|
|
226
|
-
|
|
242
|
+
as: "li",
|
|
243
|
+
children: "8"
|
|
244
|
+
})),
|
|
227
245
|
container = _render12.container;
|
|
228
|
-
const day = container.querySelector('[class
|
|
246
|
+
const day = container.querySelector('[class*="-calendarDay"]');
|
|
229
247
|
expect(day === null || day === void 0 ? void 0 : day.tagName).toEqual('LI');
|
|
230
248
|
});
|
|
231
249
|
});
|
|
@@ -233,7 +251,7 @@ describe('Day', () => {
|
|
|
233
251
|
const generatedComponents = (0, _generateA11yTests.generateA11yTests)(_index.Day, _Day12.default);
|
|
234
252
|
for (const component of generatedComponents) {
|
|
235
253
|
it(component.description, async () => {
|
|
236
|
-
const _render13 = (0,
|
|
254
|
+
const _render13 = (0, _react.render)(component.content),
|
|
237
255
|
container = _render13.container;
|
|
238
256
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
239
257
|
expect(axeCheck).toBe(true);
|
|
@@ -17,6 +17,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
17
17
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
18
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
19
19
|
var _props = require("./props");
|
|
20
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
20
21
|
const _excluded = ["children", "label", "interaction", "isOutsideMonth", "isSelected", "isToday", "onClick", "onKeyDown", "as", "styles"];
|
|
21
22
|
var _dec, _dec2, _class, _Day;
|
|
22
23
|
/*
|
|
@@ -42,7 +43,6 @@ var _dec, _dec2, _class, _Day;
|
|
|
42
43
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
44
|
* SOFTWARE.
|
|
44
45
|
*/
|
|
45
|
-
/** @jsx jsx */
|
|
46
46
|
/**
|
|
47
47
|
---
|
|
48
48
|
parent: Calendar
|
|
@@ -122,7 +122,8 @@ let Day = exports.Day = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.
|
|
|
122
122
|
const elementType = this.elementType,
|
|
123
123
|
isDisabled = this.isDisabled;
|
|
124
124
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(props, Day.allowedProps), Day);
|
|
125
|
-
return (0,
|
|
125
|
+
return (0, _jsxRuntime.jsx)(_View.View, {
|
|
126
|
+
...passthroughProps,
|
|
126
127
|
as: elementType,
|
|
127
128
|
css: styles === null || styles === void 0 ? void 0 : styles.calendarDay,
|
|
128
129
|
display: "inline-block",
|
|
@@ -136,12 +137,15 @@ let Day = exports.Day = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.
|
|
|
136
137
|
"aria-selected": this.shouldApplyAriaSelected() ? isSelected ? 'true' : 'false' : void 0,
|
|
137
138
|
onClick: onClick && this.handleClick,
|
|
138
139
|
onKeyDown: onKeyDown && this.handleKeyDown,
|
|
139
|
-
elementRef: this.handleElementRef
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
elementRef: this.handleElementRef,
|
|
141
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
142
|
+
css: styles === null || styles === void 0 ? void 0 : styles.day,
|
|
143
|
+
children: (0, _jsxRuntime.jsx)(_AccessibleContent.AccessibleContent, {
|
|
144
|
+
alt: label,
|
|
145
|
+
children: (0, _callRenderProp.callRenderProp)(children)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
});
|
|
145
149
|
}
|
|
146
150
|
}, _Day.displayName = "Day", _Day.componentId = 'Calendar.Day', _Day.propTypes = _props.propTypes, _Day.allowedProps = _props.allowedProps, _Day.defaultProps = {
|
|
147
151
|
interaction: 'enabled',
|