@atlaskit/calendar 13.0.2 → 13.0.3
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 +7 -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 +2 -2
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
import { useMemo } from 'react';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// eslint-disable-next-line no-restricted-imports
|
|
10
8
|
import { parseISO } from 'date-fns';
|
|
11
9
|
import { daysPerWeek } from '../constants';
|
|
12
10
|
import dateToString from '../utils/date-to-string';
|
|
13
11
|
import getBaseCalendar from '../utils/get-base-calendar';
|
|
14
|
-
|
|
15
12
|
function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
16
13
|
var month = _ref.month,
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
year = _ref.year,
|
|
15
|
+
weekStartDay = _ref.weekStartDay;
|
|
19
16
|
var shouldDisplaySixthWeek = calendar.length % 6;
|
|
20
17
|
var calendarLastValue = calendar[calendar.length - 1];
|
|
21
18
|
return useMemo(function () {
|
|
@@ -34,21 +31,21 @@ function useGetCalendarWithSixthWeek(calendar, _ref) {
|
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
}, [calendarLastValue, month, shouldDisplaySixthWeek, weekStartDay, year]);
|
|
37
|
-
}
|
|
38
|
-
|
|
34
|
+
}
|
|
39
35
|
|
|
36
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
40
37
|
export default function useGetWeeks(_ref2) {
|
|
41
38
|
var day = _ref2.day,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
month = _ref2.month,
|
|
40
|
+
year = _ref2.year,
|
|
41
|
+
today = _ref2.today,
|
|
42
|
+
disabled = _ref2.disabled,
|
|
43
|
+
disabledDateFilter = _ref2.disabledDateFilter,
|
|
44
|
+
minDateString = _ref2.minDate,
|
|
45
|
+
maxDateString = _ref2.maxDate,
|
|
46
|
+
selected = _ref2.selected,
|
|
47
|
+
previouslySelected = _ref2.previouslySelected,
|
|
48
|
+
weekStartDay = _ref2.weekStartDay;
|
|
52
49
|
var calendar = useMemo(function () {
|
|
53
50
|
return getBaseCalendar(year, month - 1, {
|
|
54
51
|
weekStartDay: weekStartDay
|
|
@@ -59,11 +56,9 @@ export default function useGetWeeks(_ref2) {
|
|
|
59
56
|
year: year,
|
|
60
57
|
weekStartDay: weekStartDay
|
|
61
58
|
});
|
|
62
|
-
|
|
63
59
|
if (calendarWithSixthWeek) {
|
|
64
60
|
calendar.push.apply(calendar, _toConsumableArray(calendarWithSixthWeek));
|
|
65
61
|
}
|
|
66
|
-
|
|
67
62
|
var minDate = minDateString ? parseISO(minDateString) : undefined;
|
|
68
63
|
var maxDate = maxDateString ? parseISO(maxDateString) : undefined;
|
|
69
64
|
var needJsDate = minDateString || maxDateString;
|
|
@@ -75,7 +70,6 @@ export default function useGetWeeks(_ref2) {
|
|
|
75
70
|
});
|
|
76
71
|
var JSDate = needJsDate ? parseISO(dateAsString) : undefined;
|
|
77
72
|
var week;
|
|
78
|
-
|
|
79
73
|
if (date.weekDay === weekStartDay) {
|
|
80
74
|
week = {
|
|
81
75
|
id: dateAsString,
|
|
@@ -84,9 +78,9 @@ export default function useGetWeeks(_ref2) {
|
|
|
84
78
|
weeks.push(week);
|
|
85
79
|
} else {
|
|
86
80
|
week = weeks[weeks.length - 1];
|
|
87
|
-
}
|
|
88
|
-
|
|
81
|
+
}
|
|
89
82
|
|
|
83
|
+
// Define a bunch of `const`s
|
|
90
84
|
var isDisabledByArray = disabled ? disabled.indexOf(dateAsString) > -1 : false;
|
|
91
85
|
var isDisabledByFilter = disabledDateFilter ? disabledDateFilter(dateAsString) : false;
|
|
92
86
|
var isDisabledByMin = minDate && JSDate ? JSDate < minDate : false;
|
|
@@ -1,62 +1,52 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
|
|
4
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
5
|
import { useCallback, useEffect, useRef } from 'react';
|
|
9
6
|
import { daysPerWeek, monthsPerYear } from '../constants';
|
|
10
7
|
import dateToString from '../utils/date-to-string';
|
|
11
8
|
import getDaysInMonth from '../utils/get-days-in-month';
|
|
12
|
-
|
|
13
9
|
var getNextMonth = function getNextMonth(monthValue, yearValue) {
|
|
14
10
|
var month = monthValue;
|
|
15
11
|
var year = yearValue;
|
|
16
|
-
|
|
17
12
|
if (month === monthsPerYear) {
|
|
18
13
|
month = 1;
|
|
19
14
|
year += 1;
|
|
20
15
|
} else {
|
|
21
16
|
month += 1;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
return {
|
|
25
19
|
month: month,
|
|
26
20
|
year: year
|
|
27
21
|
};
|
|
28
22
|
};
|
|
29
|
-
|
|
30
23
|
var getPrevMonth = function getPrevMonth(monthValue, yearValue) {
|
|
31
24
|
var month = monthValue;
|
|
32
25
|
var year = yearValue;
|
|
33
|
-
|
|
34
26
|
if (month === 1) {
|
|
35
27
|
month = monthsPerYear;
|
|
36
28
|
year -= 1;
|
|
37
29
|
} else {
|
|
38
30
|
month -= 1;
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
return {
|
|
42
33
|
month: month,
|
|
43
34
|
year: year
|
|
44
35
|
};
|
|
45
|
-
};
|
|
46
|
-
|
|
36
|
+
};
|
|
47
37
|
|
|
38
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
48
39
|
export default function useHandleDateChange(_ref) {
|
|
49
40
|
var _ref$day = _slicedToArray(_ref.day, 2),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
dayValue = _ref$day[0],
|
|
42
|
+
setDayValue = _ref$day[1],
|
|
43
|
+
_ref$month = _slicedToArray(_ref.month, 2),
|
|
44
|
+
monthValue = _ref$month[0],
|
|
45
|
+
setMonthValue = _ref$month[1],
|
|
46
|
+
_ref$year = _slicedToArray(_ref.year, 2),
|
|
47
|
+
yearValue = _ref$year[0],
|
|
48
|
+
setYearValue = _ref$year[1],
|
|
49
|
+
onChange = _ref.onChange;
|
|
60
50
|
var dateRef = useRef({
|
|
61
51
|
day: dayValue,
|
|
62
52
|
month: monthValue,
|
|
@@ -71,9 +61,9 @@ export default function useHandleDateChange(_ref) {
|
|
|
71
61
|
}, [dayValue, monthValue, yearValue]);
|
|
72
62
|
var triggerOnChange = useCallback(function (_ref2) {
|
|
73
63
|
var year = _ref2.year,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
month = _ref2.month,
|
|
65
|
+
day = _ref2.day,
|
|
66
|
+
type = _ref2.type;
|
|
77
67
|
var iso = dateToString({
|
|
78
68
|
year: year,
|
|
79
69
|
month: month,
|
|
@@ -92,19 +82,16 @@ export default function useHandleDateChange(_ref) {
|
|
|
92
82
|
}, [onChange, setDayValue, setMonthValue, setYearValue]);
|
|
93
83
|
var navigate = useCallback(function (type) {
|
|
94
84
|
var _dateRef$current = dateRef.current,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
day = _dateRef$current.day,
|
|
86
|
+
month = _dateRef$current.month,
|
|
87
|
+
year = _dateRef$current.year;
|
|
99
88
|
if (type === 'down') {
|
|
100
89
|
var next = day + daysPerWeek;
|
|
101
90
|
var daysInMonth = getDaysInMonth(year, month - 1);
|
|
102
|
-
|
|
103
91
|
if (next > daysInMonth) {
|
|
104
92
|
var _getNextMonth = getNextMonth(month, year),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
nextMonth = _getNextMonth.month,
|
|
94
|
+
nextYear = _getNextMonth.year;
|
|
108
95
|
triggerOnChange({
|
|
109
96
|
year: nextYear,
|
|
110
97
|
month: nextMonth,
|
|
@@ -121,12 +108,10 @@ export default function useHandleDateChange(_ref) {
|
|
|
121
108
|
}
|
|
122
109
|
} else if (type === 'left') {
|
|
123
110
|
var prev = day - 1;
|
|
124
|
-
|
|
125
111
|
if (prev < 1) {
|
|
126
112
|
var _getPrevMonth = getPrevMonth(month, year),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
113
|
+
prevMonth = _getPrevMonth.month,
|
|
114
|
+
prevYear = _getPrevMonth.year;
|
|
130
115
|
var prevDay = getDaysInMonth(prevYear, prevMonth - 1);
|
|
131
116
|
triggerOnChange({
|
|
132
117
|
year: prevYear,
|
|
@@ -144,14 +129,11 @@ export default function useHandleDateChange(_ref) {
|
|
|
144
129
|
}
|
|
145
130
|
} else if (type === 'right') {
|
|
146
131
|
var _next = day + 1;
|
|
147
|
-
|
|
148
132
|
var _daysInMonth = getDaysInMonth(year, month - 1);
|
|
149
|
-
|
|
150
133
|
if (_next > _daysInMonth) {
|
|
151
134
|
var _getNextMonth2 = getNextMonth(month, year),
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
_nextMonth = _getNextMonth2.month,
|
|
136
|
+
_nextYear = _getNextMonth2.year;
|
|
155
137
|
triggerOnChange({
|
|
156
138
|
year: _nextYear,
|
|
157
139
|
month: _nextMonth,
|
|
@@ -168,14 +150,11 @@ export default function useHandleDateChange(_ref) {
|
|
|
168
150
|
}
|
|
169
151
|
} else if (type === 'up') {
|
|
170
152
|
var _prev = day - daysPerWeek;
|
|
171
|
-
|
|
172
153
|
if (_prev < 1) {
|
|
173
154
|
var _getPrevMonth2 = getPrevMonth(month, year),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
155
|
+
_prevMonth = _getPrevMonth2.month,
|
|
156
|
+
_prevYear = _getPrevMonth2.year;
|
|
177
157
|
var _prevDay = getDaysInMonth(_prevYear, _prevMonth - 1) + _prev;
|
|
178
|
-
|
|
179
158
|
triggerOnChange({
|
|
180
159
|
year: _prevYear,
|
|
181
160
|
month: _prevMonth,
|
|
@@ -194,10 +173,9 @@ export default function useHandleDateChange(_ref) {
|
|
|
194
173
|
}, [triggerOnChange]);
|
|
195
174
|
var handleClickNext = useCallback(function () {
|
|
196
175
|
var _dateRef$current$getN = _objectSpread(_objectSpread({}, dateRef.current), getNextMonth(dateRef.current.month, dateRef.current.year)),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
176
|
+
day = _dateRef$current$getN.day,
|
|
177
|
+
month = _dateRef$current$getN.month,
|
|
178
|
+
year = _dateRef$current$getN.year;
|
|
201
179
|
triggerOnChange({
|
|
202
180
|
day: day,
|
|
203
181
|
month: month,
|
|
@@ -207,10 +185,9 @@ export default function useHandleDateChange(_ref) {
|
|
|
207
185
|
}, [triggerOnChange]);
|
|
208
186
|
var handleClickPrev = useCallback(function () {
|
|
209
187
|
var _dateRef$current$getP = _objectSpread(_objectSpread({}, dateRef.current), getPrevMonth(dateRef.current.month, dateRef.current.year)),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
188
|
+
day = _dateRef$current$getP.day,
|
|
189
|
+
month = _dateRef$current$getP.month,
|
|
190
|
+
year = _dateRef$current$getP.year;
|
|
214
191
|
triggerOnChange({
|
|
215
192
|
day: day,
|
|
216
193
|
month: month,
|
|
@@ -1,23 +1,23 @@
|
|
|
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';
|
|
5
5
|
|
|
6
|
+
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
6
7
|
export default function useHandleDateSelect(_ref) {
|
|
7
8
|
var _ref$day = _slicedToArray(_ref.day, 1),
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
dayValue = _ref$day[0],
|
|
10
|
+
_ref$month = _slicedToArray(_ref.month, 1),
|
|
11
|
+
monthValue = _ref$month[0],
|
|
12
|
+
_ref$year = _slicedToArray(_ref.year, 1),
|
|
13
|
+
yearValue = _ref$year[0],
|
|
14
|
+
_ref$selected = _slicedToArray(_ref.selected, 2),
|
|
15
|
+
selectedValue = _ref$selected[0],
|
|
16
|
+
setSelectedValue = _ref$selected[1],
|
|
17
|
+
_ref$previous = _slicedToArray(_ref.previous, 2),
|
|
18
|
+
setPreviouslySelectedValue = _ref$previous[1],
|
|
19
|
+
onSelect = _ref.onSelect,
|
|
20
|
+
navigate = _ref.navigate;
|
|
21
21
|
var dateRef = useRef({
|
|
22
22
|
day: dayValue,
|
|
23
23
|
month: monthValue,
|
|
@@ -32,8 +32,8 @@ export default function useHandleDateSelect(_ref) {
|
|
|
32
32
|
}, [dayValue, monthValue, yearValue]);
|
|
33
33
|
var triggerOnSelect = useCallback(function (_ref2) {
|
|
34
34
|
var year = _ref2.year,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
month = _ref2.month,
|
|
36
|
+
day = _ref2.day;
|
|
37
37
|
var iso = dateToString({
|
|
38
38
|
year: year,
|
|
39
39
|
month: month,
|
|
@@ -50,8 +50,8 @@ export default function useHandleDateSelect(_ref) {
|
|
|
50
50
|
}, [onSelect, selectedValue, setPreviouslySelectedValue, setSelectedValue]);
|
|
51
51
|
var handleClickDay = useCallback(function (_ref3) {
|
|
52
52
|
var year = _ref3.year,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
month = _ref3.month,
|
|
54
|
+
day = _ref3.day;
|
|
55
55
|
triggerOnSelect({
|
|
56
56
|
year: year,
|
|
57
57
|
month: month,
|
|
@@ -61,7 +61,6 @@ export default function useHandleDateSelect(_ref) {
|
|
|
61
61
|
var handleContainerKeyDown = useCallback(function (e) {
|
|
62
62
|
var key = e.key;
|
|
63
63
|
var arrowKey = arrowKeys[key];
|
|
64
|
-
|
|
65
64
|
if (key === 'Enter' || key === ' ') {
|
|
66
65
|
e.preventDefault();
|
|
67
66
|
triggerOnSelect(dateRef.current);
|
|
@@ -3,7 +3,7 @@ import { createLocalizationProvider } from '@atlaskit/locale';
|
|
|
3
3
|
// eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
4
4
|
export default function useLocale(_ref) {
|
|
5
5
|
var locale = _ref.locale,
|
|
6
|
-
|
|
6
|
+
weekStartDay = _ref.weekStartDay;
|
|
7
7
|
var l10n = useMemo(function () {
|
|
8
8
|
return createLocalizationProvider(locale);
|
|
9
9
|
}, [locale]);
|
|
@@ -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
|
var seed = useUIDSeed();
|
|
5
6
|
return "".concat(prefix, "-").concat(seed(prefix));
|
|
@@ -3,15 +3,15 @@
|
|
|
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) {
|
|
9
10
|
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
weekStartDay: 0
|
|
12
|
+
},
|
|
13
|
+
_ref$weekStartDay = _ref.weekStartDay,
|
|
14
|
+
weekStartDay = _ref$weekStartDay === void 0 ? 0 : _ref$weekStartDay;
|
|
15
15
|
var date = new Date(Date.UTC(year, month, 1, 0, 0, 0, 0));
|
|
16
16
|
var utcYear = date.getUTCFullYear();
|
|
17
17
|
var utcMonth = date.getUTCMonth();
|
|
@@ -28,34 +28,27 @@ export default function getBaseCalendar(year, month) {
|
|
|
28
28
|
var calculatedMonth;
|
|
29
29
|
var calculatedYear;
|
|
30
30
|
var maxDateCount = lastDate - dateCounter + (lastDay !== 0 ? daysPerWeek - lastDay : 0) + firstDate;
|
|
31
|
-
|
|
32
31
|
while (dateCounter < maxDateCount) {
|
|
33
32
|
currentDate = dateCounter + 1;
|
|
34
33
|
currentDay = ((dateCounter < 1 ? daysPerWeek + dateCounter : dateCounter) + firstDay) % daysPerWeek;
|
|
35
|
-
|
|
36
34
|
if (currentDate < 1 || currentDate > lastDate) {
|
|
37
35
|
if (currentDate < 1) {
|
|
38
36
|
calculatedMonth = utcMonth - 1;
|
|
39
37
|
calculatedYear = utcYear;
|
|
40
|
-
|
|
41
38
|
if (calculatedMonth < 0) {
|
|
42
39
|
calculatedMonth = monthsPerYear - 1;
|
|
43
40
|
calculatedYear--;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
currentDate = lastDateOfPreviousMonth + currentDate;
|
|
47
43
|
} else if (currentDate > lastDate) {
|
|
48
44
|
calculatedMonth = utcMonth + 1;
|
|
49
45
|
calculatedYear = utcYear;
|
|
50
|
-
|
|
51
46
|
if (calculatedMonth > monthsPerYear - 1) {
|
|
52
47
|
calculatedMonth = 0;
|
|
53
48
|
calculatedYear++;
|
|
54
49
|
}
|
|
55
|
-
|
|
56
50
|
currentDate = dateCounter - lastDate + 1;
|
|
57
51
|
}
|
|
58
|
-
|
|
59
52
|
if (calculatedMonth !== undefined && calculatedYear !== undefined) {
|
|
60
53
|
currentDateObject = {
|
|
61
54
|
day: currentDate,
|
|
@@ -73,10 +66,8 @@ export default function getBaseCalendar(year, month) {
|
|
|
73
66
|
year: utcYear
|
|
74
67
|
};
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
calendar.push(currentDateObject);
|
|
78
70
|
dateCounter++;
|
|
79
71
|
}
|
|
80
|
-
|
|
81
72
|
return calendar;
|
|
82
73
|
}
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/calendar",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.3",
|
|
4
4
|
"description": "An interactive calendar for date selection experiences.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@atlaskit/icon": "^21.11.0",
|
|
33
33
|
"@atlaskit/locale": "^2.3.0",
|
|
34
34
|
"@atlaskit/theme": "^12.2.0",
|
|
35
|
-
"@atlaskit/tokens": "^0.
|
|
35
|
+
"@atlaskit/tokens": "^1.0.0",
|
|
36
36
|
"@atlaskit/visually-hidden": "^1.1.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"@emotion/react": "^11.7.1",
|