@vygruppen/spor-react 4.1.0 → 4.1.1

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.
@@ -4,15 +4,15 @@ import tokens10__default from '@vygruppen/spor-design-tokens';
4
4
  import * as tokens10 from '@vygruppen/spor-design-tokens';
5
5
  export { tokens10 as tokens };
6
6
  import * as React69 from 'react';
7
- import React69__default, { createContext, useEffect, forwardRef as forwardRef$1, useRef, useState, useId, Suspense, useMemo, useContext, useCallback } from 'react';
7
+ import React69__default, { createContext, useEffect, forwardRef as forwardRef$1, useRef, useState, useId, Suspense, useContext, useCallback, useMemo } from 'react';
8
8
  import { CloseFill30Icon, CloseFill24Icon, CloseFill18Icon, CalendarOutline24Icon, CloseOutline24Icon, SearchOutline24Icon, InformationFill24Icon, InformationFill18Icon, WarningFill24Icon, WarningFill18Icon, ErrorFill24Icon, ErrorFill18Icon, LinkOutOutline24Icon, DropdownRightFill18Icon, DropdownLeftFill18Icon, DropdownDownFill18Icon, DropdownDownFill24Icon, DropdownUpFill24Icon, ArrowRightFill18Icon, DropdownLeftFill24Icon, ArrowLeftOutline24Icon, ArrowRightOutline24Icon, ErrorOutline24Icon, AltTransportOutline24Icon, WarningOutline24Icon, SuccessOutline24Icon, InformationOutline24Icon, TrainFill18Icon, TrainFill24Icon, TrainFill30Icon, ExpressBusFill18Icon, ExpressBusFill24Icon, ExpressBusFill30Icon, BusFill18Icon, BusFill24Icon, BusFill30Icon, FerryFill18Icon, FerryFill24Icon, FerryFill30Icon, SubwayFill18Icon, SubwayFill24Icon, SubwayFill30Icon, TramFill18Icon, TramFill24Icon, TramFill30Icon, AltTransportFill18Icon, AltTransportFill24Icon, AltTransportFill30Icon, WalkFill18Icon, WalkFill24Icon, WalkFill30Icon } from '@vygruppen/spor-icon-react';
9
9
  import { inlineLoaderColorData, spinnerColorData, contentLoaderData, fullScreenLoaderWhiteData, inlineLoaderDarkData, fullScreenLoaderBlackData, inlineLoaderLightData, spinnerLightData, spinnerDarkData } from '@vygruppen/spor-loader';
10
10
  import { useLottie } from 'lottie-react';
11
11
  import { useDateSegment, useDateField, useDatePicker, I18nProvider, usePopover, DismissButton, Overlay, useOverlayTrigger, useButton, useProgressBar, useCalendar, useDateRangePicker, useDialog, useFilter, useComboBox, useListBox, useOption, useListBoxSection, useSelect, HiddenSelect, useCalendarGrid, useRangeCalendar, useTimeField, useCalendarCell } from 'react-aria';
12
12
  import { motion } from 'framer-motion';
13
- import { DateFormatter, toCalendar, getMinimumDayInMonth, getMinimumMonthInYear, createCalendar, GregorianCalendar, Time, now, toCalendarDate, toCalendarDateTime, today, startOfWeek, startOfMonth, endOfWeek, endOfMonth, isSameDay, getDayOfWeek, parseTime, getWeeksInMonth, getLocalTimeZone, startOfYear, maxDate, minDate, isEqualDay, isSameMonth, isToday } from '@internationalized/date';
13
+ import { createCalendar, GregorianCalendar, parseTime, endOfMonth, getWeeksInMonth, getLocalTimeZone, isSameMonth, isToday } from '@internationalized/date';
14
14
  export { Time } from '@internationalized/date';
15
- import { useOverlayTriggerState, Item, useTimeFieldState, useComboBoxState, useSelectState } from 'react-stately';
15
+ import { useDateFieldState, useDatePickerState, useOverlayTriggerState, Item, useCalendarState, useDateRangePickerState, useTimeFieldState, useComboBoxState, useSelectState, useRangeCalendarState } from 'react-stately';
16
16
  export { Item, Section } from 'react-stately';
17
17
  import { useSwipeable } from 'react-swipeable';
18
18
  import { Global, keyframes } from '@emotion/react';
@@ -1551,1734 +1551,6 @@ var Card = forwardRef(
1551
1551
  return /* @__PURE__ */ React69__default.createElement(Box, { __css: styles3, ...props, ref }, children);
1552
1552
  }
1553
1553
  );
