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