2024-06-15 00:55:43 +03:00

1534 lines
58 KiB
JavaScript

import $b3427c06585c22a0$exports from "./ar-AE.module.js";
import $d282528f459122b9$exports from "./bg-BG.module.js";
import $2d5eecd634a9ca45$exports from "./cs-CZ.module.js";
import $c8e2288226c24a67$exports from "./da-DK.module.js";
import $6f5745e389c346d7$exports from "./de-DE.module.js";
import $8c882ccf4300d1da$exports from "./el-GR.module.js";
import $22195056771860be$exports from "./en-US.module.js";
import $cedfa43b4e2a5906$exports from "./es-ES.module.js";
import $eeeaa8daee3601c7$exports from "./et-EE.module.js";
import $35e0614a49b3bb40$exports from "./fi-FI.module.js";
import $929bc63f7705a78f$exports from "./fr-FR.module.js";
import $9a28d073b034d183$exports from "./he-IL.module.js";
import $7743e79780ebcca3$exports from "./hr-HR.module.js";
import $3351817a04898858$exports from "./hu-HU.module.js";
import $4120bdb1d03484db$exports from "./it-IT.module.js";
import $65e5e1569f34ea4f$exports from "./ja-JP.module.js";
import $d34552a7550967e7$exports from "./ko-KR.module.js";
import $8f855bffe63f6eca$exports from "./lt-LT.module.js";
import $ce40f46d09034645$exports from "./lv-LV.module.js";
import $dd1a9a73340c793e$exports from "./nb-NO.module.js";
import $4ee1fb3f0cbe6f59$exports from "./nl-NL.module.js";
import $c85829aebb0bc94b$exports from "./pl-PL.module.js";
import $27f5cd2291ca8a02$exports from "./pt-BR.module.js";
import $e046fdccd69bea8e$exports from "./pt-PT.module.js";
import $fa5f88e804986547$exports from "./ro-RO.module.js";
import $28e4714602d1b568$exports from "./ru-RU.module.js";
import $4e3bc8cf783ad569$exports from "./sk-SK.module.js";
import $bee07513333bdc15$exports from "./sl-SI.module.js";
import $7ed9c6fad16a15ec$exports from "./sr-SP.module.js";
import $8bef6d5a236de86c$exports from "./sv-SE.module.js";
import $098b9a2d2340cfc5$exports from "./tr-TR.module.js";
import $54a862ea7fad7419$exports from "./uk-UA.module.js";
import $e6cc491d590dfda5$exports from "./zh-CN.module.js";
import $9aebf53181a474bd$exports from "./zh-TW.module.js";
import {toCalendarDate as $7UzoM$toCalendarDate, toCalendarDateTime as $7UzoM$toCalendarDateTime, DateFormatter as $7UzoM$DateFormatter, Time as $7UzoM$Time, toCalendar as $7UzoM$toCalendar, now as $7UzoM$now, GregorianCalendar as $7UzoM$GregorianCalendar, getMinimumMonthInYear as $7UzoM$getMinimumMonthInYear, getMinimumDayInMonth as $7UzoM$getMinimumDayInMonth, toZoned as $7UzoM$toZoned, toTime as $7UzoM$toTime, today as $7UzoM$today, getLocalTimeZone as $7UzoM$getLocalTimeZone} from "@internationalized/date";
import {useFormValidationState as $7UzoM$useFormValidationState, mergeValidation as $7UzoM$mergeValidation, VALID_VALIDITY_STATE as $7UzoM$VALID_VALIDITY_STATE} from "@react-stately/form";
import {useOverlayTriggerState as $7UzoM$useOverlayTriggerState} from "@react-stately/overlays";
import {useControlledState as $7UzoM$useControlledState} from "@react-stately/utils";
import {useState as $7UzoM$useState, useMemo as $7UzoM$useMemo, useRef as $7UzoM$useRef, useEffect as $7UzoM$useEffect, useCallback as $7UzoM$useCallback} from "react";
import {LocalizedStringDictionary as $7UzoM$LocalizedStringDictionary, LocalizedStringFormatter as $7UzoM$LocalizedStringFormatter} from "@internationalized/string";
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
var $452ac34de8c2444e$exports = {};
$452ac34de8c2444e$exports = {
"ar-AE": $b3427c06585c22a0$exports,
"bg-BG": $d282528f459122b9$exports,
"cs-CZ": $2d5eecd634a9ca45$exports,
"da-DK": $c8e2288226c24a67$exports,
"de-DE": $6f5745e389c346d7$exports,
"el-GR": $8c882ccf4300d1da$exports,
"en-US": $22195056771860be$exports,
"es-ES": $cedfa43b4e2a5906$exports,
"et-EE": $eeeaa8daee3601c7$exports,
"fi-FI": $35e0614a49b3bb40$exports,
"fr-FR": $929bc63f7705a78f$exports,
"he-IL": $9a28d073b034d183$exports,
"hr-HR": $7743e79780ebcca3$exports,
"hu-HU": $3351817a04898858$exports,
"it-IT": $4120bdb1d03484db$exports,
"ja-JP": $65e5e1569f34ea4f$exports,
"ko-KR": $d34552a7550967e7$exports,
"lt-LT": $8f855bffe63f6eca$exports,
"lv-LV": $ce40f46d09034645$exports,
"nb-NO": $dd1a9a73340c793e$exports,
"nl-NL": $4ee1fb3f0cbe6f59$exports,
"pl-PL": $c85829aebb0bc94b$exports,
"pt-BR": $27f5cd2291ca8a02$exports,
"pt-PT": $e046fdccd69bea8e$exports,
"ro-RO": $fa5f88e804986547$exports,
"ru-RU": $28e4714602d1b568$exports,
"sk-SK": $4e3bc8cf783ad569$exports,
"sl-SI": $bee07513333bdc15$exports,
"sr-SP": $7ed9c6fad16a15ec$exports,
"sv-SE": $8bef6d5a236de86c$exports,
"tr-TR": $098b9a2d2340cfc5$exports,
"uk-UA": $54a862ea7fad7419$exports,
"zh-CN": $e6cc491d590dfda5$exports,
"zh-TW": $9aebf53181a474bd$exports
};
const $35a22f14a1f04b11$var$dictionary = new (0, $7UzoM$LocalizedStringDictionary)((0, (/*@__PURE__*/$parcel$interopDefault($452ac34de8c2444e$exports))));
function $35a22f14a1f04b11$var$getLocale() {
// Match browser language setting here, NOT react-aria's I18nProvider, so that we match other browser-provided
// validation messages, which to not respect our provider's language.
// @ts-ignore
return typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
}
function $35a22f14a1f04b11$export$f18627323ab57ac0(value, minValue, maxValue, isDateUnavailable, options) {
let rangeOverflow = value != null && maxValue != null && value.compare(maxValue) > 0;
let rangeUnderflow = value != null && minValue != null && value.compare(minValue) < 0;
let isUnavailable = value != null && (isDateUnavailable === null || isDateUnavailable === void 0 ? void 0 : isDateUnavailable(value)) || false;
let isInvalid = rangeOverflow || rangeUnderflow || isUnavailable;
let errors = [];
if (isInvalid) {
let locale = $35a22f14a1f04b11$var$getLocale();
let strings = (0, $7UzoM$LocalizedStringDictionary).getGlobalDictionaryForPackage("@react-stately/datepicker") || $35a22f14a1f04b11$var$dictionary;
let formatter = new (0, $7UzoM$LocalizedStringFormatter)(locale, strings);
let dateFormatter = new (0, $7UzoM$DateFormatter)(locale, $35a22f14a1f04b11$export$7e319ea407e63bc0({}, options));
let timeZone = dateFormatter.resolvedOptions().timeZone;
if (rangeUnderflow) errors.push(formatter.format("rangeUnderflow", {
minValue: dateFormatter.format(minValue.toDate(timeZone))
}));
if (rangeOverflow) errors.push(formatter.format("rangeOverflow", {
maxValue: dateFormatter.format(maxValue.toDate(timeZone))
}));
if (isUnavailable) errors.push(formatter.format("unavailableDate"));
}
return {
isInvalid: isInvalid,
validationErrors: errors,
validationDetails: {
badInput: isUnavailable,
customError: false,
patternMismatch: false,
rangeOverflow: rangeOverflow,
rangeUnderflow: rangeUnderflow,
stepMismatch: false,
tooLong: false,
tooShort: false,
typeMismatch: false,
valueMissing: false,
valid: !isInvalid
}
};
}
function $35a22f14a1f04b11$export$80ff8fc0ae339c13(value, minValue, maxValue, isDateUnavailable, options) {
let startValidation = $35a22f14a1f04b11$export$f18627323ab57ac0(value === null || value === void 0 ? void 0 : value.start, minValue, maxValue, isDateUnavailable, options);
let endValidation = $35a22f14a1f04b11$export$f18627323ab57ac0(value === null || value === void 0 ? void 0 : value.end, minValue, maxValue, isDateUnavailable, options);
let result = (0, $7UzoM$mergeValidation)(startValidation, endValidation);
if (value.end != null && value.start != null && value.end.compare(value.start) < 0) result = (0, $7UzoM$mergeValidation)(result, {
isInvalid: true,
validationErrors: [
$35a22f14a1f04b11$var$dictionary.getStringForLocale("rangeReversed", $35a22f14a1f04b11$var$getLocale())
],
validationDetails: {
...(0, $7UzoM$VALID_VALIDITY_STATE),
rangeUnderflow: true,
rangeOverflow: true,
valid: false
}
});
return result;
}
const $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS = {
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "2-digit",
second: "2-digit"
};
const $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS = {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
};
function $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, options) {
let defaultFieldOptions = options.shouldForceLeadingZeros ? $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS : $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS;
fieldOptions = {
...defaultFieldOptions,
...fieldOptions
};
let granularity = options.granularity || "minute";
let keys = Object.keys(fieldOptions);
var _options_maxGranularity;
let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity : "year");
if (startIdx < 0) startIdx = 0;
let endIdx = keys.indexOf(granularity);
if (endIdx < 0) endIdx = 2;
if (startIdx > endIdx) throw new Error("maxGranularity must be greater than granularity");
let opts = keys.slice(startIdx, endIdx + 1).reduce((opts, key)=>{
opts[key] = fieldOptions[key];
return opts;
}, {});
if (options.hourCycle != null) opts.hour12 = options.hourCycle === 12;
opts.timeZone = options.timeZone || "UTC";
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
if (hasTime && options.timeZone && !options.hideTimeZone) opts.timeZoneName = "short";
if (options.showEra && startIdx === 0) opts.era = "short";
return opts;
}
function $35a22f14a1f04b11$export$c5221a78ef73c5e9(placeholderValue) {
if (placeholderValue && "hour" in placeholderValue) return placeholderValue;
return new (0, $7UzoM$Time)();
}
function $35a22f14a1f04b11$export$61a490a80c552550(value, calendar) {
if (value === null) return null;
if (!value) return undefined;
return (0, $7UzoM$toCalendar)(value, calendar);
}
function $35a22f14a1f04b11$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
if (placeholderValue) return $35a22f14a1f04b11$export$61a490a80c552550(placeholderValue, calendar);
let date = (0, $7UzoM$toCalendar)((0, $7UzoM$now)(timeZone).set({
hour: 0,
minute: 0,
second: 0,
millisecond: 0
}), calendar);
if (granularity === "year" || granularity === "month" || granularity === "day") return (0, $7UzoM$toCalendarDate)(date);
if (!timeZone) return (0, $7UzoM$toCalendarDateTime)(date);
return date;
}
function $35a22f14a1f04b11$export$2440da353cedad43(v, granularity) {
// Compute default granularity and time zone from the value. If the value becomes null, keep the last values.
let defaultTimeZone = v && "timeZone" in v ? v.timeZone : undefined;
let defaultGranularity = v && "minute" in v ? "minute" : "day";
// props.granularity must actually exist in the value if one is provided.
if (v && granularity && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
let [lastValue, setLastValue] = (0, $7UzoM$useState)([
defaultGranularity,
defaultTimeZone
]);
// If the granularity or time zone changed, update the last value.
if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone)) setLastValue([
defaultGranularity,
defaultTimeZone
]);
if (!granularity) granularity = v ? defaultGranularity : lastValue[0];
let timeZone = v ? defaultTimeZone : lastValue[1];
return [
granularity,
timeZone
];
}
function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
let overlayState = (0, $7UzoM$useOverlayTriggerState)(props);
let [value, setValue] = (0, $7UzoM$useControlledState)(props.value, props.defaultValue || null, props.onChange);
let v = value || props.placeholderValue;
let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
var _props_shouldCloseOnSelect;
let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
let [selectedDate, setSelectedDate] = (0, $7UzoM$useState)(null);
let [selectedTime, setSelectedTime] = (0, $7UzoM$useState)(null);
if (value) {
selectedDate = value;
if ("hour" in value) selectedTime = value;
}
// props.granularity must actually exist in the value if one is provided.
if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
let showEra = (value === null || value === void 0 ? void 0 : value.calendar.identifier) === "gregory" && value.era === "BC";
let formatOpts = (0, $7UzoM$useMemo)(()=>({
granularity: granularity,
timeZone: defaultTimeZone,
hideTimeZone: props.hideTimeZone,
hourCycle: props.hourCycle,
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
showEra: showEra
}), [
granularity,
props.hourCycle,
props.shouldForceLeadingZeros,
defaultTimeZone,
props.hideTimeZone,
showEra
]);
let { minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
let builtinValidation = (0, $7UzoM$useMemo)(()=>(0, $35a22f14a1f04b11$export$f18627323ab57ac0)(value, minValue, maxValue, isDateUnavailable, formatOpts), [
value,
minValue,
maxValue,
isDateUnavailable,
formatOpts
]);
let validation = (0, $7UzoM$useFormValidationState)({
...props,
value: value,
builtinValidation: builtinValidation
});
let isValueInvalid = validation.displayValidation.isInvalid;
let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
let commitValue = (date, time)=>{
setValue("timeZone" in time ? time.set((0, $7UzoM$toCalendarDate)(date)) : (0, $7UzoM$toCalendarDateTime)(date, time));
setSelectedDate(null);
setSelectedTime(null);
validation.commitValidation();
};
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
let selectDate = (newValue)=>{
let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
if (hasTime) {
if (selectedTime || shouldClose) commitValue(newValue, selectedTime || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
else setSelectedDate(newValue);
} else {
setValue(newValue);
validation.commitValidation();
}
if (shouldClose) overlayState.setOpen(false);
};
let selectTime = (newValue)=>{
if (selectedDate && newValue) commitValue(selectedDate, newValue);
else setSelectedTime(newValue);
};
return {
...validation,
value: value,
setValue: setValue,
dateValue: selectedDate,
timeValue: selectedTime,
setDateValue: selectDate,
setTimeValue: selectTime,
granularity: granularity,
hasTime: hasTime,
...overlayState,
setOpen (isOpen) {
// Commit the selected date when the calendar is closed. Use a placeholder time if one wasn't set.
// If only the time was set and not the date, don't commit. The state will be preserved until
// the user opens the popover again.
if (!isOpen && !value && selectedDate && hasTime) commitValue(selectedDate, selectedTime || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
overlayState.setOpen(isOpen);
},
validationState: validationState,
isInvalid: isValueInvalid,
formatValue (locale, fieldOptions) {
if (!dateValue) return "";
let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
let formatter = new (0, $7UzoM$DateFormatter)(locale, formatOptions);
return formatter.format(dateValue);
}
};
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
// These placeholders are based on the strings used by the <input type="date">
// implementations in Chrome and Firefox. Additional languages are supported
// here than React Spectrum's typical translations.
const $3e3ed55ab2966714$var$placeholders = new (0, $7UzoM$LocalizedStringDictionary)({
ach: {
year: "mwaka",
month: "dwe",
day: "nino"
},
af: {
year: "jjjj",
month: "mm",
day: "dd"
},
am: {
year: "\u12D3\u12D3\u12D3\u12D3",
month: "\u121A\u121C",
day: "\u1240\u1240"
},
an: {
year: "aaaa",
month: "mm",
day: "dd"
},
ar: {
year: "\u0633\u0646\u0629",
month: "\u0634\u0647\u0631",
day: "\u064A\u0648\u0645"
},
ast: {
year: "aaaa",
month: "mm",
day: "dd"
},
az: {
year: "iiii",
month: "aa",
day: "gg"
},
be: {
year: "\u0433\u0433\u0433\u0433",
month: "\u043C\u043C",
day: "\u0434\u0434"
},
bg: {
year: "\u0433\u0433\u0433\u0433",
month: "\u043C\u043C",
day: "\u0434\u0434"
},
bn: {
year: "yyyy",
month: "\u09AE\u09BF\u09AE\u09BF",
day: "dd"
},
br: {
year: "bbbb",
month: "mm",
day: "dd"
},
bs: {
year: "gggg",
month: "mm",
day: "dd"
},
ca: {
year: "aaaa",
month: "mm",
day: "dd"
},
cak: {
year: "jjjj",
month: "ii",
day: "q'q'"
},
ckb: {
year: "\u0633\u0627\u06B5",
month: "\u0645\u0627\u0646\u06AF",
day: "\u0695\u06C6\u0698"
},
cs: {
year: "rrrr",
month: "mm",
day: "dd"
},
cy: {
year: "bbbb",
month: "mm",
day: "dd"
},
da: {
year: "\xe5\xe5\xe5\xe5",
month: "mm",
day: "dd"
},
de: {
year: "jjjj",
month: "mm",
day: "tt"
},
dsb: {
year: "llll",
month: "mm",
day: "\u017A\u017A"
},
el: {
year: "\u03B5\u03B5\u03B5\u03B5",
month: "\u03BC\u03BC",
day: "\u03B7\u03B7"
},
en: {
year: "yyyy",
month: "mm",
day: "dd"
},
eo: {
year: "jjjj",
month: "mm",
day: "tt"
},
es: {
year: "aaaa",
month: "mm",
day: "dd"
},
et: {
year: "aaaa",
month: "kk",
day: "pp"
},
eu: {
year: "uuuu",
month: "hh",
day: "ee"
},
fa: {
year: "\u0633\u0627\u0644",
month: "\u0645\u0627\u0647",
day: "\u0631\u0648\u0632"
},
ff: {
year: "hhhh",
month: "ll",
day: "\xf1\xf1"
},
fi: {
year: "vvvv",
month: "kk",
day: "pp"
},
fr: {
year: "aaaa",
month: "mm",
day: "jj"
},
fy: {
year: "jjjj",
month: "mm",
day: "dd"
},
ga: {
year: "bbbb",
month: "mm",
day: "ll"
},
gd: {
year: "bbbb",
month: "mm",
day: "ll"
},
gl: {
year: "aaaa",
month: "mm",
day: "dd"
},
he: {
year: "\u05E9\u05E0\u05D4",
month: "\u05D7\u05D5\u05D3\u05E9",
day: "\u05D9\u05D5\u05DD"
},
hr: {
year: "gggg",
month: "mm",
day: "dd"
},
hsb: {
year: "llll",
month: "mm",
day: "dd"
},
hu: {
year: "\xe9\xe9\xe9\xe9",
month: "hh",
day: "nn"
},
ia: {
year: "aaaa",
month: "mm",
day: "dd"
},
id: {
year: "tttt",
month: "bb",
day: "hh"
},
it: {
year: "aaaa",
month: "mm",
day: "gg"
},
ja: {
year: " \u5E74 ",
month: "\u6708",
day: "\u65E5"
},
ka: {
year: "\u10EC\u10EC\u10EC\u10EC",
month: "\u10D7\u10D7",
day: "\u10E0\u10E0"
},
kk: {
year: "\u0436\u0436\u0436\u0436",
month: "\u0430\u0430",
day: "\u043A\u043A"
},
kn: {
year: "\u0CB5\u0CB5\u0CB5\u0CB5",
month: "\u0CAE\u0CBF\u0CAE\u0CC0",
day: "\u0CA6\u0CBF\u0CA6\u0CBF"
},
ko: {
year: "\uC5F0\uB3C4",
month: "\uC6D4",
day: "\uC77C"
},
lb: {
year: "jjjj",
month: "mm",
day: "dd"
},
lo: {
year: "\u0E9B\u0E9B\u0E9B\u0E9B",
month: "\u0E94\u0E94",
day: "\u0EA7\u0EA7"
},
lt: {
year: "mmmm",
month: "mm",
day: "dd"
},
lv: {
year: "gggg",
month: "mm",
day: "dd"
},
meh: {
year: "aaaa",
month: "mm",
day: "dd"
},
ml: {
year: "\u0D35\u0D7C\u0D37\u0D02",
month: "\u0D2E\u0D3E\u0D38\u0D02",
day: "\u0D24\u0D40\u0D2F\u0D24\u0D3F"
},
ms: {
year: "tttt",
month: "mm",
day: "hh"
},
nl: {
year: "jjjj",
month: "mm",
day: "dd"
},
nn: {
year: "\xe5\xe5\xe5\xe5",
month: "mm",
day: "dd"
},
no: {
year: "\xe5\xe5\xe5\xe5",
month: "mm",
day: "dd"
},
oc: {
year: "aaaa",
month: "mm",
day: "jj"
},
pl: {
year: "rrrr",
month: "mm",
day: "dd"
},
pt: {
year: "aaaa",
month: "mm",
day: "dd"
},
rm: {
year: "oooo",
month: "mm",
day: "dd"
},
ro: {
year: "aaaa",
month: "ll",
day: "zz"
},
ru: {
year: "\u0433\u0433\u0433\u0433",
month: "\u043C\u043C",
day: "\u0434\u0434"
},
sc: {
year: "aaaa",
month: "mm",
day: "dd"
},
scn: {
year: "aaaa",
month: "mm",
day: "jj"
},
sk: {
year: "rrrr",
month: "mm",
day: "dd"
},
sl: {
year: "llll",
month: "mm",
day: "dd"
},
sr: {
year: "\u0433\u0433\u0433\u0433",
month: "\u043C\u043C",
day: "\u0434\u0434"
},
sv: {
year: "\xe5\xe5\xe5\xe5",
month: "mm",
day: "dd"
},
szl: {
year: "rrrr",
month: "mm",
day: "dd"
},
tg: {
year: "\u0441\u0441\u0441\u0441",
month: "\u043C\u043C",
day: "\u0440\u0440"
},
th: {
year: "\u0E1B\u0E1B\u0E1B\u0E1B",
month: "\u0E14\u0E14",
day: "\u0E27\u0E27"
},
tr: {
year: "yyyy",
month: "aa",
day: "gg"
},
uk: {
year: "\u0440\u0440\u0440\u0440",
month: "\u043C\u043C",
day: "\u0434\u0434"
},
"zh-CN": {
year: "\u5E74",
month: "\u6708",
day: "\u65E5"
},
"zh-TW": {
year: "\u5E74",
month: "\u6708",
day: "\u65E5"
}
}, "en");
function $3e3ed55ab2966714$export$d3f5c5e0a5023fa0(field, value, locale) {
// Use the actual placeholder value for the era and day period fields.
if (field === "era" || field === "dayPeriod") return value;
if (field === "year" || field === "month" || field === "day") return $3e3ed55ab2966714$var$placeholders.getStringForLocale(field, locale);
// For time fields (e.g. hour, minute, etc.), use two dashes as the placeholder.
return "\u2013\u2013";
}
const $3c0fc76039f1c516$var$EDITABLE_SEGMENTS = {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
dayPeriod: true,
era: true
};
const $3c0fc76039f1c516$var$PAGE_STEP = {
year: 5,
month: 2,
day: 7,
hour: 2,
minute: 15,
second: 15
};
// Node seems to convert everything to lowercase...
const $3c0fc76039f1c516$var$TYPE_MAPPING = {
dayperiod: "dayPeriod"
};
function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
let { locale: locale, createCalendar: createCalendar, hideTimeZone: hideTimeZone, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
let v = props.value || props.defaultValue || props.placeholderValue;
let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
let timeZone = defaultTimeZone || "UTC";
// props.granularity must actually exist in the value if one is provided.
if (v && !(granularity in v)) throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
let defaultFormatter = (0, $7UzoM$useMemo)(()=>new (0, $7UzoM$DateFormatter)(locale), [
locale
]);
let calendar = (0, $7UzoM$useMemo)(()=>createCalendar(defaultFormatter.resolvedOptions().calendar), [
createCalendar,
defaultFormatter
]);
let [value, setDate] = (0, $7UzoM$useControlledState)(props.value, props.defaultValue, props.onChange);
let calendarValue = (0, $7UzoM$useMemo)(()=>(0, $35a22f14a1f04b11$export$61a490a80c552550)(value, calendar), [
value,
calendar
]);
// We keep track of the placeholder date separately in state so that onChange is not called
// until all segments are set. If the value === null (not undefined), then assume the component
// is controlled, so use the placeholder as the value until all segments are entered so it doesn't
// change from uncontrolled to controlled and emit a warning.
let [placeholderDate, setPlaceholderDate] = (0, $7UzoM$useState)(()=>(0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
let val = calendarValue || placeholderDate;
let showEra = calendar.identifier === "gregory" && val.era === "BC";
let formatOpts = (0, $7UzoM$useMemo)(()=>{
var _props_maxGranularity;
return {
granularity: granularity,
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
timeZone: defaultTimeZone,
hideTimeZone: hideTimeZone,
hourCycle: props.hourCycle,
showEra: showEra,
shouldForceLeadingZeros: props.shouldForceLeadingZeros
};
}, [
props.maxGranularity,
granularity,
props.hourCycle,
props.shouldForceLeadingZeros,
defaultTimeZone,
hideTimeZone,
showEra
]);
let opts = (0, $7UzoM$useMemo)(()=>(0, $35a22f14a1f04b11$export$7e319ea407e63bc0)({}, formatOpts), [
formatOpts
]);
let dateFormatter = (0, $7UzoM$useMemo)(()=>new (0, $7UzoM$DateFormatter)(locale, opts), [
locale,
opts
]);
let resolvedOptions = (0, $7UzoM$useMemo)(()=>dateFormatter.resolvedOptions(), [
dateFormatter
]);
// Determine how many editable segments there are for validation purposes.
// The result is cached for performance.
let allSegments = (0, $7UzoM$useMemo)(()=>dateFormatter.formatToParts(new Date()).filter((seg)=>$3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg)=>(p[seg.type] = true, p), {}), [
dateFormatter
]);
let [validSegments, setValidSegments] = (0, $7UzoM$useState)(()=>props.value || props.defaultValue ? {
...allSegments
} : {});
let clearedSegment = (0, $7UzoM$useRef)();
// Reset placeholder when calendar changes
let lastCalendarIdentifier = (0, $7UzoM$useRef)(calendar.identifier);
(0, $7UzoM$useEffect)(()=>{
if (calendar.identifier !== lastCalendarIdentifier.current) {
lastCalendarIdentifier.current = calendar.identifier;
setPlaceholderDate((placeholder)=>Object.keys(validSegments).length > 0 ? (0, $7UzoM$toCalendar)(placeholder, calendar) : (0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
}
}, [
calendar,
granularity,
validSegments,
defaultTimeZone,
props.placeholderValue
]);
// If there is a value prop, and some segments were previously placeholders, mark them all as valid.
if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {
validSegments = {
...allSegments
};
setValidSegments(validSegments);
}
// If the value is set to null and all segments are valid, reset the placeholder.
if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {
validSegments = {};
setValidSegments(validSegments);
setPlaceholderDate((0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
}
// If all segments are valid, use the date from state, otherwise use the placeholder date.
let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
let setValue = (newValue)=>{
if (props.isDisabled || props.isReadOnly) return;
let validKeys = Object.keys(validSegments);
let allKeys = Object.keys(allSegments);
// if all the segments are completed or a timefield with everything but am/pm set the time, also ignore when am/pm cleared
if (newValue == null) {
setDate(null);
setPlaceholderDate((0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
setValidSegments({});
} else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== "dayPeriod") {
// The display calendar should not have any effect on the emitted value.
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
newValue = (0, $7UzoM$toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (0, $7UzoM$GregorianCalendar)());
setDate(newValue);
} else setPlaceholderDate(newValue);
clearedSegment.current = null;
};
let dateValue = (0, $7UzoM$useMemo)(()=>displayValue.toDate(timeZone), [
displayValue,
timeZone
]);
let segments = (0, $7UzoM$useMemo)(()=>dateFormatter.formatToParts(dateValue).map((segment)=>{
let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
if (segment.type === "era" && calendar.getEras().length === 1) isEditable = false;
let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? (0, $3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
return {
type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
text: isPlaceholder ? placeholder : segment.value,
...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
isPlaceholder: isPlaceholder,
placeholder: placeholder,
isEditable: isEditable
};
}), [
dateValue,
validSegments,
dateFormatter,
resolvedOptions,
displayValue,
calendar,
locale
]);
// When the era field appears, mark it valid if the year field is already valid.
// If the era field disappears, remove it from the valid segments.
if (allSegments.era && validSegments.year && !validSegments.era) {
validSegments.era = true;
setValidSegments({
...validSegments
});
} else if (!allSegments.era && validSegments.era) {
delete validSegments.era;
setValidSegments({
...validSegments
});
}
let markValid = (part)=>{
validSegments[part] = true;
if (part === "year" && allSegments.era) validSegments.era = true;
setValidSegments({
...validSegments
});
};
let adjustSegment = (type, amount)=>{
if (!validSegments[type]) {
markValid(type);
let validKeys = Object.keys(validSegments);
let allKeys = Object.keys(allSegments);
if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) setValue(displayValue);
} else setValue($3c0fc76039f1c516$var$addSegment(displayValue, type, amount, resolvedOptions));
};
let builtinValidation = (0, $7UzoM$useMemo)(()=>(0, $35a22f14a1f04b11$export$f18627323ab57ac0)(value, minValue, maxValue, isDateUnavailable, formatOpts), [
value,
minValue,
maxValue,
isDateUnavailable,
formatOpts
]);
let validation = (0, $7UzoM$useFormValidationState)({
...props,
value: value,
builtinValidation: builtinValidation
});
let isValueInvalid = validation.displayValidation.isInvalid;
let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
var _props_maxGranularity;
return {
...validation,
value: calendarValue,
dateValue: dateValue,
calendar: calendar,
setValue: setValue,
segments: segments,
dateFormatter: dateFormatter,
validationState: validationState,
isInvalid: isValueInvalid,
granularity: granularity,
maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
isDisabled: isDisabled,
isReadOnly: isReadOnly,
isRequired: isRequired,
increment (part) {
adjustSegment(part, 1);
},
decrement (part) {
adjustSegment(part, -1);
},
incrementPage (part) {
adjustSegment(part, $3c0fc76039f1c516$var$PAGE_STEP[part] || 1);
},
decrementPage (part) {
adjustSegment(part, -($3c0fc76039f1c516$var$PAGE_STEP[part] || 1));
},
setSegment (part, v) {
markValid(part);
setValue($3c0fc76039f1c516$var$setSegment(displayValue, part, v, resolvedOptions));
},
confirmPlaceholder () {
if (props.isDisabled || props.isReadOnly) return;
// Confirm the placeholder if only the day period is not filled in.
let validKeys = Object.keys(validSegments);
let allKeys = Object.keys(allSegments);
if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {
validSegments = {
...allSegments
};
setValidSegments(validSegments);
setValue(displayValue.copy());
}
},
clearSegment (part) {
delete validSegments[part];
clearedSegment.current = part;
setValidSegments({
...validSegments
});
let placeholder = (0, $35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone);
let value = displayValue;
// Reset day period to default without changing the hour.
if (part === "dayPeriod" && "hour" in displayValue && "hour" in placeholder) {
let isPM = displayValue.hour >= 12;
let shouldBePM = placeholder.hour >= 12;
if (isPM && !shouldBePM) value = displayValue.set({
hour: displayValue.hour - 12
});
else if (!isPM && shouldBePM) value = displayValue.set({
hour: displayValue.hour + 12
});
} else if (part in displayValue) value = displayValue.set({
[part]: placeholder[part]
});
setDate(null);
setValue(value);
},
formatValue (fieldOptions) {
if (!calendarValue) return "";
let formatOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
let formatter = new (0, $7UzoM$DateFormatter)(locale, formatOptions);
return formatter.format(dateValue);
}
};
}
function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
switch(type){
case "era":
{
let eras = date.calendar.getEras();
return {
value: eras.indexOf(date.era),
minValue: 0,
maxValue: eras.length - 1
};
}
case "year":
return {
value: date.year,
minValue: 1,
maxValue: date.calendar.getYearsInEra(date)
};
case "month":
return {
value: date.month,
minValue: (0, $7UzoM$getMinimumMonthInYear)(date),
maxValue: date.calendar.getMonthsInYear(date)
};
case "day":
return {
value: date.day,
minValue: (0, $7UzoM$getMinimumDayInMonth)(date),
maxValue: date.calendar.getDaysInMonth(date)
};
}
if ("hour" in date) switch(type){
case "dayPeriod":
return {
value: date.hour >= 12 ? 12 : 0,
minValue: 0,
maxValue: 12
};
case "hour":
if (options.hour12) {
let isPM = date.hour >= 12;
return {
value: date.hour,
minValue: isPM ? 12 : 0,
maxValue: isPM ? 23 : 11
};
}
return {
value: date.hour,
minValue: 0,
maxValue: 23
};
case "minute":
return {
value: date.minute,
minValue: 0,
maxValue: 59
};
case "second":
return {
value: date.second,
minValue: 0,
maxValue: 59
};
}
return {};
}
function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
switch(part){
case "era":
case "year":
case "month":
case "day":
return value.cycle(part, amount, {
round: part === "year"
});
}
if ("hour" in value) switch(part){
case "dayPeriod":
{
let hours = value.hour;
let isPM = hours >= 12;
return value.set({
hour: isPM ? hours - 12 : hours + 12
});
}
case "hour":
case "minute":
case "second":
return value.cycle(part, amount, {
round: part !== "hour",
hourCycle: options.hour12 ? 12 : 24
});
}
}
function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
switch(part){
case "day":
case "month":
case "year":
case "era":
return value.set({
[part]: segmentValue
});
}
if ("hour" in value) switch(part){
case "dayPeriod":
{
let hours = value.hour;
let wasPM = hours >= 12;
let isPM = segmentValue >= 12;
if (isPM === wasPM) return value;
return value.set({
hour: wasPM ? hours - 12 : hours + 12
});
}
case "hour":
// In 12 hour time, ensure that AM/PM does not change
if (options.hour12) {
let hours = value.hour;
let wasPM = hours >= 12;
if (!wasPM && segmentValue === 12) segmentValue = 0;
if (wasPM && segmentValue < 12) segmentValue += 12;
}
// fallthrough
case "minute":
case "second":
return value.set({
[part]: segmentValue
});
}
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
var _value_start, _value_end;
let overlayState = (0, $7UzoM$useOverlayTriggerState)(props);
let [controlledValue, setControlledValue] = (0, $7UzoM$useControlledState)(props.value, props.defaultValue || null, props.onChange);
let [placeholderValue, setPlaceholderValue] = (0, $7UzoM$useState)(()=>controlledValue || {
start: null,
end: null
});
// Reset the placeholder if the value prop is set to null.
if (controlledValue == null && placeholderValue.start && placeholderValue.end) {
placeholderValue = {
start: null,
end: null
};
setPlaceholderValue(placeholderValue);
}
let value = controlledValue || placeholderValue;
let setValue = (value)=>{
setPlaceholderValue(value || {
start: null,
end: null
});
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) setControlledValue(value);
else setControlledValue(null);
};
let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
let [granularity, defaultTimeZone] = (0, $35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
var _props_shouldCloseOnSelect;
let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
let [dateRange, setSelectedDateRange] = (0, $7UzoM$useState)(null);
let [timeRange, setSelectedTimeRange] = (0, $7UzoM$useState)(null);
if (value && value.start && value.end) {
dateRange = value;
if ("hour" in value.start) timeRange = value;
}
let commitValue = (dateRange, timeRange)=>{
setValue({
start: "timeZone" in timeRange.start ? timeRange.start.set((0, $7UzoM$toCalendarDate)(dateRange.start)) : (0, $7UzoM$toCalendarDateTime)(dateRange.start, timeRange.start),
end: "timeZone" in timeRange.end ? timeRange.end.set((0, $7UzoM$toCalendarDate)(dateRange.end)) : (0, $7UzoM$toCalendarDateTime)(dateRange.end, timeRange.end)
});
setSelectedDateRange(null);
setSelectedTimeRange(null);
validation.commitValidation();
};
// Intercept setValue to make sure the Time section is not changed by date selection in Calendar
let setDateRange = (range)=>{
let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
if (hasTime) {
if (shouldClose || range.start && range.end && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end)) commitValue(range, {
start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
});
else setSelectedDateRange(range);
} else if (range.start && range.end) {
setValue(range);
validation.commitValidation();
} else setSelectedDateRange(range);
if (shouldClose) overlayState.setOpen(false);
};
let setTimeRange = (range)=>{
if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && range.start && range.end) commitValue(dateRange, range);
else setSelectedTimeRange(range);
};
let showEra = (value === null || value === void 0 ? void 0 : (_value_start = value.start) === null || _value_start === void 0 ? void 0 : _value_start.calendar.identifier) === "gregory" && value.start.era === "BC" || (value === null || value === void 0 ? void 0 : (_value_end = value.end) === null || _value_end === void 0 ? void 0 : _value_end.calendar.identifier) === "gregory" && value.end.era === "BC";
let formatOpts = (0, $7UzoM$useMemo)(()=>({
granularity: granularity,
timeZone: defaultTimeZone,
hideTimeZone: props.hideTimeZone,
hourCycle: props.hourCycle,
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
showEra: showEra
}), [
granularity,
props.hourCycle,
props.shouldForceLeadingZeros,
defaultTimeZone,
props.hideTimeZone,
showEra
]);
let { minValue: minValue, maxValue: maxValue, isDateUnavailable: isDateUnavailable } = props;
let builtinValidation = (0, $7UzoM$useMemo)(()=>(0, $35a22f14a1f04b11$export$80ff8fc0ae339c13)(value, minValue, maxValue, isDateUnavailable, formatOpts), [
value,
minValue,
maxValue,
isDateUnavailable,
formatOpts
]);
let validation = (0, $7UzoM$useFormValidationState)({
...props,
value: controlledValue,
name: (0, $7UzoM$useMemo)(()=>[
props.startName,
props.endName
], [
props.startName,
props.endName
]),
builtinValidation: builtinValidation
});
let isValueInvalid = validation.displayValidation.isInvalid;
let validationState = props.validationState || (isValueInvalid ? "invalid" : null);
return {
...validation,
value: value,
setValue: setValue,
dateRange: dateRange,
timeRange: timeRange,
granularity: granularity,
hasTime: hasTime,
setDate (part, date) {
setDateRange({
...dateRange,
[part]: date
});
},
setTime (part, time) {
setTimeRange({
...timeRange,
[part]: time
});
},
setDateTime (part, dateTime) {
setValue({
...value,
[part]: dateTime
});
},
setDateRange: setDateRange,
setTimeRange: setTimeRange,
...overlayState,
setOpen (isOpen) {
// Commit the selected date range when the calendar is closed. Use a placeholder time if one wasn't set.
// If only the time range was set and not the date range, don't commit. The state will be preserved until
// the user opens the popover again.
if (!isOpen && !((value === null || value === void 0 ? void 0 : value.start) && (value === null || value === void 0 ? void 0 : value.end)) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && hasTime) commitValue(dateRange, {
start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || (0, $35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
});
overlayState.setOpen(isOpen);
},
validationState: validationState,
isInvalid: isValueInvalid,
formatValue (locale, fieldOptions) {
if (!value || !value.start || !value.end) return null;
let startTimeZone = "timeZone" in value.start ? value.start.timeZone : undefined;
let startGranularity = props.granularity || (value.start && "minute" in value.start ? "minute" : "day");
let endTimeZone = "timeZone" in value.end ? value.end.timeZone : undefined;
let endGranularity = props.granularity || (value.end && "minute" in value.end ? "minute" : "day");
let startOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
granularity: startGranularity,
timeZone: startTimeZone,
hideTimeZone: props.hideTimeZone,
hourCycle: props.hourCycle,
showEra: value.start.calendar.identifier === "gregory" && value.start.era === "BC" || value.end.calendar.identifier === "gregory" && value.end.era === "BC"
});
let startDate = value.start.toDate(startTimeZone || "UTC");
let endDate = value.end.toDate(endTimeZone || "UTC");
let startFormatter = new (0, $7UzoM$DateFormatter)(locale, startOptions);
let endFormatter;
if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
// Use formatRange, as it results in shorter output when some of the fields
// are shared between the start and end dates (e.g. the same month).
// Formatting will fail if the end date is before the start date. Fall back below when that happens.
try {
let parts = startFormatter.formatRangeToParts(startDate, endDate);
// Find the separator between the start and end date. This is determined
// by finding the last shared literal before the end range.
let separatorIndex = -1;
for(let i = 0; i < parts.length; i++){
let part = parts[i];
if (part.source === "shared" && part.type === "literal") separatorIndex = i;
else if (part.source === "endRange") break;
}
// Now we can combine the parts into start and end strings.
let start = "";
let end = "";
for(let i = 0; i < parts.length; i++){
if (i < separatorIndex) start += parts[i].value;
else if (i > separatorIndex) end += parts[i].value;
}
return {
start: start,
end: end
};
} catch (e) {
// ignore
}
endFormatter = startFormatter;
} else {
let endOptions = (0, $35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
granularity: endGranularity,
timeZone: endTimeZone,
hideTimeZone: props.hideTimeZone,
hourCycle: props.hourCycle
});
endFormatter = new (0, $7UzoM$DateFormatter)(locale, endOptions);
}
return {
start: startFormatter.format(startDate),
end: endFormatter.format(endDate)
};
}
};
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $eff5d8ee529ac4bb$export$fd53cef0cc796101(props) {
let { placeholderValue: placeholderValue = new (0, $7UzoM$Time)(), minValue: minValue, maxValue: maxValue, granularity: granularity, validate: validate } = props;
let [value, setValue] = (0, $7UzoM$useControlledState)(props.value, props.defaultValue, props.onChange);
let v = value || placeholderValue;
let day = v && "day" in v ? v : undefined;
let defaultValueTimeZone = props.defaultValue && "timeZone" in props.defaultValue ? props.defaultValue.timeZone : undefined;
let placeholderDate = (0, $7UzoM$useMemo)(()=>{
let valueTimeZone = v && "timeZone" in v ? v.timeZone : undefined;
return (valueTimeZone || defaultValueTimeZone) && placeholderValue ? (0, $7UzoM$toZoned)($eff5d8ee529ac4bb$var$convertValue(placeholderValue), valueTimeZone || defaultValueTimeZone) : $eff5d8ee529ac4bb$var$convertValue(placeholderValue);
}, [
placeholderValue,
v,
defaultValueTimeZone
]);
let minDate = (0, $7UzoM$useMemo)(()=>$eff5d8ee529ac4bb$var$convertValue(minValue, day), [
minValue,
day
]);
let maxDate = (0, $7UzoM$useMemo)(()=>$eff5d8ee529ac4bb$var$convertValue(maxValue, day), [
maxValue,
day
]);
let timeValue = (0, $7UzoM$useMemo)(()=>value && "day" in value ? (0, $7UzoM$toTime)(value) : value, [
value
]);
let dateTime = (0, $7UzoM$useMemo)(()=>value == null ? null : $eff5d8ee529ac4bb$var$convertValue(value), [
value
]);
let onChange = (newValue)=>{
setValue(day || defaultValueTimeZone ? newValue : newValue && (0, $7UzoM$toTime)(newValue));
};
let state = (0, $3c0fc76039f1c516$export$60e84778edff6d26)({
...props,
value: dateTime,
defaultValue: undefined,
minValue: minDate,
maxValue: maxDate,
onChange: onChange,
granularity: granularity || "minute",
maxGranularity: "hour",
placeholderValue: placeholderDate,
// Calendar should not matter for time fields.
createCalendar: ()=>new (0, $7UzoM$GregorianCalendar)(),
validate: (0, $7UzoM$useCallback)(()=>validate === null || validate === void 0 ? void 0 : validate(value), [
validate,
value
])
});
return {
...state,
timeValue: timeValue
};
}
function $eff5d8ee529ac4bb$var$convertValue(value, date = (0, $7UzoM$today)((0, $7UzoM$getLocalTimeZone)())) {
if (!value) return null;
if ("day" in value) return value;
return (0, $7UzoM$toCalendarDateTime)(date, value);
}
export {$ab5bf3f618090389$export$87194bb378cc3ac2 as useDatePickerState, $3c0fc76039f1c516$export$60e84778edff6d26 as useDateFieldState, $93c38a5e28be6249$export$e50a61c1de9f574 as useDateRangePickerState, $eff5d8ee529ac4bb$export$fd53cef0cc796101 as useTimeFieldState};
//# sourceMappingURL=module.js.map