@atlaskit/calendar 12.2.0 → 12.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/codemods/{11.0.0-lite-mode.ts → 11.0.0-lite-mode.tsx} +0 -0
- package/codemods/__tests__/{11.0.0-lite-mode.ts → 11.0.0-lite-mode.tsx} +0 -0
- package/codemods/migrations/{flatten-certain-inner-props-as-prop.ts → flatten-certain-inner-props-as-prop.tsx} +0 -0
- package/codemods/migrations/{remove-inner-props.ts → remove-inner-props.tsx} +0 -0
- package/codemods/{utils.ts → utils.tsx} +0 -0
- package/dist/cjs/calendar.js +17 -5
- package/dist/cjs/internal/components/date.js +2 -1
- package/dist/cjs/internal/components/heading.js +2 -1
- package/dist/cjs/internal/components/week-days.js +2 -1
- package/dist/cjs/internal/components/week-header.js +2 -1
- package/dist/cjs/internal/hooks/use-calendar-ref.js +1 -0
- package/dist/cjs/internal/hooks/use-controlled-date-state.js +1 -0
- package/dist/cjs/internal/hooks/use-focusing.js +1 -0
- package/dist/cjs/internal/hooks/use-get-weeks.js +2 -1
- package/dist/cjs/internal/hooks/use-handle-date-change.js +2 -1
- package/dist/cjs/internal/hooks/use-handle-date-select.js +1 -0
- package/dist/cjs/internal/hooks/use-locale.js +1 -0
- package/dist/cjs/internal/hooks/use-unique-id.js +1 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/calendar.js +16 -5
- package/dist/es2019/internal/components/date.js +2 -1
- package/dist/es2019/internal/components/heading.js +2 -1
- package/dist/es2019/internal/components/week-days.js +2 -1
- package/dist/es2019/internal/components/week-header.js +2 -1
- package/dist/es2019/internal/hooks/use-calendar-ref.js +1 -0
- package/dist/es2019/internal/hooks/use-controlled-date-state.js +2 -1
- package/dist/es2019/internal/hooks/use-focusing.js +2 -1
- package/dist/es2019/internal/hooks/use-get-weeks.js +2 -1
- package/dist/es2019/internal/hooks/use-handle-date-change.js +2 -1
- package/dist/es2019/internal/hooks/use-handle-date-select.js +2 -1
- package/dist/es2019/internal/hooks/use-locale.js +1 -0
- package/dist/es2019/internal/hooks/use-unique-id.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/calendar.js +17 -5
- package/dist/esm/internal/components/date.js +2 -1
- package/dist/esm/internal/components/heading.js +2 -1
- package/dist/esm/internal/components/week-days.js +2 -1
- package/dist/esm/internal/components/week-header.js +2 -1
- package/dist/esm/internal/hooks/use-calendar-ref.js +1 -0
- package/dist/esm/internal/hooks/use-controlled-date-state.js +2 -1
- package/dist/esm/internal/hooks/use-focusing.js +2 -1
- package/dist/esm/internal/hooks/use-get-weeks.js +2 -1
- package/dist/esm/internal/hooks/use-handle-date-change.js +2 -1
- package/dist/esm/internal/hooks/use-handle-date-select.js +2 -1
- package/dist/esm/internal/hooks/use-locale.js +1 -0
- package/dist/esm/internal/hooks/use-unique-id.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/calendar.d.ts +10 -1
- package/dist/types/internal/components/date.d.ts +2 -2
- package/dist/types/internal/components/heading.d.ts +2 -2
- package/dist/types/internal/components/week-days.d.ts +2 -2
- package/dist/types/internal/components/week-header.d.ts +2 -2
- package/dist/types/types.d.ts +81 -31
- package/package.json +8 -7
- package/report.api.md +175 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/calendar
|
|
2
2
|
|
|
3
|
+
## 12.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
|
|
8
|
+
|
|
9
|
+
## 12.3.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`124a1b7532b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/124a1b7532b) - Remove calendar's background when design tokens are provided, to allow calendar to match the color of any surface in light or dark mode
|
|
14
|
+
- [`6bf81ead961`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6bf81ead961) - Internal code change turning on new linting rules.
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 12.3.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [`e1e33cfe0db`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e1e33cfe0db) - [ux] Adds tabIndex prop for `@atlaskit/calendar`, useful when needing to disable calendar from receiving focus by keyboard.
|
|
22
|
+
|
|
3
23
|
## 12.2.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/cjs/calendar.js
CHANGED
|
@@ -59,7 +59,7 @@ var lightWrapperStyles = (0, _core.css)({
|
|
|
59
59
|
display: 'inline-block',
|
|
60
60
|
boxSizing: 'border-box',
|
|
61
61
|
padding: 16,
|
|
62
|
-
backgroundColor: "var(--ds-
|
|
62
|
+
backgroundColor: "var(--ds-UNSAFE_util-transparent, ".concat(_colors.N0, ")"),
|
|
63
63
|
color: "var(--ds-text, ".concat(_colors.N900, ")"),
|
|
64
64
|
outline: 'none',
|
|
65
65
|
userSelect: 'none'
|
|
@@ -68,7 +68,7 @@ var darkWrapperStyles = (0, _core.css)({
|
|
|
68
68
|
display: 'inline-block',
|
|
69
69
|
boxSizing: 'border-box',
|
|
70
70
|
padding: 16,
|
|
71
|
-
backgroundColor: "var(--ds-
|
|
71
|
+
backgroundColor: "var(--ds-UNSAFE_util-transparent, ".concat(_colors.N700, ")"),
|
|
72
72
|
color: "var(--ds-text, ".concat(_colors.DN600, ")"),
|
|
73
73
|
outline: 'none',
|
|
74
74
|
userSelect: 'none'
|
|
@@ -83,7 +83,7 @@ var gridsContainerStyles = (0, _core.css)({
|
|
|
83
83
|
var analyticsAttributes = {
|
|
84
84
|
componentName: 'calendar',
|
|
85
85
|
packageName: "@atlaskit/calendar",
|
|
86
|
-
packageVersion: "12.2
|
|
86
|
+
packageVersion: "12.3.2"
|
|
87
87
|
};
|
|
88
88
|
var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_ref, ref) {
|
|
89
89
|
var day = _ref.day,
|
|
@@ -125,7 +125,9 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
125
125
|
calendarRef = _ref.calendarRef,
|
|
126
126
|
mode = _ref.mode,
|
|
127
127
|
className = _ref.className,
|
|
128
|
-
style = _ref.style
|
|
128
|
+
style = _ref.style,
|
|
129
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
130
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
129
131
|
|
|
130
132
|
var _useControlledDateSta = (0, _useControlledDateState.default)({
|
|
131
133
|
day: day,
|
|
@@ -245,7 +247,7 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
245
247
|
"aria-describedby": announceId,
|
|
246
248
|
"aria-label": "calendar",
|
|
247
249
|
role: "grid",
|
|
248
|
-
tabIndex:
|
|
250
|
+
tabIndex: tabIndex
|
|
249
251
|
}, (0, _core.jsx)(_heading.default // The month number needs to be translated to index in the month
|
|
250
252
|
// name array e.g. 1 (January) -> 0
|
|
251
253
|
, {
|
|
@@ -270,6 +272,16 @@ var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_re
|
|
|
270
272
|
testId: testId
|
|
271
273
|
}))));
|
|
272
274
|
});
|
|
275
|
+
/**
|
|
276
|
+
* __Calendar__
|
|
277
|
+
*
|
|
278
|
+
* A calendar is used for date selection.
|
|
279
|
+
*
|
|
280
|
+
* - [Examples](https://atlassian.design/components/calendar/examples)
|
|
281
|
+
* - [Code](https://atlassian.design/components/calendar/code)
|
|
282
|
+
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
283
|
+
*/
|
|
284
|
+
|
|
273
285
|
var Calendar = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Calendar(props, ref) {
|
|
274
286
|
return (0, _core.jsx)(_components.default.Consumer, null, function (_ref2) {
|
|
275
287
|
var mode = _ref2.mode;
|
|
@@ -86,6 +86,7 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
86
86
|
"data-testid": testId && isSelected ? "".concat(testId, "--selected-day") : undefined
|
|
87
87
|
}, day);
|
|
88
88
|
}));
|
|
89
|
-
Date.displayName = 'Date';
|
|
89
|
+
Date.displayName = 'Date'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
90
|
+
|
|
90
91
|
var _default = Date;
|
|
91
92
|
exports.default = _default;
|
|
@@ -95,6 +95,7 @@ var Heading = /*#__PURE__*/(0, _react.memo)(function Heading(_ref) {
|
|
|
95
95
|
})
|
|
96
96
|
}));
|
|
97
97
|
});
|
|
98
|
-
Heading.displayName = 'Heading';
|
|
98
|
+
Heading.displayName = 'Heading'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
99
|
+
|
|
99
100
|
var _default = Heading;
|
|
100
101
|
exports.default = _default;
|
|
@@ -50,6 +50,7 @@ var WeekDays = /*#__PURE__*/(0, _react.memo)(function WeekDays(_ref) {
|
|
|
50
50
|
}));
|
|
51
51
|
}));
|
|
52
52
|
});
|
|
53
|
-
WeekDays.displayName = 'WeekDays';
|
|
53
|
+
WeekDays.displayName = 'WeekDays'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
54
|
+
|
|
54
55
|
var _default = WeekDays;
|
|
55
56
|
exports.default = _default;
|
|
@@ -40,6 +40,7 @@ var WeekHeader = /*#__PURE__*/(0, _react.memo)(function WeekHeader(_ref) {
|
|
|
40
40
|
}, shortDay);
|
|
41
41
|
}));
|
|
42
42
|
});
|
|
43
|
-
WeekHeader.displayName = 'WeekHeader';
|
|
43
|
+
WeekHeader.displayName = 'WeekHeader'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
44
|
+
|
|
44
45
|
var _default = WeekHeader;
|
|
45
46
|
exports.default = _default;
|
|
@@ -7,6 +7,7 @@ exports.default = useCalendarRef;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
10
11
|
function useCalendarRef(calendarRef, _ref) {
|
|
11
12
|
var navigate = _ref.navigate;
|
|
12
13
|
(0, _react.useImperativeHandle)(calendarRef, function () {
|
|
@@ -15,6 +15,7 @@ var _useLazyRef2 = _interopRequireDefault(require("@atlaskit/ds-lib/use-lazy-ref
|
|
|
15
15
|
|
|
16
16
|
var _pad = _interopRequireDefault(require("../utils/pad"));
|
|
17
17
|
|
|
18
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
18
19
|
function useControlledDateState(_ref) {
|
|
19
20
|
var day = _ref.day,
|
|
20
21
|
defaultDay = _ref.defaultDay,
|
|
@@ -47,7 +47,8 @@ function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}, [calendarLastValue, month, shouldDisplaySixthWeek, weekStartDay, year]);
|
|
50
|
-
}
|
|
50
|
+
} // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
51
|
+
|
|
51
52
|
|
|
52
53
|
function useGetWeeks(_ref2) {
|
|
53
54
|
var day = _ref2.day,
|
|
@@ -55,7 +55,8 @@ var getPrevMonth = function getPrevMonth(monthValue, yearValue) {
|
|
|
55
55
|
month: month,
|
|
56
56
|
year: year
|
|
57
57
|
};
|
|
58
|
-
};
|
|
58
|
+
}; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
59
|
+
|
|
59
60
|
|
|
60
61
|
function useHandleDateChange(_ref) {
|
|
61
62
|
var _ref$day = (0, _slicedToArray2.default)(_ref.day, 2),
|
|
@@ -15,6 +15,7 @@ var _constants = require("../constants");
|
|
|
15
15
|
|
|
16
16
|
var _dateToString = _interopRequireDefault(require("../utils/date-to-string"));
|
|
17
17
|
|
|
18
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
18
19
|
function useHandleDateSelect(_ref) {
|
|
19
20
|
var _ref$day = (0, _slicedToArray2.default)(_ref.day, 1),
|
|
20
21
|
dayValue = _ref$day[0],
|
|
@@ -7,6 +7,7 @@ exports.default = useUniqueId;
|
|
|
7
7
|
|
|
8
8
|
var _reactUid = require("react-uid");
|
|
9
9
|
|
|
10
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
10
11
|
function useUniqueId(prefix) {
|
|
11
12
|
var seed = (0, _reactUid.useUIDSeed)();
|
|
12
13
|
return "".concat(prefix, "-").concat(seed(prefix));
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/calendar.js
CHANGED
|
@@ -24,7 +24,7 @@ const lightWrapperStyles = css({
|
|
|
24
24
|
display: 'inline-block',
|
|
25
25
|
boxSizing: 'border-box',
|
|
26
26
|
padding: 16,
|
|
27
|
-
backgroundColor: `var(--ds-
|
|
27
|
+
backgroundColor: `var(--ds-UNSAFE_util-transparent, ${N0})`,
|
|
28
28
|
color: `var(--ds-text, ${N900})`,
|
|
29
29
|
outline: 'none',
|
|
30
30
|
userSelect: 'none'
|
|
@@ -33,7 +33,7 @@ const darkWrapperStyles = css({
|
|
|
33
33
|
display: 'inline-block',
|
|
34
34
|
boxSizing: 'border-box',
|
|
35
35
|
padding: 16,
|
|
36
|
-
backgroundColor: `var(--ds-
|
|
36
|
+
backgroundColor: `var(--ds-UNSAFE_util-transparent, ${N700})`,
|
|
37
37
|
color: `var(--ds-text, ${DN600})`,
|
|
38
38
|
outline: 'none',
|
|
39
39
|
userSelect: 'none'
|
|
@@ -48,7 +48,7 @@ const gridsContainerStyles = css({
|
|
|
48
48
|
const analyticsAttributes = {
|
|
49
49
|
componentName: 'calendar',
|
|
50
50
|
packageName: "@atlaskit/calendar",
|
|
51
|
-
packageVersion: "12.2
|
|
51
|
+
packageVersion: "12.3.2"
|
|
52
52
|
};
|
|
53
53
|
const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
54
54
|
day,
|
|
@@ -79,7 +79,8 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
79
79
|
calendarRef,
|
|
80
80
|
mode,
|
|
81
81
|
className,
|
|
82
|
-
style
|
|
82
|
+
style,
|
|
83
|
+
tabIndex = 0
|
|
83
84
|
}, ref) {
|
|
84
85
|
const {
|
|
85
86
|
day: [dayValue, setDayValue],
|
|
@@ -185,7 +186,7 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
185
186
|
"aria-describedby": announceId,
|
|
186
187
|
"aria-label": "calendar",
|
|
187
188
|
role: "grid",
|
|
188
|
-
tabIndex:
|
|
189
|
+
tabIndex: tabIndex
|
|
189
190
|
}, jsx(HeadingComponent // The month number needs to be translated to index in the month
|
|
190
191
|
// name array e.g. 1 (January) -> 0
|
|
191
192
|
, {
|
|
@@ -210,6 +211,16 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
210
211
|
testId: testId
|
|
211
212
|
}))));
|
|
212
213
|
});
|
|
214
|
+
/**
|
|
215
|
+
* __Calendar__
|
|
216
|
+
*
|
|
217
|
+
* A calendar is used for date selection.
|
|
218
|
+
*
|
|
219
|
+
* - [Examples](https://atlassian.design/components/calendar/examples)
|
|
220
|
+
* - [Code](https://atlassian.design/components/calendar/code)
|
|
221
|
+
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
222
|
+
*/
|
|
223
|
+
|
|
213
224
|
const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Calendar(props, ref) {
|
|
214
225
|
return jsx(GlobalTheme.Consumer, null, ({
|
|
215
226
|
mode
|
|
@@ -66,5 +66,6 @@ const Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date({
|
|
|
66
66
|
"data-testid": testId && isSelected ? `${testId}--selected-day` : undefined
|
|
67
67
|
}, day);
|
|
68
68
|
}));
|
|
69
|
-
Date.displayName = 'Date';
|
|
69
|
+
Date.displayName = 'Date'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
70
|
+
|
|
70
71
|
export default Date;
|
|
@@ -35,5 +35,6 @@ const WeekDays = /*#__PURE__*/memo(function WeekDays({
|
|
|
35
35
|
testId: testId
|
|
36
36
|
}, weekDay.day)))));
|
|
37
37
|
});
|
|
38
|
-
WeekDays.displayName = 'WeekDays';
|
|
38
|
+
WeekDays.displayName = 'WeekDays'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
39
|
+
|
|
39
40
|
export default WeekDays;
|
|
@@ -29,5 +29,6 @@ const WeekHeader = /*#__PURE__*/memo(function WeekHeader({
|
|
|
29
29
|
key: shortDay
|
|
30
30
|
}, shortDay)));
|
|
31
31
|
});
|
|
32
|
-
WeekHeader.displayName = 'WeekHeader';
|
|
32
|
+
WeekHeader.displayName = 'WeekHeader'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
33
|
+
|
|
33
34
|
export default WeekHeader;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import useControlled from '@atlaskit/ds-lib/use-controlled';
|
|
2
2
|
import useLazyRef from '@atlaskit/ds-lib/use-lazy-ref';
|
|
3
|
-
import pad from '../utils/pad';
|
|
3
|
+
import pad from '../utils/pad'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
4
|
+
|
|
4
5
|
export default function useControlledDateState({
|
|
5
6
|
day,
|
|
6
7
|
defaultDay,
|
|
@@ -26,7 +26,8 @@ function useGetCalendarWithSixthWeek(calendar, {
|
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
28
|
}, [calendarLastValue, month, shouldDisplaySixthWeek, weekStartDay, year]);
|
|
29
|
-
}
|
|
29
|
+
} // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
30
|
+
|
|
30
31
|
|
|
31
32
|
export default function useGetWeeks({
|
|
32
33
|
day,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { arrowKeys } from '../constants';
|
|
3
|
-
import dateToString from '../utils/date-to-string';
|
|
3
|
+
import dateToString from '../utils/date-to-string'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
4
|
+
|
|
4
5
|
export default function useHandleDateSelect({
|
|
5
6
|
day: [dayValue],
|
|
6
7
|
month: [monthValue],
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/calendar.js
CHANGED
|
@@ -30,7 +30,7 @@ var lightWrapperStyles = css({
|
|
|
30
30
|
display: 'inline-block',
|
|
31
31
|
boxSizing: 'border-box',
|
|
32
32
|
padding: 16,
|
|
33
|
-
backgroundColor: "var(--ds-
|
|
33
|
+
backgroundColor: "var(--ds-UNSAFE_util-transparent, ".concat(N0, ")"),
|
|
34
34
|
color: "var(--ds-text, ".concat(N900, ")"),
|
|
35
35
|
outline: 'none',
|
|
36
36
|
userSelect: 'none'
|
|
@@ -39,7 +39,7 @@ var darkWrapperStyles = css({
|
|
|
39
39
|
display: 'inline-block',
|
|
40
40
|
boxSizing: 'border-box',
|
|
41
41
|
padding: 16,
|
|
42
|
-
backgroundColor: "var(--ds-
|
|
42
|
+
backgroundColor: "var(--ds-UNSAFE_util-transparent, ".concat(N700, ")"),
|
|
43
43
|
color: "var(--ds-text, ".concat(DN600, ")"),
|
|
44
44
|
outline: 'none',
|
|
45
45
|
userSelect: 'none'
|
|
@@ -54,7 +54,7 @@ var gridsContainerStyles = css({
|
|
|
54
54
|
var analyticsAttributes = {
|
|
55
55
|
componentName: 'calendar',
|
|
56
56
|
packageName: "@atlaskit/calendar",
|
|
57
|
-
packageVersion: "12.2
|
|
57
|
+
packageVersion: "12.3.2"
|
|
58
58
|
};
|
|
59
59
|
var CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
|
|
60
60
|
var day = _ref.day,
|
|
@@ -96,7 +96,9 @@ var CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
|
|
|
96
96
|
calendarRef = _ref.calendarRef,
|
|
97
97
|
mode = _ref.mode,
|
|
98
98
|
className = _ref.className,
|
|
99
|
-
style = _ref.style
|
|
99
|
+
style = _ref.style,
|
|
100
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
101
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
100
102
|
|
|
101
103
|
var _useControlledDateSta = useControlledDateState({
|
|
102
104
|
day: day,
|
|
@@ -216,7 +218,7 @@ var CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
|
|
|
216
218
|
"aria-describedby": announceId,
|
|
217
219
|
"aria-label": "calendar",
|
|
218
220
|
role: "grid",
|
|
219
|
-
tabIndex:
|
|
221
|
+
tabIndex: tabIndex
|
|
220
222
|
}, jsx(HeadingComponent // The month number needs to be translated to index in the month
|
|
221
223
|
// name array e.g. 1 (January) -> 0
|
|
222
224
|
, {
|
|
@@ -241,6 +243,16 @@ var CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
|
|
|
241
243
|
testId: testId
|
|
242
244
|
}))));
|
|
243
245
|
});
|
|
246
|
+
/**
|
|
247
|
+
* __Calendar__
|
|
248
|
+
*
|
|
249
|
+
* A calendar is used for date selection.
|
|
250
|
+
*
|
|
251
|
+
* - [Examples](https://atlassian.design/components/calendar/examples)
|
|
252
|
+
* - [Code](https://atlassian.design/components/calendar/code)
|
|
253
|
+
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
254
|
+
*/
|
|
255
|
+
|
|
244
256
|
var Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Calendar(props, ref) {
|
|
245
257
|
return jsx(GlobalTheme.Consumer, null, function (_ref2) {
|
|
246
258
|
var mode = _ref2.mode;
|
|
@@ -73,5 +73,6 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref, ref) {
|
|
|
73
73
|
"data-testid": testId && isSelected ? "".concat(testId, "--selected-day") : undefined
|
|
74
74
|
}, day);
|
|
75
75
|
}));
|
|
76
|
-
Date.displayName = 'Date';
|
|
76
|
+
Date.displayName = 'Date'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
77
|
+
|
|
77
78
|
export default Date;
|
|
@@ -30,5 +30,6 @@ var WeekHeader = /*#__PURE__*/memo(function WeekHeader(_ref) {
|
|
|
30
30
|
}, shortDay);
|
|
31
31
|
}));
|
|
32
32
|
});
|
|
33
|
-
WeekHeader.displayName = 'WeekHeader';
|
|
33
|
+
WeekHeader.displayName = 'WeekHeader'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
34
|
+
|
|
34
35
|
export default WeekHeader;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import useControlled from '@atlaskit/ds-lib/use-controlled';
|
|
3
3
|
import useLazyRef from '@atlaskit/ds-lib/use-lazy-ref';
|
|
4
|
-
import pad from '../utils/pad';
|
|
4
|
+
import pad from '../utils/pad'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
5
|
+
|
|
5
6
|
export default function useControlledDateState(_ref) {
|
|
6
7
|
var day = _ref.day,
|
|
7
8
|
defaultDay = _ref.defaultDay,
|
|
@@ -34,7 +34,8 @@ function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
}, [calendarLastValue, month, shouldDisplaySixthWeek, weekStartDay, year]);
|
|
37
|
-
}
|
|
37
|
+
} // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
38
|
+
|
|
38
39
|
|
|
39
40
|
export default function useGetWeeks(_ref2) {
|
|
40
41
|
var day = _ref2.day,
|
|
@@ -42,7 +42,8 @@ var getPrevMonth = function getPrevMonth(monthValue, yearValue) {
|
|
|
42
42
|
month: month,
|
|
43
43
|
year: year
|
|
44
44
|
};
|
|
45
|
-
};
|
|
45
|
+
}; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
46
|
+
|
|
46
47
|
|
|
47
48
|
export default function useHandleDateChange(_ref) {
|
|
48
49
|
var _ref$day = _slicedToArray(_ref.day, 2),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { useCallback, useEffect, useRef } from 'react';
|
|
3
3
|
import { arrowKeys } from '../constants';
|
|
4
|
-
import dateToString from '../utils/date-to-string';
|
|
4
|
+
import dateToString from '../utils/date-to-string'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
5
|
+
|
|
5
6
|
export default function useHandleDateSelect(_ref) {
|
|
6
7
|
var _ref$day = _slicedToArray(_ref.day, 1),
|
|
7
8
|
dayValue = _ref$day[0],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
3
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
3
4
|
export default function useLocale(_ref) {
|
|
4
5
|
var locale = _ref.locale,
|
|
5
6
|
weekStartDay = _ref.weekStartDay;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useUIDSeed } from 'react-uid';
|
|
1
|
+
import { useUIDSeed } from 'react-uid'; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
2
|
+
|
|
2
3
|
export default function useUniqueId(prefix) {
|
|
3
4
|
var seed = useUIDSeed();
|
|
4
5
|
return "".concat(prefix, "-").concat(seed(prefix));
|
package/dist/esm/version.json
CHANGED
package/dist/types/calendar.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CalendarProps } from './types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* __Calendar__
|
|
5
|
+
*
|
|
6
|
+
* A calendar is used for date selection.
|
|
7
|
+
*
|
|
8
|
+
* - [Examples](https://atlassian.design/components/calendar/examples)
|
|
9
|
+
* - [Code](https://atlassian.design/components/calendar/code)
|
|
10
|
+
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
11
|
+
*/
|
|
12
|
+
declare const Calendar: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CalendarProps, "style" | "disabled" | "year" | "previousMonthLabel" | "nextMonthLabel" | "mode" | "testId" | "selected" | "className" | "tabIndex" | "onFocus" | "onBlur" | "onChange" | "onSelect" | "analyticsContext" | "day" | "month" | "defaultDay" | "defaultMonth" | "defaultYear" | "today" | "defaultSelected" | "previouslySelected" | "defaultPreviouslySelected" | "weekStartDay" | "disabledDateFilter" | "minDate" | "maxDate" | "locale" | "calendarRef" | "createAnalyticsEvent"> & import("react").RefAttributes<HTMLDivElement>>>;
|
|
4
13
|
export default Calendar;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
3
|
import type { DateObj } from '../types';
|
|
4
|
-
interface
|
|
4
|
+
interface DateProps {
|
|
5
5
|
children: number;
|
|
6
6
|
isDisabled?: boolean;
|
|
7
7
|
isFocused?: boolean;
|
|
@@ -15,5 +15,5 @@ interface Props {
|
|
|
15
15
|
mode?: ThemeModes;
|
|
16
16
|
testId?: string;
|
|
17
17
|
}
|
|
18
|
-
declare const Date: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<
|
|
18
|
+
declare const Date: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<DateProps & import("react").RefAttributes<HTMLButtonElement>>>;
|
|
19
19
|
export default Date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
-
interface
|
|
3
|
+
interface HeadingProps {
|
|
4
4
|
monthLongTitle: string;
|
|
5
5
|
year: number;
|
|
6
6
|
previousMonthLabel?: string;
|
|
@@ -10,5 +10,5 @@ interface Props {
|
|
|
10
10
|
mode?: ThemeModes;
|
|
11
11
|
testId?: string;
|
|
12
12
|
}
|
|
13
|
-
declare const Heading: import("react").NamedExoticComponent<
|
|
13
|
+
declare const Heading: import("react").NamedExoticComponent<HeadingProps>;
|
|
14
14
|
export default Heading;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ThemeModes } from '@atlaskit/theme/types';
|
|
3
3
|
import { DateObj, Week } from '../types';
|
|
4
|
-
interface
|
|
4
|
+
interface WeekDaysProps {
|
|
5
5
|
weeks: Week[];
|
|
6
6
|
handleClickDay: (date: DateObj) => void;
|
|
7
7
|
mode?: ThemeModes;
|
|
8
8
|
testId?: string;
|
|
9
9
|
}
|
|
10
|
-
declare const WeekDays: import("react").NamedExoticComponent<
|
|
10
|
+
declare const WeekDays: import("react").NamedExoticComponent<WeekDaysProps>;
|
|
11
11
|
export default WeekDays;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ThemeModes } from '@atlaskit/theme/types';
|
|
3
|
-
interface
|
|
3
|
+
interface WeekHeaderProps {
|
|
4
4
|
daysShort: string[];
|
|
5
5
|
mode?: ThemeModes;
|
|
6
6
|
}
|
|
7
|
-
declare const WeekHeader: import("react").NamedExoticComponent<
|
|
7
|
+
declare const WeekHeader: import("react").NamedExoticComponent<WeekHeaderProps>;
|
|
8
8
|
export default WeekHeader;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -11,58 +11,104 @@ export declare type SelectEvent = {
|
|
|
11
11
|
iso: ISODate;
|
|
12
12
|
} & DateObj;
|
|
13
13
|
export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The number of the day currently focused. Places border around the date. 0 highlights no date.
|
|
16
|
+
*/
|
|
15
17
|
day?: number;
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Default for `day`.
|
|
20
|
+
*/
|
|
17
21
|
defaultDay?: number;
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Default for `month`.
|
|
24
|
+
*/
|
|
19
25
|
defaultMonth?: number;
|
|
20
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Default for `previouslySelected`.
|
|
28
|
+
*/
|
|
21
29
|
defaultPreviouslySelected?: Array<string>;
|
|
22
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Default for `selected`.
|
|
32
|
+
*/
|
|
23
33
|
defaultSelected?: Array<string>;
|
|
24
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Default for `year`.
|
|
36
|
+
*/
|
|
25
37
|
defaultYear?: number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates provided are greyed out.
|
|
40
|
+
* This does not prevent these dates being selected.
|
|
41
|
+
*/
|
|
28
42
|
disabled?: Array<string>;
|
|
29
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* A filter function that takes a date string in the format 'YYYY-MM-DD' and returns true if that date should be disabled.
|
|
45
|
+
*/
|
|
30
46
|
disabledDateFilter?: (date: string) => boolean;
|
|
31
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The latest enabled date
|
|
49
|
+
*/
|
|
32
50
|
maxDate?: string;
|
|
33
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* The earliest enabled date
|
|
53
|
+
*/
|
|
34
54
|
minDate?: string;
|
|
35
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* The number of the month (from 1 to 12) which the calendar should be on.
|
|
57
|
+
*/
|
|
36
58
|
month?: number;
|
|
37
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* The aria-label attribute associated with the next-month arrow.
|
|
61
|
+
*/
|
|
38
62
|
nextMonthLabel?: string;
|
|
39
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Function which is called when the calendar is no longer focused.
|
|
65
|
+
*/
|
|
40
66
|
onBlur?: React.FocusEventHandler;
|
|
41
|
-
/**
|
|
42
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Called when the calendar is navigated. This can be triggered by the keyboard, or by clicking the navigational buttons.
|
|
69
|
+
* The 'interface' property indicates the the direction the calendar was navigated whereas the 'iso' property is a string of the format YYYY-MM-DD.
|
|
70
|
+
*/
|
|
43
71
|
onChange?: (event: ChangeEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
44
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Called when the calendar receives focus. This could be from a mouse event on the container by tabbing into it.
|
|
74
|
+
*/
|
|
45
75
|
onFocus?: React.FocusEventHandler;
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Function called when a day is clicked on. Calls with an object that has
|
|
78
|
+
* a day, month and year property as numbers, representing the date just clicked.
|
|
79
|
+
* It also has an 'iso' property, which is a string of the selected date in the
|
|
80
|
+
* format YYYY-MM-DD.
|
|
81
|
+
*/
|
|
50
82
|
onSelect?: (event: SelectEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
51
|
-
/**
|
|
52
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates
|
|
85
|
+
* provided are given a background color.
|
|
86
|
+
*/
|
|
53
87
|
previouslySelected?: Array<string>;
|
|
54
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The aria-label attribute associated with the previous-month arrow.
|
|
90
|
+
*/
|
|
55
91
|
previousMonthLabel?: string;
|
|
56
|
-
/**
|
|
57
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates
|
|
94
|
+
* provided are given a background color.
|
|
95
|
+
*/
|
|
58
96
|
selected?: Array<string>;
|
|
59
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Value of current day, as a string in the format 'YYYY-MM-DD'.
|
|
99
|
+
*/
|
|
60
100
|
today?: string;
|
|
61
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Year to display the calendar for.
|
|
103
|
+
*/
|
|
62
104
|
year?: number;
|
|
63
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* BCP 47 language tag (e.g. ja-JP) that ensures dates are in the official format for the locale.
|
|
107
|
+
*/
|
|
64
108
|
locale?: string;
|
|
65
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Additional information to be included in the `context` of analytics events.
|
|
111
|
+
*/
|
|
66
112
|
analyticsContext?: Record<string, any>;
|
|
67
113
|
/**
|
|
68
114
|
* Start day of the week for the calendar.
|
|
@@ -84,7 +130,7 @@ export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
|
84
130
|
* testId--next-month - Button to show previous month
|
|
85
131
|
* testId--current-month-year - Text containing the current month and year
|
|
86
132
|
* testId--selected-day - The currently selected day (may be missing if a date isn’t selected)
|
|
87
|
-
|
|
133
|
+
*/
|
|
88
134
|
testId?: string;
|
|
89
135
|
/**
|
|
90
136
|
* Class name to apply to the calendar
|
|
@@ -103,6 +149,10 @@ export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
|
103
149
|
* @internal Legacy theme mode, can be either 'light' or 'dark'
|
|
104
150
|
*/
|
|
105
151
|
mode?: ThemeModes;
|
|
152
|
+
/**
|
|
153
|
+
* Tab index indicates if the calendar can be focused by keyboard or only programmatically.
|
|
154
|
+
*/
|
|
155
|
+
tabIndex?: number;
|
|
106
156
|
}
|
|
107
157
|
export interface CalendarRef {
|
|
108
158
|
navigate: (type: ArrowKeys) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/calendar",
|
|
3
|
-
"version": "12.2
|
|
3
|
+
"version": "12.3.2",
|
|
4
4
|
"description": "An interactive calendar for date selection experiences.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
15
|
"sideEffects": false,
|
|
16
|
-
"atlaskit:src": "src/index.
|
|
16
|
+
"atlaskit:src": "src/index.tsx",
|
|
17
17
|
"atlassian": {
|
|
18
18
|
"team": "Design System Team",
|
|
19
19
|
"releaseModel": "scheduled",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
27
27
|
"@atlaskit/button": "^16.3.0",
|
|
28
|
-
"@atlaskit/ds-lib": "^2.
|
|
28
|
+
"@atlaskit/ds-lib": "^2.1.0",
|
|
29
29
|
"@atlaskit/icon": "^21.10.0",
|
|
30
30
|
"@atlaskit/locale": "^2.3.0",
|
|
31
31
|
"@atlaskit/theme": "^12.1.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@atlaskit/docs": "*",
|
|
44
|
-
"@atlaskit/select": "^15.
|
|
44
|
+
"@atlaskit/select": "^15.6.0",
|
|
45
45
|
"@atlaskit/ssr": "*",
|
|
46
46
|
"@atlaskit/visual-regression": "*",
|
|
47
47
|
"@atlaskit/webdriver-runner": "*",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"react-dom": "^16.8.0",
|
|
54
54
|
"react-test-renderer": "^16.8.0",
|
|
55
55
|
"storybook-addon-performance": "^0.16.0",
|
|
56
|
-
"typescript": "4.
|
|
56
|
+
"typescript": "4.3.5",
|
|
57
57
|
"wait-for-expect": "^1.2.0"
|
|
58
58
|
},
|
|
59
59
|
"techstack": {
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"@repo/internal": {
|
|
64
64
|
"dom-events": "use-bind-event-listener",
|
|
65
|
+
"design-system": "v1",
|
|
65
66
|
"ui-components": "lite-mode",
|
|
66
67
|
"analytics": "analytics-next",
|
|
67
68
|
"theming": "tokens",
|
|
@@ -73,8 +74,8 @@
|
|
|
73
74
|
}
|
|
74
75
|
},
|
|
75
76
|
"af:exports": {
|
|
76
|
-
"./types": "./src/entry-points/types.
|
|
77
|
-
".": "./src/index.
|
|
77
|
+
"./types": "./src/entry-points/types.tsx",
|
|
78
|
+
".": "./src/index.tsx"
|
|
78
79
|
},
|
|
79
80
|
"homepage": "https://atlassian.design/components/calendar/",
|
|
80
81
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
package/report.api.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/calendar"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
/// <reference types="react" />
|
|
7
|
+
|
|
8
|
+
import { CSSProperties } from 'react';
|
|
9
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
10
|
+
import { MemoExoticComponent } from 'react';
|
|
11
|
+
import { RefAttributes } from 'react';
|
|
12
|
+
import { ThemeModes } from '@atlaskit/theme/types';
|
|
13
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
14
|
+
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
15
|
+
|
|
16
|
+
declare type ArrowKeys = 'left' | 'up' | 'right' | 'down';
|
|
17
|
+
|
|
18
|
+
declare const Calendar: MemoExoticComponent<ForwardRefExoticComponent<
|
|
19
|
+
Pick<
|
|
20
|
+
CalendarProps,
|
|
21
|
+
| 'year'
|
|
22
|
+
| 'previousMonthLabel'
|
|
23
|
+
| 'nextMonthLabel'
|
|
24
|
+
| 'mode'
|
|
25
|
+
| 'testId'
|
|
26
|
+
| 'style'
|
|
27
|
+
| 'disabled'
|
|
28
|
+
| 'selected'
|
|
29
|
+
| 'className'
|
|
30
|
+
| 'onFocus'
|
|
31
|
+
| 'onBlur'
|
|
32
|
+
| 'onChange'
|
|
33
|
+
| 'onSelect'
|
|
34
|
+
| 'analyticsContext'
|
|
35
|
+
| 'day'
|
|
36
|
+
| 'month'
|
|
37
|
+
| 'defaultDay'
|
|
38
|
+
| 'defaultMonth'
|
|
39
|
+
| 'defaultYear'
|
|
40
|
+
| 'today'
|
|
41
|
+
| 'defaultSelected'
|
|
42
|
+
| 'previouslySelected'
|
|
43
|
+
| 'defaultPreviouslySelected'
|
|
44
|
+
| 'weekStartDay'
|
|
45
|
+
| 'disabledDateFilter'
|
|
46
|
+
| 'minDate'
|
|
47
|
+
| 'maxDate'
|
|
48
|
+
| 'locale'
|
|
49
|
+
| 'calendarRef'
|
|
50
|
+
| 'createAnalyticsEvent'
|
|
51
|
+
> &
|
|
52
|
+
RefAttributes<HTMLDivElement>
|
|
53
|
+
>>;
|
|
54
|
+
export default Calendar;
|
|
55
|
+
|
|
56
|
+
export declare interface CalendarProps extends WithAnalyticsEventsProps {
|
|
57
|
+
/** The number of the day currently focused. Places border around the date. 0 highlights no date. */
|
|
58
|
+
day?: number;
|
|
59
|
+
/** Default for `day`. */
|
|
60
|
+
defaultDay?: number;
|
|
61
|
+
/** Default for `month`. */
|
|
62
|
+
defaultMonth?: number;
|
|
63
|
+
/** Default for `previouslySelected`. */
|
|
64
|
+
defaultPreviouslySelected?: Array<string>;
|
|
65
|
+
/** Default for `selected`. */
|
|
66
|
+
defaultSelected?: Array<string>;
|
|
67
|
+
/** Default for `year`. */
|
|
68
|
+
defaultYear?: number;
|
|
69
|
+
/** Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates provided are greyed out.
|
|
70
|
+
This does not prevent these dates being selected. */
|
|
71
|
+
disabled?: Array<string>;
|
|
72
|
+
/** A filter function that takes a date string in the format 'YYYY-MM-DD' and returns true if that date should be disabled. */
|
|
73
|
+
disabledDateFilter?: (date: string) => boolean;
|
|
74
|
+
/** The latest enabled date */
|
|
75
|
+
maxDate?: string;
|
|
76
|
+
/** The earliest enabled date */
|
|
77
|
+
minDate?: string;
|
|
78
|
+
/** The number of the month (from 1 to 12) which the calendar should be on. */
|
|
79
|
+
month?: number;
|
|
80
|
+
/** The aria-label attribute associated with the next-month arrow. */
|
|
81
|
+
nextMonthLabel?: string;
|
|
82
|
+
/** Function which is called when the calendar is no longer focused. */
|
|
83
|
+
onBlur?: React.FocusEventHandler;
|
|
84
|
+
/** Called when the calendar is navigated. This can be triggered by the keyboard, or by clicking the navigational buttons.
|
|
85
|
+
The 'interface' property indicates the the direction the calendar was navigated whereas the 'iso' property is a string of the format YYYY-MM-DD. */
|
|
86
|
+
onChange?: (event: ChangeEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
87
|
+
/** Called when the calendar receives focus. This could be from a mouse event on the container by tabbing into it. */
|
|
88
|
+
onFocus?: React.FocusEventHandler;
|
|
89
|
+
/** Function called when a day is clicked on. Calls with an object that has
|
|
90
|
+
a day, month and year property as numbers, representing the date just clicked.
|
|
91
|
+
It also has an 'iso' property, which is a string of the selected date in the
|
|
92
|
+
format YYYY-MM-DD. */
|
|
93
|
+
onSelect?: (event: SelectEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
94
|
+
/** Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates
|
|
95
|
+
provided are given a background color. */
|
|
96
|
+
previouslySelected?: Array<string>;
|
|
97
|
+
/** The aria-label attribute associated with the previous-month arrow. */
|
|
98
|
+
previousMonthLabel?: string;
|
|
99
|
+
/** Takes an array of dates as string in the format 'YYYY-MM-DD'. All dates
|
|
100
|
+
provided are given a background color. */
|
|
101
|
+
selected?: Array<string>;
|
|
102
|
+
/** Value of current day, as a string in the format 'YYYY-MM-DD'. */
|
|
103
|
+
today?: string;
|
|
104
|
+
/** Year to display the calendar for. */
|
|
105
|
+
year?: number;
|
|
106
|
+
/** BCP 47 language tag (e.g. ja-JP) that ensures dates are in the official format for the locale. */
|
|
107
|
+
locale?: string;
|
|
108
|
+
/** Additional information to be included in the `context` of analytics events. */
|
|
109
|
+
analyticsContext?: Record<string, any>;
|
|
110
|
+
/**
|
|
111
|
+
* Start day of the week for the calendar.
|
|
112
|
+
* - `0` sunday (default value)
|
|
113
|
+
* - `1` monday
|
|
114
|
+
* - `2` tuesday
|
|
115
|
+
* - `3` wednesday
|
|
116
|
+
* - `4` thursday
|
|
117
|
+
* - `5` friday
|
|
118
|
+
* - `6` saturday
|
|
119
|
+
*/
|
|
120
|
+
weekStartDay?: WeekDay;
|
|
121
|
+
/**
|
|
122
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
123
|
+
*
|
|
124
|
+
* testId--container - Outermost container containing everything inside calendar
|
|
125
|
+
* testId--month - Container containing all available days for the month
|
|
126
|
+
* testId--previous-month - Button to show next month
|
|
127
|
+
* testId--next-month - Button to show previous month
|
|
128
|
+
* testId--current-month-year - Text containing the current month and year
|
|
129
|
+
* testId--selected-day - The currently selected day (may be missing if a date isn’t selected)
|
|
130
|
+
* */
|
|
131
|
+
testId?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Class name to apply to the calendar
|
|
134
|
+
*/
|
|
135
|
+
className?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Style customization to apply to the calendar
|
|
138
|
+
*/
|
|
139
|
+
style?: CSSProperties;
|
|
140
|
+
/**
|
|
141
|
+
* @internal An additional ref which exposes Calendar's internal api's. We kept this for
|
|
142
|
+
* backward compatibility. PLEASE DO NOT USE THIS.
|
|
143
|
+
*/
|
|
144
|
+
calendarRef?: React.Ref<CalendarRef>;
|
|
145
|
+
/**
|
|
146
|
+
* @internal Legacy theme mode, can be either 'light' or 'dark'
|
|
147
|
+
*/
|
|
148
|
+
mode?: ThemeModes;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare interface CalendarRef {
|
|
152
|
+
navigate: (type: ArrowKeys) => void;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export declare type ChangeEvent = {
|
|
156
|
+
iso: ISODate;
|
|
157
|
+
type: 'left' | 'up' | 'right' | 'down' | 'prev' | 'next';
|
|
158
|
+
} & DateObj;
|
|
159
|
+
|
|
160
|
+
declare type DateObj = {
|
|
161
|
+
day: number;
|
|
162
|
+
month: number;
|
|
163
|
+
year: number;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
declare type ISODate = string;
|
|
167
|
+
|
|
168
|
+
export declare type SelectEvent = {
|
|
169
|
+
iso: ISODate;
|
|
170
|
+
} & DateObj;
|
|
171
|
+
|
|
172
|
+
declare type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
173
|
+
|
|
174
|
+
export {};
|
|
175
|
+
```
|