@react-stately/calendar 3.0.4 → 3.1.0
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/dist/import.mjs +522 -0
- package/dist/main.js +125 -93
- package/dist/main.js.map +1 -1
- package/dist/module.js +125 -93
- package/dist/module.js.map +1 -1
- package/package.json +13 -8
package/dist/module.js
CHANGED
|
@@ -2,13 +2,42 @@ import {DateFormatter as $keQhS$DateFormatter, toCalendar as $keQhS$toCalendar,
|
|
|
2
2
|
import {useControlledState as $keQhS$useControlledState} from "@react-stately/utils";
|
|
3
3
|
import {useMemo as $keQhS$useMemo, useState as $keQhS$useState, useRef as $keQhS$useRef} from "react";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/ /*
|
|
16
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
17
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
+
* governing permissions and limitations under the License.
|
|
25
|
+
*/ /*
|
|
26
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
27
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
29
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
+
*
|
|
31
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
32
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
33
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
|
+
* governing permissions and limitations under the License.
|
|
35
|
+
*/
|
|
6
36
|
function $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue) {
|
|
7
37
|
return minValue != null && date.compare(minValue) < 0 || maxValue != null && date.compare(maxValue) > 0;
|
|
8
38
|
}
|
|
9
39
|
function $f62d864046160412$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) {
|
|
10
|
-
let halfDuration = {
|
|
11
|
-
};
|
|
40
|
+
let halfDuration = {};
|
|
12
41
|
for(let key in duration){
|
|
13
42
|
halfDuration[key] = Math.floor(duration[key] / 2);
|
|
14
43
|
if (halfDuration[key] > 0 && duration[key] % 2 === 0) halfDuration[key]--;
|
|
@@ -19,9 +48,9 @@ function $f62d864046160412$export$f4a51ff076cc9a09(date, duration, locale, minVa
|
|
|
19
48
|
function $f62d864046160412$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) {
|
|
20
49
|
// align to the start of the largest unit
|
|
21
50
|
let aligned = date;
|
|
22
|
-
if (duration.years) aligned = $keQhS$startOfYear(date);
|
|
23
|
-
else if (duration.months) aligned = $keQhS$startOfMonth(date);
|
|
24
|
-
else if (duration.weeks) aligned = $keQhS$startOfWeek(date, locale);
|
|
51
|
+
if (duration.years) aligned = (0, $keQhS$startOfYear)(date);
|
|
52
|
+
else if (duration.months) aligned = (0, $keQhS$startOfMonth)(date);
|
|
53
|
+
else if (duration.weeks) aligned = (0, $keQhS$startOfWeek)(date, locale);
|
|
25
54
|
return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue);
|
|
26
55
|
}
|
|
27
56
|
function $f62d864046160412$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) {
|
|
@@ -37,13 +66,13 @@ function $f62d864046160412$export$530edbfc915b2b04(date, duration, locale, minVa
|
|
|
37
66
|
return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue);
|
|
38
67
|
}
|
|
39
68
|
function $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) {
|
|
40
|
-
if (minValue && date.compare(minValue) >= 0) aligned = $keQhS$maxDate(aligned, $f62d864046160412$export$144a00ba6044eb9($keQhS$toCalendarDate(minValue), duration, locale));
|
|
41
|
-
if (maxValue && date.compare(maxValue) <= 0) aligned = $keQhS$minDate(aligned, $f62d864046160412$export$530edbfc915b2b04($keQhS$toCalendarDate(maxValue), duration, locale));
|
|
69
|
+
if (minValue && date.compare(minValue) >= 0) aligned = (0, $keQhS$maxDate)(aligned, $f62d864046160412$export$144a00ba6044eb9((0, $keQhS$toCalendarDate)(minValue), duration, locale));
|
|
70
|
+
if (maxValue && date.compare(maxValue) <= 0) aligned = (0, $keQhS$minDate)(aligned, $f62d864046160412$export$530edbfc915b2b04((0, $keQhS$toCalendarDate)(maxValue), duration, locale));
|
|
42
71
|
return aligned;
|
|
43
72
|
}
|
|
44
73
|
function $f62d864046160412$export$4f5203c0d889109e(date, minValue, maxValue) {
|
|
45
|
-
if (minValue) date = $keQhS$maxDate(date, $keQhS$toCalendarDate(minValue));
|
|
46
|
-
if (maxValue) date = $keQhS$minDate(date, $keQhS$toCalendarDate(maxValue));
|
|
74
|
+
if (minValue) date = (0, $keQhS$maxDate)(date, (0, $keQhS$toCalendarDate)(minValue));
|
|
75
|
+
if (maxValue) date = (0, $keQhS$minDate)(date, (0, $keQhS$toCalendarDate)(maxValue));
|
|
47
76
|
return date;
|
|
48
77
|
}
|
|
49
78
|
function $f62d864046160412$export$a1d3911297b952d7(date, minValue, isDateUnavailable) {
|
|
@@ -59,42 +88,35 @@ function $f62d864046160412$export$a1d3911297b952d7(date, minValue, isDateUnavail
|
|
|
59
88
|
|
|
60
89
|
|
|
61
90
|
function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
62
|
-
let defaultFormatter = $keQhS$useMemo(()=>new $keQhS$DateFormatter(props.locale)
|
|
63
|
-
, [
|
|
91
|
+
let defaultFormatter = (0, $keQhS$useMemo)(()=>new (0, $keQhS$DateFormatter)(props.locale), [
|
|
64
92
|
props.locale
|
|
65
93
|
]);
|
|
66
|
-
let resolvedOptions = $keQhS$useMemo(()=>defaultFormatter.resolvedOptions()
|
|
67
|
-
, [
|
|
94
|
+
let resolvedOptions = (0, $keQhS$useMemo)(()=>defaultFormatter.resolvedOptions(), [
|
|
68
95
|
defaultFormatter
|
|
69
96
|
]);
|
|
70
97
|
let { locale: locale , createCalendar: createCalendar , visibleDuration: visibleDuration = {
|
|
71
98
|
months: 1
|
|
72
99
|
} , minValue: minValue , maxValue: maxValue , selectionAlignment: selectionAlignment , isDateUnavailable: isDateUnavailable } = props;
|
|
73
|
-
let calendar = $keQhS$useMemo(()=>createCalendar(resolvedOptions.calendar)
|
|
74
|
-
, [
|
|
100
|
+
let calendar = (0, $keQhS$useMemo)(()=>createCalendar(resolvedOptions.calendar), [
|
|
75
101
|
createCalendar,
|
|
76
102
|
resolvedOptions.calendar
|
|
77
103
|
]);
|
|
78
|
-
let [value, setControlledValue] = $keQhS$useControlledState(props.value, props.defaultValue, props.onChange);
|
|
79
|
-
let calendarDateValue = $keQhS$useMemo(()=>value ? $keQhS$toCalendar($keQhS$toCalendarDate(value), calendar) : null
|
|
80
|
-
, [
|
|
104
|
+
let [value, setControlledValue] = (0, $keQhS$useControlledState)(props.value, props.defaultValue, props.onChange);
|
|
105
|
+
let calendarDateValue = (0, $keQhS$useMemo)(()=>value ? (0, $keQhS$toCalendar)((0, $keQhS$toCalendarDate)(value), calendar) : null, [
|
|
81
106
|
value,
|
|
82
107
|
calendar
|
|
83
108
|
]);
|
|
84
|
-
let timeZone = $keQhS$useMemo(()=>value &&
|
|
85
|
-
, [
|
|
109
|
+
let timeZone = (0, $keQhS$useMemo)(()=>value && "timeZone" in value ? value.timeZone : resolvedOptions.timeZone, [
|
|
86
110
|
value,
|
|
87
111
|
resolvedOptions.timeZone
|
|
88
112
|
]);
|
|
89
|
-
let focusedCalendarDate = $keQhS$useMemo(()=>props.focusedValue ? $f62d864046160412$export$4f5203c0d889109e($keQhS$toCalendar($keQhS$toCalendarDate(props.focusedValue), calendar), minValue, maxValue) : undefined
|
|
90
|
-
, [
|
|
113
|
+
let focusedCalendarDate = (0, $keQhS$useMemo)(()=>props.focusedValue ? (0, $f62d864046160412$export$4f5203c0d889109e)((0, $keQhS$toCalendar)((0, $keQhS$toCalendarDate)(props.focusedValue), calendar), minValue, maxValue) : undefined, [
|
|
91
114
|
props.focusedValue,
|
|
92
115
|
calendar,
|
|
93
116
|
minValue,
|
|
94
117
|
maxValue
|
|
95
118
|
]);
|
|
96
|
-
let defaultFocusedCalendarDate = $keQhS$useMemo(()
|
|
97
|
-
, [
|
|
119
|
+
let defaultFocusedCalendarDate = (0, $keQhS$useMemo)(()=>(0, $f62d864046160412$export$4f5203c0d889109e)(props.defaultFocusedValue ? (0, $keQhS$toCalendar)((0, $keQhS$toCalendarDate)(props.defaultFocusedValue), calendar) : calendarDateValue || (0, $keQhS$toCalendar)((0, $keQhS$today)(timeZone), calendar), minValue, maxValue), [
|
|
98
120
|
props.defaultFocusedValue,
|
|
99
121
|
calendarDateValue,
|
|
100
122
|
timeZone,
|
|
@@ -102,20 +124,20 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
102
124
|
minValue,
|
|
103
125
|
maxValue
|
|
104
126
|
]);
|
|
105
|
-
let [focusedDate, setFocusedDate] = $keQhS$useControlledState(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);
|
|
106
|
-
let [startDate, setStartDate] = $keQhS$useState(()=>{
|
|
127
|
+
let [focusedDate, setFocusedDate] = (0, $keQhS$useControlledState)(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);
|
|
128
|
+
let [startDate, setStartDate] = (0, $keQhS$useState)(()=>{
|
|
107
129
|
switch(selectionAlignment){
|
|
108
|
-
case
|
|
109
|
-
return $f62d864046160412$export$144a00ba6044eb9(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
110
|
-
case
|
|
111
|
-
return $f62d864046160412$export$530edbfc915b2b04(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
112
|
-
case
|
|
130
|
+
case "start":
|
|
131
|
+
return (0, $f62d864046160412$export$144a00ba6044eb9)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
132
|
+
case "end":
|
|
133
|
+
return (0, $f62d864046160412$export$530edbfc915b2b04)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
134
|
+
case "center":
|
|
113
135
|
default:
|
|
114
|
-
return $f62d864046160412$export$f4a51ff076cc9a09(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
136
|
+
return (0, $f62d864046160412$export$f4a51ff076cc9a09)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
115
137
|
}
|
|
116
138
|
});
|
|
117
|
-
let [isFocused, setFocused] = $keQhS$useState(props.autoFocus || false);
|
|
118
|
-
let endDate = $keQhS$useMemo(()=>{
|
|
139
|
+
let [isFocused, setFocused] = (0, $keQhS$useState)(props.autoFocus || false);
|
|
140
|
+
let endDate = (0, $keQhS$useMemo)(()=>{
|
|
119
141
|
let duration = {
|
|
120
142
|
...visibleDuration
|
|
121
143
|
};
|
|
@@ -127,46 +149,46 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
127
149
|
visibleDuration
|
|
128
150
|
]);
|
|
129
151
|
// Reset focused date and visible range when calendar changes.
|
|
130
|
-
let lastCalendarIdentifier = $keQhS$useRef(calendar.identifier);
|
|
152
|
+
let lastCalendarIdentifier = (0, $keQhS$useRef)(calendar.identifier);
|
|
131
153
|
if (calendar.identifier !== lastCalendarIdentifier.current) {
|
|
132
|
-
let newFocusedDate = $keQhS$toCalendar(focusedDate, calendar);
|
|
133
|
-
setStartDate($f62d864046160412$export$f4a51ff076cc9a09(newFocusedDate, visibleDuration, locale, minValue, maxValue));
|
|
154
|
+
let newFocusedDate = (0, $keQhS$toCalendar)(focusedDate, calendar);
|
|
155
|
+
setStartDate((0, $f62d864046160412$export$f4a51ff076cc9a09)(newFocusedDate, visibleDuration, locale, minValue, maxValue));
|
|
134
156
|
setFocusedDate(newFocusedDate);
|
|
135
157
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
136
158
|
}
|
|
137
|
-
if ($f62d864046160412$export$eac50920cf2fd59a(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
138
|
-
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate, minValue, maxValue));
|
|
139
|
-
else if (focusedDate.compare(startDate) < 0) setStartDate($f62d864046160412$export$530edbfc915b2b04(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
140
|
-
else if (focusedDate.compare(endDate) > 0) setStartDate($f62d864046160412$export$144a00ba6044eb9(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
159
|
+
if ((0, $f62d864046160412$export$eac50920cf2fd59a)(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
160
|
+
setFocusedDate((0, $f62d864046160412$export$4f5203c0d889109e)(focusedDate, minValue, maxValue));
|
|
161
|
+
else if (focusedDate.compare(startDate) < 0) setStartDate((0, $f62d864046160412$export$530edbfc915b2b04)(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
162
|
+
else if (focusedDate.compare(endDate) > 0) setStartDate((0, $f62d864046160412$export$144a00ba6044eb9)(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
141
163
|
// Sets focus to a specific cell date
|
|
142
164
|
function focusCell(date) {
|
|
143
|
-
date = $f62d864046160412$export$4f5203c0d889109e(date, minValue, maxValue);
|
|
165
|
+
date = (0, $f62d864046160412$export$4f5203c0d889109e)(date, minValue, maxValue);
|
|
144
166
|
setFocusedDate(date);
|
|
145
167
|
}
|
|
146
168
|
function setValue(newValue) {
|
|
147
169
|
if (!props.isDisabled && !props.isReadOnly) {
|
|
148
|
-
newValue = $f62d864046160412$export$4f5203c0d889109e(newValue, minValue, maxValue);
|
|
149
|
-
newValue = $f62d864046160412$export$a1d3911297b952d7(newValue, startDate, isDateUnavailable);
|
|
170
|
+
newValue = (0, $f62d864046160412$export$4f5203c0d889109e)(newValue, minValue, maxValue);
|
|
171
|
+
newValue = (0, $f62d864046160412$export$a1d3911297b952d7)(newValue, startDate, isDateUnavailable);
|
|
150
172
|
if (!newValue) return;
|
|
151
173
|
// The display calendar should not have any effect on the emitted value.
|
|
152
174
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
153
|
-
newValue = $keQhS$toCalendar(newValue, (value === null || value === void 0 ? void 0 : value.calendar) || new $keQhS$GregorianCalendar());
|
|
175
|
+
newValue = (0, $keQhS$toCalendar)(newValue, (value === null || value === void 0 ? void 0 : value.calendar) || new (0, $keQhS$GregorianCalendar)());
|
|
154
176
|
// Preserve time if the input value had one.
|
|
155
|
-
if (value &&
|
|
177
|
+
if (value && "hour" in value) setControlledValue(value.set(newValue));
|
|
156
178
|
else setControlledValue(newValue);
|
|
157
179
|
}
|
|
158
180
|
}
|
|
159
|
-
let isUnavailable = $keQhS$useMemo(()=>{
|
|
181
|
+
let isUnavailable = (0, $keQhS$useMemo)(()=>{
|
|
160
182
|
if (!calendarDateValue) return false;
|
|
161
183
|
if (isDateUnavailable && isDateUnavailable(calendarDateValue)) return true;
|
|
162
|
-
return $f62d864046160412$export$eac50920cf2fd59a(calendarDateValue, minValue, maxValue);
|
|
184
|
+
return (0, $f62d864046160412$export$eac50920cf2fd59a)(calendarDateValue, minValue, maxValue);
|
|
163
185
|
}, [
|
|
164
186
|
calendarDateValue,
|
|
165
187
|
isDateUnavailable,
|
|
166
188
|
minValue,
|
|
167
189
|
maxValue
|
|
168
190
|
]);
|
|
169
|
-
let validationState = props.validationState || (isUnavailable ?
|
|
191
|
+
let validationState = props.validationState || (isUnavailable ? "invalid" : null);
|
|
170
192
|
return {
|
|
171
193
|
isDisabled: props.isDisabled,
|
|
172
194
|
isReadOnly: props.isReadOnly,
|
|
@@ -209,23 +231,23 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
209
231
|
},
|
|
210
232
|
focusNextPage () {
|
|
211
233
|
let start = startDate.add(visibleDuration);
|
|
212
|
-
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue));
|
|
213
|
-
setStartDate($f62d864046160412$export$144a00ba6044eb9($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale));
|
|
234
|
+
setFocusedDate((0, $f62d864046160412$export$4f5203c0d889109e)(focusedDate.add(visibleDuration), minValue, maxValue));
|
|
235
|
+
setStartDate((0, $f62d864046160412$export$144a00ba6044eb9)((0, $f62d864046160412$export$5bb865b12696a77d)(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale));
|
|
214
236
|
},
|
|
215
237
|
focusPreviousPage () {
|
|
216
238
|
let start = startDate.subtract(visibleDuration);
|
|
217
|
-
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue));
|
|
218
|
-
setStartDate($f62d864046160412$export$144a00ba6044eb9($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale));
|
|
239
|
+
setFocusedDate((0, $f62d864046160412$export$4f5203c0d889109e)(focusedDate.subtract(visibleDuration), minValue, maxValue));
|
|
240
|
+
setStartDate((0, $f62d864046160412$export$144a00ba6044eb9)((0, $f62d864046160412$export$5bb865b12696a77d)(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale));
|
|
219
241
|
},
|
|
220
242
|
focusSectionStart () {
|
|
221
243
|
if (visibleDuration.days) focusCell(startDate);
|
|
222
|
-
else if (visibleDuration.weeks) focusCell($keQhS$startOfWeek(focusedDate, locale));
|
|
223
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell($keQhS$startOfMonth(focusedDate));
|
|
244
|
+
else if (visibleDuration.weeks) focusCell((0, $keQhS$startOfWeek)(focusedDate, locale));
|
|
245
|
+
else if (visibleDuration.months || visibleDuration.years) focusCell((0, $keQhS$startOfMonth)(focusedDate));
|
|
224
246
|
},
|
|
225
247
|
focusSectionEnd () {
|
|
226
248
|
if (visibleDuration.days) focusCell(endDate);
|
|
227
|
-
else if (visibleDuration.weeks) focusCell($keQhS$endOfWeek(focusedDate, locale));
|
|
228
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell($keQhS$endOfMonth(focusedDate));
|
|
249
|
+
else if (visibleDuration.weeks) focusCell((0, $keQhS$endOfWeek)(focusedDate, locale));
|
|
250
|
+
else if (visibleDuration.months || visibleDuration.years) focusCell((0, $keQhS$endOfMonth)(focusedDate));
|
|
229
251
|
},
|
|
230
252
|
focusNextSection (larger) {
|
|
231
253
|
if (!larger && !visibleDuration.days) {
|
|
@@ -262,13 +284,13 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
262
284
|
isFocused: isFocused,
|
|
263
285
|
setFocused: setFocused,
|
|
264
286
|
isInvalid (date) {
|
|
265
|
-
return $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue);
|
|
287
|
+
return (0, $f62d864046160412$export$eac50920cf2fd59a)(date, minValue, maxValue);
|
|
266
288
|
},
|
|
267
289
|
isSelected (date) {
|
|
268
|
-
return calendarDateValue != null && $keQhS$isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
290
|
+
return calendarDateValue != null && (0, $keQhS$isSameDay)(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
269
291
|
},
|
|
270
292
|
isCellFocused (date) {
|
|
271
|
-
return isFocused && focusedDate && $keQhS$isSameDay(date, focusedDate);
|
|
293
|
+
return isFocused && focusedDate && (0, $keQhS$isSameDay)(date, focusedDate);
|
|
272
294
|
},
|
|
273
295
|
isCellDisabled (date) {
|
|
274
296
|
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);
|
|
@@ -280,7 +302,7 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
280
302
|
let prev = startDate.subtract({
|
|
281
303
|
days: 1
|
|
282
304
|
});
|
|
283
|
-
return $keQhS$isSameDay(prev, startDate) || this.isInvalid(prev, minValue, maxValue);
|
|
305
|
+
return (0, $keQhS$isSameDay)(prev, startDate) || this.isInvalid(prev, minValue, maxValue);
|
|
284
306
|
},
|
|
285
307
|
isNextVisibleRangeInvalid () {
|
|
286
308
|
// Adding may return the same date if we reached the end of time
|
|
@@ -288,7 +310,7 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
288
310
|
let next = endDate.add({
|
|
289
311
|
days: 1
|
|
290
312
|
});
|
|
291
|
-
return $keQhS$isSameDay(next, endDate) || this.isInvalid(next, minValue, maxValue);
|
|
313
|
+
return (0, $keQhS$isSameDay)(next, endDate) || this.isInvalid(next, minValue, maxValue);
|
|
292
314
|
},
|
|
293
315
|
getDatesInWeek (weekIndex, from = startDate) {
|
|
294
316
|
// let date = startOfWeek(from, locale);
|
|
@@ -296,17 +318,17 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
296
318
|
weeks: weekIndex
|
|
297
319
|
});
|
|
298
320
|
let dates = [];
|
|
299
|
-
date = $keQhS$startOfWeek(date, locale);
|
|
321
|
+
date = (0, $keQhS$startOfWeek)(date, locale);
|
|
300
322
|
// startOfWeek will clamp dates within the calendar system's valid range, which may
|
|
301
323
|
// start in the middle of a week. In this case, add null placeholders.
|
|
302
|
-
let dayOfWeek = $keQhS$getDayOfWeek(date, locale);
|
|
324
|
+
let dayOfWeek = (0, $keQhS$getDayOfWeek)(date, locale);
|
|
303
325
|
for(let i = 0; i < dayOfWeek; i++)dates.push(null);
|
|
304
326
|
while(dates.length < 7){
|
|
305
327
|
dates.push(date);
|
|
306
328
|
let nextDate = date.add({
|
|
307
329
|
days: 1
|
|
308
330
|
});
|
|
309
|
-
if ($keQhS$isSameDay(date, nextDate)) break;
|
|
331
|
+
if ((0, $keQhS$isSameDay)(date, nextDate)) break;
|
|
310
332
|
date = nextDate;
|
|
311
333
|
}
|
|
312
334
|
// Add null placeholders if at the end of the calendar system.
|
|
@@ -324,7 +346,17 @@ function $131cf43a05231e1e$var$unitDuration(duration) {
|
|
|
324
346
|
}
|
|
325
347
|
|
|
326
348
|
|
|
327
|
-
|
|
349
|
+
/*
|
|
350
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
351
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
352
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
353
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
354
|
+
*
|
|
355
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
356
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
357
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
358
|
+
* governing permissions and limitations under the License.
|
|
359
|
+
*/
|
|
328
360
|
|
|
329
361
|
|
|
330
362
|
|
|
@@ -333,32 +365,32 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
333
365
|
let { value: valueProp , defaultValue: defaultValue , onChange: onChange , createCalendar: createCalendar , locale: locale , visibleDuration: visibleDuration = {
|
|
334
366
|
months: 1
|
|
335
367
|
} , minValue: minValue , maxValue: maxValue , ...calendarProps } = props;
|
|
336
|
-
let [value, setValue] = $keQhS$useControlledState(valueProp, defaultValue || null, onChange);
|
|
337
|
-
let [anchorDate, setAnchorDateState] = $keQhS$useState(null);
|
|
338
|
-
let alignment =
|
|
368
|
+
let [value, setValue] = (0, $keQhS$useControlledState)(valueProp, defaultValue || null, onChange);
|
|
369
|
+
let [anchorDate, setAnchorDateState] = (0, $keQhS$useState)(null);
|
|
370
|
+
let alignment = "center";
|
|
339
371
|
if (value && value.start && value.end) {
|
|
340
|
-
let start = $f62d864046160412$export$f4a51ff076cc9a09($keQhS$toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);
|
|
372
|
+
let start = (0, $f62d864046160412$export$f4a51ff076cc9a09)((0, $keQhS$toCalendarDate)(value.start), visibleDuration, locale, minValue, maxValue);
|
|
341
373
|
let end = start.add(visibleDuration).subtract({
|
|
342
374
|
days: 1
|
|
343
375
|
});
|
|
344
|
-
if (value.end.compare(end) > 0) alignment =
|
|
376
|
+
if (value.end.compare(end) > 0) alignment = "start";
|
|
345
377
|
}
|
|
346
378
|
// Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.
|
|
347
|
-
let availableRangeRef = $keQhS$useRef(null);
|
|
348
|
-
let [availableRange, setAvailableRange] = $keQhS$useState(null);
|
|
349
|
-
let min = $keQhS$useMemo(()=>{
|
|
350
|
-
return $keQhS$maxDate(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start);
|
|
379
|
+
let availableRangeRef = (0, $keQhS$useRef)(null);
|
|
380
|
+
let [availableRange, setAvailableRange] = (0, $keQhS$useState)(null);
|
|
381
|
+
let min = (0, $keQhS$useMemo)(()=>{
|
|
382
|
+
return (0, $keQhS$maxDate)(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start);
|
|
351
383
|
}, [
|
|
352
384
|
minValue,
|
|
353
385
|
availableRange
|
|
354
386
|
]);
|
|
355
|
-
let max = $keQhS$useMemo(()=>{
|
|
356
|
-
return $keQhS$minDate(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end);
|
|
387
|
+
let max = (0, $keQhS$useMemo)(()=>{
|
|
388
|
+
return (0, $keQhS$minDate)(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end);
|
|
357
389
|
}, [
|
|
358
390
|
maxValue,
|
|
359
391
|
availableRange
|
|
360
392
|
]);
|
|
361
|
-
let calendar = $131cf43a05231e1e$export$6d095e787d2b5e1f({
|
|
393
|
+
let calendar = (0, $131cf43a05231e1e$export$6d095e787d2b5e1f)({
|
|
362
394
|
...calendarProps,
|
|
363
395
|
value: value && value.start,
|
|
364
396
|
createCalendar: createCalendar,
|
|
@@ -381,8 +413,8 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
381
413
|
}
|
|
382
414
|
};
|
|
383
415
|
// If the visible range changes, we need to update the available range.
|
|
384
|
-
let lastVisibleRange = $keQhS$useRef(calendar.visibleRange);
|
|
385
|
-
if (
|
|
416
|
+
let lastVisibleRange = (0, $keQhS$useRef)(calendar.visibleRange);
|
|
417
|
+
if (!(0, $keQhS$isEqualDay)(calendar.visibleRange.start, lastVisibleRange.current.start) || !(0, $keQhS$isEqualDay)(calendar.visibleRange.end, lastVisibleRange.current.end)) {
|
|
386
418
|
updateAvailableRange(anchorDate);
|
|
387
419
|
lastVisibleRange.current = calendar.visibleRange;
|
|
388
420
|
}
|
|
@@ -398,8 +430,8 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
398
430
|
let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end);
|
|
399
431
|
let selectDate = (date)=>{
|
|
400
432
|
if (props.isReadOnly) return;
|
|
401
|
-
date = $f62d864046160412$export$4f5203c0d889109e(date, min, max);
|
|
402
|
-
date = $f62d864046160412$export$a1d3911297b952d7(date, calendar.visibleRange.start, props.isDateUnavailable);
|
|
433
|
+
date = (0, $f62d864046160412$export$4f5203c0d889109e)(date, min, max);
|
|
434
|
+
date = (0, $f62d864046160412$export$a1d3911297b952d7)(date, calendar.visibleRange.start, props.isDateUnavailable);
|
|
403
435
|
if (!date) return;
|
|
404
436
|
if (!anchorDate) setAnchorDate(date);
|
|
405
437
|
else {
|
|
@@ -411,12 +443,12 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
411
443
|
setAnchorDate(null);
|
|
412
444
|
}
|
|
413
445
|
};
|
|
414
|
-
let [isDragging, setDragging] = $keQhS$useState(false);
|
|
446
|
+
let [isDragging, setDragging] = (0, $keQhS$useState)(false);
|
|
415
447
|
let { isDateUnavailable: isDateUnavailable } = props;
|
|
416
|
-
let isInvalidSelection = $keQhS$useMemo(()=>{
|
|
448
|
+
let isInvalidSelection = (0, $keQhS$useMemo)(()=>{
|
|
417
449
|
if (!value || anchorDate) return false;
|
|
418
450
|
if (isDateUnavailable && (isDateUnavailable(value.start) || isDateUnavailable(value.end))) return true;
|
|
419
|
-
return $f62d864046160412$export$eac50920cf2fd59a(value.start, minValue, maxValue) || $f62d864046160412$export$eac50920cf2fd59a(value.end, minValue, maxValue);
|
|
451
|
+
return (0, $f62d864046160412$export$eac50920cf2fd59a)(value.start, minValue, maxValue) || (0, $f62d864046160412$export$eac50920cf2fd59a)(value.end, minValue, maxValue);
|
|
420
452
|
}, [
|
|
421
453
|
isDateUnavailable,
|
|
422
454
|
value,
|
|
@@ -424,7 +456,7 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
424
456
|
minValue,
|
|
425
457
|
maxValue
|
|
426
458
|
]);
|
|
427
|
-
let validationState = props.validationState || (isInvalidSelection ?
|
|
459
|
+
let validationState = props.validationState || (isInvalidSelection ? "invalid" : null);
|
|
428
460
|
return {
|
|
429
461
|
...calendar,
|
|
430
462
|
value: value,
|
|
@@ -444,8 +476,8 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
444
476
|
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);
|
|
445
477
|
},
|
|
446
478
|
isInvalid (date) {
|
|
447
|
-
var
|
|
448
|
-
return calendar.isInvalid(date) || $f62d864046160412$export$eac50920cf2fd59a(date, (
|
|
479
|
+
var _availableRangeRef_current, _availableRangeRef_current1;
|
|
480
|
+
return calendar.isInvalid(date) || (0, $f62d864046160412$export$eac50920cf2fd59a)(date, (_availableRangeRef_current = availableRangeRef.current) === null || _availableRangeRef_current === void 0 ? void 0 : _availableRangeRef_current.start, (_availableRangeRef_current1 = availableRangeRef.current) === null || _availableRangeRef_current1 === void 0 ? void 0 : _availableRangeRef_current1.end);
|
|
449
481
|
},
|
|
450
482
|
isDragging: isDragging,
|
|
451
483
|
setDragging: setDragging
|
|
@@ -458,16 +490,16 @@ function $9a36b6ba2fb1a7c5$var$makeRange(start, end) {
|
|
|
458
490
|
start
|
|
459
491
|
];
|
|
460
492
|
return {
|
|
461
|
-
start: $keQhS$toCalendarDate(start),
|
|
462
|
-
end: $keQhS$toCalendarDate(end)
|
|
493
|
+
start: (0, $keQhS$toCalendarDate)(start),
|
|
494
|
+
end: (0, $keQhS$toCalendarDate)(end)
|
|
463
495
|
};
|
|
464
496
|
}
|
|
465
497
|
function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) {
|
|
466
498
|
// The display calendar should not have any effect on the emitted value.
|
|
467
499
|
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
468
|
-
newValue = $keQhS$toCalendar(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new $keQhS$GregorianCalendar());
|
|
500
|
+
newValue = (0, $keQhS$toCalendar)(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new (0, $keQhS$GregorianCalendar)());
|
|
469
501
|
// Preserve time if the input value had one.
|
|
470
|
-
if (oldValue &&
|
|
502
|
+
if (oldValue && "hour" in oldValue) return oldValue.set(newValue);
|
|
471
503
|
return newValue;
|
|
472
504
|
}
|
|
473
505
|
function $9a36b6ba2fb1a7c5$var$nextUnavailableDate(anchorDate, state, dir) {
|