Socket
Socket
Sign inDemoInstall

@react-aria/calendar

Package Overview
Dependencies
Maintainers
2
Versions
559
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/calendar - npm Package Compare versions

Comparing version 3.0.0-nightly.2843 to 3.0.0-nightly.2846

dist/intlStrings.main.js

789

dist/main.js

@@ -1,41 +0,5 @@

var $1fedb39dedbf7c51$exports = require("./ar-AE.main.js");
var $524ada6153e36bf5$exports = require("./bg-BG.main.js");
var $181053d31fc585a6$exports = require("./cs-CZ.main.js");
var $87f1f2ee75c25d27$exports = require("./da-DK.main.js");
var $3018d278e45fefcf$exports = require("./de-DE.main.js");
var $880b624ba6c377b6$exports = require("./el-GR.main.js");
var $6a7e3934431e9523$exports = require("./en-US.main.js");
var $4c458303ff44205c$exports = require("./es-ES.main.js");
var $4b6ec4ab19a96fff$exports = require("./et-EE.main.js");
var $a5184a366ed55e98$exports = require("./fi-FI.main.js");
var $094c11f0389b0f6c$exports = require("./fr-FR.main.js");
var $5b28c6b8eb99673e$exports = require("./he-IL.main.js");
var $519824243c1aad60$exports = require("./hr-HR.main.js");
var $2fde332abe847288$exports = require("./hu-HU.main.js");
var $b266f7fa452e8e83$exports = require("./it-IT.main.js");
var $3528fd03237947e3$exports = require("./ja-JP.main.js");
var $398f3b7902d2708f$exports = require("./ko-KR.main.js");
var $ebaae1c76687311e$exports = require("./lt-LT.main.js");
var $3ecb31d6694563f6$exports = require("./lv-LV.main.js");
var $26dc2e2c103f178c$exports = require("./nb-NO.main.js");
var $6bfd45b83a7d37dd$exports = require("./nl-NL.main.js");
var $6f70d036cac4bd46$exports = require("./pl-PL.main.js");
var $a227ce57c671783d$exports = require("./pt-BR.main.js");
var $97acad4758696d87$exports = require("./pt-PT.main.js");
var $010069c7d7fbbea3$exports = require("./ro-RO.main.js");
var $0ba9c30c48c8d602$exports = require("./ru-RU.main.js");
var $6873e95bd7af7559$exports = require("./sk-SK.main.js");
var $ce3c7852583668e3$exports = require("./sl-SI.main.js");
var $36cbdcce92af5213$exports = require("./sr-SP.main.js");
var $ce53fa032c8abdc9$exports = require("./sv-SE.main.js");
var $358703e281d51beb$exports = require("./tr-TR.main.js");
var $16bef71241a84fd2$exports = require("./uk-UA.main.js");
var $c80940728ad8dc0d$exports = require("./zh-CN.main.js");
var $ec192a5a83cfafeb$exports = require("./zh-TW.main.js");
var $jzHdg$reactarialiveannouncer = require("@react-aria/live-announcer");
var $jzHdg$reactariautils = require("@react-aria/utils");
var $jzHdg$reactariai18n = require("@react-aria/i18n");
var $jzHdg$react = require("react");
var $jzHdg$internationalizeddate = require("@internationalized/date");
var $jzHdg$reactariainteractions = require("@react-aria/interactions");
var $20e845123e697a89$exports = require("./useCalendar.main.js");
var $c49ada48cbc48220$exports = require("./useRangeCalendar.main.js");
var $a07388a797d86b95$exports = require("./useCalendarGrid.main.js");
var $4d833327a32c9193$exports = require("./useCalendarCell.main.js");

@@ -47,10 +11,6 @@