1554
- function $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange) {
1555
- let [stateValue, setStateValue] = (useState)(value || defaultValue);
1556
- let isControlledRef = (useRef)(value !== void 0);
1557
- let isControlled = value !== void 0;
1558
- (useEffect)(() => {
1559
- let wasControlled = isControlledRef.current;
1560
- if (wasControlled !== isControlled)
1561
- console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
1562
- isControlledRef.current = isControlled;
1563
- }, [
1564
- isControlled
1565
- ]);
1566
- let currentValue = isControlled ? value : stateValue;
1567
- let setValue = (useCallback)((value2, ...args) => {
1568
- let onChangeCaller = (value3, ...onChangeArgs) => {
1569
- if (onChange) {
1570
- if (!Object.is(currentValue, value3))
1571
- onChange(value3, ...onChangeArgs);
1572
- }
1573
- if (!isControlled)
1574
- currentValue = value3;
1575
- };
1576
- if (typeof value2 === "function") {
1577
- console.warn("We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320");
1578
- let updateFunction = (oldValue, ...functionArgs) => {
1579
- let interceptedValue = value2(isControlled ? currentValue : oldValue, ...functionArgs);
1580
- onChangeCaller(interceptedValue, ...args);
1581
- if (!isControlled)
1582
- return interceptedValue;
1583
- return oldValue;
1584
- };
1585
- setStateValue(updateFunction);
1586
- } else {
1587
- if (!isControlled)
1588
- setStateValue(value2);
1589
- onChangeCaller(value2, ...args);
1590
- }
1591
- }, [
1592
- isControlled,
1593
- currentValue,
1594
- onChange
1595
- ]);
1596
- return [
1597
- currentValue,
1598
- setValue
1599
- ];
1600
- }
1601
-
1602
- // ../../node_modules/@react-stately/overlays/dist/import.mjs
1603
- function $fc909762b330b746$export$61c6a8c84e605fb6(props) {
1604
- let [isOpen, setOpen] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
1605
- const open = (useCallback)(() => {
1606
- setOpen(true);
1607
- }, [
1608
- setOpen
1609
- ]);
1610
- const close = (useCallback)(() => {
1611
- setOpen(false);
1612
- }, [
1613
- setOpen
1614
- ]);
1615
- const toggle = (useCallback)(() => {
1616
- setOpen(!isOpen);
1617
- }, [
1618
- setOpen,
1619
- isOpen
1620
- ]);
1621
- return {
1622
- isOpen,
1623
- setOpen,
1624
- open,
1625
- close,
1626
- toggle
1627
- };
1628
- }
1629
-
1630
- // ../../node_modules/@internationalized/string/dist/import.mjs
1631
- var $5b160d28a433310d$export$c17fa47878dc55b6 = class {
1632
- /** Returns a localized string for the given key and locale. */
1633
- getStringForLocale(key, locale) {
1634
- let strings = this.strings[locale];
1635
- if (!strings) {
1636
- strings = $5b160d28a433310d$var$getStringsForLocale(locale, this.strings, this.defaultLocale);
1637
- this.strings[locale] = strings;
1638
- }
1639
- let string = strings[key];
1640
- if (!string)
1641
- throw new Error(`Could not find intl message ${key} in ${locale} locale`);
1642
- return string;
1643
- }
1644
- constructor(messages, defaultLocale = "en-US") {
1645
- this.strings = {
1646
- ...messages
1647
- };
1648
- this.defaultLocale = defaultLocale;
1649
- }
1650
- };
1651
- function $5b160d28a433310d$var$getStringsForLocale(locale, strings, defaultLocale = "en-US") {
1652
- if (strings[locale])
1653
- return strings[locale];
1654
- let language = $5b160d28a433310d$var$getLanguage(locale);
1655
- if (strings[language])
1656
- return strings[language];
1657
- for (let key in strings) {
1658
- if (key.startsWith(language + "-"))
1659
- return strings[key];
1660
- }
1661
- return strings[defaultLocale];
1662
- }
1663
- function $5b160d28a433310d$var$getLanguage(locale) {
1664
- if (Intl.Locale)
1665
- return new Intl.Locale(locale).language;
1666
- return locale.split("-")[0];
1667
- }
1668
-
1669
- // ../../node_modules/@react-stately/datepicker/dist/import.mjs
1670
- function $35a22f14a1f04b11$export$eac50920cf2fd59a(value, minValue, maxValue) {
1671
- return value != null && (minValue != null && value.compare(minValue) < 0 || maxValue != null && value.compare(maxValue) > 0);
1672
- }
1673
- var $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS = {
1674
- year: "numeric",
1675
- month: "numeric",
1676
- day: "numeric",
1677
- hour: "numeric",
1678
- minute: "2-digit",
1679
- second: "2-digit"
1680
- };
1681
- var $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS = {
1682
- year: "numeric",
1683
- month: "2-digit",
1684
- day: "2-digit",
1685
- hour: "2-digit",
1686
- minute: "2-digit",
1687
- second: "2-digit"
1688
- };
1689
- function $35a22f14a1f04b11$export$7e319ea407e63bc0(fieldOptions, options) {
1690
- let defaultFieldOptions = options.shouldForceLeadingZeros ? $35a22f14a1f04b11$var$TWO_DIGIT_FIELD_OPTIONS : $35a22f14a1f04b11$var$DEFAULT_FIELD_OPTIONS;
1691
- fieldOptions = {
1692
- ...defaultFieldOptions,
1693
- ...fieldOptions
1694
- };
1695
- let granularity = options.granularity || "minute";
1696
- let keys = Object.keys(fieldOptions);
1697
- var _options_maxGranularity;
1698
- let startIdx = keys.indexOf((_options_maxGranularity = options.maxGranularity) !== null && _options_maxGranularity !== void 0 ? _options_maxGranularity : "year");
1699
- if (startIdx < 0)
1700
- startIdx = 0;
1701
- let endIdx = keys.indexOf(granularity);
1702
- if (endIdx < 0)
1703
- endIdx = 2;
1704
- if (startIdx > endIdx)
1705
- throw new Error("maxGranularity must be greater than granularity");
1706
- let opts = keys.slice(startIdx, endIdx + 1).reduce((opts2, key) => {
1707
- opts2[key] = fieldOptions[key];
1708
- return opts2;
1709
- }, {});
1710
- if (options.hourCycle != null)
1711
- opts.hour12 = options.hourCycle === 12;
1712
- opts.timeZone = options.timeZone || "UTC";
1713
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
1714
- if (hasTime && options.timeZone && !options.hideTimeZone)
1715
- opts.timeZoneName = "short";
1716
- if (options.showEra && startIdx === 0)
1717
- opts.era = "short";
1718
- return opts;
1719
- }
1720
- function $35a22f14a1f04b11$export$c5221a78ef73c5e9(placeholderValue) {
1721
- if (placeholderValue && "hour" in placeholderValue)
1722
- return placeholderValue;
1723
- return new (Time)();
1724
- }
1725
- function $35a22f14a1f04b11$export$61a490a80c552550(value, calendar) {
1726
- if (value === null)
1727
- return null;
1728
- if (!value)
1729
- return void 0;
1730
- return (toCalendar)(value, calendar);
1731
- }
1732
- function $35a22f14a1f04b11$export$66aa2b09de4b1ea5(placeholderValue, granularity, calendar, timeZone) {
1733
- if (placeholderValue)
1734
- return $35a22f14a1f04b11$export$61a490a80c552550(placeholderValue, calendar);
1735
- let date = (toCalendar)((now)(timeZone).set({
1736
- hour: 0,
1737
- minute: 0,
1738
- second: 0,
1739
- millisecond: 0
1740
- }), calendar);
1741
- if (granularity === "year" || granularity === "month" || granularity === "day")
1742
- return (toCalendarDate)(date);
1743
- if (!timeZone)
1744
- return (toCalendarDateTime)(date);
1745
- return date;
1746
- }
1747
- function $35a22f14a1f04b11$export$2440da353cedad43(v, granularity) {
1748
- let defaultTimeZone = v && "timeZone" in v ? v.timeZone : void 0;
1749
- let defaultGranularity = v && "minute" in v ? "minute" : "day";
1750
- if (v && granularity && !(granularity in v))
1751
- throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
1752
- let [lastValue, setLastValue] = (useState)([
1753
- defaultGranularity,
1754
- defaultTimeZone
1755
- ]);
1756
- if (v && (lastValue[0] !== defaultGranularity || lastValue[1] !== defaultTimeZone))
1757
- setLastValue([
1758
- defaultGranularity,
1759
- defaultTimeZone
1760
- ]);
1761
- if (!granularity)
1762
- granularity = v ? defaultGranularity : lastValue[0];
1763
- let timeZone = v ? defaultTimeZone : lastValue[1];
1764
- return [
1765
- granularity,
1766
- timeZone
1767
- ];
1768
- }
1769
- function $ab5bf3f618090389$export$87194bb378cc3ac2(props) {
1770
- var _props_isDateUnavailable;
1771
- let overlayState = ($fc909762b330b746$export$61c6a8c84e605fb6)(props);
1772
- let [value, setValue] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, props.defaultValue || null, props.onChange);
1773
- let v = value || props.placeholderValue;
1774
- let [granularity, defaultTimeZone] = ($35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
1775
- let dateValue = value != null ? value.toDate(defaultTimeZone !== null && defaultTimeZone !== void 0 ? defaultTimeZone : "UTC") : null;
1776
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
1777
- var _props_shouldCloseOnSelect;
1778
- let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
1779
- let [selectedDate, setSelectedDate] = (useState)(null);
1780
- let [selectedTime, setSelectedTime] = (useState)(null);
1781
- if (value) {
1782
- selectedDate = value;
1783
- if ("hour" in value)
1784
- selectedTime = value;
1785
- }
1786
- if (v && !(granularity in v))
1787
- throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
1788
- let commitValue = (date, time) => {
1789
- setValue("timeZone" in time ? time.set((toCalendarDate)(date)) : (toCalendarDateTime)(date, time));
1790
- setSelectedDate(null);
1791
- setSelectedTime(null);
1792
- };
1793
- let selectDate = (newValue) => {
1794
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
1795
- if (hasTime) {
1796
- if (selectedTime || shouldClose)
1797
- commitValue(newValue, selectedTime || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
1798
- else
1799
- setSelectedDate(newValue);
1800
- } else
1801
- setValue(newValue);
1802
- if (shouldClose)
1803
- overlayState.setOpen(false);
1804
- };
1805
- let selectTime = (newValue) => {
1806
- if (selectedDate && newValue)
1807
- commitValue(selectedDate, newValue);
1808
- else
1809
- setSelectedTime(newValue);
1810
- };
1811
- let validationState = props.validationState || (($35a22f14a1f04b11$export$eac50920cf2fd59a)(value, props.minValue, props.maxValue) ? "invalid" : null) || (value && ((_props_isDateUnavailable = props.isDateUnavailable) === null || _props_isDateUnavailable === void 0 ? void 0 : _props_isDateUnavailable.call(props, value)) ? "invalid" : null);
1812
- return {
1813
- value,
1814
- setValue,
1815
- dateValue: selectedDate,
1816
- timeValue: selectedTime,
1817
- setDateValue: selectDate,
1818
- setTimeValue: selectTime,
1819
- granularity,
1820
- hasTime,
1821
- ...overlayState,
1822
- setOpen(isOpen) {
1823
- if (!isOpen && !value && selectedDate && hasTime)
1824
- commitValue(selectedDate, selectedTime || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue));
1825
- overlayState.setOpen(isOpen);
1826
- },
1827
- validationState,
1828
- formatValue(locale, fieldOptions) {
1829
- if (!dateValue)
1830
- return "";
1831
- let formatOptions = ($35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
1832
- granularity,
1833
- timeZone: defaultTimeZone,
1834
- hideTimeZone: props.hideTimeZone,
1835
- hourCycle: props.hourCycle,
1836
- showEra: value.calendar.identifier === "gregory" && value.era === "BC"
1837
- });
1838
- let formatter = new (DateFormatter)(locale, formatOptions);
1839
- return formatter.format(dateValue);
1840
- }
1841
- };
1842
- }
1843
- var $3e3ed55ab2966714$var$placeholders = new ($5b160d28a433310d$export$c17fa47878dc55b6)({
1844
- ach: {
1845
- year: "mwaka",
1846
- month: "dwe",
1847
- day: "nino"
1848
- },
1849
- af: {
1850
- year: "jjjj",
1851
- month: "mm",
1852
- day: "dd"
1853
- },
1854
- am: {
1855
- year: "\u12D3\u12D3\u12D3\u12D3",
1856
- month: "\u121A\u121C",
1857
- day: "\u1240\u1240"
1858
- },
1859
- an: {
1860
- year: "aaaa",
1861
- month: "mm",
1862
- day: "dd"
1863
- },
1864
- ar: {
1865
- year: "\u0633\u0646\u0629",
1866
- month: "\u0634\u0647\u0631",
1867
- day: "\u064A\u0648\u0645"
1868
- },
1869
- ast: {
1870
- year: "aaaa",
1871
- month: "mm",
1872
- day: "dd"
1873
- },
1874
- az: {
1875
- year: "iiii",
1876
- month: "aa",
1877
- day: "gg"
1878
- },
1879
- be: {
1880
- year: "\u0433\u0433\u0433\u0433",
1881
- month: "\u043C\u043C",
1882
- day: "\u0434\u0434"
1883
- },
1884
- bg: {
1885
- year: "\u0433\u0433\u0433\u0433",
1886
- month: "\u043C\u043C",
1887
- day: "\u0434\u0434"
1888
- },
1889
- bn: {
1890
- year: "yyyy",
1891
- month: "\u09AE\u09BF\u09AE\u09BF",
1892
- day: "dd"
1893
- },
1894
- br: {
1895
- year: "bbbb",
1896
- month: "mm",
1897
- day: "dd"
1898
- },
1899
- bs: {
1900
- year: "gggg",
1901
- month: "mm",
1902
- day: "dd"
1903
- },
1904
- ca: {
1905
- year: "aaaa",
1906
- month: "mm",
1907
- day: "dd"
1908
- },
1909
- cak: {
1910
- year: "jjjj",
1911
- month: "ii",
1912
- day: "q'q'"
1913
- },
1914
- ckb: {
1915
- year: "\u0633\u0627\u06B5",
1916
- month: "\u0645\u0627\u0646\u06AF",
1917
- day: "\u0695\u06C6\u0698"
1918
- },
1919
- cs: {
1920
- year: "rrrr",
1921
- month: "mm",
1922
- day: "dd"
1923
- },
1924
- cy: {
1925
- year: "bbbb",
1926
- month: "mm",
1927
- day: "dd"
1928
- },
1929
- da: {
1930
- year: "\xE5\xE5\xE5\xE5",
1931
- month: "mm",
1932
- day: "dd"
1933
- },
1934
- de: {
1935
- year: "jjjj",
1936
- month: "mm",
1937
- day: "tt"
1938
- },
1939
- dsb: {
1940
- year: "llll",
1941
- month: "mm",
1942
- day: "\u017A\u017A"
1943
- },
1944
- el: {
1945
- year: "\u03B5\u03B5\u03B5\u03B5",
1946
- month: "\u03BC\u03BC",
1947
- day: "\u03B7\u03B7"
1948
- },
1949
- en: {
1950
- year: "yyyy",
1951
- month: "mm",
1952
- day: "dd"
1953
- },
1954
- eo: {
1955
- year: "jjjj",
1956
- month: "mm",
1957
- day: "tt"
1958
- },
1959
- es: {
1960
- year: "aaaa",
1961
- month: "mm",
1962
- day: "dd"
1963
- },
1964
- et: {
1965
- year: "aaaa",
1966
- month: "kk",
1967
- day: "pp"
1968
- },
1969
- eu: {
1970
- year: "uuuu",
1971
- month: "hh",
1972
- day: "ee"
1973
- },
1974
- fa: {
1975
- year: "\u0633\u0627\u0644",
1976
- month: "\u0645\u0627\u0647",
1977
- day: "\u0631\u0648\u0632"
1978
- },
1979
- ff: {
1980
- year: "hhhh",
1981
- month: "ll",
1982
- day: "\xF1\xF1"
1983
- },
1984
- fi: {
1985
- year: "vvvv",
1986
- month: "kk",
1987
- day: "pp"
1988
- },
1989
- fr: {
1990
- year: "aaaa",
1991
- month: "mm",
1992
- day: "jj"
1993
- },
1994
- fy: {
1995
- year: "jjjj",
1996
- month: "mm",
1997
- day: "dd"
1998
- },
1999
- ga: {
2000
- year: "bbbb",
2001
- month: "mm",
2002
- day: "ll"
2003
- },
2004
- gd: {
2005
- year: "bbbb",
2006
- month: "mm",
2007
- day: "ll"
2008
- },
2009
- gl: {
2010
- year: "aaaa",
2011
- month: "mm",
2012
- day: "dd"
2013
- },
2014
- he: {
2015
- year: "\u05E9\u05E0\u05D4",
2016
- month: "\u05D7\u05D5\u05D3\u05E9",
2017
- day: "\u05D9\u05D5\u05DD"
2018
- },
2019
- hr: {
2020
- year: "gggg",
2021
- month: "mm",
2022
- day: "dd"
2023
- },
2024
- hsb: {
2025
- year: "llll",
2026
- month: "mm",
2027
- day: "dd"
2028
- },
2029
- hu: {
2030
- year: "\xE9\xE9\xE9\xE9",
2031
- month: "hh",
2032
- day: "nn"
2033
- },
2034
- ia: {
2035
- year: "aaaa",
2036
- month: "mm",
2037
- day: "dd"
2038
- },
2039
- id: {
2040
- year: "tttt",
2041
- month: "bb",
2042
- day: "hh"
2043
- },
2044
- it: {
2045
- year: "aaaa",
2046
- month: "mm",
2047
- day: "gg"
2048
- },
2049
- ja: {
2050
- year: " \u5E74 ",
2051
- month: "\u6708",
2052
- day: "\u65E5"
2053
- },
2054
- ka: {
2055
- year: "\u10EC\u10EC\u10EC\u10EC",
2056
- month: "\u10D7\u10D7",
2057
- day: "\u10E0\u10E0"
2058
- },
2059
- kk: {
2060
- year: "\u0436\u0436\u0436\u0436",
2061
- month: "\u0430\u0430",
2062
- day: "\u043A\u043A"
2063
- },
2064
- kn: {
2065
- year: "\u0CB5\u0CB5\u0CB5\u0CB5",
2066
- month: "\u0CAE\u0CBF\u0CAE\u0CC0",
2067
- day: "\u0CA6\u0CBF\u0CA6\u0CBF"
2068
- },
2069
- ko: {
2070
- year: "\uC5F0\uB3C4",
2071
- month: "\uC6D4",
2072
- day: "\uC77C"
2073
- },
2074
- lb: {
2075
- year: "jjjj",
2076
- month: "mm",
2077
- day: "dd"
2078
- },
2079
- lo: {
2080
- year: "\u0E9B\u0E9B\u0E9B\u0E9B",
2081
- month: "\u0E94\u0E94",
2082
- day: "\u0EA7\u0EA7"
2083
- },
2084
- lt: {
2085
- year: "mmmm",
2086
- month: "mm",
2087
- day: "dd"
2088
- },
2089
- lv: {
2090
- year: "gggg",
2091
- month: "mm",
2092
- day: "dd"
2093
- },
2094
- meh: {
2095
- year: "aaaa",
2096
- month: "mm",
2097
- day: "dd"
2098
- },
2099
- ml: {
2100
- year: "\u0D35\u0D7C\u0D37\u0D02",
2101
- month: "\u0D2E\u0D3E\u0D38\u0D02",
2102
- day: "\u0D24\u0D40\u0D2F\u0D24\u0D3F"
2103
- },
2104
- ms: {
2105
- year: "tttt",
2106
- month: "mm",
2107
- day: "hh"
2108
- },
2109
- nl: {
2110
- year: "jjjj",
2111
- month: "mm",
2112
- day: "dd"
2113
- },
2114
- nn: {
2115
- year: "\xE5\xE5\xE5\xE5",
2116
- month: "mm",
2117
- day: "dd"
2118
- },
2119
- no: {
2120
- year: "\xE5\xE5\xE5\xE5",
2121
- month: "mm",
2122
- day: "dd"
2123
- },
2124
- oc: {
2125
- year: "aaaa",
2126
- month: "mm",
2127
- day: "jj"
2128
- },
2129
- pl: {
2130
- year: "rrrr",
2131
- month: "mm",
2132
- day: "dd"
2133
- },
2134
- pt: {
2135
- year: "aaaa",
2136
- month: "mm",
2137
- day: "dd"
2138
- },
2139
- rm: {
2140
- year: "oooo",
2141
- month: "mm",
2142
- day: "dd"
2143
- },
2144
- ro: {
2145
- year: "aaaa",
2146
- month: "ll",
2147
- day: "zz"
2148
- },
2149
- ru: {
2150
- year: "\u0433\u0433\u0433\u0433",
2151
- month: "\u043C\u043C",
2152
- day: "\u0434\u0434"
2153
- },
2154
- sc: {
2155
- year: "aaaa",
2156
- month: "mm",
2157
- day: "dd"
2158
- },
2159
- scn: {
2160
- year: "aaaa",
2161
- month: "mm",
2162
- day: "jj"
2163
- },
2164
- sk: {
2165
- year: "rrrr",
2166
- month: "mm",
2167
- day: "dd"
2168
- },
2169
- sl: {
2170
- year: "llll",
2171
- month: "mm",
2172
- day: "dd"
2173
- },
2174
- sr: {
2175
- year: "\u0433\u0433\u0433\u0433",
2176
- month: "\u043C\u043C",
2177
- day: "\u0434\u0434"
2178
- },
2179
- sv: {
2180
- year: "\xE5\xE5\xE5\xE5",
2181
- month: "mm",
2182
- day: "dd"
2183
- },
2184
- szl: {
2185
- year: "rrrr",
2186
- month: "mm",
2187
- day: "dd"
2188
- },
2189
- tg: {
2190
- year: "\u0441\u0441\u0441\u0441",
2191
- month: "\u043C\u043C",
2192
- day: "\u0440\u0440"
2193
- },
2194
- th: {
2195
- year: "\u0E1B\u0E1B\u0E1B\u0E1B",
2196
- month: "\u0E14\u0E14",
2197
- day: "\u0E27\u0E27"
2198
- },
2199
- tr: {
2200
- year: "yyyy",
2201
- month: "aa",
2202
- day: "gg"
2203
- },
2204
- uk: {
2205
- year: "\u0440\u0440\u0440\u0440",
2206
- month: "\u043C\u043C",
2207
- day: "\u0434\u0434"
2208
- },
2209
- "zh-CN": {
2210
- year: "\u5E74",
2211
- month: "\u6708",
2212
- day: "\u65E5"
2213
- },
2214
- "zh-TW": {
2215
- year: "\u5E74",
2216
- month: "\u6708",
2217
- day: "\u65E5"
2218
- }
2219
- }, "en");
2220
- function $3e3ed55ab2966714$export$d3f5c5e0a5023fa0(field, value, locale) {
2221
- if (field === "era" || field === "dayPeriod")
2222
- return value;
2223
- if (field === "year" || field === "month" || field === "day")
2224
- return $3e3ed55ab2966714$var$placeholders.getStringForLocale(field, locale);
2225
- return "\u2013\u2013";
2226
- }
2227
- var $3c0fc76039f1c516$var$EDITABLE_SEGMENTS = {
2228
- year: true,
2229
- month: true,
2230
- day: true,
2231
- hour: true,
2232
- minute: true,
2233
- second: true,
2234
- dayPeriod: true,
2235
- era: true
2236
- };
2237
- var $3c0fc76039f1c516$var$PAGE_STEP = {
2238
- year: 5,
2239
- month: 2,
2240
- day: 7,
2241
- hour: 2,
2242
- minute: 15,
2243
- second: 15
2244
- };
2245
- var $3c0fc76039f1c516$var$TYPE_MAPPING = {
2246
- dayperiod: "dayPeriod"
2247
- };
2248
- function $3c0fc76039f1c516$export$60e84778edff6d26(props) {
2249
- let { locale, createCalendar: createCalendar4, hideTimeZone, isDisabled, isReadOnly, isRequired } = props;
2250
- let v = props.value || props.defaultValue || props.placeholderValue;
2251
- let [granularity, defaultTimeZone] = ($35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
2252
- let timeZone = defaultTimeZone || "UTC";
2253
- if (v && !(granularity in v))
2254
- throw new Error("Invalid granularity " + granularity + " for value " + v.toString());
2255
- let defaultFormatter = (useMemo)(() => new (DateFormatter)(locale), [
2256
- locale
2257
- ]);
2258
- let calendar = (useMemo)(() => createCalendar4(defaultFormatter.resolvedOptions().calendar), [
2259
- createCalendar4,
2260
- defaultFormatter
2261
- ]);
2262
- let [value, setDate] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, props.defaultValue, props.onChange);
2263
- let calendarValue = (useMemo)(() => ($35a22f14a1f04b11$export$61a490a80c552550)(value, calendar), [
2264
- value,
2265
- calendar
2266
- ]);
2267
- let [placeholderDate, setPlaceholderDate] = (useState)(() => ($35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
2268
- let val = calendarValue || placeholderDate;
2269
- let showEra = calendar.identifier === "gregory" && val.era === "BC";
2270
- var _props_maxGranularity;
2271
- let formatOpts = (useMemo)(() => ({
2272
- granularity,
2273
- maxGranularity: (_props_maxGranularity = props.maxGranularity) !== null && _props_maxGranularity !== void 0 ? _props_maxGranularity : "year",
2274
- timeZone: defaultTimeZone,
2275
- hideTimeZone,
2276
- hourCycle: props.hourCycle,
2277
- showEra,
2278
- shouldForceLeadingZeros: props.shouldForceLeadingZeros
2279
- }), [
2280
- props.maxGranularity,
2281
- granularity,
2282
- props.hourCycle,
2283
- props.shouldForceLeadingZeros,
2284
- defaultTimeZone,
2285
- hideTimeZone,
2286
- showEra
2287
- ]);
2288
- let opts = (useMemo)(() => ($35a22f14a1f04b11$export$7e319ea407e63bc0)({}, formatOpts), [
2289
- formatOpts
2290
- ]);
2291
- let dateFormatter = (useMemo)(() => new (DateFormatter)(locale, opts), [
2292
- locale,
2293
- opts
2294
- ]);
2295
- let resolvedOptions = (useMemo)(() => dateFormatter.resolvedOptions(), [
2296
- dateFormatter
2297
- ]);
2298
- let allSegments = (useMemo)(() => dateFormatter.formatToParts(/* @__PURE__ */ new Date()).filter((seg) => $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[seg.type]).reduce((p, seg) => (p[seg.type] = true, p), {}), [
2299
- dateFormatter
2300
- ]);
2301
- let [validSegments, setValidSegments] = (useState)(() => props.value || props.defaultValue ? {
2302
- ...allSegments
2303
- } : {});
2304
- let clearedSegment = (useRef)();
2305
- let lastCalendarIdentifier = (useRef)(calendar.identifier);
2306
- (useEffect)(() => {
2307
- if (calendar.identifier !== lastCalendarIdentifier.current) {
2308
- lastCalendarIdentifier.current = calendar.identifier;
2309
- setPlaceholderDate((placeholder) => Object.keys(validSegments).length > 0 ? (toCalendar)(placeholder, calendar) : ($35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
2310
- }
2311
- }, [
2312
- calendar,
2313
- granularity,
2314
- validSegments,
2315
- defaultTimeZone,
2316
- props.placeholderValue
2317
- ]);
2318
- if (value && Object.keys(validSegments).length < Object.keys(allSegments).length) {
2319
- validSegments = {
2320
- ...allSegments
2321
- };
2322
- setValidSegments(validSegments);
2323
- }
2324
- if (value == null && Object.keys(validSegments).length === Object.keys(allSegments).length) {
2325
- validSegments = {};
2326
- setValidSegments(validSegments);
2327
- setPlaceholderDate(($35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
2328
- }
2329
- let displayValue = calendarValue && Object.keys(validSegments).length >= Object.keys(allSegments).length ? calendarValue : placeholderDate;
2330
- let setValue = (newValue) => {
2331
- if (props.isDisabled || props.isReadOnly)
2332
- return;
2333
- let validKeys = Object.keys(validSegments);
2334
- let allKeys = Object.keys(allSegments);
2335
- if (newValue == null) {
2336
- setDate(null);
2337
- setPlaceholderDate(($35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone));
2338
- setValidSegments({});
2339
- } else if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod && clearedSegment.current !== "dayPeriod") {
2340
- newValue = (toCalendar)(newValue, (v === null || v === void 0 ? void 0 : v.calendar) || new (GregorianCalendar)());
2341
- setDate(newValue);
2342
- } else
2343
- setPlaceholderDate(newValue);
2344
- clearedSegment.current = null;
2345
- };
2346
- let dateValue = (useMemo)(() => displayValue.toDate(timeZone), [
2347
- displayValue,
2348
- timeZone
2349
- ]);
2350
- let segments = (useMemo)(() => dateFormatter.formatToParts(dateValue).map((segment) => {
2351
- let isEditable = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type];
2352
- if (segment.type === "era" && calendar.getEras().length === 1)
2353
- isEditable = false;
2354
- let isPlaceholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] && !validSegments[segment.type];
2355
- let placeholder = $3c0fc76039f1c516$var$EDITABLE_SEGMENTS[segment.type] ? ($3e3ed55ab2966714$export$d3f5c5e0a5023fa0)(segment.type, segment.value, locale) : null;
2356
- return {
2357
- type: $3c0fc76039f1c516$var$TYPE_MAPPING[segment.type] || segment.type,
2358
- text: isPlaceholder ? placeholder : segment.value,
2359
- ...$3c0fc76039f1c516$var$getSegmentLimits(displayValue, segment.type, resolvedOptions),
2360
- isPlaceholder,
2361
- placeholder,
2362
- isEditable
2363
- };
2364
- }), [
2365
- dateValue,
2366
- validSegments,
2367
- dateFormatter,
2368
- resolvedOptions,
2369
- displayValue,
2370
- calendar,
2371
- locale
2372
- ]);
2373
- if (allSegments.era && validSegments.year && !validSegments.era) {
2374
- validSegments.era = true;
2375
- setValidSegments({
2376
- ...validSegments
2377
- });
2378
- } else if (!allSegments.era && validSegments.era) {
2379
- delete validSegments.era;
2380
- setValidSegments({
2381
- ...validSegments
2382
- });
2383
- }
2384
- let markValid = (part) => {
2385
- validSegments[part] = true;
2386
- if (part === "year" && allSegments.era)
2387
- validSegments.era = true;
2388
- setValidSegments({
2389
- ...validSegments
2390
- });
2391
- };
2392
- let adjustSegment = (type, amount) => {
2393
- if (!validSegments[type]) {
2394
- markValid(type);
2395
- let validKeys = Object.keys(validSegments);
2396
- let allKeys = Object.keys(allSegments);
2397
- if (validKeys.length >= allKeys.length || validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod)
2398
- setValue(displayValue);
2399
- } else
2400
- setValue($3c0fc76039f1c516$var$addSegment(displayValue, type, amount, resolvedOptions));
2401
- };
2402
- let validationState = props.validationState || (($35a22f14a1f04b11$export$eac50920cf2fd59a)(calendarValue, props.minValue, props.maxValue) ? "invalid" : null);
2403
- var _props_maxGranularity1;
2404
- return {
2405
- value: calendarValue,
2406
- dateValue,
2407
- calendar,
2408
- setValue,
2409
- segments,
2410
- dateFormatter,
2411
- validationState,
2412
- granularity,
2413
- maxGranularity: (_props_maxGranularity1 = props.maxGranularity) !== null && _props_maxGranularity1 !== void 0 ? _props_maxGranularity1 : "year",
2414
- isDisabled,
2415
- isReadOnly,
2416
- isRequired,
2417
- increment(part) {
2418
- adjustSegment(part, 1);
2419
- },
2420
- decrement(part) {
2421
- adjustSegment(part, -1);
2422
- },
2423
- incrementPage(part) {
2424
- adjustSegment(part, $3c0fc76039f1c516$var$PAGE_STEP[part] || 1);
2425
- },
2426
- decrementPage(part) {
2427
- adjustSegment(part, -($3c0fc76039f1c516$var$PAGE_STEP[part] || 1));
2428
- },
2429
- setSegment(part, v2) {
2430
- markValid(part);
2431
- setValue($3c0fc76039f1c516$var$setSegment(displayValue, part, v2, resolvedOptions));
2432
- },
2433
- confirmPlaceholder() {
2434
- if (props.isDisabled || props.isReadOnly)
2435
- return;
2436
- let validKeys = Object.keys(validSegments);
2437
- let allKeys = Object.keys(allSegments);
2438
- if (validKeys.length === allKeys.length - 1 && allSegments.dayPeriod && !validSegments.dayPeriod) {
2439
- validSegments = {
2440
- ...allSegments
2441
- };
2442
- setValidSegments(validSegments);
2443
- setValue(displayValue.copy());
2444
- }
2445
- },
2446
- clearSegment(part) {
2447
- delete validSegments[part];
2448
- clearedSegment.current = part;
2449
- setValidSegments({
2450
- ...validSegments
2451
- });
2452
- let placeholder = ($35a22f14a1f04b11$export$66aa2b09de4b1ea5)(props.placeholderValue, granularity, calendar, defaultTimeZone);
2453
- let value2 = displayValue;
2454
- if (part === "dayPeriod" && "hour" in displayValue && "hour" in placeholder) {
2455
- let isPM = displayValue.hour >= 12;
2456
- let shouldBePM = placeholder.hour >= 12;
2457
- if (isPM && !shouldBePM)
2458
- value2 = displayValue.set({
2459
- hour: displayValue.hour - 12
2460
- });
2461
- else if (!isPM && shouldBePM)
2462
- value2 = displayValue.set({
2463
- hour: displayValue.hour + 12
2464
- });
2465
- } else if (part in displayValue)
2466
- value2 = displayValue.set({
2467
- [part]: placeholder[part]
2468
- });
2469
- setDate(null);
2470
- setValue(value2);
2471
- },
2472
- formatValue(fieldOptions) {
2473
- if (!calendarValue)
2474
- return "";
2475
- let formatOptions = ($35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, formatOpts);
2476
- let formatter = new (DateFormatter)(locale, formatOptions);
2477
- return formatter.format(dateValue);
2478
- }
2479
- };
2480
- }
2481
- function $3c0fc76039f1c516$var$getSegmentLimits(date, type, options) {
2482
- switch (type) {
2483
- case "era": {
2484
- let eras = date.calendar.getEras();
2485
- return {
2486
- value: eras.indexOf(date.era),
2487
- minValue: 0,
2488
- maxValue: eras.length - 1
2489
- };
2490
- }
2491
- case "year":
2492
- return {
2493
- value: date.year,
2494
- minValue: 1,
2495
- maxValue: date.calendar.getYearsInEra(date)
2496
- };
2497
- case "month":
2498
- return {
2499
- value: date.month,
2500
- minValue: (getMinimumMonthInYear)(date),
2501
- maxValue: date.calendar.getMonthsInYear(date)
2502
- };
2503
- case "day":
2504
- return {
2505
- value: date.day,
2506
- minValue: (getMinimumDayInMonth)(date),
2507
- maxValue: date.calendar.getDaysInMonth(date)
2508
- };
2509
- }
2510
- if ("hour" in date)
2511
- switch (type) {
2512
- case "dayPeriod":
2513
- return {
2514
- value: date.hour >= 12 ? 12 : 0,
2515
- minValue: 0,
2516
- maxValue: 12
2517
- };
2518
- case "hour":
2519
- if (options.hour12) {
2520
- let isPM = date.hour >= 12;
2521
- return {
2522
- value: date.hour,
2523
- minValue: isPM ? 12 : 0,
2524
- maxValue: isPM ? 23 : 11
2525
- };
2526
- }
2527
- return {
2528
- value: date.hour,
2529
- minValue: 0,
2530
- maxValue: 23
2531
- };
2532
- case "minute":
2533
- return {
2534
- value: date.minute,
2535
- minValue: 0,
2536
- maxValue: 59
2537
- };
2538
- case "second":
2539
- return {
2540
- value: date.second,
2541
- minValue: 0,
2542
- maxValue: 59
2543
- };
2544
- }
2545
- return {};
2546
- }
2547
- function $3c0fc76039f1c516$var$addSegment(value, part, amount, options) {
2548
- switch (part) {
2549
- case "era":
2550
- case "year":
2551
- case "month":
2552
- case "day":
2553
- return value.cycle(part, amount, {
2554
- round: part === "year"
2555
- });
2556
- }
2557
- if ("hour" in value)
2558
- switch (part) {
2559
- case "dayPeriod": {
2560
- let hours = value.hour;
2561
- let isPM = hours >= 12;
2562
- return value.set({
2563
- hour: isPM ? hours - 12 : hours + 12
2564
- });
2565
- }
2566
- case "hour":
2567
- case "minute":
2568
- case "second":
2569
- return value.cycle(part, amount, {
2570
- round: part !== "hour",
2571
- hourCycle: options.hour12 ? 12 : 24
2572
- });
2573
- }
2574
- }
2575
- function $3c0fc76039f1c516$var$setSegment(value, part, segmentValue, options) {
2576
- switch (part) {
2577
- case "day":
2578
- case "month":
2579
- case "year":
2580
- case "era":
2581
- return value.set({
2582
- [part]: segmentValue
2583
- });
2584
- }
2585
- if ("hour" in value)
2586
- switch (part) {
2587
- case "dayPeriod": {
2588
- let hours = value.hour;
2589
- let wasPM = hours >= 12;
2590
- let isPM = segmentValue >= 12;
2591
- if (isPM === wasPM)
2592
- return value;
2593
- return value.set({
2594
- hour: wasPM ? hours - 12 : hours + 12
2595
- });
2596
- }
2597
- case "hour":
2598
- if (options.hour12) {
2599
- let hours = value.hour;
2600
- let wasPM = hours >= 12;
2601
- if (!wasPM && segmentValue === 12)
2602
- segmentValue = 0;
2603
- if (wasPM && segmentValue < 12)
2604
- segmentValue += 12;
2605
- }
2606
- case "minute":
2607
- case "second":
2608
- return value.set({
2609
- [part]: segmentValue
2610
- });
2611
- }
2612
- }
2613
- function $93c38a5e28be6249$export$e50a61c1de9f574(props) {
2614
- var _props_isDateUnavailable, _props_isDateUnavailable1;
2615
- let overlayState = ($fc909762b330b746$export$61c6a8c84e605fb6)(props);
2616
- let [controlledValue, setControlledValue] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, props.defaultValue || null, props.onChange);
2617
- let [placeholderValue, setPlaceholderValue] = (useState)(() => controlledValue || {
2618
- start: null,
2619
- end: null
2620
- });
2621
- if (controlledValue == null && placeholderValue.start && placeholderValue.end) {
2622
- placeholderValue = {
2623
- start: null,
2624
- end: null
2625
- };
2626
- setPlaceholderValue(placeholderValue);
2627
- }
2628
- let value = controlledValue || placeholderValue;
2629
- let setValue = (value2) => {
2630
- setPlaceholderValue(value2);
2631
- if ((value2 === null || value2 === void 0 ? void 0 : value2.start) && value2.end)
2632
- setControlledValue(value2);
2633
- else
2634
- setControlledValue(null);
2635
- };
2636
- let v = (value === null || value === void 0 ? void 0 : value.start) || (value === null || value === void 0 ? void 0 : value.end) || props.placeholderValue;
2637
- let [granularity] = ($35a22f14a1f04b11$export$2440da353cedad43)(v, props.granularity);
2638
- let hasTime = granularity === "hour" || granularity === "minute" || granularity === "second";
2639
- var _props_shouldCloseOnSelect;
2640
- let shouldCloseOnSelect = (_props_shouldCloseOnSelect = props.shouldCloseOnSelect) !== null && _props_shouldCloseOnSelect !== void 0 ? _props_shouldCloseOnSelect : true;
2641
- let [dateRange, setSelectedDateRange] = (useState)(null);
2642
- let [timeRange, setSelectedTimeRange] = (useState)(null);
2643
- if (value && value.start && value.end) {
2644
- dateRange = value;
2645
- if ("hour" in value.start)
2646
- timeRange = value;
2647
- }
2648
- let commitValue = (dateRange2, timeRange2) => {
2649
- setValue({
2650
- start: "timeZone" in timeRange2.start ? timeRange2.start.set((toCalendarDate)(dateRange2.start)) : (toCalendarDateTime)(dateRange2.start, timeRange2.start),
2651
- end: "timeZone" in timeRange2.end ? timeRange2.end.set((toCalendarDate)(dateRange2.end)) : (toCalendarDateTime)(dateRange2.end, timeRange2.end)
2652
- });
2653
- setSelectedDateRange(null);
2654
- setSelectedTimeRange(null);
2655
- };
2656
- let setDateRange = (range) => {
2657
- let shouldClose = typeof shouldCloseOnSelect === "function" ? shouldCloseOnSelect() : shouldCloseOnSelect;
2658
- if (hasTime) {
2659
- if (shouldClose || range.start && range.end && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) && (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end))
2660
- commitValue(range, {
2661
- start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
2662
- end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
2663
- });
2664
- else
2665
- setSelectedDateRange(range);
2666
- } else if (range.start && range.end)
2667
- setValue(range);
2668
- else
2669
- setSelectedDateRange(range);
2670
- if (shouldClose)
2671
- overlayState.setOpen(false);
2672
- };
2673
- let setTimeRange = (range) => {
2674
- if ((dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && (dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) && range.start && range.end)
2675
- commitValue(dateRange, range);
2676
- else
2677
- setSelectedTimeRange(range);
2678
- };
2679
- let validationState = props.validationState || (value != null && (($35a22f14a1f04b11$export$eac50920cf2fd59a)(value.start, props.minValue, props.maxValue) || ($35a22f14a1f04b11$export$eac50920cf2fd59a)(value.end, props.minValue, props.maxValue) || value.end != null && value.start != null && value.end.compare(value.start) < 0 || (value === null || value === void 0 ? void 0 : value.start) && ((_props_isDateUnavailable = props.isDateUnavailable) === null || _props_isDateUnavailable === void 0 ? void 0 : _props_isDateUnavailable.call(props, value.start)) || (value === null || value === void 0 ? void 0 : value.end) && ((_props_isDateUnavailable1 = props.isDateUnavailable) === null || _props_isDateUnavailable1 === void 0 ? void 0 : _props_isDateUnavailable1.call(props, value.end))) ? "invalid" : null);
2680
- return {
2681
- value,
2682
- setValue,
2683
- dateRange,
2684
- timeRange,
2685
- granularity,
2686
- hasTime,
2687
- setDate(part, date) {
2688
- setDateRange({
2689
- ...dateRange,
2690
- [part]: date
2691
- });
2692
- },
2693
- setTime(part, time) {
2694
- setTimeRange({
2695
- ...timeRange,
2696
- [part]: time
2697
- });
2698
- },
2699
- setDateTime(part, dateTime) {
2700
- setValue({
2701
- ...value,
2702
- [part]: dateTime
2703
- });
2704
- },
2705
- setDateRange,
2706
- setTimeRange,
2707
- ...overlayState,
2708
- setOpen(isOpen) {
2709
- 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)
2710
- commitValue(dateRange, {
2711
- start: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.start) || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue),
2712
- end: (timeRange === null || timeRange === void 0 ? void 0 : timeRange.end) || ($35a22f14a1f04b11$export$c5221a78ef73c5e9)(props.placeholderValue)
2713
- });
2714
- overlayState.setOpen(isOpen);
2715
- },
2716
- validationState,
2717
- formatValue(locale, fieldOptions) {
2718
- if (!value || !value.start || !value.end)
2719
- return null;
2720
- let startTimeZone = "timeZone" in value.start ? value.start.timeZone : void 0;
2721
- let startGranularity = props.granularity || (value.start && "minute" in value.start ? "minute" : "day");
2722
- let endTimeZone = "timeZone" in value.end ? value.end.timeZone : void 0;
2723
- let endGranularity = props.granularity || (value.end && "minute" in value.end ? "minute" : "day");
2724
- let startOptions = ($35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
2725
- granularity: startGranularity,
2726
- timeZone: startTimeZone,
2727
- hideTimeZone: props.hideTimeZone,
2728
- hourCycle: props.hourCycle,
2729
- showEra: value.start.calendar.identifier === "gregory" && value.start.era === "BC" || value.end.calendar.identifier === "gregory" && value.end.era === "BC"
2730
- });
2731
- let startDate = value.start.toDate(startTimeZone || "UTC");
2732
- let endDate = value.end.toDate(endTimeZone || "UTC");
2733
- let startFormatter = new (DateFormatter)(locale, startOptions);
2734
- let endFormatter;
2735
- if (startTimeZone === endTimeZone && startGranularity === endGranularity && value.start.compare(value.end) !== 0) {
2736
- try {
2737
- let parts14 = startFormatter.formatRangeToParts(startDate, endDate);
2738
- let separatorIndex = -1;
2739
- for (let i = 0; i < parts14.length; i++) {
2740
- let part = parts14[i];
2741
- if (part.source === "shared" && part.type === "literal")
2742
- separatorIndex = i;
2743
- else if (part.source === "endRange")
2744
- break;
2745
- }
2746
- let start = "";
2747
- let end = "";
2748
- for (let i = 0; i < parts14.length; i++) {
2749
- if (i < separatorIndex)
2750
- start += parts14[i].value;
2751
- else if (i > separatorIndex)
2752
- end += parts14[i].value;
2753
- }
2754
- return {
2755
- start,
2756
- end
2757
- };
2758
- } catch (e) {
2759
- }
2760
- endFormatter = startFormatter;
2761
- } else {
2762
- let endOptions = ($35a22f14a1f04b11$export$7e319ea407e63bc0)(fieldOptions, {
2763
- granularity: endGranularity,
2764
- timeZone: endTimeZone,
2765
- hideTimeZone: props.hideTimeZone,
2766
- hourCycle: props.hourCycle
2767
- });
2768
- endFormatter = new (DateFormatter)(locale, endOptions);
2769
- }
2770
- return {
2771
- start: startFormatter.format(startDate),
2772
- end: endFormatter.format(endDate)
2773
- };
2774
- }
2775
- };
2776
- }
2777
- function $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue) {
2778
- return minValue != null && date.compare(minValue) < 0 || maxValue != null && date.compare(maxValue) > 0;
2779
- }
2780
- function $f62d864046160412$export$f4a51ff076cc9a09(date, duration, locale, minValue, maxValue) {
2781
- let halfDuration = {};
2782
- for (let key in duration) {
2783
- halfDuration[key] = Math.floor(duration[key] / 2);
2784
- if (halfDuration[key] > 0 && duration[key] % 2 === 0)
2785
- halfDuration[key]--;
2786
- }
2787
- let aligned = $f62d864046160412$export$144a00ba6044eb9(date, duration, locale).subtract(halfDuration);
2788
- return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue);
2789
- }
2790
- function $f62d864046160412$export$144a00ba6044eb9(date, duration, locale, minValue, maxValue) {
2791
- let aligned = date;
2792
- if (duration.years)
2793
- aligned = (startOfYear)(date);
2794
- else if (duration.months)
2795
- aligned = (startOfMonth)(date);
2796
- else if (duration.weeks)
2797
- aligned = (startOfWeek)(date, locale);
2798
- return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue);
2799
- }
2800
- function $f62d864046160412$export$530edbfc915b2b04(date, duration, locale, minValue, maxValue) {
2801
- let d = {
2802
- ...duration
2803
- };
2804
- if (duration.days)
2805
- d.days--;
2806
- else if (duration.weeks)
2807
- d.weeks--;
2808
- else if (duration.months)
2809
- d.months--;
2810
- else if (duration.years)
2811
- d.years--;
2812
- let aligned = $f62d864046160412$export$144a00ba6044eb9(date, duration, locale).subtract(d);
2813
- return $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue);
2814
- }
2815
- function $f62d864046160412$export$5bb865b12696a77d(date, aligned, duration, locale, minValue, maxValue) {
2816
- if (minValue && date.compare(minValue) >= 0)
2817
- aligned = (maxDate)(aligned, $f62d864046160412$export$144a00ba6044eb9((toCalendarDate)(minValue), duration, locale));
2818
- if (maxValue && date.compare(maxValue) <= 0)
2819
- aligned = (minDate)(aligned, $f62d864046160412$export$530edbfc915b2b04((toCalendarDate)(maxValue), duration, locale));
2820
- return aligned;
2821
- }
2822
- function $f62d864046160412$export$4f5203c0d889109e(date, minValue, maxValue) {
2823
- if (minValue)
2824
- date = (maxDate)(date, (toCalendarDate)(minValue));
2825
- if (maxValue)
2826
- date = (minDate)(date, (toCalendarDate)(maxValue));
2827
- return date;
2828
- }
2829
- function $f62d864046160412$export$a1d3911297b952d7(date, minValue, isDateUnavailable) {
2830
- if (!isDateUnavailable)
2831
- return date;
2832
- while (date.compare(minValue) >= 0 && isDateUnavailable(date))
2833
- date = date.subtract({
2834
- days: 1
2835
- });
2836
- if (date.compare(minValue) >= 0)
2837
- return date;
2838
- }
2839
- function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
2840
- let defaultFormatter = (useMemo)(() => new (DateFormatter)(props.locale), [
2841
- props.locale
2842
- ]);
2843
- let resolvedOptions = (useMemo)(() => defaultFormatter.resolvedOptions(), [
2844
- defaultFormatter
2845
- ]);
2846
- let { locale, createCalendar: createCalendar4, visibleDuration = {
2847
- months: 1
2848
- }, minValue, maxValue, selectionAlignment, isDateUnavailable, pageBehavior = "visible" } = props;
2849
- let calendar = (useMemo)(() => createCalendar4(resolvedOptions.calendar), [
2850
- createCalendar4,
2851
- resolvedOptions.calendar
2852
- ]);
2853
- let [value, setControlledValue] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(props.value, props.defaultValue, props.onChange);
2854
- let calendarDateValue = (useMemo)(() => value ? (toCalendar)((toCalendarDate)(value), calendar) : null, [
2855
- value,
2856
- calendar
2857
- ]);
2858
- let timeZone = (useMemo)(() => value && "timeZone" in value ? value.timeZone : resolvedOptions.timeZone, [
2859
- value,
2860
- resolvedOptions.timeZone
2861
- ]);
2862
- let focusedCalendarDate = (useMemo)(() => props.focusedValue ? ($f62d864046160412$export$4f5203c0d889109e)((toCalendar)((toCalendarDate)(props.focusedValue), calendar), minValue, maxValue) : void 0, [
2863
- props.focusedValue,
2864
- calendar,
2865
- minValue,
2866
- maxValue
2867
- ]);
2868
- let defaultFocusedCalendarDate = (useMemo)(() => ($f62d864046160412$export$4f5203c0d889109e)(props.defaultFocusedValue ? (toCalendar)((toCalendarDate)(props.defaultFocusedValue), calendar) : calendarDateValue || (toCalendar)((today)(timeZone), calendar), minValue, maxValue), [
2869
- props.defaultFocusedValue,
2870
- calendarDateValue,
2871
- timeZone,
2872
- calendar,
2873
- minValue,
2874
- maxValue
2875
- ]);
2876
- let [focusedDate, setFocusedDate] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);
2877
- let [startDate, setStartDate] = (useState)(() => {
2878
- switch (selectionAlignment) {
2879
- case "start":
2880
- return ($f62d864046160412$export$144a00ba6044eb9)(focusedDate, visibleDuration, locale, minValue, maxValue);
2881
- case "end":
2882
- return ($f62d864046160412$export$530edbfc915b2b04)(focusedDate, visibleDuration, locale, minValue, maxValue);
2883
- case "center":
2884
- default:
2885
- return ($f62d864046160412$export$f4a51ff076cc9a09)(focusedDate, visibleDuration, locale, minValue, maxValue);
2886
- }
2887
- });
2888
- let [isFocused, setFocused] = (useState)(props.autoFocus || false);
2889
- let endDate = (useMemo)(() => {
2890
- let duration = {
2891
- ...visibleDuration
2892
- };
2893
- if (duration.days)
2894
- duration.days--;
2895
- else
2896
- duration.days = -1;
2897
- return startDate.add(duration);
2898
- }, [
2899
- startDate,
2900
- visibleDuration
2901
- ]);
2902
- let [lastCalendarIdentifier, setLastCalendarIdentifier] = (useState)(calendar.identifier);
2903
- if (calendar.identifier !== lastCalendarIdentifier) {
2904
- let newFocusedDate = (toCalendar)(focusedDate, calendar);
2905
- setStartDate(($f62d864046160412$export$f4a51ff076cc9a09)(newFocusedDate, visibleDuration, locale, minValue, maxValue));
2906
- setFocusedDate(newFocusedDate);
2907
- setLastCalendarIdentifier(calendar.identifier);
2908
- }
2909
- if (($f62d864046160412$export$eac50920cf2fd59a)(focusedDate, minValue, maxValue))
2910
- setFocusedDate(($f62d864046160412$export$4f5203c0d889109e)(focusedDate, minValue, maxValue));
2911
- else if (focusedDate.compare(startDate) < 0)
2912
- setStartDate(($f62d864046160412$export$530edbfc915b2b04)(focusedDate, visibleDuration, locale, minValue, maxValue));
2913
- else if (focusedDate.compare(endDate) > 0)
2914
- setStartDate(($f62d864046160412$export$144a00ba6044eb9)(focusedDate, visibleDuration, locale, minValue, maxValue));
2915
- function focusCell(date) {
2916
- date = ($f62d864046160412$export$4f5203c0d889109e)(date, minValue, maxValue);
2917
- setFocusedDate(date);
2918
- }
2919
- function setValue(newValue) {
2920
- if (!props.isDisabled && !props.isReadOnly) {
2921
- newValue = ($f62d864046160412$export$4f5203c0d889109e)(newValue, minValue, maxValue);
2922
- newValue = ($f62d864046160412$export$a1d3911297b952d7)(newValue, startDate, isDateUnavailable);
2923
- if (!newValue)
2924
- return;
2925
- newValue = (toCalendar)(newValue, (value === null || value === void 0 ? void 0 : value.calendar) || new (GregorianCalendar)());
2926
- if (value && "hour" in value)
2927
- setControlledValue(value.set(newValue));
2928
- else
2929
- setControlledValue(newValue);
2930
- }
2931
- }
2932
- let isUnavailable = (useMemo)(() => {
2933
- if (!calendarDateValue)
2934
- return false;
2935
- if (isDateUnavailable && isDateUnavailable(calendarDateValue))
2936
- return true;
2937
- return ($f62d864046160412$export$eac50920cf2fd59a)(calendarDateValue, minValue, maxValue);
2938
- }, [
2939
- calendarDateValue,
2940
- isDateUnavailable,
2941
- minValue,
2942
- maxValue
2943
- ]);
2944
- let validationState = props.validationState || (isUnavailable ? "invalid" : null);
2945
- let pageDuration = (useMemo)(() => {
2946
- if (pageBehavior === "visible")
2947
- return visibleDuration;
2948
- return $131cf43a05231e1e$var$unitDuration(visibleDuration);
2949
- }, [
2950
- pageBehavior,
2951
- visibleDuration
2952
- ]);
2953
- return {
2954
- isDisabled: props.isDisabled,
2955
- isReadOnly: props.isReadOnly,
2956
- value: calendarDateValue,
2957
- setValue,
2958
- visibleRange: {
2959
- start: startDate,
2960
- end: endDate
2961
- },
2962
- minValue,
2963
- maxValue,
2964
- focusedDate,
2965
- timeZone,
2966
- validationState,
2967
- setFocusedDate(date) {
2968
- focusCell(date);
2969
- setFocused(true);
2970
- },
2971
- focusNextDay() {
2972
- focusCell(focusedDate.add({
2973
- days: 1
2974
- }));
2975
- },
2976
- focusPreviousDay() {
2977
- focusCell(focusedDate.subtract({
2978
- days: 1
2979
- }));
2980
- },
2981
- focusNextRow() {
2982
- if (visibleDuration.days)
2983
- this.focusNextPage();
2984
- else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years)
2985
- focusCell(focusedDate.add({
2986
- weeks: 1
2987
- }));
2988
- },
2989
- focusPreviousRow() {
2990
- if (visibleDuration.days)
2991
- this.focusPreviousPage();
2992
- else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years)
2993
- focusCell(focusedDate.subtract({
2994
- weeks: 1
2995
- }));
2996
- },
2997
- focusNextPage() {
2998
- let start = startDate.add(pageDuration);
2999
- setFocusedDate(($f62d864046160412$export$4f5203c0d889109e)(focusedDate.add(pageDuration), minValue, maxValue));
3000
- setStartDate(($f62d864046160412$export$144a00ba6044eb9)(($f62d864046160412$export$5bb865b12696a77d)(focusedDate, start, pageDuration, locale, minValue, maxValue), pageDuration, locale));
3001
- },
3002
- focusPreviousPage() {
3003
- let start = startDate.subtract(pageDuration);
3004
- setFocusedDate(($f62d864046160412$export$4f5203c0d889109e)(focusedDate.subtract(pageDuration), minValue, maxValue));
3005
- setStartDate(($f62d864046160412$export$144a00ba6044eb9)(($f62d864046160412$export$5bb865b12696a77d)(focusedDate, start, pageDuration, locale, minValue, maxValue), pageDuration, locale));
3006
- },
3007
- focusSectionStart() {
3008
- if (visibleDuration.days)
3009
- focusCell(startDate);
3010
- else if (visibleDuration.weeks)
3011
- focusCell((startOfWeek)(focusedDate, locale));
3012
- else if (visibleDuration.months || visibleDuration.years)
3013
- focusCell((startOfMonth)(focusedDate));
3014
- },
3015
- focusSectionEnd() {
3016
- if (visibleDuration.days)
3017
- focusCell(endDate);
3018
- else if (visibleDuration.weeks)
3019
- focusCell((endOfWeek)(focusedDate, locale));
3020
- else if (visibleDuration.months || visibleDuration.years)
3021
- focusCell((endOfMonth)(focusedDate));
3022
- },
3023
- focusNextSection(larger) {
3024
- if (!larger && !visibleDuration.days) {
3025
- focusCell(focusedDate.add($131cf43a05231e1e$var$unitDuration(visibleDuration)));
3026
- return;
3027
- }
3028
- if (visibleDuration.days)
3029
- this.focusNextPage();
3030
- else if (visibleDuration.weeks)
3031
- focusCell(focusedDate.add({
3032
- months: 1
3033
- }));
3034
- else if (visibleDuration.months || visibleDuration.years)
3035
- focusCell(focusedDate.add({
3036
- years: 1
3037
- }));
3038
- },
3039
- focusPreviousSection(larger) {
3040
- if (!larger && !visibleDuration.days) {
3041
- focusCell(focusedDate.subtract($131cf43a05231e1e$var$unitDuration(visibleDuration)));
3042
- return;
3043
- }
3044
- if (visibleDuration.days)
3045
- this.focusPreviousPage();
3046
- else if (visibleDuration.weeks)
3047
- focusCell(focusedDate.subtract({
3048
- months: 1
3049
- }));
3050
- else if (visibleDuration.months || visibleDuration.years)
3051
- focusCell(focusedDate.subtract({
3052
- years: 1
3053
- }));
3054
- },
3055
- selectFocusedDate() {
3056
- setValue(focusedDate);
3057
- },
3058
- selectDate(date) {
3059
- setValue(date);
3060
- },
3061
- isFocused,
3062
- setFocused,
3063
- isInvalid(date) {
3064
- return ($f62d864046160412$export$eac50920cf2fd59a)(date, minValue, maxValue);
3065
- },
3066
- isSelected(date) {
3067
- return calendarDateValue != null && (isSameDay)(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
3068
- },
3069
- isCellFocused(date) {
3070
- return isFocused && focusedDate && (isSameDay)(date, focusedDate);
3071
- },
3072
- isCellDisabled(date) {
3073
- return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);
3074
- },
3075
- isCellUnavailable(date) {
3076
- return props.isDateUnavailable && props.isDateUnavailable(date);
3077
- },
3078
- isPreviousVisibleRangeInvalid() {
3079
- let prev = startDate.subtract({
3080
- days: 1
3081
- });
3082
- return (isSameDay)(prev, startDate) || this.isInvalid(prev, minValue, maxValue);
3083
- },
3084
- isNextVisibleRangeInvalid() {
3085
- let next = endDate.add({
3086
- days: 1
3087
- });
3088
- return (isSameDay)(next, endDate) || this.isInvalid(next, minValue, maxValue);
3089
- },
3090
- getDatesInWeek(weekIndex, from = startDate) {
3091
- let date = from.add({
3092
- weeks: weekIndex
3093
- });
3094
- let dates = [];
3095
- date = (startOfWeek)(date, locale);
3096
- let dayOfWeek = (getDayOfWeek)(date, locale);
3097
- for (let i = 0; i < dayOfWeek; i++)
3098
- dates.push(null);
3099
- while (dates.length < 7) {
3100
- dates.push(date);
3101
- let nextDate = date.add({
3102
- days: 1
3103
- });
3104
- if ((isSameDay)(date, nextDate))
3105
- break;
3106
- date = nextDate;
3107
- }
3108
- while (dates.length < 7)
3109
- dates.push(null);
3110
- return dates;
3111
- }
3112
- };
3113
- }
3114
- function $131cf43a05231e1e$var$unitDuration(duration) {
3115
- let unit = {
3116
- ...duration
3117
- };
3118
- for (let key in duration)
3119
- unit[key] = 1;
3120
- return unit;
3121
- }
3122
- function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
3123
- let { value: valueProp, defaultValue, onChange, createCalendar: createCalendar4, locale, visibleDuration = {
3124
- months: 1
3125
- }, minValue, maxValue, ...calendarProps } = props;
3126
- let [value, setValue] = ($458b0a5536c1a7cf$export$40bfa8c7b0832715)(valueProp, defaultValue || null, onChange);
3127
- let [anchorDate, setAnchorDateState] = (useState)(null);
3128
- let alignment = "center";
3129
- if (value && value.start && value.end) {
3130
- let start = ($f62d864046160412$export$f4a51ff076cc9a09)((toCalendarDate)(value.start), visibleDuration, locale, minValue, maxValue);
3131
- let end = start.add(visibleDuration).subtract({
3132
- days: 1
3133
- });
3134
- if (value.end.compare(end) > 0)
3135
- alignment = "start";
3136
- }
3137
- let availableRangeRef = (useRef)(null);
3138
- let [availableRange, setAvailableRange] = (useState)(null);
3139
- let min = (useMemo)(() => {
3140
- return (maxDate)(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start);
3141
- }, [
3142
- minValue,
3143
- availableRange
3144
- ]);
3145
- let max = (useMemo)(() => {
3146
- return (minDate)(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end);
3147
- }, [
3148
- maxValue,
3149
- availableRange
3150
- ]);
3151
- let calendar = ($131cf43a05231e1e$export$6d095e787d2b5e1f)({
3152
- ...calendarProps,
3153
- value: value && value.start,
3154
- createCalendar: createCalendar4,
3155
- locale,
3156
- visibleDuration,
3157
- minValue: min,
3158
- maxValue: max,
3159
- selectionAlignment: alignment
3160
- });
3161
- let updateAvailableRange = (date) => {
3162
- if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
3163
- availableRangeRef.current = {
3164
- start: $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, -1),
3165
- end: $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, 1)
3166
- };
3167
- setAvailableRange(availableRangeRef.current);
3168
- } else {
3169
- availableRangeRef.current = null;
3170
- setAvailableRange(null);
3171
- }
3172
- };
3173
- let [lastVisibleRange, setLastVisibleRange] = (useState)(calendar.visibleRange);
3174
- if (!(isEqualDay)(calendar.visibleRange.start, lastVisibleRange.start) || !(isEqualDay)(calendar.visibleRange.end, lastVisibleRange.end)) {
3175
- updateAvailableRange(anchorDate);
3176
- setLastVisibleRange(calendar.visibleRange);
3177
- }
3178
- let setAnchorDate = (date) => {
3179
- if (date) {
3180
- setAnchorDateState(date);
3181
- updateAvailableRange(date);
3182
- } else {
3183
- setAnchorDateState(null);
3184
- updateAvailableRange(null);
3185
- }
3186
- };
3187
- let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end);
3188
- let selectDate = (date) => {
3189
- if (props.isReadOnly)
3190
- return;
3191
- date = ($f62d864046160412$export$4f5203c0d889109e)(date, min, max);
3192
- date = ($f62d864046160412$export$a1d3911297b952d7)(date, calendar.visibleRange.start, props.isDateUnavailable);
3193
- if (!date)
3194
- return;
3195
- if (!anchorDate)
3196
- setAnchorDate(date);
3197
- else {
3198
- let range = $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, date);
3199
- setValue({
3200
- start: $9a36b6ba2fb1a7c5$var$convertValue(range.start, value === null || value === void 0 ? void 0 : value.start),
3201
- end: $9a36b6ba2fb1a7c5$var$convertValue(range.end, value === null || value === void 0 ? void 0 : value.end)
3202
- });
3203
- setAnchorDate(null);
3204
- }
3205
- };
3206
- let [isDragging, setDragging] = (useState)(false);
3207
- let { isDateUnavailable } = props;
3208
- let isInvalidSelection = (useMemo)(() => {
3209
- if (!value || anchorDate)
3210
- return false;
3211
- if (isDateUnavailable && (isDateUnavailable(value.start) || isDateUnavailable(value.end)))
3212
- return true;
3213
- return ($f62d864046160412$export$eac50920cf2fd59a)(value.start, minValue, maxValue) || ($f62d864046160412$export$eac50920cf2fd59a)(value.end, minValue, maxValue);
3214
- }, [
3215
- isDateUnavailable,
3216
- value,
3217
- anchorDate,
3218
- minValue,
3219
- maxValue
3220
- ]);
3221
- let validationState = props.validationState || (isInvalidSelection ? "invalid" : null);
3222
- return {
3223
- ...calendar,
3224
- value,
3225
- setValue,
3226
- anchorDate,
3227
- setAnchorDate,
3228
- highlightedRange,
3229
- validationState,
3230
- selectFocusedDate() {
3231
- selectDate(calendar.focusedDate);
3232
- },
3233
- selectDate,
3234
- highlightDate(date) {
3235
- if (anchorDate)
3236
- calendar.setFocusedDate(date);
3237
- },
3238
- isSelected(date) {
3239
- return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);
3240
- },
3241
- isInvalid(date) {
3242
- var _availableRangeRef_current, _availableRangeRef_current1;
3243
- return calendar.isInvalid(date) || ($f62d864046160412$export$eac50920cf2fd59a)(date, (_availableRangeRef_current = availableRangeRef.current) === null || _availableRangeRef_current === void 0 ? void 0 : _availableRangeRef_current.start, (_availableRangeRef_current1 = availableRangeRef.current) === null || _availableRangeRef_current1 === void 0 ? void 0 : _availableRangeRef_current1.end);
3244
- },
3245
- isDragging,
3246
- setDragging
3247
- };
3248
- }
3249
- function $9a36b6ba2fb1a7c5$var$makeRange(start, end) {
3250
- if (!start || !end)
3251
- return null;
3252
- if (end.compare(start) < 0)
3253
- [start, end] = [
3254
- end,
3255
- start
3256
- ];
3257
- return {
3258
- start: (toCalendarDate)(start),
3259
- end: (toCalendarDate)(end)
3260
- };
3261
- }
3262
- function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) {
3263
- newValue = (toCalendar)(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new (GregorianCalendar)());
3264
- if (oldValue && "hour" in oldValue)
3265
- return oldValue.set(newValue);
3266
- return newValue;
3267
- }
3268
- function $9a36b6ba2fb1a7c5$var$nextUnavailableDate(anchorDate, state2, dir) {
3269
- let nextDate = anchorDate.add({
3270
- days: dir
3271
- });
3272
- while ((dir < 0 ? nextDate.compare(state2.visibleRange.start) >= 0 : nextDate.compare(state2.visibleRange.end) <= 0) && !state2.isCellUnavailable(nextDate))
3273
- nextDate = nextDate.add({
3274
- days: dir
3275
- });
3276
- if (state2.isCellUnavailable(nextDate))
3277
- return nextDate.add({
3278
- days: -dir
3279
- });
3280
- return null;
3281
- }
3282
1554
  var Badge = forwardRef(
3283
1555
  ({ icon, colorScheme = "grey", children, ...props }, ref) => {
3284
1556
  return /* @__PURE__ */ React69__default.createElement(
@@ -3594,7 +1866,7 @@ function Calendar({
3594
1866
  }) {
3595
1867
  const { t: t2 } = useTranslation();
3596
1868
  const locale = useCurrentLocale();
3597
- const state2 = $131cf43a05231e1e$export$6d095e787d2b5e1f({
1869
+ const state2 = useCalendarState({
3598
1870
  ...props,
3599
1871
  locale,
3600
1872
  createCalendar
@@ -3698,7 +1970,7 @@ var DateField = forwardRef$1(
3698
1970
  var _a6;
3699
1971
  const locale = useCurrentLocale();
3700
1972
  const styles3 = useMultiStyleConfig("Datepicker", {});
3701
- const state2 = $3c0fc76039f1c516$export$60e84778edff6d26({
1973
+ const state2 = useDateFieldState({
3702
1974
  ...props,
3703
1975
  locale,
3704
1976
  createCalendar: createCalendar2
@@ -3769,7 +2041,7 @@ var DatePicker = forwardRef$1(
3769
2041
  ...props
3770
2042
  }, externalRef) => {
3771
2043
  const formControlProps = useFormControlContext();
3772
- const state2 = $ab5bf3f618090389$export$87194bb378cc3ac2({
2044
+ const state2 = useDatePickerState({
3773
2045
  ...props,
3774
2046
  shouldCloseOnSelect: true,
3775
2047
  errorMessage,
@@ -3855,7 +2127,7 @@ var DatePicker = forwardRef$1(
3855
2127
  );
3856
2128
  function RangeCalendar(props) {
3857
2129
  const locale = useCurrentLocale();
3858
- const state2 = $9a36b6ba2fb1a7c5$export$9a987164d97ecc90({
2130
+ const state2 = useRangeCalendarState({
3859
2131
  ...props,
3860
2132
  visibleDuration: { months: 2 },
3861
2133
  locale,
@@ -3883,7 +2155,7 @@ function DateRangePicker({
3883
2155
  ...props
3884
2156
  }) {
3885
2157
  const formControlProps = useFormControlContext();
3886
- const state2 = $93c38a5e28be6249$export$e50a61c1de9f574({
2158
+ const state2 = useDateRangePickerState({
3887
2159
  ...props,
3888
2160
  shouldCloseOnSelect: true,
3889
2161
  isRequired: props.isRequired ?? (formControlProps == null ? void 0 : formControlProps.isRequired),
@@ -5144,7 +3416,7 @@ var texts14 = createTexts({
5144
3416
  sv: "Telefonnummer"
5145
3417
  }
5146
3418
  });
5147
- var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-FBKDO5JS.mjs'));
3419
+ var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-7MAIS4VT.mjs'));
5148
3420
  var Radio = forwardRef((props, ref) => {
5149
3421
  return /* @__PURE__ */ React69__default.createElement(Radio$1, { ...props, ref });
5150
3422
  });