@react-aria/calendar 3.5.13 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/ar-AE.main.js.map +1 -1
  2. package/dist/ar-AE.module.js.map +1 -1
  3. package/dist/bg-BG.main.js.map +1 -1
  4. package/dist/bg-BG.module.js.map +1 -1
  5. package/dist/cs-CZ.main.js.map +1 -1
  6. package/dist/cs-CZ.module.js.map +1 -1
  7. package/dist/da-DK.main.js.map +1 -1
  8. package/dist/da-DK.module.js.map +1 -1
  9. package/dist/de-DE.main.js.map +1 -1
  10. package/dist/de-DE.module.js.map +1 -1
  11. package/dist/el-GR.main.js.map +1 -1
  12. package/dist/el-GR.module.js.map +1 -1
  13. package/dist/en-US.main.js.map +1 -1
  14. package/dist/en-US.module.js.map +1 -1
  15. package/dist/es-ES.main.js.map +1 -1
  16. package/dist/es-ES.module.js.map +1 -1
  17. package/dist/et-EE.main.js.map +1 -1
  18. package/dist/et-EE.module.js.map +1 -1
  19. package/dist/fi-FI.main.js.map +1 -1
  20. package/dist/fi-FI.module.js.map +1 -1
  21. package/dist/fr-FR.main.js.map +1 -1
  22. package/dist/fr-FR.module.js.map +1 -1
  23. package/dist/he-IL.main.js.map +1 -1
  24. package/dist/he-IL.module.js.map +1 -1
  25. package/dist/hr-HR.main.js.map +1 -1
  26. package/dist/hr-HR.module.js.map +1 -1
  27. package/dist/hu-HU.main.js.map +1 -1
  28. package/dist/hu-HU.module.js.map +1 -1
  29. package/dist/it-IT.main.js.map +1 -1
  30. package/dist/it-IT.module.js.map +1 -1
  31. package/dist/ja-JP.main.js.map +1 -1
  32. package/dist/ja-JP.module.js.map +1 -1
  33. package/dist/ko-KR.main.js.map +1 -1
  34. package/dist/ko-KR.module.js.map +1 -1
  35. package/dist/lt-LT.main.js.map +1 -1
  36. package/dist/lt-LT.module.js.map +1 -1
  37. package/dist/lv-LV.main.js.map +1 -1
  38. package/dist/lv-LV.module.js.map +1 -1
  39. package/dist/nb-NO.main.js.map +1 -1
  40. package/dist/nb-NO.module.js.map +1 -1
  41. package/dist/nl-NL.main.js.map +1 -1
  42. package/dist/nl-NL.module.js.map +1 -1
  43. package/dist/pl-PL.main.js.map +1 -1
  44. package/dist/pl-PL.module.js.map +1 -1
  45. package/dist/pt-BR.main.js.map +1 -1
  46. package/dist/pt-BR.module.js.map +1 -1
  47. package/dist/pt-PT.main.js.map +1 -1
  48. package/dist/pt-PT.module.js.map +1 -1
  49. package/dist/ro-RO.main.js.map +1 -1
  50. package/dist/ro-RO.module.js.map +1 -1
  51. package/dist/ru-RU.main.js.map +1 -1
  52. package/dist/ru-RU.module.js.map +1 -1
  53. package/dist/sk-SK.main.js.map +1 -1
  54. package/dist/sk-SK.module.js.map +1 -1
  55. package/dist/sl-SI.main.js.map +1 -1
  56. package/dist/sl-SI.module.js.map +1 -1
  57. package/dist/sr-SP.main.js.map +1 -1
  58. package/dist/sr-SP.module.js.map +1 -1
  59. package/dist/sv-SE.main.js.map +1 -1
  60. package/dist/sv-SE.module.js.map +1 -1
  61. package/dist/tr-TR.main.js.map +1 -1
  62. package/dist/tr-TR.module.js.map +1 -1
  63. package/dist/types.d.ts +4 -0
  64. package/dist/types.d.ts.map +1 -1
  65. package/dist/uk-UA.main.js.map +1 -1
  66. package/dist/uk-UA.module.js.map +1 -1
  67. package/dist/useCalendarCell.main.js +11 -11
  68. package/dist/useCalendarCell.main.js.map +1 -1
  69. package/dist/useCalendarCell.mjs +11 -11
  70. package/dist/useCalendarCell.module.js +11 -11
  71. package/dist/useCalendarCell.module.js.map +1 -1
  72. package/dist/useCalendarGrid.main.js +6 -5
  73. package/dist/useCalendarGrid.main.js.map +1 -1
  74. package/dist/useCalendarGrid.mjs +6 -5
  75. package/dist/useCalendarGrid.module.js +6 -5
  76. package/dist/useCalendarGrid.module.js.map +1 -1
  77. package/dist/utils.main.js +2 -1
  78. package/dist/utils.main.js.map +1 -1
  79. package/dist/utils.mjs +2 -1
  80. package/dist/utils.module.js +2 -1
  81. package/dist/utils.module.js.map +1 -1
  82. package/dist/zh-CN.main.js.map +1 -1
  83. package/dist/zh-CN.module.js.map +1 -1
  84. package/dist/zh-TW.main.js.map +1 -1
  85. package/dist/zh-TW.module.js.map +1 -1
  86. package/package.json +13 -13
  87. package/src/useCalendarCell.ts +13 -13
  88. package/src/useCalendarGrid.ts +12 -7
  89. package/src/utils.ts +5 -5
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAgEM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC,EAAE,GAAkC;IACzI,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,gBAAgB,CAAA,GAAA,uBAAe,EAAE;QACnC,SAAS;QACT,KAAK;QACL,OAAO;QACP,MAAM;QACN,KAAK,CAAA,GAAA,yCAAW,EAAE;QAClB,UAAU,MAAM,QAAQ;IAC1B;IACA,IAAI,aAAa,MAAM,UAAU,CAAC;IAClC,IAAI,YAAY,MAAM,aAAa,CAAC;IACpC,aAAa,cAAc,MAAM,cAAc,CAAC;IAChD,IAAI,gBAAgB,MAAM,iBAAiB,CAAC;IAC5C,IAAI,eAAe,CAAC,cAAc,CAAC;IACnC,IAAI,YAAY,MAAM,cAAc,IAClC,CAAA,sBAAsB,QAClB,CAAC,MAAM,UAAU,IAAI,MAAM,gBAAgB,IAAI,KAAK,OAAO,CAAC,MAAM,gBAAgB,CAAC,KAAK,KAAK,KAAK,KAAK,OAAO,CAAC,MAAM,gBAAgB,CAAC,GAAG,KAAK,IAC9I,MAAM,KAAK,IAAI,CAAA,GAAA,gBAAQ,EAAE,MAAM,KAAK,EAAE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ClC,iBAAiB,cAAc;YAC/B,gBAAgB,aAAa;QAC/B;QACA,aAAa,CAAA,GAAA,iBAAS,EAAE,YAAY;YAClC;gBACE,IAAI,CAAC,YACH,MAAM,cAAc,CAAC;YAEzB;sBACA;YACA,MAAM;YACN,iBAAiB,CAAC,gBAAgB;YAClC,cAAc;YACd,gBAAgB,aAAa;YAC7B,oBAAoB;gBAClB,YAAY,iBAAiB;gBAC7B,gBAAgB,CAAC,mBAAmB;aACrC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;YAC/B,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IAAI,mBAAmB,SAAU,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAAM,cACjF,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAC;gBACb,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,2BAA2B,EAAE,MAAM,EACrC,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAE,SAAS;YAE9C;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBAAuB,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBAC5G;uBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarCell.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, getScrollParent, mergeProps, scrollIntoViewport, useDeepMemo, useDescription} from '@react-aria/utils';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality, usePress} from '@react-aria/interactions';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useEffect, useMemo, useRef} from 'react';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate,\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes,\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes,\n /** Whether the cell is currently being pressed. */\n isPressed: boolean,\n /** Whether the cell is selected. */\n isSelected: boolean,\n /** Whether the cell is focused. */\n isFocused: boolean,\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and `isDisabled` props.\n * Disabled dates are not focusable, and cannot be selected by the user. They are typically\n * displayed with a dimmed appearance.\n */\n isDisabled: boolean,\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop. Unavailable dates remain\n * focusable, but cannot be selected by the user. They should be displayed with a visual affordance to indicate they\n * are unavailable, such as a different color or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean,\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean,\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean,\n /** The day number formatted according to the current locale. */\n formattedDate: string\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(props: AriaCalendarCellProps, state: CalendarState | RangeCalendarState, ref: RefObject<HTMLElement | null>): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state);\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isSelected = state.isSelected(date);\n let isFocused = state.isCellFocused(date);\n isDisabled = isDisabled || state.isCellDisabled(date);\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isInvalid = state.isValueInvalid && (\n 'highlightedRange' in state\n ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0\n : state.value && isSameDay(state.value, date)\n );\n\n if (isInvalid) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [dateFormatter, nativeDate, stringFormatter, isSelected, isDateToday, date, state, selectedDateDescription]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef(null);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n return;\n }\n\n if ('highlightedRange' in state && !state.anchorDate && (e.pointerType === 'mouse' || e.pointerType === 'touch')) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = null;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = null;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n let nextDay = date.add({days: 1});\n if (state.isInvalid(nextDay)) {\n nextDay = date.subtract({days: 1});\n }\n if (!state.isInvalid(nextDay)) {\n state.setFocusedDate(nextDay);\n }\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n }\n }\n });\n\n let tabIndex = null;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && document.activeElement === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day').value, [cellDateFormatter, nativeDate]);\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || null,\n 'aria-selected': isSelected || null,\n 'aria-invalid': isInvalid || null\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || null,\n 'aria-label': label,\n 'aria-invalid': isInvalid || null,\n 'aria-describedby': [\n isInvalid ? errorMessageId : null,\n descriptionProps['aria-describedby']\n ].filter(Boolean).join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if ('highlightDate' in state && (e.pointerType !== 'touch' || state.isDragging) && isSelectable) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n if ('releasePointerCapture' in e.target) {\n e.target.releasePointerCapture(e.pointerId);\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange: date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAgEM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC,EAAE,GAAkC;IACzI,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,gBAAgB,CAAA,GAAA,uBAAe,EAAE;QACnC,SAAS;QACT,KAAK;QACL,OAAO;QACP,MAAM;QACN,KAAK,CAAA,GAAA,yCAAW,EAAE;QAClB,UAAU,MAAM,QAAQ;IAC1B;IACA,IAAI,aAAa,MAAM,UAAU,CAAC;IAClC,IAAI,YAAY,MAAM,aAAa,CAAC;IACpC,aAAa,cAAc,MAAM,cAAc,CAAC;IAChD,IAAI,gBAAgB,MAAM,iBAAiB,CAAC;IAC5C,IAAI,eAAe,CAAC,cAAc,CAAC;IACnC,IAAI,YAAY,MAAM,cAAc,IAAI,QACtC,sBAAsB,QAClB,CAAC,MAAM,UAAU,IAAI,MAAM,gBAAgB,IAAI,KAAK,OAAO,CAAC,MAAM,gBAAgB,CAAC,KAAK,KAAK,KAAK,KAAK,OAAO,CAAC,MAAM,gBAAgB,CAAC,GAAG,KAAK,IAC9I,MAAM,KAAK,IAAI,CAAA,GAAA,gBAAQ,EAAE,MAAM,KAAK,EAAE;IAG5C,IAAI,WACF,aAAa;IAGf,0FAA0F;IAC1F,uDAAu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Aa,CAAA,GAAA,iBAAS,EAAE,YAAY;YAClC;gBACE,IAAI,CAAC,YACH,MAAM,cAAc,CAAC;YAEzB;sBACA;YACA,MAAM;YACN,iBAAiB,CAAC,gBAAgB;YAClC,cAAc;YACd,gBAAgB,aAAa;YAC7B,oBAAoB;gBAClB,YAAY,iBAAiB;gBAC7B,gBAAgB,CAAC,mBAAmB;aACrC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;YAC/B,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IAAI,mBAAmB,SAAU,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAAM,cACjF,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAC;gBACb,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,2BAA2B,EAAE,MAAM,EACrC,EAAE,MAAM,CAAC,qBAAqB,CAAC,EAAE,SAAS;YAE9C;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBAAuB,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBAC5G;uBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarCell.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling, getScrollParent, mergeProps, scrollIntoViewport, useDeepMemo, useDescription} from '@react-aria/utils';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality, usePress} from '@react-aria/interactions';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useEffect, useMemo, useRef} from 'react';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate,\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes,\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes,\n /** Whether the cell is currently being pressed. */\n isPressed: boolean,\n /** Whether the cell is selected. */\n isSelected: boolean,\n /** Whether the cell is focused. */\n isFocused: boolean,\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and `isDisabled` props.\n * Disabled dates are not focusable, and cannot be selected by the user. They are typically\n * displayed with a dimmed appearance.\n */\n isDisabled: boolean,\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop. Unavailable dates remain\n * focusable, but cannot be selected by the user. They should be displayed with a visual affordance to indicate they\n * are unavailable, such as a different color or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean,\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean,\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean,\n /** The day number formatted according to the current locale. */\n formattedDate: string\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(props: AriaCalendarCellProps, state: CalendarState | RangeCalendarState, ref: RefObject<HTMLElement | null>): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state)!;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isSelected = state.isSelected(date);\n let isFocused = state.isCellFocused(date);\n isDisabled = isDisabled || state.isCellDisabled(date);\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isInvalid = state.isValueInvalid && Boolean(\n 'highlightedRange' in state\n ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0\n : state.value && isSameDay(state.value, date)\n );\n\n if (isInvalid) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [dateFormatter, nativeDate, stringFormatter, isSelected, isDateToday, date, state, selectedDateDescription]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n return;\n }\n\n if ('highlightedRange' in state && !state.anchorDate && (e.pointerType === 'mouse' || e.pointerType === 'touch')) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = undefined;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = undefined;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n let nextDay = date.add({days: 1});\n if (state.isInvalid(nextDay)) {\n nextDay = date.subtract({days: 1});\n }\n if (!state.isInvalid(nextDay)) {\n state.setFocusedDate(nextDay);\n }\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n }\n }\n }\n });\n\n let tabIndex: number | undefined = undefined;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && document.activeElement === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value, [cellDateFormatter, nativeDate]);\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-selected': isSelected || undefined,\n 'aria-invalid': isInvalid || undefined\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-label': label,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby': [\n isInvalid ? errorMessageId : undefined,\n descriptionProps['aria-describedby']\n ].filter(Boolean).join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if ('highlightDate' in state && (e.pointerType !== 'touch' || state.isDragging) && isSelectable) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n if ('releasePointerCapture' in e.target) {\n e.target.releasePointerCapture(e.pointerId);\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange: date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.module.js.map"}
@@ -26,7 +26,7 @@ $parcel$export(module.exports, "useCalendarGrid", () => $a07388a797d86b95$export
26
26
 
27
27
 
28
28
  function $a07388a797d86b95$export$cb95147730a423f5(props, state) {
29
- let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
29
+ let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end, firstDayOfWeek: firstDayOfWeek } = props;
30
30
  let { direction: direction } = (0, $iASLq$reactariai18n.useLocale)();
31
31
  let onKeyDown = (e)=>{
32
32
  switch(e.key){
@@ -101,7 +101,7 @@ function $a07388a797d86b95$export$cb95147730a423f5(props, state) {
101
101
  });
102
102
  let { locale: locale } = (0, $iASLq$reactariai18n.useLocale)();
103
103
  let weekDays = (0, $iASLq$react.useMemo)(()=>{
104
- let weekStart = (0, $iASLq$internationalizeddate.startOfWeek)((0, $iASLq$internationalizeddate.today)(state.timeZone), locale);
104
+ let weekStart = (0, $iASLq$internationalizeddate.startOfWeek)((0, $iASLq$internationalizeddate.today)(state.timeZone), locale, firstDayOfWeek);
105
105
  return [
106
106
  ...new Array(7).keys()
107
107
  ].map((index)=>{
@@ -114,13 +114,14 @@ function $a07388a797d86b95$export$cb95147730a423f5(props, state) {
114
114
  }, [
115
115
  locale,
116
116
  state.timeZone,
117
- dayFormatter
117
+ dayFormatter,
118
+ firstDayOfWeek
118
119
  ]);
119
120
  return {
120
121
  gridProps: (0, $iASLq$reactariautils.mergeProps)(labelProps, {
121
122
  role: 'grid',
122
- 'aria-readonly': state.isReadOnly || null,
123
- 'aria-disabled': state.isDisabled || null,
123
+ 'aria-readonly': state.isReadOnly || undefined,
124
+ 'aria-disabled': state.isDisabled || undefined,
124
125
  'aria-multiselectable': 'highlightedRange' in state || undefined,
125
126
  onKeyDown: onKeyDown,
126
127
  onFocus: ()=>state.setFocused(true),
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6CM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC;IACrG,IAAI,aACF,YAAY,MAAM,YAAY,CAAC,KAAK,WACpC,UAAU,MAAM,YAAY,CAAC,GAAG,EACjC,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAAE,cAAc;gBAChB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,oBAAoB,CAAC,EAAE,QAAQ;gBACrC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,gBAAgB,CAAC,EAAE,QAAQ;gBACjC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,eAAe;gBACrB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,IAAI,cAAc,OAChB,MAAM,YAAY;qBAElB,MAAM,gBAAgB;gBAExB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,gBAAgB;gBACtB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,IAAI,cAAc,OAChB,MAAM,gBAAgB;qBAEtB,MAAM,YAAY;gBAEpB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACj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,UAAU,CAAC;QACjC;QACA,aAAa;YACX,oGAAoG;YACpG,2GAA2G;YAC3G,eAAe;QACjB;kBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarGrid.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\n\nexport interface AriaCalendarGridProps {\n /**\n * The first date displayed in the calendar grid.\n * Defaults to the first visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n startDate?: CalendarDate,\n /**\n * The last date displayed in the calendar grid.\n * Defaults to the last visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n endDate?: CalendarDate,\n /**\n * The style of weekday names to display in the calendar grid header,\n * e.g. single letter, abbreviation, or full day name.\n * @default \"narrow\"\n */\n weekdayStyle?: 'narrow' | 'short' | 'long'\n}\n\nexport interface CalendarGridAria {\n /** Props for the date grid element (e.g. `<table>`). */\n gridProps: DOMAttributes,\n /** Props for the grid header element (e.g. `<thead>`). */\n headerProps: DOMAttributes,\n /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n weekDays: string[]\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n let {\n startDate = state.visibleRange.start,\n endDate = state.visibleRange.end\n } = props;\n\n let {direction} = useLocale();\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n state.selectFocusedDate();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousSection(e.shiftKey);\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextSection(e.shiftKey);\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionEnd();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionStart();\n break;\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusNextDay();\n } else {\n state.focusPreviousDay();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousRow();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusPreviousDay();\n } else {\n state.focusNextDay();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextRow();\n break;\n case 'Escape':\n // Cancel the selection.\n if ('setAnchorDate' in state) {\n e.preventDefault();\n state.setAnchorDate(null);\n }\n break;\n }\n };\n\n let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n let {ariaLabel, ariaLabelledBy} = hookData.get(state);\n let labelProps = useLabels({\n 'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': ariaLabelledBy\n });\n\n let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n let {locale} = useLocale();\n let weekDays = useMemo(() => {\n let weekStart = startOfWeek(today(state.timeZone), locale);\n return [...new Array(7).keys()].map((index) => {\n let date = weekStart.add({days: index});\n let dateDay = date.toDate(state.timeZone);\n return dayFormatter.format(dateDay);\n });\n }, [locale, state.timeZone, dayFormatter]);\n\n return {\n gridProps: mergeProps(labelProps, {\n role: 'grid',\n 'aria-readonly': state.isReadOnly || null,\n 'aria-disabled': state.isDisabled || null,\n 'aria-multiselectable': ('highlightedRange' in state) || undefined,\n onKeyDown,\n onFocus: () => state.setFocused(true),\n onBlur: () => state.setFocused(false)\n }),\n headerProps: {\n // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n // The day names are already included in the label of each cell, so there's no need to announce them twice.\n 'aria-hidden': true\n },\n weekDays\n };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiDM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC;IACrG,IAAI,aACF,YAAY,MAAM,YAAY,CAAC,KAAK,WACpC,UAAU,MAAM,YAAY,CAAC,GAAG,kBAChC,cAAc,EACf,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAAE,cAAc;gBAChB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,oBAAoB,CAAC,EAAE,QAAQ;gBACrC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,gBAAgB,CAAC,EAAE,QAAQ;gBACjC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,eAAe;gBACrB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,IAAI,cAAc,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,MAAM,CAAC;QAC7B;IACF,GAAG;QAAC;QAAQ,MAAM,QAAQ;QAAE;QAAc;KAAe;IAEzD,OAAO;QACL,WAAW,CAAA,GAAA,gCAAS,EAAE,YAAY;YAChC,MAAM;YACN,iBAAiB,MAAM,UAAU,IAAI;YACrC,iBAAiB,MAAM,UAAU,IAAI;YACrC,wBAAwB,AAAC,sBAAsB,SAAU;uBACzD;YACA,SAAS,IAAM,MAAM,UAAU,CAAC;YAChC,QAAQ,IAAM,MAAM,UAAU,CAAC;QACjC;QACA,aAAa;YACX,oGAAoG;YACpG,2GAA2G;YAC3G,eAAe;QACjB;kBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarGrid.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\n\nexport interface AriaCalendarGridProps {\n /**\n * The first date displayed in the calendar grid.\n * Defaults to the first visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n startDate?: CalendarDate,\n /**\n * The last date displayed in the calendar grid.\n * Defaults to the last visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n endDate?: CalendarDate,\n /**\n * The style of weekday names to display in the calendar grid header,\n * e.g. single letter, abbreviation, or full day name.\n * @default \"narrow\"\n */\n weekdayStyle?: 'narrow' | 'short' | 'long',\n /**\n * The day that starts the week.\n */\n firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'\n}\n\nexport interface CalendarGridAria {\n /** Props for the date grid element (e.g. `<table>`). */\n gridProps: DOMAttributes,\n /** Props for the grid header element (e.g. `<thead>`). */\n headerProps: DOMAttributes,\n /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n weekDays: string[]\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n let {\n startDate = state.visibleRange.start,\n endDate = state.visibleRange.end,\n firstDayOfWeek\n } = props;\n\n let {direction} = useLocale();\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n state.selectFocusedDate();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousSection(e.shiftKey);\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextSection(e.shiftKey);\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionEnd();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionStart();\n break;\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusNextDay();\n } else {\n state.focusPreviousDay();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousRow();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusPreviousDay();\n } else {\n state.focusNextDay();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextRow();\n break;\n case 'Escape':\n // Cancel the selection.\n if ('setAnchorDate' in state) {\n e.preventDefault();\n state.setAnchorDate(null);\n }\n break;\n }\n };\n\n let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n let {ariaLabel, ariaLabelledBy} = hookData.get(state)!;\n let labelProps = useLabels({\n 'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': ariaLabelledBy\n });\n\n let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n let {locale} = useLocale();\n let weekDays = useMemo(() => {\n let weekStart = startOfWeek(today(state.timeZone), locale, firstDayOfWeek);\n return [...new Array(7).keys()].map((index) => {\n let date = weekStart.add({days: index});\n let dateDay = date.toDate(state.timeZone);\n return dayFormatter.format(dateDay);\n });\n }, [locale, state.timeZone, dayFormatter, firstDayOfWeek]);\n\n return {\n gridProps: mergeProps(labelProps, {\n role: 'grid',\n 'aria-readonly': state.isReadOnly || undefined,\n 'aria-disabled': state.isDisabled || undefined,\n 'aria-multiselectable': ('highlightedRange' in state) || undefined,\n onKeyDown,\n onFocus: () => state.setFocused(true),\n onBlur: () => state.setFocused(false)\n }),\n headerProps: {\n // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n // The day names are already included in the label of each cell, so there's no need to announce them twice.\n 'aria-hidden': true\n },\n weekDays\n };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.main.js.map"}
@@ -20,7 +20,7 @@ import {useLocale as $NQfxu$useLocale, useDateFormatter as $NQfxu$useDateFormatt
20
20
 
21
21
 
22
22
  function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
23
- let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
23
+ let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end, firstDayOfWeek: firstDayOfWeek } = props;
24
24
  let { direction: direction } = (0, $NQfxu$useLocale)();
25
25
  let onKeyDown = (e)=>{
26
26
  switch(e.key){
@@ -95,7 +95,7 @@ function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
95
95
  });
96
96
  let { locale: locale } = (0, $NQfxu$useLocale)();
97
97
  let weekDays = (0, $NQfxu$useMemo)(()=>{
98
- let weekStart = (0, $NQfxu$startOfWeek)((0, $NQfxu$today)(state.timeZone), locale);
98
+ let weekStart = (0, $NQfxu$startOfWeek)((0, $NQfxu$today)(state.timeZone), locale, firstDayOfWeek);
99
99
  return [
100
100
  ...new Array(7).keys()
101
101
  ].map((index)=>{
@@ -108,13 +108,14 @@ function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
108
108
  }, [
109
109
  locale,
110
110
  state.timeZone,
111
- dayFormatter
111
+ dayFormatter,
112
+ firstDayOfWeek
112
113
  ]);
113
114
  return {
114
115
  gridProps: (0, $NQfxu$mergeProps)(labelProps, {
115
116
  role: 'grid',
116
- 'aria-readonly': state.isReadOnly || null,
117
- 'aria-disabled': state.isDisabled || null,
117
+ 'aria-readonly': state.isReadOnly || undefined,
118
+ 'aria-disabled': state.isDisabled || undefined,
118
119
  'aria-multiselectable': 'highlightedRange' in state || undefined,
119
120
  onKeyDown: onKeyDown,
120
121
  onFocus: ()=>state.setFocused(true),
@@ -20,7 +20,7 @@ import {useLocale as $NQfxu$useLocale, useDateFormatter as $NQfxu$useDateFormatt
20
20
 
21
21
 
22
22
  function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
23
- let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
23
+ let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end, firstDayOfWeek: firstDayOfWeek } = props;
24
24
  let { direction: direction } = (0, $NQfxu$useLocale)();
25
25
  let onKeyDown = (e)=>{
26
26
  switch(e.key){
@@ -95,7 +95,7 @@ function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
95
95
  });
96
96
  let { locale: locale } = (0, $NQfxu$useLocale)();
97
97
  let weekDays = (0, $NQfxu$useMemo)(()=>{
98
- let weekStart = (0, $NQfxu$startOfWeek)((0, $NQfxu$today)(state.timeZone), locale);
98
+ let weekStart = (0, $NQfxu$startOfWeek)((0, $NQfxu$today)(state.timeZone), locale, firstDayOfWeek);
99
99
  return [
100
100
  ...new Array(7).keys()
101
101
  ].map((index)=>{
@@ -108,13 +108,14 @@ function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
108
108
  }, [
109
109
  locale,
110
110
  state.timeZone,
111
- dayFormatter
111
+ dayFormatter,
112
+ firstDayOfWeek
112
113
  ]);
113
114
  return {
114
115
  gridProps: (0, $NQfxu$mergeProps)(labelProps, {
115
116
  role: 'grid',
116
- 'aria-readonly': state.isReadOnly || null,
117
- 'aria-disabled': state.isDisabled || null,
117
+ 'aria-readonly': state.isReadOnly || undefined,
118
+ 'aria-disabled': state.isDisabled || undefined,
118
119
  'aria-multiselectable': 'highlightedRange' in state || undefined,
119
120
  onKeyDown: onKeyDown,
120
121
  onFocus: ()=>state.setFocused(true),
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6CM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC;IACrG,IAAI,aACF,YAAY,MAAM,YAAY,CAAC,KAAK,WACpC,UAAU,MAAM,YAAY,CAAC,GAAG,EACjC,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAAE,cAAc;gBAChB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,oBAAoB,CAAC,EAAE,QAAQ;gBACrC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,gBAAgB,CAAC,EAAE,QAAQ;gBACjC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB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I;SAAG,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,OAAO,UAAU,GAAG,CAAC;gBAAC,MAAM;YAAK;YACrC,IAAI,UAAU,KAAK,MAAM,CAAC,MAAM,QAAQ;YACxC,OAAO,aAAa,MAAM,CAAC;QAC7B;IACF,GAAG;QAAC;QAAQ,MAAM,QAAQ;QAAE;KAAa;IAEzC,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,YAAY;YAChC,MAAM;YACN,iBAAiB,MAAM,UAAU,IAAI;YACrC,iBAAiB,MAAM,UAAU,IAAI;YACrC,wBAAwB,AAAC,sBAAsB,SAAU;uBACzD;YACA,SAAS,IAAM,MAAM,UAAU,CAAC;YAChC,QAAQ,IAAM,MAAM,UAAU,CAAC;QACjC;QACA,aAAa;YACX,oGAAoG;YACpG,2GAA2G;YAC3G,eAAe;QACjB;kBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarGrid.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\n\nexport interface AriaCalendarGridProps {\n /**\n * The first date displayed in the calendar grid.\n * Defaults to the first visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n startDate?: CalendarDate,\n /**\n * The last date displayed in the calendar grid.\n * Defaults to the last visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n endDate?: CalendarDate,\n /**\n * The style of weekday names to display in the calendar grid header,\n * e.g. single letter, abbreviation, or full day name.\n * @default \"narrow\"\n */\n weekdayStyle?: 'narrow' | 'short' | 'long'\n}\n\nexport interface CalendarGridAria {\n /** Props for the date grid element (e.g. `<table>`). */\n gridProps: DOMAttributes,\n /** Props for the grid header element (e.g. `<thead>`). */\n headerProps: DOMAttributes,\n /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n weekDays: string[]\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n let {\n startDate = state.visibleRange.start,\n endDate = state.visibleRange.end\n } = props;\n\n let {direction} = useLocale();\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n state.selectFocusedDate();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousSection(e.shiftKey);\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextSection(e.shiftKey);\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionEnd();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionStart();\n break;\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusNextDay();\n } else {\n state.focusPreviousDay();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousRow();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusPreviousDay();\n } else {\n state.focusNextDay();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextRow();\n break;\n case 'Escape':\n // Cancel the selection.\n if ('setAnchorDate' in state) {\n e.preventDefault();\n state.setAnchorDate(null);\n }\n break;\n }\n };\n\n let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n let {ariaLabel, ariaLabelledBy} = hookData.get(state);\n let labelProps = useLabels({\n 'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': ariaLabelledBy\n });\n\n let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n let {locale} = useLocale();\n let weekDays = useMemo(() => {\n let weekStart = startOfWeek(today(state.timeZone), locale);\n return [...new Array(7).keys()].map((index) => {\n let date = weekStart.add({days: index});\n let dateDay = date.toDate(state.timeZone);\n return dayFormatter.format(dateDay);\n });\n }, [locale, state.timeZone, dayFormatter]);\n\n return {\n gridProps: mergeProps(labelProps, {\n role: 'grid',\n 'aria-readonly': state.isReadOnly || null,\n 'aria-disabled': state.isDisabled || null,\n 'aria-multiselectable': ('highlightedRange' in state) || undefined,\n onKeyDown,\n onFocus: () => state.setFocused(true),\n onBlur: () => state.setFocused(false)\n }),\n headerProps: {\n // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n // The day names are already included in the label of each cell, so there's no need to announce them twice.\n 'aria-hidden': true\n },\n weekDays\n };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiDM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC;IACrG,IAAI,aACF,YAAY,MAAM,YAAY,CAAC,KAAK,WACpC,UAAU,MAAM,YAAY,CAAC,GAAG,kBAChC,cAAc,EACf,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAA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AC,SAAS,MAAM,YAAY,IAAI;QAAU,UAAU,MAAM,QAAQ;IAAA;IACtG,IAAI,UAAC,MAAM,EAAC,GAAG,CAAA,GAAA,gBAAQ;IACvB,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE;QACrB,IAAI,YAAY,CAAA,GAAA,kBAAU,EAAE,CAAA,GAAA,YAAI,EAAE,MAAM,QAAQ,GAAG,QAAQ;QAC3D,OAAO;eAAI,IAAI,MAAM,GAAG,IAAI;SAAG,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,OAAO,UAAU,GAAG,CAAC;gBAAC,MAAM;YAAK;YACrC,IAAI,UAAU,KAAK,MAAM,CAAC,MAAM,QAAQ;YACxC,OAAO,aAAa,MAAM,CAAC;QAC7B;IACF,GAAG;QAAC;QAAQ,MAAM,QAAQ;QAAE;QAAc;KAAe;IAEzD,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,YAAY;YAChC,MAAM;YACN,iBAAiB,MAAM,UAAU,IAAI;YACrC,iBAAiB,MAAM,UAAU,IAAI;YACrC,wBAAwB,AAAC,sBAAsB,SAAU;uBACzD;YACA,SAAS,IAAM,MAAM,UAAU,CAAC;YAChC,QAAQ,IAAM,MAAM,UAAU,CAAC;QACjC;QACA,aAAa;YACX,oGAAoG;YACpG,2GAA2G;YAC3G,eAAe;QACjB;kBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarGrid.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\n\nexport interface AriaCalendarGridProps {\n /**\n * The first date displayed in the calendar grid.\n * Defaults to the first visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n startDate?: CalendarDate,\n /**\n * The last date displayed in the calendar grid.\n * Defaults to the last visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n endDate?: CalendarDate,\n /**\n * The style of weekday names to display in the calendar grid header,\n * e.g. single letter, abbreviation, or full day name.\n * @default \"narrow\"\n */\n weekdayStyle?: 'narrow' | 'short' | 'long',\n /**\n * The day that starts the week.\n */\n firstDayOfWeek?: 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'\n}\n\nexport interface CalendarGridAria {\n /** Props for the date grid element (e.g. `<table>`). */\n gridProps: DOMAttributes,\n /** Props for the grid header element (e.g. `<thead>`). */\n headerProps: DOMAttributes,\n /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n weekDays: string[]\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n let {\n startDate = state.visibleRange.start,\n endDate = state.visibleRange.end,\n firstDayOfWeek\n } = props;\n\n let {direction} = useLocale();\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n state.selectFocusedDate();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousSection(e.shiftKey);\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextSection(e.shiftKey);\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionEnd();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionStart();\n break;\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusNextDay();\n } else {\n state.focusPreviousDay();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousRow();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusPreviousDay();\n } else {\n state.focusNextDay();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextRow();\n break;\n case 'Escape':\n // Cancel the selection.\n if ('setAnchorDate' in state) {\n e.preventDefault();\n state.setAnchorDate(null);\n }\n break;\n }\n };\n\n let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n let {ariaLabel, ariaLabelledBy} = hookData.get(state)!;\n let labelProps = useLabels({\n 'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': ariaLabelledBy\n });\n\n let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n let {locale} = useLocale();\n let weekDays = useMemo(() => {\n let weekStart = startOfWeek(today(state.timeZone), locale, firstDayOfWeek);\n return [...new Array(7).keys()].map((index) => {\n let date = weekStart.add({days: index});\n let dateDay = date.toDate(state.timeZone);\n return dayFormatter.format(dateDay);\n });\n }, [locale, state.timeZone, dayFormatter, firstDayOfWeek]);\n\n return {\n gridProps: mergeProps(labelProps, {\n role: 'grid',\n 'aria-readonly': state.isReadOnly || undefined,\n 'aria-disabled': state.isDisabled || undefined,\n 'aria-multiselectable': ('highlightedRange' in state) || undefined,\n onKeyDown,\n onFocus: () => state.setFocused(true),\n onBlur: () => state.setFocused(false)\n }),\n headerProps: {\n // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n // The day names are already included in the label of each cell, so there's no need to announce them twice.\n 'aria-hidden': true\n },\n weekDays\n };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.module.js.map"}
@@ -37,8 +37,9 @@ function $df1d8e967e73ec8e$export$134cbb7fb09a9522(date) {
37
37
  function $df1d8e967e73ec8e$export$b6df97c887c38e1a(state) {
38
38
  let stringFormatter = (0, $idq92$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), '@react-aria/calendar');
39
39
  let start, end;
40
+ var _state_value;
40
41
  if ('highlightedRange' in state) ({ start: start, end: end } = state.highlightedRange || {});
41
- else start = end = state.value;
42
+ else start = end = (_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : undefined;
42
43
  let dateFormatter = (0, $idq92$reactariai18n.useDateFormatter)({
43
44
  weekday: 'long',
44
45
  month: 'long',
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiBM,MAAM,4CAAW,IAAI;AAErB,SAAS,0CAAa,IAAkB;IAC7C,OAAO,CAAA,iBAAA,2BAAA,KAAM,QAAQ,CAAC,UAAU,MAAK,aAAa,KAAK,GAAG,KAAK,OAAO,UAAU;AAClF;AAEO,SAAS,0CAA2B,KAAyC;IAClF,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,OAAqB;IACzB,IAAI,sBAAsB,OACvB,CAAA,SAAC,KAAK,OAAE,GAAG,EAAC,GAAG,MAAM,gBAAgB,IAAI,CAAC,CAAA;SAE3C,QAAQ,MAAM,MAAM,KAAK;IAG3B,IAAI,gBAAgB,CAAA,GAAA,qCAAe,EAAE;QACnC,SAAS;QACT,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK,0CAAa,UAAU,0CAAa;QACzC,UAAU,MAAM,QAAQ;IAC1B;IAEA,IAAI,aAAa,gBAAgB,QAAQ,MAAM,UAAU,GAAG;IAC5D,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Q,EAAE,SAAS,CAAA,GAAA,uCAAS,EAAE,WACvC,OAAO,SACH,kCAAY,gBAAgB,iBAAiB,WAAW,SAAS,YACjE,eAAe,WAAW,CAAC,UAAU,MAAM,CAAC,WAAW,QAAQ,MAAM,CAAC;QAE9E;QAEA,OAAO,SACH,kCAAY,eAAe,iBAAiB,WAAW,SAAS,YAChE,cAAc,WAAW,CAAC,UAAU,MAAM,CAAC,WAAW,QAAQ,MAAM,CAAC;IAC3E,GAAG;QAAC;QAAW;QAAS;QAAgB;QAAe;QAAiB;QAAU;KAAO;AAC3F;AAEA,SAAS,kCAAY,aAA4B,EAAE,eAAyC,EAAE,KAAmB,EAAE,GAAiB,EAAE,QAAgB;IACpJ,IAAI,QAAQ,cAAc,kBAAkB,CAAC,MAAM,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC;IAEhF,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,iBAAiB;IACrB,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,OAAO,KAAK,CAAC,EAAE;QACnB,IAAI,KAAK,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,WAC5C,iBAAiB;aACZ,IAAI,KAAK,MAAM,KAAK,YACzB;IAEJ;IAEA,2DAA2D;IAC3D,IAAI,aAAa;IACjB,IAAI,WAAW;IACf,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,IAAI,gBACN,cAAc,KAAK,CAAC,EAAE,CAAC,KAAK;aACvB,IAAI,IAAI,gBACb,YAAY,KAAK,CAAC,EAAE,CAAC,KAAK;IAE9B;IAEA,OAAO,gBAAgB,MAAM,CAAC,aAAa;QAAC,WAAW;QAAY,SAAS;IAAQ;AACtF","sources":["packages/@react-aria/calendar/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, DateFormatter, endOfMonth, isSameDay, startOfMonth} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n errorMessageId: string,\n selectedDateDescription: string\n}\n\nexport const hookData = new WeakMap<CalendarState | RangeCalendarState, HookData>();\n\nexport function getEraFormat(date: CalendarDate): 'short' | undefined {\n return date?.calendar.identifier === 'gregory' && date.era === 'BC' ? 'short' : undefined;\n}\n\nexport function useSelectedDateDescription(state: CalendarState | RangeCalendarState) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n\n let start: CalendarDate, end: CalendarDate;\n if ('highlightedRange' in state) {\n ({start, end} = state.highlightedRange || {});\n } else {\n start = end = state.value;\n }\n\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era: getEraFormat(start) || getEraFormat(end),\n timeZone: state.timeZone\n });\n\n let anchorDate = 'anchorDate' in state ? state.anchorDate : null;\n return useMemo(() => {\n // No message if currently selecting a range, or there is nothing highlighted.\n if (!anchorDate && start && end) {\n // Use a single date message if the start and end dates are the same day,\n // otherwise include both dates.\n if (isSameDay(start, end)) {\n let date = dateFormatter.format(start.toDate(state.timeZone));\n return stringFormatter.format('selectedDateDescription', {date});\n } else {\n let dateRange = formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);\n\n return stringFormatter.format('selectedRangeDescription', {dateRange});\n }\n }\n return '';\n }, [start, end, anchorDate, state.timeZone, stringFormatter, dateFormatter]);\n}\n\nexport function useVisibleRangeDescription(startDate: CalendarDate, endDate: CalendarDate, timeZone: string, isAria: boolean) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let era: any = getEraFormat(startDate) || getEraFormat(endDate);\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n let dateFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n return useMemo(() => {\n // Special case for month granularity. Format as a single month if only a\n // single month is visible, otherwise format as a range of months.\n if (isSameDay(startDate, startOfMonth(startDate))) {\n if (isSameDay(endDate, endOfMonth(startDate))) {\n return monthFormatter.format(startDate.toDate(timeZone));\n } else if (isSameDay(endDate, endOfMonth(endDate))) {\n return isAria\n ? formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone)\n : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }\n }\n\n return isAria\n ? formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone)\n : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }, [startDate, endDate, monthFormatter, dateFormatter, stringFormatter, timeZone, isAria]);\n}\n\nfunction formatRange(dateFormatter: DateFormatter, stringFormatter: LocalizedStringFormatter, start: CalendarDate, end: CalendarDate, timeZone: string) {\n let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let startValue = '';\n let endValue = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n startValue += parts[i].value;\n } else if (i > separatorIndex) {\n endValue += parts[i].value;\n }\n }\n\n return stringFormatter.format('dateRange', {startDate: startValue, endDate: endValue});\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiBM,MAAM,4CAAW,IAAI;AAErB,SAAS,0CAAa,IAA8B;IACzD,OAAO,CAAA,iBAAA,2BAAA,KAAM,QAAQ,CAAC,UAAU,MAAK,aAAa,KAAK,GAAG,KAAK,OAAO,UAAU;AAClF;AAEO,SAAS,0CAA2B,KAAyC;IAClF,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,OAAiC;QAIrB;IAHhB,IAAI,sBAAsB,OACvB,CAAA,SAAC,KAAK,OAAE,GAAG,EAAC,GAAG,MAAM,gBAAgB,IAAI,CAAC,CAAA;SAE3C,QAAQ,MAAM,CAAA,eAAA,MAAM,KAAK,cAAX,0BAAA,eAAe;IAG/B,IAAI,gBAAgB,CAAA,GAAA,qCAAe,EAAE;QACnC,SAAS;QACT,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK,0CAAa,UAAU,0CAAa;QACzC,UAAU,MAAM,QAAQ;IAC1B;IAEA,IAAI,aAAa,gBAAgB,QAAQ,MAAM,UAAU,GAAG;IAC5D,OAAO,CAAA,GAAA,oBAAM,EAAE;QACb,8EAA8E;QAC9E,IAAI,CAAC,cAAc,SAAS;YAC1B,yEAAyE;YACzE,gCAAgC;YAChC,IAAI,CAAA,GAAA,sCAAQ,EAAE,OAAO,MAAM;gBACzB,IAAI,OAAO,cAAc,MAAM,CAAC,MAAM,MAAM,CAAC,MAAM,QAAQ;gBAC3D,OAAO,gBAAgB,MAAM,CAAC,2BAA2B;0BAAC;gBAAI;YAChE,OAAO;gBACL,IAAI,YAAY,kCAAY,eAAe,iBAAiB,O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B;QAAU;KAAO;AAC3F;AAEA,SAAS,kCAAY,aAA4B,EAAE,eAAyC,EAAE,KAAmB,EAAE,GAAiB,EAAE,QAAgB;IACpJ,IAAI,QAAQ,cAAc,kBAAkB,CAAC,MAAM,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC;IAEhF,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,iBAAiB;IACrB,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,OAAO,KAAK,CAAC,EAAE;QACnB,IAAI,KAAK,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,WAC5C,iBAAiB;aACZ,IAAI,KAAK,MAAM,KAAK,YACzB;IAEJ;IAEA,2DAA2D;IAC3D,IAAI,aAAa;IACjB,IAAI,WAAW;IACf,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,IAAI,gBACN,cAAc,KAAK,CAAC,EAAE,CAAC,KAAK;aACvB,IAAI,IAAI,gBACb,YAAY,KAAK,CAAC,EAAE,CAAC,KAAK;IAE9B;IAEA,OAAO,gBAAgB,MAAM,CAAC,aAAa;QAAC,WAAW;QAAY,SAAS;IAAQ;AACtF","sources":["packages/@react-aria/calendar/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, DateFormatter, endOfMonth, isSameDay, startOfMonth} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\ninterface HookData {\n ariaLabel?: string,\n ariaLabelledBy?: string,\n errorMessageId: string,\n selectedDateDescription: string\n}\n\nexport const hookData = new WeakMap<CalendarState | RangeCalendarState, HookData>();\n\nexport function getEraFormat(date: CalendarDate | undefined): 'short' | undefined {\n return date?.calendar.identifier === 'gregory' && date.era === 'BC' ? 'short' : undefined;\n}\n\nexport function useSelectedDateDescription(state: CalendarState | RangeCalendarState) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n\n let start: CalendarDate | undefined, end: CalendarDate | undefined;\n if ('highlightedRange' in state) {\n ({start, end} = state.highlightedRange || {});\n } else {\n start = end = state.value ?? undefined;\n }\n\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era: getEraFormat(start) || getEraFormat(end),\n timeZone: state.timeZone\n });\n\n let anchorDate = 'anchorDate' in state ? state.anchorDate : null;\n return useMemo(() => {\n // No message if currently selecting a range, or there is nothing highlighted.\n if (!anchorDate && start && end) {\n // Use a single date message if the start and end dates are the same day,\n // otherwise include both dates.\n if (isSameDay(start, end)) {\n let date = dateFormatter.format(start.toDate(state.timeZone));\n return stringFormatter.format('selectedDateDescription', {date});\n } else {\n let dateRange = formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);\n\n return stringFormatter.format('selectedRangeDescription', {dateRange});\n }\n }\n return '';\n }, [start, end, anchorDate, state.timeZone, stringFormatter, dateFormatter]);\n}\n\nexport function useVisibleRangeDescription(startDate: CalendarDate, endDate: CalendarDate, timeZone: string, isAria: boolean) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let era: any = getEraFormat(startDate) || getEraFormat(endDate);\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n let dateFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n return useMemo(() => {\n // Special case for month granularity. Format as a single month if only a\n // single month is visible, otherwise format as a range of months.\n if (isSameDay(startDate, startOfMonth(startDate))) {\n if (isSameDay(endDate, endOfMonth(startDate))) {\n return monthFormatter.format(startDate.toDate(timeZone));\n } else if (isSameDay(endDate, endOfMonth(endDate))) {\n return isAria\n ? formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone)\n : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }\n }\n\n return isAria\n ? formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone)\n : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }, [startDate, endDate, monthFormatter, dateFormatter, stringFormatter, timeZone, isAria]);\n}\n\nfunction formatRange(dateFormatter: DateFormatter, stringFormatter: LocalizedStringFormatter, start: CalendarDate, end: CalendarDate, timeZone: string) {\n let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let startValue = '';\n let endValue = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n startValue += parts[i].value;\n } else if (i > separatorIndex) {\n endValue += parts[i].value;\n }\n }\n\n return stringFormatter.format('dateRange', {startDate: startValue, endDate: endValue});\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
package/dist/utils.mjs CHANGED
@@ -28,8 +28,9 @@ function $a074e1e2d0f0a665$export$134cbb7fb09a9522(date) {
28
28
  function $a074e1e2d0f0a665$export$b6df97c887c38e1a(state) {
29
29
  let stringFormatter = (0, $3HATx$useLocalizedStringFormatter)((0, ($parcel$interopDefault($3HATx$intlStringsmodulejs))), '@react-aria/calendar');
30
30
  let start, end;
31
+ var _state_value;
31
32
  if ('highlightedRange' in state) ({ start: start, end: end } = state.highlightedRange || {});
32
- else start = end = state.value;
33
+ else start = end = (_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : undefined;
33
34
  let dateFormatter = (0, $3HATx$useDateFormatter)({
34
35
  weekday: 'long',
35
36
  month: 'long',
@@ -28,8 +28,9 @@ function $a074e1e2d0f0a665$export$134cbb7fb09a9522(date) {
28
28
  function $a074e1e2d0f0a665$export$b6df97c887c38e1a(state) {
29
29
  let stringFormatter = (0, $3HATx$useLocalizedStringFormatter)((0, ($parcel$interopDefault($3HATx$intlStringsmodulejs))), '@react-aria/calendar');
30
30
  let start, end;
31
+ var _state_value;
31
32
  if ('highlightedRange' in state) ({ start: start, end: end } = state.highlightedRange || {});
32
- else start = end = state.value;
33
+ else start = end = (_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : undefined;
33
34
  let dateFormatter = (0, $3HATx$useDateFormatter)({
34
35
  weekday: 'long',
35
36
  month: 'long',
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiBM,MAAM,4CAAW,IAAI;AAErB,SAAS,0CAAa,IAAkB;IAC7C,OAAO,CAAA,iBAAA,2BAAA,KAAM,QAAQ,CAAC,UAAU,MAAK,aAAa,KAAK,GAAG,KAAK,OAAO,UAAU;AAClF;AAEO,SAAS,0CAA2B,KAAyC;IAClF,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,IAAI,OAAqB;IACzB,IAAI,sBAAsB,OACvB,CAAA,SAAC,KAAK,OAAE,GAAG,EAAC,GAAG,MAAM,gBAAgB,IAAI,CAAC,CAAA;SAE3C,QAAQ,MAAM,MAAM,KAAK;IAG3B,IAAI,gBAAgB,CAAA,GAAA,uBAAe,EAA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AAW;QAAY,SAAS;IAAQ;AACtF","sources":["packages/@react-aria/calendar/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, DateFormatter, endOfMonth, isSameDay, startOfMonth} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n errorMessageId: string,\n selectedDateDescription: string\n}\n\nexport const hookData = new WeakMap<CalendarState | RangeCalendarState, HookData>();\n\nexport function getEraFormat(date: CalendarDate): 'short' | undefined {\n return date?.calendar.identifier === 'gregory' && date.era === 'BC' ? 'short' : undefined;\n}\n\nexport function useSelectedDateDescription(state: CalendarState | RangeCalendarState) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n\n let start: CalendarDate, end: CalendarDate;\n if ('highlightedRange' in state) {\n ({start, end} = state.highlightedRange || {});\n } else {\n start = end = state.value;\n }\n\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era: getEraFormat(start) || getEraFormat(end),\n timeZone: state.timeZone\n });\n\n let anchorDate = 'anchorDate' in state ? state.anchorDate : null;\n return useMemo(() => {\n // No message if currently selecting a range, or there is nothing highlighted.\n if (!anchorDate && start && end) {\n // Use a single date message if the start and end dates are the same day,\n // otherwise include both dates.\n if (isSameDay(start, end)) {\n let date = dateFormatter.format(start.toDate(state.timeZone));\n return stringFormatter.format('selectedDateDescription', {date});\n } else {\n let dateRange = formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);\n\n return stringFormatter.format('selectedRangeDescription', {dateRange});\n }\n }\n return '';\n }, [start, end, anchorDate, state.timeZone, stringFormatter, dateFormatter]);\n}\n\nexport function useVisibleRangeDescription(startDate: CalendarDate, endDate: CalendarDate, timeZone: string, isAria: boolean) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let era: any = getEraFormat(startDate) || getEraFormat(endDate);\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n let dateFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n return useMemo(() => {\n // Special case for month granularity. Format as a single month if only a\n // single month is visible, otherwise format as a range of months.\n if (isSameDay(startDate, startOfMonth(startDate))) {\n if (isSameDay(endDate, endOfMonth(startDate))) {\n return monthFormatter.format(startDate.toDate(timeZone));\n } else if (isSameDay(endDate, endOfMonth(endDate))) {\n return isAria\n ? formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone)\n : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }\n }\n\n return isAria\n ? formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone)\n : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }, [startDate, endDate, monthFormatter, dateFormatter, stringFormatter, timeZone, isAria]);\n}\n\nfunction formatRange(dateFormatter: DateFormatter, stringFormatter: LocalizedStringFormatter, start: CalendarDate, end: CalendarDate, timeZone: string) {\n let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let startValue = '';\n let endValue = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n startValue += parts[i].value;\n } else if (i > separatorIndex) {\n endValue += parts[i].value;\n }\n }\n\n return stringFormatter.format('dateRange', {startDate: startValue, endDate: endValue});\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiBM,MAAM,4CAAW,IAAI;AAErB,SAAS,0CAAa,IAA8B;IACzD,OAAO,CAAA,iBAAA,2BAAA,KAAM,QAAQ,CAAC,UAAU,MAAK,aAAa,KAAK,GAAG,KAAK,OAAO,UAAU;AAClF;AAEO,SAAS,0CAA2B,KAAyC;IAClF,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,IAAI,OAAiC;QAIrB;IAHhB,IAAI,sBAAsB,OACvB,CAAA,SAAC,KAAK,OAAE,GAAG,EAAC,GAAG,MAAM,gBAAgB,IAAI,CAAC,CAAA;SAE3C,QAAQ,MAAM,CAAA,eAAA,MAAM,KAAK,cAAX,0BAAA,eAAe;IAG/B,IAAI,gBAAgB,CAAA,GAAA,uBAAe,EAAE;QACnC,SAAS;QACT,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK,0CAAa,UAAU,0CAAa;QACzC,UAAU,MAAM,QAAQ;IAC1B;IAEA,IAAI,aAAa,gBAAgB,QAAQ,MAAM,UAAU,GAAG;IAC5D,OAAO,CAAA,GAAA,cAAM,EAAE;QACb,8EAA8E;QAC9E,IAAI,CAAC,cAAc,SAAS;YAC1B,yEAAyE;YACzE,gCAAgC;YAChC,IAAI,CAAA,GAAA,gBAAQ,EAAE,OAAO,MAAM;gBACzB,IAAI,OAAO,cAAc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ACH,kCAAY,eAAe,iBAAiB,WAAW,SAAS,YAChE,cAAc,WAAW,CAAC,UAAU,MAAM,CAAC,WAAW,QAAQ,MAAM,CAAC;IAC3E,GAAG;QAAC;QAAW;QAAS;QAAgB;QAAe;QAAiB;QAAU;KAAO;AAC3F;AAEA,SAAS,kCAAY,aAA4B,EAAE,eAAyC,EAAE,KAAmB,EAAE,GAAiB,EAAE,QAAgB;IACpJ,IAAI,QAAQ,cAAc,kBAAkB,CAAC,MAAM,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC;IAEhF,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,iBAAiB;IACrB,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,OAAO,KAAK,CAAC,EAAE;QACnB,IAAI,KAAK,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,WAC5C,iBAAiB;aACZ,IAAI,KAAK,MAAM,KAAK,YACzB;IAEJ;IAEA,2DAA2D;IAC3D,IAAI,aAAa;IACjB,IAAI,WAAW;IACf,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,IAAI,gBACN,cAAc,KAAK,CAAC,EAAE,CAAC,KAAK;aACvB,IAAI,IAAI,gBACb,YAAY,KAAK,CAAC,EAAE,CAAC,KAAK;IAE9B;IAEA,OAAO,gBAAgB,MAAM,CAAC,aAAa;QAAC,WAAW;QAAY,SAAS;IAAQ;AACtF","sources":["packages/@react-aria/calendar/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate, DateFormatter, endOfMonth, isSameDay, startOfMonth} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\ninterface HookData {\n ariaLabel?: string,\n ariaLabelledBy?: string,\n errorMessageId: string,\n selectedDateDescription: string\n}\n\nexport const hookData = new WeakMap<CalendarState | RangeCalendarState, HookData>();\n\nexport function getEraFormat(date: CalendarDate | undefined): 'short' | undefined {\n return date?.calendar.identifier === 'gregory' && date.era === 'BC' ? 'short' : undefined;\n}\n\nexport function useSelectedDateDescription(state: CalendarState | RangeCalendarState) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n\n let start: CalendarDate | undefined, end: CalendarDate | undefined;\n if ('highlightedRange' in state) {\n ({start, end} = state.highlightedRange || {});\n } else {\n start = end = state.value ?? undefined;\n }\n\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era: getEraFormat(start) || getEraFormat(end),\n timeZone: state.timeZone\n });\n\n let anchorDate = 'anchorDate' in state ? state.anchorDate : null;\n return useMemo(() => {\n // No message if currently selecting a range, or there is nothing highlighted.\n if (!anchorDate && start && end) {\n // Use a single date message if the start and end dates are the same day,\n // otherwise include both dates.\n if (isSameDay(start, end)) {\n let date = dateFormatter.format(start.toDate(state.timeZone));\n return stringFormatter.format('selectedDateDescription', {date});\n } else {\n let dateRange = formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);\n\n return stringFormatter.format('selectedRangeDescription', {dateRange});\n }\n }\n return '';\n }, [start, end, anchorDate, state.timeZone, stringFormatter, dateFormatter]);\n}\n\nexport function useVisibleRangeDescription(startDate: CalendarDate, endDate: CalendarDate, timeZone: string, isAria: boolean) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let era: any = getEraFormat(startDate) || getEraFormat(endDate);\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n let dateFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n return useMemo(() => {\n // Special case for month granularity. Format as a single month if only a\n // single month is visible, otherwise format as a range of months.\n if (isSameDay(startDate, startOfMonth(startDate))) {\n if (isSameDay(endDate, endOfMonth(startDate))) {\n return monthFormatter.format(startDate.toDate(timeZone));\n } else if (isSameDay(endDate, endOfMonth(endDate))) {\n return isAria\n ? formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone)\n : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }\n }\n\n return isAria\n ? formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone)\n : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }, [startDate, endDate, monthFormatter, dateFormatter, stringFormatter, timeZone, isAria]);\n}\n\nfunction formatRange(dateFormatter: DateFormatter, stringFormatter: LocalizedStringFormatter, start: CalendarDate, end: CalendarDate, timeZone: string) {\n let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let startValue = '';\n let endValue = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n startValue += parts[i].value;\n } else if (i > separatorIndex) {\n endValue += parts[i].value;\n }\n }\n\n return stringFormatter.format('dateRange', {startDate: startValue, endDate: endValue});\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,aAAa,CAAC,OAAS,CAAC,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,8BAA8B,CAAC,wFAAW,CAAC;IAC3C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,CAAC;IAC/D,6BAA6B,CAAC,wFAAW,CAAC;IAC1C,aAAa,CAAC,OAAS,CAAC,iCAAK,EAAE,KAAK,IAAI,CAAC,CAAC;IAC1C,qBAAqB,CAAC,OAAS,CAAC,yDAAQ,EAAE,KAAK,IAAI,CAAC,CAAC;AACvD","sources":["packages/@react-aria/calendar/intl/zh-CN.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已选择 {date}\",\n \"finishRangeSelectionPrompt\": \"单击以完成选择日期范围\",\n \"maximumDate\": \"最后一个可用日期\",\n \"minimumDate\": \"第一个可用日期\",\n \"next\": \"下一页\",\n \"previous\": \"上一页\",\n \"selectedDateDescription\": \"选定的日期:{date}\",\n \"selectedRangeDescription\": \"选定的范围:{dateRange}\",\n \"startRangeSelectionPrompt\": \"单击以开始选择日期范围\",\n \"todayDate\": \"今天,即 {date}\",\n \"todayDateSelected\": \"已选择今天,即 {date}\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
1
+ {"mappings":"AAAA,iBAAiB;IAAG,aAAa,CAAC,OAAS,GAAG,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,EAAE;IAC5C,8BAA8B,CAAC,wFAAW,CAAC;IAC3C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,EAAE;IAC/D,6BAA6B,CAAC,wFAAW,CAAC;IAC1C,aAAa,CAAC,OAAS,CAAC,iCAAK,EAAE,KAAK,IAAI,EAAE;IAC1C,qBAAqB,CAAC,OAAS,CAAC,yDAAQ,EAAE,KAAK,IAAI,EAAE;AACvD","sources":["packages/@react-aria/calendar/intl/zh-CN.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已选择 {date}\",\n \"finishRangeSelectionPrompt\": \"单击以完成选择日期范围\",\n \"maximumDate\": \"最后一个可用日期\",\n \"minimumDate\": \"第一个可用日期\",\n \"next\": \"下一页\",\n \"previous\": \"上一页\",\n \"selectedDateDescription\": \"选定的日期:{date}\",\n \"selectedRangeDescription\": \"选定的范围:{dateRange}\",\n \"startRangeSelectionPrompt\": \"单击以开始选择日期范围\",\n \"todayDate\": \"今天,即 {date}\",\n \"todayDateSelected\": \"已选择今天,即 {date}\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,aAAa,CAAC,OAAS,CAAC,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,8BAA8B,CAAC,wFAAW,CAAC;IAC3C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,CAAC;IAC/D,6BAA6B,CAAC,wFAAW,CAAC;IAC1C,aAAa,CAAC,OAAS,CAAC,iCAAK,EAAE,KAAK,IAAI,CAAC,CAAC;IAC1C,qBAAqB,CAAC,OAAS,CAAC,yDAAQ,EAAE,KAAK,IAAI,CAAC,CAAC;AACvD","sources":["packages/@react-aria/calendar/intl/zh-CN.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已选择 {date}\",\n \"finishRangeSelectionPrompt\": \"单击以完成选择日期范围\",\n \"maximumDate\": \"最后一个可用日期\",\n \"minimumDate\": \"第一个可用日期\",\n \"next\": \"下一页\",\n \"previous\": \"上一页\",\n \"selectedDateDescription\": \"选定的日期:{date}\",\n \"selectedRangeDescription\": \"选定的范围:{dateRange}\",\n \"startRangeSelectionPrompt\": \"单击以开始选择日期范围\",\n \"todayDate\": \"今天,即 {date}\",\n \"todayDateSelected\": \"已选择今天,即 {date}\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,aAAa,CAAC,OAAS,GAAG,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,EAAE;IAC5C,8BAA8B,CAAC,wFAAW,CAAC;IAC3C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,EAAE;IAC/D,6BAA6B,CAAC,wFAAW,CAAC;IAC1C,aAAa,CAAC,OAAS,CAAC,iCAAK,EAAE,KAAK,IAAI,EAAE;IAC1C,qBAAqB,CAAC,OAAS,CAAC,yDAAQ,EAAE,KAAK,IAAI,EAAE;AACvD","sources":["packages/@react-aria/calendar/intl/zh-CN.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已选择 {date}\",\n \"finishRangeSelectionPrompt\": \"单击以完成选择日期范围\",\n \"maximumDate\": \"最后一个可用日期\",\n \"minimumDate\": \"第一个可用日期\",\n \"next\": \"下一页\",\n \"previous\": \"上一页\",\n \"selectedDateDescription\": \"选定的日期:{date}\",\n \"selectedRangeDescription\": \"选定的范围:{dateRange}\",\n \"startRangeSelectionPrompt\": \"单击以开始选择日期范围\",\n \"todayDate\": \"今天,即 {date}\",\n \"todayDateSelected\": \"已选择今天,即 {date}\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,iBAAiB;IAAG,aAAa,CAAC,OAAS,CAAC,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,8BAA8B,CAAC,gGAAY,CAAC;IAC5C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,CAAC;IAC/D,6BAA6B,CAAC,gGAAY,CAAC;IAC3C,aAAa,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,IAAI,CAAC,CAAC;IACxC,qBAAqB,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;AACrD","sources":["packages/@react-aria/calendar/intl/zh-TW.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已選取 {date}\",\n \"finishRangeSelectionPrompt\": \"按一下以完成選取日期範圍\",\n \"maximumDate\": \"最後一個可用日期\",\n \"minimumDate\": \"第一個可用日期\",\n \"next\": \"下一頁\",\n \"previous\": \"上一頁\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{dateRange}\",\n \"startRangeSelectionPrompt\": \"按一下以開始選取日期範圍\",\n \"todayDate\": \"今天,{date}\",\n \"todayDateSelected\": \"已選取今天,{date}\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
1
+ {"mappings":"AAAA,iBAAiB;IAAG,aAAa,CAAC,OAAS,GAAG,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,EAAE;IAC5C,8BAA8B,CAAC,gGAAY,CAAC;IAC5C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,EAAE;IAC/D,6BAA6B,CAAC,gGAAY,CAAC;IAC3C,aAAa,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,IAAI,EAAE;IACxC,qBAAqB,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;AACrD","sources":["packages/@react-aria/calendar/intl/zh-TW.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已選取 {date}\",\n \"finishRangeSelectionPrompt\": \"按一下以完成選取日期範圍\",\n \"maximumDate\": \"最後一個可用日期\",\n \"minimumDate\": \"第一個可用日期\",\n \"next\": \"下一頁\",\n \"previous\": \"上一頁\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{dateRange}\",\n \"startRangeSelectionPrompt\": \"按一下以開始選取日期範圍\",\n \"todayDate\": \"今天,{date}\",\n \"todayDateSelected\": \"已選取今天,{date}\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
@@ -1 +1 @@
1
- {"mappings":";AAAA,4BAAiB;IAAG,aAAa,CAAC,OAAS,CAAC,EAAE,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,CAAC,CAAC;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,CAAC,CAAC;IAC5C,8BAA8B,CAAC,gGAAY,CAAC;IAC5C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,CAAC,CAAC;IAC/D,6BAA6B,CAAC,gGAAY,CAAC;IAC3C,aAAa,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,IAAI,CAAC,CAAC;IACxC,qBAAqB,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,CAAC,CAAC;AACrD","sources":["packages/@react-aria/calendar/intl/zh-TW.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已選取 {date}\",\n \"finishRangeSelectionPrompt\": \"按一下以完成選取日期範圍\",\n \"maximumDate\": \"最後一個可用日期\",\n \"minimumDate\": \"第一個可用日期\",\n \"next\": \"下一頁\",\n \"previous\": \"上一頁\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{dateRange}\",\n \"startRangeSelectionPrompt\": \"按一下以開始選取日期範圍\",\n \"todayDate\": \"今天,{date}\",\n \"todayDateSelected\": \"已選取今天,{date}\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
1
+ {"mappings":";AAAA,4BAAiB;IAAG,aAAa,CAAC,OAAS,GAAG,KAAK,SAAS,CAAC,UAAG,EAAE,KAAK,OAAO,EAAE;IAC9E,gBAAgB,CAAC,OAAS,CAAC,yBAAI,EAAE,KAAK,IAAI,EAAE;IAC5C,8BAA8B,CAAC,gGAAY,CAAC;IAC5C,eAAe,CAAC,gEAAQ,CAAC;IACzB,eAAe,CAAC,wDAAO,CAAC;IACxB,QAAQ,CAAC,wBAAG,CAAC;IACb,YAAY,CAAC,wBAAG,CAAC;IACjB,2BAA2B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;IACzD,4BAA4B,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,SAAS,EAAE;IAC/D,6BAA6B,CAAC,gGAAY,CAAC;IAC3C,aAAa,CAAC,OAAS,CAAC,wBAAG,EAAE,KAAK,IAAI,EAAE;IACxC,qBAAqB,CAAC,OAAS,CAAC,gDAAM,EAAE,KAAK,IAAI,EAAE;AACrD","sources":["packages/@react-aria/calendar/intl/zh-TW.json"],"sourcesContent":["{\n \"dateRange\": \"{startDate} 至 {endDate}\",\n \"dateSelected\": \"已選取 {date}\",\n \"finishRangeSelectionPrompt\": \"按一下以完成選取日期範圍\",\n \"maximumDate\": \"最後一個可用日期\",\n \"minimumDate\": \"第一個可用日期\",\n \"next\": \"下一頁\",\n \"previous\": \"上一頁\",\n \"selectedDateDescription\": \"選定的日期:{date}\",\n \"selectedRangeDescription\": \"選定的範圍:{dateRange}\",\n \"startRangeSelectionPrompt\": \"按一下以開始選取日期範圍\",\n \"todayDate\": \"今天,{date}\",\n \"todayDateSelected\": \"已選取今天,{date}\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/calendar",
3
- "version": "3.5.13",
3
+ "version": "3.7.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,23 +22,23 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@internationalized/date": "^3.5.6",
26
- "@react-aria/i18n": "^3.12.3",
27
- "@react-aria/interactions": "^3.22.4",
28
- "@react-aria/live-announcer": "^3.4.0",
29
- "@react-aria/utils": "^3.25.3",
30
- "@react-stately/calendar": "^3.5.5",
31
- "@react-types/button": "^3.10.0",
32
- "@react-types/calendar": "^3.4.10",
33
- "@react-types/shared": "^3.25.0",
25
+ "@internationalized/date": "^3.7.0",
26
+ "@react-aria/i18n": "^3.12.5",
27
+ "@react-aria/interactions": "^3.23.0",
28
+ "@react-aria/live-announcer": "^3.4.1",
29
+ "@react-aria/utils": "^3.27.0",
30
+ "@react-stately/calendar": "^3.7.0",
31
+ "@react-types/button": "^3.10.2",
32
+ "@react-types/calendar": "^3.6.0",
33
+ "@react-types/shared": "^3.27.0",
34
34
  "@swc/helpers": "^0.5.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
38
- "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
37
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
38
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "8e0a28d188cdbdbd2b32296fa034b1b02ddde229"
43
+ "gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
44
44
  }
@@ -74,7 +74,7 @@ export interface CalendarCellAria {
74
74
  */
75
75
  export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarState | RangeCalendarState, ref: RefObject<HTMLElement | null>): CalendarCellAria {
76
76
  let {date, isDisabled} = props;
77
- let {errorMessageId, selectedDateDescription} = hookData.get(state);
77
+ let {errorMessageId, selectedDateDescription} = hookData.get(state)!;
78
78
  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');
79
79
  let dateFormatter = useDateFormatter({
80
80
  weekday: 'long',
@@ -89,7 +89,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
89
89
  isDisabled = isDisabled || state.isCellDisabled(date);
90
90
  let isUnavailable = state.isCellUnavailable(date);
91
91
  let isSelectable = !isDisabled && !isUnavailable;
92
- let isInvalid = state.isValueInvalid && (
92
+ let isInvalid = state.isValueInvalid && Boolean(
93
93
  'highlightedRange' in state
94
94
  ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0
95
95
  : state.value && isSameDay(state.value, date)
@@ -159,7 +159,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
159
159
 
160
160
  let isAnchorPressed = useRef(false);
161
161
  let isRangeBoundaryPressed = useRef(false);
162
- let touchDragTimerRef = useRef(null);
162
+ let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
163
163
  let {pressProps, isPressed} = usePress({
164
164
  // When dragging to select a range, we don't want dragging over the original anchor
165
165
  // again to trigger onPressStart. Cancel presses immediately when the pointer exits.
@@ -195,7 +195,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
195
195
 
196
196
  let startDragging = () => {
197
197
  state.setDragging(true);
198
- touchDragTimerRef.current = null;
198
+ touchDragTimerRef.current = undefined;
199
199
 
200
200
  state.selectDate(date);
201
201
  state.setFocusedDate(date);
@@ -215,7 +215,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
215
215
  isRangeBoundaryPressed.current = false;
216
216
  isAnchorPressed.current = false;
217
217
  clearTimeout(touchDragTimerRef.current);
218
- touchDragTimerRef.current = null;
218
+ touchDragTimerRef.current = undefined;
219
219
  },
220
220
  onPress() {
221
221
  // For non-range selection, always select on press up.
@@ -269,7 +269,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
269
269
  }
270
270
  });
271
271
 
272
- let tabIndex = null;
272
+ let tabIndex: number | undefined = undefined;
273
273
  if (!isDisabled) {
274
274
  tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;
275
275
  }
@@ -298,14 +298,14 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
298
298
  calendar: date.calendar.identifier
299
299
  });
300
300
 
301
- let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day').value, [cellDateFormatter, nativeDate]);
301
+ let formattedDate = useMemo(() => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value, [cellDateFormatter, nativeDate]);
302
302
 
303
303
  return {
304
304
  cellProps: {
305
305
  role: 'gridcell',
306
- 'aria-disabled': !isSelectable || null,
307
- 'aria-selected': isSelected || null,
308
- 'aria-invalid': isInvalid || null
306
+ 'aria-disabled': !isSelectable || undefined,
307
+ 'aria-selected': isSelected || undefined,
308
+ 'aria-invalid': isInvalid || undefined
309
309
  },
310
310
  buttonProps: mergeProps(pressProps, {
311
311
  onFocus() {
@@ -315,11 +315,11 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
315
315
  },
316
316
  tabIndex,
317
317
  role: 'button',
318
- 'aria-disabled': !isSelectable || null,
318
+ 'aria-disabled': !isSelectable || undefined,
319
319
  'aria-label': label,
320
- 'aria-invalid': isInvalid || null,
320
+ 'aria-invalid': isInvalid || undefined,
321
321
  'aria-describedby': [
322
- isInvalid ? errorMessageId : null,
322
+ isInvalid ? errorMessageId : undefined,
323
323
  descriptionProps['aria-describedby']
324
324
  ].filter(Boolean).join(' ') || undefined,
325
325
  onPointerEnter(e) {