@expcat/tigercat-react 1.3.4 → 1.4.0
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/dist/{chunk-3SV6J7I5.mjs → chunk-2L7QEOFD.mjs} +34 -25
- package/dist/{chunk-FNJDBFKM.mjs → chunk-2LYV6NBJ.mjs} +6 -1
- package/dist/{chunk-EEWHWEYO.js → chunk-2RBHQBSG.js} +2 -2
- package/dist/{chunk-Y5RQN5BO.mjs → chunk-376X7SDZ.mjs} +2 -2
- package/dist/{chunk-UXUYCWQC.js → chunk-3EDASNTG.js} +5 -5
- package/dist/{chunk-NPTXXUXF.mjs → chunk-3RBRWBUG.mjs} +9 -7
- package/dist/{chunk-PUZDW7NR.js → chunk-4AMSYFYC.js} +134 -20
- package/dist/{chunk-IG75YSX3.mjs → chunk-4MONGWU5.mjs} +4 -6
- package/dist/{chunk-3CJFNG54.mjs → chunk-56CTXEJS.mjs} +1 -1
- package/dist/{chunk-TMON4MPO.js → chunk-5ALMTE35.js} +9 -7
- package/dist/{chunk-MSHCPJIJ.mjs → chunk-6BOSSZM3.mjs} +8 -9
- package/dist/{chunk-SIY6FDKJ.js → chunk-7CHTTM6D.js} +339 -314
- package/dist/{chunk-RF2BA2N6.js → chunk-7PXALKLM.js} +4 -4
- package/dist/{chunk-DLKUDB2R.js → chunk-AF2AEZKM.js} +15 -3
- package/dist/{chunk-FB34UWF7.mjs → chunk-AVLIUHOS.mjs} +101 -40
- package/dist/{chunk-TSJYAEFZ.js → chunk-B63GEB2Y.js} +358 -305
- package/dist/{chunk-6I6X255M.js → chunk-BA6TJQZL.js} +12 -12
- package/dist/{chunk-LMTUM3J3.js → chunk-BEM7XG2L.js} +2 -4
- package/dist/{chunk-MB6U72CI.js → chunk-BEZO5IE4.js} +2 -2
- package/dist/{chunk-5OHVTGHS.mjs → chunk-BN4ZKCAI.mjs} +368 -315
- package/dist/{chunk-UHFHOTNI.js → chunk-BRA3PO53.js} +6 -7
- package/dist/{chunk-M7HBWFQO.js → chunk-BROIZ266.js} +11 -1
- package/dist/{chunk-SDZOVRVR.mjs → chunk-CAQPYJFA.mjs} +350 -325
- package/dist/{chunk-BFAZZUD6.js → chunk-CC5GFX6F.js} +5 -22
- package/dist/{chunk-LQT6ZGME.mjs → chunk-CME2IFUT.mjs} +15 -3
- package/dist/{chunk-KQ5I7PRM.js → chunk-CNNEUJR2.js} +28 -14
- package/dist/{chunk-EF5ZTNHX.js → chunk-D5MQBUP2.js} +16 -4
- package/dist/{chunk-RQXY2MGX.mjs → chunk-D7UR526A.mjs} +231 -184
- package/dist/{chunk-CBYJXDW4.js → chunk-DBMC6FPU.js} +16 -4
- package/dist/{chunk-WQ4FOHOU.mjs → chunk-DEIVWO2D.mjs} +3 -5
- package/dist/{chunk-7QZ4XT2P.mjs → chunk-DVEK5SO6.mjs} +3 -8
- package/dist/{chunk-TC6JLEGZ.js → chunk-EJKOUI26.js} +24 -7
- package/dist/{chunk-4GITZKAH.mjs → chunk-EPJ6W4VI.mjs} +14 -2
- package/dist/{chunk-KYP7U6FK.js → chunk-FZHBVHQ6.js} +34 -25
- package/dist/{chunk-WVVXZKNI.js → chunk-GDPU5MYA.js} +3 -8
- package/dist/{chunk-2GQCFTD7.mjs → chunk-H4MPPCTB.mjs} +23 -4
- package/dist/{chunk-YOAYDEWW.mjs → chunk-HHMYERHY.mjs} +3 -20
- package/dist/{chunk-LRPPXU74.mjs → chunk-I7FEGKX2.mjs} +19 -5
- package/dist/{chunk-F6IXIH6B.mjs → chunk-IZGXDHPB.mjs} +24 -5
- package/dist/{chunk-GQFVVAEF.js → chunk-J6OZWT3P.js} +5 -5
- package/dist/{chunk-IGAMV6ML.mjs → chunk-KDXKF6B2.mjs} +1 -1
- package/dist/{chunk-A42OLED6.mjs → chunk-KED5S2WG.mjs} +13 -2
- package/dist/{chunk-BJQIYELW.mjs → chunk-KGMVRIYC.mjs} +5 -5
- package/dist/{chunk-6GYT3EZD.mjs → chunk-KXT2TP6A.mjs} +3 -4
- package/dist/{chunk-BBLVRLXT.js → chunk-KYNWNTGO.js} +230 -146
- package/dist/{chunk-M73NMNZX.js → chunk-L24PPXLV.js} +17 -5
- package/dist/chunk-L3WPA2RP.js +25 -0
- package/dist/{chunk-V4JIZN3E.mjs → chunk-L6KSO66F.mjs} +4 -12
- package/dist/{chunk-4LX5UGPQ.js → chunk-LJRCEB7F.js} +168 -121
- package/dist/{chunk-F7H4ALKN.js → chunk-LZG24TDB.js} +8 -9
- package/dist/{chunk-ZYJTHGQW.js → chunk-M3FVPPMM.js} +9 -13
- package/dist/{chunk-GN3TSQWW.mjs → chunk-M6YXUNOU.mjs} +2 -2
- package/dist/{chunk-I373B74W.js → chunk-MC26ORSN.js} +102 -41
- package/dist/{chunk-5HFHHFQS.mjs → chunk-MTIGGMHG.mjs} +17 -5
- package/dist/{chunk-DKT2EYVM.mjs → chunk-MV2JQ6XQ.mjs} +3 -6
- package/dist/{chunk-HR5GBE3P.js → chunk-NDGA3N6H.js} +19 -7
- package/dist/{chunk-PU7KEYLP.mjs → chunk-NEZ445D4.mjs} +9 -9
- package/dist/{chunk-4U5HSR2H.js → chunk-NVI2P7VH.js} +3 -4
- package/dist/{chunk-NVEIVIAW.mjs → chunk-OFRKYQOZ.mjs} +133 -19
- package/dist/{chunk-AW5M3EL4.js → chunk-OS6M3IZF.js} +62 -12
- package/dist/{chunk-3ZNZLGQO.mjs → chunk-OXQOKKTP.mjs} +6 -7
- package/dist/{chunk-NMEVQPOD.js → chunk-PHAJXRGE.js} +2 -4
- package/dist/{chunk-WG3YS2QV.js → chunk-PT5T5F4H.js} +13 -2
- package/dist/{chunk-WNLUUD5N.mjs → chunk-QIL24WZD.mjs} +8 -12
- package/dist/{chunk-ZFMMAYSX.js → chunk-QLATA4UB.js} +4 -6
- package/dist/{chunk-2TZ3SBMU.mjs → chunk-RVLV63SI.mjs} +16 -11
- package/dist/{chunk-3QPCQH62.mjs → chunk-RYNLPRUM.mjs} +1 -1
- package/dist/{chunk-6GIJ7NFV.mjs → chunk-SDZKL3IB.mjs} +3 -5
- package/dist/{chunk-G5USITWF.js → chunk-SH4BZYXO.js} +27 -8
- package/dist/{chunk-L5AMVEQL.mjs → chunk-SLEXEH7R.mjs} +60 -10
- package/dist/{chunk-JLRRXRZO.js → chunk-SQONS5PH.js} +4 -7
- package/dist/chunk-SQTOVSDU.mjs +692 -0
- package/dist/{chunk-ITRYKHQJ.js → chunk-TEYL5X56.js} +19 -14
- package/dist/{chunk-KGSDDVRC.mjs → chunk-TNTOSFGN.mjs} +4 -4
- package/dist/{chunk-CY5GRTAX.js → chunk-UAM3RQY4.js} +24 -5
- package/dist/{chunk-XRNKHQTL.js → chunk-UEAXYZSE.js} +3 -2
- package/dist/{chunk-7ISEWLA3.js → chunk-UKQMF3JV.js} +21 -6
- package/dist/{chunk-ITVLIR7T.mjs → chunk-ULWT6W6M.mjs} +13 -20
- package/dist/{chunk-M5GSLKUX.mjs → chunk-VAIWWELW.mjs} +15 -3
- package/dist/{chunk-4SO4LANY.js → chunk-VC26SAXB.js} +340 -274
- package/dist/{chunk-SKMZTW3K.js → chunk-WCTNQYXO.js} +16 -23
- package/dist/{chunk-KXNWY2Q7.mjs → chunk-WFWEMXO7.mjs} +241 -157
- package/dist/chunk-WHYHLUXG.mjs +25 -0
- package/dist/{chunk-ONTRGV5T.js → chunk-WZUADPYB.js} +6 -14
- package/dist/{chunk-N4PP3ENO.js → chunk-XTQUPDRI.js} +2 -2
- package/dist/{chunk-XATXFVKR.mjs → chunk-Y7K27DVV.mjs} +4 -3
- package/dist/{chunk-WI4N5DD3.mjs → chunk-YH57D4AV.mjs} +16 -4
- package/dist/{chunk-3MRP3XYI.js → chunk-YRVAF2ID.js} +7 -2
- package/dist/{chunk-5XE5VBDS.mjs → chunk-YSGM22AH.mjs} +11 -1
- package/dist/{chunk-6TR7JB6C.js → chunk-ZDNQGS4O.js} +4 -4
- package/dist/{chunk-CHBUNQIJ.mjs → chunk-ZQSMJS2Q.mjs} +23 -6
- package/dist/{chunk-QQFLRNI3.mjs → chunk-ZRZB3C5J.mjs} +18 -3
- package/dist/components/ActivityFeed.js +4 -3
- package/dist/components/ActivityFeed.mjs +3 -2
- package/dist/components/Cascader.d.mts +3 -1
- package/dist/components/Cascader.d.ts +3 -1
- package/dist/components/Cascader.js +3 -2
- package/dist/components/Cascader.mjs +2 -1
- package/dist/components/ChatWindow.js +5 -5
- package/dist/components/ChatWindow.mjs +4 -4
- package/dist/components/Checkbox.js +4 -4
- package/dist/components/Checkbox.mjs +3 -3
- package/dist/components/CheckboxGroup.js +3 -3
- package/dist/components/CheckboxGroup.mjs +2 -2
- package/dist/components/CommentThread.js +4 -4
- package/dist/components/CommentThread.mjs +3 -3
- package/dist/components/CropUpload.js +4 -4
- package/dist/components/CropUpload.mjs +3 -3
- package/dist/components/DataTableWithToolbar.d.mts +2 -2
- package/dist/components/DataTableWithToolbar.d.ts +2 -2
- package/dist/components/DataTableWithToolbar.js +11 -11
- package/dist/components/DataTableWithToolbar.mjs +10 -10
- package/dist/components/DatePicker.d.mts +1 -0
- package/dist/components/DatePicker.d.ts +1 -0
- package/dist/components/DatePicker.js +3 -2
- package/dist/components/DatePicker.mjs +2 -1
- package/dist/components/Drawer.js +3 -3
- package/dist/components/Drawer.mjs +2 -2
- package/dist/components/FileManager.d.mts +2 -1
- package/dist/components/FileManager.d.ts +2 -1
- package/dist/components/FileManager.js +3 -2
- package/dist/components/FileManager.mjs +2 -1
- package/dist/components/Form.js +3 -2
- package/dist/components/Form.mjs +2 -1
- package/dist/components/FormItem.js +4 -3
- package/dist/components/FormItem.mjs +3 -2
- package/dist/components/FormWizard.js +4 -4
- package/dist/components/FormWizard.mjs +3 -3
- package/dist/components/Image.js +4 -4
- package/dist/components/Image.mjs +3 -3
- package/dist/components/ImageGroup.js +3 -3
- package/dist/components/ImageGroup.mjs +2 -2
- package/dist/components/ImagePreview.js +2 -2
- package/dist/components/ImagePreview.mjs +1 -1
- package/dist/components/ImageViewer.d.mts +1 -1
- package/dist/components/ImageViewer.d.ts +1 -1
- package/dist/components/ImageViewer.js +2 -2
- package/dist/components/ImageViewer.mjs +1 -1
- package/dist/components/InfiniteScroll.d.mts +2 -0
- package/dist/components/InfiniteScroll.d.ts +2 -0
- package/dist/components/InfiniteScroll.js +3 -2
- package/dist/components/InfiniteScroll.mjs +2 -1
- package/dist/components/Input.js +3 -2
- package/dist/components/Input.mjs +2 -1
- package/dist/components/InputNumber.js +3 -2
- package/dist/components/InputNumber.mjs +2 -1
- package/dist/components/List.d.mts +6 -2
- package/dist/components/List.d.ts +6 -2
- package/dist/components/List.js +3 -2
- package/dist/components/List.mjs +2 -1
- package/dist/components/Loading.js +3 -2
- package/dist/components/Loading.mjs +2 -1
- package/dist/components/MarkdownEditor.js +3 -3
- package/dist/components/MarkdownEditor.mjs +2 -2
- package/dist/components/Mentions.js +2 -2
- package/dist/components/Mentions.mjs +1 -1
- package/dist/components/Menu.d.mts +8 -80
- package/dist/components/Menu.d.ts +8 -80
- package/dist/components/Menu.js +2 -2
- package/dist/components/Menu.mjs +1 -1
- package/dist/components/MenuItem.d.mts +6 -2
- package/dist/components/MenuItem.d.ts +6 -2
- package/dist/components/MenuItem.js +2 -2
- package/dist/components/MenuItem.mjs +1 -1
- package/dist/components/MenuItemGroup.d.mts +6 -2
- package/dist/components/MenuItemGroup.d.ts +6 -2
- package/dist/components/MenuItemGroup.js +2 -2
- package/dist/components/MenuItemGroup.mjs +1 -1
- package/dist/components/Message.js +2 -2
- package/dist/components/Message.mjs +1 -1
- package/dist/components/Modal.js +3 -3
- package/dist/components/Modal.mjs +2 -2
- package/dist/components/Notification.js +2 -2
- package/dist/components/Notification.mjs +1 -1
- package/dist/components/NotificationCenter.js +5 -4
- package/dist/components/NotificationCenter.mjs +4 -3
- package/dist/components/NumberKeyboard.js +3 -2
- package/dist/components/NumberKeyboard.mjs +2 -1
- package/dist/components/Radio.js +4 -4
- package/dist/components/Radio.mjs +3 -3
- package/dist/components/RadioGroup.js +3 -3
- package/dist/components/RadioGroup.mjs +2 -2
- package/dist/components/RichTextEditor.js +3 -3
- package/dist/components/RichTextEditor.mjs +2 -2
- package/dist/components/Select.d.mts +3 -1
- package/dist/components/Select.d.ts +3 -1
- package/dist/components/Select.js +3 -2
- package/dist/components/Select.mjs +2 -1
- package/dist/components/Signature.d.mts +1 -0
- package/dist/components/Signature.d.ts +1 -0
- package/dist/components/Signature.js +3 -2
- package/dist/components/Signature.mjs +2 -1
- package/dist/components/Spotlight.js +4 -2
- package/dist/components/Spotlight.mjs +3 -1
- package/dist/components/Steps.js +2 -2
- package/dist/components/Steps.mjs +1 -1
- package/dist/components/StepsItem.js +2 -2
- package/dist/components/StepsItem.mjs +1 -1
- package/dist/components/SubMenu.d.mts +6 -2
- package/dist/components/SubMenu.d.ts +6 -2
- package/dist/components/SubMenu.js +2 -2
- package/dist/components/SubMenu.mjs +1 -1
- package/dist/components/Table.d.mts +2 -2
- package/dist/components/Table.d.ts +2 -2
- package/dist/components/Table.js +9 -9
- package/dist/components/Table.mjs +8 -8
- package/dist/components/Textarea.js +3 -3
- package/dist/components/Textarea.mjs +2 -2
- package/dist/components/TimePicker.d.mts +1 -0
- package/dist/components/TimePicker.d.ts +1 -0
- package/dist/components/TimePicker.js +4 -2
- package/dist/components/TimePicker.mjs +3 -1
- package/dist/components/Tour.js +3 -2
- package/dist/components/Tour.mjs +2 -1
- package/dist/components/Transfer.d.mts +3 -1
- package/dist/components/Transfer.d.ts +3 -1
- package/dist/components/Transfer.js +3 -2
- package/dist/components/Transfer.mjs +2 -1
- package/dist/components/Tree.d.mts +3 -1
- package/dist/components/Tree.d.ts +3 -1
- package/dist/components/Tree.js +3 -2
- package/dist/components/Tree.mjs +2 -1
- package/dist/components/TreeSelect.d.mts +3 -1
- package/dist/components/TreeSelect.d.ts +3 -1
- package/dist/components/TreeSelect.js +3 -2
- package/dist/components/TreeSelect.mjs +2 -1
- package/dist/components/Upload.js +3 -2
- package/dist/components/Upload.mjs +2 -1
- package/dist/components/VirtualTable.d.mts +3 -2
- package/dist/components/VirtualTable.d.ts +3 -2
- package/dist/components/VirtualTable.js +3 -2
- package/dist/components/VirtualTable.mjs +2 -1
- package/dist/index.d.mts +33 -7
- package/dist/index.d.ts +33 -7
- package/dist/index.js +54 -54
- package/dist/index.mjs +53 -53
- package/dist/{types-CHmCMNEM.d.mts → types-0oVwMXtR.d.mts} +1 -1
- package/dist/{types-CHmCMNEM.d.ts → types-0oVwMXtR.d.ts} +1 -1
- package/dist/types-DaC4a0Ny.d.mts +80 -0
- package/dist/types-DaC4a0Ny.d.ts +80 -0
- package/package.json +2 -2
- package/dist/chunk-UKGQ7256.js +0 -12
- package/dist/chunk-UQMPEMY7.mjs +0 -12
- package/dist/chunk-VNVGSPBI.mjs +0 -626
- package/dist/{chunk-OZD75CLT.js → chunk-ANBNSUSR.js} +3 -3
- package/dist/{chunk-I2AUOICV.mjs → chunk-M3MOSUZO.mjs} +3 -3
- package/dist/{chunk-UMZ3PMUJ.js → chunk-SXHCMZ6U.js} +2 -2
- package/dist/{chunk-BWDQZSAB.mjs → chunk-WTSG7QXK.mjs} +3 -3
|
@@ -1,55 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useControlledState
|
|
3
|
+
} from "./chunk-WHYHLUXG.mjs";
|
|
4
|
+
|
|
1
5
|
// src/components/DatePicker.tsx
|
|
6
|
+
import {
|
|
7
|
+
datePickerInputWrapperClasses,
|
|
8
|
+
datePickerClearButtonClasses,
|
|
9
|
+
CalendarIconPath,
|
|
10
|
+
CloseIconPath
|
|
11
|
+
} from "@expcat/tigercat-core";
|
|
12
|
+
|
|
13
|
+
// src/components/DatePicker/state.ts
|
|
2
14
|
import { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
|
3
15
|
import {
|
|
4
16
|
classNames,
|
|
5
|
-
icon20ViewBox,
|
|
6
17
|
parseDate,
|
|
7
18
|
formatDate,
|
|
8
|
-
|
|
9
|
-
|
|
19
|
+
addDays,
|
|
20
|
+
addMonths,
|
|
10
21
|
isDateInRange,
|
|
11
22
|
getCalendarDays,
|
|
12
23
|
getShortDayNames,
|
|
13
|
-
isToday as isTodayUtil,
|
|
14
24
|
normalizeDate,
|
|
15
25
|
datePickerBaseClasses,
|
|
16
|
-
datePickerInputWrapperClasses,
|
|
17
26
|
getDatePickerInputClasses,
|
|
18
27
|
getDatePickerIconButtonClasses,
|
|
19
|
-
datePickerCalendarClasses,
|
|
20
|
-
datePickerMobileWheelClasses,
|
|
21
|
-
datePickerMobileWheelGridClasses,
|
|
22
|
-
datePickerMobileWheelSelectClasses,
|
|
23
|
-
datePickerCalendarHeaderClasses,
|
|
24
|
-
datePickerNavButtonClasses,
|
|
25
|
-
datePickerMonthYearClasses,
|
|
26
|
-
datePickerCalendarGridClasses,
|
|
27
|
-
datePickerDayNameClasses,
|
|
28
|
-
getDatePickerDayCellClasses,
|
|
29
|
-
datePickerClearButtonClasses,
|
|
30
|
-
datePickerFooterClasses,
|
|
31
|
-
datePickerFooterButtonClasses,
|
|
32
|
-
CalendarIconPath,
|
|
33
|
-
CloseIconPath,
|
|
34
|
-
ChevronLeftIconPath,
|
|
35
|
-
ChevronRightIconPath,
|
|
36
28
|
getDatePickerLocaleCode,
|
|
37
29
|
getDatePickerLabels,
|
|
38
30
|
getLocaleDirection
|
|
39
31
|
} from "@expcat/tigercat-core";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"svg",
|
|
43
|
-
{
|
|
44
|
-
className,
|
|
45
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
46
|
-
viewBox: icon20ViewBox,
|
|
47
|
-
fill: "currentColor",
|
|
48
|
-
children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: path, clipRule: "evenodd" })
|
|
49
|
-
}
|
|
50
|
-
);
|
|
32
|
+
|
|
33
|
+
// src/components/DatePicker/types.ts
|
|
51
34
|
var isRangeDatePicker = (props) => props.range === true;
|
|
52
|
-
|
|
35
|
+
|
|
36
|
+
// src/components/DatePicker/state.ts
|
|
37
|
+
function useDatePickerState(props) {
|
|
53
38
|
const {
|
|
54
39
|
size = "md",
|
|
55
40
|
disabled = false,
|
|
@@ -86,38 +71,33 @@ var DatePicker = (props) => {
|
|
|
86
71
|
const [isOpen, setIsOpen] = useState(false);
|
|
87
72
|
const [activeDateIso, setActiveDateIso] = useState(null);
|
|
88
73
|
const [activeRangePart, setActiveRangePart] = useState("start");
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
74
|
+
const singleProps = props;
|
|
75
|
+
const rangeProps = props;
|
|
76
|
+
const parseRangeTuple = (tuple) => {
|
|
77
|
+
if (!tuple || !Array.isArray(tuple)) return [null, null];
|
|
78
|
+
return [parseDate(tuple[0]), parseDate(tuple[1])];
|
|
79
|
+
};
|
|
80
|
+
const [singleValue, setSingleValue] = useControlledState(
|
|
81
|
+
!isRangeMode && singleProps.value !== void 0 ? parseDate(singleProps.value ?? null) : void 0,
|
|
82
|
+
parseDate(singleProps.defaultValue ?? null),
|
|
83
|
+
singleProps.onChange
|
|
84
|
+
);
|
|
85
|
+
const [rangeValue, setRangeValue] = useControlledState(
|
|
86
|
+
isRangeMode && rangeProps.value !== void 0 ? parseRangeTuple(rangeProps.value) : void 0,
|
|
87
|
+
parseRangeTuple(rangeProps.defaultValue),
|
|
88
|
+
rangeProps.onChange
|
|
89
|
+
);
|
|
101
90
|
const calendarRef = useRef(null);
|
|
102
91
|
const mobileCalendarRef = useRef(null);
|
|
103
92
|
const inputWrapperRef = useRef(null);
|
|
104
93
|
const inputRef = useRef(null);
|
|
105
94
|
const pendingFocusIsoRef = useRef(null);
|
|
106
95
|
const restoreFocusRef = useRef(null);
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
})();
|
|
113
|
-
const selectedRange = (() => {
|
|
114
|
-
if (!isRangeMode) return [null, null];
|
|
115
|
-
const tuple = isControlled ? props.value : internalRangeValue;
|
|
116
|
-
if (!tuple) return [null, null];
|
|
117
|
-
const start = Array.isArray(tuple) ? parseDate(tuple[0]) : null;
|
|
118
|
-
const end = Array.isArray(tuple) ? parseDate(tuple[1]) : null;
|
|
119
|
-
return [start, end];
|
|
120
|
-
})();
|
|
96
|
+
const selectedDate = isRangeMode ? null : singleValue;
|
|
97
|
+
const selectedRange = useMemo(
|
|
98
|
+
() => isRangeMode ? rangeValue : [null, null],
|
|
99
|
+
[isRangeMode, rangeValue]
|
|
100
|
+
);
|
|
121
101
|
const minDateParsed = useMemo(() => parseDate(props.minDate ?? null), [props.minDate]);
|
|
122
102
|
const maxDateParsed = useMemo(() => parseDate(props.maxDate ?? null), [props.maxDate]);
|
|
123
103
|
const localeCode = useMemo(() => getDatePickerLocaleCode(props.locale), [props.locale]);
|
|
@@ -233,11 +213,6 @@ var DatePicker = (props) => {
|
|
|
233
213
|
target.focus();
|
|
234
214
|
}
|
|
235
215
|
}, []);
|
|
236
|
-
const addDays = (date, days) => {
|
|
237
|
-
const next = new Date(date);
|
|
238
|
-
next.setDate(next.getDate() + days);
|
|
239
|
-
return next;
|
|
240
|
-
};
|
|
241
216
|
const moveFocus = (deltaDays) => {
|
|
242
217
|
const activeEl = document.activeElement;
|
|
243
218
|
const currentIso = activeEl?.getAttribute("data-date") ?? activeDateIso ?? null;
|
|
@@ -305,13 +280,6 @@ var DatePicker = (props) => {
|
|
|
305
280
|
}
|
|
306
281
|
}
|
|
307
282
|
};
|
|
308
|
-
const setRangeValue = (next) => {
|
|
309
|
-
if (!isControlled) {
|
|
310
|
-
setInternalRangeValue(next);
|
|
311
|
-
}
|
|
312
|
-
;
|
|
313
|
-
props.onChange?.(next);
|
|
314
|
-
};
|
|
315
283
|
const selectDate = (date) => {
|
|
316
284
|
if (!date) return;
|
|
317
285
|
const normalizedDate = normalizeDate(date);
|
|
@@ -319,11 +287,7 @@ var DatePicker = (props) => {
|
|
|
319
287
|
return;
|
|
320
288
|
}
|
|
321
289
|
if (!isRangeMode) {
|
|
322
|
-
|
|
323
|
-
setInternalValue(normalizedDate);
|
|
324
|
-
}
|
|
325
|
-
;
|
|
326
|
-
props.onChange?.(normalizedDate);
|
|
290
|
+
setSingleValue(normalizedDate);
|
|
327
291
|
closeCalendar();
|
|
328
292
|
return;
|
|
329
293
|
}
|
|
@@ -343,11 +307,7 @@ var DatePicker = (props) => {
|
|
|
343
307
|
setViewingYear(normalized.getFullYear());
|
|
344
308
|
setViewingMonth(normalized.getMonth());
|
|
345
309
|
if (!isRangeMode) {
|
|
346
|
-
|
|
347
|
-
setInternalValue(normalized);
|
|
348
|
-
}
|
|
349
|
-
;
|
|
350
|
-
props.onChange?.(normalized);
|
|
310
|
+
setSingleValue(normalized);
|
|
351
311
|
return;
|
|
352
312
|
}
|
|
353
313
|
const [start, end] = selectedRange;
|
|
@@ -370,8 +330,7 @@ var DatePicker = (props) => {
|
|
|
370
330
|
const val = typeof shortcut.value === "function" ? shortcut.value() : shortcut.value;
|
|
371
331
|
if (!isRangeMode) {
|
|
372
332
|
const date = val instanceof Date ? normalizeDate(val) : val ? normalizeDate(parseDate(val)) : null;
|
|
373
|
-
|
|
374
|
-
props.onChange?.(date);
|
|
333
|
+
setSingleValue(date);
|
|
375
334
|
} else {
|
|
376
335
|
const range = val;
|
|
377
336
|
if (range && Array.isArray(range)) {
|
|
@@ -387,32 +346,19 @@ var DatePicker = (props) => {
|
|
|
387
346
|
const clearDate = (event) => {
|
|
388
347
|
event.stopPropagation();
|
|
389
348
|
if (!isRangeMode) {
|
|
390
|
-
|
|
391
|
-
setInternalValue(null);
|
|
392
|
-
}
|
|
393
|
-
;
|
|
394
|
-
props.onChange?.(null);
|
|
349
|
+
setSingleValue(null);
|
|
395
350
|
} else {
|
|
396
351
|
setRangeValue([null, null]);
|
|
397
352
|
}
|
|
398
353
|
props.onClear?.();
|
|
399
354
|
};
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
} else {
|
|
405
|
-
setViewingMonth(viewingMonth - 1);
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
const nextMonth = () => {
|
|
409
|
-
if (viewingMonth === 11) {
|
|
410
|
-
setViewingMonth(0);
|
|
411
|
-
setViewingYear(viewingYear + 1);
|
|
412
|
-
} else {
|
|
413
|
-
setViewingMonth(viewingMonth + 1);
|
|
414
|
-
}
|
|
355
|
+
const stepViewingMonth = (delta) => {
|
|
356
|
+
const next = addMonths(new Date(viewingYear, viewingMonth, 1), delta);
|
|
357
|
+
setViewingYear(next.getFullYear());
|
|
358
|
+
setViewingMonth(next.getMonth());
|
|
415
359
|
};
|
|
360
|
+
const previousMonth = () => stepViewingMonth(-1);
|
|
361
|
+
const nextMonth = () => stepViewingMonth(1);
|
|
416
362
|
const isCurrentMonth = (date) => {
|
|
417
363
|
if (!date) return false;
|
|
418
364
|
return date.getMonth() === viewingMonth;
|
|
@@ -459,235 +405,342 @@ var DatePicker = (props) => {
|
|
|
459
405
|
[size, disabled, readonly]
|
|
460
406
|
);
|
|
461
407
|
const iconButtonClasses = useMemo(() => getDatePickerIconButtonClasses(size), [size]);
|
|
462
|
-
return
|
|
463
|
-
|
|
464
|
-
|
|
408
|
+
return {
|
|
409
|
+
inputWrapperRef,
|
|
410
|
+
inputRef,
|
|
411
|
+
calendarRef,
|
|
412
|
+
mobileCalendarRef,
|
|
413
|
+
isOpen,
|
|
414
|
+
activeRangePart,
|
|
415
|
+
setActiveRangePart,
|
|
416
|
+
activeDateIso,
|
|
417
|
+
setActiveDateIso,
|
|
418
|
+
isRangeMode,
|
|
419
|
+
placeholder,
|
|
420
|
+
disabled,
|
|
421
|
+
readonly,
|
|
422
|
+
required,
|
|
423
|
+
name: props.name,
|
|
424
|
+
id: props.id,
|
|
425
|
+
shortcuts: props.shortcuts,
|
|
426
|
+
containerClasses: classNames(datePickerBaseClasses, props.className),
|
|
427
|
+
divProps,
|
|
428
|
+
displayValue,
|
|
429
|
+
showClearButton,
|
|
430
|
+
inputClasses,
|
|
431
|
+
iconButtonClasses,
|
|
432
|
+
labels,
|
|
433
|
+
localeCode,
|
|
434
|
+
isRtl,
|
|
435
|
+
dayNames,
|
|
436
|
+
calendarDays,
|
|
437
|
+
selectedDate,
|
|
438
|
+
selectedRange,
|
|
439
|
+
viewingMonth,
|
|
440
|
+
viewingYear,
|
|
441
|
+
mobileDate,
|
|
442
|
+
mobileYears,
|
|
443
|
+
mobileDays,
|
|
444
|
+
toggleCalendar,
|
|
445
|
+
closeCalendar,
|
|
446
|
+
clearDate,
|
|
447
|
+
selectDate,
|
|
448
|
+
setToday,
|
|
449
|
+
handleShortcut,
|
|
450
|
+
handleCalendarKeyDown,
|
|
451
|
+
previousMonth,
|
|
452
|
+
nextMonth,
|
|
453
|
+
updateMobileDate,
|
|
454
|
+
isCurrentMonth,
|
|
455
|
+
isDateDisabled
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/components/DatePicker/render-mobile.tsx
|
|
460
|
+
import {
|
|
461
|
+
datePickerMobileWheelClasses,
|
|
462
|
+
datePickerMobileWheelGridClasses,
|
|
463
|
+
datePickerMobileWheelSelectClasses,
|
|
464
|
+
datePickerFooterButtonClasses
|
|
465
|
+
} from "@expcat/tigercat-core";
|
|
466
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
467
|
+
function renderDatePickerMobile(ctx) {
|
|
468
|
+
return /* @__PURE__ */ jsxs(
|
|
469
|
+
"div",
|
|
470
|
+
{
|
|
471
|
+
ref: ctx.mobileCalendarRef,
|
|
472
|
+
className: datePickerMobileWheelClasses,
|
|
473
|
+
role: "group",
|
|
474
|
+
"aria-label": ctx.labels.calendar,
|
|
475
|
+
children: [
|
|
476
|
+
ctx.isRangeMode && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
|
|
477
|
+
/* @__PURE__ */ jsx(
|
|
478
|
+
"button",
|
|
479
|
+
{
|
|
480
|
+
type: "button",
|
|
481
|
+
className: datePickerFooterButtonClasses,
|
|
482
|
+
"aria-selected": ctx.activeRangePart === "start",
|
|
483
|
+
onClick: () => ctx.setActiveRangePart("start"),
|
|
484
|
+
children: "Start"
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
/* @__PURE__ */ jsx(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
type: "button",
|
|
491
|
+
className: datePickerFooterButtonClasses,
|
|
492
|
+
"aria-selected": ctx.activeRangePart === "end",
|
|
493
|
+
onClick: () => ctx.setActiveRangePart("end"),
|
|
494
|
+
children: "End"
|
|
495
|
+
}
|
|
496
|
+
)
|
|
497
|
+
] }),
|
|
498
|
+
/* @__PURE__ */ jsxs("div", { className: datePickerMobileWheelGridClasses, children: [
|
|
499
|
+
/* @__PURE__ */ jsx(
|
|
500
|
+
"select",
|
|
501
|
+
{
|
|
502
|
+
className: datePickerMobileWheelSelectClasses,
|
|
503
|
+
value: ctx.mobileDate.getFullYear(),
|
|
504
|
+
"aria-label": "Year",
|
|
505
|
+
onChange: (event) => ctx.updateMobileDate("year", Number(event.target.value)),
|
|
506
|
+
children: ctx.mobileYears.map((year) => /* @__PURE__ */ jsx("option", { value: year, children: year }, year))
|
|
507
|
+
}
|
|
508
|
+
),
|
|
509
|
+
/* @__PURE__ */ jsx(
|
|
510
|
+
"select",
|
|
511
|
+
{
|
|
512
|
+
className: datePickerMobileWheelSelectClasses,
|
|
513
|
+
value: ctx.mobileDate.getMonth(),
|
|
514
|
+
"aria-label": "Month",
|
|
515
|
+
onChange: (event) => ctx.updateMobileDate("month", Number(event.target.value)),
|
|
516
|
+
children: Array.from({ length: 12 }, (_, month) => /* @__PURE__ */ jsx("option", { value: month, children: month + 1 }, month))
|
|
517
|
+
}
|
|
518
|
+
),
|
|
519
|
+
/* @__PURE__ */ jsx(
|
|
520
|
+
"select",
|
|
521
|
+
{
|
|
522
|
+
className: datePickerMobileWheelSelectClasses,
|
|
523
|
+
value: ctx.mobileDate.getDate(),
|
|
524
|
+
"aria-label": "Day",
|
|
525
|
+
onChange: (event) => ctx.updateMobileDate("day", Number(event.target.value)),
|
|
526
|
+
children: ctx.mobileDays.map((day) => /* @__PURE__ */ jsx("option", { value: day, children: day }, day))
|
|
527
|
+
}
|
|
528
|
+
)
|
|
529
|
+
] }),
|
|
530
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end gap-2", children: /* @__PURE__ */ jsx(
|
|
531
|
+
"button",
|
|
532
|
+
{
|
|
533
|
+
type: "button",
|
|
534
|
+
className: datePickerFooterButtonClasses,
|
|
535
|
+
"aria-label": `Mobile ${ctx.labels.ok}`,
|
|
536
|
+
onClick: ctx.closeCalendar,
|
|
537
|
+
children: ctx.labels.ok
|
|
538
|
+
}
|
|
539
|
+
) })
|
|
540
|
+
]
|
|
541
|
+
}
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/components/DatePicker/render-calendar.tsx
|
|
546
|
+
import {
|
|
547
|
+
formatDate as formatDate2,
|
|
548
|
+
formatMonthYear,
|
|
549
|
+
isSameDay,
|
|
550
|
+
isToday as isTodayUtil,
|
|
551
|
+
normalizeDate as normalizeDate2,
|
|
552
|
+
datePickerCalendarClasses,
|
|
553
|
+
datePickerCalendarHeaderClasses,
|
|
554
|
+
datePickerNavButtonClasses,
|
|
555
|
+
datePickerMonthYearClasses,
|
|
556
|
+
datePickerCalendarGridClasses,
|
|
557
|
+
datePickerDayNameClasses,
|
|
558
|
+
getDatePickerDayCellClasses,
|
|
559
|
+
datePickerFooterClasses,
|
|
560
|
+
datePickerFooterButtonClasses as datePickerFooterButtonClasses2,
|
|
561
|
+
ChevronLeftIconPath,
|
|
562
|
+
ChevronRightIconPath
|
|
563
|
+
} from "@expcat/tigercat-core";
|
|
564
|
+
|
|
565
|
+
// src/components/DatePicker/icons.tsx
|
|
566
|
+
import { icon20ViewBox } from "@expcat/tigercat-core";
|
|
567
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
568
|
+
var Icon = ({ path, className }) => /* @__PURE__ */ jsx2(
|
|
569
|
+
"svg",
|
|
570
|
+
{
|
|
571
|
+
className,
|
|
572
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
573
|
+
viewBox: icon20ViewBox,
|
|
574
|
+
fill: "currentColor",
|
|
575
|
+
children: /* @__PURE__ */ jsx2("path", { fillRule: "evenodd", d: path, clipRule: "evenodd" })
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
// src/components/DatePicker/render-calendar.tsx
|
|
580
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
581
|
+
function renderDatePickerCalendar(ctx) {
|
|
582
|
+
return /* @__PURE__ */ jsxs2(
|
|
583
|
+
"div",
|
|
584
|
+
{
|
|
585
|
+
ref: ctx.calendarRef,
|
|
586
|
+
className: datePickerCalendarClasses,
|
|
587
|
+
role: "dialog",
|
|
588
|
+
"aria-modal": "true",
|
|
589
|
+
"aria-label": ctx.labels.calendar,
|
|
590
|
+
onKeyDown: ctx.handleCalendarKeyDown,
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ jsxs2("div", { className: datePickerCalendarHeaderClasses, children: [
|
|
593
|
+
/* @__PURE__ */ jsx3(
|
|
594
|
+
"button",
|
|
595
|
+
{
|
|
596
|
+
type: "button",
|
|
597
|
+
className: datePickerNavButtonClasses,
|
|
598
|
+
onClick: ctx.previousMonth,
|
|
599
|
+
"aria-label": ctx.labels.previousMonth,
|
|
600
|
+
children: /* @__PURE__ */ jsx3(Icon, { path: ctx.isRtl ? ChevronRightIconPath : ChevronLeftIconPath, className: "w-5 h-5" })
|
|
601
|
+
}
|
|
602
|
+
),
|
|
603
|
+
/* @__PURE__ */ jsx3("div", { className: datePickerMonthYearClasses, children: formatMonthYear(ctx.viewingYear, ctx.viewingMonth, ctx.localeCode) }),
|
|
604
|
+
/* @__PURE__ */ jsx3(
|
|
605
|
+
"button",
|
|
606
|
+
{
|
|
607
|
+
type: "button",
|
|
608
|
+
className: datePickerNavButtonClasses,
|
|
609
|
+
onClick: ctx.nextMonth,
|
|
610
|
+
"aria-label": ctx.labels.nextMonth,
|
|
611
|
+
children: /* @__PURE__ */ jsx3(Icon, { path: ctx.isRtl ? ChevronLeftIconPath : ChevronRightIconPath, className: "w-5 h-5" })
|
|
612
|
+
}
|
|
613
|
+
)
|
|
614
|
+
] }),
|
|
615
|
+
/* @__PURE__ */ jsx3("div", { className: datePickerCalendarGridClasses, role: "row", children: ctx.dayNames.map((day) => /* @__PURE__ */ jsx3("div", { className: datePickerDayNameClasses, role: "columnheader", children: day }, day)) }),
|
|
616
|
+
(() => {
|
|
617
|
+
const [rangeStart, rangeEnd] = ctx.selectedRange;
|
|
618
|
+
const normStart = rangeStart ? normalizeDate2(rangeStart) : null;
|
|
619
|
+
const normEnd = rangeEnd ? normalizeDate2(rangeEnd) : null;
|
|
620
|
+
const isSelectingEnd = ctx.isRangeMode && Boolean(rangeStart) && !rangeEnd;
|
|
621
|
+
return /* @__PURE__ */ jsx3(
|
|
622
|
+
"div",
|
|
623
|
+
{
|
|
624
|
+
className: datePickerCalendarGridClasses,
|
|
625
|
+
role: "grid",
|
|
626
|
+
"aria-rowcount": 6,
|
|
627
|
+
"aria-colcount": 7,
|
|
628
|
+
children: ctx.calendarDays.map((date, index) => {
|
|
629
|
+
if (!date) return null;
|
|
630
|
+
const normDate = normalizeDate2(date);
|
|
631
|
+
const isRangeStart = ctx.isRangeMode && rangeStart ? isSameDay(date, rangeStart) : false;
|
|
632
|
+
const isRangeEnd = ctx.isRangeMode && rangeEnd ? isSameDay(date, rangeEnd) : false;
|
|
633
|
+
const isInRange = ctx.isRangeMode && normStart && normEnd && normDate >= normStart && normDate <= normEnd;
|
|
634
|
+
const isSelected = !ctx.isRangeMode ? ctx.selectedDate ? isSameDay(date, ctx.selectedDate) : false : isRangeStart || isRangeEnd;
|
|
635
|
+
const isCurrentMonthDay = ctx.isCurrentMonth(date);
|
|
636
|
+
const isTodayDay = isTodayUtil(date);
|
|
637
|
+
const isBeforeRangeStart = isSelectingEnd && normStart && normDate < normStart;
|
|
638
|
+
const isDisabled = ctx.isDateDisabled(date) || Boolean(isBeforeRangeStart);
|
|
639
|
+
const iso = formatDate2(date, "yyyy-MM-dd");
|
|
640
|
+
return /* @__PURE__ */ jsx3(
|
|
641
|
+
"button",
|
|
642
|
+
{
|
|
643
|
+
type: "button",
|
|
644
|
+
className: getDatePickerDayCellClasses(
|
|
645
|
+
isCurrentMonthDay,
|
|
646
|
+
isSelected,
|
|
647
|
+
isTodayDay,
|
|
648
|
+
isDisabled,
|
|
649
|
+
Boolean(isInRange),
|
|
650
|
+
Boolean(isRangeStart),
|
|
651
|
+
Boolean(isRangeEnd)
|
|
652
|
+
),
|
|
653
|
+
disabled: isDisabled,
|
|
654
|
+
onClick: () => ctx.selectDate(date),
|
|
655
|
+
role: "gridcell",
|
|
656
|
+
"data-date": iso,
|
|
657
|
+
onFocus: () => ctx.setActiveDateIso(iso),
|
|
658
|
+
tabIndex: ctx.activeDateIso === iso && !isDisabled ? 0 : -1,
|
|
659
|
+
"aria-label": iso,
|
|
660
|
+
"aria-selected": isSelected,
|
|
661
|
+
"aria-current": isTodayDay ? "date" : void 0,
|
|
662
|
+
children: date.getDate()
|
|
663
|
+
},
|
|
664
|
+
index
|
|
665
|
+
);
|
|
666
|
+
})
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
})(),
|
|
670
|
+
ctx.shortcuts && ctx.shortcuts.length > 0 && /* @__PURE__ */ jsx3("div", { className: "flex flex-wrap gap-1 px-3 py-2 border-t border-[var(--tiger-border,#e5e7eb)]", children: ctx.shortcuts.map((sc, i) => /* @__PURE__ */ jsx3(
|
|
671
|
+
"button",
|
|
672
|
+
{
|
|
673
|
+
type: "button",
|
|
674
|
+
className: datePickerFooterButtonClasses2,
|
|
675
|
+
onClick: () => ctx.handleShortcut(sc),
|
|
676
|
+
children: sc.label
|
|
677
|
+
},
|
|
678
|
+
i
|
|
679
|
+
)) }),
|
|
680
|
+
ctx.isRangeMode && /* @__PURE__ */ jsxs2("div", { className: datePickerFooterClasses, children: [
|
|
681
|
+
/* @__PURE__ */ jsx3("button", { type: "button", className: datePickerFooterButtonClasses2, onClick: ctx.setToday, children: ctx.labels.today }),
|
|
682
|
+
/* @__PURE__ */ jsx3(
|
|
683
|
+
"button",
|
|
684
|
+
{
|
|
685
|
+
type: "button",
|
|
686
|
+
className: datePickerFooterButtonClasses2,
|
|
687
|
+
onClick: ctx.closeCalendar,
|
|
688
|
+
children: ctx.labels.ok
|
|
689
|
+
}
|
|
690
|
+
)
|
|
691
|
+
] })
|
|
692
|
+
]
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// src/components/DatePicker.tsx
|
|
698
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
699
|
+
var DatePicker = (props) => {
|
|
700
|
+
const ctx = useDatePickerState(props);
|
|
701
|
+
return /* @__PURE__ */ jsxs3("div", { className: ctx.containerClasses, ...ctx.divProps, children: [
|
|
702
|
+
/* @__PURE__ */ jsxs3("div", { ref: ctx.inputWrapperRef, className: datePickerInputWrapperClasses, children: [
|
|
703
|
+
/* @__PURE__ */ jsx4(
|
|
465
704
|
"input",
|
|
466
705
|
{
|
|
467
|
-
ref: inputRef,
|
|
706
|
+
ref: ctx.inputRef,
|
|
468
707
|
type: "text",
|
|
469
|
-
className: inputClasses,
|
|
470
|
-
value: displayValue,
|
|
471
|
-
placeholder,
|
|
472
|
-
disabled,
|
|
708
|
+
className: ctx.inputClasses,
|
|
709
|
+
value: ctx.displayValue,
|
|
710
|
+
placeholder: ctx.placeholder,
|
|
711
|
+
disabled: ctx.disabled,
|
|
473
712
|
readOnly: true,
|
|
474
|
-
required,
|
|
475
|
-
name:
|
|
476
|
-
id:
|
|
477
|
-
onClick: toggleCalendar,
|
|
478
|
-
"aria-label": placeholder || "Select date"
|
|
713
|
+
required: ctx.required,
|
|
714
|
+
name: ctx.name,
|
|
715
|
+
id: ctx.id,
|
|
716
|
+
onClick: ctx.toggleCalendar,
|
|
717
|
+
"aria-label": ctx.placeholder || "Select date"
|
|
479
718
|
}
|
|
480
719
|
),
|
|
481
|
-
showClearButton && /* @__PURE__ */
|
|
720
|
+
ctx.showClearButton && /* @__PURE__ */ jsx4(
|
|
482
721
|
"button",
|
|
483
722
|
{
|
|
484
723
|
type: "button",
|
|
485
724
|
className: datePickerClearButtonClasses,
|
|
486
|
-
onClick: clearDate,
|
|
487
|
-
"aria-label": labels.clearDate,
|
|
488
|
-
children: /* @__PURE__ */
|
|
725
|
+
onClick: ctx.clearDate,
|
|
726
|
+
"aria-label": ctx.labels.clearDate,
|
|
727
|
+
children: /* @__PURE__ */ jsx4(Icon, { path: CloseIconPath, className: "w-4 h-4" })
|
|
489
728
|
}
|
|
490
729
|
),
|
|
491
|
-
/* @__PURE__ */
|
|
730
|
+
/* @__PURE__ */ jsx4(
|
|
492
731
|
"button",
|
|
493
732
|
{
|
|
494
733
|
type: "button",
|
|
495
|
-
className: iconButtonClasses,
|
|
496
|
-
disabled: disabled || readonly,
|
|
497
|
-
onClick: toggleCalendar,
|
|
498
|
-
"aria-label": labels.toggleCalendar,
|
|
499
|
-
children: /* @__PURE__ */
|
|
734
|
+
className: ctx.iconButtonClasses,
|
|
735
|
+
disabled: ctx.disabled || ctx.readonly,
|
|
736
|
+
onClick: ctx.toggleCalendar,
|
|
737
|
+
"aria-label": ctx.labels.toggleCalendar,
|
|
738
|
+
children: /* @__PURE__ */ jsx4(Icon, { path: CalendarIconPath, className: "w-5 h-5" })
|
|
500
739
|
}
|
|
501
740
|
)
|
|
502
741
|
] }),
|
|
503
|
-
isOpen &&
|
|
504
|
-
|
|
505
|
-
{
|
|
506
|
-
ref: mobileCalendarRef,
|
|
507
|
-
className: datePickerMobileWheelClasses,
|
|
508
|
-
role: "group",
|
|
509
|
-
"aria-label": labels.calendar,
|
|
510
|
-
children: [
|
|
511
|
-
isRangeMode && /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
|
|
512
|
-
/* @__PURE__ */ jsx(
|
|
513
|
-
"button",
|
|
514
|
-
{
|
|
515
|
-
type: "button",
|
|
516
|
-
className: datePickerFooterButtonClasses,
|
|
517
|
-
"aria-selected": activeRangePart === "start",
|
|
518
|
-
onClick: () => setActiveRangePart("start"),
|
|
519
|
-
children: "Start"
|
|
520
|
-
}
|
|
521
|
-
),
|
|
522
|
-
/* @__PURE__ */ jsx(
|
|
523
|
-
"button",
|
|
524
|
-
{
|
|
525
|
-
type: "button",
|
|
526
|
-
className: datePickerFooterButtonClasses,
|
|
527
|
-
"aria-selected": activeRangePart === "end",
|
|
528
|
-
onClick: () => setActiveRangePart("end"),
|
|
529
|
-
children: "End"
|
|
530
|
-
}
|
|
531
|
-
)
|
|
532
|
-
] }),
|
|
533
|
-
/* @__PURE__ */ jsxs("div", { className: datePickerMobileWheelGridClasses, children: [
|
|
534
|
-
/* @__PURE__ */ jsx(
|
|
535
|
-
"select",
|
|
536
|
-
{
|
|
537
|
-
className: datePickerMobileWheelSelectClasses,
|
|
538
|
-
value: mobileDate.getFullYear(),
|
|
539
|
-
"aria-label": "Year",
|
|
540
|
-
onChange: (event) => updateMobileDate("year", Number(event.target.value)),
|
|
541
|
-
children: mobileYears.map((year) => /* @__PURE__ */ jsx("option", { value: year, children: year }, year))
|
|
542
|
-
}
|
|
543
|
-
),
|
|
544
|
-
/* @__PURE__ */ jsx(
|
|
545
|
-
"select",
|
|
546
|
-
{
|
|
547
|
-
className: datePickerMobileWheelSelectClasses,
|
|
548
|
-
value: mobileDate.getMonth(),
|
|
549
|
-
"aria-label": "Month",
|
|
550
|
-
onChange: (event) => updateMobileDate("month", Number(event.target.value)),
|
|
551
|
-
children: Array.from({ length: 12 }, (_, month) => /* @__PURE__ */ jsx("option", { value: month, children: month + 1 }, month))
|
|
552
|
-
}
|
|
553
|
-
),
|
|
554
|
-
/* @__PURE__ */ jsx(
|
|
555
|
-
"select",
|
|
556
|
-
{
|
|
557
|
-
className: datePickerMobileWheelSelectClasses,
|
|
558
|
-
value: mobileDate.getDate(),
|
|
559
|
-
"aria-label": "Day",
|
|
560
|
-
onChange: (event) => updateMobileDate("day", Number(event.target.value)),
|
|
561
|
-
children: mobileDays.map((day) => /* @__PURE__ */ jsx("option", { value: day, children: day }, day))
|
|
562
|
-
}
|
|
563
|
-
)
|
|
564
|
-
] }),
|
|
565
|
-
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end gap-2", children: /* @__PURE__ */ jsx(
|
|
566
|
-
"button",
|
|
567
|
-
{
|
|
568
|
-
type: "button",
|
|
569
|
-
className: datePickerFooterButtonClasses,
|
|
570
|
-
"aria-label": `Mobile ${labels.ok}`,
|
|
571
|
-
onClick: closeCalendar,
|
|
572
|
-
children: labels.ok
|
|
573
|
-
}
|
|
574
|
-
) })
|
|
575
|
-
]
|
|
576
|
-
}
|
|
577
|
-
),
|
|
578
|
-
isOpen && /* @__PURE__ */ jsxs(
|
|
579
|
-
"div",
|
|
580
|
-
{
|
|
581
|
-
ref: calendarRef,
|
|
582
|
-
className: datePickerCalendarClasses,
|
|
583
|
-
role: "dialog",
|
|
584
|
-
"aria-modal": "true",
|
|
585
|
-
"aria-label": labels.calendar,
|
|
586
|
-
onKeyDown: handleCalendarKeyDown,
|
|
587
|
-
children: [
|
|
588
|
-
/* @__PURE__ */ jsxs("div", { className: datePickerCalendarHeaderClasses, children: [
|
|
589
|
-
/* @__PURE__ */ jsx(
|
|
590
|
-
"button",
|
|
591
|
-
{
|
|
592
|
-
type: "button",
|
|
593
|
-
className: datePickerNavButtonClasses,
|
|
594
|
-
onClick: previousMonth,
|
|
595
|
-
"aria-label": labels.previousMonth,
|
|
596
|
-
children: /* @__PURE__ */ jsx(Icon, { path: isRtl ? ChevronRightIconPath : ChevronLeftIconPath, className: "w-5 h-5" })
|
|
597
|
-
}
|
|
598
|
-
),
|
|
599
|
-
/* @__PURE__ */ jsx("div", { className: datePickerMonthYearClasses, children: formatMonthYear(viewingYear, viewingMonth, localeCode) }),
|
|
600
|
-
/* @__PURE__ */ jsx(
|
|
601
|
-
"button",
|
|
602
|
-
{
|
|
603
|
-
type: "button",
|
|
604
|
-
className: datePickerNavButtonClasses,
|
|
605
|
-
onClick: nextMonth,
|
|
606
|
-
"aria-label": labels.nextMonth,
|
|
607
|
-
children: /* @__PURE__ */ jsx(Icon, { path: isRtl ? ChevronLeftIconPath : ChevronRightIconPath, className: "w-5 h-5" })
|
|
608
|
-
}
|
|
609
|
-
)
|
|
610
|
-
] }),
|
|
611
|
-
/* @__PURE__ */ jsx("div", { className: datePickerCalendarGridClasses, role: "row", children: dayNames.map((day) => /* @__PURE__ */ jsx("div", { className: datePickerDayNameClasses, role: "columnheader", children: day }, day)) }),
|
|
612
|
-
(() => {
|
|
613
|
-
const [rangeStart, rangeEnd] = selectedRange;
|
|
614
|
-
const normStart = rangeStart ? normalizeDate(rangeStart) : null;
|
|
615
|
-
const normEnd = rangeEnd ? normalizeDate(rangeEnd) : null;
|
|
616
|
-
const isSelectingEnd = isRangeMode && Boolean(rangeStart) && !rangeEnd;
|
|
617
|
-
return /* @__PURE__ */ jsx(
|
|
618
|
-
"div",
|
|
619
|
-
{
|
|
620
|
-
className: datePickerCalendarGridClasses,
|
|
621
|
-
role: "grid",
|
|
622
|
-
"aria-rowcount": 6,
|
|
623
|
-
"aria-colcount": 7,
|
|
624
|
-
children: calendarDays.map((date, index) => {
|
|
625
|
-
if (!date) return null;
|
|
626
|
-
const normDate = normalizeDate(date);
|
|
627
|
-
const isRangeStart = isRangeMode && rangeStart ? isSameDay(date, rangeStart) : false;
|
|
628
|
-
const isRangeEnd = isRangeMode && rangeEnd ? isSameDay(date, rangeEnd) : false;
|
|
629
|
-
const isInRange = isRangeMode && normStart && normEnd && normDate >= normStart && normDate <= normEnd;
|
|
630
|
-
const isSelected = !isRangeMode ? selectedDate ? isSameDay(date, selectedDate) : false : isRangeStart || isRangeEnd;
|
|
631
|
-
const isCurrentMonthDay = isCurrentMonth(date);
|
|
632
|
-
const isTodayDay = isTodayUtil(date);
|
|
633
|
-
const isBeforeRangeStart = isSelectingEnd && normStart && normDate < normStart;
|
|
634
|
-
const isDisabled = isDateDisabled(date) || Boolean(isBeforeRangeStart);
|
|
635
|
-
const iso = formatDate(date, "yyyy-MM-dd");
|
|
636
|
-
return /* @__PURE__ */ jsx(
|
|
637
|
-
"button",
|
|
638
|
-
{
|
|
639
|
-
type: "button",
|
|
640
|
-
className: getDatePickerDayCellClasses(
|
|
641
|
-
isCurrentMonthDay,
|
|
642
|
-
isSelected,
|
|
643
|
-
isTodayDay,
|
|
644
|
-
isDisabled,
|
|
645
|
-
Boolean(isInRange),
|
|
646
|
-
Boolean(isRangeStart),
|
|
647
|
-
Boolean(isRangeEnd)
|
|
648
|
-
),
|
|
649
|
-
disabled: isDisabled,
|
|
650
|
-
onClick: () => selectDate(date),
|
|
651
|
-
role: "gridcell",
|
|
652
|
-
"data-date": iso,
|
|
653
|
-
onFocus: () => setActiveDateIso(iso),
|
|
654
|
-
tabIndex: activeDateIso === iso && !isDisabled ? 0 : -1,
|
|
655
|
-
"aria-label": iso,
|
|
656
|
-
"aria-selected": isSelected,
|
|
657
|
-
"aria-current": isTodayDay ? "date" : void 0,
|
|
658
|
-
children: date.getDate()
|
|
659
|
-
},
|
|
660
|
-
index
|
|
661
|
-
);
|
|
662
|
-
})
|
|
663
|
-
}
|
|
664
|
-
);
|
|
665
|
-
})(),
|
|
666
|
-
props.shortcuts && props.shortcuts.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 px-3 py-2 border-t border-[var(--tiger-border,#e5e7eb)]", children: props.shortcuts.map((sc, i) => /* @__PURE__ */ jsx(
|
|
667
|
-
"button",
|
|
668
|
-
{
|
|
669
|
-
type: "button",
|
|
670
|
-
className: datePickerFooterButtonClasses,
|
|
671
|
-
onClick: () => handleShortcut(sc),
|
|
672
|
-
children: sc.label
|
|
673
|
-
},
|
|
674
|
-
i
|
|
675
|
-
)) }),
|
|
676
|
-
isRangeMode && /* @__PURE__ */ jsxs("div", { className: datePickerFooterClasses, children: [
|
|
677
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: datePickerFooterButtonClasses, onClick: setToday, children: labels.today }),
|
|
678
|
-
/* @__PURE__ */ jsx(
|
|
679
|
-
"button",
|
|
680
|
-
{
|
|
681
|
-
type: "button",
|
|
682
|
-
className: datePickerFooterButtonClasses,
|
|
683
|
-
onClick: closeCalendar,
|
|
684
|
-
children: labels.ok
|
|
685
|
-
}
|
|
686
|
-
)
|
|
687
|
-
] })
|
|
688
|
-
]
|
|
689
|
-
}
|
|
690
|
-
)
|
|
742
|
+
ctx.isOpen && renderDatePickerMobile(ctx),
|
|
743
|
+
ctx.isOpen && renderDatePickerCalendar(ctx)
|
|
691
744
|
] });
|
|
692
745
|
};
|
|
693
746
|
|