@atlaskit/calendar 13.1.1 → 13.1.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/calendar.js +1 -1
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/es2019/calendar.js +1 -1
  5. package/dist/es2019/version.json +1 -1
  6. package/dist/esm/calendar.js +1 -1
  7. package/dist/esm/version.json +1 -1
  8. package/dist/types-ts4.5/calendar.d.ts +13 -0
  9. package/dist/types-ts4.5/entry-points/types.d.ts +1 -0
  10. package/dist/types-ts4.5/index.d.ts +2 -0
  11. package/dist/types-ts4.5/internal/components/date.d.ts +19 -0
  12. package/dist/types-ts4.5/internal/components/header.d.ts +14 -0
  13. package/dist/types-ts4.5/internal/components/week-day-grid.d.ts +15 -0
  14. package/dist/types-ts4.5/internal/components/week-days.d.ts +11 -0
  15. package/dist/types-ts4.5/internal/components/week-header.d.ts +8 -0
  16. package/dist/types-ts4.5/internal/constants.d.ts +5 -0
  17. package/dist/types-ts4.5/internal/hooks/use-calendar-ref.d.ts +5 -0
  18. package/dist/types-ts4.5/internal/hooks/use-controlled-date-state.d.ts +37 -0
  19. package/dist/types-ts4.5/internal/hooks/use-focusing.d.ts +8 -0
  20. package/dist/types-ts4.5/internal/hooks/use-get-weeks.d.ts +15 -0
  21. package/dist/types-ts4.5/internal/hooks/use-handle-date-change.d.ts +21 -0
  22. package/dist/types-ts4.5/internal/hooks/use-handle-date-select.d.ts +30 -0
  23. package/dist/types-ts4.5/internal/hooks/use-locale.d.ts +8 -0
  24. package/dist/types-ts4.5/internal/hooks/use-unique-id.d.ts +1 -0
  25. package/dist/types-ts4.5/internal/styles/date.d.ts +3 -0
  26. package/dist/types-ts4.5/internal/types.d.ts +26 -0
  27. package/dist/types-ts4.5/internal/utils/date-to-string.d.ts +6 -0
  28. package/dist/types-ts4.5/internal/utils/get-base-calendar.d.ts +10 -0
  29. package/dist/types-ts4.5/internal/utils/get-days-in-month.d.ts +1 -0
  30. package/dist/types-ts4.5/internal/utils/pad.d.ts +1 -0
  31. package/dist/types-ts4.5/types.d.ts +159 -0
  32. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/calendar
2
2
 
3
+ ## 13.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
3
9
  ## 13.1.1
4
10
 
5
11
  ### Patch Changes
@@ -33,7 +33,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
33
33
  var analyticsAttributes = {
34
34
  componentName: 'calendar',
35
35
  packageName: "@atlaskit/calendar",
36
- packageVersion: "13.1.1"
36
+ packageVersion: "13.1.2"
37
37
  };
38
38
  var CalendarWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_ref, ref) {
39
39
  var day = _ref.day,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/calendar",
3
- "version": "13.1.1",
3
+ "version": "13.1.2",
4
4
  "sideEffects": false
5
5
  }
@@ -23,7 +23,7 @@ import useUniqueId from './internal/hooks/use-unique-id';
23
23
  const analyticsAttributes = {
24
24
  componentName: 'calendar',
25
25
  packageName: "@atlaskit/calendar",
26
- packageVersion: "13.1.1"
26
+ packageVersion: "13.1.2"
27
27
  };
28
28
  const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
29
29
  day,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/calendar",
3
- "version": "13.1.1",
3
+ "version": "13.1.2",
4
4
  "sideEffects": false
5
5
  }
@@ -27,7 +27,7 @@ import useUniqueId from './internal/hooks/use-unique-id';
27
27
  var analyticsAttributes = {
28
28
  componentName: 'calendar',
29
29
  packageName: "@atlaskit/calendar",
30
- packageVersion: "13.1.1"
30
+ packageVersion: "13.1.2"
31
31
  };
32
32
  var CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
33
33
  var day = _ref.day,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/calendar",
