@atlaskit/calendar 12.1.14 → 12.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -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 +21 -5
- package/dist/cjs/internal/components/date.js +2 -1
- package/dist/cjs/internal/components/heading.js +12 -5
- 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 +20 -5
- package/dist/es2019/internal/components/date.js +2 -1
- package/dist/es2019/internal/components/heading.js +10 -5
- 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 +21 -5
- package/dist/esm/internal/components/date.js +2 -1
- package/dist/esm/internal/components/heading.js +12 -5
- 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 +4 -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 +83 -29
- package/package.json +10 -7
- package/report.api.md +175 -0
|
@@ -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, "year" | "previousMonthLabel" | "nextMonthLabel" | "mode" | "testId" | "style" | "disabled" | "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,12 +1,14 @@
|
|
|
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
|
+
previousMonthLabel?: string;
|
|
7
|
+
nextMonthLabel?: string;
|
|
6
8
|
handleClickNext?: () => void;
|
|
7
9
|
handleClickPrev?: () => void;
|
|
8
10
|
mode?: ThemeModes;
|
|
9
11
|
testId?: string;
|
|
10
12
|
}
|
|
11
|
-
declare const Heading: import("react").NamedExoticComponent<
|
|
13
|
+
declare const Heading: import("react").NamedExoticComponent<HeadingProps>;
|
|
12
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,54 +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
|
+
*/
|
|
62
|
+
nextMonthLabel?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Function which is called when the calendar is no longer focused.
|
|
65
|
+
*/
|
|
38
66
|
onBlur?: React.FocusEventHandler;
|
|
39
|
-
/**
|
|
40
|
-
|
|
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
|
+
*/
|
|
41
71
|
onChange?: (event: ChangeEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
42
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Called when the calendar receives focus. This could be from a mouse event on the container by tabbing into it.
|
|
74
|
+
*/
|
|
43
75
|
onFocus?: React.FocusEventHandler;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
*/
|
|
48
82
|
onSelect?: (event: SelectEvent, analyticsEvent: UIAnalyticsEvent) => void;
|
|
49
|
-
/**
|
|
50
|
-
|
|
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
|
+
*/
|
|
51
87
|
previouslySelected?: Array<string>;
|
|
52
|
-
/**
|
|
53
|
-
|
|
88
|
+
/**
|
|
89
|
+
* The aria-label attribute associated with the previous-month arrow.
|
|
90
|
+
*/
|
|
91
|
+
previousMonthLabel?: string;
|
|
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
|
+
*/
|
|
54
96
|
selected?: Array<string>;
|
|
55
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Value of current day, as a string in the format 'YYYY-MM-DD'.
|
|
99
|
+
*/
|
|
56
100
|
today?: string;
|
|
57
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Year to display the calendar for.
|
|
103
|
+
*/
|
|
58
104
|
year?: number;
|
|
59
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* BCP 47 language tag (e.g. ja-JP) that ensures dates are in the official format for the locale.
|
|
107
|
+
*/
|
|
60
108
|
locale?: string;
|
|
61
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Additional information to be included in the `context` of analytics events.
|
|
111
|
+
*/
|
|
62
112
|
analyticsContext?: Record<string, any>;
|
|
63
113
|
/**
|
|
64
114
|
* Start day of the week for the calendar.
|
|
@@ -80,7 +130,7 @@ export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
|
80
130
|
* testId--next-month - Button to show previous month
|
|
81
131
|
* testId--current-month-year - Text containing the current month and year
|
|
82
132
|
* testId--selected-day - The currently selected day (may be missing if a date isn’t selected)
|
|
83
|
-
|
|
133
|
+
*/
|
|
84
134
|
testId?: string;
|
|
85
135
|
/**
|
|
86
136
|
* Class name to apply to the calendar
|
|
@@ -99,6 +149,10 @@ export interface CalendarProps extends WithAnalyticsEventsProps {
|
|
|
99
149
|
* @internal Legacy theme mode, can be either 'light' or 'dark'
|
|
100
150
|
*/
|
|
101
151
|
mode?: ThemeModes;
|
|
152
|
+
/**
|
|
153
|
+
* Tab index indicates if the calendar can be focused by keyboard or only programmatically.
|
|
154
|
+
*/
|
|
155
|
+
tabIndex?: number;
|
|
102
156
|
}
|
|
103
157
|
export interface CalendarRef {
|
|
104
158
|
navigate: (type: ArrowKeys) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/calendar",
|
|
3
|
-
"version": "12.1
|
|
3
|
+
"version": "12.3.1",
|
|
4
4
|
"description": "An interactive calendar for date selection experiences.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -13,18 +13,19 @@
|
|
|
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",
|
|
20
20
|
"website": {
|
|
21
|
-
"name": "Calendar"
|
|
21
|
+
"name": "Calendar",
|
|
22
|
+
"category": "Components"
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
26
27
|
"@atlaskit/button": "^16.3.0",
|
|
27
|
-
"@atlaskit/ds-lib": "^1.
|
|
28
|
+
"@atlaskit/ds-lib": "^2.1.0",
|
|
28
29
|
"@atlaskit/icon": "^21.10.0",
|
|
29
30
|
"@atlaskit/locale": "^2.3.0",
|
|
30
31
|
"@atlaskit/theme": "^12.1.0",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@atlaskit/docs": "*",
|
|
43
|
-
"@atlaskit/select": "^15.
|
|
44
|
+
"@atlaskit/select": "^15.5.0",
|
|
44
45
|
"@atlaskit/ssr": "*",
|
|
45
46
|
"@atlaskit/visual-regression": "*",
|
|
46
47
|
"@atlaskit/webdriver-runner": "*",
|
|
@@ -60,6 +61,8 @@
|
|
|
60
61
|
"import-structure": "atlassian-conventions"
|
|
61
62
|
},
|
|
62
63
|
"@repo/internal": {
|
|
64
|
+
"dom-events": "use-bind-event-listener",
|
|
65
|
+
"design-system": "v1",
|
|
63
66
|
"ui-components": "lite-mode",
|
|
64
67
|
"analytics": "analytics-next",
|
|
65
68
|
"theming": "tokens",
|
|
@@ -71,8 +74,8 @@
|
|
|
71
74
|
}
|
|
72
75
|
},
|
|
73
76
|
"af:exports": {
|
|
74
|
-
"./types": "./src/entry-points/types.
|
|
75
|
-
".": "./src/index.
|
|
77
|
+
"./types": "./src/entry-points/types.tsx",
|
|
78
|
+
".": "./src/index.tsx"
|
|
76
79
|
},
|
|
77
80
|
"homepage": "https://atlassian.design/components/calendar/",
|
|
78
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
|
+
```
|