@atlaskit/calendar 13.0.2 → 13.0.4
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 +13 -0
- package/dist/cjs/calendar.js +103 -138
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/internal/components/date.js +27 -31
- package/dist/cjs/internal/components/header.js +11 -20
- package/dist/cjs/internal/components/week-day-grid.js +4 -6
- package/dist/cjs/internal/components/week-days.js +6 -10
- package/dist/cjs/internal/components/week-header.js +4 -10
- package/dist/cjs/internal/hooks/use-calendar-ref.js +0 -2
- package/dist/cjs/internal/hooks/use-controlled-date-state.js +53 -67
- package/dist/cjs/internal/hooks/use-focusing.js +1 -3
- package/dist/cjs/internal/hooks/use-get-weeks.js +16 -30
- package/dist/cjs/internal/hooks/use-handle-date-change.js +31 -60
- package/dist/cjs/internal/hooks/use-handle-date-select.js +16 -24
- package/dist/cjs/internal/hooks/use-locale.js +1 -4
- package/dist/cjs/internal/hooks/use-unique-id.js +0 -2
- package/dist/cjs/internal/styles/date.js +0 -4
- package/dist/cjs/internal/utils/date-to-string.js +0 -3
- package/dist/cjs/internal/utils/get-base-calendar.js +5 -18
- package/dist/cjs/internal/utils/get-days-in-month.js +0 -1
- package/dist/cjs/internal/utils/pad.js +0 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/calendar.js +4 -4
- package/dist/es2019/internal/components/date.js +4 -3
- package/dist/es2019/internal/components/header.js +2 -1
- package/dist/es2019/internal/components/week-day-grid.js +3 -3
- package/dist/es2019/internal/components/week-days.js +2 -1
- package/dist/es2019/internal/components/week-header.js +3 -2
- 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 +8 -10
- package/dist/es2019/internal/hooks/use-handle-date-change.js +6 -15
- package/dist/es2019/internal/hooks/use-handle-date-select.js +2 -2
- package/dist/es2019/internal/hooks/use-unique-id.js +2 -1
- package/dist/es2019/internal/utils/get-base-calendar.js +1 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/calendar.js +103 -114
- package/dist/esm/internal/components/date.js +26 -25
- package/dist/esm/internal/components/header.js +10 -9
- package/dist/esm/internal/components/week-day-grid.js +4 -4
- package/dist/esm/internal/components/week-days.js +5 -4
- package/dist/esm/internal/components/week-header.js +3 -2
- package/dist/esm/internal/hooks/use-controlled-date-state.js +55 -62
- package/dist/esm/internal/hooks/use-focusing.js +3 -2
- package/dist/esm/internal/hooks/use-get-weeks.js +18 -24
- package/dist/esm/internal/hooks/use-handle-date-change.js +31 -54
- package/dist/esm/internal/hooks/use-handle-date-select.js +18 -19
- package/dist/esm/internal/hooks/use-locale.js +1 -1
- package/dist/esm/internal/hooks/use-unique-id.js +2 -1
- package/dist/esm/internal/utils/get-base-calendar.js +5 -14
- package/dist/esm/version.json +1 -1
- package/package.json +4 -4
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = getBaseCalendar;
|
|
9
|
-
|
|
10
8
|
var _constants = require("../constants");
|
|
11
|
-
|
|
12
9
|
var _getDaysInMonth = _interopRequireDefault(require("./get-days-in-month"));
|
|
13
|
-
|
|
14
10
|
/**
|
|
15
11
|
* Logic taken from https://github.com/WesSouza/calendar-base which is not maintained for quite sometime.
|
|
16
12
|
* This will help us fixing any issue we might get or any new functionality we might want to support.
|
|
17
13
|
* Not changing much code below. Just removed those parts which we don't need.
|
|
18
14
|
*/
|
|
15
|
+
|
|
19
16
|
function getBaseCalendar(year, month) {
|
|
20
17
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
weekStartDay: 0
|
|
19
|
+
},
|
|
20
|
+
_ref$weekStartDay = _ref.weekStartDay,
|
|
21
|
+
weekStartDay = _ref$weekStartDay === void 0 ? 0 : _ref$weekStartDay;
|
|
26
22
|
var date = new Date(Date.UTC(year, month, 1, 0, 0, 0, 0));
|
|
27
23
|
var utcYear = date.getUTCFullYear();
|
|
28
24
|
var utcMonth = date.getUTCMonth();
|
|
@@ -39,34 +35,27 @@ function getBaseCalendar(year, month) {
|
|
|
39
35
|
var calculatedMonth;
|
|
40
36
|
var calculatedYear;
|
|
41
37
|
var maxDateCount = lastDate - dateCounter + (lastDay !== 0 ? _constants.daysPerWeek - lastDay : 0) + firstDate;
|
|
42
|
-
|
|
43
38
|
while (dateCounter < maxDateCount) {
|
|
44
39
|
currentDate = dateCounter + 1;
|
|
45
40
|
currentDay = ((dateCounter < 1 ? _constants.daysPerWeek + dateCounter : dateCounter) + firstDay) % _constants.daysPerWeek;
|
|
46
|
-
|
|
47
41
|
if (currentDate < 1 || currentDate > lastDate) {
|
|
48
42
|
if (currentDate < 1) {
|
|
49
43
|
calculatedMonth = utcMonth - 1;
|
|
50
44
|
calculatedYear = utcYear;
|
|
51
|
-
|
|
52
45
|
if (calculatedMonth < 0) {
|
|
53
46
|
calculatedMonth = _constants.monthsPerYear - 1;
|
|
54
47
|
calculatedYear--;
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
currentDate = lastDateOfPreviousMonth + currentDate;
|
|
58
50
|
} else if (currentDate > lastDate) {
|
|
59
51
|
calculatedMonth = utcMonth + 1;
|
|
60
52
|
calculatedYear = utcYear;
|
|
61
|
-
|
|
62
53
|
if (calculatedMonth > _constants.monthsPerYear - 1) {
|
|
63
54
|
calculatedMonth = 0;
|
|
64
55
|
calculatedYear++;
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
currentDate = dateCounter - lastDate + 1;
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
if (calculatedMonth !== undefined && calculatedYear !== undefined) {
|
|
71
60
|
currentDateObject = {
|
|
72
61
|
day: currentDate,
|
|
@@ -84,10 +73,8 @@ function getBaseCalendar(year, month) {
|
|
|
84
73
|
year: utcYear
|
|
85
74
|
};
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
calendar.push(currentDateObject);
|
|
89
77
|
dateCounter++;
|
|
90
78
|
}
|
|
91
|
-
|
|
92
79
|
return calendar;
|
|
93
80
|
}
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/calendar.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { forwardRef, memo, useMemo } from 'react';
|
|
5
4
|
import { jsx } from '@emotion/react';
|
|
@@ -24,7 +23,7 @@ import useUniqueId from './internal/hooks/use-unique-id';
|
|
|
24
23
|
const analyticsAttributes = {
|
|
25
24
|
componentName: 'calendar',
|
|
26
25
|
packageName: "@atlaskit/calendar",
|
|
27
|
-
packageVersion: "13.0.
|
|
26
|
+
packageVersion: "13.0.4"
|
|
28
27
|
};
|
|
29
28
|
const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
30
29
|
day,
|
|
@@ -170,7 +169,8 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
170
169
|
tabIndex: tabIndex
|
|
171
170
|
}, jsx(Stack, {
|
|
172
171
|
gap: "space.150"
|
|
173
|
-
}, jsx(Header
|
|
172
|
+
}, jsx(Header
|
|
173
|
+
// The month number needs to be translated to index in the month
|
|
174
174
|
// name array e.g. 1 (January) -> 0
|
|
175
175
|
, {
|
|
176
176
|
monthLongTitle: monthsLong[monthValue - 1],
|
|
@@ -194,6 +194,7 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
194
194
|
testId: testId
|
|
195
195
|
})))));
|
|
196
196
|
});
|
|
197
|
+
|
|
197
198
|
/**
|
|
198
199
|
* __Calendar__
|
|
199
200
|
*
|
|
@@ -203,7 +204,6 @@ const CalendarWithMode = /*#__PURE__*/forwardRef(function Calendar({
|
|
|
203
204
|
* - [Code](https://atlassian.design/components/calendar/code)
|
|
204
205
|
* - [Usage](https://atlassian.design/components/calendar/usage)
|
|
205
206
|
*/
|
|
206
|
-
|
|
207
207
|
const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Calendar(props, ref) {
|
|
208
208
|
return jsx(GlobalTheme.Consumer, null, ({
|
|
209
209
|
mode
|
|
@@ -38,7 +38,6 @@ const Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date({
|
|
|
38
38
|
year: yearValue,
|
|
39
39
|
isDisabled: isDisabledValue
|
|
40
40
|
} = dateRef.current;
|
|
41
|
-
|
|
42
41
|
if (!isDisabledValue) {
|
|
43
42
|
onClick({
|
|
44
43
|
day: dayValue,
|
|
@@ -48,7 +47,8 @@ const Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date({
|
|
|
48
47
|
}
|
|
49
48
|
}, [onClick]);
|
|
50
49
|
const dateCellStyles = useMemo(() => css(getDateCellStyles(mode)), [mode]);
|
|
51
|
-
return (
|
|
50
|
+
return (
|
|
51
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
52
52
|
jsx("button", {
|
|
53
53
|
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
54
54
|
css: dateCellStyles,
|
|
@@ -68,6 +68,7 @@ const Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date({
|
|
|
68
68
|
}, day)
|
|
69
69
|
);
|
|
70
70
|
}));
|
|
71
|
-
Date.displayName = 'Date';
|
|
71
|
+
Date.displayName = 'Date';
|
|
72
72
|
|
|
73
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
73
74
|
export default Date;
|
|
@@ -55,6 +55,7 @@ const Header = /*#__PURE__*/memo(function Header({
|
|
|
55
55
|
})
|
|
56
56
|
})));
|
|
57
57
|
});
|
|
58
|
-
Header.displayName = 'Header';
|
|
58
|
+
Header.displayName = 'Header';
|
|
59
59
|
|
|
60
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
60
61
|
export default Header;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import { css, jsx } from '@emotion/react';
|
|
3
4
|
const gridStyles = css({
|
|
4
5
|
display: 'grid',
|
|
5
6
|
gridTemplateColumns: 'repeat(7, minmax(max-content, 1fr))'
|
|
6
7
|
});
|
|
7
|
-
|
|
8
8
|
/**
|
|
9
9
|
* __Week day grid__
|
|
10
10
|
*
|
|
@@ -14,10 +14,10 @@ const gridStyles = css({
|
|
|
14
14
|
const WeekDayGrid = ({
|
|
15
15
|
testId,
|
|
16
16
|
children
|
|
17
|
-
}) =>
|
|
17
|
+
}) =>
|
|
18
|
+
// eslint-disable-next-line @repo/internal/react/use-primitives
|
|
18
19
|
jsx("div", {
|
|
19
20
|
"data-testid": testId,
|
|
20
21
|
css: gridStyles
|
|
21
22
|
}, children);
|
|
22
|
-
|
|
23
23
|
export default WeekDayGrid;
|
|
@@ -27,6 +27,7 @@ const WeekDays = /*#__PURE__*/memo(function WeekDays({
|
|
|
27
27
|
testId: testId
|
|
28
28
|
}, weekDay.day))));
|
|
29
29
|
});
|
|
30
|
-
WeekDays.displayName = 'WeekDays';
|
|
30
|
+
WeekDays.displayName = 'WeekDays';
|
|
31
31
|
|
|
32
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
32
33
|
export default WeekDays;
|
|
@@ -19,8 +19,8 @@ const WeekHeader = /*#__PURE__*/memo(function WeekHeader({
|
|
|
19
19
|
textAlign: 'center',
|
|
20
20
|
lineHeight: '16px',
|
|
21
21
|
color: `var(--ds-text-subtle, ${N200})` // Apply correct fallback to shortDay text
|
|
22
|
-
|
|
23
22
|
},
|
|
23
|
+
|
|
24
24
|
key: shortDay
|
|
25
25
|
}, jsx(Text, {
|
|
26
26
|
fontWeight: "bold",
|
|
@@ -29,6 +29,7 @@ const WeekHeader = /*#__PURE__*/memo(function WeekHeader({
|
|
|
29
29
|
textTransform: "uppercase"
|
|
30
30
|
}, shortDay))));
|
|
31
31
|
});
|
|
32
|
-
WeekHeader.displayName = 'WeekHeader';
|
|
32
|
+
WeekHeader.displayName = 'WeekHeader';
|
|
33
33
|
|
|
34
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
34
35
|
export default WeekHeader;
|
|
@@ -1,7 +1,8 @@
|
|
|
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';
|
|
4
4
|
|
|
5
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
5
6
|
export default function useControlledDateState({
|
|
6
7
|
day,
|
|
7
8
|
defaultDay,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line no-restricted-imports
|
|
3
4
|
import { parseISO } from 'date-fns';
|
|
4
5
|
import { daysPerWeek } from '../constants';
|
|
5
6
|
import dateToString from '../utils/date-to-string';
|
|
6
7
|
import getBaseCalendar from '../utils/get-base-calendar';
|
|
7
|
-
|
|
8
8
|
function useGetCalendarWithSixthWeek(calendar, {
|
|
9
9
|
month,
|
|
10
10
|
year,
|
|
@@ -21,14 +21,15 @@ function useGetCalendarWithSixthWeek(calendar, {
|
|
|
21
21
|
const sliceStart = lastDayIsSibling ? daysPerWeek : 0;
|
|
22
22
|
return getBaseCalendar(year, month, {
|
|
23
23
|
weekStartDay
|
|
24
|
-
}).slice(sliceStart, sliceStart + daysPerWeek).map(date => ({
|
|
24
|
+
}).slice(sliceStart, sliceStart + daysPerWeek).map(date => ({
|
|
25
|
+
...date,
|
|
25
26
|
siblingMonth: true
|
|
26
27
|
}));
|
|
27
28
|
}
|
|
28
29
|
}, [calendarLastValue, month, shouldDisplaySixthWeek, weekStartDay, year]);
|
|
29
|
-
}
|
|
30
|
-
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
32
33
|
export default function useGetWeeks({
|
|
33
34
|
day,
|
|
34
35
|
month,
|
|
@@ -50,11 +51,9 @@ export default function useGetWeeks({
|
|
|
50
51
|
year,
|
|
51
52
|
weekStartDay
|
|
52
53
|
});
|
|
53
|
-
|
|
54
54
|
if (calendarWithSixthWeek) {
|
|
55
55
|
calendar.push(...calendarWithSixthWeek);
|
|
56
56
|
}
|
|
57
|
-
|
|
58
57
|
const minDate = minDateString ? parseISO(minDateString) : undefined;
|
|
59
58
|
const maxDate = maxDateString ? parseISO(maxDateString) : undefined;
|
|
60
59
|
const needJsDate = minDateString || maxDateString;
|
|
@@ -66,7 +65,6 @@ export default function useGetWeeks({
|
|
|
66
65
|
});
|
|
67
66
|
const JSDate = needJsDate ? parseISO(dateAsString) : undefined;
|
|
68
67
|
let week;
|
|
69
|
-
|
|
70
68
|
if (date.weekDay === weekStartDay) {
|
|
71
69
|
week = {
|
|
72
70
|
id: dateAsString,
|
|
@@ -75,9 +73,9 @@ export default function useGetWeeks({
|
|
|
75
73
|
weeks.push(week);
|
|
76
74
|
} else {
|
|
77
75
|
week = weeks[weeks.length - 1];
|
|
78
|
-
}
|
|
79
|
-
|
|
76
|
+
}
|
|
80
77
|
|
|
78
|
+
// Define a bunch of `const`s
|
|
81
79
|
const isDisabledByArray = disabled ? disabled.indexOf(dateAsString) > -1 : false;
|
|
82
80
|
const isDisabledByFilter = disabledDateFilter ? disabledDateFilter(dateAsString) : false;
|
|
83
81
|
const isDisabledByMin = minDate && JSDate ? JSDate < minDate : false;
|
|
@@ -2,42 +2,36 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
2
2
|
import { daysPerWeek, monthsPerYear } from '../constants';
|
|
3
3
|
import dateToString from '../utils/date-to-string';
|
|
4
4
|
import getDaysInMonth from '../utils/get-days-in-month';
|
|
5
|
-
|
|
6
5
|
const getNextMonth = (monthValue, yearValue) => {
|
|
7
6
|
let month = monthValue;
|
|
8
7
|
let year = yearValue;
|
|
9
|
-
|
|
10
8
|
if (month === monthsPerYear) {
|
|
11
9
|
month = 1;
|
|
12
10
|
year += 1;
|
|
13
11
|
} else {
|
|
14
12
|
month += 1;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
return {
|
|
18
15
|
month,
|
|
19
16
|
year
|
|
20
17
|
};
|
|
21
18
|
};
|
|
22
|
-
|
|
23
19
|
const getPrevMonth = (monthValue, yearValue) => {
|
|
24
20
|
let month = monthValue;
|
|
25
21
|
let year = yearValue;
|
|
26
|
-
|
|
27
22
|
if (month === 1) {
|
|
28
23
|
month = monthsPerYear;
|
|
29
24
|
year -= 1;
|
|
30
25
|
} else {
|
|
31
26
|
month -= 1;
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
return {
|
|
35
29
|
month,
|
|
36
30
|
year
|
|
37
31
|
};
|
|
38
|
-
};
|
|
39
|
-
|
|
32
|
+
};
|
|
40
33
|
|
|
34
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
41
35
|
export default function useHandleDateChange({
|
|
42
36
|
day: [dayValue, setDayValue],
|
|
43
37
|
month: [monthValue, setMonthValue],
|
|
@@ -84,11 +78,9 @@ export default function useHandleDateChange({
|
|
|
84
78
|
month,
|
|
85
79
|
year
|
|
86
80
|
} = dateRef.current;
|
|
87
|
-
|
|
88
81
|
if (type === 'down') {
|
|
89
82
|
const next = day + daysPerWeek;
|
|
90
83
|
const daysInMonth = getDaysInMonth(year, month - 1);
|
|
91
|
-
|
|
92
84
|
if (next > daysInMonth) {
|
|
93
85
|
const {
|
|
94
86
|
month: nextMonth,
|
|
@@ -110,7 +102,6 @@ export default function useHandleDateChange({
|
|
|
110
102
|
}
|
|
111
103
|
} else if (type === 'left') {
|
|
112
104
|
const prev = day - 1;
|
|
113
|
-
|
|
114
105
|
if (prev < 1) {
|
|
115
106
|
const {
|
|
116
107
|
month: prevMonth,
|
|
@@ -134,7 +125,6 @@ export default function useHandleDateChange({
|
|
|
134
125
|
} else if (type === 'right') {
|
|
135
126
|
const next = day + 1;
|
|
136
127
|
const daysInMonth = getDaysInMonth(year, month - 1);
|
|
137
|
-
|
|
138
128
|
if (next > daysInMonth) {
|
|
139
129
|
const {
|
|
140
130
|
month: nextMonth,
|
|
@@ -156,7 +146,6 @@ export default function useHandleDateChange({
|
|
|
156
146
|
}
|
|
157
147
|
} else if (type === 'up') {
|
|
158
148
|
const prev = day - daysPerWeek;
|
|
159
|
-
|
|
160
149
|
if (prev < 1) {
|
|
161
150
|
const {
|
|
162
151
|
month: prevMonth,
|
|
@@ -184,7 +173,8 @@ export default function useHandleDateChange({
|
|
|
184
173
|
day,
|
|
185
174
|
month,
|
|
186
175
|
year
|
|
187
|
-
} = {
|
|
176
|
+
} = {
|
|
177
|
+
...dateRef.current,
|
|
188
178
|
...getNextMonth(dateRef.current.month, dateRef.current.year)
|
|
189
179
|
};
|
|
190
180
|
triggerOnChange({
|
|
@@ -199,7 +189,8 @@ export default function useHandleDateChange({
|
|
|
199
189
|
day,
|
|
200
190
|
month,
|
|
201
191
|
year
|
|
202
|
-
} = {
|
|
192
|
+
} = {
|
|
193
|
+
...dateRef.current,
|
|
203
194
|
...getPrevMonth(dateRef.current.month, dateRef.current.year)
|
|
204
195
|
};
|
|
205
196
|
triggerOnChange({
|
|
@@ -1,7 +1,8 @@
|
|
|
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';
|
|
4
4
|
|
|
5
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
5
6
|
export default function useHandleDateSelect({
|
|
6
7
|
day: [dayValue],
|
|
7
8
|
month: [monthValue],
|
|
@@ -58,7 +59,6 @@ export default function useHandleDateSelect({
|
|
|
58
59
|
key
|
|
59
60
|
} = e;
|
|
60
61
|
const arrowKey = arrowKeys[key];
|
|
61
|
-
|
|
62
62
|
if (key === 'Enter' || key === ' ') {
|
|
63
63
|
e.preventDefault();
|
|
64
64
|
triggerOnSelect(dateRef.current);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { useUIDSeed } from 'react-uid';
|
|
1
|
+
import { useUIDSeed } from 'react-uid';
|
|
2
2
|
|
|
3
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
3
4
|
export default function useUniqueId(prefix) {
|
|
4
5
|
const seed = useUIDSeed();
|
|
5
6
|
return `${prefix}-${seed(prefix)}`;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* This will help us fixing any issue we might get or any new functionality we might want to support.
|
|
4
4
|
* Not changing much code below. Just removed those parts which we don't need.
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
import { daysPerWeek, monthsPerYear } from '../constants';
|
|
7
8
|
import getDaysInMonth from './get-days-in-month';
|
|
8
9
|
export default function getBaseCalendar(year, month, {
|
|
@@ -26,34 +27,27 @@ export default function getBaseCalendar(year, month, {
|
|
|
26
27
|
let calculatedMonth;
|
|
27
28
|
let calculatedYear;
|
|
28
29
|
const maxDateCount = lastDate - dateCounter + (lastDay !== 0 ? daysPerWeek - lastDay : 0) + firstDate;
|
|
29
|
-
|
|
30
30
|
while (dateCounter < maxDateCount) {
|
|
31
31
|
currentDate = dateCounter + 1;
|
|
32
32
|
currentDay = ((dateCounter < 1 ? daysPerWeek + dateCounter : dateCounter) + firstDay) % daysPerWeek;
|
|
33
|
-
|
|
34
33
|
if (currentDate < 1 || currentDate > lastDate) {
|
|
35
34
|
if (currentDate < 1) {
|
|
36
35
|
calculatedMonth = utcMonth - 1;
|
|
37
36
|
calculatedYear = utcYear;
|
|
38
|
-
|
|
39
37
|
if (calculatedMonth < 0) {
|
|
40
38
|
calculatedMonth = monthsPerYear - 1;
|
|
41
39
|
calculatedYear--;
|
|
42
40
|
}
|
|
43
|
-
|
|
44
41
|
currentDate = lastDateOfPreviousMonth + currentDate;
|
|
45
42
|
} else if (currentDate > lastDate) {
|
|
46
43
|
calculatedMonth = utcMonth + 1;
|
|
47
44
|
calculatedYear = utcYear;
|
|
48
|
-
|
|
49
45
|
if (calculatedMonth > monthsPerYear - 1) {
|
|
50
46
|
calculatedMonth = 0;
|
|
51
47
|
calculatedYear++;
|
|
52
48
|
}
|
|
53
|
-
|
|
54
49
|
currentDate = dateCounter - lastDate + 1;
|
|
55
50
|
}
|
|
56
|
-
|
|
57
51
|
if (calculatedMonth !== undefined && calculatedYear !== undefined) {
|
|
58
52
|
currentDateObject = {
|
|
59
53
|
day: currentDate,
|
|
@@ -71,10 +65,8 @@ export default function getBaseCalendar(year, month, {
|
|
|
71
65
|
year: utcYear
|
|
72
66
|
};
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
calendar.push(currentDateObject);
|
|
76
69
|
dateCounter++;
|
|
77
70
|
}
|
|
78
|
-
|
|
79
71
|
return calendar;
|
|
80
72
|
}
|
package/dist/es2019/version.json
CHANGED