3
- "version": "13.1.1",
3
+ "version": "13.1.2",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { CalendarProps } from './types';
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" | "className" | "style" | "tabIndex" | "onFocus" | "onBlur" | "onChange" | "onSelect" | "disabled" | "selected" | "analyticsContext" | "day" | "defaultDay" | "defaultMonth" | "defaultPreviouslySelected" | "defaultSelected" | "defaultYear" | "disabledDateFilter" | "maxDate" | "minDate" | "month" | "previouslySelected" | "today" | "locale" | "weekStartDay" | "calendarRef" | "createAnalyticsEvent"> & import("react").RefAttributes<HTMLDivElement>>>;
13
+ export default Calendar;
@@ -0,0 +1 @@
1
+ export type { CalendarProps, ChangeEvent, SelectEvent, CalendarRef, WeekDay, } from '../types';
@@ -0,0 +1,2 @@
1
+ export { default } from './calendar';
2
+ export type { CalendarProps, ChangeEvent, SelectEvent, CalendarRef, } from './types';
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { ThemeModes } from '@atlaskit/theme/types';
3
+ import type { DateObj } from '../types';
4
+ interface DateProps {
5
+ children: number;
6
+ isDisabled?: boolean;
7
+ isFocused?: boolean;
8
+ isToday?: boolean;
9
+ month: number;
10
+ onClick?: ({ day, month, year }: DateObj) => void;
11
+ isPreviouslySelected?: boolean;
12
+ isSelected?: boolean;
13
+ isSibling?: boolean;
14
+ year: number;
15
+ mode?: ThemeModes;
16
+ testId?: string;
17
+ }
18
+ declare const Date: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<DateProps & import("react").RefAttributes<HTMLButtonElement>>>;
19
+ export default Date;
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ import { ThemeModes } from '@atlaskit/theme/types';
3
+ interface HeaderProps {
4
+ monthLongTitle: string;
5
+ year: number;
6
+ previousMonthLabel?: string;
7
+ nextMonthLabel?: string;
8
+ handleClickNext?: () => void;
9
+ handleClickPrev?: () => void;
10
+ mode?: ThemeModes;
11
+ testId?: string;
12
+ }
13
+ declare const Header: import("react").NamedExoticComponent<HeaderProps>;
14
+ export default Header;
@@ -0,0 +1,15 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ import { jsx } from '@emotion/react';
4
+ interface WeekDayGridProps extends React.HTMLAttributes<HTMLElement> {
5
+ testId?: string;
6
+ children: ReactNode;
7
+ }
8
+ /**
9
+ * __Week day grid__
10
+ *
11
+ * A week day grid aligns elements in a 7 wide grid layout.
12
+ *
13
+ */
14
+ declare const WeekDayGrid: ({ testId, children }: WeekDayGridProps) => jsx.JSX.Element;
15
+ export default WeekDayGrid;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { ThemeModes } from '@atlaskit/theme/types';
3
+ import { DateObj, Week } from '../types';
4
+ interface WeekDaysProps {
5
+ weeks: Week[];
6
+ handleClickDay: (date: DateObj) => void;
7
+ mode?: ThemeModes;
8
+ testId?: string;
9
+ }
10
+ declare const WeekDays: import("react").NamedExoticComponent<WeekDaysProps>;
11
+ export default WeekDays;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { ThemeModes } from '@atlaskit/theme/types';
3
+ interface WeekHeaderProps {
4
+ daysShort: string[];
5
+ mode?: ThemeModes;
6
+ }
7
+ declare const WeekHeader: import("react").NamedExoticComponent<WeekHeaderProps>;
8
+ export default WeekHeader;
@@ -0,0 +1,5 @@
1
+ import type { ArrowKeys } from './types';
2
+ export declare const arrowKeys: Record<string, ArrowKeys>;
3
+ export declare const daysPerWeek = 7;
4
+ export declare const monthsPerYear = 12;
5
+ export declare const blankStringArray: Array<string>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { CalendarRef } from '../../types';
3
+ export default function useCalendarRef(calendarRef: React.Ref<CalendarRef> | undefined, { navigate, }: {
4
+ navigate: CalendarRef['navigate'];
5
+ }): void;
@@ -0,0 +1,37 @@
1
+ export default function useControlledDateState({ day, defaultDay, month, defaultMonth, year, defaultYear, today, selected, defaultSelected, previouslySelected, defaultPreviouslySelected, }: {
2
+ day?: number;
3
+ defaultDay: number;
4
+ month?: number;
5
+ defaultMonth: number;
6
+ year?: number;
7
+ defaultYear: number;
8
+ today?: string;
9
+ selected?: Array<string>;
10
+ defaultSelected: Array<string>;
11
+ previouslySelected?: Array<string>;
12
+ defaultPreviouslySelected: Array<string>;
13
+ }): {
14
+ readonly day: readonly [
15
+ number,
16
+ (newValue: number) => void
17
+ ];
18
+ readonly month: readonly [
19
+ number,
20
+ (newValue: number) => void
21
+ ];
22
+ readonly year: readonly [
23
+ number,
24
+ (newValue: number) => void
25
+ ];
26
+ readonly today: readonly [
27
+ string
28
+ ];
29
+ readonly selected: readonly [
30
+ string[],
31
+ (newValue: string[]) => void
32
+ ];
33
+ readonly previous: readonly [
34
+ string[],
35
+ (newValue: string[]) => void
36
+ ];
37
+ };
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export default function useFocusing({ onBlur, onFocus, }: {
3
+ onBlur: React.FocusEventHandler;
4
+ onFocus: React.FocusEventHandler;
5
+ }): {
6
+ handleContainerBlur: (event: React.FocusEvent) => void;
7
+ handleContainerFocus: (event: React.FocusEvent) => void;
8
+ };
@@ -0,0 +1,15 @@
1
+ import type { WeekDay } from '../../types';
2
+ import type { Week } from '../types';
3
+ export default function useGetWeeks({ day, month, year, today, disabled, disabledDateFilter, minDate: minDateString, maxDate: maxDateString, selected, previouslySelected, weekStartDay, }: {
4
+ day: number;
5
+ month: number;
6
+ year: number;
7
+ today: string;
8
+ disabled?: string[];
9
+ disabledDateFilter?: (date: string) => boolean;
10
+ minDate?: string;
11
+ maxDate?: string;
12
+ selected: string[];
13
+ previouslySelected: string[];
14
+ weekStartDay: WeekDay;
15
+ }): Week[];
@@ -0,0 +1,21 @@
1
+ import type { ChangeEvent } from '../../types';
2
+ import type { ArrowKeys } from '../types';
3
+ export default function useHandleDateChange({ day: [dayValue, setDayValue], month: [monthValue, setMonthValue], year: [yearValue, setYearValue], onChange, }: {
4
+ day: readonly [
5
+ number,
6
+ (newValue: number) => void
7
+ ];
8
+ month: readonly [
9
+ number,
10
+ (newValue: number) => void
11
+ ];
12
+ year: readonly [
13
+ number,
14
+ (newValue: number) => void
15
+ ];
16
+ onChange: (event: ChangeEvent) => void;
17
+ }): {
18
+ navigate: (type: ArrowKeys) => void;
19
+ handleClickNext: () => void;
20
+ handleClickPrev: () => void;
21
+ };
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import type { SelectEvent } from '../../types';
3
+ import type { ArrowKeys, DateObj } from '../types';
4
+ export default function useHandleDateSelect({ day: [dayValue], month: [monthValue], year: [yearValue], selected: [selectedValue, setSelectedValue], previous: [, setPreviouslySelectedValue], onSelect, navigate, }: {
5
+ day: readonly [
6
+ number,
7
+ (newValue: number) => void
8
+ ];
9
+ month: readonly [
10
+ number,
11
+ (newValue: number) => void
12
+ ];
13
+ year: readonly [
14
+ number,
15
+ (newValue: number) => void
16
+ ];
17
+ selected: [
18
+ string[],
19
+ (newValue: string[]) => void
20
+ ];
21
+ previous: [
22
+ unknown,
23
+ (newValue: string[]) => void
24
+ ];
25
+ onSelect: (event: SelectEvent) => void;
26
+ navigate: (type: ArrowKeys) => void;
27
+ }): {
28
+ handleClickDay: ({ year, month, day }: DateObj) => void;
29
+ handleContainerKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
30
+ };
@@ -0,0 +1,8 @@
1
+ import type { WeekDay } from '../../types';
2
+ export default function useLocale({ locale, weekStartDay, }: {
3
+ locale: string;
4
+ weekStartDay: WeekDay;
5
+ }): {
6
+ monthsLong: string[];
7
+ daysShort: string[];
8
+ };
@@ -0,0 +1 @@
1
+ export default function useUniqueId(prefix: string): string;
@@ -0,0 +1,3 @@
1
+ import { CSSObject } from '@emotion/react';
2
+ import { ThemeModes } from '@atlaskit/theme/types';
3
+ export declare const dateCellStyles: (mode?: ThemeModes) => CSSObject;
@@ -0,0 +1,26 @@
1
+ import type { WeekDay } from '../types';
2
+ export type ArrowKeys = 'left' | 'up' | 'right' | 'down';
3
+ export type DateObj = {
4
+ day: number;
5
+ month: number;
6
+ year: number;
7
+ };
8
+ export interface WeekDayState {
9
+ isDisabled: boolean;
10
+ isFocused: boolean;
11
+ isToday: boolean;
12
+ isPreviouslySelected: boolean;
13
+ isSelected: boolean;
14
+ isSiblingMonth: boolean;
15
+ }
16
+ export interface Week {
17
+ id: string;
18
+ values: Array<{
19
+ id: string;
20
+ } & DateObj & WeekDayState>;
21
+ }
22
+ export interface CalendarDate extends DateObj {
23
+ weekDay?: WeekDay;
24
+ siblingMonth?: boolean;
25
+ }
26
+ export type ISODate = string;
@@ -0,0 +1,6 @@
1
+ import type { DateObj } from '../types';
2
+ interface DateToStringOptions {
3
+ fixMonth: boolean;
4
+ }
5
+ export default function dateToString(date: DateObj, options?: DateToStringOptions): string;
6
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Logic taken from https://github.com/WesSouza/calendar-base which is not maintained for quite sometime.
3
+ * This will help us fixing any issue we might get or any new functionality we might want to support.
4
+ * Not changing much code below. Just removed those parts which we don't need.
5
+ */
6
+ import type { WeekDay } from '../../types';
7
+ import type { CalendarDate } from '../types';
8
+ export default function getBaseCalendar(year: number, month: number, { weekStartDay, }?: {
9
+ weekStartDay?: WeekDay;
10
+ }): CalendarDate[];
@@ -0,0 +1 @@
1
+ export default function getDaysInMonth(year: number, month: number): number;
@@ -0,0 +1 @@
1
+ export default function pad(num: number): string;
@@ -0,0 +1,159 @@
1
+ import { CSSProperties } from 'react';
2
+ import { UIAnalyticsEvent, WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
3
+ import { ThemeModes } from '@atlaskit/theme/types';
4
+ import type { ArrowKeys, DateObj, ISODate } from './internal/types';
5
+ export type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
6
+ export type ChangeEvent = {
7
+ iso: ISODate;
8
+ type: 'left' | 'up' | 'right' | 'down' | 'prev' | 'next';
9
+ } & DateObj;
10
+ export type SelectEvent = {
11
+ iso: ISODate;
12
+ } & DateObj;
13
+ export interface CalendarProps extends WithAnalyticsEventsProps {
14
+ /**
15
+ * The number of the day currently focused. Places border around the date. 0 highlights no date.
16
+ */
17
+ day?: number;
18
+ /**
19
+ * Default for `day`.
20
+ */
21
+ defaultDay?: number;
22
+ /**
23
+ * Default for `month`.
24
+ */
25
+ defaultMonth?: number;
26
+ /**
27
+ * Default for `previouslySelected`.
28
+ */
29
+ defaultPreviouslySelected?: Array<string>;
30
+ /**
31
+ * Default for `selected`.
32
+ */
33
+ defaultSelected?: Array<string>;
34
+ /**
35
+ * Default for `year`.
36
+ */
37
+ defaultYear?: number;
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
+ */
42
+ disabled?: Array<string>;
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
+ */
46
+ disabledDateFilter?: (date: string) => boolean;
47
+ /**
48
+ * The latest enabled date
49
+ */
50
+ maxDate?: string;
51
+ /**
52
+ * The earliest enabled date
53
+ */
54
+ minDate?: string;
55
+ /**
56
+ * The number of the month (from 1 to 12) which the calendar should be on.
57
+ */
58
+ month?: number;
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
+ */
66
+ onBlur?: React.FocusEventHandler;
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
+ */
71
+ onChange?: (event: ChangeEvent, analyticsEvent: UIAnalyticsEvent) => void;
72
+ /**
73
+ * Called when the calendar receives focus. This could be from a mouse event on the container by tabbing into it.
74
+ */
75
+ onFocus?: React.FocusEventHandler;
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
+ */
82
+ onSelect?: (event: SelectEvent, analyticsEvent: UIAnalyticsEvent) => void;
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
+ */
87
+ previouslySelected?: Array<string>;
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
+ */
96
+ selected?: Array<string>;
97
+ /**
98
+ * Value of current day, as a string in the format 'YYYY-MM-DD'.
99
+ */
100
+ today?: string;
101
+ /**
102
+ * Year to display the calendar for.
103
+ */
104
+ year?: number;
105
+ /**
106
+ * BCP 47 language tag (e.g. ja-JP) that ensures dates are in the official format for the locale.
107
+ */
108
+ locale?: string;
109
+ /**
110
+ * Additional information to be included in the `context` of analytics events.
111
+ */
112
+ analyticsContext?: Record<string, any>;
113
+ /**
114
+ * Start day of the week for the calendar.
115
+ * - `0` sunday (default value)
116
+ * - `1` monday
117
+ * - `2` tuesday
118
+ * - `3` wednesday
119
+ * - `4` thursday
120
+ * - `5` friday
121
+ * - `6` saturday
122
+ */
123
+ weekStartDay?: WeekDay;
124
+ /**
125
+ * 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
126
+ *
127
+ * testId--container - Outermost container containing everything inside calendar
128
+ * testId--month - Container containing all available days for the month
129
+ * testId--previous-month - Button to show next month
130
+ * testId--next-month - Button to show previous month
131
+ * testId--current-month-year - Text containing the current month and year
132
+ * testId--selected-day - The currently selected day (may be missing if a date isn’t selected)
133
+ */
134
+ testId?: string;
135
+ /**
136
+ * Class name to apply to the calendar
137
+ */
138
+ className?: string;
139
+ /**
140
+ * Style customization to apply to the calendar
141
+ */
142
+ style?: CSSProperties;
143
+ /**
144
+ * @internal An additional ref which exposes Calendar's internal api's. We kept this for
145
+ * backward compatibility. PLEASE DO NOT USE THIS.
146
+ */
147
+ calendarRef?: React.Ref<CalendarRef>;
148
+ /**
149
+ * @internal Legacy theme mode, can be either 'light' or 'dark'
150
+ */
151
+ mode?: ThemeModes;
152
+ /**
153
+ * Tab index indicates if the calendar can be focused by keyboard or only programmatically.
154
+ */
155
+ tabIndex?: number;
156
+ }
157
+ export interface CalendarRef {
158
+ navigate: (type: ArrowKeys) => void;
159
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/calendar",
3
- "version": "13.1.1",
3
+ "version": "13.1.2",
4
4
  "description": "An interactive calendar for date selection experiences.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/ds-lib": "^2.2.0",
38
38
  "@atlaskit/heading": "^1.3.0",
39
39
  "@atlaskit/icon": "^21.12.0",
40
- "@atlaskit/locale": "^2.4.0",
40
+ "@atlaskit/locale": "^2.5.0",
41
41
  "@atlaskit/primitives": "^0.9.0",
42
42
  "@atlaskit/theme": "^12.5.0",
43
43
  "@atlaskit/tokens": "^1.4.0",