@atlaskit/calendar 13.1.16 → 13.2.0
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 +12 -0
- package/dist/cjs/calendar.js +46 -12
- package/dist/cjs/internal/components/date.js +50 -22
- package/dist/cjs/internal/components/header.js +26 -11
- package/dist/cjs/internal/components/week-days.js +7 -0
- package/dist/cjs/internal/components/week-header.js +14 -16
- package/dist/cjs/internal/hooks/use-get-weeks.js +6 -2
- package/dist/cjs/internal/hooks/use-handle-date-change.js +6 -1
- package/dist/cjs/internal/hooks/use-locale.js +5 -1
- package/dist/cjs/internal/styles/date.js +27 -29
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/calendar.js +45 -14
- package/dist/es2019/internal/components/date.js +50 -22
- package/dist/es2019/internal/components/header.js +26 -11
- package/dist/es2019/internal/components/week-days.js +7 -0
- package/dist/es2019/internal/components/week-header.js +5 -6
- package/dist/es2019/internal/hooks/use-get-weeks.js +6 -2
- package/dist/es2019/internal/hooks/use-handle-date-change.js +4 -1
- package/dist/es2019/internal/hooks/use-locale.js +3 -1
- package/dist/es2019/internal/styles/date.js +6 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/calendar.js +47 -13
- package/dist/esm/internal/components/date.js +50 -22
- package/dist/esm/internal/components/header.js +26 -11
- package/dist/esm/internal/components/week-days.js +7 -0
- package/dist/esm/internal/components/week-header.js +14 -16
- package/dist/esm/internal/hooks/use-get-weeks.js +6 -2
- package/dist/esm/internal/hooks/use-handle-date-change.js +6 -1
- package/dist/esm/internal/hooks/use-locale.js +5 -1
- package/dist/esm/internal/styles/date.js +27 -30
- package/dist/esm/version.json +1 -1
- package/dist/types/calendar.d.ts +1 -1
- package/dist/types/internal/components/date.d.ts +5 -0
- package/dist/types/internal/components/header.d.ts +5 -0
- package/dist/types/internal/components/week-days.d.ts +4 -0
- package/dist/types/internal/hooks/use-get-weeks.d.ts +2 -1
- package/dist/types/internal/hooks/use-handle-date-change.d.ts +2 -1
- package/dist/types/internal/hooks/use-locale.d.ts +1 -0
- package/dist/types/internal/types.d.ts +1 -0
- package/dist/types/types.d.ts +4 -2
- package/dist/types-ts4.5/calendar.d.ts +1 -1
- package/dist/types-ts4.5/internal/components/date.d.ts +5 -0
- package/dist/types-ts4.5/internal/components/header.d.ts +5 -0
- package/dist/types-ts4.5/internal/components/week-days.d.ts +4 -0
- package/dist/types-ts4.5/internal/hooks/use-get-weeks.d.ts +2 -1
- package/dist/types-ts4.5/internal/hooks/use-handle-date-change.d.ts +5 -1
- package/dist/types-ts4.5/internal/hooks/use-locale.d.ts +1 -0
- package/dist/types-ts4.5/internal/types.d.ts +1 -0
- package/dist/types-ts4.5/types.d.ts +4 -2
- package/package.json +12 -5
- package/report.api.md +4 -1
- package/tmp/api-report-tmp.d.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/calendar
|
|
2
2
|
|
|
3
|
+
## 13.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b5716b91b31`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b5716b91b31) - [ux] We are testing adding keyboard accessibility for Calendar behind a feature flag. This will add more affordances for users of assistive technologies to use the calendar, and updates the `tabIndex` prop to only use recommended values. If this fix is successful it will be available in a later release.
|
|
8
|
+
|
|
9
|
+
## 13.1.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`0ed39bbcb73`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0ed39bbcb73) - [ux] correct fallback color of focused state to meet contrast requirement
|
|
14
|
+
|
|
3
15
|
## 13.1.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/calendar.js
CHANGED
|
@@ -12,6 +12,7 @@ var _react = require("react");
|
|
|
12
12
|
var _react2 = require("@emotion/react");
|
|
13
13
|
var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
|
|
14
14
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _primitives = require("@atlaskit/primitives");
|
|
16
17
|
var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
|
|
17
18
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
@@ -36,7 +37,7 @@ var boxStyles = (0, _primitives.xcss)({
|
|
|
36
37
|
var analyticsAttributes = {
|
|
37
38
|
componentName: 'calendar',
|
|
38
39
|
packageName: "@atlaskit/calendar",
|
|
39
|
-
packageVersion: "13.
|
|
40
|
+
packageVersion: "13.2.0"
|
|
40
41
|
};
|
|
41
42
|
var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_ref, ref) {
|
|
42
43
|
var day = _ref.day,
|
|
@@ -112,6 +113,10 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
112
113
|
_useControlledDateSta7 = (0, _slicedToArray2.default)(_useControlledDateSta.previous, 2),
|
|
113
114
|
previouslySelectedValue = _useControlledDateSta7[0],
|
|
114
115
|
setPreviouslySelectedValue = _useControlledDateSta7[1];
|
|
116
|
+
var _useState = (0, _react.useState)(false),
|
|
117
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
118
|
+
shouldSetFocus = _useState2[0],
|
|
119
|
+
setShouldSetFocus = _useState2[1];
|
|
115
120
|
var onChangeWithAnalytics = (0, _usePlatformLeafEventHandler.usePlatformLeafEventHandler)(_objectSpread({
|
|
116
121
|
fn: onChange,
|
|
117
122
|
action: 'changed',
|
|
@@ -121,6 +126,7 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
121
126
|
day: [dayValue, setDayValue],
|
|
122
127
|
month: [monthValue, setMonthValue],
|
|
123
128
|
year: [yearValue, setYearValue],
|
|
129
|
+
shouldSetFocus: [shouldSetFocus, setShouldSetFocus],
|
|
124
130
|
onChange: onChangeWithAnalytics
|
|
125
131
|
}),
|
|
126
132
|
navigate = _useHandleDateChange.navigate,
|
|
@@ -151,6 +157,13 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
151
157
|
(0, _useCalendarRef.default)(calendarRef, {
|
|
152
158
|
navigate: navigate
|
|
153
159
|
});
|
|
160
|
+
var _useLocale = (0, _useLocale2.default)({
|
|
161
|
+
locale: locale,
|
|
162
|
+
weekStartDay: weekStartDay
|
|
163
|
+
}),
|
|
164
|
+
monthsLong = _useLocale.monthsLong,
|
|
165
|
+
daysShort = _useLocale.daysShort,
|
|
166
|
+
daysLong = _useLocale.daysLong;
|
|
154
167
|
var weeks = (0, _useGetWeeks.default)({
|
|
155
168
|
day: dayValue,
|
|
156
169
|
month: monthValue,
|
|
@@ -162,18 +175,28 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
162
175
|
disabledDateFilter: disabledDateFilter,
|
|
163
176
|
minDate: minDate,
|
|
164
177
|
maxDate: maxDate,
|
|
178
|
+
daysLong: daysLong,
|
|
165
179
|
weekStartDay: weekStartDay
|
|
166
180
|
});
|
|
167
181
|
var announceId = (0, _useUniqueId.default)('announce');
|
|
168
182
|
var announcerDate = (0, _react.useMemo)(function () {
|
|
169
183
|
return new Date(yearValue, monthValue - 1, dayValue).toString();
|
|
170
184
|
}, [dayValue, monthValue, yearValue]);
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
185
|
+
var getNextHeading = function getNextHeading() {
|
|
186
|
+
// Next month is (currentMonth - 1) + 1, or just currentMonth in this
|
|
187
|
+
// instance.
|
|
188
|
+
var nextMonth = monthValue % 12;
|
|
189
|
+
var showNextYear = monthValue === 12;
|
|
190
|
+
return "".concat(monthsLong[nextMonth], " ").concat(showNextYear ? yearValue + 1 : yearValue);
|
|
191
|
+
};
|
|
192
|
+
var getPreviousHeading = function getPreviousHeading() {
|
|
193
|
+
// Previous month is (monthValue - 1) - 1. Need to add 12 so the modulo
|
|
194
|
+
// works as expected and stays positive.
|
|
195
|
+
var previousMonth = (monthValue + 12 - 2) % 12;
|
|
196
|
+
var showPreviousYear = monthValue === 1;
|
|
197
|
+
return "".concat(monthsLong[previousMonth], " ").concat(showPreviousYear ? yearValue - 1 : yearValue);
|
|
198
|
+
};
|
|
199
|
+
var headerId = (0, _useUniqueId.default)('month-year-header');
|
|
177
200
|
return (
|
|
178
201
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/no-static-element-interactions
|
|
179
202
|
(0, _react2.jsx)("div", {
|
|
@@ -181,19 +204,19 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
181
204
|
style: style,
|
|
182
205
|
onBlur: handleContainerBlur,
|
|
183
206
|
onFocus: handleContainerFocus,
|
|
184
|
-
onKeyDown: handleContainerKeyDown,
|
|
207
|
+
onKeyDown: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? undefined : handleContainerKeyDown,
|
|
185
208
|
"data-testid": testId && "".concat(testId, "--container"),
|
|
186
209
|
ref: ref
|
|
187
|
-
}, (0, _react2.jsx)(_visuallyHidden.default, null, (0, _react2.jsx)("span", {
|
|
210
|
+
}, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? null : (0, _react2.jsx)(_visuallyHidden.default, null, (0, _react2.jsx)("span", {
|
|
188
211
|
id: announceId,
|
|
189
212
|
"aria-live": "assertive",
|
|
190
213
|
"aria-relevant": "text"
|
|
191
214
|
}, announcerDate)), (0, _react2.jsx)(_primitives.Box, {
|
|
192
215
|
xcss: boxStyles,
|
|
193
216
|
padding: "space.200",
|
|
194
|
-
"aria-describedby": announceId,
|
|
217
|
+
"aria-describedby": (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? undefined : announceId,
|
|
195
218
|
"aria-label": "calendar",
|
|
196
|
-
tabIndex: tabIndex,
|
|
219
|
+
tabIndex: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? undefined : tabIndex,
|
|
197
220
|
testId: testId && "".concat(testId, "--calendar")
|
|
198
221
|
}, (0, _react2.jsx)(_primitives.Stack, {
|
|
199
222
|
space: "space.150"
|
|
@@ -205,12 +228,20 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
205
228
|
year: yearValue,
|
|
206
229
|
nextMonthLabel: nextMonthLabel,
|
|
207
230
|
previousMonthLabel: previousMonthLabel,
|
|
231
|
+
nextHeading: getNextHeading(),
|
|
232
|
+
previousHeading: getPreviousHeading(),
|
|
208
233
|
handleClickNext: handleClickNext,
|
|
209
234
|
handleClickPrev: handleClickPrev,
|
|
235
|
+
headerId: headerId,
|
|
210
236
|
mode: mode,
|
|
237
|
+
tabIndex: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : undefined,
|
|
211
238
|
testId: testId
|
|
212
239
|
}), (0, _react2.jsx)(_primitives.Box, {
|
|
213
|
-
role: "grid"
|
|
240
|
+
role: "grid",
|
|
241
|
+
tabIndex: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : undefined,
|
|
242
|
+
onKeyDown: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? handleContainerKeyDown : undefined,
|
|
243
|
+
"aria-labelledby": (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? headerId : undefined,
|
|
244
|
+
testId: testId && "".concat(testId, "--calendar-dates")
|
|
214
245
|
}, (0, _react2.jsx)(_weekHeader.default, {
|
|
215
246
|
daysShort: daysShort,
|
|
216
247
|
mode: mode,
|
|
@@ -219,6 +250,9 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
219
250
|
weeks: weeks,
|
|
220
251
|
handleClickDay: handleClickDay,
|
|
221
252
|
mode: mode,
|
|
253
|
+
monthsLong: monthsLong,
|
|
254
|
+
shouldSetFocus: shouldSetFocus,
|
|
255
|
+
tabIndex: tabIndex,
|
|
222
256
|
testId: testId
|
|
223
257
|
})))))
|
|
224
258
|
);
|
|
@@ -8,6 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _primitives = require("@atlaskit/primitives");
|
|
11
13
|
var _date = require("../styles/date");
|
|
12
14
|
/** @jsx jsx */
|
|
13
15
|
|
|
@@ -19,7 +21,9 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
19
21
|
isFocused = _ref$isFocused === void 0 ? false : _ref$isFocused,
|
|
20
22
|
_ref$isToday = _ref.isToday,
|
|
21
23
|
isToday = _ref$isToday === void 0 ? false : _ref$isToday,
|
|
24
|
+
dayLong = _ref.dayLong,
|
|
22
25
|
month = _ref.month,
|
|
26
|
+
monthLong = _ref.monthLong,
|
|
23
27
|
_ref$onClick = _ref.onClick,
|
|
24
28
|
onClick = _ref$onClick === void 0 ? _noop.default : _ref$onClick,
|
|
25
29
|
_ref$isPreviouslySele = _ref.isPreviouslySelected,
|
|
@@ -30,6 +34,8 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
30
34
|
isSibling = _ref$isSibling === void 0 ? false : _ref$isSibling,
|
|
31
35
|
year = _ref.year,
|
|
32
36
|
mode = _ref.mode,
|
|
37
|
+
shouldSetFocus = _ref.shouldSetFocus,
|
|
38
|
+
tabIndex = _ref.tabIndex,
|
|
33
39
|
testId = _ref.testId;
|
|
34
40
|
var dateRef = (0, _react.useRef)({
|
|
35
41
|
day: day,
|
|
@@ -45,6 +51,12 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
45
51
|
isDisabled: isDisabled
|
|
46
52
|
};
|
|
47
53
|
}, [day, month, year, isDisabled]);
|
|
54
|
+
var focusRef = (0, _react.useRef)(null);
|
|
55
|
+
(0, _react.useEffect)(function () {
|
|
56
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') && isFocused && shouldSetFocus && focusRef.current) {
|
|
57
|
+
focusRef.current.focus();
|
|
58
|
+
}
|
|
59
|
+
}, [isFocused, shouldSetFocus]);
|
|
48
60
|
var handleClick = (0, _react.useCallback)(function () {
|
|
49
61
|
var _dateRef$current = dateRef.current,
|
|
50
62
|
dayValue = _dateRef$current.day,
|
|
@@ -62,28 +74,44 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
62
74
|
var dateCellStyles = (0, _react.useMemo)(function () {
|
|
63
75
|
return (0, _react2.css)((0, _date.dateCellStyles)(mode));
|
|
64
76
|
}, [mode]);
|
|
65
|
-
return (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
77
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? (0, _react2.jsx)(_primitives.Grid, {
|
|
78
|
+
role: "gridcell",
|
|
79
|
+
alignItems: "center"
|
|
80
|
+
}, (0, _react2.jsx)("button", {
|
|
81
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
82
|
+
css: dateCellStyles,
|
|
83
|
+
"aria-current": isToday ? 'date' : undefined,
|
|
84
|
+
"aria-disabled": isDisabled || undefined,
|
|
85
|
+
"aria-label": "".concat(day, ", ").concat(dayLong, " ").concat(monthLong, " ").concat(year),
|
|
86
|
+
"aria-pressed": isSelected ? 'true' : 'false',
|
|
87
|
+
tabIndex: isFocused ? tabIndex : -1,
|
|
88
|
+
type: "button",
|
|
89
|
+
onClick: handleClick,
|
|
90
|
+
ref: focusRef,
|
|
91
|
+
"data-disabled": isDisabled || undefined,
|
|
92
|
+
"data-focused": isFocused || undefined,
|
|
93
|
+
"data-prev-selected": isPreviouslySelected || undefined,
|
|
94
|
+
"data-selected": isSelected || undefined,
|
|
95
|
+
"data-sibling": isSibling || undefined,
|
|
96
|
+
"data-today": isToday || undefined,
|
|
97
|
+
"data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day"))
|
|
98
|
+
}, day)) : (0, _react2.jsx)("button", {
|
|
99
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
100
|
+
css: dateCellStyles,
|
|
101
|
+
"aria-selected": isSelected ? 'true' : 'false',
|
|
102
|
+
tabIndex: isSelected ? 0 : -1,
|
|
103
|
+
type: "button",
|
|
104
|
+
role: "gridcell",
|
|
105
|
+
onClick: handleClick,
|
|
106
|
+
ref: ref,
|
|
107
|
+
"data-disabled": isDisabled || undefined,
|
|
108
|
+
"data-focused": isFocused || undefined,
|
|
109
|
+
"data-prev-selected": isPreviouslySelected || undefined,
|
|
110
|
+
"data-selected": isSelected || undefined,
|
|
111
|
+
"data-sibling": isSibling || undefined,
|
|
112
|
+
"data-today": isToday || undefined,
|
|
113
|
+
"data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day"))
|
|
114
|
+
}, day);
|
|
87
115
|
}));
|
|
88
116
|
Date.displayName = 'Date';
|
|
89
117
|
|
|
@@ -11,23 +11,36 @@ var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-
|
|
|
11
11
|
var _heading = _interopRequireDefault(require("@atlaskit/heading"));
|
|
12
12
|
var _chevronLeftLarge = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-left-large"));
|
|
13
13
|
var _chevronRightLarge = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-right-large"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _primitives = require("@atlaskit/primitives");
|
|
15
16
|
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
+
var _useUniqueId = _interopRequireDefault(require("../../internal/hooks/use-unique-id"));
|
|
16
18
|
/** @jsx jsx */
|
|
17
19
|
|
|
18
20
|
var Header = /*#__PURE__*/(0, _react.memo)(function Header(_ref) {
|
|
19
21
|
var monthLongTitle = _ref.monthLongTitle,
|
|
20
22
|
year = _ref.year,
|
|
21
23
|
_ref$previousMonthLab = _ref.previousMonthLabel,
|
|
22
|
-
previousMonthLabel = _ref$previousMonthLab === void 0 ? 'Last month' : _ref$previousMonthLab,
|
|
24
|
+
previousMonthLabel = _ref$previousMonthLab === void 0 ? (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'Previous month' : 'Last month' : _ref$previousMonthLab,
|
|
25
|
+
previousHeading = _ref.previousHeading,
|
|
23
26
|
_ref$nextMonthLabel = _ref.nextMonthLabel,
|
|
24
27
|
nextMonthLabel = _ref$nextMonthLabel === void 0 ? 'Next month' : _ref$nextMonthLabel,
|
|
28
|
+
nextHeading = _ref.nextHeading,
|
|
25
29
|
handleClickPrev = _ref.handleClickPrev,
|
|
26
30
|
handleClickNext = _ref.handleClickNext,
|
|
31
|
+
headerId = _ref.headerId,
|
|
32
|
+
tabIndex = _ref.tabIndex,
|
|
27
33
|
testId = _ref.testId;
|
|
34
|
+
var announceId = (0, _useUniqueId.default)('month-year-announce');
|
|
35
|
+
var renderedHeading = (0, _react2.jsx)(_heading.default, {
|
|
36
|
+
level: "h400",
|
|
37
|
+
as: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'h2' : 'div',
|
|
38
|
+
id: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? headerId : undefined,
|
|
39
|
+
testId: testId && "".concat(testId, "--current-month-year")
|
|
40
|
+
}, "".concat(monthLongTitle, " ").concat(year));
|
|
28
41
|
return (0, _react2.jsx)(_primitives.Box, {
|
|
29
42
|
paddingInline: "space.100",
|
|
30
|
-
"aria-hidden":
|
|
43
|
+
"aria-hidden": (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? undefined : 'true'
|
|
31
44
|
}, (0, _react2.jsx)(_primitives.Inline, {
|
|
32
45
|
space: "space.0",
|
|
33
46
|
alignBlock: "center",
|
|
@@ -35,27 +48,29 @@ var Header = /*#__PURE__*/(0, _react.memo)(function Header(_ref) {
|
|
|
35
48
|
}, (0, _react2.jsx)(_standardButton.default, {
|
|
36
49
|
appearance: "subtle",
|
|
37
50
|
spacing: "none",
|
|
38
|
-
tabIndex: -1,
|
|
51
|
+
tabIndex: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : -1,
|
|
39
52
|
onClick: handleClickPrev,
|
|
40
53
|
testId: testId && "".concat(testId, "--previous-month"),
|
|
41
54
|
iconBefore: (0, _react2.jsx)(_chevronLeftLarge.default, {
|
|
42
|
-
label: previousMonthLabel,
|
|
55
|
+
label: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? "".concat(previousMonthLabel, ", ").concat(previousHeading) : previousMonthLabel,
|
|
43
56
|
size: "medium",
|
|
44
57
|
primaryColor: "var(--ds-icon, ".concat(_colors.N700, ")"),
|
|
45
58
|
testId: testId && "".concat(testId, "--previous-month-icon")
|
|
46
59
|
})
|
|
47
|
-
}), (0,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
}), (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ?
|
|
61
|
+
// This is required to ensure that the new month/year is announced when the previous/next month buttons are activated
|
|
62
|
+
(0, _react2.jsx)(_primitives.Box, {
|
|
63
|
+
"aria-live": "polite",
|
|
64
|
+
id: announceId,
|
|
65
|
+
testId: testId && "".concat(testId, "--current-month-year--container")
|
|
66
|
+
}, renderedHeading) : renderedHeading, (0, _react2.jsx)(_standardButton.default, {
|
|
52
67
|
appearance: "subtle",
|
|
53
68
|
spacing: "none",
|
|
54
|
-
tabIndex: -1,
|
|
69
|
+
tabIndex: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : -1,
|
|
55
70
|
onClick: handleClickNext,
|
|
56
71
|
testId: testId && "".concat(testId, "--next-month"),
|
|
57
72
|
iconBefore: (0, _react2.jsx)(_chevronRightLarge.default, {
|
|
58
|
-
label: nextMonthLabel,
|
|
73
|
+
label: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? "".concat(nextMonthLabel, ", ").concat(nextHeading) : nextMonthLabel,
|
|
59
74
|
size: "medium",
|
|
60
75
|
primaryColor: "var(--ds-icon, ".concat(_colors.N700, ")"),
|
|
61
76
|
testId: testId && "".concat(testId, "--next-month-icon")
|
|
@@ -16,6 +16,9 @@ var WeekDays = /*#__PURE__*/(0, _react.memo)(function WeekDays(_ref) {
|
|
|
16
16
|
var weeks = _ref.weeks,
|
|
17
17
|
handleClickDay = _ref.handleClickDay,
|
|
18
18
|
mode = _ref.mode,
|
|
19
|
+
monthsLong = _ref.monthsLong,
|
|
20
|
+
shouldSetFocus = _ref.shouldSetFocus,
|
|
21
|
+
tabIndex = _ref.tabIndex,
|
|
19
22
|
testId = _ref.testId;
|
|
20
23
|
return (
|
|
21
24
|
// TODO: Determine if there is a better way to render the button (should be
|
|
@@ -34,13 +37,17 @@ var WeekDays = /*#__PURE__*/(0, _react.memo)(function WeekDays(_ref) {
|
|
|
34
37
|
isDisabled: weekDay.isDisabled,
|
|
35
38
|
isFocused: weekDay.isFocused,
|
|
36
39
|
isToday: weekDay.isToday,
|
|
40
|
+
dayLong: weekDay.weekDayName,
|
|
37
41
|
month: weekDay.month,
|
|
42
|
+
monthLong: monthsLong[weekDay.month - 1],
|
|
38
43
|
onClick: handleClickDay,
|
|
39
44
|
isPreviouslySelected: weekDay.isPreviouslySelected,
|
|
40
45
|
isSelected: weekDay.isSelected,
|
|
41
46
|
isSibling: weekDay.isSiblingMonth,
|
|
42
47
|
year: weekDay.year,
|
|
43
48
|
mode: mode,
|
|
49
|
+
shouldSetFocus: shouldSetFocus,
|
|
50
|
+
tabIndex: tabIndex,
|
|
44
51
|
testId: testId
|
|
45
52
|
}, weekDay.day);
|
|
46
53
|
}));
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _text = _interopRequireDefault(require("@atlaskit/ds-explorations/text"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _primitives = require("@atlaskit/primitives");
|
|
12
13
|
var _weekDayGrid = _interopRequireDefault(require("./week-day-grid"));
|
|
13
14
|
/** @jsx jsx */
|
|
@@ -28,22 +29,19 @@ var WeekHeader = /*#__PURE__*/(0, _react.memo)(function WeekHeader(_ref) {
|
|
|
28
29
|
return (0, _react2.jsx)(_weekDayGrid.default, {
|
|
29
30
|
testId: testId && "".concat(testId, "--column-headers")
|
|
30
31
|
}, daysShort.map(function (shortDay) {
|
|
31
|
-
return (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
textTransform: "uppercase"
|
|
45
|
-
}, shortDay))
|
|
46
|
-
);
|
|
32
|
+
return (0, _react2.jsx)(_primitives.Box, {
|
|
33
|
+
"aria-hidden": (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'true' : undefined,
|
|
34
|
+
padding: "space.100",
|
|
35
|
+
xcss: columnHeaderStyles,
|
|
36
|
+
key: shortDay,
|
|
37
|
+
role: "columnheader",
|
|
38
|
+
testId: testId && "".concat(testId, "--column-header")
|
|
39
|
+
}, (0, _react2.jsx)(_text.default, {
|
|
40
|
+
fontWeight: "bold",
|
|
41
|
+
fontSize: "size.050",
|
|
42
|
+
verticalAlign: "middle",
|
|
43
|
+
textTransform: "uppercase"
|
|
44
|
+
}, shortDay));
|
|
47
45
|
}));
|
|
48
46
|
});
|
|
49
47
|
WeekHeader.displayName = 'WeekHeader';
|
|
@@ -41,6 +41,7 @@ function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
|
41
41
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
42
42
|
function useGetWeeks(_ref2) {
|
|
43
43
|
var day = _ref2.day,
|
|
44
|
+
daysLong = _ref2.daysLong,
|
|
44
45
|
month = _ref2.month,
|
|
45
46
|
year = _ref2.year,
|
|
46
47
|
today = _ref2.today,
|
|
@@ -84,8 +85,10 @@ function useGetWeeks(_ref2) {
|
|
|
84
85
|
} else {
|
|
85
86
|
week = weeks[weeks.length - 1];
|
|
86
87
|
}
|
|
88
|
+
var weekDayOffset = (date.weekDay - weekStartDay) % 7;
|
|
87
89
|
|
|
88
90
|
// Define a bunch of `const`s
|
|
91
|
+
var weekDayName = daysLong[weekDayOffset];
|
|
89
92
|
var isDisabledByArray = disabled ? disabled.indexOf(dateAsString) > -1 : false;
|
|
90
93
|
var isDisabledByFilter = disabledDateFilter ? disabledDateFilter(dateAsString) : false;
|
|
91
94
|
var isDisabledByMin = minDate && JSDate ? JSDate < minDate : false;
|
|
@@ -106,9 +109,10 @@ function useGetWeeks(_ref2) {
|
|
|
106
109
|
isSelected: isSelected,
|
|
107
110
|
isSiblingMonth: isSiblingMonth,
|
|
108
111
|
year: date.year,
|
|
109
|
-
day: date.day
|
|
112
|
+
day: date.day,
|
|
113
|
+
weekDayName: weekDayName
|
|
110
114
|
});
|
|
111
115
|
});
|
|
112
116
|
return weeks;
|
|
113
|
-
}, [calendar, day, disabled, disabledDateFilter, minDate, maxDate, needJsDate, previouslySelected, selected, today, weekStartDay]);
|
|
117
|
+
}, [calendar, day, disabled, disabledDateFilter, minDate, maxDate, needJsDate, previouslySelected, selected, today, weekStartDay, daysLong]);
|
|
114
118
|
}
|
|
@@ -53,6 +53,9 @@ function useHandleDateChange(_ref) {
|
|
|
53
53
|
_ref$year = (0, _slicedToArray2.default)(_ref.year, 2),
|
|
54
54
|
yearValue = _ref$year[0],
|
|
55
55
|
setYearValue = _ref$year[1],
|
|
56
|
+
_ref$shouldSetFocus = (0, _slicedToArray2.default)(_ref.shouldSetFocus, 2),
|
|
57
|
+
shouldSetFocus = _ref$shouldSetFocus[0],
|
|
58
|
+
setShouldSetFocus = _ref$shouldSetFocus[1],
|
|
56
59
|
onChange = _ref.onChange;
|
|
57
60
|
var dateRef = (0, _react.useRef)({
|
|
58
61
|
day: dayValue,
|
|
@@ -76,6 +79,7 @@ function useHandleDateChange(_ref) {
|
|
|
76
79
|
month: month,
|
|
77
80
|
day: day
|
|
78
81
|
});
|
|
82
|
+
var isFocusableType = ['up', 'down', 'left', 'right'].includes(type);
|
|
79
83
|
onChange({
|
|
80
84
|
day: day,
|
|
81
85
|
month: month,
|
|
@@ -86,7 +90,8 @@ function useHandleDateChange(_ref) {
|
|
|
86
90
|
setDayValue(day);
|
|
87
91
|
setMonthValue(month);
|
|
88
92
|
setYearValue(year);
|
|
89
|
-
|
|
93
|
+
setShouldSetFocus(isFocusableType);
|
|
94
|
+
}, [onChange, setDayValue, setMonthValue, setYearValue, setShouldSetFocus]);
|
|
90
95
|
var navigate = (0, _react.useCallback)(function (type) {
|
|
91
96
|
var _dateRef$current = dateRef.current,
|
|
92
97
|
day = _dateRef$current.day,
|
|
@@ -19,8 +19,12 @@ function useLocale(_ref) {
|
|
|
19
19
|
var daysShort = (0, _react.useMemo)(function () {
|
|
20
20
|
return l10n.getDaysShort(weekStartDay);
|
|
21
21
|
}, [l10n, weekStartDay]);
|
|
22
|
+
var daysLong = (0, _react.useMemo)(function () {
|
|
23
|
+
return l10n.getDaysLong(weekStartDay);
|
|
24
|
+
}, [l10n, weekStartDay]);
|
|
22
25
|
return {
|
|
23
26
|
monthsLong: monthsLong,
|
|
24
|
-
daysShort: daysShort
|
|
27
|
+
daysShort: daysShort,
|
|
28
|
+
daysLong: daysLong
|
|
25
29
|
};
|
|
26
30
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.dateCellStyles = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
8
11
|
var textColor = {
|
|
9
12
|
light: "var(--ds-text, ".concat(_colors.N900, ")"),
|
|
@@ -27,12 +30,14 @@ var selectedBackground = {
|
|
|
27
30
|
dark: "var(--ds-background-selected, ".concat(_colors.N0, ")")
|
|
28
31
|
};
|
|
29
32
|
var borderColorFocused = {
|
|
30
|
-
light: "var(--ds-border-focused, ".concat(_colors.
|
|
31
|
-
dark: "var(--ds-border-focused, ".concat(_colors.
|
|
33
|
+
light: "var(--ds-border-focused, ".concat(_colors.B200, ")"),
|
|
34
|
+
dark: "var(--ds-border-focused, ".concat(_colors.B100, ")")
|
|
32
35
|
};
|
|
36
|
+
var focusBorderSelector = (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? '&:focus-visible' : '&[data-focused]';
|
|
33
37
|
var dateCellStyles = function dateCellStyles() {
|
|
38
|
+
var _ref;
|
|
34
39
|
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
|
|
35
|
-
return {
|
|
40
|
+
return _ref = {
|
|
36
41
|
all: 'unset',
|
|
37
42
|
display: 'block',
|
|
38
43
|
padding: "var(--ds-space-050, 4px)".concat(" 9px"),
|
|
@@ -73,32 +78,25 @@ var dateCellStyles = function dateCellStyles() {
|
|
|
73
78
|
'&[data-disabled]': {
|
|
74
79
|
color: "var(--ds-text-disabled, ".concat(_colors.N40, ")"),
|
|
75
80
|
cursor: 'not-allowed'
|
|
76
|
-
},
|
|
77
|
-
'&[data-focused]': {
|
|
78
|
-
border: "2px solid ".concat(borderColorFocused[mode])
|
|
79
|
-
},
|
|
80
|
-
'&:hover': {
|
|
81
|
-
backgroundColor: hoverBackground[mode],
|
|
82
|
-
color: textColor[mode]
|
|
83
|
-
},
|
|
84
|
-
'&:active': {
|
|
85
|
-
backgroundColor: "var(--ds-background-neutral-subtle-pressed, ".concat(_colors.B50, ")"),
|
|
86
|
-
color: textColor[mode]
|
|
87
|
-
},
|
|
88
|
-
'&[data-selected]:hover': {
|
|
89
|
-
backgroundColor: "var(--ds-background-selected-hovered, ".concat(_colors.B50, ")"),
|
|
90
|
-
color: "var(--ds-text-selected, ".concat(_colors.N600, ")")
|
|
91
|
-
},
|
|
92
|
-
'&[data-prev-selected]:hover': {
|
|
93
|
-
color: textColorMedium
|
|
94
|
-
},
|
|
95
|
-
'&[data-sibling]:hover': {
|
|
96
|
-
color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
|
|
97
|
-
},
|
|
98
|
-
'&[data-disabled]:hover': {
|
|
99
|
-
backgroundColor: 'transparent',
|
|
100
|
-
color: "var(--ds-text-disabled, ".concat(_colors.N40, ")")
|
|
101
81
|
}
|
|
102
|
-
}
|
|
82
|
+
}, (0, _defineProperty2.default)(_ref, focusBorderSelector, {
|
|
83
|
+
border: "2px solid ".concat(borderColorFocused[mode])
|
|
84
|
+
}), (0, _defineProperty2.default)(_ref, '&:hover', {
|
|
85
|
+
backgroundColor: hoverBackground[mode],
|
|
86
|
+
color: textColor[mode]
|
|
87
|
+
}), (0, _defineProperty2.default)(_ref, '&:active', {
|
|
88
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, ".concat(_colors.B50, ")"),
|
|
89
|
+
color: textColor[mode]
|
|
90
|
+
}), (0, _defineProperty2.default)(_ref, '&[data-selected]:hover', {
|
|
91
|
+
backgroundColor: "var(--ds-background-selected-hovered, ".concat(_colors.B50, ")"),
|
|
92
|
+
color: "var(--ds-text-selected, ".concat(_colors.N600, ")")
|
|
93
|
+
}), (0, _defineProperty2.default)(_ref, '&[data-prev-selected]:hover', {
|
|
94
|
+
color: textColorMedium
|
|
95
|
+
}), (0, _defineProperty2.default)(_ref, '&[data-sibling]:hover', {
|
|
96
|
+
color: "var(--ds-text-subtlest, ".concat(_colors.N200, ")")
|
|
97
|
+
}), (0, _defineProperty2.default)(_ref, '&[data-disabled]:hover', {
|
|
98
|
+
backgroundColor: 'transparent',
|
|
99
|
+
color: "var(--ds-text-disabled, ".concat(_colors.N40, ")")
|
|
100
|
+
}), _ref;
|
|
103
101
|
};
|
|
104
102
|
exports.dateCellStyles = dateCellStyles;
|
package/dist/cjs/version.json
CHANGED