@react-stately/calendar
Advanced tools
Comparing version 3.0.0-nightly.1415 to 3.0.0-nightly.1417
156
dist/main.js
@@ -1,5 +0,5 @@ | ||
var $8fZ0X$internationalizeddate = require("@internationalized/date"); | ||
var $8fZ0X$reactstatelyutils = require("@react-stately/utils"); | ||
var $8fZ0X$reactariai18n = require("@react-aria/i18n"); | ||
var $8fZ0X$react = require("react"); | ||
var $hEzMm$internationalizeddate = require("@internationalized/date"); | ||
var $hEzMm$reactstatelyutils = require("@react-stately/utils"); | ||
var $hEzMm$reactariai18n = require("@react-aria/i18n"); | ||
var $hEzMm$react = require("react"); | ||
@@ -25,13 +25,13 @@ function $parcel$exportWildcard(dest, source) { | ||
} | ||
var $b6932658840cac06$exports = {}; | ||
var $7a549489c00e7fe0$exports = {}; | ||
var $f61c34523ac023ce$exports = {}; | ||
var $6adad0c8536fc209$exports = {}; | ||
$parcel$export($f61c34523ac023ce$exports, "useCalendarState", () => $f61c34523ac023ce$export$6d095e787d2b5e1f); | ||
$parcel$export($6adad0c8536fc209$exports, "useCalendarState", () => $6adad0c8536fc209$export$6d095e787d2b5e1f); | ||
function $7e122b6ea38c4913$export$eac50920cf2fd59a(date, minValue, maxValue) { | ||
function $4301262d71f567b9$export$eac50920cf2fd59a(date, minValue, maxValue) { | ||
return minValue != null && date.compare(minValue) < 0 || maxValue != null && date.compare(maxValue) > 0; | ||
} | ||
function $7e122b6ea38c4913$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) { | ||
function $4301262d71f567b9$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) { | ||
let halfDuration = { | ||
@@ -43,14 +43,14 @@ }; | ||
} | ||
let aligned = $7e122b6ea38c4913$export$144a00ba6044eb9(date, duration, locale).subtract(halfDuration); | ||
return $7e122b6ea38c4913$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
let aligned = $4301262d71f567b9$export$144a00ba6044eb9(date, duration, locale).subtract(halfDuration); | ||
return $4301262d71f567b9$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $7e122b6ea38c4913$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) { | ||
function $4301262d71f567b9$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) { | ||
// align to the start of the largest unit | ||
let aligned = date; | ||
if (duration.years) aligned = $8fZ0X$internationalizeddate.startOfYear(date); | ||
else if (duration.months) aligned = $8fZ0X$internationalizeddate.startOfMonth(date); | ||
else if (duration.weeks) aligned = $8fZ0X$internationalizeddate.startOfWeek(date, locale); | ||
return $7e122b6ea38c4913$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
if (duration.years) aligned = $hEzMm$internationalizeddate.startOfYear(date); | ||
else if (duration.months) aligned = $hEzMm$internationalizeddate.startOfMonth(date); | ||
else if (duration.weeks) aligned = $hEzMm$internationalizeddate.startOfWeek(date, locale); | ||
return $4301262d71f567b9$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $7e122b6ea38c4913$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) { | ||
function $4301262d71f567b9$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) { | ||
let d = { | ||
@@ -64,13 +64,13 @@ ...duration | ||
else if (duration.years) d.years--; | ||
let aligned = $7e122b6ea38c4913$export$144a00ba6044eb9(date, duration, locale).subtract(d); | ||
return $7e122b6ea38c4913$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
let aligned = $4301262d71f567b9$export$144a00ba6044eb9(date, duration, locale).subtract(d); | ||
return $4301262d71f567b9$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $7e122b6ea38c4913$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) { | ||
if (minValue && date.compare(minValue) >= 0) aligned = $8fZ0X$internationalizeddate.maxDate(aligned, $7e122b6ea38c4913$export$144a00ba6044eb9($8fZ0X$internationalizeddate.toCalendarDate(minValue), duration, locale)); | ||
if (maxValue && date.compare(maxValue) <= 0) aligned = $8fZ0X$internationalizeddate.minDate(aligned, $7e122b6ea38c4913$export$530edbfc915b2b04($8fZ0X$internationalizeddate.toCalendarDate(maxValue), duration, locale)); | ||
function $4301262d71f567b9$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) { | ||
if (minValue && date.compare(minValue) >= 0) aligned = $hEzMm$internationalizeddate.maxDate(aligned, $4301262d71f567b9$export$144a00ba6044eb9($hEzMm$internationalizeddate.toCalendarDate(minValue), duration, locale)); | ||
if (maxValue && date.compare(maxValue) <= 0) aligned = $hEzMm$internationalizeddate.minDate(aligned, $4301262d71f567b9$export$530edbfc915b2b04($hEzMm$internationalizeddate.toCalendarDate(maxValue), duration, locale)); | ||
return aligned; | ||
} | ||
function $7e122b6ea38c4913$export$4f5203c0d889109e(date, minValue, maxValue) { | ||
if (minValue) date = $8fZ0X$internationalizeddate.maxDate(date, $8fZ0X$internationalizeddate.toCalendarDate(minValue)); | ||
if (maxValue) date = $8fZ0X$internationalizeddate.minDate(date, $8fZ0X$internationalizeddate.toCalendarDate(maxValue)); | ||
function $4301262d71f567b9$export$4f5203c0d889109e(date, minValue, maxValue) { | ||
if (minValue) date = $hEzMm$internationalizeddate.maxDate(date, $hEzMm$internationalizeddate.toCalendarDate(minValue)); | ||
if (maxValue) date = $hEzMm$internationalizeddate.minDate(date, $hEzMm$internationalizeddate.toCalendarDate(maxValue)); | ||
return date; | ||
@@ -84,5 +84,5 @@ } | ||
function $f61c34523ac023ce$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $8fZ0X$reactariai18n.useDateFormatter(); | ||
let resolvedOptions = $8fZ0X$react.useMemo(()=>defaultFormatter.resolvedOptions() | ||
function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $hEzMm$reactariai18n.useDateFormatter(); | ||
let resolvedOptions = $hEzMm$react.useMemo(()=>defaultFormatter.resolvedOptions() | ||
, [ | ||
@@ -94,3 +94,3 @@ defaultFormatter | ||
} , minValue: minValue , maxValue: maxValue , selectionAlignment: selectionAlignment } = props; | ||
let calendar = $8fZ0X$react.useMemo(()=>createCalendar(resolvedOptions.calendar) | ||
let calendar = $hEzMm$react.useMemo(()=>createCalendar(resolvedOptions.calendar) | ||
, [ | ||
@@ -100,4 +100,4 @@ createCalendar, | ||
]); | ||
let [value, setControlledValue] = $8fZ0X$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange); | ||
let calendarDateValue = $8fZ0X$react.useMemo(()=>value ? $8fZ0X$internationalizeddate.toCalendar($8fZ0X$internationalizeddate.toCalendarDate(value), calendar) : null | ||
let [value, setControlledValue] = $hEzMm$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange); | ||
let calendarDateValue = $hEzMm$react.useMemo(()=>value ? $hEzMm$internationalizeddate.toCalendar($hEzMm$internationalizeddate.toCalendarDate(value), calendar) : null | ||
, [ | ||
@@ -107,3 +107,3 @@ value, | ||
]); | ||
let timeZone = $8fZ0X$react.useMemo(()=>value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone | ||
let timeZone = $hEzMm$react.useMemo(()=>value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone | ||
, [ | ||
@@ -113,3 +113,3 @@ value, | ||
]); | ||
let defaultDate = $8fZ0X$react.useMemo(()=>calendarDateValue || $7e122b6ea38c4913$export$4f5203c0d889109e($8fZ0X$internationalizeddate.toCalendar($8fZ0X$internationalizeddate.today(timeZone), calendar), minValue, maxValue) | ||
let defaultDate = $hEzMm$react.useMemo(()=>calendarDateValue || $4301262d71f567b9$export$4f5203c0d889109e($hEzMm$internationalizeddate.toCalendar($hEzMm$internationalizeddate.today(timeZone), calendar), minValue, maxValue) | ||
, [ | ||
@@ -122,16 +122,16 @@ calendarDateValue, | ||
]); | ||
let [startDate, setStartDate] = $8fZ0X$react.useState(()=>{ | ||
let [startDate, setStartDate] = $hEzMm$react.useState(()=>{ | ||
switch(selectionAlignment){ | ||
case 'start': | ||
return $7e122b6ea38c4913$export$144a00ba6044eb9(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $4301262d71f567b9$export$144a00ba6044eb9(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
case 'end': | ||
return $7e122b6ea38c4913$export$530edbfc915b2b04(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $4301262d71f567b9$export$530edbfc915b2b04(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
case 'center': | ||
default: | ||
return $7e122b6ea38c4913$export$f4a51ff076cc9a09(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $4301262d71f567b9$export$f4a51ff076cc9a09(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
} | ||
}); | ||
let [focusedDate, setFocusedDate] = $8fZ0X$react.useState(defaultDate); | ||
let [isFocused, setFocused] = $8fZ0X$react.useState(props.autoFocus || false); | ||
let endDate = $8fZ0X$react.useMemo(()=>startDate.add(visibleDuration).subtract({ | ||
let [focusedDate, setFocusedDate] = $hEzMm$react.useState(defaultDate); | ||
let [isFocused, setFocused] = $hEzMm$react.useState(props.autoFocus || false); | ||
let endDate = $hEzMm$react.useMemo(()=>startDate.add(visibleDuration).subtract({ | ||
days: 1 | ||
@@ -144,7 +144,7 @@ }) | ||
// Reset focused date and visible range when calendar changes. | ||
let lastCalendarIdentifier = $8fZ0X$react.useRef(calendar.identifier); | ||
$8fZ0X$react.useEffect(()=>{ | ||
let lastCalendarIdentifier = $hEzMm$react.useRef(calendar.identifier); | ||
$hEzMm$react.useEffect(()=>{ | ||
if (calendar.identifier !== lastCalendarIdentifier.current) { | ||
let newFocusedDate = $8fZ0X$internationalizeddate.toCalendar(focusedDate, calendar); | ||
setStartDate($7e122b6ea38c4913$export$f4a51ff076cc9a09(newFocusedDate, visibleDuration, locale, minValue, maxValue)); | ||
let newFocusedDate = $hEzMm$internationalizeddate.toCalendar(focusedDate, calendar); | ||
setStartDate($4301262d71f567b9$export$f4a51ff076cc9a09(newFocusedDate, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate(newFocusedDate); | ||
@@ -164,6 +164,6 @@ lastCalendarIdentifier.current = calendar.identifier; | ||
// date = constrain(focusedDate, date, visibleDuration, locale, minValue, maxValue); | ||
date = $7e122b6ea38c4913$export$4f5203c0d889109e(date, minValue, maxValue); | ||
date = $4301262d71f567b9$export$4f5203c0d889109e(date, minValue, maxValue); | ||
let next = startDate.add(visibleDuration); | ||
if (date.compare(startDate) < 0) setStartDate($7e122b6ea38c4913$export$530edbfc915b2b04(date, visibleDuration, locale, minValue, maxValue)); | ||
else if (date.compare(next) >= 0) setStartDate($7e122b6ea38c4913$export$144a00ba6044eb9(date, visibleDuration, locale, minValue, maxValue)); | ||
if (date.compare(startDate) < 0) setStartDate($4301262d71f567b9$export$530edbfc915b2b04(date, visibleDuration, locale, minValue, maxValue)); | ||
else if (date.compare(next) >= 0) setStartDate($4301262d71f567b9$export$144a00ba6044eb9(date, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate(date); | ||
@@ -175,3 +175,3 @@ } | ||
// Emit dates in the same calendar as the original value, if any, otherwise gregorian. | ||
newValue = $8fZ0X$internationalizeddate.toCalendar(newValue, value?.calendar || new $8fZ0X$internationalizeddate.GregorianCalendar()); | ||
newValue = $hEzMm$internationalizeddate.toCalendar(newValue, (value === null || value === void 0 ? void 0 : value.calendar) || new $hEzMm$internationalizeddate.GregorianCalendar()); | ||
// Preserve time if the input value had one. | ||
@@ -221,9 +221,9 @@ if (value && 'hour' in value) setControlledValue(value.set(newValue)); | ||
let start = startDate.add(visibleDuration); | ||
setStartDate($7e122b6ea38c4913$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($7e122b6ea38c4913$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue)); | ||
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($4301262d71f567b9$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue)); | ||
}, | ||
focusPreviousPage () { | ||
let start = startDate.subtract(visibleDuration); | ||
setStartDate($7e122b6ea38c4913$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($7e122b6ea38c4913$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue)); | ||
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($4301262d71f567b9$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue)); | ||
}, | ||
@@ -263,15 +263,15 @@ focusPageStart () { | ||
isInvalid (date) { | ||
return $7e122b6ea38c4913$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
return $4301262d71f567b9$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
}, | ||
isSelected (date) { | ||
return calendarDateValue != null && $8fZ0X$internationalizeddate.isSameDay(date, calendarDateValue); | ||
return calendarDateValue != null && $hEzMm$internationalizeddate.isSameDay(date, calendarDateValue); | ||
}, | ||
isCellFocused (date) { | ||
return isFocused && focusedDate && $8fZ0X$internationalizeddate.isSameDay(date, focusedDate); | ||
return isFocused && focusedDate && $hEzMm$internationalizeddate.isSameDay(date, focusedDate); | ||
}, | ||
isCellDisabled (date) { | ||
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || $7e122b6ea38c4913$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || $4301262d71f567b9$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
}, | ||
isPreviousVisibleRangeInvalid () { | ||
return $7e122b6ea38c4913$export$eac50920cf2fd59a(startDate.subtract({ | ||
return $4301262d71f567b9$export$eac50920cf2fd59a(startDate.subtract({ | ||
days: 1 | ||
@@ -281,3 +281,3 @@ }), minValue, maxValue); | ||
isNextVisibleRangeInvalid () { | ||
return $7e122b6ea38c4913$export$eac50920cf2fd59a(endDate.add({ | ||
return $4301262d71f567b9$export$eac50920cf2fd59a(endDate.add({ | ||
days: 1 | ||
@@ -290,5 +290,5 @@ }), minValue, maxValue); | ||
var $794e8b1784854410$exports = {}; | ||
var $e49f7b861e5e8049$exports = {}; | ||
$parcel$export($794e8b1784854410$exports, "useRangeCalendarState", () => $794e8b1784854410$export$9a987164d97ecc90); | ||
$parcel$export($e49f7b861e5e8049$exports, "useRangeCalendarState", () => $e49f7b861e5e8049$export$9a987164d97ecc90); | ||
@@ -299,11 +299,11 @@ | ||
function $794e8b1784854410$export$9a987164d97ecc90(props) { | ||
function $e49f7b861e5e8049$export$9a987164d97ecc90(props) { | ||
let { value: valueProp , defaultValue: defaultValue , onChange: onChange , createCalendar: createCalendar , locale: locale , visibleDuration: visibleDuration = { | ||
months: 1 | ||
} , minValue: minValue , maxValue: maxValue , ...calendarProps } = props; | ||
let [value, setValue] = $8fZ0X$reactstatelyutils.useControlledState(valueProp, defaultValue, onChange); | ||
let [anchorDate, setAnchorDate] = $8fZ0X$react.useState(null); | ||
let [value, setValue] = $hEzMm$reactstatelyutils.useControlledState(valueProp, defaultValue, onChange); | ||
let [anchorDate, setAnchorDate] = $hEzMm$react.useState(null); | ||
let alignment = 'center'; | ||
if (value && value.start && value.end) { | ||
let start = $7e122b6ea38c4913$export$f4a51ff076cc9a09($8fZ0X$internationalizeddate.toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue); | ||
let start = $4301262d71f567b9$export$f4a51ff076cc9a09($hEzMm$internationalizeddate.toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue); | ||
let end = start.add(visibleDuration).subtract({ | ||
@@ -314,3 +314,3 @@ days: 1 | ||
} | ||
let calendar = $f61c34523ac023ce$export$6d095e787d2b5e1f({ | ||
let calendar = $6adad0c8536fc209$export$6d095e787d2b5e1f({ | ||
...calendarProps, | ||
@@ -325,3 +325,3 @@ value: value && value.start, | ||
}); | ||
let highlightedRange = anchorDate ? $794e8b1784854410$var$makeRange(anchorDate, calendar.focusedDate) : value && $794e8b1784854410$var$makeRange(value.start, value.end); | ||
let highlightedRange = anchorDate ? $e49f7b861e5e8049$var$makeRange(anchorDate, calendar.focusedDate) : value && $e49f7b861e5e8049$var$makeRange(value.start, value.end); | ||
let selectDate = (date)=>{ | ||
@@ -331,6 +331,6 @@ if (props.isReadOnly) return; | ||
else { | ||
let range = $794e8b1784854410$var$makeRange(anchorDate, date); | ||
let range = $e49f7b861e5e8049$var$makeRange(anchorDate, date); | ||
setValue({ | ||
start: $794e8b1784854410$var$convertValue(range.start, value?.start), | ||
end: $794e8b1784854410$var$convertValue(range.end, value?.end) | ||
start: $e49f7b861e5e8049$var$convertValue(range.start, value === null || value === void 0 ? void 0 : value.start), | ||
end: $e49f7b861e5e8049$var$convertValue(range.end, value === null || value === void 0 ? void 0 : value.end) | ||
}); | ||
@@ -340,3 +340,3 @@ setAnchorDate(null); | ||
}; | ||
let [isDragging, setDragging] = $8fZ0X$react.useState(false); | ||
let [isDragging, setDragging] = $hEzMm$react.useState(false); | ||
return { | ||
@@ -363,3 +363,3 @@ ...calendar, | ||
} | ||
function $794e8b1784854410$var$makeRange(start, end) { | ||
function $e49f7b861e5e8049$var$makeRange(start, end) { | ||
if (!start || !end) return null; | ||
@@ -371,10 +371,10 @@ if (end.compare(start) < 0) [start, end] = [ | ||
return { | ||
start: $8fZ0X$internationalizeddate.toCalendarDate(start), | ||
end: $8fZ0X$internationalizeddate.toCalendarDate(end) | ||
start: $hEzMm$internationalizeddate.toCalendarDate(start), | ||
end: $hEzMm$internationalizeddate.toCalendarDate(end) | ||
}; | ||
} | ||
function $794e8b1784854410$var$convertValue(newValue, oldValue) { | ||
function $e49f7b861e5e8049$var$convertValue(newValue, oldValue) { | ||
// The display calendar should not have any effect on the emitted value. | ||
// Emit dates in the same calendar as the original value, if any, otherwise gregorian. | ||
newValue = $8fZ0X$internationalizeddate.toCalendar(newValue, oldValue?.calendar || new $8fZ0X$internationalizeddate.GregorianCalendar()); | ||
newValue = $hEzMm$internationalizeddate.toCalendar(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new $hEzMm$internationalizeddate.GregorianCalendar()); | ||
// Preserve time if the input value had one. | ||
@@ -386,7 +386,7 @@ if (oldValue && 'hour' in oldValue) return oldValue.set(newValue); | ||
$parcel$exportWildcard(module.exports, $b6932658840cac06$exports); | ||
$parcel$exportWildcard(module.exports, $f61c34523ac023ce$exports); | ||
$parcel$exportWildcard(module.exports, $794e8b1784854410$exports); | ||
$parcel$exportWildcard(module.exports, $7a549489c00e7fe0$exports); | ||
$parcel$exportWildcard(module.exports, $6adad0c8536fc209$exports); | ||
$parcel$exportWildcard(module.exports, $e49f7b861e5e8049$exports); | ||
//# sourceMappingURL=main.js.map |
@@ -1,5 +0,5 @@ | ||
import {toCalendar as $gtpA2$toCalendar, toCalendarDate as $gtpA2$toCalendarDate, today as $gtpA2$today, GregorianCalendar as $gtpA2$GregorianCalendar, isSameDay as $gtpA2$isSameDay, startOfYear as $gtpA2$startOfYear, startOfMonth as $gtpA2$startOfMonth, startOfWeek as $gtpA2$startOfWeek, maxDate as $gtpA2$maxDate, minDate as $gtpA2$minDate} from "@internationalized/date"; | ||
import {useControlledState as $gtpA2$useControlledState} from "@react-stately/utils"; | ||
import {useDateFormatter as $gtpA2$useDateFormatter} from "@react-aria/i18n"; | ||
import {useMemo as $gtpA2$useMemo, useState as $gtpA2$useState, useRef as $gtpA2$useRef, useEffect as $gtpA2$useEffect} from "react"; | ||
import {toCalendar as $keQhS$toCalendar, toCalendarDate as $keQhS$toCalendarDate, today as $keQhS$today, GregorianCalendar as $keQhS$GregorianCalendar, isSameDay as $keQhS$isSameDay, startOfYear as $keQhS$startOfYear, startOfMonth as $keQhS$startOfMonth, startOfWeek as $keQhS$startOfWeek, maxDate as $keQhS$maxDate, minDate as $keQhS$minDate} from "@internationalized/date"; | ||
import {useControlledState as $keQhS$useControlledState} from "@react-stately/utils"; | ||
import {useDateFormatter as $keQhS$useDateFormatter} from "@react-aria/i18n"; | ||
import {useMemo as $keQhS$useMemo, useState as $keQhS$useState, useRef as $keQhS$useRef, useEffect as $keQhS$useEffect} from "react"; | ||
@@ -9,13 +9,13 @@ function $parcel$export(e, n, v, s) { | ||
} | ||
var $509a3e380a190741$exports = {}; | ||
var $77b8da46fac7b53e$exports = {}; | ||
var $773eaea6455709cc$exports = {}; | ||
var $131cf43a05231e1e$exports = {}; | ||
$parcel$export($773eaea6455709cc$exports, "useCalendarState", () => $773eaea6455709cc$export$6d095e787d2b5e1f); | ||
$parcel$export($131cf43a05231e1e$exports, "useCalendarState", () => $131cf43a05231e1e$export$6d095e787d2b5e1f); | ||
function $e8a61e762628fc7e$export$eac50920cf2fd59a(date, minValue, maxValue) { | ||
function $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue) { | ||
return minValue != null && date.compare(minValue) < 0 || maxValue != null && date.compare(maxValue) > 0; | ||
} | ||
function $e8a61e762628fc7e$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) { | ||
function $f62d864046160412$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) { | ||
let halfDuration = { | ||
@@ -27,14 +27,14 @@ }; | ||
} | ||
let aligned = $e8a61e762628fc7e$export$144a00ba6044eb9(date, duration, locale).subtract(halfDuration); | ||
return $e8a61e762628fc7e$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
let aligned = $f62d864046160412$export$144a00ba6044eb9(date, duration, locale).subtract(halfDuration); | ||
return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $e8a61e762628fc7e$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) { | ||
function $f62d864046160412$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) { | ||
// align to the start of the largest unit | ||
let aligned = date; | ||
if (duration.years) aligned = $gtpA2$startOfYear(date); | ||
else if (duration.months) aligned = $gtpA2$startOfMonth(date); | ||
else if (duration.weeks) aligned = $gtpA2$startOfWeek(date, locale); | ||
return $e8a61e762628fc7e$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
if (duration.years) aligned = $keQhS$startOfYear(date); | ||
else if (duration.months) aligned = $keQhS$startOfMonth(date); | ||
else if (duration.weeks) aligned = $keQhS$startOfWeek(date, locale); | ||
return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $e8a61e762628fc7e$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) { | ||
function $f62d864046160412$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) { | ||
let d = { | ||
@@ -48,13 +48,13 @@ ...duration | ||
else if (duration.years) d.years--; | ||
let aligned = $e8a61e762628fc7e$export$144a00ba6044eb9(date, duration, locale).subtract(d); | ||
return $e8a61e762628fc7e$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
let aligned = $f62d864046160412$export$144a00ba6044eb9(date, duration, locale).subtract(d); | ||
return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue); | ||
} | ||
function $e8a61e762628fc7e$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) { | ||
if (minValue && date.compare(minValue) >= 0) aligned = $gtpA2$maxDate(aligned, $e8a61e762628fc7e$export$144a00ba6044eb9($gtpA2$toCalendarDate(minValue), duration, locale)); | ||
if (maxValue && date.compare(maxValue) <= 0) aligned = $gtpA2$minDate(aligned, $e8a61e762628fc7e$export$530edbfc915b2b04($gtpA2$toCalendarDate(maxValue), duration, locale)); | ||
function $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) { | ||
if (minValue && date.compare(minValue) >= 0) aligned = $keQhS$maxDate(aligned, $f62d864046160412$export$144a00ba6044eb9($keQhS$toCalendarDate(minValue), duration, locale)); | ||
if (maxValue && date.compare(maxValue) <= 0) aligned = $keQhS$minDate(aligned, $f62d864046160412$export$530edbfc915b2b04($keQhS$toCalendarDate(maxValue), duration, locale)); | ||
return aligned; | ||
} | ||
function $e8a61e762628fc7e$export$4f5203c0d889109e(date, minValue, maxValue) { | ||
if (minValue) date = $gtpA2$maxDate(date, $gtpA2$toCalendarDate(minValue)); | ||
if (maxValue) date = $gtpA2$minDate(date, $gtpA2$toCalendarDate(maxValue)); | ||
function $f62d864046160412$export$4f5203c0d889109e(date, minValue, maxValue) { | ||
if (minValue) date = $keQhS$maxDate(date, $keQhS$toCalendarDate(minValue)); | ||
if (maxValue) date = $keQhS$minDate(date, $keQhS$toCalendarDate(maxValue)); | ||
return date; | ||
@@ -68,5 +68,5 @@ } | ||
function $773eaea6455709cc$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $gtpA2$useDateFormatter(); | ||
let resolvedOptions = $gtpA2$useMemo(()=>defaultFormatter.resolvedOptions() | ||
function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $keQhS$useDateFormatter(); | ||
let resolvedOptions = $keQhS$useMemo(()=>defaultFormatter.resolvedOptions() | ||
, [ | ||
@@ -78,3 +78,3 @@ defaultFormatter | ||
} , minValue: minValue , maxValue: maxValue , selectionAlignment: selectionAlignment } = props; | ||
let calendar = $gtpA2$useMemo(()=>createCalendar(resolvedOptions.calendar) | ||
let calendar = $keQhS$useMemo(()=>createCalendar(resolvedOptions.calendar) | ||
, [ | ||
@@ -84,4 +84,4 @@ createCalendar, | ||
]); | ||
let [value, setControlledValue] = $gtpA2$useControlledState(props.value, props.defaultValue, props.onChange); | ||
let calendarDateValue = $gtpA2$useMemo(()=>value ? $gtpA2$toCalendar($gtpA2$toCalendarDate(value), calendar) : null | ||
let [value, setControlledValue] = $keQhS$useControlledState(props.value, props.defaultValue, props.onChange); | ||
let calendarDateValue = $keQhS$useMemo(()=>value ? $keQhS$toCalendar($keQhS$toCalendarDate(value), calendar) : null | ||
, [ | ||
@@ -91,3 +91,3 @@ value, | ||
]); | ||
let timeZone = $gtpA2$useMemo(()=>value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone | ||
let timeZone = $keQhS$useMemo(()=>value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone | ||
, [ | ||
@@ -97,3 +97,3 @@ value, | ||
]); | ||
let defaultDate = $gtpA2$useMemo(()=>calendarDateValue || $e8a61e762628fc7e$export$4f5203c0d889109e($gtpA2$toCalendar($gtpA2$today(timeZone), calendar), minValue, maxValue) | ||
let defaultDate = $keQhS$useMemo(()=>calendarDateValue || $f62d864046160412$export$4f5203c0d889109e($keQhS$toCalendar($keQhS$today(timeZone), calendar), minValue, maxValue) | ||
, [ | ||
@@ -106,16 +106,16 @@ calendarDateValue, | ||
]); | ||
let [startDate, setStartDate] = $gtpA2$useState(()=>{ | ||
let [startDate, setStartDate] = $keQhS$useState(()=>{ | ||
switch(selectionAlignment){ | ||
case 'start': | ||
return $e8a61e762628fc7e$export$144a00ba6044eb9(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $f62d864046160412$export$144a00ba6044eb9(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
case 'end': | ||
return $e8a61e762628fc7e$export$530edbfc915b2b04(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $f62d864046160412$export$530edbfc915b2b04(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
case 'center': | ||
default: | ||
return $e8a61e762628fc7e$export$f4a51ff076cc9a09(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
return $f62d864046160412$export$f4a51ff076cc9a09(defaultDate, visibleDuration, locale, minValue, maxValue); | ||
} | ||
}); | ||
let [focusedDate, setFocusedDate] = $gtpA2$useState(defaultDate); | ||
let [isFocused, setFocused] = $gtpA2$useState(props.autoFocus || false); | ||
let endDate = $gtpA2$useMemo(()=>startDate.add(visibleDuration).subtract({ | ||
let [focusedDate, setFocusedDate] = $keQhS$useState(defaultDate); | ||
let [isFocused, setFocused] = $keQhS$useState(props.autoFocus || false); | ||
let endDate = $keQhS$useMemo(()=>startDate.add(visibleDuration).subtract({ | ||
days: 1 | ||
@@ -128,7 +128,7 @@ }) | ||
// Reset focused date and visible range when calendar changes. | ||
let lastCalendarIdentifier = $gtpA2$useRef(calendar.identifier); | ||
$gtpA2$useEffect(()=>{ | ||
let lastCalendarIdentifier = $keQhS$useRef(calendar.identifier); | ||
$keQhS$useEffect(()=>{ | ||
if (calendar.identifier !== lastCalendarIdentifier.current) { | ||
let newFocusedDate = $gtpA2$toCalendar(focusedDate, calendar); | ||
setStartDate($e8a61e762628fc7e$export$f4a51ff076cc9a09(newFocusedDate, visibleDuration, locale, minValue, maxValue)); | ||
let newFocusedDate = $keQhS$toCalendar(focusedDate, calendar); | ||
setStartDate($f62d864046160412$export$f4a51ff076cc9a09(newFocusedDate, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate(newFocusedDate); | ||
@@ -148,6 +148,6 @@ lastCalendarIdentifier.current = calendar.identifier; | ||
// date = constrain(focusedDate, date, visibleDuration, locale, minValue, maxValue); | ||
date = $e8a61e762628fc7e$export$4f5203c0d889109e(date, minValue, maxValue); | ||
date = $f62d864046160412$export$4f5203c0d889109e(date, minValue, maxValue); | ||
let next = startDate.add(visibleDuration); | ||
if (date.compare(startDate) < 0) setStartDate($e8a61e762628fc7e$export$530edbfc915b2b04(date, visibleDuration, locale, minValue, maxValue)); | ||
else if (date.compare(next) >= 0) setStartDate($e8a61e762628fc7e$export$144a00ba6044eb9(date, visibleDuration, locale, minValue, maxValue)); | ||
if (date.compare(startDate) < 0) setStartDate($f62d864046160412$export$530edbfc915b2b04(date, visibleDuration, locale, minValue, maxValue)); | ||
else if (date.compare(next) >= 0) setStartDate($f62d864046160412$export$144a00ba6044eb9(date, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate(date); | ||
@@ -159,3 +159,3 @@ } | ||
// Emit dates in the same calendar as the original value, if any, otherwise gregorian. | ||
newValue = $gtpA2$toCalendar(newValue, value?.calendar || new $gtpA2$GregorianCalendar()); | ||
newValue = $keQhS$toCalendar(newValue, (value === null || value === void 0 ? void 0 : value.calendar) || new $keQhS$GregorianCalendar()); | ||
// Preserve time if the input value had one. | ||
@@ -205,9 +205,9 @@ if (value && 'hour' in value) setControlledValue(value.set(newValue)); | ||
let start = startDate.add(visibleDuration); | ||
setStartDate($e8a61e762628fc7e$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($e8a61e762628fc7e$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue)); | ||
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue)); | ||
}, | ||
focusPreviousPage () { | ||
let start = startDate.subtract(visibleDuration); | ||
setStartDate($e8a61e762628fc7e$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($e8a61e762628fc7e$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue)); | ||
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue)); | ||
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue)); | ||
}, | ||
@@ -247,15 +247,15 @@ focusPageStart () { | ||
isInvalid (date) { | ||
return $e8a61e762628fc7e$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
return $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
}, | ||
isSelected (date) { | ||
return calendarDateValue != null && $gtpA2$isSameDay(date, calendarDateValue); | ||
return calendarDateValue != null && $keQhS$isSameDay(date, calendarDateValue); | ||
}, | ||
isCellFocused (date) { | ||
return isFocused && focusedDate && $gtpA2$isSameDay(date, focusedDate); | ||
return isFocused && focusedDate && $keQhS$isSameDay(date, focusedDate); | ||
}, | ||
isCellDisabled (date) { | ||
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || $e8a61e762628fc7e$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue); | ||
}, | ||
isPreviousVisibleRangeInvalid () { | ||
return $e8a61e762628fc7e$export$eac50920cf2fd59a(startDate.subtract({ | ||
return $f62d864046160412$export$eac50920cf2fd59a(startDate.subtract({ | ||
days: 1 | ||
@@ -265,3 +265,3 @@ }), minValue, maxValue); | ||
isNextVisibleRangeInvalid () { | ||
return $e8a61e762628fc7e$export$eac50920cf2fd59a(endDate.add({ | ||
return $f62d864046160412$export$eac50920cf2fd59a(endDate.add({ | ||
days: 1 | ||
@@ -274,5 +274,5 @@ }), minValue, maxValue); | ||
var $47d19290c26a12d7$exports = {}; | ||
var $9a36b6ba2fb1a7c5$exports = {}; | ||
$parcel$export($47d19290c26a12d7$exports, "useRangeCalendarState", () => $47d19290c26a12d7$export$9a987164d97ecc90); | ||
$parcel$export($9a36b6ba2fb1a7c5$exports, "useRangeCalendarState", () => $9a36b6ba2fb1a7c5$export$9a987164d97ecc90); | ||
@@ -283,11 +283,11 @@ | ||
function $47d19290c26a12d7$export$9a987164d97ecc90(props) { | ||
function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) { | ||
let { value: valueProp , defaultValue: defaultValue , onChange: onChange , createCalendar: createCalendar , locale: locale , visibleDuration: visibleDuration = { | ||
months: 1 | ||
} , minValue: minValue , maxValue: maxValue , ...calendarProps } = props; | ||
let [value, setValue] = $gtpA2$useControlledState(valueProp, defaultValue, onChange); | ||
let [anchorDate, setAnchorDate] = $gtpA2$useState(null); | ||
let [value, setValue] = $keQhS$useControlledState(valueProp, defaultValue, onChange); | ||
let [anchorDate, setAnchorDate] = $keQhS$useState(null); | ||
let alignment = 'center'; | ||
if (value && value.start && value.end) { | ||
let start = $e8a61e762628fc7e$export$f4a51ff076cc9a09($gtpA2$toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue); | ||
let start = $f62d864046160412$export$f4a51ff076cc9a09($keQhS$toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue); | ||
let end = start.add(visibleDuration).subtract({ | ||
@@ -298,3 +298,3 @@ days: 1 | ||
} | ||
let calendar = $773eaea6455709cc$export$6d095e787d2b5e1f({ | ||
let calendar = $131cf43a05231e1e$export$6d095e787d2b5e1f({ | ||
...calendarProps, | ||
@@ -309,3 +309,3 @@ value: value && value.start, | ||
}); | ||
let highlightedRange = anchorDate ? $47d19290c26a12d7$var$makeRange(anchorDate, calendar.focusedDate) : value && $47d19290c26a12d7$var$makeRange(value.start, value.end); | ||
let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end); | ||
let selectDate = (date)=>{ | ||
@@ -315,6 +315,6 @@ if (props.isReadOnly) return; | ||
else { | ||
let range = $47d19290c26a12d7$var$makeRange(anchorDate, date); | ||
let range = $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, date); | ||
setValue({ | ||
start: $47d19290c26a12d7$var$convertValue(range.start, value?.start), | ||
end: $47d19290c26a12d7$var$convertValue(range.end, value?.end) | ||
start: $9a36b6ba2fb1a7c5$var$convertValue(range.start, value === null || value === void 0 ? void 0 : value.start), | ||
end: $9a36b6ba2fb1a7c5$var$convertValue(range.end, value === null || value === void 0 ? void 0 : value.end) | ||
}); | ||
@@ -324,3 +324,3 @@ setAnchorDate(null); | ||
}; | ||
let [isDragging, setDragging] = $gtpA2$useState(false); | ||
let [isDragging, setDragging] = $keQhS$useState(false); | ||
return { | ||
@@ -347,3 +347,3 @@ ...calendar, | ||
} | ||
function $47d19290c26a12d7$var$makeRange(start, end) { | ||
function $9a36b6ba2fb1a7c5$var$makeRange(start, end) { | ||
if (!start || !end) return null; | ||
@@ -355,10 +355,10 @@ if (end.compare(start) < 0) [start, end] = [ | ||
return { | ||
start: $gtpA2$toCalendarDate(start), | ||
end: $gtpA2$toCalendarDate(end) | ||
start: $keQhS$toCalendarDate(start), | ||
end: $keQhS$toCalendarDate(end) | ||
}; | ||
} | ||
function $47d19290c26a12d7$var$convertValue(newValue, oldValue) { | ||
function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) { | ||
// The display calendar should not have any effect on the emitted value. | ||
// Emit dates in the same calendar as the original value, if any, otherwise gregorian. | ||
newValue = $gtpA2$toCalendar(newValue, oldValue?.calendar || new $gtpA2$GregorianCalendar()); | ||
newValue = $keQhS$toCalendar(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new $keQhS$GregorianCalendar()); | ||
// Preserve time if the input value had one. | ||
@@ -372,3 +372,3 @@ if (oldValue && 'hour' in oldValue) return oldValue.set(newValue); | ||
export {$773eaea6455709cc$export$6d095e787d2b5e1f as useCalendarState, $47d19290c26a12d7$export$9a987164d97ecc90 as useRangeCalendarState}; | ||
export {$131cf43a05231e1e$export$6d095e787d2b5e1f as useCalendarState, $9a36b6ba2fb1a7c5$export$9a987164d97ecc90 as useRangeCalendarState}; | ||
//# sourceMappingURL=module.js.map |
{ | ||
"name": "@react-stately/calendar", | ||
"version": "3.0.0-nightly.1415+d6ded0736", | ||
"version": "3.0.0-nightly.1417+404d41859", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,8 +21,8 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@internationalized/date": "3.0.0-nightly.3111+d6ded0736", | ||
"@react-aria/i18n": "3.0.0-nightly.1415+d6ded0736", | ||
"@react-stately/utils": "3.0.0-nightly.1415+d6ded0736", | ||
"@react-types/calendar": "3.0.0-nightly.1415+d6ded0736", | ||
"@react-types/datepicker": "3.0.0-nightly.1415+d6ded0736", | ||
"@react-types/shared": "3.0.0-nightly.1415+d6ded0736", | ||
"@internationalized/date": "3.0.0-nightly.3113+404d41859", | ||
"@react-aria/i18n": "3.0.0-nightly.1417+404d41859", | ||
"@react-stately/utils": "3.0.0-nightly.1417+404d41859", | ||
"@react-types/calendar": "3.0.0-nightly.3113+404d41859", | ||
"@react-types/datepicker": "3.0.0-nightly.3113+404d41859", | ||
"@react-types/shared": "3.0.0-nightly.1417+404d41859", | ||
"date-fns": "^1.30.1" | ||
@@ -36,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "d6ded0736edd4c36d0abeb1ae615cacfa90ea8ff" | ||
"gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
128452