function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "useCalendar", () => $20e845123e697a89$export$3ee915f8151bd4f1);
$parcel$export(module.exports, "useRangeCalendar", () => $c49ada48cbc48220$export$87e0539f600c24e5);
$parcel$export(module.exports, "useCalendarGrid", () => $a07388a797d86b95$export$cb95147730a423f5);
$parcel$export(module.exports, "useCalendarCell", () => $4d833327a32c9193$export$136073280381448e);
$parcel$export(module.exports, "useCalendar", () => $20e845123e697a89$exports.useCalendar);
$parcel$export(module.exports, "useRangeCalendar", () => $c49ada48cbc48220$exports.useRangeCalendar);
$parcel$export(module.exports, "useCalendarGrid", () => $a07388a797d86b95$exports.useCalendarGrid);
$parcel$export(module.exports, "useCalendarCell", () => $4d833327a32c9193$exports.useCalendarCell);
/*

@@ -66,36 +26,4 @@ * Copyright 2020 Adobe. All rights reserved.

* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
var $bd6dc95a3c5ee5cd$exports = {};

@@ -105,703 +33,2 @@

$bd6dc95a3c5ee5cd$exports = {
"ar-AE": $1fedb39dedbf7c51$exports,
"bg-BG": $524ada6153e36bf5$exports,
"cs-CZ": $181053d31fc585a6$exports,
"da-DK": $87f1f2ee75c25d27$exports,
"de-DE": $3018d278e45fefcf$exports,
"el-GR": $880b624ba6c377b6$exports,
"en-US": $6a7e3934431e9523$exports,
"es-ES": $4c458303ff44205c$exports,
"et-EE": $4b6ec4ab19a96fff$exports,
"fi-FI": $a5184a366ed55e98$exports,
"fr-FR": $094c11f0389b0f6c$exports,
"he-IL": $5b28c6b8eb99673e$exports,
"hr-HR": $519824243c1aad60$exports,
"hu-HU": $2fde332abe847288$exports,
"it-IT": $b266f7fa452e8e83$exports,
"ja-JP": $3528fd03237947e3$exports,
"ko-KR": $398f3b7902d2708f$exports,
"lt-LT": $ebaae1c76687311e$exports,
"lv-LV": $3ecb31d6694563f6$exports,
"nb-NO": $26dc2e2c103f178c$exports,
"nl-NL": $6bfd45b83a7d37dd$exports,
"pl-PL": $6f70d036cac4bd46$exports,
"pt-BR": $a227ce57c671783d$exports,
"pt-PT": $97acad4758696d87$exports,
"ro-RO": $010069c7d7fbbea3$exports,
"ru-RU": $0ba9c30c48c8d602$exports,
"sk-SK": $6873e95bd7af7559$exports,
"sl-SI": $ce3c7852583668e3$exports,
"sr-SP": $36cbdcce92af5213$exports,
"sv-SE": $ce53fa032c8abdc9$exports,
"tr-TR": $358703e281d51beb$exports,
"uk-UA": $16bef71241a84fd2$exports,
"zh-CN": $c80940728ad8dc0d$exports,
"zh-TW": $ec192a5a83cfafeb$exports
};
const $df1d8e967e73ec8e$export$653eddfc964b0f8a = new WeakMap();
function $df1d8e967e73ec8e$export$134cbb7fb09a9522(date) {
return (date === null || date === void 0 ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : undefined;
}
function $df1d8e967e73ec8e$export$b6df97c887c38e1a(state) {
let stringFormatter = (0, $jzHdg$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), "@react-aria/calendar");
let start, end;
if ("highlightedRange" in state) ({ start: start, end: end } = state.highlightedRange || {});
else start = end = state.value;
let dateFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
weekday: "long",
month: "long",
year: "numeric",
day: "numeric",
era: $df1d8e967e73ec8e$export$134cbb7fb09a9522(start) || $df1d8e967e73ec8e$export$134cbb7fb09a9522(end),
timeZone: state.timeZone
});
let anchorDate = "anchorDate" in state ? state.anchorDate : null;
return (0, $jzHdg$react.useMemo)(()=>{
// No message if currently selecting a range, or there is nothing highlighted.
if (!anchorDate && start && end) {
// Use a single date message if the start and end dates are the same day,
// otherwise include both dates.
if ((0, $jzHdg$internationalizeddate.isSameDay)(start, end)) {
let date = dateFormatter.format(start.toDate(state.timeZone));
return stringFormatter.format("selectedDateDescription", {
date: date
});
} else {
let dateRange = $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);
return stringFormatter.format("selectedRangeDescription", {
dateRange: dateRange
});
}
}
return "";
}, [
start,
end,
anchorDate,
state.timeZone,
stringFormatter,
dateFormatter
]);
}
function $df1d8e967e73ec8e$export$31afe65d91ef6e8(startDate, endDate, timeZone, isAria) {
let stringFormatter = (0, $jzHdg$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), "@react-aria/calendar");
let era = $df1d8e967e73ec8e$export$134cbb7fb09a9522(startDate) || $df1d8e967e73ec8e$export$134cbb7fb09a9522(endDate);
let monthFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
month: "long",
year: "numeric",
era: era,
calendar: startDate.calendar.identifier,
timeZone: timeZone
});
let dateFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
month: "long",
year: "numeric",
day: "numeric",
era: era,
calendar: startDate.calendar.identifier,
timeZone: timeZone
});
return (0, $jzHdg$react.useMemo)(()=>{
// Special case for month granularity. Format as a single month if only a
// single month is visible, otherwise format as a range of months.
if ((0, $jzHdg$internationalizeddate.isSameDay)(startDate, (0, $jzHdg$internationalizeddate.startOfMonth)(startDate))) {
if ((0, $jzHdg$internationalizeddate.isSameDay)(endDate, (0, $jzHdg$internationalizeddate.endOfMonth)(startDate))) return monthFormatter.format(startDate.toDate(timeZone));
else if ((0, $jzHdg$internationalizeddate.isSameDay)(endDate, (0, $jzHdg$internationalizeddate.endOfMonth)(endDate))) return isAria ? $df1d8e967e73ec8e$var$formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone) : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
}
return isAria ? $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone) : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
}, [
startDate,
endDate,
monthFormatter,
dateFormatter,
stringFormatter,
timeZone,
isAria
]);
}
function $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, start, end, timeZone) {
let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));
// Find the separator between the start and end date. This is determined
// by finding the last shared literal before the end range.
let separatorIndex = -1;
for(let i = 0; i < parts.length; i++){
let part = parts[i];
if (part.source === "shared" && part.type === "literal") separatorIndex = i;
else if (part.source === "endRange") break;
}
// Now we can combine the parts into start and end strings.
let startValue = "";
let endValue = "";
for(let i = 0; i < parts.length; i++){
if (i < separatorIndex) startValue += parts[i].value;
else if (i > separatorIndex) endValue += parts[i].value;
}
return stringFormatter.format("dateRange", {
startDate: startValue,
endDate: endValue
});
}
function $02ef492a56b91cb2$export$d652b3ea2d672d5b(props, state) {
let stringFormatter = (0, $jzHdg$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), "@react-aria/calendar");
let domProps = (0, $jzHdg$reactariautils.filterDOMProps)(props);
let title = (0, $df1d8e967e73ec8e$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);
let visibleRangeDescription = (0, $df1d8e967e73ec8e$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);
// Announce when the visible date range changes
(0, $jzHdg$reactariautils.useUpdateEffect)(()=>{
// only when pressing the Previous or Next button
if (!state.isFocused) (0, $jzHdg$reactarialiveannouncer.announce)(visibleRangeDescription);
}, [
visibleRangeDescription
]);
// Announce when the selected value changes
let selectedDateDescription = (0, $df1d8e967e73ec8e$export$b6df97c887c38e1a)(state);
(0, $jzHdg$reactariautils.useUpdateEffect)(()=>{
if (selectedDateDescription) (0, $jzHdg$reactarialiveannouncer.announce)(selectedDateDescription, "polite", 4000);
// handle an update to the caption that describes the currently selected range, to announce the new value
}, [
selectedDateDescription
]);
let errorMessageId = (0, $jzHdg$reactariautils.useSlotId)([
Boolean(props.errorMessage),
props.isInvalid,
props.validationState
]);
// Pass the label to the child grid elements.
(0, $df1d8e967e73ec8e$export$653eddfc964b0f8a).set(state, {
ariaLabel: props["aria-label"],
ariaLabelledBy: props["aria-labelledby"],
errorMessageId: errorMessageId,
selectedDateDescription: selectedDateDescription
});
// If the next or previous buttons become disabled while they are focused, move focus to the calendar body.
let [nextFocused, setNextFocused] = (0, $jzHdg$react.useState)(false);
let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();
if (nextDisabled && nextFocused) {
setNextFocused(false);
state.setFocused(true);
}
let [previousFocused, setPreviousFocused] = (0, $jzHdg$react.useState)(false);
let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();
if (previousDisabled && previousFocused) {
setPreviousFocused(false);
state.setFocused(true);
}
let labelProps = (0, $jzHdg$reactariautils.useLabels)({
id: props["id"],
"aria-label": [
props["aria-label"],
visibleRangeDescription
].filter(Boolean).join(", "),
"aria-labelledby": props["aria-labelledby"]
});
return {
calendarProps: (0, $jzHdg$reactariautils.mergeProps)(domProps, labelProps, {
role: "application",
"aria-describedby": props["aria-describedby"] || undefined
}),
nextButtonProps: {
onPress: ()=>state.focusNextPage(),
"aria-label": stringFormatter.format("next"),
isDisabled: nextDisabled,
onFocusChange: setNextFocused
},
prevButtonProps: {
onPress: ()=>state.focusPreviousPage(),
"aria-label": stringFormatter.format("previous"),
isDisabled: previousDisabled,
onFocusChange: setPreviousFocused
},
errorMessageProps: {
id: errorMessageId
},
title: title
};
}
function $20e845123e697a89$export$3ee915f8151bd4f1(props, state) {
return (0, $02ef492a56b91cb2$export$d652b3ea2d672d5b)(props, state);
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $c49ada48cbc48220$export$87e0539f600c24e5(props, state, ref) {
let res = (0, $02ef492a56b91cb2$export$d652b3ea2d672d5b)(props, state);
// We need to ignore virtual pointer events from VoiceOver due to these bugs.
// https://bugs.webkit.org/show_bug.cgi?id=222627
// https://bugs.webkit.org/show_bug.cgi?id=223202
// usePress also does this and waits for the following click event before firing.
// We need to match that here otherwise this will fire before the press event in
// useCalendarCell, causing range selection to not work properly.
let isVirtualClick = (0, $jzHdg$react.useRef)(false);
let windowRef = (0, $jzHdg$react.useRef)(typeof window !== "undefined" ? window : null);
(0, $jzHdg$reactariautils.useEvent)(windowRef, "pointerdown", (e)=>{
isVirtualClick.current = e.width === 0 && e.height === 0;
});
// Stop range selection when pressing or releasing a pointer outside the calendar body,
// except when pressing the next or previous buttons to switch months.
let endDragging = (e)=>{
if (isVirtualClick.current) {
isVirtualClick.current = false;
return;
}
state.setDragging(false);
if (!state.anchorDate) return;
let target = e.target;
if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
};
(0, $jzHdg$reactariautils.useEvent)(windowRef, "pointerup", endDragging);
// Also stop range selection on blur, e.g. tabbing away from the calendar.
res.calendarProps.onBlur = (e)=>{
if (!ref.current) return;
if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
};
// Prevent touch scrolling while dragging
(0, $jzHdg$reactariautils.useEvent)(ref, "touchmove", (e)=>{
if (state.isDragging) e.preventDefault();
}, {
passive: false,
capture: true
});
return res;
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $a07388a797d86b95$export$cb95147730a423f5(props, state) {
let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
let { direction: direction } = (0, $jzHdg$reactariai18n.useLocale)();
let onKeyDown = (e)=>{
switch(e.key){
case "Enter":
case " ":
e.preventDefault();
state.selectFocusedDate();
break;
case "PageUp":
e.preventDefault();
e.stopPropagation();
state.focusPreviousSection(e.shiftKey);
break;
case "PageDown":
e.preventDefault();
e.stopPropagation();
state.focusNextSection(e.shiftKey);
break;
case "End":
e.preventDefault();
e.stopPropagation();
state.focusSectionEnd();
break;
case "Home":
e.preventDefault();
e.stopPropagation();
state.focusSectionStart();
break;
case "ArrowLeft":
e.preventDefault();
e.stopPropagation();
if (direction === "rtl") state.focusNextDay();
else state.focusPreviousDay();
break;
case "ArrowUp":
e.preventDefault();
e.stopPropagation();
state.focusPreviousRow();
break;
case "ArrowRight":
e.preventDefault();
e.stopPropagation();
if (direction === "rtl") state.focusPreviousDay();
else state.focusNextDay();
break;
case "ArrowDown":
e.preventDefault();
e.stopPropagation();
state.focusNextRow();
break;
case "Escape":
// Cancel the selection.
if ("setAnchorDate" in state) {
e.preventDefault();
state.setAnchorDate(null);
}
break;
}
};
let visibleRangeDescription = (0, $df1d8e967e73ec8e$export$31afe65d91ef6e8)(startDate, endDate, state.timeZone, true);
let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy } = (0, $df1d8e967e73ec8e$export$653eddfc964b0f8a).get(state);
let labelProps = (0, $jzHdg$reactariautils.useLabels)({
"aria-label": [
ariaLabel,
visibleRangeDescription
].filter(Boolean).join(", "),
"aria-labelledby": ariaLabelledBy
});
let dayFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
weekday: props.weekdayStyle || "narrow",
timeZone: state.timeZone
});
let { locale: locale } = (0, $jzHdg$reactariai18n.useLocale)();
let weekDays = (0, $jzHdg$react.useMemo)(()=>{
let weekStart = (0, $jzHdg$internationalizeddate.startOfWeek)((0, $jzHdg$internationalizeddate.today)(state.timeZone), locale);
return [
...new Array(7).keys()
].map((index)=>{
let date = weekStart.add({
days: index
});
let dateDay = date.toDate(state.timeZone);
return dayFormatter.format(dateDay);
});
}, [
locale,
state.timeZone,
dayFormatter
]);
return {
gridProps: (0, $jzHdg$reactariautils.mergeProps)(labelProps, {
role: "grid",
"aria-readonly": state.isReadOnly || null,
"aria-disabled": state.isDisabled || null,
"aria-multiselectable": "highlightedRange" in state || undefined,
onKeyDown: onKeyDown,
onFocus: ()=>state.setFocused(true),
onBlur: ()=>state.setFocused(false)
}),
headerProps: {
// Column headers are hidden to screen readers to make navigating with a touch screen reader easier.
// The day names are already included in the label of each cell, so there's no need to announce them twice.
"aria-hidden": true
},
weekDays: weekDays
};
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $4d833327a32c9193$export$136073280381448e(props, state, ref) {
let { date: date, isDisabled: isDisabled } = props;
let { errorMessageId: errorMessageId, selectedDateDescription: selectedDateDescription } = (0, $df1d8e967e73ec8e$export$653eddfc964b0f8a).get(state);
let stringFormatter = (0, $jzHdg$reactariai18n.useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), "@react-aria/calendar");
let dateFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
weekday: "long",
day: "numeric",
month: "long",
year: "numeric",
era: (0, $df1d8e967e73ec8e$export$134cbb7fb09a9522)(date),
timeZone: state.timeZone
});
let isSelected = state.isSelected(date);
let isFocused = state.isCellFocused(date);
isDisabled = isDisabled || state.isCellDisabled(date);
let isUnavailable = state.isCellUnavailable(date);
let isSelectable = !isDisabled && !isUnavailable;
let isInvalid = state.isValueInvalid && ("highlightedRange" in state ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0 : state.value && (0, $jzHdg$internationalizeddate.isSameDay)(state.value, date));
if (isInvalid) isSelected = true;
// For performance, reuse the same date object as before if the new date prop is the same.
// This allows subsequent useMemo results to be reused.
date = (0, $jzHdg$reactariautils.useDeepMemo)(date, (0, $jzHdg$internationalizeddate.isEqualDay));
let nativeDate = (0, $jzHdg$react.useMemo)(()=>date.toDate(state.timeZone), [
date,
state.timeZone
]);
// aria-label should be localize Day of week, Month, Day and Year without Time.
let isDateToday = (0, $jzHdg$internationalizeddate.isToday)(date, state.timeZone);
let label = (0, $jzHdg$react.useMemo)(()=>{
let label = "";
// If this is a range calendar, add a description of the full selected range
// to the first and last selected date.
if ("highlightedRange" in state && state.value && !state.anchorDate && ((0, $jzHdg$internationalizeddate.isSameDay)(date, state.value.start) || (0, $jzHdg$internationalizeddate.isSameDay)(date, state.value.end))) label = selectedDateDescription + ", ";
label += dateFormatter.format(nativeDate);
if (isDateToday) // If date is today, set appropriate string depending on selected state:
label = stringFormatter.format(isSelected ? "todayDateSelected" : "todayDate", {
date: label
});
else if (isSelected) // If date is selected but not today:
label = stringFormatter.format("dateSelected", {
date: label
});
if (state.minValue && (0, $jzHdg$internationalizeddate.isSameDay)(date, state.minValue)) label += ", " + stringFormatter.format("minimumDate");
else if (state.maxValue && (0, $jzHdg$internationalizeddate.isSameDay)(date, state.maxValue)) label += ", " + stringFormatter.format("maximumDate");
return label;
}, [
dateFormatter,
nativeDate,
stringFormatter,
isSelected,
isDateToday,
date,
state,
selectedDateDescription
]);
// When a cell is focused and this is a range calendar, add a prompt to help
// screenreader users know that they are in a range selection mode.
let rangeSelectionPrompt = "";
if ("anchorDate" in state && isFocused && !state.isReadOnly && isSelectable) {
// If selection has started add "click to finish selecting range"
if (state.anchorDate) rangeSelectionPrompt = stringFormatter.format("finishRangeSelectionPrompt");
else rangeSelectionPrompt = stringFormatter.format("startRangeSelectionPrompt");
}
let descriptionProps = (0, $jzHdg$reactariautils.useDescription)(rangeSelectionPrompt);
let isAnchorPressed = (0, $jzHdg$react.useRef)(false);
let isRangeBoundaryPressed = (0, $jzHdg$react.useRef)(false);
let touchDragTimerRef = (0, $jzHdg$react.useRef)(null);
let { pressProps: pressProps, isPressed: isPressed } = (0, $jzHdg$reactariainteractions.usePress)({
// When dragging to select a range, we don't want dragging over the original anchor
// again to trigger onPressStart. Cancel presses immediately when the pointer exits.
shouldCancelOnPointerExit: "anchorDate" in state && !!state.anchorDate,
preventFocusOnPress: true,
isDisabled: !isSelectable || state.isReadOnly,
onPressStart (e) {
if (state.isReadOnly) {
state.setFocusedDate(date);
return;
}
if ("highlightedRange" in state && !state.anchorDate && (e.pointerType === "mouse" || e.pointerType === "touch")) {
// Allow dragging the start or end date of a range to modify it
// rather than starting a new selection.
// Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges
// are constrained to available dates. The user will need to select a new range in this case.
if (state.highlightedRange && !isInvalid) {
if ((0, $jzHdg$internationalizeddate.isSameDay)(date, state.highlightedRange.start)) {
state.setAnchorDate(state.highlightedRange.end);
state.setFocusedDate(date);
state.setDragging(true);
isRangeBoundaryPressed.current = true;
return;
} else if ((0, $jzHdg$internationalizeddate.isSameDay)(date, state.highlightedRange.end)) {
state.setAnchorDate(state.highlightedRange.start);
state.setFocusedDate(date);
state.setDragging(true);
isRangeBoundaryPressed.current = true;
return;
}
}
let startDragging = ()=>{
state.setDragging(true);
touchDragTimerRef.current = null;
state.selectDate(date);
state.setFocusedDate(date);
isAnchorPressed.current = true;
};
// Start selection on mouse/touch down so users can drag to select a range.
// On touch, delay dragging to determine if the user really meant to scroll.
if (e.pointerType === "touch") touchDragTimerRef.current = setTimeout(startDragging, 200);
else startDragging();
}
},
onPressEnd () {
isRangeBoundaryPressed.current = false;
isAnchorPressed.current = false;
clearTimeout(touchDragTimerRef.current);
touchDragTimerRef.current = null;
},
onPress () {
// For non-range selection, always select on press up.
if (!("anchorDate" in state) && !state.isReadOnly) {
state.selectDate(date);
state.setFocusedDate(date);
}
},
onPressUp (e) {
if (state.isReadOnly) return;
// If the user tapped quickly, the date won't be selected yet and the
// timer will still be in progress. In this case, select the date on touch up.
// Timer is cleared in onPressEnd.
if ("anchorDate" in state && touchDragTimerRef.current) {
state.selectDate(date);
state.setFocusedDate(date);
}
if ("anchorDate" in state) {
if (isRangeBoundaryPressed.current) // When clicking on the start or end date of an already selected range,
// start a new selection on press up to also allow dragging the date to
// change the existing range.
state.setAnchorDate(date);
else if (state.anchorDate && !isAnchorPressed.current) {
// When releasing a drag or pressing the end date of a range, select it.
state.selectDate(date);
state.setFocusedDate(date);
} else if (e.pointerType === "keyboard" && !state.anchorDate) {
// For range selection, auto-advance the focused date by one if using keyboard.
// This gives an indication that you're selecting a range rather than a single date.
// For mouse, this is unnecessary because users will see the indication on hover. For screen readers,
// there will be an announcement to "click to finish selecting range" (above).
state.selectDate(date);
let nextDay = date.add({
days: 1
});
if (state.isInvalid(nextDay)) nextDay = date.subtract({
days: 1
});
if (!state.isInvalid(nextDay)) state.setFocusedDate(nextDay);
} else if (e.pointerType === "virtual") {
// For screen readers, just select the date on click.
state.selectDate(date);
state.setFocusedDate(date);
}
}
}
});
let tabIndex = null;
if (!isDisabled) tabIndex = (0, $jzHdg$internationalizeddate.isSameDay)(date, state.focusedDate) ? 0 : -1;
// Focus the button in the DOM when the state updates.
(0, $jzHdg$react.useEffect)(()=>{
if (isFocused && ref.current) {
(0, $jzHdg$reactariautils.focusWithoutScrolling)(ref.current);
// Scroll into view if navigating with a keyboard, otherwise
// try not to shift the view under the user's mouse/finger.
// If in a overlay, scrollIntoViewport will only cause scrolling
// up to the overlay scroll body to prevent overlay shifting.
// Also only scroll into view if the cell actually got focused.
// There are some cases where the cell might be disabled or inside,
// an inert container and we don't want to scroll then.
if ((0, $jzHdg$reactariainteractions.getInteractionModality)() !== "pointer" && document.activeElement === ref.current) (0, $jzHdg$reactariautils.scrollIntoViewport)(ref.current, {
containingElement: (0, $jzHdg$reactariautils.getScrollParent)(ref.current)
});
}
}, [
isFocused,
ref
]);
let cellDateFormatter = (0, $jzHdg$reactariai18n.useDateFormatter)({
day: "numeric",
timeZone: state.timeZone,
calendar: date.calendar.identifier
});
let formattedDate = (0, $jzHdg$react.useMemo)(()=>cellDateFormatter.formatToParts(nativeDate).find((part)=>part.type === "day").value, [
cellDateFormatter,
nativeDate
]);
return {
cellProps: {
role: "gridcell",
"aria-disabled": !isSelectable || null,
"aria-selected": isSelected || null,
"aria-invalid": isInvalid || null
},
buttonProps: (0, $jzHdg$reactariautils.mergeProps)(pressProps, {
onFocus () {
if (!isDisabled) state.setFocusedDate(date);
},
tabIndex: tabIndex,
role: "button",
"aria-disabled": !isSelectable || null,
"aria-label": label,
"aria-invalid": isInvalid || null,
"aria-describedby": [
isInvalid ? errorMessageId : null,
descriptionProps["aria-describedby"]
].filter(Boolean).join(" ") || undefined,
onPointerEnter (e) {
// Highlight the date on hover or drag over a date when selecting a range.
if ("highlightDate" in state && (e.pointerType !== "touch" || state.isDragging) && isSelectable) state.highlightDate(date);
},
onPointerDown (e) {
// This is necessary on touch devices to allow dragging
// outside the original pressed element.
// (JSDOM does not support this)
if ("releasePointerCapture" in e.target) e.target.releasePointerCapture(e.pointerId);
},
onContextMenu (e) {
// Prevent context menu on long press.
e.preventDefault();
}
}),
isPressed: isPressed,
isFocused: isFocused,
isSelected: isSelected,
isDisabled: isDisabled,
isUnavailable: isUnavailable,
isOutsideVisibleRange: date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,
isInvalid: isInvalid,
formattedDate: formattedDate
};
}
//# sourceMappingURL=main.js.map

@@ -1,46 +0,6 @@

import $39324ace0d945f59$exports from "./ar-AE.module.js";
import $1830a539e98c7baf$exports from "./bg-BG.module.js";
import $f4b92528965aab97$exports from "./cs-CZ.module.js";
import $1cd578ef0547c8f1$exports from "./da-DK.module.js";
import $db55a8973925d619$exports from "./de-DE.module.js";
import $ec6937d58566d443$exports from "./el-GR.module.js";
import $1f5cea0742dc284a$exports from "./en-US.module.js";
import $2ca7ea366384817b$exports from "./es-ES.module.js";
import $97874a7fe9cd091f$exports from "./et-EE.module.js";
import $5d376b7fce1a45b2$exports from "./fi-FI.module.js";
import $3bf722b362aaf54d$exports from "./fr-FR.module.js";
import $38c43f8322316031$exports from "./he-IL.module.js";
import $c90e0f32b44630bf$exports from "./hr-HR.module.js";
import $715875e6e7a338f4$exports from "./hu-HU.module.js";
import $37d77c66e34daccf$exports from "./it-IT.module.js";
import $542f39aee29303c3$exports from "./ja-JP.module.js";
import $22a5f0623ea73e4f$exports from "./ko-KR.module.js";
import $522380d13d62cba0$exports from "./lt-LT.module.js";
import $8a7bc830b2fe6485$exports from "./lv-LV.module.js";
import $9fac9c044470683b$exports from "./nb-NO.module.js";
import $b127d3569efb1449$exports from "./nl-NL.module.js";
import $51404a4090633490$exports from "./pl-PL.module.js";
import $e5e6a3fe3b4527df$exports from "./pt-BR.module.js";
import $c519dcadcbb1ee47$exports from "./pt-PT.module.js";
import $e5aa0186ca7889c6$exports from "./ro-RO.module.js";
import $5b907f5fa3eee652$exports from "./ru-RU.module.js";
import $1b4c51359c99cf79$exports from "./sk-SK.module.js";
import $02e4e6a4608cc6f3$exports from "./sl-SI.module.js";
import $6dd2fbaad93b6878$exports from "./sr-SP.module.js";
import $33ea59bfe6e804e0$exports from "./sv-SE.module.js";
import $4603b0d0246969b2$exports from "./tr-TR.module.js";
import $82649816f530bb1b$exports from "./uk-UA.module.js";
import $628e140a43dfb330$exports from "./zh-CN.module.js";
import $745937250cd4679c$exports from "./zh-TW.module.js";
import {announce as $amWdn$announce} from "@react-aria/live-announcer";
import {filterDOMProps as $amWdn$filterDOMProps, useUpdateEffect as $amWdn$useUpdateEffect, useSlotId as $amWdn$useSlotId, useLabels as $amWdn$useLabels, mergeProps as $amWdn$mergeProps, useEvent as $amWdn$useEvent, useDeepMemo as $amWdn$useDeepMemo, useDescription as $amWdn$useDescription, focusWithoutScrolling as $amWdn$focusWithoutScrolling, scrollIntoViewport as $amWdn$scrollIntoViewport, getScrollParent as $amWdn$getScrollParent} from "@react-aria/utils";
import {useLocalizedStringFormatter as $amWdn$useLocalizedStringFormatter, useDateFormatter as $amWdn$useDateFormatter, useLocale as $amWdn$useLocale} from "@react-aria/i18n";
import {useState as $amWdn$useState, useMemo as $amWdn$useMemo, useRef as $amWdn$useRef, useEffect as $amWdn$useEffect} from "react";
import {isSameDay as $amWdn$isSameDay, startOfMonth as $amWdn$startOfMonth, endOfMonth as $amWdn$endOfMonth, startOfWeek as $amWdn$startOfWeek, today as $amWdn$today, isEqualDay as $amWdn$isEqualDay, isToday as $amWdn$isToday} from "@internationalized/date";
import {usePress as $amWdn$usePress, getInteractionModality as $amWdn$getInteractionModality} from "@react-aria/interactions";
import {useCalendar as $9942cad8a072a530$export$3ee915f8151bd4f1} from "./useCalendar.module.js";
import {useRangeCalendar as $46a4342aab3d8076$export$87e0539f600c24e5} from "./useRangeCalendar.module.js";
import {useCalendarGrid as $e3031d1f8c9d64eb$export$cb95147730a423f5} from "./useCalendarGrid.module.js";
import {useCalendarCell as $36a0ac60f04457c5$export$136073280381448e} from "./useCalendarCell.module.js";
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
/*

@@ -56,36 +16,4 @@ * Copyright 2020 Adobe. All rights reserved.

* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
var $3904726b442bd9b2$exports = {};

@@ -95,704 +23,3 @@

$3904726b442bd9b2$exports = {
"ar-AE": $39324ace0d945f59$exports,
"bg-BG": $1830a539e98c7baf$exports,
"cs-CZ": $f4b92528965aab97$exports,
"da-DK": $1cd578ef0547c8f1$exports,
"de-DE": $db55a8973925d619$exports,
"el-GR": $ec6937d58566d443$exports,
"en-US": $1f5cea0742dc284a$exports,
"es-ES": $2ca7ea366384817b$exports,
"et-EE": $97874a7fe9cd091f$exports,
"fi-FI": $5d376b7fce1a45b2$exports,
"fr-FR": $3bf722b362aaf54d$exports,
"he-IL": $38c43f8322316031$exports,
"hr-HR": $c90e0f32b44630bf$exports,
"hu-HU": $715875e6e7a338f4$exports,
"it-IT": $37d77c66e34daccf$exports,
"ja-JP": $542f39aee29303c3$exports,
"ko-KR": $22a5f0623ea73e4f$exports,
"lt-LT": $522380d13d62cba0$exports,
"lv-LV": $8a7bc830b2fe6485$exports,
"nb-NO": $9fac9c044470683b$exports,
"nl-NL": $b127d3569efb1449$exports,
"pl-PL": $51404a4090633490$exports,
"pt-BR": $e5e6a3fe3b4527df$exports,
"pt-PT": $c519dcadcbb1ee47$exports,
"ro-RO": $e5aa0186ca7889c6$exports,
"ru-RU": $5b907f5fa3eee652$exports,
"sk-SK": $1b4c51359c99cf79$exports,
"sl-SI": $02e4e6a4608cc6f3$exports,
"sr-SP": $6dd2fbaad93b6878$exports,
"sv-SE": $33ea59bfe6e804e0$exports,
"tr-TR": $4603b0d0246969b2$exports,
"uk-UA": $82649816f530bb1b$exports,
"zh-CN": $628e140a43dfb330$exports,
"zh-TW": $745937250cd4679c$exports
};
const $a074e1e2d0f0a665$export$653eddfc964b0f8a = new WeakMap();
function $a074e1e2d0f0a665$export$134cbb7fb09a9522(date) {
return (date === null || date === void 0 ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : undefined;
}
function $a074e1e2d0f0a665$export$b6df97c887c38e1a(state) {
let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
let start, end;
if ("highlightedRange" in state) ({ start: start, end: end } = state.highlightedRange || {});
else start = end = state.value;
let dateFormatter = (0, $amWdn$useDateFormatter)({
weekday: "long",
month: "long",
year: "numeric",
day: "numeric",
era: $a074e1e2d0f0a665$export$134cbb7fb09a9522(start) || $a074e1e2d0f0a665$export$134cbb7fb09a9522(end),
timeZone: state.timeZone
});
let anchorDate = "anchorDate" in state ? state.anchorDate : null;
return (0, $amWdn$useMemo)(()=>{
// No message if currently selecting a range, or there is nothing highlighted.
if (!anchorDate && start && end) {
// Use a single date message if the start and end dates are the same day,
// otherwise include both dates.
if ((0, $amWdn$isSameDay)(start, end)) {
let date = dateFormatter.format(start.toDate(state.timeZone));
return stringFormatter.format("selectedDateDescription", {
date: date
});
} else {
let dateRange = $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);
return stringFormatter.format("selectedRangeDescription", {
dateRange: dateRange
});
}
}
return "";
}, [
start,
end,
anchorDate,
state.timeZone,
stringFormatter,
dateFormatter
]);
}
function $a074e1e2d0f0a665$export$31afe65d91ef6e8(startDate, endDate, timeZone, isAria) {
let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
let era = $a074e1e2d0f0a665$export$134cbb7fb09a9522(startDate) || $a074e1e2d0f0a665$export$134cbb7fb09a9522(endDate);
let monthFormatter = (0, $amWdn$useDateFormatter)({
month: "long",
year: "numeric",
era: era,
calendar: startDate.calendar.identifier,
timeZone: timeZone
});
let dateFormatter = (0, $amWdn$useDateFormatter)({
month: "long",
year: "numeric",
day: "numeric",
era: era,
calendar: startDate.calendar.identifier,
timeZone: timeZone
});
return (0, $amWdn$useMemo)(()=>{
// Special case for month granularity. Format as a single month if only a
// single month is visible, otherwise format as a range of months.
if ((0, $amWdn$isSameDay)(startDate, (0, $amWdn$startOfMonth)(startDate))) {
if ((0, $amWdn$isSameDay)(endDate, (0, $amWdn$endOfMonth)(startDate))) return monthFormatter.format(startDate.toDate(timeZone));
else if ((0, $amWdn$isSameDay)(endDate, (0, $amWdn$endOfMonth)(endDate))) return isAria ? $a074e1e2d0f0a665$var$formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone) : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
}
return isAria ? $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone) : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
}, [
startDate,
endDate,
monthFormatter,
dateFormatter,
stringFormatter,
timeZone,
isAria
]);
}
function $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, start, end, timeZone) {
let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));
// Find the separator between the start and end date. This is determined
// by finding the last shared literal before the end range.
let separatorIndex = -1;
for(let i = 0; i < parts.length; i++){
let part = parts[i];
if (part.source === "shared" && part.type === "literal") separatorIndex = i;
else if (part.source === "endRange") break;
}
// Now we can combine the parts into start and end strings.
let startValue = "";
let endValue = "";
for(let i = 0; i < parts.length; i++){
if (i < separatorIndex) startValue += parts[i].value;
else if (i > separatorIndex) endValue += parts[i].value;
}
return stringFormatter.format("dateRange", {
startDate: startValue,
endDate: endValue
});
}
function $c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state) {
let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
let domProps = (0, $amWdn$filterDOMProps)(props);
let title = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);
let visibleRangeDescription = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);
// Announce when the visible date range changes
(0, $amWdn$useUpdateEffect)(()=>{
// only when pressing the Previous or Next button
if (!state.isFocused) (0, $amWdn$announce)(visibleRangeDescription);
}, [
visibleRangeDescription
]);
// Announce when the selected value changes
let selectedDateDescription = (0, $a074e1e2d0f0a665$export$b6df97c887c38e1a)(state);
(0, $amWdn$useUpdateEffect)(()=>{
if (selectedDateDescription) (0, $amWdn$announce)(selectedDateDescription, "polite", 4000);
// handle an update to the caption that describes the currently selected range, to announce the new value
}, [
selectedDateDescription
]);
let errorMessageId = (0, $amWdn$useSlotId)([
Boolean(props.errorMessage),
props.isInvalid,
props.validationState
]);
// Pass the label to the child grid elements.
(0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).set(state, {
ariaLabel: props["aria-label"],
ariaLabelledBy: props["aria-labelledby"],
errorMessageId: errorMessageId,
selectedDateDescription: selectedDateDescription
});
// If the next or previous buttons become disabled while they are focused, move focus to the calendar body.
let [nextFocused, setNextFocused] = (0, $amWdn$useState)(false);
let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();
if (nextDisabled && nextFocused) {
setNextFocused(false);
state.setFocused(true);
}
let [previousFocused, setPreviousFocused] = (0, $amWdn$useState)(false);
let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();
if (previousDisabled && previousFocused) {
setPreviousFocused(false);
state.setFocused(true);
}
let labelProps = (0, $amWdn$useLabels)({
id: props["id"],
"aria-label": [
props["aria-label"],
visibleRangeDescription
].filter(Boolean).join(", "),
"aria-labelledby": props["aria-labelledby"]
});
return {
calendarProps: (0, $amWdn$mergeProps)(domProps, labelProps, {
role: "application",
"aria-describedby": props["aria-describedby"] || undefined
}),
nextButtonProps: {
onPress: ()=>state.focusNextPage(),
"aria-label": stringFormatter.format("next"),
isDisabled: nextDisabled,
onFocusChange: setNextFocused
},
prevButtonProps: {
onPress: ()=>state.focusPreviousPage(),
"aria-label": stringFormatter.format("previous"),
isDisabled: previousDisabled,
onFocusChange: setPreviousFocused
},
errorMessageProps: {
id: errorMessageId
},
title: title
};
}
function $9942cad8a072a530$export$3ee915f8151bd4f1(props, state) {
return (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
let res = (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
// We need to ignore virtual pointer events from VoiceOver due to these bugs.
// https://bugs.webkit.org/show_bug.cgi?id=222627
// https://bugs.webkit.org/show_bug.cgi?id=223202
// usePress also does this and waits for the following click event before firing.
// We need to match that here otherwise this will fire before the press event in
// useCalendarCell, causing range selection to not work properly.
let isVirtualClick = (0, $amWdn$useRef)(false);
let windowRef = (0, $amWdn$useRef)(typeof window !== "undefined" ? window : null);
(0, $amWdn$useEvent)(windowRef, "pointerdown", (e)=>{
isVirtualClick.current = e.width === 0 && e.height === 0;
});
// Stop range selection when pressing or releasing a pointer outside the calendar body,
// except when pressing the next or previous buttons to switch months.
let endDragging = (e)=>{
if (isVirtualClick.current) {
isVirtualClick.current = false;
return;
}
state.setDragging(false);
if (!state.anchorDate) return;
let target = e.target;
if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
};
(0, $amWdn$useEvent)(windowRef, "pointerup", endDragging);
// Also stop range selection on blur, e.g. tabbing away from the calendar.
res.calendarProps.onBlur = (e)=>{
if (!ref.current) return;
if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
};
// Prevent touch scrolling while dragging
(0, $amWdn$useEvent)(ref, "touchmove", (e)=>{
if (state.isDragging) e.preventDefault();
}, {
passive: false,
capture: true
});
return res;
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
let { direction: direction } = (0, $amWdn$useLocale)();
let onKeyDown = (e)=>{
switch(e.key){
case "Enter":
case " ":
e.preventDefault();
state.selectFocusedDate();
break;
case "PageUp":
e.preventDefault();
e.stopPropagation();
state.focusPreviousSection(e.shiftKey);
break;
case "PageDown":
e.preventDefault();
e.stopPropagation();
state.focusNextSection(e.shiftKey);
break;
case "End":
e.preventDefault();
e.stopPropagation();
state.focusSectionEnd();
break;
case "Home":
e.preventDefault();
e.stopPropagation();
state.focusSectionStart();
break;
case "ArrowLeft":
e.preventDefault();
e.stopPropagation();
if (direction === "rtl") state.focusNextDay();
else state.focusPreviousDay();
break;
case "ArrowUp":
e.preventDefault();
e.stopPropagation();
state.focusPreviousRow();
break;
case "ArrowRight":
e.preventDefault();
e.stopPropagation();
if (direction === "rtl") state.focusPreviousDay();
else state.focusNextDay();
break;
case "ArrowDown":
e.preventDefault();
e.stopPropagation();
state.focusNextRow();
break;
case "Escape":
// Cancel the selection.
if ("setAnchorDate" in state) {
e.preventDefault();
state.setAnchorDate(null);
}
break;
}
};
let visibleRangeDescription = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(startDate, endDate, state.timeZone, true);
let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy } = (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).get(state);
let labelProps = (0, $amWdn$useLabels)({
"aria-label": [
ariaLabel,
visibleRangeDescription
].filter(Boolean).join(", "),
"aria-labelledby": ariaLabelledBy
});
let dayFormatter = (0, $amWdn$useDateFormatter)({
weekday: props.weekdayStyle || "narrow",
timeZone: state.timeZone
});
let { locale: locale } = (0, $amWdn$useLocale)();
let weekDays = (0, $amWdn$useMemo)(()=>{
let weekStart = (0, $amWdn$startOfWeek)((0, $amWdn$today)(state.timeZone), locale);
return [
...new Array(7).keys()
].map((index)=>{
let date = weekStart.add({
days: index
});
let dateDay = date.toDate(state.timeZone);
return dayFormatter.format(dateDay);
});
}, [
locale,
state.timeZone,
dayFormatter
]);
return {
gridProps: (0, $amWdn$mergeProps)(labelProps, {
role: "grid",
"aria-readonly": state.isReadOnly || null,
"aria-disabled": state.isDisabled || null,
"aria-multiselectable": "highlightedRange" in state || undefined,
onKeyDown: onKeyDown,
onFocus: ()=>state.setFocused(true),
onBlur: ()=>state.setFocused(false)
}),
headerProps: {
// Column headers are hidden to screen readers to make navigating with a touch screen reader easier.
// The day names are already included in the label of each cell, so there's no need to announce them twice.
"aria-hidden": true
},
weekDays: weekDays
};
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $36a0ac60f04457c5$export$136073280381448e(props, state, ref) {
let { date: date, isDisabled: isDisabled } = props;
let { errorMessageId: errorMessageId, selectedDateDescription: selectedDateDescription } = (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).get(state);
let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
let dateFormatter = (0, $amWdn$useDateFormatter)({
weekday: "long",
day: "numeric",
month: "long",
year: "numeric",
era: (0, $a074e1e2d0f0a665$export$134cbb7fb09a9522)(date),
timeZone: state.timeZone
});
let isSelected = state.isSelected(date);
let isFocused = state.isCellFocused(date);
isDisabled = isDisabled || state.isCellDisabled(date);
let isUnavailable = state.isCellUnavailable(date);
let isSelectable = !isDisabled && !isUnavailable;
let isInvalid = state.isValueInvalid && ("highlightedRange" in state ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0 : state.value && (0, $amWdn$isSameDay)(state.value, date));
if (isInvalid) isSelected = true;
// For performance, reuse the same date object as before if the new date prop is the same.
// This allows subsequent useMemo results to be reused.
date = (0, $amWdn$useDeepMemo)(date, (0, $amWdn$isEqualDay));
let nativeDate = (0, $amWdn$useMemo)(()=>date.toDate(state.timeZone), [
date,
state.timeZone
]);
// aria-label should be localize Day of week, Month, Day and Year without Time.
let isDateToday = (0, $amWdn$isToday)(date, state.timeZone);
let label = (0, $amWdn$useMemo)(()=>{
let label = "";
// If this is a range calendar, add a description of the full selected range
// to the first and last selected date.
if ("highlightedRange" in state && state.value && !state.anchorDate && ((0, $amWdn$isSameDay)(date, state.value.start) || (0, $amWdn$isSameDay)(date, state.value.end))) label = selectedDateDescription + ", ";
label += dateFormatter.format(nativeDate);
if (isDateToday) // If date is today, set appropriate string depending on selected state:
label = stringFormatter.format(isSelected ? "todayDateSelected" : "todayDate", {
date: label
});
else if (isSelected) // If date is selected but not today:
label = stringFormatter.format("dateSelected", {
date: label
});
if (state.minValue && (0, $amWdn$isSameDay)(date, state.minValue)) label += ", " + stringFormatter.format("minimumDate");
else if (state.maxValue && (0, $amWdn$isSameDay)(date, state.maxValue)) label += ", " + stringFormatter.format("maximumDate");
return label;
}, [
dateFormatter,
nativeDate,
stringFormatter,
isSelected,
isDateToday,
date,
state,
selectedDateDescription
]);
// When a cell is focused and this is a range calendar, add a prompt to help
// screenreader users know that they are in a range selection mode.
let rangeSelectionPrompt = "";
if ("anchorDate" in state && isFocused && !state.isReadOnly && isSelectable) {
// If selection has started add "click to finish selecting range"
if (state.anchorDate) rangeSelectionPrompt = stringFormatter.format("finishRangeSelectionPrompt");
else rangeSelectionPrompt = stringFormatter.format("startRangeSelectionPrompt");
}
let descriptionProps = (0, $amWdn$useDescription)(rangeSelectionPrompt);
let isAnchorPressed = (0, $amWdn$useRef)(false);
let isRangeBoundaryPressed = (0, $amWdn$useRef)(false);
let touchDragTimerRef = (0, $amWdn$useRef)(null);
let { pressProps: pressProps, isPressed: isPressed } = (0, $amWdn$usePress)({
// When dragging to select a range, we don't want dragging over the original anchor
// again to trigger onPressStart. Cancel presses immediately when the pointer exits.
shouldCancelOnPointerExit: "anchorDate" in state && !!state.anchorDate,
preventFocusOnPress: true,
isDisabled: !isSelectable || state.isReadOnly,
onPressStart (e) {
if (state.isReadOnly) {
state.setFocusedDate(date);
return;
}
if ("highlightedRange" in state && !state.anchorDate && (e.pointerType === "mouse" || e.pointerType === "touch")) {
// Allow dragging the start or end date of a range to modify it
// rather than starting a new selection.
// Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges
// are constrained to available dates. The user will need to select a new range in this case.
if (state.highlightedRange && !isInvalid) {
if ((0, $amWdn$isSameDay)(date, state.highlightedRange.start)) {
state.setAnchorDate(state.highlightedRange.end);
state.setFocusedDate(date);
state.setDragging(true);
isRangeBoundaryPressed.current = true;
return;
} else if ((0, $amWdn$isSameDay)(date, state.highlightedRange.end)) {
state.setAnchorDate(state.highlightedRange.start);
state.setFocusedDate(date);
state.setDragging(true);
isRangeBoundaryPressed.current = true;
return;
}
}
let startDragging = ()=>{
state.setDragging(true);
touchDragTimerRef.current = null;
state.selectDate(date);
state.setFocusedDate(date);
isAnchorPressed.current = true;
};
// Start selection on mouse/touch down so users can drag to select a range.
// On touch, delay dragging to determine if the user really meant to scroll.
if (e.pointerType === "touch") touchDragTimerRef.current = setTimeout(startDragging, 200);
else startDragging();
}
},
onPressEnd () {
isRangeBoundaryPressed.current = false;
isAnchorPressed.current = false;
clearTimeout(touchDragTimerRef.current);
touchDragTimerRef.current = null;
},
onPress () {
// For non-range selection, always select on press up.
if (!("anchorDate" in state) && !state.isReadOnly) {
state.selectDate(date);
state.setFocusedDate(date);
}
},
onPressUp (e) {
if (state.isReadOnly) return;
// If the user tapped quickly, the date won't be selected yet and the
// timer will still be in progress. In this case, select the date on touch up.
// Timer is cleared in onPressEnd.
if ("anchorDate" in state && touchDragTimerRef.current) {
state.selectDate(date);
state.setFocusedDate(date);
}
if ("anchorDate" in state) {
if (isRangeBoundaryPressed.current) // When clicking on the start or end date of an already selected range,
// start a new selection on press up to also allow dragging the date to
// change the existing range.
state.setAnchorDate(date);
else if (state.anchorDate && !isAnchorPressed.current) {
// When releasing a drag or pressing the end date of a range, select it.
state.selectDate(date);
state.setFocusedDate(date);
} else if (e.pointerType === "keyboard" && !state.anchorDate) {
// For range selection, auto-advance the focused date by one if using keyboard.
// This gives an indication that you're selecting a range rather than a single date.
// For mouse, this is unnecessary because users will see the indication on hover. For screen readers,
// there will be an announcement to "click to finish selecting range" (above).
state.selectDate(date);
let nextDay = date.add({
days: 1
});
if (state.isInvalid(nextDay)) nextDay = date.subtract({
days: 1
});
if (!state.isInvalid(nextDay)) state.setFocusedDate(nextDay);
} else if (e.pointerType === "virtual") {
// For screen readers, just select the date on click.
state.selectDate(date);
state.setFocusedDate(date);
}
}
}
});
let tabIndex = null;
if (!isDisabled) tabIndex = (0, $amWdn$isSameDay)(date, state.focusedDate) ? 0 : -1;
// Focus the button in the DOM when the state updates.
(0, $amWdn$useEffect)(()=>{
if (isFocused && ref.current) {
(0, $amWdn$focusWithoutScrolling)(ref.current);
// Scroll into view if navigating with a keyboard, otherwise
// try not to shift the view under the user's mouse/finger.
// If in a overlay, scrollIntoViewport will only cause scrolling
// up to the overlay scroll body to prevent overlay shifting.
// Also only scroll into view if the cell actually got focused.
// There are some cases where the cell might be disabled or inside,
// an inert container and we don't want to scroll then.
if ((0, $amWdn$getInteractionModality)() !== "pointer" && document.activeElement === ref.current) (0, $amWdn$scrollIntoViewport)(ref.current, {
containingElement: (0, $amWdn$getScrollParent)(ref.current)
});
}
}, [
isFocused,
ref
]);
let cellDateFormatter = (0, $amWdn$useDateFormatter)({
day: "numeric",
timeZone: state.timeZone,
calendar: date.calendar.identifier
});
let formattedDate = (0, $amWdn$useMemo)(()=>cellDateFormatter.formatToParts(nativeDate).find((part)=>part.type === "day").value, [
cellDateFormatter,
nativeDate
]);
return {
cellProps: {
role: "gridcell",
"aria-disabled": !isSelectable || null,
"aria-selected": isSelected || null,
"aria-invalid": isInvalid || null
},
buttonProps: (0, $amWdn$mergeProps)(pressProps, {
onFocus () {
if (!isDisabled) state.setFocusedDate(date);
},
tabIndex: tabIndex,
role: "button",
"aria-disabled": !isSelectable || null,
"aria-label": label,
"aria-invalid": isInvalid || null,
"aria-describedby": [
isInvalid ? errorMessageId : null,
descriptionProps["aria-describedby"]
].filter(Boolean).join(" ") || undefined,
onPointerEnter (e) {
// Highlight the date on hover or drag over a date when selecting a range.
if ("highlightDate" in state && (e.pointerType !== "touch" || state.isDragging) && isSelectable) state.highlightDate(date);
},
onPointerDown (e) {
// This is necessary on touch devices to allow dragging
// outside the original pressed element.
// (JSDOM does not support this)
if ("releasePointerCapture" in e.target) e.target.releasePointerCapture(e.pointerId);
},
onContextMenu (e) {
// Prevent context menu on long press.
e.preventDefault();
}
}),
isPressed: isPressed,
isFocused: isFocused,
isSelected: isSelected,
isDisabled: isDisabled,
isUnavailable: isUnavailable,
isOutsideVisibleRange: date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,
isInvalid: isInvalid,
formattedDate: formattedDate
};
}
export {$9942cad8a072a530$export$3ee915f8151bd4f1 as useCalendar, $46a4342aab3d8076$export$87e0539f600c24e5 as useRangeCalendar, $e3031d1f8c9d64eb$export$cb95147730a423f5 as useCalendarGrid, $36a0ac60f04457c5$export$136073280381448e as useCalendarCell};
//# sourceMappingURL=module.js.map
{
"name": "@react-aria/calendar",
"version": "3.0.0-nightly.2843+81162ea39",
"version": "3.0.0-nightly.2846+c5e4b3701",
"description": "Spectrum UI components in React",

@@ -25,11 +25,11 @@ "license": "Apache-2.0",

"dependencies": {
"@internationalized/date": "3.5.3-nightly.4555+81162ea39",
"@react-aria/i18n": "3.0.0-nightly.2843+81162ea39",
"@react-aria/interactions": "3.0.0-nightly.2843+81162ea39",
"@react-aria/live-announcer": "3.0.0-nightly.2843+81162ea39",
"@react-aria/utils": "3.0.0-nightly.2843+81162ea39",
"@react-stately/calendar": "3.0.0-nightly.2843+81162ea39",
"@react-types/button": "3.9.3-nightly.4555+81162ea39",
"@react-types/calendar": "3.0.0-nightly.2843+81162ea39",
"@react-types/shared": "3.0.0-nightly.2843+81162ea39",
"@internationalized/date": "3.5.3-nightly.4558+c5e4b3701",
"@react-aria/i18n": "3.0.0-nightly.2846+c5e4b3701",
"@react-aria/interactions": "3.0.0-nightly.2846+c5e4b3701",
"@react-aria/live-announcer": "3.0.0-nightly.2846+c5e4b3701",
"@react-aria/utils": "3.0.0-nightly.2846+c5e4b3701",
"@react-stately/calendar": "3.0.0-nightly.2846+c5e4b3701",
"@react-types/button": "3.9.3-nightly.4558+c5e4b3701",
"@react-types/calendar": "3.0.0-nightly.2846+c5e4b3701",
"@react-types/shared": "3.0.0-nightly.2846+c5e4b3701",
"@swc/helpers": "^0.5.0"

@@ -44,3 +44,3 @@ },

},
"gitHead": "81162ea392926d06ec3d25c228e6f9b6b5479d59"
"gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc