@easypost/easy-ui 1.0.0-alpha.55 → 1.0.0-alpha.56
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.
- package/Badge/index.js +14 -14
- package/Badge/index.mjs +14 -14
- package/Banner/index.js +5 -5
- package/Banner/index.mjs +5 -5
- package/Button/index.js +1 -1
- package/Button/index.mjs +1 -1
- package/CHANGELOG.md +7 -0
- package/Calendar/Calendar.d.ts +43 -33
- package/Calendar/Calendar.d.ts.map +1 -1
- package/Calendar/CalendarBase.d.ts +57 -0
- package/Calendar/CalendarBase.d.ts.map +1 -0
- package/Calendar/CalendarCell.d.ts +2 -2
- package/Calendar/CalendarCell.d.ts.map +1 -1
- package/Calendar/CalendarGrid.d.ts +2 -5
- package/Calendar/CalendarGrid.d.ts.map +1 -1
- package/Calendar/CalendarHeader.d.ts +1 -6
- package/Calendar/CalendarHeader.d.ts.map +1 -1
- package/Calendar/index.js +9 -3349
- package/Calendar/index.mjs +8 -3348
- package/Card/index.js +1 -1
- package/Card/index.mjs +1 -1
- package/Checkbox/index.js +1 -1
- package/Checkbox/index.mjs +1 -1
- package/CodeBlock/index.js +13 -13
- package/CodeBlock/index.mjs +16 -16
- package/CodeSnippet/index.js +1 -1
- package/CodeSnippet/index.mjs +1 -1
- package/DataGrid/index.js +58 -58
- package/DataGrid/index.mjs +72 -72
- package/Drawer/index.js +18 -18
- package/Drawer/index.mjs +21 -21
- package/DropdownButton/index.js +12 -12
- package/DropdownButton/index.mjs +13 -13
- package/EmptyStateCard/index.js +8 -8
- package/EmptyStateCard/index.mjs +8 -8
- package/FocusedProductLayout/index.js +23 -23
- package/FocusedProductLayout/index.mjs +23 -23
- package/FormLayout/index.js +5 -5
- package/FormLayout/index.mjs +5 -5
- package/HorizontalGrid/index.js +1 -1
- package/HorizontalGrid/index.mjs +1 -1
- package/HorizontalStack/index.js +1 -1
- package/HorizontalStack/index.mjs +1 -1
- package/Icon/index.js +1 -1
- package/Icon/index.mjs +1 -1
- package/IconButton/index.js +12 -12
- package/IconButton/index.mjs +13 -13
- package/InputField/InputField.d.ts +4 -0
- package/InputField/InputField.d.ts.map +1 -1
- package/InputField/index.js +1 -1
- package/InputField/index.mjs +1 -1
- package/InputField/inputText.d.ts +24 -0
- package/InputField/inputText.d.ts.map +1 -0
- package/InputField/utilities.d.ts +1 -1
- package/InputField/utilities.d.ts.map +1 -1
- package/KebabButton/index.js +1 -1
- package/KebabButton/index.mjs +1 -1
- package/Menu/index.js +1 -1
- package/Menu/index.mjs +1 -1
- package/Modal/index.js +19 -19
- package/Modal/index.mjs +22 -22
- package/NexusLayout/index.js +28 -28
- package/NexusLayout/index.mjs +32 -32
- package/Notification/index.js +1 -1
- package/Notification/index.mjs +1 -1
- package/Pagination/index.js +10 -10
- package/Pagination/index.mjs +9 -9
- package/PillGroup/index.js +7 -7
- package/PillGroup/index.mjs +22 -22
- package/ProductLayout/index.js +21 -21
- package/ProductLayout/index.mjs +25 -25
- package/Provider/index.js +1 -1
- package/Provider/index.mjs +2 -2
- package/RadioButtonGroup/index.js +2 -2
- package/RadioButtonGroup/index.mjs +8 -8
- package/RadioGroup/index.js +15 -15
- package/RadioGroup/index.mjs +25 -25
- package/RangeCalendar/RangeCalendar.d.ts +71 -0
- package/RangeCalendar/RangeCalendar.d.ts.map +1 -0
- package/RangeCalendar/RangeCalendar.stories.d.ts +15 -0
- package/RangeCalendar/RangeCalendar.stories.d.ts.map +1 -0
- package/RangeCalendar/RangeCalendar.test.d.ts +2 -0
- package/RangeCalendar/RangeCalendar.test.d.ts.map +1 -0
- package/RangeCalendar/index.d.ts +2 -0
- package/RangeCalendar/index.d.ts.map +1 -0
- package/RangeCalendar/index.js +228 -0
- package/RangeCalendar/index.mjs +228 -0
- package/SearchNav/index.js +29 -29
- package/SearchNav/index.mjs +30 -30
- package/SectionCard/index.js +9 -5497
- package/SectionCard/index.mjs +8 -5496
- package/Select/index.js +4 -4
- package/Select/index.mjs +5 -5
- package/SelectorErrorTooltip/index.js +1 -1
- package/SelectorErrorTooltip/index.mjs +1 -1
- package/Spinner/index.js +1 -1
- package/Spinner/index.mjs +1 -1
- package/SplitToggleCard/index.js +4 -4
- package/SplitToggleCard/index.mjs +4 -4
- package/Stepper/index.js +1 -1
- package/Stepper/index.mjs +1 -1
- package/TabNav/index.js +1 -1
- package/TabNav/index.mjs +1 -1
- package/TabPanels/index.js +2 -2
- package/TabPanels/index.mjs +7 -7
- package/Tabs/index.js +1 -1
- package/Tabs/index.mjs +1 -1
- package/Text/index.js +1 -1
- package/Text/index.mjs +1 -1
- package/TextField/TextField.stories.d.ts +1 -0
- package/TextField/TextField.stories.d.ts.map +1 -1
- package/TextField/index.js +1 -1
- package/TextField/index.mjs +1 -1
- package/Textarea/index.js +1 -1
- package/Textarea/index.mjs +1 -1
- package/Toggle/index.js +1 -1
- package/Toggle/index.mjs +1 -1
- package/ToggleCard/index.js +2 -2
- package/ToggleCard/index.mjs +2 -2
- package/Tooltip/index.js +1 -1
- package/Tooltip/index.mjs +1 -1
- package/UnstyledButton/index.mjs +1 -1
- package/VerticalNav/index.js +24 -24
- package/VerticalNav/index.mjs +26 -26
- package/VerticalStack/index.js +1 -1
- package/VerticalStack/index.mjs +1 -1
- package/__chunks__/{Button-vppvnDZX.mjs → Button-D6onI-kJ.mjs} +18 -18
- package/__chunks__/{Button-Bg19kicX.js → Button-DQ2NkvB7.js} +17 -17
- package/__chunks__/CalendarBase-DaXcE0Vl.js +3410 -0
- package/__chunks__/CalendarBase-DkLU-xxk.mjs +3411 -0
- package/__chunks__/{Card-BL4ap8Im.mjs → Card-CYdEo89C.mjs} +12 -12
- package/__chunks__/{Card-bN2Bjyiu.js → Card-Cw9W0Zvm.js} +12 -12
- package/__chunks__/{Checkbox-Bbhv57QW.js → Checkbox-DMIaBIMX.js} +19 -19
- package/__chunks__/{Checkbox-D7PJfiLF.mjs → Checkbox-DTX_wDBB.mjs} +24 -24
- package/__chunks__/{CodeSnippet-CT5SOnzT.mjs → CodeSnippet-CBDtqnFn.mjs} +2 -2
- package/__chunks__/{CodeSnippet-DMxiG1lt.js → CodeSnippet-Dg-w1ncw.js} +2 -2
- package/__chunks__/{FocusScope-CMdrObui.mjs → FocusScope-CEeqhVmO.mjs} +3 -3
- package/__chunks__/{HelpMenu-Cz2v3GAo.mjs → HelpMenu-DCIr7b5K.mjs} +7 -7
- package/__chunks__/{HelpMenu-C4Lgr_6O.js → HelpMenu-br4uY5D7.js} +6 -6
- package/__chunks__/{HorizontalGrid-BV2_WP0d.mjs → HorizontalGrid--W2GD8lN.mjs} +1 -1
- package/__chunks__/{HorizontalGrid-sYdKXIX9.js → HorizontalGrid-BUpw5nwO.js} +1 -1
- package/__chunks__/{HorizontalStack-Jdgb1NMD.js → HorizontalStack-CXhmbQu4.js} +1 -1
- package/__chunks__/{HorizontalStack-DtOxexq4.mjs → HorizontalStack-x4HGqgsU.mjs} +1 -1
- package/__chunks__/{Icon-ylOKybLj.js → Icon-BCBvOy-b.js} +2 -2
- package/__chunks__/{Icon-BdrQIZ7G.mjs → Icon-CDgix2Sz.mjs} +2 -2
- package/__chunks__/{InputField-CmzPMEdU.mjs → InputField-Bj22Z9om.mjs} +36 -14
- package/__chunks__/{InputField-CDopP3qd.js → InputField-C86b2081.js} +29 -7
- package/__chunks__/{InputIcon-DJjhAUG8.js → InputIcon-BLzlQuQq.js} +44 -27
- package/__chunks__/{InputIcon-C4kynRVv.mjs → InputIcon-zjySEVjo.mjs} +44 -27
- package/__chunks__/{KebabButton-Bct1ZWZ7.js → KebabButton-ClU7vgEf.js} +4 -4
- package/__chunks__/{KebabButton-b1cJAu-k.mjs → KebabButton-DDDKfSUI.mjs} +5 -5
- package/__chunks__/{Menu-Bi8Xblu3.mjs → Menu-B4KcJbMm.mjs} +20 -20
- package/__chunks__/{Menu-DhjEsT6X.js → Menu-anVQErb9.js} +14 -14
- package/__chunks__/{Notification-B7cXFkbn.js → Notification-BCLsclpu.js} +14 -14
- package/__chunks__/{Notification-DgT-Srat.mjs → Notification-BoMoXyLI.mjs} +19 -19
- package/__chunks__/{Overlay-C3rJpwIX.mjs → Overlay-CuhLUuXt.mjs} +2 -2
- package/__chunks__/{SelectOverlay-QlG4R4EK.js → SelectOverlay-BAFmxwi9.js} +22 -22
- package/__chunks__/{SelectOverlay-DRYndVx9.mjs → SelectOverlay-C5Kk7H2z.mjs} +33 -33
- package/__chunks__/{SelectorErrorTooltip-Uuj_150A.js → SelectorErrorTooltip-B1tkBijI.js} +4 -4
- package/__chunks__/{SelectorErrorTooltip-CpIinREp.mjs → SelectorErrorTooltip-C3BApHSk.mjs} +4 -4
- package/__chunks__/{Spinner-BHcblUXI.js → Spinner-0AHyjbiK.js} +5 -5
- package/__chunks__/{Spinner-Cq8bw1nz.mjs → Spinner-DCi-JKIV.mjs} +8 -8
- package/__chunks__/{Stepper-B7UuO2-U.mjs → Stepper-CgF1pSNE.mjs} +28 -28
- package/__chunks__/{Stepper-RX4JamiX.js → Stepper-Ds60cKSk.js} +25 -25
- package/__chunks__/{TabNav-BJEE3Rgt.mjs → TabNav-BVyJkGz0.mjs} +1 -1
- package/__chunks__/{TabNav-Cr966uUR.js → TabNav-BpsdF4EQ.js} +1 -1
- package/__chunks__/{Tabs-pX8dmtn1.js → Tabs-BTr3Uoym.js} +17 -17
- package/__chunks__/{Tabs-BJTPGnZs.mjs → Tabs-N3WVqQTL.mjs} +19 -19
- package/__chunks__/{Text-BP87eq_Y.js → Text-Bo5ZXIKu.js} +34 -34
- package/__chunks__/{Text-hB1p7qnS.mjs → Text-Sv_euunS.mjs} +34 -34
- package/__chunks__/{Toggle-CBZgoM67.js → Toggle-CHXljwk6.js} +11 -11
- package/__chunks__/{Toggle-CLR23YhR.mjs → Toggle-Dj6H2veI.mjs} +14 -14
- package/__chunks__/{Tooltip-BckLAOT1.js → Tooltip-C0qyP5jK.js} +8 -8
- package/__chunks__/{Tooltip-C1JxFbtW.mjs → Tooltip-DMLWZU15.mjs} +13 -13
- package/__chunks__/{UnstyledButton-CO7FOpAq.mjs → UnstyledButton-6seSbTV1.mjs} +2 -2
- package/__chunks__/{VerticalStack-CkBHjLJD.mjs → VerticalStack-BGcflJsS.mjs} +3 -3
- package/__chunks__/{VerticalStack-CDoPLDw4.js → VerticalStack-DYStFa7Z.js} +3 -3
- package/__chunks__/{VisuallyHidden-BsBkcHpw.mjs → VisuallyHidden-BttNIgVC.mjs} +2 -2
- package/__chunks__/{ariaHideOutside-D-yj7DXL.mjs → ariaHideOutside-DcIkumuG.mjs} +5 -5
- package/__chunks__/{context-D3I6RuRU.mjs → context-DEwqildc.mjs} +1 -1
- package/__chunks__/{focusSafely-8R2xSTi2.mjs → focusSafely-Dw7K4rnX.mjs} +2 -2
- package/__chunks__/{isVirtualEvent-BPCuFO54.mjs → isVirtualEvent-BFRy7P_p.mjs} +2 -2
- package/__chunks__/lodash-Cu2-TIbX.mjs +5492 -0
- package/__chunks__/lodash-DfTCP3Dk.js +5491 -0
- package/__chunks__/{mergeProps-SJQ-f8LF.mjs → mergeProps-T961Q1yJ.mjs} +4 -4
- package/__chunks__/{scrollIntoView-C4vMSOYx.mjs → scrollIntoView-GfnXaOCE.mjs} +1 -1
- package/__chunks__/{useButton-s_sjr8Ix.mjs → useButton-DEhs-Rkj.mjs} +3 -3
- package/__chunks__/{useDialog-RxvhRzry.mjs → useDialog-DAYxqkKY.mjs} +4 -4
- package/__chunks__/{useEdgeInterceptors-D0t_4eZ3.mjs → useEdgeInterceptors-B-WQYXsP.mjs} +5 -5
- package/__chunks__/{useEdgeInterceptors-B7c--t3K.js → useEdgeInterceptors-CuD3aTAb.js} +5 -5
- package/__chunks__/useEvent-C5RCZjKr.mjs +23 -0
- package/__chunks__/useEvent-DY7dR7Mi.js +22 -0
- package/__chunks__/{useField-DPD-La1H.mjs → useField-DWmSslhe.mjs} +2 -2
- package/__chunks__/{useFocus-By3Cx-xz.mjs → useFocus-DDj4i8Xy.mjs} +2 -2
- package/__chunks__/{useFocusRing-dRPhwlpK.mjs → useFocusRing-BE_dgxH5.mjs} +3 -3
- package/__chunks__/{useFocusVisible-BbEmluTm.mjs → useFocusVisible-CXSIZSY_.mjs} +2 -2
- package/__chunks__/{useFocusWithin-krnNAgDY.mjs → useFocusWithin-CDX8m0Wu.mjs} +1 -1
- package/__chunks__/{useFocusable-CgTd-4A-.mjs → useFocusable-DD5dAIXt.mjs} +4 -4
- package/__chunks__/{useFormReset-CFhWic3i.mjs → useFormReset-CmXMJVpO.mjs} +1 -1
- package/__chunks__/{useFormValidation-DAScndBq.mjs → useFormValidation-gwcVryr8.mjs} +2 -2
- package/__chunks__/{useHasTabbableChild-BQnJycug.mjs → useHasTabbableChild-CRCY1COZ.mjs} +2 -2
- package/__chunks__/{useHighlightSelectionDescription-CPtYsCSQ.mjs → useHighlightSelectionDescription-DCgFgP4G.mjs} +3 -3
- package/__chunks__/{useLabel-BlM5Qwvq.mjs → useLabel-C0Q8946u.mjs} +2 -2
- package/__chunks__/{useLabels-DdXkBiwn.mjs → useLabels-Bly436JP.mjs} +1 -1
- package/__chunks__/{useLocalizedStringFormatter-DJWWtB78.mjs → useLocalizedStringFormatter-B5ons_mh.mjs} +1 -1
- package/__chunks__/{useOverlayPosition-CoEMr0ZL.mjs → useOverlayPosition-B31NgShQ.mjs} +4 -4
- package/__chunks__/{usePress-qBr44_1g.mjs → usePress-DV7a17gG.mjs} +3 -3
- package/__chunks__/{useSelectableItem-D7gxXSuA.mjs → useSelectableItem-BDZ5pN_C.mjs} +10 -27
- package/__chunks__/{useSelectableItem-Ca_8R3iv.js → useSelectableItem-BGvBbIwY.js} +3 -20
- package/__chunks__/{useSelectableList-CWMPIUPQ.mjs → useSelectableList-Bj35aLZH.mjs} +2 -2
- package/__chunks__/{useSelectableList-uSeYGnKL.js → useSelectableList-DlkRkps4.js} +1 -1
- package/__chunks__/{useSyncRef-Cp332icp.mjs → useSyncRef-CpaiKz0R.mjs} +1 -1
- package/__chunks__/{useToggle-D9D1ZDRl.mjs → useToggle-BfGkPrAg.mjs} +4 -4
- package/__chunks__/{useTriggerWidth-i06IegOT.mjs → useTriggerWidth-BC_zeUJ5.mjs} +7 -7
- package/__chunks__/{useTriggerWidth-ClsknzJh.js → useTriggerWidth-C7OT3WI9.js} +1 -1
- package/__chunks__/{utils-Dm-0qf_-.mjs → utils-XuD3IFpv.mjs} +1 -1
- package/package.json +1 -1
- package/style.css +1131 -1046
- package/__chunks__/{KeyboardDoubleArrowLeft-GpUjmD9o.mjs → KeyboardDoubleArrowRight-AAMLvGk-.mjs} +4 -4
- package/__chunks__/{KeyboardDoubleArrowLeft-BHR8vGMo.js → KeyboardDoubleArrowRight-Ber8mUIO.js} +4 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { RangeValue } from "@react-types/shared";
|
|
3
|
+
import { DateValue, MappedDateValue, DateRange } from "@react-types/calendar";
|
|
4
|
+
import { CalendarBaseStateProps } from "../Calendar/CalendarBase";
|
|
5
|
+
export type RangeCalendarProps = CalendarBaseStateProps & {
|
|
6
|
+
/**
|
|
7
|
+
* The current value (controlled).
|
|
8
|
+
*/
|
|
9
|
+
value?: DateRange | null;
|
|
10
|
+
/**
|
|
11
|
+
* The default value (uncontrolled).
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: DateRange | null;
|
|
14
|
+
/**
|
|
15
|
+
* Handler that is called when the value changes.
|
|
16
|
+
*/
|
|
17
|
+
onChange?: (value: RangeValue<MappedDateValue<DateValue>>) => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* A `RangeCalendar` displays a grid of days and allows users to select a range of dates.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* _Default Value:_
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Calendar
|
|
27
|
+
* defaultValue={{
|
|
28
|
+
* start: new CalendarDate(2024, 7, 15),
|
|
29
|
+
* end: new CalendarDate(2024, 7, 25),
|
|
30
|
+
* }}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* _Set limited available dates:_
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <RangeCalendar
|
|
38
|
+
* minValue={new CalendarDate(2024, 7, 24)}
|
|
39
|
+
* maxValue={new CalendarDate(2024, 8, 5)}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* _Date availability:_
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <RangeCalendar
|
|
47
|
+
* isDateUnavailable={(date: DateValue) =>
|
|
48
|
+
* today(getLocalTimeZone()).compare(date) > 0
|
|
49
|
+
* }
|
|
50
|
+
* />
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* _Controlled:_
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const [date, setDate] = React.useState({
|
|
57
|
+
* start: today(getLocalTimeZone()).subtract({ days: 7 }),
|
|
58
|
+
* end: today(getLocalTimeZone()),
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* <RangeCalendar
|
|
62
|
+
* value={date}
|
|
63
|
+
* onChange={setDate}
|
|
64
|
+
* />
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function RangeCalendar(props: RangeCalendarProps): React.JSX.Element;
|
|
68
|
+
export declare namespace RangeCalendar {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=RangeCalendar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeCalendar.d.ts","sourceRoot":"","sources":["../../src/RangeCalendar/RangeCalendar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAgB,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEhF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAkBtD;yBAlBe,aAAa"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { RangeCalendar } from "./RangeCalendar";
|
|
3
|
+
type Story = StoryObj<typeof RangeCalendar>;
|
|
4
|
+
declare const meta: Meta<typeof RangeCalendar>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const DefaultValue: Story;
|
|
8
|
+
export declare const LimitAvailableDates: Story;
|
|
9
|
+
export declare const DatesAvailability: Story;
|
|
10
|
+
export declare const ShowDaysOutsideCurrentMonth: Story;
|
|
11
|
+
export declare const ControlledSelection: Story;
|
|
12
|
+
export declare const InvalidSelection: Story;
|
|
13
|
+
export declare const DisabledCalendar: Story;
|
|
14
|
+
export declare const ReadonlyCalendar: Story;
|
|
15
|
+
//# sourceMappingURL=RangeCalendar.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeCalendar.stories.d.ts","sourceRoot":"","sources":["../../src/RangeCalendar/RangeCalendar.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIlD,OAAO,EAAE,aAAa,EAAsB,MAAM,iBAAiB,CAAC;AAEpE,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAI5C,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,aAAa,CAqBpC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAQ1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAUjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAM/B,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,KAKzC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KASjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAkB9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAK9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAK9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RangeCalendar.test.d.ts","sourceRoot":"","sources":["../../src/RangeCalendar/RangeCalendar.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/RangeCalendar/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
34
|
+
const React = require("react");
|
|
35
|
+
const CalendarBase = require("../__chunks__/CalendarBase-DaXcE0Vl.js");
|
|
36
|
+
const context = require("../__chunks__/context-D3NeXov7.js");
|
|
37
|
+
const useControlledState = require("../__chunks__/useControlledState-mnKBd6Uc.js");
|
|
38
|
+
const useEvent = require("../__chunks__/useEvent-DY7dR7Mi.js");
|
|
39
|
+
function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
40
|
+
let _a = props, { value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {
|
|
41
|
+
months: 1
|
|
42
|
+
}, minValue, maxValue } = _a, calendarProps = __objRest(_a, ["value", "defaultValue", "onChange", "createCalendar", "locale", "visibleDuration", "minValue", "maxValue"]);
|
|
43
|
+
let [value, setValue] = useControlledState.$458b0a5536c1a7cf$export$40bfa8c7b0832715(valueProp, defaultValue || null, onChange);
|
|
44
|
+
let [anchorDate, setAnchorDateState] = React.useState(null);
|
|
45
|
+
let alignment = "center";
|
|
46
|
+
if (value && value.start && value.end) {
|
|
47
|
+
let start = CalendarBase.$f62d864046160412$export$f4a51ff076cc9a09(CalendarBase.$11d87f3f76e88657$export$93522d1a439f3617(value.start), visibleDuration, locale, minValue, maxValue);
|
|
48
|
+
let end = start.add(visibleDuration).subtract({
|
|
49
|
+
days: 1
|
|
50
|
+
});
|
|
51
|
+
if (value.end.compare(end) > 0) alignment = "start";
|
|
52
|
+
}
|
|
53
|
+
let availableRangeRef = React.useRef(null);
|
|
54
|
+
let [availableRange, setAvailableRange] = React.useState(null);
|
|
55
|
+
let min = React.useMemo(() => CalendarBase.$14e0f24ef4ac5c92$export$a75f2bff57811055(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start), [
|
|
56
|
+
minValue,
|
|
57
|
+
availableRange
|
|
58
|
+
]);
|
|
59
|
+
let max = React.useMemo(() => CalendarBase.$14e0f24ef4ac5c92$export$5c333a116e949cdd(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end), [
|
|
60
|
+
maxValue,
|
|
61
|
+
availableRange
|
|
62
|
+
]);
|
|
63
|
+
let calendar = CalendarBase.$131cf43a05231e1e$export$6d095e787d2b5e1f(__spreadProps(__spreadValues({}, calendarProps), {
|
|
64
|
+
value: value && value.start,
|
|
65
|
+
createCalendar,
|
|
66
|
+
locale,
|
|
67
|
+
visibleDuration,
|
|
68
|
+
minValue: min,
|
|
69
|
+
maxValue: max,
|
|
70
|
+
selectionAlignment: alignment
|
|
71
|
+
}));
|
|
72
|
+
let updateAvailableRange = (date) => {
|
|
73
|
+
if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
74
|
+
const nextAvailableStartDate = $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, -1);
|
|
75
|
+
const nextAvailableEndDate = $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, 1);
|
|
76
|
+
availableRangeRef.current = {
|
|
77
|
+
start: nextAvailableStartDate,
|
|
78
|
+
end: nextAvailableEndDate
|
|
79
|
+
};
|
|
80
|
+
setAvailableRange(availableRangeRef.current);
|
|
81
|
+
} else {
|
|
82
|
+
availableRangeRef.current = null;
|
|
83
|
+
setAvailableRange(null);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
let [lastVisibleRange, setLastVisibleRange] = React.useState(calendar.visibleRange);
|
|
87
|
+
if (!CalendarBase.$14e0f24ef4ac5c92$export$91b62ebf2ba703ee(calendar.visibleRange.start, lastVisibleRange.start) || !CalendarBase.$14e0f24ef4ac5c92$export$91b62ebf2ba703ee(calendar.visibleRange.end, lastVisibleRange.end)) {
|
|
88
|
+
updateAvailableRange(anchorDate);
|
|
89
|
+
setLastVisibleRange(calendar.visibleRange);
|
|
90
|
+
}
|
|
91
|
+
let setAnchorDate = (date) => {
|
|
92
|
+
if (date) {
|
|
93
|
+
setAnchorDateState(date);
|
|
94
|
+
updateAvailableRange(date);
|
|
95
|
+
} else {
|
|
96
|
+
setAnchorDateState(null);
|
|
97
|
+
updateAvailableRange(null);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end);
|
|
101
|
+
let selectDate = (date) => {
|
|
102
|
+
if (props.isReadOnly) return;
|
|
103
|
+
const constrainedDate = CalendarBase.$f62d864046160412$export$4f5203c0d889109e(date, min, max);
|
|
104
|
+
const previousAvailableConstrainedDate = CalendarBase.$f62d864046160412$export$a1d3911297b952d7(constrainedDate, calendar.visibleRange.start, props.isDateUnavailable);
|
|
105
|
+
if (!previousAvailableConstrainedDate) return;
|
|
106
|
+
if (!anchorDate) setAnchorDate(previousAvailableConstrainedDate);
|
|
107
|
+
else {
|
|
108
|
+
let range = $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, previousAvailableConstrainedDate);
|
|
109
|
+
if (range) setValue({
|
|
110
|
+
start: $9a36b6ba2fb1a7c5$var$convertValue(range.start, value === null || value === void 0 ? void 0 : value.start),
|
|
111
|
+
end: $9a36b6ba2fb1a7c5$var$convertValue(range.end, value === null || value === void 0 ? void 0 : value.end)
|
|
112
|
+
});
|
|
113
|
+
setAnchorDate(null);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
let [isDragging, setDragging] = React.useState(false);
|
|
117
|
+
let { isDateUnavailable } = props;
|
|
118
|
+
let isInvalidSelection = React.useMemo(() => {
|
|
119
|
+
if (!value || anchorDate) return false;
|
|
120
|
+
if (isDateUnavailable && (isDateUnavailable(value.start) || isDateUnavailable(value.end))) return true;
|
|
121
|
+
return CalendarBase.$f62d864046160412$export$eac50920cf2fd59a(value.start, minValue, maxValue) || CalendarBase.$f62d864046160412$export$eac50920cf2fd59a(value.end, minValue, maxValue);
|
|
122
|
+
}, [
|
|
123
|
+
isDateUnavailable,
|
|
124
|
+
value,
|
|
125
|
+
anchorDate,
|
|
126
|
+
minValue,
|
|
127
|
+
maxValue
|
|
128
|
+
]);
|
|
129
|
+
let isValueInvalid = props.isInvalid || props.validationState === "invalid" || isInvalidSelection;
|
|
130
|
+
let validationState = isValueInvalid ? "invalid" : null;
|
|
131
|
+
return __spreadProps(__spreadValues({}, calendar), {
|
|
132
|
+
value,
|
|
133
|
+
setValue,
|
|
134
|
+
anchorDate,
|
|
135
|
+
setAnchorDate,
|
|
136
|
+
highlightedRange,
|
|
137
|
+
validationState,
|
|
138
|
+
isValueInvalid,
|
|
139
|
+
selectFocusedDate() {
|
|
140
|
+
selectDate(calendar.focusedDate);
|
|
141
|
+
},
|
|
142
|
+
selectDate,
|
|
143
|
+
highlightDate(date) {
|
|
144
|
+
if (anchorDate) calendar.setFocusedDate(date);
|
|
145
|
+
},
|
|
146
|
+
isSelected(date) {
|
|
147
|
+
return Boolean(highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date));
|
|
148
|
+
},
|
|
149
|
+
isInvalid(date) {
|
|
150
|
+
var _availableRangeRef_current, _availableRangeRef_current1;
|
|
151
|
+
return calendar.isInvalid(date) || CalendarBase.$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);
|
|
152
|
+
},
|
|
153
|
+
isDragging,
|
|
154
|
+
setDragging
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function $9a36b6ba2fb1a7c5$var$makeRange(start, end) {
|
|
158
|
+
if (!start || !end) return null;
|
|
159
|
+
if (end.compare(start) < 0) [start, end] = [
|
|
160
|
+
end,
|
|
161
|
+
start
|
|
162
|
+
];
|
|
163
|
+
return {
|
|
164
|
+
start: CalendarBase.$11d87f3f76e88657$export$93522d1a439f3617(start),
|
|
165
|
+
end: CalendarBase.$11d87f3f76e88657$export$93522d1a439f3617(end)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) {
|
|
169
|
+
newValue = CalendarBase.$11d87f3f76e88657$export$b4a036af3fc0b032(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new CalendarBase.$3b62074eb05584b2$export$80ee6245ec4f29ec());
|
|
170
|
+
if (oldValue && "hour" in oldValue) return oldValue.set(newValue);
|
|
171
|
+
return newValue;
|
|
172
|
+
}
|
|
173
|
+
function $9a36b6ba2fb1a7c5$var$nextUnavailableDate(anchorDate, state, dir) {
|
|
174
|
+
let nextDate = anchorDate.add({
|
|
175
|
+
days: dir
|
|
176
|
+
});
|
|
177
|
+
while ((dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) && !state.isCellUnavailable(nextDate)) nextDate = nextDate.add({
|
|
178
|
+
days: dir
|
|
179
|
+
});
|
|
180
|
+
if (state.isCellUnavailable(nextDate)) return nextDate.add({
|
|
181
|
+
days: -dir
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
|
|
185
|
+
let res = CalendarBase.$c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state);
|
|
186
|
+
let isVirtualClick = React.useRef(false);
|
|
187
|
+
let windowRef = React.useRef(typeof window !== "undefined" ? window : null);
|
|
188
|
+
useEvent.$e9faafb641e167db$export$90fc3a17d93f704c(windowRef, "pointerdown", (e) => {
|
|
189
|
+
isVirtualClick.current = e.width === 0 && e.height === 0;
|
|
190
|
+
});
|
|
191
|
+
let endDragging = (e) => {
|
|
192
|
+
if (isVirtualClick.current) {
|
|
193
|
+
isVirtualClick.current = false;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
state.setDragging(false);
|
|
197
|
+
if (!state.anchorDate) return;
|
|
198
|
+
let target = e.target;
|
|
199
|
+
if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
|
|
200
|
+
};
|
|
201
|
+
useEvent.$e9faafb641e167db$export$90fc3a17d93f704c(windowRef, "pointerup", endDragging);
|
|
202
|
+
res.calendarProps.onBlur = (e) => {
|
|
203
|
+
if (!ref.current) return;
|
|
204
|
+
if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
|
|
205
|
+
};
|
|
206
|
+
useEvent.$e9faafb641e167db$export$90fc3a17d93f704c(ref, "touchmove", (e) => {
|
|
207
|
+
if (state.isDragging) e.preventDefault();
|
|
208
|
+
}, {
|
|
209
|
+
passive: false,
|
|
210
|
+
capture: true
|
|
211
|
+
});
|
|
212
|
+
return res;
|
|
213
|
+
}
|
|
214
|
+
function RangeCalendar(props) {
|
|
215
|
+
const { locale } = context.$18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
216
|
+
const calendarRef = React.useRef(null);
|
|
217
|
+
const state = $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(__spreadProps(__spreadValues({}, props), {
|
|
218
|
+
locale,
|
|
219
|
+
createCalendar: CalendarBase.$64244302c3013299$export$dd0bbc9b26defe37
|
|
220
|
+
}));
|
|
221
|
+
const rangeCalendarProps = $46a4342aab3d8076$export$87e0539f600c24e5(props, state, calendarRef);
|
|
222
|
+
return React.createElement(CalendarBase.CalendarBase, __spreadProps(__spreadValues(__spreadValues({}, props), rangeCalendarProps), {
|
|
223
|
+
state,
|
|
224
|
+
calendarRef
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
RangeCalendar.displayName = "RangeCalendar";
|
|
228
|
+
exports.RangeCalendar = RangeCalendar;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import React__default, { useState, useRef, useMemo } from "react";
|
|
33
|
+
import { c as $f62d864046160412$export$f4a51ff076cc9a09, d as $11d87f3f76e88657$export$93522d1a439f3617, e as $14e0f24ef4ac5c92$export$a75f2bff57811055, f as $14e0f24ef4ac5c92$export$5c333a116e949cdd, a as $131cf43a05231e1e$export$6d095e787d2b5e1f, g as $14e0f24ef4ac5c92$export$91b62ebf2ba703ee, h as $f62d864046160412$export$eac50920cf2fd59a, i as $f62d864046160412$export$4f5203c0d889109e, j as $f62d864046160412$export$a1d3911297b952d7, k as $11d87f3f76e88657$export$b4a036af3fc0b032, l as $3b62074eb05584b2$export$80ee6245ec4f29ec, $ as $c4acc1de3ab169cf$export$d652b3ea2d672d5b, b as $64244302c3013299$export$dd0bbc9b26defe37, C as CalendarBase } from "../__chunks__/CalendarBase-DkLU-xxk.mjs";
|
|
34
|
+
import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../__chunks__/context-DEwqildc.mjs";
|
|
35
|
+
import { $ as $458b0a5536c1a7cf$export$40bfa8c7b0832715 } from "../__chunks__/useControlledState-CFWhSD5C.mjs";
|
|
36
|
+
import { $ as $e9faafb641e167db$export$90fc3a17d93f704c } from "../__chunks__/useEvent-C5RCZjKr.mjs";
|
|
37
|
+
function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
38
|
+
let _a = props, { value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {
|
|
39
|
+
months: 1
|
|
40
|
+
}, minValue, maxValue } = _a, calendarProps = __objRest(_a, ["value", "defaultValue", "onChange", "createCalendar", "locale", "visibleDuration", "minValue", "maxValue"]);
|
|
41
|
+
let [value, setValue] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(valueProp, defaultValue || null, onChange);
|
|
42
|
+
let [anchorDate, setAnchorDateState] = useState(null);
|
|
43
|
+
let alignment = "center";
|
|
44
|
+
if (value && value.start && value.end) {
|
|
45
|
+
let start = $f62d864046160412$export$f4a51ff076cc9a09($11d87f3f76e88657$export$93522d1a439f3617(value.start), visibleDuration, locale, minValue, maxValue);
|
|
46
|
+
let end = start.add(visibleDuration).subtract({
|
|
47
|
+
days: 1
|
|
48
|
+
});
|
|
49
|
+
if (value.end.compare(end) > 0) alignment = "start";
|
|
50
|
+
}
|
|
51
|
+
let availableRangeRef = useRef(null);
|
|
52
|
+
let [availableRange, setAvailableRange] = useState(null);
|
|
53
|
+
let min = useMemo(() => $14e0f24ef4ac5c92$export$a75f2bff57811055(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start), [
|
|
54
|
+
minValue,
|
|
55
|
+
availableRange
|
|
56
|
+
]);
|
|
57
|
+
let max = useMemo(() => $14e0f24ef4ac5c92$export$5c333a116e949cdd(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end), [
|
|
58
|
+
maxValue,
|
|
59
|
+
availableRange
|
|
60
|
+
]);
|
|
61
|
+
let calendar = $131cf43a05231e1e$export$6d095e787d2b5e1f(__spreadProps(__spreadValues({}, calendarProps), {
|
|
62
|
+
value: value && value.start,
|
|
63
|
+
createCalendar,
|
|
64
|
+
locale,
|
|
65
|
+
visibleDuration,
|
|
66
|
+
minValue: min,
|
|
67
|
+
maxValue: max,
|
|
68
|
+
selectionAlignment: alignment
|
|
69
|
+
}));
|
|
70
|
+
let updateAvailableRange = (date) => {
|
|
71
|
+
if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
72
|
+
const nextAvailableStartDate = $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, -1);
|
|
73
|
+
const nextAvailableEndDate = $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, 1);
|
|
74
|
+
availableRangeRef.current = {
|
|
75
|
+
start: nextAvailableStartDate,
|
|
76
|
+
end: nextAvailableEndDate
|
|
77
|
+
};
|
|
78
|
+
setAvailableRange(availableRangeRef.current);
|
|
79
|
+
} else {
|
|
80
|
+
availableRangeRef.current = null;
|
|
81
|
+
setAvailableRange(null);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
let [lastVisibleRange, setLastVisibleRange] = useState(calendar.visibleRange);
|
|
85
|
+
if (!$14e0f24ef4ac5c92$export$91b62ebf2ba703ee(calendar.visibleRange.start, lastVisibleRange.start) || !$14e0f24ef4ac5c92$export$91b62ebf2ba703ee(calendar.visibleRange.end, lastVisibleRange.end)) {
|
|
86
|
+
updateAvailableRange(anchorDate);
|
|
87
|
+
setLastVisibleRange(calendar.visibleRange);
|
|
88
|
+
}
|
|
89
|
+
let setAnchorDate = (date) => {
|
|
90
|
+
if (date) {
|
|
91
|
+
setAnchorDateState(date);
|
|
92
|
+
updateAvailableRange(date);
|
|
93
|
+
} else {
|
|
94
|
+
setAnchorDateState(null);
|
|
95
|
+
updateAvailableRange(null);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end);
|
|
99
|
+
let selectDate = (date) => {
|
|
100
|
+
if (props.isReadOnly) return;
|
|
101
|
+
const constrainedDate = $f62d864046160412$export$4f5203c0d889109e(date, min, max);
|
|
102
|
+
const previousAvailableConstrainedDate = $f62d864046160412$export$a1d3911297b952d7(constrainedDate, calendar.visibleRange.start, props.isDateUnavailable);
|
|
103
|
+
if (!previousAvailableConstrainedDate) return;
|
|
104
|
+
if (!anchorDate) setAnchorDate(previousAvailableConstrainedDate);
|
|
105
|
+
else {
|
|
106
|
+
let range = $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, previousAvailableConstrainedDate);
|
|
107
|
+
if (range) setValue({
|
|
108
|
+
start: $9a36b6ba2fb1a7c5$var$convertValue(range.start, value === null || value === void 0 ? void 0 : value.start),
|
|
109
|
+
end: $9a36b6ba2fb1a7c5$var$convertValue(range.end, value === null || value === void 0 ? void 0 : value.end)
|
|
110
|
+
});
|
|
111
|
+
setAnchorDate(null);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
let [isDragging, setDragging] = useState(false);
|
|
115
|
+
let { isDateUnavailable } = props;
|
|
116
|
+
let isInvalidSelection = useMemo(() => {
|
|
117
|
+
if (!value || anchorDate) return false;
|
|
118
|
+
if (isDateUnavailable && (isDateUnavailable(value.start) || isDateUnavailable(value.end))) return true;
|
|
119
|
+
return $f62d864046160412$export$eac50920cf2fd59a(value.start, minValue, maxValue) || $f62d864046160412$export$eac50920cf2fd59a(value.end, minValue, maxValue);
|
|
120
|
+
}, [
|
|
121
|
+
isDateUnavailable,
|
|
122
|
+
value,
|
|
123
|
+
anchorDate,
|
|
124
|
+
minValue,
|
|
125
|
+
maxValue
|
|
126
|
+
]);
|
|
127
|
+
let isValueInvalid = props.isInvalid || props.validationState === "invalid" || isInvalidSelection;
|
|
128
|
+
let validationState = isValueInvalid ? "invalid" : null;
|
|
129
|
+
return __spreadProps(__spreadValues({}, calendar), {
|
|
130
|
+
value,
|
|
131
|
+
setValue,
|
|
132
|
+
anchorDate,
|
|
133
|
+
setAnchorDate,
|
|
134
|
+
highlightedRange,
|
|
135
|
+
validationState,
|
|
136
|
+
isValueInvalid,
|
|
137
|
+
selectFocusedDate() {
|
|
138
|
+
selectDate(calendar.focusedDate);
|
|
139
|
+
},
|
|
140
|
+
selectDate,
|
|
141
|
+
highlightDate(date) {
|
|
142
|
+
if (anchorDate) calendar.setFocusedDate(date);
|
|
143
|
+
},
|
|
144
|
+
isSelected(date) {
|
|
145
|
+
return Boolean(highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date));
|
|
146
|
+
},
|
|
147
|
+
isInvalid(date) {
|
|
148
|
+
var _availableRangeRef_current, _availableRangeRef_current1;
|
|
149
|
+
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);
|
|
150
|
+
},
|
|
151
|
+
isDragging,
|
|
152
|
+
setDragging
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function $9a36b6ba2fb1a7c5$var$makeRange(start, end) {
|
|
156
|
+
if (!start || !end) return null;
|
|
157
|
+
if (end.compare(start) < 0) [start, end] = [
|
|
158
|
+
end,
|
|
159
|
+
start
|
|
160
|
+
];
|
|
161
|
+
return {
|
|
162
|
+
start: $11d87f3f76e88657$export$93522d1a439f3617(start),
|
|
163
|
+
end: $11d87f3f76e88657$export$93522d1a439f3617(end)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) {
|
|
167
|
+
newValue = $11d87f3f76e88657$export$b4a036af3fc0b032(newValue, (oldValue === null || oldValue === void 0 ? void 0 : oldValue.calendar) || new $3b62074eb05584b2$export$80ee6245ec4f29ec());
|
|
168
|
+
if (oldValue && "hour" in oldValue) return oldValue.set(newValue);
|
|
169
|
+
return newValue;
|
|
170
|
+
}
|
|
171
|
+
function $9a36b6ba2fb1a7c5$var$nextUnavailableDate(anchorDate, state, dir) {
|
|
172
|
+
let nextDate = anchorDate.add({
|
|
173
|
+
days: dir
|
|
174
|
+
});
|
|
175
|
+
while ((dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) && !state.isCellUnavailable(nextDate)) nextDate = nextDate.add({
|
|
176
|
+
days: dir
|
|
177
|
+
});
|
|
178
|
+
if (state.isCellUnavailable(nextDate)) return nextDate.add({
|
|
179
|
+
days: -dir
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
|
|
183
|
+
let res = $c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state);
|
|
184
|
+
let isVirtualClick = useRef(false);
|
|
185
|
+
let windowRef = useRef(typeof window !== "undefined" ? window : null);
|
|
186
|
+
$e9faafb641e167db$export$90fc3a17d93f704c(windowRef, "pointerdown", (e) => {
|
|
187
|
+
isVirtualClick.current = e.width === 0 && e.height === 0;
|
|
188
|
+
});
|
|
189
|
+
let endDragging = (e) => {
|
|
190
|
+
if (isVirtualClick.current) {
|
|
191
|
+
isVirtualClick.current = false;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
state.setDragging(false);
|
|
195
|
+
if (!state.anchorDate) return;
|
|
196
|
+
let target = e.target;
|
|
197
|
+
if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
|
|
198
|
+
};
|
|
199
|
+
$e9faafb641e167db$export$90fc3a17d93f704c(windowRef, "pointerup", endDragging);
|
|
200
|
+
res.calendarProps.onBlur = (e) => {
|
|
201
|
+
if (!ref.current) return;
|
|
202
|
+
if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
|
|
203
|
+
};
|
|
204
|
+
$e9faafb641e167db$export$90fc3a17d93f704c(ref, "touchmove", (e) => {
|
|
205
|
+
if (state.isDragging) e.preventDefault();
|
|
206
|
+
}, {
|
|
207
|
+
passive: false,
|
|
208
|
+
capture: true
|
|
209
|
+
});
|
|
210
|
+
return res;
|
|
211
|
+
}
|
|
212
|
+
function RangeCalendar(props) {
|
|
213
|
+
const { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
214
|
+
const calendarRef = React__default.useRef(null);
|
|
215
|
+
const state = $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(__spreadProps(__spreadValues({}, props), {
|
|
216
|
+
locale,
|
|
217
|
+
createCalendar: $64244302c3013299$export$dd0bbc9b26defe37
|
|
218
|
+
}));
|
|
219
|
+
const rangeCalendarProps = $46a4342aab3d8076$export$87e0539f600c24e5(props, state, calendarRef);
|
|
220
|
+
return React__default.createElement(CalendarBase, __spreadProps(__spreadValues(__spreadValues({}, props), rangeCalendarProps), {
|
|
221
|
+
state,
|
|
222
|
+
calendarRef
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
RangeCalendar.displayName = "RangeCalendar";
|
|
226
|
+
export {
|
|
227
|
+
RangeCalendar
|
|
228
|
+
};
|