UNPKG

@react-spectrum/s2

Version:
125 lines (110 loc) 6.54 kB
import "./RangeCalendar.css"; import {CalendarButton as $f06f4d5597ad704c$export$adb29da0ac001538, CalendarGrid as $f06f4d5597ad704c$export$5bd780d491cfc46c, CalendarHeading as $f06f4d5597ad704c$export$77af08ed164baa7} from "./Calendar.mjs"; import $5c3fed25abf344cc$export$2e2bcd8739ae039 from "../icons/ChevronLeft.mjs"; import $04f4b15c8c66bb2a$export$2e2bcd8739ae039 from "../icons/ChevronRight.mjs"; import {Header as $8e847109a6ab556d$export$8b251419efc915eb, HeaderContext as $8e847109a6ab556d$export$e0e4026c12a8bdbb, HeadingContext as $8e847109a6ab556d$export$d688439359537581} from "./Content.mjs"; import {helpTextStyles as $9afd80978c252040$export$13b1fd5431595bf6} from "./Field.mjs"; import $6je1a$intlStringsmjs from "./intlStrings.mjs"; import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs"; import {jsx as $6je1a$jsx, jsxs as $6je1a$jsxs, Fragment as $6je1a$Fragment} from "react/jsx-runtime"; import {RangeCalendar as $6je1a$RangeCalendar, Provider as $6je1a$Provider, Text as $6je1a$Text} from "react-aria-components"; import {createContext as $6je1a$createContext, forwardRef as $6je1a$forwardRef} from "react"; import {useLocalizedStringFormatter as $6je1a$useLocalizedStringFormatter} from "@react-aria/i18n"; function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } /* * Copyright 2024 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ const $ecdee84c2f0ddfb5$export$233dd9682e1ad64b = /*#__PURE__*/ (0, $6je1a$createContext)(null); const $ecdee84c2f0ddfb5$var$calendarStyles = function anonymous(props, overrides) { let rules = " "; let width = false; let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g); for (let p of matches){ if (p[1] === "Z") width = true; rules += p[0]; } rules += ' sd1'; rules += ' _ta1'; rules += ' Uj1'; rules += ' qj1'; if (!width) rules += ' ZJ1'; return rules; }; const $ecdee84c2f0ddfb5$var$headerStyles = " sd1 eb1 _Ce1 Za1"; const $ecdee84c2f0ddfb5$export$a4f5c8b89d277a8d = /*#__PURE__*/ (0, $6je1a$forwardRef)(function RangeCalendar(props, ref) { [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $ecdee84c2f0ddfb5$export$233dd9682e1ad64b); let { visibleMonths: visibleMonths = 1, errorMessage: errorMessage, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, ...otherProps } = props; let stringFormatter = (0, $6je1a$useLocalizedStringFormatter)((0, ($parcel$interopDefault($6je1a$intlStringsmjs))), '@react-spectrum/s2'); return /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$RangeCalendar), { ...otherProps, ref: ref, visibleDuration: { months: visibleMonths }, style: UNSAFE_style, className: (UNSAFE_className || '') + $ecdee84c2f0ddfb5$var$calendarStyles(null, styles), children: ({ isInvalid: isInvalid, isDisabled: isDisabled })=>{ return /*#__PURE__*/ (0, $6je1a$jsxs)((0, $6je1a$Fragment), { children: [ /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$Provider), { values: [ [ (0, $8e847109a6ab556d$export$e0e4026c12a8bdbb), null ], [ (0, $8e847109a6ab556d$export$d688439359537581), null ] ], children: /*#__PURE__*/ (0, $6je1a$jsxs)((0, $8e847109a6ab556d$export$8b251419efc915eb), { styles: $ecdee84c2f0ddfb5$var$headerStyles, children: [ /*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$adb29da0ac001538), { slot: "previous", children: /*#__PURE__*/ (0, $6je1a$jsx)((0, $5c3fed25abf344cc$export$2e2bcd8739ae039), {}) }), /*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$77af08ed164baa7), {}), /*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$adb29da0ac001538), { slot: "next", children: /*#__PURE__*/ (0, $6je1a$jsx)((0, $04f4b15c8c66bb2a$export$2e2bcd8739ae039), {}) }) ] }) }), /*#__PURE__*/ (0, $6je1a$jsx)("div", { className: " sd1 _tc1 Uj1 qj1 Za1 ed1", children: Array.from({ length: visibleMonths }).map((_, i)=>/*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$5bd780d491cfc46c), { months: i }, i)) }), isInvalid && /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$Text), { slot: "errorMessage", className: (0, $9afd80978c252040$export$13b1fd5431595bf6)({ isInvalid: isInvalid, isDisabled: isDisabled, size: 'M' }), children: errorMessage || stringFormatter.format('calendar.invalidSelection', { selectedCount: 2 }) }) ] }); } }); }); export {$ecdee84c2f0ddfb5$export$233dd9682e1ad64b as RangeCalendarContext, $ecdee84c2f0ddfb5$export$a4f5c8b89d277a8d as RangeCalendar}; //# sourceMappingURL=RangeCalendar.mjs.map