UNPKG

@react-spectrum/s2

Version:
131 lines (114 loc) 6.42 kB
require("./RangeCalendar.css"); var $e9e9a0d15c3364d7$exports = require("./Calendar.cjs"); var $4f683da24e35b31a$exports = require("../icons/ChevronLeft.cjs"); var $f76eebe9b8ebc714$exports = require("../icons/ChevronRight.cjs"); var $6367bc87eb7d24ad$exports = require("./Content.cjs"); var $a0b996a550bb0891$exports = require("./Field.cjs"); var $4526404114e78c80$exports = require("./intlStrings.cjs"); var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs"); var $3M0RL$reactjsxruntime = require("react/jsx-runtime"); var $3M0RL$reactariacomponents = require("react-aria-components"); var $3M0RL$react = require("react"); var $3M0RL$reactariai18n = require("@react-aria/i18n"); function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "RangeCalendarContext", () => $ad2936801c627ac5$export$233dd9682e1ad64b); $parcel$export(module.exports, "RangeCalendar", () => $ad2936801c627ac5$export$a4f5c8b89d277a8d); /* * 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 $ad2936801c627ac5$export$233dd9682e1ad64b = /*#__PURE__*/ (0, $3M0RL$react.createContext)(null); const $ad2936801c627ac5$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 $ad2936801c627ac5$var$headerStyles = " sd1 eb1 _Ce1 Za1"; const $ad2936801c627ac5$export$a4f5c8b89d277a8d = /*#__PURE__*/ (0, $3M0RL$react.forwardRef)(function RangeCalendar(props, ref) { [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $ad2936801c627ac5$export$233dd9682e1ad64b); let { visibleMonths: visibleMonths = 1, errorMessage: errorMessage, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, ...otherProps } = props; let stringFormatter = (0, $3M0RL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2'); return /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $3M0RL$reactariacomponents.RangeCalendar), { ...otherProps, ref: ref, visibleDuration: { months: visibleMonths }, style: UNSAFE_style, className: (UNSAFE_className || '') + $ad2936801c627ac5$var$calendarStyles(null, styles), children: ({ isInvalid: isInvalid, isDisabled: isDisabled })=>{ return /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsxs)((0, $3M0RL$reactjsxruntime.Fragment), { children: [ /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $3M0RL$reactariacomponents.Provider), { values: [ [ (0, $6367bc87eb7d24ad$exports.HeaderContext), null ], [ (0, $6367bc87eb7d24ad$exports.HeadingContext), null ] ], children: /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsxs)((0, $6367bc87eb7d24ad$exports.Header), { styles: $ad2936801c627ac5$var$headerStyles, children: [ /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $e9e9a0d15c3364d7$exports.CalendarButton), { slot: "previous", children: /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $4f683da24e35b31a$exports.default), {}) }), /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $e9e9a0d15c3364d7$exports.CalendarHeading), {}), /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $e9e9a0d15c3364d7$exports.CalendarButton), { slot: "next", children: /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $f76eebe9b8ebc714$exports.default), {}) }) ] }) }), /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)("div", { className: " sd1 _tc1 Uj1 qj1 Za1 ed1", children: Array.from({ length: visibleMonths }).map((_, i)=>/*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $e9e9a0d15c3364d7$exports.CalendarGrid), { months: i }, i)) }), isInvalid && /*#__PURE__*/ (0, $3M0RL$reactjsxruntime.jsx)((0, $3M0RL$reactariacomponents.Text), { slot: "errorMessage", className: (0, $a0b996a550bb0891$exports.helpTextStyles)({ isInvalid: isInvalid, isDisabled: isDisabled, size: 'M' }), children: errorMessage || stringFormatter.format('calendar.invalidSelection', { selectedCount: 2 }) }) ] }); } }); }); //# sourceMappingURL=RangeCalendar.cjs.map