@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
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { forwardRef, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import noop from '@atlaskit/ds-lib/noop';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { Grid } from '@atlaskit/primitives';
|
|
5
7
|
import { dateCellStyles as getDateCellStyles } from '../styles/date';
|
|
6
8
|
var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
7
9
|
var day = _ref.children,
|
|
@@ -11,7 +13,9 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
|
11
13
|
isFocused = _ref$isFocused === void 0 ? false : _ref$isFocused,
|
|
12
14
|
_ref$isToday = _ref.isToday,
|
|
13
15
|
isToday = _ref$isToday === void 0 ? false : _ref$isToday,
|
|
16
|
+
dayLong = _ref.dayLong,
|
|
14
17
|
month = _ref.month,
|
|
18
|
+
monthLong = _ref.monthLong,
|
|
15
19
|
_ref$onClick = _ref.onClick,
|
|
16
20
|
onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
|
|
17
21
|
_ref$isPreviouslySele = _ref.isPreviouslySelected,
|
|
@@ -22,6 +26,8 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
|
22
26
|
isSibling = _ref$isSibling === void 0 ? false : _ref$isSibling,
|
|
23
27
|
year = _ref.year,
|
|
24
28
|
mode = _ref.mode,
|
|
29
|
+
shouldSetFocus = _ref.shouldSetFocus,
|
|
30
|
+
tabIndex = _ref.tabIndex,
|
|
25
31
|
testId = _ref.testId;
|
|
26
32
|
var dateRef = useRef({
|
|
27
33
|
day: day,
|
|
@@ -37,6 +43,12 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
|
37
43
|
isDisabled: isDisabled
|
|
38
44
|
};
|
|
39
45
|
}, [day, month, year, isDisabled]);
|
|
46
|
+
var focusRef = useRef(null);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
if (getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') && isFocused && shouldSetFocus && focusRef.current) {
|
|
49
|
+
focusRef.current.focus();
|
|
50
|
+
}
|
|
51
|
+
}, [isFocused, shouldSetFocus]);
|
|
40
52
|
var handleClick = useCallback(function () {
|
|
41
53
|
var _dateRef$current = dateRef.current,
|
|
42
54
|
dayValue = _dateRef$current.day,
|
|
@@ -54,28 +66,44 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
|
54
66
|
var dateCellStyles = useMemo(function () {
|
|
55
67
|
return css(getDateCellStyles(mode));
|
|
56
68
|
}, [mode]);
|
|
57
|
-
return (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
)
|
|
69
|
+
return getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? jsx(Grid, {
|
|
70
|
+
role: "gridcell",
|
|
71
|
+
alignItems: "center"
|
|
72
|
+
}, jsx("button", {
|
|
73
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
74
|
+
css: dateCellStyles,
|
|
75
|
+
"aria-current": isToday ? 'date' : undefined,
|
|
76
|
+
"aria-disabled": isDisabled || undefined,
|
|
77
|
+
"aria-label": "".concat(day, ", ").concat(dayLong, " ").concat(monthLong, " ").concat(year),
|
|
78
|
+
"aria-pressed": isSelected ? 'true' : 'false',
|
|
79
|
+
tabIndex: isFocused ? tabIndex : -1,
|
|
80
|
+
type: "button",
|
|
81
|
+
onClick: handleClick,
|
|
82
|
+
ref: focusRef,
|
|
83
|
+
"data-disabled": isDisabled || undefined,
|
|
84
|
+
"data-focused": isFocused || undefined,
|
|
85
|
+
"data-prev-selected": isPreviouslySelected || undefined,
|
|
86
|
+
"data-selected": isSelected || undefined,
|
|
87
|
+
"data-sibling": isSibling || undefined,
|
|
88
|
+
"data-today": isToday || undefined,
|
|
89
|
+
"data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day"))
|
|
90
|
+
}, day)) : jsx("button", {
|
|
91
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
92
|
+
css: dateCellStyles,
|
|
93
|
+
"aria-selected": isSelected ? 'true' : 'false',
|
|
94
|
+
tabIndex: isSelected ? 0 : -1,
|
|
95
|
+
type: "button",
|
|
96
|
+
role: "gridcell",
|
|
97
|
+
onClick: handleClick,
|
|
98
|
+
ref: ref,
|
|
99
|
+
"data-disabled": isDisabled || undefined,
|
|
100
|
+
"data-focused": isFocused || undefined,
|
|
101
|
+
"data-prev-selected": isPreviouslySelected || undefined,
|
|
102
|
+
"data-selected": isSelected || undefined,
|
|
103
|
+
"data-sibling": isSibling || undefined,
|
|
104
|
+
"data-today": isToday || undefined,
|
|
105
|
+
"data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day"))
|
|
106
|
+
}, day);
|
|
79
107
|
}));
|
|
80
108
|
Date.displayName = 'Date';
|
|
81
109
|
|
|
@@ -5,21 +5,34 @@ import Button from '@atlaskit/button/standard-button';
|
|
|
5
5
|
import Heading from '@atlaskit/heading';
|
|
6
6
|
import ArrowleftIcon from '@atlaskit/icon/glyph/chevron-left-large';
|
|
7
7
|
import ArrowrightIcon from '@atlaskit/icon/glyph/chevron-right-large';
|
|
8
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { Box, Inline } from '@atlaskit/primitives';
|
|
9
10
|
import { N700 } from '@atlaskit/theme/colors';
|
|
11
|
+
import useUniqueId from '../../internal/hooks/use-unique-id';
|
|
10
12
|
var Header = /*#__PURE__*/memo(function Header(_ref) {
|
|
11
13
|
var monthLongTitle = _ref.monthLongTitle,
|
|
12
14
|
year = _ref.year,
|
|
13
15
|
_ref$previousMonthLab = _ref.previousMonthLabel,
|
|
14
|
-
previousMonthLabel = _ref$previousMonthLab === void 0 ? 'Last month' : _ref$previousMonthLab,
|
|
16
|
+
previousMonthLabel = _ref$previousMonthLab === void 0 ? getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'Previous month' : 'Last month' : _ref$previousMonthLab,
|
|
17
|
+
previousHeading = _ref.previousHeading,
|
|
15
18
|
_ref$nextMonthLabel = _ref.nextMonthLabel,
|
|
16
19
|
nextMonthLabel = _ref$nextMonthLabel === void 0 ? 'Next month' : _ref$nextMonthLabel,
|
|
20
|
+
nextHeading = _ref.nextHeading,
|
|
17
21
|
handleClickPrev = _ref.handleClickPrev,
|
|
18
22
|
handleClickNext = _ref.handleClickNext,
|
|
23
|
+
headerId = _ref.headerId,
|
|
24
|
+
tabIndex = _ref.tabIndex,
|
|
19
25
|
testId = _ref.testId;
|
|
26
|
+
var announceId = useUniqueId('month-year-announce');
|
|
27
|
+
var renderedHeading = jsx(Heading, {
|
|
28
|
+
level: "h400",
|
|
29
|
+
as: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'h2' : 'div',
|
|
30
|
+
id: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? headerId : undefined,
|
|
31
|
+
testId: testId && "".concat(testId, "--current-month-year")
|
|
32
|
+
}, "".concat(monthLongTitle, " ").concat(year));
|
|
20
33
|
return jsx(Box, {
|
|
21
34
|
paddingInline: "space.100",
|
|
22
|
-
"aria-hidden":
|
|
35
|
+
"aria-hidden": getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? undefined : 'true'
|
|
23
36
|
}, jsx(Inline, {
|
|
24
37
|
space: "space.0",
|
|
25
38
|
alignBlock: "center",
|
|
@@ -27,27 +40,29 @@ var Header = /*#__PURE__*/memo(function Header(_ref) {
|
|
|
27
40
|
}, jsx(Button, {
|
|
28
41
|
appearance: "subtle",
|
|
29
42
|
spacing: "none",
|
|
30
|
-
tabIndex: -1,
|
|
43
|
+
tabIndex: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : -1,
|
|
31
44
|
onClick: handleClickPrev,
|
|
32
45
|
testId: testId && "".concat(testId, "--previous-month"),
|
|
33
46
|
iconBefore: jsx(ArrowleftIcon, {
|
|
34
|
-
label: previousMonthLabel,
|
|
47
|
+
label: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? "".concat(previousMonthLabel, ", ").concat(previousHeading) : previousMonthLabel,
|
|
35
48
|
size: "medium",
|
|
36
49
|
primaryColor: "var(--ds-icon, ".concat(N700, ")"),
|
|
37
50
|
testId: testId && "".concat(testId, "--previous-month-icon")
|
|
38
51
|
})
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
}), getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ?
|
|
53
|
+
// This is required to ensure that the new month/year is announced when the previous/next month buttons are activated
|
|
54
|
+
jsx(Box, {
|
|
55
|
+
"aria-live": "polite",
|
|
56
|
+
id: announceId,
|
|
57
|
+
testId: testId && "".concat(testId, "--current-month-year--container")
|
|
58
|
+
}, renderedHeading) : renderedHeading, jsx(Button, {
|
|
44
59
|
appearance: "subtle",
|
|
45
60
|
spacing: "none",
|
|
46
|
-
tabIndex: -1,
|
|
61
|
+
tabIndex: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? tabIndex : -1,
|
|
47
62
|
onClick: handleClickNext,
|
|
48
63
|
testId: testId && "".concat(testId, "--next-month"),
|
|
49
64
|
iconBefore: jsx(ArrowrightIcon, {
|
|
50
|
-
label: nextMonthLabel,
|
|
65
|
+
label: getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? "".concat(nextMonthLabel, ", ").concat(nextHeading) : nextMonthLabel,
|
|
51
66
|
size: "medium",
|
|
52
67
|
primaryColor: "var(--ds-icon, ".concat(N700, ")"),
|
|
53
68
|
testId: testId && "".concat(testId, "--next-month-icon")
|
|
@@ -8,6 +8,9 @@ var WeekDays = /*#__PURE__*/memo(function WeekDays(_ref) {
|
|
|
8
8
|
var weeks = _ref.weeks,
|
|
9
9
|
handleClickDay = _ref.handleClickDay,
|
|
10
10
|
mode = _ref.mode,
|
|
11
|
+
monthsLong = _ref.monthsLong,
|
|
12
|
+
shouldSetFocus = _ref.shouldSetFocus,
|
|
13
|
+
tabIndex = _ref.tabIndex,
|
|
11
14
|
testId = _ref.testId;
|
|
12
15
|
return (
|
|
13
16
|
// TODO: Determine if there is a better way to render the button (should be
|
|
@@ -26,13 +29,17 @@ var WeekDays = /*#__PURE__*/memo(function WeekDays(_ref) {
|
|
|
26
29
|
isDisabled: weekDay.isDisabled,
|
|
27
30
|
isFocused: weekDay.isFocused,
|
|
28
31
|
isToday: weekDay.isToday,
|
|
32
|
+
dayLong: weekDay.weekDayName,
|
|
29
33
|
month: weekDay.month,
|
|
34
|
+
monthLong: monthsLong[weekDay.month - 1],
|
|
30
35
|
onClick: handleClickDay,
|
|
31
36
|
isPreviouslySelected: weekDay.isPreviouslySelected,
|
|
32
37
|
isSelected: weekDay.isSelected,
|
|
33
38
|
isSibling: weekDay.isSiblingMonth,
|
|
34
39
|
year: weekDay.year,
|
|
35
40
|
mode: mode,
|
|
41
|
+
shouldSetFocus: shouldSetFocus,
|
|
42
|
+
tabIndex: tabIndex,
|
|
36
43
|
testId: testId
|
|
37
44
|
}, weekDay.day);
|
|
38
45
|
}));
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import Text from '@atlaskit/ds-explorations/text';
|
|
5
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
6
7
|
import WeekDayGrid from './week-day-grid';
|
|
7
8
|
var columnHeaderStyles = xcss({
|
|
@@ -20,22 +21,19 @@ var WeekHeader = /*#__PURE__*/memo(function WeekHeader(_ref) {
|
|
|
20
21
|
return jsx(WeekDayGrid, {
|
|
21
22
|
testId: testId && "".concat(testId, "--column-headers")
|
|
22
23
|
}, daysShort.map(function (shortDay) {
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
textTransform: "uppercase"
|
|
37
|
-
}, shortDay))
|
|
38
|
-
);
|
|
24
|
+
return jsx(Box, {
|
|
25
|
+
"aria-hidden": getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? 'true' : undefined,
|
|
26
|
+
padding: "space.100",
|
|
27
|
+
xcss: columnHeaderStyles,
|
|
28
|
+
key: shortDay,
|
|
29
|
+
role: "columnheader",
|
|
30
|
+
testId: testId && "".concat(testId, "--column-header")
|
|
31
|
+
}, jsx(Text, {
|
|
32
|
+
fontWeight: "bold",
|
|
33
|
+
fontSize: "size.050",
|
|
34
|
+
verticalAlign: "middle",
|
|
35
|
+
textTransform: "uppercase"
|
|
36
|
+
}, shortDay));
|
|
39
37
|
}));
|
|
40
38
|
});
|
|
41
39
|
WeekHeader.displayName = 'WeekHeader';
|
|
@@ -36,6 +36,7 @@ function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
|
36
36
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
37
37
|
export default function useGetWeeks(_ref2) {
|
|
38
38
|
var day = _ref2.day,
|
|
39
|
+
daysLong = _ref2.daysLong,
|
|
39
40
|
month = _ref2.month,
|
|
40
41
|
year = _ref2.year,
|
|
41
42
|
today = _ref2.today,
|
|
@@ -79,8 +80,10 @@ export default function useGetWeeks(_ref2) {
|
|
|
79
80
|
} else {
|
|
80
81
|
week = weeks[weeks.length - 1];
|
|
81
82
|
}
|
|
83
|
+
var weekDayOffset = (date.weekDay - weekStartDay) % 7;
|
|
82
84
|
|
|
83
85
|
// Define a bunch of `const`s
|
|
86
|
+
var weekDayName = daysLong[weekDayOffset];
|
|
84
87
|
var isDisabledByArray = disabled ? disabled.indexOf(dateAsString) > -1 : false;
|
|
85
88
|
var isDisabledByFilter = disabledDateFilter ? disabledDateFilter(dateAsString) : false;
|
|
86
89
|
var isDisabledByMin = minDate && JSDate ? JSDate < minDate : false;
|
|
@@ -101,9 +104,10 @@ export default function useGetWeeks(_ref2) {
|
|
|
101
104
|
isSelected: isSelected,
|
|
102
105
|
isSiblingMonth: isSiblingMonth,
|
|
103
106
|
year: date.year,
|
|
104
|
-
day: date.day
|
|
107
|
+
day: date.day,
|
|
108
|
+
weekDayName: weekDayName
|
|
105
109
|
});
|
|
106
110
|
});
|
|
107
111
|
return weeks;
|
|
108
|
-
}, [calendar, day, disabled, disabledDateFilter, minDate, maxDate, needJsDate, previouslySelected, selected, today, weekStartDay]);
|
|
112
|
+
}, [calendar, day, disabled, disabledDateFilter, minDate, maxDate, needJsDate, previouslySelected, selected, today, weekStartDay, daysLong]);
|
|
109
113
|
}
|
|
@@ -46,6 +46,9 @@ export default function useHandleDateChange(_ref) {
|
|
|
46
46
|
_ref$year = _slicedToArray(_ref.year, 2),
|
|
47
47
|
yearValue = _ref$year[0],
|
|
48
48
|
setYearValue = _ref$year[1],
|
|
49
|
+
_ref$shouldSetFocus = _slicedToArray(_ref.shouldSetFocus, 2),
|
|
50
|
+
shouldSetFocus = _ref$shouldSetFocus[0],
|
|
51
|
+
setShouldSetFocus = _ref$shouldSetFocus[1],
|
|
49
52
|
onChange = _ref.onChange;
|
|
50
53
|
var dateRef = useRef({
|
|
51
54
|
day: dayValue,
|
|
@@ -69,6 +72,7 @@ export default function useHandleDateChange(_ref) {
|
|
|
69
72
|
month: month,
|
|
70
73
|
day: day
|
|
71
74
|
});
|
|
75
|
+
var isFocusableType = ['up', 'down', 'left', 'right'].includes(type);
|
|
72
76
|
onChange({
|
|
73
77
|
day: day,
|
|
74
78
|
month: month,
|
|
@@ -79,7 +83,8 @@ export default function useHandleDateChange(_ref) {
|
|
|
79
83
|
setDayValue(day);
|
|
80
84
|
setMonthValue(month);
|
|
81
85
|
setYearValue(year);
|
|
82
|
-
|
|
86
|
+
setShouldSetFocus(isFocusableType);
|
|
87
|
+
}, [onChange, setDayValue, setMonthValue, setYearValue, setShouldSetFocus]);
|
|
83
88
|
var navigate = useCallback(function (type) {
|
|
84
89
|
var _dateRef$current = dateRef.current,
|
|
85
90
|
day = _dateRef$current.day,
|
|
@@ -13,8 +13,12 @@ export default function useLocale(_ref) {
|
|
|
13
13
|
var daysShort = useMemo(function () {
|
|
14
14
|
return l10n.getDaysShort(weekStartDay);
|
|
15
15
|
}, [l10n, weekStartDay]);
|
|
16
|
+
var daysLong = useMemo(function () {
|
|
17
|
+
return l10n.getDaysLong(weekStartDay);
|
|
18
|
+
}, [l10n, weekStartDay]);
|
|
16
19
|
return {
|
|
17
20
|
monthsLong: monthsLong,
|
|
18
|
-
daysShort: daysShort
|
|
21
|
+
daysShort: daysShort,
|
|
22
|
+
daysLong: daysLong
|
|
19
23
|
};
|
|
20
24
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { B100, B200, B400, B50, DN600, N0, N200, N30, N40, N500, N600, N700, N800, N900 } from '@atlaskit/theme/colors';
|
|
2
4
|
var textColor = {
|
|
3
5
|
light: "var(--ds-text, ".concat(N900, ")"),
|
|
4
6
|
dark: "var(--ds-text, ".concat(DN600, ")")
|
|
@@ -21,12 +23,14 @@ var selectedBackground = {
|
|
|
21
23
|
dark: "var(--ds-background-selected, ".concat(N0, ")")
|
|
22
24
|
};
|
|
23
25
|
var borderColorFocused = {
|
|
24
|
-
light: "var(--ds-border-focused, ".concat(
|
|
25
|
-
dark: "var(--ds-border-focused, ".concat(
|
|
26
|
+
light: "var(--ds-border-focused, ".concat(B200, ")"),
|
|
27
|
+
dark: "var(--ds-border-focused, ".concat(B100, ")")
|
|
26
28
|
};
|
|
29
|
+
var focusBorderSelector = getBooleanFF('platform.design-system-team.calendar-keyboard-accessibility_967h1') ? '&:focus-visible' : '&[data-focused]';
|
|
27
30
|
export var dateCellStyles = function dateCellStyles() {
|
|
31
|
+
var _ref;
|
|
28
32
|
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
|
|
29
|
-
return {
|
|
33
|
+
return _ref = {
|
|
30
34
|
all: 'unset',
|
|
31
35
|
display: 'block',
|
|
32
36
|
padding: "var(--ds-space-050, 4px)".concat(" 9px"),
|
|
@@ -67,31 +71,24 @@ export var dateCellStyles = function dateCellStyles() {
|
|
|
67
71
|
'&[data-disabled]': {
|
|
68
72
|
color: "var(--ds-text-disabled, ".concat(N40, ")"),
|
|
69
73
|
cursor: 'not-allowed'
|
|
70
|
-
},
|
|
71
|
-
'&[data-focused]': {
|
|
72
|
-
border: "2px solid ".concat(borderColorFocused[mode])
|
|
73
|
-
},
|
|
74
|
-
'&:hover': {
|
|
75
|
-
backgroundColor: hoverBackground[mode],
|
|
76
|
-
color: textColor[mode]
|
|
77
|
-
},
|
|
78
|
-
'&:active': {
|
|
79
|
-
backgroundColor: "var(--ds-background-neutral-subtle-pressed, ".concat(B50, ")"),
|
|
80
|
-
color: textColor[mode]
|
|
81
|
-
},
|
|
82
|
-
'&[data-selected]:hover': {
|
|
83
|
-
backgroundColor: "var(--ds-background-selected-hovered, ".concat(B50, ")"),
|
|
84
|
-
color: "var(--ds-text-selected, ".concat(N600, ")")
|
|
85
|
-
},
|
|
86
|
-
'&[data-prev-selected]:hover': {
|
|
87
|
-
color: textColorMedium
|
|
88
|
-
},
|
|
89
|
-
'&[data-sibling]:hover': {
|
|
90
|
-
color: "var(--ds-text-subtlest, ".concat(N200, ")")
|
|
91
|
-
},
|
|
92
|
-
'&[data-disabled]:hover': {
|
|
93
|
-
backgroundColor: 'transparent',
|
|
94
|
-
color: "var(--ds-text-disabled, ".concat(N40, ")")
|
|
95
74
|
}
|
|
96
|
-
}
|
|
75
|
+
}, _defineProperty(_ref, focusBorderSelector, {
|
|
76
|
+
border: "2px solid ".concat(borderColorFocused[mode])
|
|
77
|
+
}), _defineProperty(_ref, '&:hover', {
|
|
78
|
+
backgroundColor: hoverBackground[mode],
|
|
79
|
+
color: textColor[mode]
|
|
80
|
+
}), _defineProperty(_ref, '&:active', {
|
|
81
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, ".concat(B50, ")"),
|
|
82
|
+
color: textColor[mode]
|
|
83
|
+
}), _defineProperty(_ref, '&[data-selected]:hover', {
|
|
84
|
+
backgroundColor: "var(--ds-background-selected-hovered, ".concat(B50, ")"),
|
|
85
|
+
color: "var(--ds-text-selected, ".concat(N600, ")")
|
|
86
|
+
}), _defineProperty(_ref, '&[data-prev-selected]:hover', {
|
|
87
|
+
color: textColorMedium
|
|
88
|
+
}), _defineProperty(_ref, '&[data-sibling]:hover', {
|
|
89
|
+
color: "var(--ds-text-subtlest, ".concat(N200, ")")
|
|
90
|
+
}), _defineProperty(_ref, '&[data-disabled]:hover', {
|
|
91
|
+
backgroundColor: 'transparent',
|
|
92
|
+
color: "var(--ds-text-disabled, ".concat(N40, ")")
|
|
93
|
+
}), _ref;
|
|
97
94
|
};
|
package/dist/esm/version.json
CHANGED
package/dist/types/calendar.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ import type { CalendarProps } from './types';
|
|
|
9
9
|
* - [Code](https://atlassian.design/components/calendar/code)
|
|
10
10
|
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
11
11
|
*/
|
|
12
|
-
declare const Calendar: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CalendarProps, "
|
|
12
|
+
declare const Calendar: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CalendarProps, "day" | "defaultDay" | "defaultMonth" | "defaultPreviouslySelected" | "defaultSelected" | "defaultYear" | "disabled" | "disabledDateFilter" | "maxDate" | "minDate" | "month" | "nextMonthLabel" | "onBlur" | "onChange" | "onFocus" | "onSelect" | "previouslySelected" | "previousMonthLabel" | "selected" | "today" | "year" | "locale" | "analyticsContext" | "weekStartDay" | "testId" | "className" | "style" | "calendarRef" | "mode" | "tabIndex" | "createAnalyticsEvent"> & import("react").RefAttributes<HTMLDivElement>>>;
|
|
13
13
|
export default Calendar;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import type { TabIndex } from '../../types';
|
|
3
4
|
import type { DateObj } from '../types';
|
|
4
5
|
interface DateProps {
|
|
5
6
|
children: number;
|
|
6
7
|
isDisabled?: boolean;
|
|
7
8
|
isFocused?: boolean;
|
|
8
9
|
isToday?: boolean;
|
|
10
|
+
dayLong: string;
|
|
9
11
|
month: number;
|
|
12
|
+
monthLong: string;
|
|
10
13
|
onClick?: ({ day, month, year }: DateObj) => void;
|
|
11
14
|
isPreviouslySelected?: boolean;
|
|
12
15
|
isSelected?: boolean;
|
|
13
16
|
isSibling?: boolean;
|
|
14
17
|
year: number;
|
|
15
18
|
mode?: ThemeModes;
|
|
19
|
+
shouldSetFocus: boolean;
|
|
20
|
+
tabIndex: TabIndex;
|
|
16
21
|
testId?: string;
|
|
17
22
|
}
|
|
18
23
|
declare const Date: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<DateProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import { TabIndex } from '../../types';
|
|
3
4
|
interface HeaderProps {
|
|
4
5
|
monthLongTitle: string;
|
|
5
6
|
year: number;
|
|
6
7
|
previousMonthLabel?: string;
|
|
8
|
+
previousHeading: string;
|
|
7
9
|
nextMonthLabel?: string;
|
|
10
|
+
nextHeading: string;
|
|
8
11
|
handleClickNext?: () => void;
|
|
9
12
|
handleClickPrev?: () => void;
|
|
10
13
|
mode?: ThemeModes;
|
|
14
|
+
headerId: string;
|
|
15
|
+
tabIndex?: TabIndex;
|
|
11
16
|
testId?: string;
|
|
12
17
|
}
|
|
13
18
|
declare const Header: import("react").NamedExoticComponent<HeaderProps>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import type { TabIndex } from '../../types';
|
|
3
4
|
import { DateObj, Week } from '../types';
|
|
4
5
|
interface WeekDaysProps {
|
|
5
6
|
weeks: Week[];
|
|
6
7
|
handleClickDay: (date: DateObj) => void;
|
|
7
8
|
mode?: ThemeModes;
|
|
9
|
+
monthsLong: string[];
|
|
10
|
+
shouldSetFocus: boolean;
|
|
11
|
+
tabIndex: TabIndex;
|
|
8
12
|
testId?: string;
|
|
9
13
|
}
|
|
10
14
|
declare const WeekDays: import("react").NamedExoticComponent<WeekDaysProps>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WeekDay } from '../../types';
|
|
2
2
|
import type { Week } from '../types';
|
|
3
|
-
export default function useGetWeeks({ day, month, year, today, disabled, disabledDateFilter, minDate: minDateString, maxDate: maxDateString, selected, previouslySelected, weekStartDay, }: {
|
|
3
|
+
export default function useGetWeeks({ day, daysLong, month, year, today, disabled, disabledDateFilter, minDate: minDateString, maxDate: maxDateString, selected, previouslySelected, weekStartDay, }: {
|
|
4
4
|
day: number;
|
|
5
|
+
daysLong: string[];
|
|
5
6
|
month: number;
|
|
6
7
|
year: number;
|
|
7
8
|
today: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ChangeEvent } from '../../types';
|
|
2
2
|
import type { ArrowKeys } from '../types';
|
|
3
|
-
export default function useHandleDateChange({ day: [dayValue, setDayValue], month: [monthValue, setMonthValue], year: [yearValue, setYearValue], onChange, }: {
|
|
3
|
+
export default function useHandleDateChange({ day: [dayValue, setDayValue], month: [monthValue, setMonthValue], year: [yearValue, setYearValue], shouldSetFocus: [shouldSetFocus, setShouldSetFocus], onChange, }: {
|
|
4
4
|
day: readonly [number, (newValue: number) => void];
|
|
5
5
|
month: readonly [number, (newValue: number) => void];
|
|
6
6
|
year: readonly [number, (newValue: number) => void];
|
|
7
|
+
shouldSetFocus: readonly [boolean, (newValue: boolean) => void];
|
|
7
8
|
onChange: (event: ChangeEvent) => void;
|
|
8
9
|
}): {
|
|
9
10
|
navigate: (type: ArrowKeys) => void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { UIAnalyticsEvent, WithAnalyticsEventsProps } from '@atlaskit/analytics-
|
|
|
3
3
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
4
4
|
import type { ArrowKeys, DateObj, ISODate } from './internal/types';
|
|
5
5
|
export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
|
+
export type TabIndex = -1 | 0;
|
|
6
7
|
export type ChangeEvent = {
|
|
7
8
|
iso: ISODate;
|
|
8
9
|
type: 'left' | 'up' | 'right' | 'down' | 'prev' | 'next';
|
|
@@ -150,9 +151,10 @@ export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
|
150
151
|
*/
|
|
151
152
|
mode?: ThemeModes;
|
|
152
153
|
/**
|
|
153
|
-
*
|
|
154
|
+
* Indicates if the calendar can be focused by keyboard or only
|
|
155
|
+
* programmatically. Defaults to "0".
|
|
154
156
|
*/
|
|
155
|
-
tabIndex?:
|
|
157
|
+
tabIndex?: TabIndex;
|
|
156
158
|
}
|
|
157
159
|
export interface CalendarRef {
|
|
158
160
|
navigate: (type: ArrowKeys) => void;
|
|
@@ -9,5 +9,5 @@ import type { CalendarProps } from './types';
|
|
|
9
9
|
* - [Code](https://atlassian.design/components/calendar/code)
|
|
10
10
|
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
11
11
|
*/
|
|
12
|
-
declare const Calendar: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CalendarProps, "
|
|
12
|
+
declare const Calendar: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CalendarProps, "day" | "defaultDay" | "defaultMonth" | "defaultPreviouslySelected" | "defaultSelected" | "defaultYear" | "disabled" | "disabledDateFilter" | "maxDate" | "minDate" | "month" | "nextMonthLabel" | "onBlur" | "onChange" | "onFocus" | "onSelect" | "previouslySelected" | "previousMonthLabel" | "selected" | "today" | "year" | "locale" | "analyticsContext" | "weekStartDay" | "testId" | "className" | "style" | "calendarRef" | "mode" | "tabIndex" | "createAnalyticsEvent"> & import("react").RefAttributes<HTMLDivElement>>>;
|
|
13
13
|
export default Calendar;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import type { TabIndex } from '../../types';
|
|
3
4
|
import type { DateObj } from '../types';
|
|
4
5
|
interface DateProps {
|
|
5
6
|
children: number;
|
|
6
7
|
isDisabled?: boolean;
|
|
7
8
|
isFocused?: boolean;
|
|
8
9
|
isToday?: boolean;
|
|
10
|
+
dayLong: string;
|
|
9
11
|
month: number;
|
|
12
|
+
monthLong: string;
|
|
10
13
|
onClick?: ({ day, month, year }: DateObj) => void;
|
|
11
14
|
isPreviouslySelected?: boolean;
|
|
12
15
|
isSelected?: boolean;
|
|
13
16
|
isSibling?: boolean;
|
|
14
17
|
year: number;
|
|
15
18
|
mode?: ThemeModes;
|
|
19
|
+
shouldSetFocus: boolean;
|
|
20
|
+
tabIndex: TabIndex;
|
|
16
21
|
testId?: string;
|
|
17
22
|
}
|
|
18
23
|
declare const Date: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<DateProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import { TabIndex } from '../../types';
|
|
3
4
|
interface HeaderProps {
|
|
4
5
|
monthLongTitle: string;
|
|
5
6
|
year: number;
|
|
6
7
|
previousMonthLabel?: string;
|
|
8
|
+
previousHeading: string;
|
|
7
9
|
nextMonthLabel?: string;
|
|
10
|
+
nextHeading: string;
|
|
8
11
|
handleClickNext?: () => void;
|
|
9
12
|
handleClickPrev?: () => void;
|
|
10
13
|
mode?: ThemeModes;
|
|
14
|
+
headerId: string;
|
|
15
|
+
tabIndex?: TabIndex;
|
|
11
16
|
testId?: string;
|
|
12
17
|
}
|
|
13
18
|
declare const Header: import("react").NamedExoticComponent<HeaderProps>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
+
import type { TabIndex } from '../../types';
|
|
3
4
|
import { DateObj, Week } from '../types';
|
|
4
5
|
interface WeekDaysProps {
|
|
5
6
|
weeks: Week[];
|
|
6
7
|
handleClickDay: (date: DateObj) => void;
|
|
7
8
|
mode?: ThemeModes;
|
|
9
|
+
monthsLong: string[];
|
|
10
|
+
shouldSetFocus: boolean;
|
|
11
|
+
tabIndex: TabIndex;
|
|
8
12
|
testId?: string;
|
|
9
13
|
}
|
|
10
14
|
declare const WeekDays: import("react").NamedExoticComponent<WeekDaysProps>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WeekDay } from '../../types';
|
|
2
2
|
import type { Week } from '../types';
|
|
3
|
-
export default function useGetWeeks({ day, month, year, today, disabled, disabledDateFilter, minDate: minDateString, maxDate: maxDateString, selected, previouslySelected, weekStartDay, }: {
|
|
3
|
+
export default function useGetWeeks({ day, daysLong, month, year, today, disabled, disabledDateFilter, minDate: minDateString, maxDate: maxDateString, selected, previouslySelected, weekStartDay, }: {
|
|
4
4
|
day: number;
|
|
5
|
+
daysLong: string[];
|
|
5
6
|
month: number;
|
|
6
7
|
year: number;
|
|
7
8
|
today: string;
|