@nori-ui/core 0.0.5 → 1.0.2
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/animation/animated-view.cjs +13 -0
- package/dist/animation/animated-view.cjs.map +1 -0
- package/dist/animation/animated-view.d.cts +6 -0
- package/dist/animation/animated-view.d.ts +6 -0
- package/dist/animation/animated-view.js +4 -0
- package/dist/animation/animated-view.js.map +1 -0
- package/dist/animation/animated-view.web.cjs +9 -0
- package/dist/animation/animated-view.web.cjs.map +1 -0
- package/dist/animation/animated-view.web.d.cts +5 -0
- package/dist/animation/animated-view.web.d.ts +5 -0
- package/dist/animation/animated-view.web.js +8 -0
- package/dist/animation/animated-view.web.js.map +1 -0
- package/dist/animation/use-animated-number.cjs +80 -0
- package/dist/animation/use-animated-number.cjs.map +1 -0
- package/dist/animation/use-animated-number.d.cts +8 -0
- package/dist/animation/use-animated-number.d.ts +8 -0
- package/dist/animation/use-animated-number.js +4 -0
- package/dist/animation/use-animated-number.js.map +1 -0
- package/dist/animation/use-animated-number.web.cjs +28 -0
- package/dist/animation/use-animated-number.web.cjs.map +1 -0
- package/dist/animation/use-animated-number.web.d.cts +8 -0
- package/dist/animation/use-animated-number.web.d.ts +8 -0
- package/dist/animation/use-animated-number.web.js +25 -0
- package/dist/animation/use-animated-number.web.js.map +1 -0
- package/dist/{chunk-RX7UULY3.js → chunk-33S7ADWM.js} +3 -3
- package/dist/{chunk-RX7UULY3.js.map → chunk-33S7ADWM.js.map} +1 -1
- package/dist/chunk-3BDDPFCI.js +108 -0
- package/dist/chunk-3BDDPFCI.js.map +1 -0
- package/dist/chunk-3F4TXKDY.js +314 -0
- package/dist/chunk-3F4TXKDY.js.map +1 -0
- package/dist/chunk-5A2QOOVN.js +15 -0
- package/dist/chunk-5A2QOOVN.js.map +1 -0
- package/dist/chunk-5XEGZFG5.js +208 -0
- package/dist/chunk-5XEGZFG5.js.map +1 -0
- package/dist/chunk-6AD6KCVB.js +178 -0
- package/dist/chunk-6AD6KCVB.js.map +1 -0
- package/dist/chunk-7GPDNQSX.js +967 -0
- package/dist/chunk-7GPDNQSX.js.map +1 -0
- package/dist/chunk-7UKRN73P.js +42 -0
- package/dist/chunk-7UKRN73P.js.map +1 -0
- package/dist/chunk-7Z4NMNX6.js +64 -0
- package/dist/chunk-7Z4NMNX6.js.map +1 -0
- package/dist/chunk-ACLHDHX3.js +29 -0
- package/dist/chunk-ACLHDHX3.js.map +1 -0
- package/dist/chunk-BZLT6R62.js +80 -0
- package/dist/chunk-BZLT6R62.js.map +1 -0
- package/dist/chunk-CCUXO2HN.js +450 -0
- package/dist/chunk-CCUXO2HN.js.map +1 -0
- package/dist/chunk-CHXHRJNZ.js +43 -0
- package/dist/chunk-CHXHRJNZ.js.map +1 -0
- package/dist/chunk-DDGMLLS3.js +188 -0
- package/dist/chunk-DDGMLLS3.js.map +1 -0
- package/dist/chunk-EWWQQ5DB.js +654 -0
- package/dist/chunk-EWWQQ5DB.js.map +1 -0
- package/dist/chunk-FEPTH5RV.js +169 -0
- package/dist/chunk-FEPTH5RV.js.map +1 -0
- package/dist/{chunk-SSTXLK5I.js → chunk-FT2XBBQJ.js} +42 -6
- package/dist/chunk-FT2XBBQJ.js.map +1 -0
- package/dist/chunk-IKLA2CVQ.js +260 -0
- package/dist/chunk-IKLA2CVQ.js.map +1 -0
- package/dist/chunk-JQQ3FBN7.js +18 -0
- package/dist/chunk-JQQ3FBN7.js.map +1 -0
- package/dist/chunk-JSAG5YO7.js +69 -0
- package/dist/chunk-JSAG5YO7.js.map +1 -0
- package/dist/chunk-JZ774T7U.js +76 -0
- package/dist/chunk-JZ774T7U.js.map +1 -0
- package/dist/chunk-KWRDJPP3.js +10 -0
- package/dist/chunk-KWRDJPP3.js.map +1 -0
- package/dist/chunk-LVWNMQGR.js +1106 -0
- package/dist/chunk-LVWNMQGR.js.map +1 -0
- package/dist/chunk-LWLK6HSW.js +143 -0
- package/dist/chunk-LWLK6HSW.js.map +1 -0
- package/dist/chunk-MDOZGILD.js +134 -0
- package/dist/chunk-MDOZGILD.js.map +1 -0
- package/dist/chunk-MKSDYRWQ.js +446 -0
- package/dist/chunk-MKSDYRWQ.js.map +1 -0
- package/dist/chunk-MRJWPRCX.js +80 -0
- package/dist/chunk-MRJWPRCX.js.map +1 -0
- package/dist/chunk-NRYWNOG5.js +410 -0
- package/dist/chunk-NRYWNOG5.js.map +1 -0
- package/dist/chunk-OMU4R4Y5.js +144 -0
- package/dist/chunk-OMU4R4Y5.js.map +1 -0
- package/dist/chunk-PNP7L4TA.js +103 -0
- package/dist/chunk-PNP7L4TA.js.map +1 -0
- package/dist/chunk-QI6646JZ.js +3 -0
- package/dist/{chunk-UAKFCMWK.js.map → chunk-QI6646JZ.js.map} +1 -1
- package/dist/chunk-QJNV7YQP.js +138 -0
- package/dist/chunk-QJNV7YQP.js.map +1 -0
- package/dist/chunk-R5JMDDCB.js +292 -0
- package/dist/chunk-R5JMDDCB.js.map +1 -0
- package/dist/chunk-RB3YBWQ4.js +77 -0
- package/dist/chunk-RB3YBWQ4.js.map +1 -0
- package/dist/chunk-RFW5SRZA.js +23 -0
- package/dist/chunk-RFW5SRZA.js.map +1 -0
- package/dist/chunk-RGJ3NBKE.js +8 -0
- package/dist/chunk-RGJ3NBKE.js.map +1 -0
- package/dist/chunk-SFNDR6DI.js +485 -0
- package/dist/chunk-SFNDR6DI.js.map +1 -0
- package/dist/chunk-SWC5CNKE.js +13 -0
- package/dist/chunk-SWC5CNKE.js.map +1 -0
- package/dist/chunk-TLS54G6Y.js +15 -0
- package/dist/chunk-TLS54G6Y.js.map +1 -0
- package/dist/chunk-WCQVDF3K.js +12 -0
- package/dist/{chunk-7QVYU63E.js.map → chunk-WCQVDF3K.js.map} +1 -1
- package/dist/chunk-WGT345SV.js +427 -0
- package/dist/chunk-WGT345SV.js.map +1 -0
- package/dist/chunk-X7APG7G2.js +1566 -0
- package/dist/chunk-X7APG7G2.js.map +1 -0
- package/dist/chunk-XALU6LOT.js +306 -0
- package/dist/chunk-XALU6LOT.js.map +1 -0
- package/dist/chunk-YNKKEO2A.js +336 -0
- package/dist/chunk-YNKKEO2A.js.map +1 -0
- package/dist/chunk-ZBW3BA5R.js +148 -0
- package/dist/chunk-ZBW3BA5R.js.map +1 -0
- package/dist/{chunk-FXKIWONG.js → chunk-ZIBNLXIV.js} +12 -6
- package/dist/chunk-ZIBNLXIV.js.map +1 -0
- package/dist/chunk-ZMSIYLSI.js +563 -0
- package/dist/chunk-ZMSIYLSI.js.map +1 -0
- package/dist/chunk-ZQMNGPLE.js +981 -0
- package/dist/chunk-ZQMNGPLE.js.map +1 -0
- package/dist/chunk-ZRD4FQBT.js +153 -0
- package/dist/chunk-ZRD4FQBT.js.map +1 -0
- package/dist/client.cjs +11289 -439
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +68 -117
- package/dist/client.d.ts +68 -117
- package/dist/client.js +58 -40
- package/dist/client.js.map +1 -1
- package/dist/components/Accordion/index.cjs +900 -0
- package/dist/components/Accordion/index.cjs.map +1 -0
- package/dist/components/Accordion/index.d.cts +72 -0
- package/dist/components/Accordion/index.d.ts +72 -0
- package/dist/components/Accordion/index.js +10 -0
- package/dist/components/Accordion/index.js.map +1 -0
- package/dist/components/Alert/index.cjs +567 -0
- package/dist/components/Alert/index.cjs.map +1 -0
- package/dist/components/Alert/index.d.cts +41 -0
- package/dist/components/Alert/index.d.ts +41 -0
- package/dist/components/Alert/index.js +8 -0
- package/dist/components/Alert/index.js.map +1 -0
- package/dist/components/AlertDialog/index.cjs +892 -0
- package/dist/components/AlertDialog/index.cjs.map +1 -0
- package/dist/components/AlertDialog/index.d.cts +68 -0
- package/dist/components/AlertDialog/index.d.ts +68 -0
- package/dist/components/AlertDialog/index.js +9 -0
- package/dist/components/AlertDialog/index.js.map +1 -0
- package/dist/components/Avatar/index.cjs +427 -0
- package/dist/components/Avatar/index.cjs.map +1 -0
- package/dist/components/Avatar/index.d.cts +40 -0
- package/dist/components/Avatar/index.d.ts +40 -0
- package/dist/components/Avatar/index.js +7 -0
- package/dist/components/Avatar/index.js.map +1 -0
- package/dist/components/Badge/index.cjs +433 -0
- package/dist/components/Badge/index.cjs.map +1 -0
- package/dist/components/Badge/index.d.cts +35 -0
- package/dist/components/Badge/index.d.ts +35 -0
- package/dist/components/Badge/index.js +7 -0
- package/dist/components/Badge/index.js.map +1 -0
- package/dist/components/Box/index.cjs +415 -0
- package/dist/components/Box/index.cjs.map +1 -0
- package/dist/components/Box/index.d.cts +24 -0
- package/dist/components/Box/index.d.ts +24 -0
- package/dist/components/Box/index.js +9 -0
- package/dist/components/Box/index.js.map +1 -0
- package/dist/components/Breadcrumb/index.cjs +1939 -0
- package/dist/components/Breadcrumb/index.cjs.map +1 -0
- package/dist/components/Breadcrumb/index.d.cts +186 -0
- package/dist/components/Breadcrumb/index.d.ts +186 -0
- package/dist/components/Breadcrumb/index.js +11 -0
- package/dist/components/Breadcrumb/index.js.map +1 -0
- package/dist/components/Button/index.cjs +631 -0
- package/dist/components/Button/index.cjs.map +1 -0
- package/dist/components/Button/index.d.cts +27 -0
- package/dist/components/Button/index.d.ts +27 -0
- package/dist/components/Button/index.js +9 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Calendar/index.cjs +3017 -0
- package/dist/components/Calendar/index.cjs.map +1 -0
- package/dist/components/Calendar/index.d.cts +169 -0
- package/dist/components/Calendar/index.d.ts +169 -0
- package/dist/components/Calendar/index.js +11 -0
- package/dist/components/Calendar/index.js.map +1 -0
- package/dist/components/Card/index.cjs +469 -0
- package/dist/components/Card/index.cjs.map +1 -0
- package/dist/components/Card/index.d.cts +33 -0
- package/dist/components/Card/index.d.ts +33 -0
- package/dist/components/Card/index.js +7 -0
- package/dist/components/Card/index.js.map +1 -0
- package/dist/components/Checkbox/index.cjs +590 -0
- package/dist/components/Checkbox/index.cjs.map +1 -0
- package/dist/components/Checkbox/index.d.cts +22 -0
- package/dist/components/Checkbox/index.d.ts +22 -0
- package/dist/components/Checkbox/index.js +9 -0
- package/dist/components/Checkbox/index.js.map +1 -0
- package/dist/components/Dialog/index.cjs +888 -0
- package/dist/components/Dialog/index.cjs.map +1 -0
- package/dist/components/Dialog/index.d.cts +56 -0
- package/dist/components/Dialog/index.d.ts +56 -0
- package/dist/components/Dialog/index.js +10 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/FloatButton/index.cjs +1254 -0
- package/dist/components/FloatButton/index.cjs.map +1 -0
- package/dist/components/FloatButton/index.d.cts +133 -0
- package/dist/components/FloatButton/index.d.ts +133 -0
- package/dist/components/FloatButton/index.js +11 -0
- package/dist/components/FloatButton/index.js.map +1 -0
- package/dist/components/HStack/index.cjs +480 -0
- package/dist/components/HStack/index.cjs.map +1 -0
- package/dist/components/HStack/index.d.cts +24 -0
- package/dist/components/HStack/index.d.ts +24 -0
- package/dist/components/HStack/index.js +9 -0
- package/dist/components/HStack/index.js.map +1 -0
- package/dist/components/InputGroup/index.cjs +638 -0
- package/dist/components/InputGroup/index.cjs.map +1 -0
- package/dist/components/InputGroup/index.d.cts +33 -0
- package/dist/components/InputGroup/index.d.ts +33 -0
- package/dist/components/InputGroup/index.js +7 -0
- package/dist/components/InputGroup/index.js.map +1 -0
- package/dist/components/Pagination/index.cjs +2501 -0
- package/dist/components/Pagination/index.cjs.map +1 -0
- package/dist/components/Pagination/index.d.cts +164 -0
- package/dist/components/Pagination/index.d.ts +164 -0
- package/dist/components/Pagination/index.js +12 -0
- package/dist/components/Pagination/index.js.map +1 -0
- package/dist/components/Popover/index.cjs +739 -0
- package/dist/components/Popover/index.cjs.map +1 -0
- package/dist/components/Popover/index.d.cts +44 -0
- package/dist/components/Popover/index.d.ts +44 -0
- package/dist/components/Popover/index.js +8 -0
- package/dist/components/Popover/index.js.map +1 -0
- package/dist/components/Progress/index.cjs +493 -0
- package/dist/components/Progress/index.cjs.map +1 -0
- package/dist/components/Progress/index.d.cts +63 -0
- package/dist/components/Progress/index.d.ts +63 -0
- package/dist/components/Progress/index.js +7 -0
- package/dist/components/Progress/index.js.map +1 -0
- package/dist/components/Radio/index.cjs +584 -0
- package/dist/components/Radio/index.cjs.map +1 -0
- package/dist/components/Radio/index.d.cts +51 -0
- package/dist/components/Radio/index.d.ts +51 -0
- package/dist/components/Radio/index.js +7 -0
- package/dist/components/Radio/index.js.map +1 -0
- package/dist/components/SegmentedControl/index.cjs +502 -0
- package/dist/components/SegmentedControl/index.cjs.map +1 -0
- package/dist/components/SegmentedControl/index.d.cts +45 -0
- package/dist/components/SegmentedControl/index.d.ts +45 -0
- package/dist/components/SegmentedControl/index.js +7 -0
- package/dist/components/SegmentedControl/index.js.map +1 -0
- package/dist/components/Select/index.cjs +1359 -0
- package/dist/components/Select/index.cjs.map +1 -0
- package/dist/components/Select/index.d.cts +140 -0
- package/dist/components/Select/index.d.ts +140 -0
- package/dist/components/Select/index.js +8 -0
- package/dist/components/Select/index.js.map +1 -0
- package/dist/components/Separator/index.cjs +358 -0
- package/dist/components/Separator/index.cjs.map +1 -0
- package/dist/components/Separator/index.d.cts +28 -0
- package/dist/components/Separator/index.d.ts +28 -0
- package/dist/components/Separator/index.js +6 -0
- package/dist/components/Separator/index.js.map +1 -0
- package/dist/components/Skeleton/index.cjs +384 -0
- package/dist/components/Skeleton/index.cjs.map +1 -0
- package/dist/components/Skeleton/index.d.cts +30 -0
- package/dist/components/Skeleton/index.d.ts +30 -0
- package/dist/components/Skeleton/index.js +6 -0
- package/dist/components/Skeleton/index.js.map +1 -0
- package/dist/components/Slider/index.cjs +880 -0
- package/dist/components/Slider/index.cjs.map +1 -0
- package/dist/components/Slider/index.d.cts +84 -0
- package/dist/components/Slider/index.d.ts +84 -0
- package/dist/components/Slider/index.js +6 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Spinner/index.cjs +32 -0
- package/dist/components/Spinner/index.cjs.map +1 -0
- package/dist/components/Spinner/index.d.cts +25 -0
- package/dist/components/Spinner/index.d.ts +25 -0
- package/dist/components/Spinner/index.js +4 -0
- package/dist/components/Spinner/index.js.map +1 -0
- package/dist/components/Switch/index.cjs +623 -0
- package/dist/components/Switch/index.cjs.map +1 -0
- package/dist/components/Switch/index.d.cts +22 -0
- package/dist/components/Switch/index.d.ts +22 -0
- package/dist/components/Switch/index.js +10 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Tabs/index.cjs +630 -0
- package/dist/components/Tabs/index.cjs.map +1 -0
- package/dist/components/Tabs/index.d.cts +63 -0
- package/dist/components/Tabs/index.d.ts +63 -0
- package/dist/components/Tabs/index.js +7 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/Text/index.cjs +401 -0
- package/dist/components/Text/index.cjs.map +1 -0
- package/dist/components/Text/index.d.cts +24 -0
- package/dist/components/Text/index.d.ts +24 -0
- package/dist/components/Text/index.js +7 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/TextArea/index.cjs +482 -0
- package/dist/components/TextArea/index.cjs.map +1 -0
- package/dist/components/TextArea/index.d.cts +25 -0
- package/dist/components/TextArea/index.d.ts +25 -0
- package/dist/components/TextArea/index.js +8 -0
- package/dist/components/TextArea/index.js.map +1 -0
- package/dist/components/TextInput/index.cjs +477 -0
- package/dist/components/TextInput/index.cjs.map +1 -0
- package/dist/components/TextInput/index.d.cts +33 -0
- package/dist/components/TextInput/index.d.ts +33 -0
- package/dist/components/TextInput/index.js +7 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/Toast/index.cjs +167 -0
- package/dist/components/Toast/index.cjs.map +1 -0
- package/dist/components/Toast/index.d.cts +143 -0
- package/dist/components/Toast/index.d.ts +143 -0
- package/dist/components/Toast/index.js +4 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/components/Toggle/index.cjs +770 -0
- package/dist/components/Toggle/index.cjs.map +1 -0
- package/dist/components/Toggle/index.d.cts +83 -0
- package/dist/components/Toggle/index.d.ts +83 -0
- package/dist/components/Toggle/index.js +7 -0
- package/dist/components/Toggle/index.js.map +1 -0
- package/dist/components/Tooltip/index.cjs +813 -0
- package/dist/components/Tooltip/index.cjs.map +1 -0
- package/dist/components/Tooltip/index.d.cts +55 -0
- package/dist/components/Tooltip/index.d.ts +55 -0
- package/dist/components/Tooltip/index.js +8 -0
- package/dist/components/Tooltip/index.js.map +1 -0
- package/dist/components/VStack/index.cjs +480 -0
- package/dist/components/VStack/index.cjs.map +1 -0
- package/dist/components/VStack/index.d.cts +19 -0
- package/dist/components/VStack/index.d.ts +19 -0
- package/dist/components/VStack/index.js +9 -0
- package/dist/components/VStack/index.js.map +1 -0
- package/dist/i18n/index.cjs +39 -3
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +4 -60
- package/dist/i18n/index.d.ts +4 -60
- package/dist/i18n/index.js +3 -2
- package/dist/icons/index.cjs +326 -26
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.js +4 -3
- package/dist/index-D3_M3G6U.d.ts +19 -0
- package/dist/index-uXPK_Rg8.d.cts +19 -0
- package/dist/index.cjs +11176 -463
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -183
- package/dist/index.d.ts +39 -183
- package/dist/index.js +49 -9
- package/dist/resolve-D-GOaxZy.d.cts +60 -0
- package/dist/resolve-D-GOaxZy.d.ts +60 -0
- package/dist/slot/index.cjs +9 -3
- package/dist/slot/index.cjs.map +1 -1
- package/dist/slot/index.js +2 -2
- package/dist/stories/index.cjs +108 -0
- package/dist/stories/index.cjs.map +1 -0
- package/dist/stories/index.d.cts +46 -0
- package/dist/stories/index.d.ts +46 -0
- package/dist/stories/index.js +94 -0
- package/dist/stories/index.js.map +1 -0
- package/dist/theme/index.cjs +259 -26
- package/dist/theme/index.cjs.map +1 -1
- package/dist/theme/index.d.cts +26 -0
- package/dist/theme/index.d.ts +26 -0
- package/dist/theme/index.js +4 -3
- package/dist/use-theme-CoqfnvRs.d.cts +112 -0
- package/dist/use-theme-CoqfnvRs.d.ts +112 -0
- package/dist/utils/cn.cjs +18 -6
- package/dist/utils/cn.cjs.map +1 -1
- package/dist/utils/cn.js +2 -2
- package/package.json +41 -10
- package/dist/chunk-6OABNXBY.js +0 -213
- package/dist/chunk-6OABNXBY.js.map +0 -1
- package/dist/chunk-7QVYU63E.js +0 -6
- package/dist/chunk-FXKIWONG.js.map +0 -1
- package/dist/chunk-NDEDMCHT.js +0 -40
- package/dist/chunk-NDEDMCHT.js.map +0 -1
- package/dist/chunk-SSTXLK5I.js.map +0 -1
- package/dist/chunk-UAKFCMWK.js +0 -3
- package/dist/chunk-X3AJNNF6.js +0 -539
- package/dist/chunk-X3AJNNF6.js.map +0 -1
- package/dist/chunk-XGM2K4TT.js +0 -31
- package/dist/chunk-XGM2K4TT.js.map +0 -1
- package/dist/stories/story-registry.cjs +0 -776
- package/dist/stories/story-registry.cjs.map +0 -1
- package/dist/stories/story-registry.d.cts +0 -13
- package/dist/stories/story-registry.d.ts +0 -13
- package/dist/stories/story-registry.js +0 -106
- package/dist/stories/story-registry.js.map +0 -1
|
@@ -0,0 +1,1566 @@
|
|
|
1
|
+
import { Select } from './chunk-ZQMNGPLE.js';
|
|
2
|
+
import { useTranslation } from './chunk-RFW5SRZA.js';
|
|
3
|
+
import { useThemeColors } from './chunk-R5JMDDCB.js';
|
|
4
|
+
import { __name } from './chunk-WCQVDF3K.js';
|
|
5
|
+
import { today, getLocalTimeZone, CalendarDate, startOfMonth } from '@internationalized/date';
|
|
6
|
+
import { createContext, useState, useCallback, useContext, useRef, useLayoutEffect, useMemo, useEffect } from 'react';
|
|
7
|
+
import { View, Text, Pressable } from 'react-native';
|
|
8
|
+
import { jsx, Fragment, jsxs } from 'nativewind/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var detectLocale = /* @__PURE__ */ __name(() => {
|
|
11
|
+
try {
|
|
12
|
+
return new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
13
|
+
} catch {
|
|
14
|
+
return "en-US";
|
|
15
|
+
}
|
|
16
|
+
}, "detectLocale");
|
|
17
|
+
var toTag = /* @__PURE__ */ __name((input) => input === void 0 ? detectLocale() : typeof input === "string" ? input : input.toString(), "toTag");
|
|
18
|
+
var LocaleContext = createContext(null);
|
|
19
|
+
LocaleContext.displayName = "LocaleContext";
|
|
20
|
+
var LocaleProvider = /* @__PURE__ */ __name(({ locale, children }) => {
|
|
21
|
+
const value = useMemo(() => toTag(locale), [locale]);
|
|
22
|
+
return /* @__PURE__ */ jsx(LocaleContext.Provider, { value, children });
|
|
23
|
+
}, "LocaleProvider");
|
|
24
|
+
var useLocale = /* @__PURE__ */ __name(() => {
|
|
25
|
+
const ctx = useContext(LocaleContext);
|
|
26
|
+
return ctx ?? detectLocale();
|
|
27
|
+
}, "useLocale");
|
|
28
|
+
|
|
29
|
+
// src/components/Calendar/state/locale-utils.ts
|
|
30
|
+
var getFirstDayOfWeek = /* @__PURE__ */ __name((locale) => {
|
|
31
|
+
try {
|
|
32
|
+
const loc = new Intl.Locale(locale);
|
|
33
|
+
const info = loc.getWeekInfo?.() ?? loc.weekInfo;
|
|
34
|
+
if (typeof info?.firstDay === "number") {
|
|
35
|
+
return info.firstDay === 7 ? 0 : info.firstDay;
|
|
36
|
+
}
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
return FIRST_DAY_FALLBACK[locale] ?? FIRST_DAY_FALLBACK[locale.split("-")[0] ?? ""] ?? 1;
|
|
40
|
+
}, "getFirstDayOfWeek");
|
|
41
|
+
var FIRST_DAY_FALLBACK = {
|
|
42
|
+
en: 0,
|
|
43
|
+
"en-US": 0,
|
|
44
|
+
"en-CA": 0,
|
|
45
|
+
"en-GB": 1,
|
|
46
|
+
"en-AU": 1,
|
|
47
|
+
de: 1,
|
|
48
|
+
fr: 1,
|
|
49
|
+
ja: 0,
|
|
50
|
+
ar: 0,
|
|
51
|
+
he: 0,
|
|
52
|
+
fa: 6
|
|
53
|
+
};
|
|
54
|
+
var getWeekendDays = /* @__PURE__ */ __name((locale) => {
|
|
55
|
+
try {
|
|
56
|
+
const loc = new Intl.Locale(locale);
|
|
57
|
+
const info = loc.getWeekInfo?.() ?? loc.weekInfo;
|
|
58
|
+
if (info?.weekend && Array.isArray(info.weekend) && info.weekend.length === 2) {
|
|
59
|
+
const [a, b] = info.weekend.map((d) => d === 7 ? 0 : d);
|
|
60
|
+
return [a, b];
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return WEEKEND_FALLBACK[locale] ?? WEEKEND_FALLBACK[locale.split("-")[0] ?? ""] ?? [6, 0];
|
|
65
|
+
}, "getWeekendDays");
|
|
66
|
+
var WEEKEND_FALLBACK = {
|
|
67
|
+
"en-US": [6, 0],
|
|
68
|
+
"de-DE": [6, 0],
|
|
69
|
+
"fr-FR": [6, 0],
|
|
70
|
+
"ja-JP": [6, 0],
|
|
71
|
+
"ar-SA": [5, 6],
|
|
72
|
+
"ar-AE": [5, 6],
|
|
73
|
+
"he-IL": [5, 6],
|
|
74
|
+
"fa-IR": [4, 5],
|
|
75
|
+
en: [6, 0],
|
|
76
|
+
de: [6, 0],
|
|
77
|
+
fr: [6, 0],
|
|
78
|
+
ar: [5, 6],
|
|
79
|
+
he: [5, 6]
|
|
80
|
+
};
|
|
81
|
+
var formatWeekdayNames = /* @__PURE__ */ __name((locale, format = "short") => {
|
|
82
|
+
const fmt = new Intl.DateTimeFormat(locale, { weekday: format });
|
|
83
|
+
const start = getFirstDayOfWeek(locale);
|
|
84
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
85
|
+
const d = new Date(Date.UTC(2026, 0, 4 + (start + i) % 7));
|
|
86
|
+
return fmt.format(d);
|
|
87
|
+
});
|
|
88
|
+
}, "formatWeekdayNames");
|
|
89
|
+
var formatMonthYearTitle = /* @__PURE__ */ __name((date, locale) => {
|
|
90
|
+
const fmt = new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" });
|
|
91
|
+
return fmt.format(date.toDate("UTC"));
|
|
92
|
+
}, "formatMonthYearTitle");
|
|
93
|
+
var formatMonthNames = /* @__PURE__ */ __name((locale) => {
|
|
94
|
+
const fmt = new Intl.DateTimeFormat(locale, { month: "long" });
|
|
95
|
+
return Array.from({ length: 12 }, (_, m) => fmt.format(new Date(Date.UTC(2026, m, 15))));
|
|
96
|
+
}, "formatMonthNames");
|
|
97
|
+
var useCalendarKeyboard = /* @__PURE__ */ __name((props) => {
|
|
98
|
+
const { focusedDate, moveFocus, selectDate, firstDayOfWeek = 0 } = props;
|
|
99
|
+
const onKeyDown = useCallback(
|
|
100
|
+
(event) => {
|
|
101
|
+
const focusedDow = focusedDate.toDate("UTC").getUTCDay();
|
|
102
|
+
switch (event.key) {
|
|
103
|
+
case "ArrowLeft":
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
moveFocus({ days: -1 });
|
|
106
|
+
return;
|
|
107
|
+
case "ArrowRight":
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
moveFocus({ days: 1 });
|
|
110
|
+
return;
|
|
111
|
+
case "ArrowUp":
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
moveFocus({ weeks: -1 });
|
|
114
|
+
return;
|
|
115
|
+
case "ArrowDown":
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
moveFocus({ weeks: 1 });
|
|
118
|
+
return;
|
|
119
|
+
case "PageUp":
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
moveFocus(event.shiftKey ? { years: -1 } : { months: -1 });
|
|
122
|
+
return;
|
|
123
|
+
case "PageDown":
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
moveFocus(event.shiftKey ? { years: 1 } : { months: 1 });
|
|
126
|
+
return;
|
|
127
|
+
case "Home": {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
const back = (focusedDow - firstDayOfWeek + 7) % 7;
|
|
130
|
+
moveFocus({ days: -back });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
case "End": {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
const back = (focusedDow - firstDayOfWeek + 7) % 7;
|
|
136
|
+
const forward = 6 - back;
|
|
137
|
+
moveFocus({ days: forward });
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
case "Enter":
|
|
141
|
+
case " ":
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
selectDate(focusedDate, "keyboard");
|
|
144
|
+
return;
|
|
145
|
+
default:
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
[focusedDate, firstDayOfWeek, moveFocus, selectDate]
|
|
150
|
+
);
|
|
151
|
+
return { onKeyDown };
|
|
152
|
+
}, "useCalendarKeyboard");
|
|
153
|
+
|
|
154
|
+
// src/components/Calendar/state/constraints.ts
|
|
155
|
+
var cmp = /* @__PURE__ */ __name((a, b) => a.compare(b), "cmp");
|
|
156
|
+
var isOutOfRange = /* @__PURE__ */ __name((date, bounds = {}) => {
|
|
157
|
+
if (bounds.minValue && cmp(date, bounds.minValue) < 0) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (bounds.maxValue && cmp(date, bounds.maxValue) > 0) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}, "isOutOfRange");
|
|
165
|
+
var composeUnavailable = /* @__PURE__ */ __name((c) => (date) => {
|
|
166
|
+
if (isOutOfRange(date, c)) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
if (c.isDateUnavailable?.(date)) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}, "composeUnavailable");
|
|
174
|
+
|
|
175
|
+
// src/components/Calendar/state/use-calendar-state.ts
|
|
176
|
+
var initialFocus = /* @__PURE__ */ __name((mode, value, fallback) => {
|
|
177
|
+
if (!value) {
|
|
178
|
+
return fallback;
|
|
179
|
+
}
|
|
180
|
+
if (mode === "single") {
|
|
181
|
+
return value ?? fallback;
|
|
182
|
+
}
|
|
183
|
+
if (mode === "range") {
|
|
184
|
+
const r = value;
|
|
185
|
+
return r?.start ?? fallback;
|
|
186
|
+
}
|
|
187
|
+
const arr = value;
|
|
188
|
+
return arr[0] ?? fallback;
|
|
189
|
+
}, "initialFocus");
|
|
190
|
+
var useCalendarState = /* @__PURE__ */ __name((props) => {
|
|
191
|
+
const mode = props.mode ?? "single";
|
|
192
|
+
const fallback = today(getLocalTimeZone());
|
|
193
|
+
const [internalValue, setInternalValue] = useState(() => {
|
|
194
|
+
if (props.value !== void 0) {
|
|
195
|
+
return props.value;
|
|
196
|
+
}
|
|
197
|
+
if (props.defaultValue !== void 0) {
|
|
198
|
+
return props.defaultValue;
|
|
199
|
+
}
|
|
200
|
+
return mode === "multiple" ? [] : null;
|
|
201
|
+
});
|
|
202
|
+
const isControlled = props.value !== void 0;
|
|
203
|
+
const value = isControlled ? props.value : internalValue;
|
|
204
|
+
const [internalView, setInternalView] = useState(props.defaultView ?? "day");
|
|
205
|
+
const isViewControlled = props.view !== void 0;
|
|
206
|
+
const view = isViewControlled ? props.view : internalView;
|
|
207
|
+
const [focusedDate, setFocusedDate] = useState(() => initialFocus(mode, value, fallback));
|
|
208
|
+
const isUnavailable = useMemo(
|
|
209
|
+
() => composeUnavailable({
|
|
210
|
+
...props.minValue !== void 0 ? { minValue: props.minValue } : {},
|
|
211
|
+
...props.maxValue !== void 0 ? { maxValue: props.maxValue } : {},
|
|
212
|
+
...props.isDateUnavailable !== void 0 ? { isDateUnavailable: props.isDateUnavailable } : {}
|
|
213
|
+
}),
|
|
214
|
+
[props.minValue, props.maxValue, props.isDateUnavailable]
|
|
215
|
+
);
|
|
216
|
+
const setView = useCallback(
|
|
217
|
+
(next) => {
|
|
218
|
+
if (!isViewControlled) {
|
|
219
|
+
setInternalView(next);
|
|
220
|
+
}
|
|
221
|
+
props.onViewChange?.(next);
|
|
222
|
+
},
|
|
223
|
+
[isViewControlled, props.onViewChange]
|
|
224
|
+
);
|
|
225
|
+
const moveFocus = useCallback(
|
|
226
|
+
(delta) => {
|
|
227
|
+
setFocusedDate((cur) => {
|
|
228
|
+
let next = cur;
|
|
229
|
+
if (delta.days) {
|
|
230
|
+
next = next.add({ days: delta.days });
|
|
231
|
+
}
|
|
232
|
+
if (delta.weeks) {
|
|
233
|
+
next = next.add({ weeks: delta.weeks });
|
|
234
|
+
}
|
|
235
|
+
if (delta.months) {
|
|
236
|
+
next = next.add({ months: delta.months });
|
|
237
|
+
}
|
|
238
|
+
if (delta.years) {
|
|
239
|
+
next = next.add({ years: delta.years });
|
|
240
|
+
}
|
|
241
|
+
if (!isUnavailable(next)) {
|
|
242
|
+
return next;
|
|
243
|
+
}
|
|
244
|
+
const totalDelta = (delta.days ?? 0) + (delta.weeks ?? 0) * 7 + (delta.months ?? 0) * 30 + (delta.years ?? 0) * 365;
|
|
245
|
+
const sign = totalDelta >= 0 ? 1 : -1;
|
|
246
|
+
for (let i = 1; i <= 100; i++) {
|
|
247
|
+
const candidate = next.add({ days: sign * i });
|
|
248
|
+
if (!isUnavailable(candidate)) {
|
|
249
|
+
return candidate;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return cur;
|
|
253
|
+
});
|
|
254
|
+
},
|
|
255
|
+
[isUnavailable]
|
|
256
|
+
);
|
|
257
|
+
const selectDate = useCallback(
|
|
258
|
+
(date, source) => {
|
|
259
|
+
if (isUnavailable(date)) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const meta = { view, source };
|
|
263
|
+
let next;
|
|
264
|
+
if (mode === "single") {
|
|
265
|
+
next = date;
|
|
266
|
+
} else if (mode === "multiple") {
|
|
267
|
+
const arr = value ?? [];
|
|
268
|
+
const exists = arr.some((d) => d.compare(date) === 0);
|
|
269
|
+
next = exists ? arr.filter((d) => d.compare(date) !== 0) : [...arr, date];
|
|
270
|
+
} else {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (!isControlled) {
|
|
274
|
+
setInternalValue(next);
|
|
275
|
+
}
|
|
276
|
+
props.onChange?.(next, meta);
|
|
277
|
+
setFocusedDate(date);
|
|
278
|
+
},
|
|
279
|
+
[isControlled, isUnavailable, mode, props.onChange, value, view]
|
|
280
|
+
);
|
|
281
|
+
return {
|
|
282
|
+
value,
|
|
283
|
+
view,
|
|
284
|
+
focusedDate,
|
|
285
|
+
setView,
|
|
286
|
+
moveFocus,
|
|
287
|
+
setFocusedDate,
|
|
288
|
+
selectDate,
|
|
289
|
+
isUnavailable
|
|
290
|
+
};
|
|
291
|
+
}, "useCalendarState");
|
|
292
|
+
var order = /* @__PURE__ */ __name((a, b) => a.compare(b) <= 0 ? [a, b] : [b, a], "order");
|
|
293
|
+
var nightsBetween = /* @__PURE__ */ __name((a, b) => {
|
|
294
|
+
const [first, last] = order(a, b);
|
|
295
|
+
return Math.round((last.toDate("UTC").getTime() - first.toDate("UTC").getTime()) / 864e5);
|
|
296
|
+
}, "nightsBetween");
|
|
297
|
+
var useRangeState = /* @__PURE__ */ __name((props) => {
|
|
298
|
+
const [internal, setInternal] = useState(props.defaultValue ?? null);
|
|
299
|
+
const isControlled = props.value !== void 0;
|
|
300
|
+
const value = isControlled ? props.value ?? null : internal;
|
|
301
|
+
const [hoveredDate, setHoveredDate] = useState(null);
|
|
302
|
+
const isUnavailable = useMemo(
|
|
303
|
+
() => composeUnavailable({
|
|
304
|
+
...props.minValue !== void 0 ? { minValue: props.minValue } : {},
|
|
305
|
+
...props.maxValue !== void 0 ? { maxValue: props.maxValue } : {},
|
|
306
|
+
...props.isDateUnavailable !== void 0 ? { isDateUnavailable: props.isDateUnavailable } : {}
|
|
307
|
+
}),
|
|
308
|
+
[props.minValue, props.maxValue, props.isDateUnavailable]
|
|
309
|
+
);
|
|
310
|
+
const commit = useCallback(
|
|
311
|
+
(next, source) => {
|
|
312
|
+
if (!isControlled) {
|
|
313
|
+
setInternal(next);
|
|
314
|
+
}
|
|
315
|
+
props.onChange?.(next, { view: "day", source });
|
|
316
|
+
},
|
|
317
|
+
[isControlled, props.onChange]
|
|
318
|
+
);
|
|
319
|
+
const selectDate = useCallback(
|
|
320
|
+
(date, source = "click") => {
|
|
321
|
+
if (isUnavailable(date)) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (!value || value.end !== null) {
|
|
325
|
+
commit({ start: date, end: null }, source);
|
|
326
|
+
setHoveredDate(null);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const nights = nightsBetween(value.start, date);
|
|
330
|
+
if (props.minNights !== void 0 && nights < props.minNights) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (props.maxNights !== void 0 && nights > props.maxNights) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const [start, end] = order(value.start, date);
|
|
337
|
+
commit({ start, end }, source);
|
|
338
|
+
setHoveredDate(null);
|
|
339
|
+
},
|
|
340
|
+
[commit, isUnavailable, props.maxNights, props.minNights, value]
|
|
341
|
+
);
|
|
342
|
+
const previewRange = useMemo(() => {
|
|
343
|
+
if (!value || value.end !== null || !hoveredDate) {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
const [start, end] = order(value.start, hoveredDate);
|
|
347
|
+
return { start, end };
|
|
348
|
+
}, [hoveredDate, value]);
|
|
349
|
+
return {
|
|
350
|
+
value,
|
|
351
|
+
previewRange,
|
|
352
|
+
hoveredDate,
|
|
353
|
+
selectDate,
|
|
354
|
+
setHoveredDate,
|
|
355
|
+
isUnavailable
|
|
356
|
+
};
|
|
357
|
+
}, "useRangeState");
|
|
358
|
+
var CaptionContext = createContext(null);
|
|
359
|
+
CaptionContext.displayName = "CalendarCaptionContext";
|
|
360
|
+
var CaptionProvider = /* @__PURE__ */ __name(({ value, children }) => /* @__PURE__ */ jsx(CaptionContext.Provider, { value, children }), "CaptionProvider");
|
|
361
|
+
var useCalendarCaption = /* @__PURE__ */ __name(() => {
|
|
362
|
+
const ctx = useContext(CaptionContext);
|
|
363
|
+
if (!ctx) {
|
|
364
|
+
throw new Error('useCalendarCaption must be called inside a <Calendar caption="custom"> subtree.');
|
|
365
|
+
}
|
|
366
|
+
return ctx;
|
|
367
|
+
}, "useCalendarCaption");
|
|
368
|
+
var ARROW_BUTTON_GAP = 8;
|
|
369
|
+
var NavButton = /* @__PURE__ */ __name(({ label, onPress, children }) => {
|
|
370
|
+
const colors = useThemeColors();
|
|
371
|
+
return /* @__PURE__ */ jsx(
|
|
372
|
+
Pressable,
|
|
373
|
+
{
|
|
374
|
+
accessibilityRole: "button",
|
|
375
|
+
accessibilityLabel: label,
|
|
376
|
+
onPress,
|
|
377
|
+
style: ({ pressed, hovered, focused }) => {
|
|
378
|
+
const base = {
|
|
379
|
+
width: 32,
|
|
380
|
+
height: 32,
|
|
381
|
+
alignItems: "center",
|
|
382
|
+
justifyContent: "center",
|
|
383
|
+
borderRadius: 8
|
|
384
|
+
};
|
|
385
|
+
const transition = {
|
|
386
|
+
transitionProperty: "background-color, border-color, transform",
|
|
387
|
+
transitionDuration: "140ms",
|
|
388
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
389
|
+
outlineStyle: "none"
|
|
390
|
+
};
|
|
391
|
+
const bg = pressed ? colors.color.primary["200"] : hovered ? colors.color.primary["100"] : "transparent";
|
|
392
|
+
const border = focused ? { borderWidth: 2, borderColor: colors.semantic.interactive.primary } : { borderWidth: 0 };
|
|
393
|
+
return [base, transition, { backgroundColor: bg, transform: [{ scale: pressed ? 0.94 : 1 }] }, border];
|
|
394
|
+
},
|
|
395
|
+
children: /* @__PURE__ */ jsx(Text, { style: { color: colors.semantic.text.default, fontSize: 16, lineHeight: 16, fontWeight: "500" }, children })
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
}, "NavButton");
|
|
399
|
+
var TitleButton = /* @__PURE__ */ __name(({
|
|
400
|
+
text,
|
|
401
|
+
ariaLabel,
|
|
402
|
+
onPress,
|
|
403
|
+
drilldown
|
|
404
|
+
}) => {
|
|
405
|
+
const colors = useThemeColors();
|
|
406
|
+
if (!onPress) {
|
|
407
|
+
return /* @__PURE__ */ jsx(View, { style: { paddingHorizontal: 12, paddingVertical: 6, alignItems: "center" }, children: /* @__PURE__ */ jsx(
|
|
408
|
+
Text,
|
|
409
|
+
{
|
|
410
|
+
style: {
|
|
411
|
+
color: colors.semantic.text.default,
|
|
412
|
+
fontSize: 15,
|
|
413
|
+
fontWeight: "600",
|
|
414
|
+
letterSpacing: -0.1
|
|
415
|
+
},
|
|
416
|
+
children: text
|
|
417
|
+
}
|
|
418
|
+
) });
|
|
419
|
+
}
|
|
420
|
+
return /* @__PURE__ */ jsxs(
|
|
421
|
+
Pressable,
|
|
422
|
+
{
|
|
423
|
+
accessibilityRole: "button",
|
|
424
|
+
accessibilityLabel: ariaLabel,
|
|
425
|
+
onPress,
|
|
426
|
+
style: ({ pressed, hovered, focused }) => {
|
|
427
|
+
const base = {
|
|
428
|
+
flexDirection: "row",
|
|
429
|
+
alignItems: "center",
|
|
430
|
+
gap: 6,
|
|
431
|
+
paddingHorizontal: 12,
|
|
432
|
+
paddingVertical: 6,
|
|
433
|
+
borderRadius: 8
|
|
434
|
+
};
|
|
435
|
+
const transition = {
|
|
436
|
+
transitionProperty: "background-color, transform",
|
|
437
|
+
transitionDuration: "140ms",
|
|
438
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
439
|
+
outlineStyle: "none"
|
|
440
|
+
};
|
|
441
|
+
const bg = pressed ? colors.color.primary["200"] : hovered ? colors.color.primary["100"] : "transparent";
|
|
442
|
+
const border = focused ? { borderWidth: 2, borderColor: colors.semantic.interactive.primary } : { borderWidth: 0 };
|
|
443
|
+
return [base, transition, { backgroundColor: bg, transform: [{ scale: pressed ? 0.97 : 1 }] }, border];
|
|
444
|
+
},
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ jsx(
|
|
447
|
+
Text,
|
|
448
|
+
{
|
|
449
|
+
style: {
|
|
450
|
+
color: colors.semantic.text.default,
|
|
451
|
+
fontSize: 15,
|
|
452
|
+
fontWeight: "600",
|
|
453
|
+
letterSpacing: -0.1
|
|
454
|
+
},
|
|
455
|
+
children: text
|
|
456
|
+
}
|
|
457
|
+
),
|
|
458
|
+
drilldown ? /* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: { color: colors.semantic.text.muted, fontSize: 10, opacity: 0.7 }, children: "\u25BE" }) : null
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
}, "TitleButton");
|
|
463
|
+
var Caption = /* @__PURE__ */ __name(({
|
|
464
|
+
months,
|
|
465
|
+
locale,
|
|
466
|
+
view,
|
|
467
|
+
caption,
|
|
468
|
+
gridWidth,
|
|
469
|
+
monthGap,
|
|
470
|
+
yearRange,
|
|
471
|
+
isMonthDisabled,
|
|
472
|
+
isYearDisabled,
|
|
473
|
+
onPrev,
|
|
474
|
+
onNext,
|
|
475
|
+
onTitlePress,
|
|
476
|
+
onSetMonth,
|
|
477
|
+
onSetYear,
|
|
478
|
+
children
|
|
479
|
+
}) => {
|
|
480
|
+
const { t } = useTranslation();
|
|
481
|
+
const titleText = /* @__PURE__ */ __name((m) => {
|
|
482
|
+
if (view === "day") {
|
|
483
|
+
return formatMonthYearTitle(m, locale);
|
|
484
|
+
}
|
|
485
|
+
if (view === "month") {
|
|
486
|
+
return String(m.year);
|
|
487
|
+
}
|
|
488
|
+
const start = m.year - m.year % 10;
|
|
489
|
+
return `${start} \u2013 ${start + 11}`;
|
|
490
|
+
}, "titleText");
|
|
491
|
+
const titleAriaKey = view === "day" ? "calendar.header.openMonthView" : view === "month" ? "calendar.header.openYearView" : "calendar.header.openDayView";
|
|
492
|
+
const showMultiTitles = view === "day" && months.length > 1;
|
|
493
|
+
const titleRowWidth = showMultiTitles ? months.length * gridWidth + (months.length - 1) * monthGap : gridWidth;
|
|
494
|
+
const monthNames = useMemo(() => formatMonthNames(locale), [locale]);
|
|
495
|
+
const focused = months[0] ?? void 0;
|
|
496
|
+
if (!focused) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
const ctxValue = {
|
|
500
|
+
month: focused.month,
|
|
501
|
+
year: focused.year,
|
|
502
|
+
visibleMonth: focused,
|
|
503
|
+
monthOptions: monthNames.map((label, i) => ({
|
|
504
|
+
value: i + 1,
|
|
505
|
+
label,
|
|
506
|
+
disabled: isMonthDisabled?.(focused.year, i + 1) ?? false
|
|
507
|
+
})),
|
|
508
|
+
yearOptions: Array.from({ length: yearRange[1] - yearRange[0] + 1 }, (_, i) => ({
|
|
509
|
+
value: yearRange[0] + i,
|
|
510
|
+
label: String(yearRange[0] + i),
|
|
511
|
+
disabled: isYearDisabled?.(yearRange[0] + i) ?? false
|
|
512
|
+
})),
|
|
513
|
+
setMonth: /* @__PURE__ */ __name((m) => onSetMonth(0, m), "setMonth"),
|
|
514
|
+
setYear: /* @__PURE__ */ __name((y) => onSetYear(0, y), "setYear"),
|
|
515
|
+
goPrev: onPrev,
|
|
516
|
+
goNext: onNext
|
|
517
|
+
};
|
|
518
|
+
if (caption === "custom") {
|
|
519
|
+
return /* @__PURE__ */ jsx(
|
|
520
|
+
View,
|
|
521
|
+
{
|
|
522
|
+
style: {
|
|
523
|
+
flexDirection: "row",
|
|
524
|
+
alignItems: "center",
|
|
525
|
+
paddingBottom: 10,
|
|
526
|
+
gap: ARROW_BUTTON_GAP,
|
|
527
|
+
alignSelf: "center"
|
|
528
|
+
},
|
|
529
|
+
children: /* @__PURE__ */ jsx(CaptionProvider, { value: ctxValue, children })
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
return /* @__PURE__ */ jsxs(
|
|
534
|
+
View,
|
|
535
|
+
{
|
|
536
|
+
style: {
|
|
537
|
+
flexDirection: "row",
|
|
538
|
+
alignItems: "center",
|
|
539
|
+
paddingBottom: 10,
|
|
540
|
+
gap: ARROW_BUTTON_GAP,
|
|
541
|
+
alignSelf: "center"
|
|
542
|
+
},
|
|
543
|
+
children: [
|
|
544
|
+
/* @__PURE__ */ jsx(NavButton, { label: t("calendar.header.previous", { defaultValue: "Previous" }), onPress: onPrev, children: "\u2039" }),
|
|
545
|
+
/* @__PURE__ */ jsx(View, { style: { flexDirection: "row", gap: monthGap, width: titleRowWidth }, children: showMultiTitles ? months.map((m, i) => /* @__PURE__ */ jsx(View, { style: { width: gridWidth, alignItems: "center" }, children: caption === "dropdown" && view === "day" ? /* @__PURE__ */ jsx(
|
|
546
|
+
DropdownPair,
|
|
547
|
+
{
|
|
548
|
+
month: m.month,
|
|
549
|
+
year: m.year,
|
|
550
|
+
monthOptions: monthNames.map((label, j) => ({
|
|
551
|
+
value: j + 1,
|
|
552
|
+
label,
|
|
553
|
+
disabled: isMonthDisabled?.(m.year, j + 1) ?? false
|
|
554
|
+
})),
|
|
555
|
+
yearOptions: makeYearOptions(yearRange, isYearDisabled),
|
|
556
|
+
onMonthChange: (next) => onSetMonth(i, next),
|
|
557
|
+
onYearChange: (next) => onSetYear(i, next)
|
|
558
|
+
}
|
|
559
|
+
) : /* @__PURE__ */ jsx(
|
|
560
|
+
TitleButton,
|
|
561
|
+
{
|
|
562
|
+
text: titleText(m),
|
|
563
|
+
ariaLabel: t(titleAriaKey, { defaultValue: "Change view" }),
|
|
564
|
+
onPress: () => onTitlePress(m),
|
|
565
|
+
drilldown: true
|
|
566
|
+
}
|
|
567
|
+
) }, `${m.year}-${m.month}`)) : /* @__PURE__ */ jsx(View, { style: { width: gridWidth, alignItems: "center" }, children: caption === "dropdown" && view === "day" ? /* @__PURE__ */ jsx(
|
|
568
|
+
DropdownPair,
|
|
569
|
+
{
|
|
570
|
+
month: focused.month,
|
|
571
|
+
year: focused.year,
|
|
572
|
+
monthOptions: monthNames.map((label, j) => ({
|
|
573
|
+
value: j + 1,
|
|
574
|
+
label,
|
|
575
|
+
disabled: isMonthDisabled?.(focused.year, j + 1) ?? false
|
|
576
|
+
})),
|
|
577
|
+
yearOptions: makeYearOptions(yearRange, isYearDisabled),
|
|
578
|
+
onMonthChange: (next) => onSetMonth(0, next),
|
|
579
|
+
onYearChange: (next) => onSetYear(0, next)
|
|
580
|
+
}
|
|
581
|
+
) : /* @__PURE__ */ jsx(
|
|
582
|
+
TitleButton,
|
|
583
|
+
{
|
|
584
|
+
text: titleText(focused),
|
|
585
|
+
ariaLabel: t(titleAriaKey, { defaultValue: "Change view" }),
|
|
586
|
+
onPress: () => onTitlePress(focused),
|
|
587
|
+
drilldown: true
|
|
588
|
+
}
|
|
589
|
+
) }) }),
|
|
590
|
+
/* @__PURE__ */ jsx(NavButton, { label: t("calendar.header.next", { defaultValue: "Next" }), onPress: onNext, children: "\u203A" })
|
|
591
|
+
]
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
}, "Caption");
|
|
595
|
+
var makeYearOptions = /* @__PURE__ */ __name((yearRange, isYearDisabled) => Array.from({ length: yearRange[1] - yearRange[0] + 1 }, (_, i) => ({
|
|
596
|
+
value: yearRange[0] + i,
|
|
597
|
+
label: String(yearRange[0] + i),
|
|
598
|
+
disabled: isYearDisabled?.(yearRange[0] + i) ?? false
|
|
599
|
+
})), "makeYearOptions");
|
|
600
|
+
var DropdownPair = /* @__PURE__ */ __name(({ month, year, monthOptions, yearOptions, onMonthChange, onYearChange }) => {
|
|
601
|
+
return /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: 6 }, children: [
|
|
602
|
+
/* @__PURE__ */ jsx(
|
|
603
|
+
Select,
|
|
604
|
+
{
|
|
605
|
+
value: String(month),
|
|
606
|
+
onChange: (v) => onMonthChange(Number(v)),
|
|
607
|
+
options: monthOptions.map((o) => ({
|
|
608
|
+
value: String(o.value),
|
|
609
|
+
label: o.label,
|
|
610
|
+
disabled: o.disabled
|
|
611
|
+
})),
|
|
612
|
+
"aria-label": "Month",
|
|
613
|
+
searchable: false
|
|
614
|
+
}
|
|
615
|
+
),
|
|
616
|
+
/* @__PURE__ */ jsx(
|
|
617
|
+
Select,
|
|
618
|
+
{
|
|
619
|
+
value: String(year),
|
|
620
|
+
onChange: (v) => onYearChange(Number(v)),
|
|
621
|
+
options: yearOptions.map((o) => ({
|
|
622
|
+
value: String(o.value),
|
|
623
|
+
label: o.label,
|
|
624
|
+
disabled: o.disabled
|
|
625
|
+
})),
|
|
626
|
+
"aria-label": "Year",
|
|
627
|
+
searchable: false
|
|
628
|
+
}
|
|
629
|
+
)
|
|
630
|
+
] });
|
|
631
|
+
}, "DropdownPair");
|
|
632
|
+
var CELL_SIZE = 40;
|
|
633
|
+
var DayCell = /* @__PURE__ */ __name(({ ctx, onPress, onHoverIn, onHoverOut, renderDay }) => {
|
|
634
|
+
const colors = useThemeColors();
|
|
635
|
+
const isSelectedLike = ctx.isSelected || ctx.isRangeStart || ctx.isRangeEnd;
|
|
636
|
+
const isInsideRange = ctx.isInRange || ctx.isInPreviewRange;
|
|
637
|
+
const isRangeMiddle = isInsideRange && !isSelectedLike;
|
|
638
|
+
const dataState = ctx.isSelected ? "selected" : ctx.isRangeStart ? "range-start" : ctx.isRangeEnd ? "range-end" : ctx.isInPreviewRange ? "preview" : ctx.isInRange ? "in-range" : void 0;
|
|
639
|
+
return /* @__PURE__ */ jsx(
|
|
640
|
+
Pressable,
|
|
641
|
+
{
|
|
642
|
+
accessibilityRole: "button",
|
|
643
|
+
accessibilityState: { disabled: ctx.isUnavailable },
|
|
644
|
+
disabled: ctx.isUnavailable,
|
|
645
|
+
onPress,
|
|
646
|
+
...onHoverIn ? { onHoverIn } : {},
|
|
647
|
+
...onHoverOut ? { onHoverOut } : {},
|
|
648
|
+
style: ({ pressed, hovered, focused }) => {
|
|
649
|
+
const base = {
|
|
650
|
+
width: CELL_SIZE,
|
|
651
|
+
height: CELL_SIZE,
|
|
652
|
+
alignItems: "center",
|
|
653
|
+
justifyContent: "center",
|
|
654
|
+
borderRadius: 999,
|
|
655
|
+
// perfect circle for endpoints/selected
|
|
656
|
+
position: "relative"
|
|
657
|
+
};
|
|
658
|
+
if (ctx.isUnavailable) {
|
|
659
|
+
return [base, { opacity: 0.28 }];
|
|
660
|
+
}
|
|
661
|
+
let backgroundColor;
|
|
662
|
+
let transform;
|
|
663
|
+
let borderWidth;
|
|
664
|
+
let borderColor;
|
|
665
|
+
if (isSelectedLike) {
|
|
666
|
+
backgroundColor = colors.semantic.interactive.primary;
|
|
667
|
+
if (pressed) {
|
|
668
|
+
backgroundColor = colors.semantic.interactive.primaryPressed;
|
|
669
|
+
} else if (hovered) {
|
|
670
|
+
backgroundColor = colors.semantic.interactive.primaryHover;
|
|
671
|
+
}
|
|
672
|
+
transform = [{ scale: pressed ? 0.94 : 1 }];
|
|
673
|
+
} else if (isRangeMiddle) {
|
|
674
|
+
backgroundColor = hovered ? colors.color.primary["200"] : "transparent";
|
|
675
|
+
transform = [{ scale: pressed ? 0.94 : 1 }];
|
|
676
|
+
} else {
|
|
677
|
+
if (pressed) {
|
|
678
|
+
backgroundColor = colors.color.primary["200"];
|
|
679
|
+
} else if (hovered) {
|
|
680
|
+
backgroundColor = colors.color.primary["100"];
|
|
681
|
+
} else {
|
|
682
|
+
backgroundColor = "transparent";
|
|
683
|
+
}
|
|
684
|
+
transform = [{ scale: pressed ? 0.94 : 1 }];
|
|
685
|
+
}
|
|
686
|
+
if ((ctx.isFocused || focused) && !isSelectedLike) {
|
|
687
|
+
borderWidth = 2;
|
|
688
|
+
borderColor = colors.semantic.interactive.primary;
|
|
689
|
+
}
|
|
690
|
+
const transition = {
|
|
691
|
+
transitionProperty: "background-color, transform, border-color, opacity",
|
|
692
|
+
transitionDuration: "140ms",
|
|
693
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
694
|
+
outlineStyle: "none"
|
|
695
|
+
};
|
|
696
|
+
return [
|
|
697
|
+
base,
|
|
698
|
+
transition,
|
|
699
|
+
{
|
|
700
|
+
backgroundColor,
|
|
701
|
+
...transform ? { transform } : {},
|
|
702
|
+
...borderWidth ? { borderWidth, borderColor } : {}
|
|
703
|
+
}
|
|
704
|
+
];
|
|
705
|
+
},
|
|
706
|
+
...{
|
|
707
|
+
dataSet: {
|
|
708
|
+
dayKey: `${ctx.date.year}-${ctx.date.month}-${ctx.date.day}`,
|
|
709
|
+
...dataState ? { state: dataState } : {}
|
|
710
|
+
}
|
|
711
|
+
},
|
|
712
|
+
children: renderDay ? renderDay(ctx) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
713
|
+
/* @__PURE__ */ jsx(
|
|
714
|
+
Text,
|
|
715
|
+
{
|
|
716
|
+
style: {
|
|
717
|
+
color: isSelectedLike ? colors.semantic.text.inverted : ctx.isOutsideMonth ? colors.semantic.text.muted : colors.semantic.text.default,
|
|
718
|
+
fontSize: 14,
|
|
719
|
+
fontWeight: ctx.isToday ? "600" : "400",
|
|
720
|
+
opacity: ctx.isOutsideMonth ? 0.55 : 1,
|
|
721
|
+
transitionProperty: "color",
|
|
722
|
+
transitionDuration: "140ms"
|
|
723
|
+
},
|
|
724
|
+
children: ctx.date.day
|
|
725
|
+
}
|
|
726
|
+
),
|
|
727
|
+
ctx.isToday ? /* @__PURE__ */ jsx(
|
|
728
|
+
View,
|
|
729
|
+
{
|
|
730
|
+
style: {
|
|
731
|
+
position: "absolute",
|
|
732
|
+
bottom: 5,
|
|
733
|
+
width: 4,
|
|
734
|
+
height: 4,
|
|
735
|
+
borderRadius: 999,
|
|
736
|
+
backgroundColor: isSelectedLike ? colors.semantic.text.inverted : colors.semantic.interactive.primary
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
) : null
|
|
740
|
+
] })
|
|
741
|
+
}
|
|
742
|
+
);
|
|
743
|
+
}, "DayCell");
|
|
744
|
+
var isInRange = /* @__PURE__ */ __name((date, range) => {
|
|
745
|
+
if (!range?.end) {
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
return date.compare(range.start) >= 0 && date.compare(range.end) <= 0;
|
|
749
|
+
}, "isInRange");
|
|
750
|
+
var buildContext = /* @__PURE__ */ __name((date, args) => {
|
|
751
|
+
const isOutsideMonth = date.month !== args.visibleMonth.month;
|
|
752
|
+
const isToday = date.compare(args.todayDate) === 0;
|
|
753
|
+
const dow = date.toDate("UTC").getUTCDay();
|
|
754
|
+
const isWeekend = args.weekendDays.includes(dow);
|
|
755
|
+
let isSelected = false;
|
|
756
|
+
let isRangeStart = false;
|
|
757
|
+
let isRangeEnd = false;
|
|
758
|
+
let inRange = false;
|
|
759
|
+
if (args.mode === "single") {
|
|
760
|
+
const v = args.value;
|
|
761
|
+
isSelected = !!v && v.compare(date) === 0;
|
|
762
|
+
} else if (args.mode === "range") {
|
|
763
|
+
const r = args.value;
|
|
764
|
+
if (r) {
|
|
765
|
+
isRangeStart = r.start.compare(date) === 0;
|
|
766
|
+
isRangeEnd = r.end !== null && r.end.compare(date) === 0;
|
|
767
|
+
inRange = isInRange(date, r);
|
|
768
|
+
}
|
|
769
|
+
} else {
|
|
770
|
+
const arr = args.value;
|
|
771
|
+
isSelected = arr.some((x) => x.compare(date) === 0);
|
|
772
|
+
}
|
|
773
|
+
return {
|
|
774
|
+
date,
|
|
775
|
+
isOutsideMonth,
|
|
776
|
+
isToday,
|
|
777
|
+
isSelected,
|
|
778
|
+
isRangeStart,
|
|
779
|
+
isRangeEnd,
|
|
780
|
+
isInRange: inRange,
|
|
781
|
+
isInPreviewRange: isInRange(date, args.previewRange ?? null),
|
|
782
|
+
isUnavailable: args.isUnavailable(date),
|
|
783
|
+
isFocused: args.focusedDate.compare(date) === 0,
|
|
784
|
+
isWeekend
|
|
785
|
+
};
|
|
786
|
+
}, "buildContext");
|
|
787
|
+
var ROW_KEYS = ["row-0", "row-1", "row-2", "row-3", "row-4", "row-5"];
|
|
788
|
+
var DayGrid = /* @__PURE__ */ __name((props) => {
|
|
789
|
+
const {
|
|
790
|
+
visibleMonth,
|
|
791
|
+
locale,
|
|
792
|
+
mode,
|
|
793
|
+
value,
|
|
794
|
+
previewRange,
|
|
795
|
+
focusedDate,
|
|
796
|
+
isUnavailable,
|
|
797
|
+
weekendDays,
|
|
798
|
+
firstDayOfWeek,
|
|
799
|
+
onDayPress,
|
|
800
|
+
onDayHover,
|
|
801
|
+
renderDay
|
|
802
|
+
} = props;
|
|
803
|
+
const colors = useThemeColors();
|
|
804
|
+
const fdow = firstDayOfWeek ?? getFirstDayOfWeek(locale);
|
|
805
|
+
const cells = useMemo(() => {
|
|
806
|
+
const start = startOfMonth(visibleMonth);
|
|
807
|
+
const startDow = start.toDate("UTC").getUTCDay();
|
|
808
|
+
const back = (startDow - fdow + 7) % 7;
|
|
809
|
+
const first = start.subtract({ days: back });
|
|
810
|
+
const total = 42;
|
|
811
|
+
return Array.from({ length: total }, (_, i) => first.add({ days: i }));
|
|
812
|
+
}, [visibleMonth, fdow]);
|
|
813
|
+
const weekdayNames = useMemo(() => formatWeekdayNames(locale), [locale]);
|
|
814
|
+
const todayDate = useMemo(() => today(getLocalTimeZone()), []);
|
|
815
|
+
const gridWidth = 7 * CELL_SIZE;
|
|
816
|
+
return /* @__PURE__ */ jsxs(View, { role: "grid", style: { width: gridWidth }, children: [
|
|
817
|
+
/* @__PURE__ */ jsx(View, { role: "row", style: { flexDirection: "row", marginBottom: 4 }, children: weekdayNames.map((name) => /* @__PURE__ */ jsx(
|
|
818
|
+
View,
|
|
819
|
+
{
|
|
820
|
+
role: "columnheader",
|
|
821
|
+
style: { width: CELL_SIZE, alignItems: "center", paddingVertical: 6 },
|
|
822
|
+
children: /* @__PURE__ */ jsx(
|
|
823
|
+
Text,
|
|
824
|
+
{
|
|
825
|
+
style: {
|
|
826
|
+
fontSize: 11,
|
|
827
|
+
fontWeight: "500",
|
|
828
|
+
letterSpacing: 0.6,
|
|
829
|
+
color: colors.semantic.text.muted,
|
|
830
|
+
textTransform: "uppercase"
|
|
831
|
+
},
|
|
832
|
+
children: name
|
|
833
|
+
}
|
|
834
|
+
)
|
|
835
|
+
},
|
|
836
|
+
name
|
|
837
|
+
)) }),
|
|
838
|
+
ROW_KEYS.map((rowKey, row) => /* @__PURE__ */ jsx(View, { role: "row", style: { flexDirection: "row" }, children: cells.slice(row * 7, row * 7 + 7).map((date) => {
|
|
839
|
+
const ctx = buildContext(date, {
|
|
840
|
+
visibleMonth,
|
|
841
|
+
mode,
|
|
842
|
+
value,
|
|
843
|
+
...previewRange !== void 0 ? { previewRange } : {},
|
|
844
|
+
focusedDate,
|
|
845
|
+
isUnavailable,
|
|
846
|
+
weekendDays,
|
|
847
|
+
todayDate
|
|
848
|
+
});
|
|
849
|
+
const isSelectedLike = ctx.isSelected || ctx.isRangeStart || ctx.isRangeEnd;
|
|
850
|
+
const isInsideRange = ctx.isInRange || ctx.isInPreviewRange;
|
|
851
|
+
const wrapperStyle = {
|
|
852
|
+
width: CELL_SIZE,
|
|
853
|
+
height: CELL_SIZE,
|
|
854
|
+
position: "relative"
|
|
855
|
+
};
|
|
856
|
+
const rangeFillTint = colors.color.primary["100"];
|
|
857
|
+
let rangeFillStyle = null;
|
|
858
|
+
if (ctx.isRangeStart && !ctx.isRangeEnd) {
|
|
859
|
+
rangeFillStyle = {
|
|
860
|
+
position: "absolute",
|
|
861
|
+
top: 0,
|
|
862
|
+
bottom: 0,
|
|
863
|
+
left: "50%",
|
|
864
|
+
right: 0,
|
|
865
|
+
backgroundColor: rangeFillTint
|
|
866
|
+
};
|
|
867
|
+
} else if (ctx.isRangeEnd && !ctx.isRangeStart) {
|
|
868
|
+
rangeFillStyle = {
|
|
869
|
+
position: "absolute",
|
|
870
|
+
top: 0,
|
|
871
|
+
bottom: 0,
|
|
872
|
+
left: 0,
|
|
873
|
+
right: "50%",
|
|
874
|
+
backgroundColor: rangeFillTint
|
|
875
|
+
};
|
|
876
|
+
} else if (isInsideRange && !isSelectedLike) {
|
|
877
|
+
rangeFillStyle = {
|
|
878
|
+
position: "absolute",
|
|
879
|
+
top: 0,
|
|
880
|
+
bottom: 0,
|
|
881
|
+
left: 0,
|
|
882
|
+
right: 0,
|
|
883
|
+
backgroundColor: rangeFillTint
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
const gridcellProps = {
|
|
887
|
+
role: "gridcell",
|
|
888
|
+
...isSelectedLike ? { "aria-selected": true } : {}
|
|
889
|
+
};
|
|
890
|
+
return /* @__PURE__ */ jsxs(
|
|
891
|
+
View,
|
|
892
|
+
{
|
|
893
|
+
...gridcellProps,
|
|
894
|
+
style: wrapperStyle,
|
|
895
|
+
children: [
|
|
896
|
+
rangeFillStyle ? /* @__PURE__ */ jsx(View, { style: rangeFillStyle }) : null,
|
|
897
|
+
/* @__PURE__ */ jsx(
|
|
898
|
+
DayCell,
|
|
899
|
+
{
|
|
900
|
+
ctx,
|
|
901
|
+
onPress: () => onDayPress(date),
|
|
902
|
+
...onDayHover ? {
|
|
903
|
+
onHoverIn: /* @__PURE__ */ __name(() => onDayHover(date), "onHoverIn"),
|
|
904
|
+
onHoverOut: /* @__PURE__ */ __name(() => onDayHover(null), "onHoverOut")
|
|
905
|
+
} : {},
|
|
906
|
+
...renderDay ? { renderDay } : {}
|
|
907
|
+
}
|
|
908
|
+
)
|
|
909
|
+
]
|
|
910
|
+
},
|
|
911
|
+
`${date.year}-${date.month}-${date.day}`
|
|
912
|
+
);
|
|
913
|
+
}) }, rowKey))
|
|
914
|
+
] });
|
|
915
|
+
}, "DayGrid");
|
|
916
|
+
var Footer = /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx(View, { style: { paddingTop: 12 }, children }), "Footer");
|
|
917
|
+
var ROW_KEYS2 = ["r0", "r1", "r2", "r3"];
|
|
918
|
+
var MonthGrid = /* @__PURE__ */ __name(({ visibleMonth, locale, availableWidth, onSelect }) => {
|
|
919
|
+
const colors = useThemeColors();
|
|
920
|
+
const names = formatMonthNames(locale);
|
|
921
|
+
const cellHeight = 56;
|
|
922
|
+
return /* @__PURE__ */ jsx(View, { style: { width: availableWidth, paddingVertical: 8 }, children: ROW_KEYS2.map((rowKey, row) => /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", marginBottom: 4 }, children: [0, 1, 2].map((col) => {
|
|
923
|
+
const idx = row * 3 + col;
|
|
924
|
+
const monthNumber = idx + 1;
|
|
925
|
+
const isCurrent = monthNumber === visibleMonth.month;
|
|
926
|
+
const name = names[idx] ?? "";
|
|
927
|
+
return /* @__PURE__ */ jsx(View, { style: { flex: 1, paddingHorizontal: 4 }, children: /* @__PURE__ */ jsx(
|
|
928
|
+
Pressable,
|
|
929
|
+
{
|
|
930
|
+
accessibilityRole: "button",
|
|
931
|
+
accessibilityLabel: name,
|
|
932
|
+
onPress: () => onSelect(monthNumber),
|
|
933
|
+
style: ({
|
|
934
|
+
pressed,
|
|
935
|
+
hovered,
|
|
936
|
+
focused
|
|
937
|
+
}) => {
|
|
938
|
+
const base = {
|
|
939
|
+
height: cellHeight,
|
|
940
|
+
alignItems: "center",
|
|
941
|
+
justifyContent: "center",
|
|
942
|
+
borderRadius: 10
|
|
943
|
+
};
|
|
944
|
+
const transition = {
|
|
945
|
+
transitionProperty: "background-color, transform, border-color",
|
|
946
|
+
transitionDuration: "140ms",
|
|
947
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
948
|
+
outlineStyle: "none"
|
|
949
|
+
};
|
|
950
|
+
let bg;
|
|
951
|
+
if (isCurrent) {
|
|
952
|
+
bg = pressed ? colors.semantic.interactive.primaryPressed : hovered ? colors.semantic.interactive.primaryHover : colors.semantic.interactive.primary;
|
|
953
|
+
} else if (pressed) {
|
|
954
|
+
bg = colors.color.primary["200"];
|
|
955
|
+
} else if (hovered) {
|
|
956
|
+
bg = colors.color.primary["100"];
|
|
957
|
+
} else {
|
|
958
|
+
bg = "transparent";
|
|
959
|
+
}
|
|
960
|
+
const border = focused && !isCurrent ? { borderWidth: 2, borderColor: colors.semantic.interactive.primary } : { borderWidth: 0 };
|
|
961
|
+
return [
|
|
962
|
+
base,
|
|
963
|
+
transition,
|
|
964
|
+
{ backgroundColor: bg, transform: [{ scale: pressed ? 0.96 : 1 }] },
|
|
965
|
+
border
|
|
966
|
+
];
|
|
967
|
+
},
|
|
968
|
+
children: /* @__PURE__ */ jsx(
|
|
969
|
+
Text,
|
|
970
|
+
{
|
|
971
|
+
style: {
|
|
972
|
+
color: isCurrent ? colors.semantic.text.inverted : colors.semantic.text.default,
|
|
973
|
+
fontSize: 14,
|
|
974
|
+
fontWeight: isCurrent ? "600" : "500"
|
|
975
|
+
},
|
|
976
|
+
children: name
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
}
|
|
980
|
+
) }, monthNumber);
|
|
981
|
+
}) }, rowKey)) });
|
|
982
|
+
}, "MonthGrid");
|
|
983
|
+
var ROW_KEYS3 = ["r0", "r1", "r2"];
|
|
984
|
+
var YearGrid = /* @__PURE__ */ __name(({ visibleMonth, availableWidth, onSelect }) => {
|
|
985
|
+
const colors = useThemeColors();
|
|
986
|
+
const decadeStart = visibleMonth.year - visibleMonth.year % 10;
|
|
987
|
+
const years = Array.from({ length: 12 }, (_, i) => decadeStart + i - 1);
|
|
988
|
+
const cellHeight = 60;
|
|
989
|
+
return /* @__PURE__ */ jsx(View, { style: { width: availableWidth, paddingVertical: 8 }, children: ROW_KEYS3.map((rowKey, row) => /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", marginBottom: 4 }, children: [0, 1, 2, 3].map((col) => {
|
|
990
|
+
const year = years[row * 4 + col];
|
|
991
|
+
if (year === void 0) {
|
|
992
|
+
return null;
|
|
993
|
+
}
|
|
994
|
+
const isCurrent = year === visibleMonth.year;
|
|
995
|
+
const isAdjacentDecade = year < decadeStart || year >= decadeStart + 10;
|
|
996
|
+
return /* @__PURE__ */ jsx(View, { style: { flex: 1, paddingHorizontal: 4 }, children: /* @__PURE__ */ jsx(
|
|
997
|
+
Pressable,
|
|
998
|
+
{
|
|
999
|
+
accessibilityRole: "button",
|
|
1000
|
+
accessibilityLabel: String(year),
|
|
1001
|
+
onPress: () => onSelect(year),
|
|
1002
|
+
style: ({
|
|
1003
|
+
pressed,
|
|
1004
|
+
hovered,
|
|
1005
|
+
focused
|
|
1006
|
+
}) => {
|
|
1007
|
+
const base = {
|
|
1008
|
+
height: cellHeight,
|
|
1009
|
+
alignItems: "center",
|
|
1010
|
+
justifyContent: "center",
|
|
1011
|
+
borderRadius: 10
|
|
1012
|
+
};
|
|
1013
|
+
const transition = {
|
|
1014
|
+
transitionProperty: "background-color, transform, border-color",
|
|
1015
|
+
transitionDuration: "140ms",
|
|
1016
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
1017
|
+
outlineStyle: "none"
|
|
1018
|
+
};
|
|
1019
|
+
let bg;
|
|
1020
|
+
if (isCurrent) {
|
|
1021
|
+
bg = pressed ? colors.semantic.interactive.primaryPressed : hovered ? colors.semantic.interactive.primaryHover : colors.semantic.interactive.primary;
|
|
1022
|
+
} else if (pressed) {
|
|
1023
|
+
bg = colors.color.primary["200"];
|
|
1024
|
+
} else if (hovered) {
|
|
1025
|
+
bg = colors.color.primary["100"];
|
|
1026
|
+
} else {
|
|
1027
|
+
bg = "transparent";
|
|
1028
|
+
}
|
|
1029
|
+
const border = focused && !isCurrent ? { borderWidth: 2, borderColor: colors.semantic.interactive.primary } : { borderWidth: 0 };
|
|
1030
|
+
return [
|
|
1031
|
+
base,
|
|
1032
|
+
transition,
|
|
1033
|
+
{ backgroundColor: bg, transform: [{ scale: pressed ? 0.96 : 1 }] },
|
|
1034
|
+
border
|
|
1035
|
+
];
|
|
1036
|
+
},
|
|
1037
|
+
children: /* @__PURE__ */ jsx(
|
|
1038
|
+
Text,
|
|
1039
|
+
{
|
|
1040
|
+
style: {
|
|
1041
|
+
color: isCurrent ? colors.semantic.text.inverted : colors.semantic.text.default,
|
|
1042
|
+
fontSize: 14,
|
|
1043
|
+
fontWeight: isCurrent ? "600" : "500",
|
|
1044
|
+
opacity: isAdjacentDecade ? 0.45 : 1
|
|
1045
|
+
},
|
|
1046
|
+
children: year
|
|
1047
|
+
}
|
|
1048
|
+
)
|
|
1049
|
+
}
|
|
1050
|
+
) }, year);
|
|
1051
|
+
}) }, rowKey)) });
|
|
1052
|
+
}, "YearGrid");
|
|
1053
|
+
var GRID_WIDTH = 7 * CELL_SIZE;
|
|
1054
|
+
var MONTH_GAP = 16;
|
|
1055
|
+
var ARROW_AREA = 32 + 8;
|
|
1056
|
+
var SURFACE_PADDING = 16;
|
|
1057
|
+
var SURFACE_BORDER = 1;
|
|
1058
|
+
var requiredOuterWidth = /* @__PURE__ */ __name((n) => 2 * (ARROW_AREA + SURFACE_PADDING + SURFACE_BORDER) + n * GRID_WIDTH + (n - 1) * MONTH_GAP, "requiredOuterWidth");
|
|
1059
|
+
var focusDayCell = /* @__PURE__ */ __name((root, date, force) => {
|
|
1060
|
+
if (!root) {
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
if (!force && !root.contains(document.activeElement)) {
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
const sel = `[data-day-key="${date.year}-${date.month}-${date.day}"]`;
|
|
1067
|
+
const cell = root.querySelector(sel);
|
|
1068
|
+
const isDisabled = cell?.disabled === true;
|
|
1069
|
+
if (cell && !isDisabled) {
|
|
1070
|
+
if (cell !== document.activeElement) {
|
|
1071
|
+
cell.focus();
|
|
1072
|
+
}
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
if (force && !root.contains(document.activeElement)) {
|
|
1076
|
+
root.focus();
|
|
1077
|
+
}
|
|
1078
|
+
}, "focusDayCell");
|
|
1079
|
+
var FadeIn = /* @__PURE__ */ __name(({ children }) => {
|
|
1080
|
+
const [mounted, setMounted] = useState(false);
|
|
1081
|
+
useEffect(() => {
|
|
1082
|
+
const id = requestAnimationFrame(() => setMounted(true));
|
|
1083
|
+
return () => cancelAnimationFrame(id);
|
|
1084
|
+
}, []);
|
|
1085
|
+
return /* @__PURE__ */ jsx(
|
|
1086
|
+
View,
|
|
1087
|
+
{
|
|
1088
|
+
style: {
|
|
1089
|
+
opacity: mounted ? 1 : 0,
|
|
1090
|
+
transform: [{ translateY: mounted ? 0 : 4 }],
|
|
1091
|
+
transitionProperty: "opacity, transform",
|
|
1092
|
+
transitionDuration: "220ms",
|
|
1093
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)"
|
|
1094
|
+
},
|
|
1095
|
+
children
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1098
|
+
}, "FadeIn");
|
|
1099
|
+
var resolveYearRange = /* @__PURE__ */ __name((input, minValue, maxValue, focusedYear) => {
|
|
1100
|
+
if (input) {
|
|
1101
|
+
return input;
|
|
1102
|
+
}
|
|
1103
|
+
if (minValue && maxValue) {
|
|
1104
|
+
return [minValue.year, maxValue.year];
|
|
1105
|
+
}
|
|
1106
|
+
if (minValue) {
|
|
1107
|
+
return [minValue.year, Math.max(minValue.year, focusedYear + 10)];
|
|
1108
|
+
}
|
|
1109
|
+
if (maxValue) {
|
|
1110
|
+
return [Math.min(maxValue.year, focusedYear - 100), maxValue.year];
|
|
1111
|
+
}
|
|
1112
|
+
return [focusedYear - 100, focusedYear + 10];
|
|
1113
|
+
}, "resolveYearRange");
|
|
1114
|
+
var pickVisibleMonths = /* @__PURE__ */ __name((input, measuredWidth) => {
|
|
1115
|
+
const target = typeof input === "number" ? input : 2;
|
|
1116
|
+
if (measuredWidth == null || measuredWidth === 0) {
|
|
1117
|
+
return typeof input === "number" ? input : 1;
|
|
1118
|
+
}
|
|
1119
|
+
for (let n = target; n >= 1; n--) {
|
|
1120
|
+
if (measuredWidth >= requiredOuterWidth(n)) {
|
|
1121
|
+
return n;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return 1;
|
|
1125
|
+
}, "pickVisibleMonths");
|
|
1126
|
+
var CalendarRoot = /* @__PURE__ */ __name((props) => {
|
|
1127
|
+
const [containerWidth, setContainerWidth] = useState(null);
|
|
1128
|
+
const onLayout = useCallback((e) => {
|
|
1129
|
+
const next = e.nativeEvent.layout.width;
|
|
1130
|
+
setContainerWidth((prev) => prev === next ? prev : next);
|
|
1131
|
+
}, []);
|
|
1132
|
+
return /* @__PURE__ */ jsx(View, { onLayout, style: { width: "100%" }, children: /* @__PURE__ */ jsx(CalendarSurface, { containerWidth: containerWidth ?? 0, ...props }) });
|
|
1133
|
+
}, "CalendarRoot");
|
|
1134
|
+
var CalendarSurface = /* @__PURE__ */ __name((props) => {
|
|
1135
|
+
const providerLocale = useLocale();
|
|
1136
|
+
const locale = props.locale ?? providerLocale;
|
|
1137
|
+
if ((props.mode ?? "single") === "range") {
|
|
1138
|
+
return /* @__PURE__ */ jsx(
|
|
1139
|
+
RangeCalendar,
|
|
1140
|
+
{
|
|
1141
|
+
...props,
|
|
1142
|
+
locale
|
|
1143
|
+
}
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
return /* @__PURE__ */ jsx(
|
|
1147
|
+
SingleOrMultiCalendar,
|
|
1148
|
+
{
|
|
1149
|
+
...props,
|
|
1150
|
+
locale
|
|
1151
|
+
}
|
|
1152
|
+
);
|
|
1153
|
+
}, "CalendarSurface");
|
|
1154
|
+
var surfaceMetrics = /* @__PURE__ */ __name((visibleMonths) => {
|
|
1155
|
+
const innerWidth = 2 * ARROW_AREA + visibleMonths * GRID_WIDTH + (visibleMonths - 1) * MONTH_GAP;
|
|
1156
|
+
return {
|
|
1157
|
+
innerWidth,
|
|
1158
|
+
// Body grids row width (excludes arrow area)
|
|
1159
|
+
gridsRowWidth: visibleMonths * GRID_WIDTH + (visibleMonths - 1) * MONTH_GAP
|
|
1160
|
+
};
|
|
1161
|
+
}, "surfaceMetrics");
|
|
1162
|
+
var SingleOrMultiCalendar = /* @__PURE__ */ __name((props) => {
|
|
1163
|
+
const { locale, renderDay, containerWidth } = props;
|
|
1164
|
+
const colors = useThemeColors();
|
|
1165
|
+
const firstDayOfWeek = props.firstDayOfWeek ?? getFirstDayOfWeek(locale);
|
|
1166
|
+
const weekendDays = props.weekendDays ?? getWeekendDays(locale);
|
|
1167
|
+
const visibleMonths = pickVisibleMonths(props.visibleMonths, containerWidth);
|
|
1168
|
+
const { innerWidth, gridsRowWidth } = surfaceMetrics(visibleMonths);
|
|
1169
|
+
const containerRef = useRef(null);
|
|
1170
|
+
const state = useCalendarState({
|
|
1171
|
+
...props.mode !== void 0 ? { mode: props.mode } : {},
|
|
1172
|
+
locale,
|
|
1173
|
+
...props.value !== void 0 ? { value: props.value } : {},
|
|
1174
|
+
...props.defaultValue !== void 0 ? { defaultValue: props.defaultValue } : {},
|
|
1175
|
+
...props.onChange !== void 0 ? { onChange: props.onChange } : {},
|
|
1176
|
+
...props.view !== void 0 ? { view: props.view } : {},
|
|
1177
|
+
...props.defaultView !== void 0 ? { defaultView: props.defaultView } : {},
|
|
1178
|
+
...props.onViewChange !== void 0 ? { onViewChange: props.onViewChange } : {},
|
|
1179
|
+
...props.minValue !== void 0 ? { minValue: props.minValue } : {},
|
|
1180
|
+
...props.maxValue !== void 0 ? { maxValue: props.maxValue } : {},
|
|
1181
|
+
...props.isDateUnavailable !== void 0 ? { isDateUnavailable: props.isDateUnavailable } : {}
|
|
1182
|
+
});
|
|
1183
|
+
const [anchor, setAnchor] = useState(state.focusedDate);
|
|
1184
|
+
const anchorRef = useRef(anchor);
|
|
1185
|
+
useEffect(() => {
|
|
1186
|
+
anchorRef.current = anchor;
|
|
1187
|
+
}, [anchor]);
|
|
1188
|
+
useEffect(() => {
|
|
1189
|
+
const start = anchorRef.current;
|
|
1190
|
+
const end = start.add({ months: visibleMonths });
|
|
1191
|
+
if (state.focusedDate.compare(start) < 0 || state.focusedDate.compare(end) >= 0) {
|
|
1192
|
+
setAnchor(state.focusedDate);
|
|
1193
|
+
}
|
|
1194
|
+
}, [state.focusedDate, visibleMonths]);
|
|
1195
|
+
const keyboardNavRef = useRef(false);
|
|
1196
|
+
useLayoutEffect(() => {
|
|
1197
|
+
focusDayCell(containerRef.current, state.focusedDate, keyboardNavRef.current);
|
|
1198
|
+
keyboardNavRef.current = false;
|
|
1199
|
+
}, [state.focusedDate, state.value]);
|
|
1200
|
+
const months = useMemo(
|
|
1201
|
+
() => Array.from({ length: visibleMonths }, (_, i) => anchor.add({ months: i })),
|
|
1202
|
+
[anchor, visibleMonths]
|
|
1203
|
+
);
|
|
1204
|
+
const keyboard = useCalendarKeyboard({
|
|
1205
|
+
focusedDate: state.focusedDate,
|
|
1206
|
+
moveFocus: /* @__PURE__ */ __name((delta) => {
|
|
1207
|
+
state.moveFocus(delta);
|
|
1208
|
+
if (delta.months || delta.years) {
|
|
1209
|
+
setAnchor((a) => {
|
|
1210
|
+
let next = a;
|
|
1211
|
+
if (delta.months) {
|
|
1212
|
+
next = next.add({ months: delta.months });
|
|
1213
|
+
}
|
|
1214
|
+
if (delta.years) {
|
|
1215
|
+
next = next.add({ years: delta.years });
|
|
1216
|
+
}
|
|
1217
|
+
return next;
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
}, "moveFocus"),
|
|
1221
|
+
selectDate: state.selectDate,
|
|
1222
|
+
setView: state.setView,
|
|
1223
|
+
view: state.view,
|
|
1224
|
+
firstDayOfWeek
|
|
1225
|
+
});
|
|
1226
|
+
const onPrev = /* @__PURE__ */ __name(() => {
|
|
1227
|
+
if (state.view === "year") {
|
|
1228
|
+
setAnchor((a) => a.add({ years: -10 }));
|
|
1229
|
+
} else if (state.view === "month") {
|
|
1230
|
+
setAnchor((a) => a.add({ years: -1 }));
|
|
1231
|
+
} else {
|
|
1232
|
+
setAnchor((a) => a.add({ months: -1 }));
|
|
1233
|
+
}
|
|
1234
|
+
}, "onPrev");
|
|
1235
|
+
const onNext = /* @__PURE__ */ __name(() => {
|
|
1236
|
+
if (state.view === "year") {
|
|
1237
|
+
setAnchor((a) => a.add({ years: 10 }));
|
|
1238
|
+
} else if (state.view === "month") {
|
|
1239
|
+
setAnchor((a) => a.add({ years: 1 }));
|
|
1240
|
+
} else {
|
|
1241
|
+
setAnchor((a) => a.add({ months: 1 }));
|
|
1242
|
+
}
|
|
1243
|
+
}, "onNext");
|
|
1244
|
+
const onTitlePress = /* @__PURE__ */ __name(() => state.setView(state.view === "day" ? "month" : state.view === "month" ? "year" : "day"), "onTitlePress");
|
|
1245
|
+
return /* @__PURE__ */ jsxs(
|
|
1246
|
+
View,
|
|
1247
|
+
{
|
|
1248
|
+
ref: (node) => {
|
|
1249
|
+
containerRef.current = node;
|
|
1250
|
+
if (typeof props.ref === "function") {
|
|
1251
|
+
props.ref(node);
|
|
1252
|
+
} else if (props.ref) {
|
|
1253
|
+
props.ref.current = node;
|
|
1254
|
+
}
|
|
1255
|
+
},
|
|
1256
|
+
...props.testID !== void 0 ? { testID: props.testID } : {},
|
|
1257
|
+
onKeyDown: (e) => {
|
|
1258
|
+
keyboardNavRef.current = true;
|
|
1259
|
+
keyboard.onKeyDown(e);
|
|
1260
|
+
},
|
|
1261
|
+
tabIndex: 0,
|
|
1262
|
+
style: {
|
|
1263
|
+
padding: SURFACE_PADDING,
|
|
1264
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
1265
|
+
borderRadius: 16,
|
|
1266
|
+
borderWidth: SURFACE_BORDER,
|
|
1267
|
+
borderColor: colors.semantic.border.default,
|
|
1268
|
+
shadowColor: "#000",
|
|
1269
|
+
shadowOpacity: 0.04,
|
|
1270
|
+
shadowRadius: 12,
|
|
1271
|
+
shadowOffset: { width: 0, height: 4 },
|
|
1272
|
+
width: innerWidth + 2 * SURFACE_PADDING + 2 * SURFACE_BORDER,
|
|
1273
|
+
maxWidth: "100%",
|
|
1274
|
+
alignSelf: "center"
|
|
1275
|
+
},
|
|
1276
|
+
children: [
|
|
1277
|
+
/* @__PURE__ */ jsx(
|
|
1278
|
+
Caption,
|
|
1279
|
+
{
|
|
1280
|
+
months,
|
|
1281
|
+
locale,
|
|
1282
|
+
view: state.view,
|
|
1283
|
+
caption: props.caption ?? "title",
|
|
1284
|
+
gridWidth: GRID_WIDTH,
|
|
1285
|
+
monthGap: MONTH_GAP,
|
|
1286
|
+
yearRange: resolveYearRange(props.yearRange, props.minValue, props.maxValue, anchor.year),
|
|
1287
|
+
onPrev,
|
|
1288
|
+
onNext,
|
|
1289
|
+
onTitlePress,
|
|
1290
|
+
onSetMonth: (slot, m) => {
|
|
1291
|
+
const picked = (months[slot] ?? anchor).set({ month: m, day: 1 });
|
|
1292
|
+
setAnchor(picked.subtract({ months: slot }));
|
|
1293
|
+
},
|
|
1294
|
+
onSetYear: (slot, y) => {
|
|
1295
|
+
const picked = (months[slot] ?? anchor).set({ year: y, day: 1 });
|
|
1296
|
+
setAnchor(picked.subtract({ months: slot }));
|
|
1297
|
+
},
|
|
1298
|
+
children: props.children
|
|
1299
|
+
}
|
|
1300
|
+
),
|
|
1301
|
+
/* @__PURE__ */ jsxs(FadeIn, { children: [
|
|
1302
|
+
state.view === "day" && /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", gap: MONTH_GAP, alignSelf: "center", width: gridsRowWidth }, children: months.map((m) => /* @__PURE__ */ jsx(
|
|
1303
|
+
DayGrid,
|
|
1304
|
+
{
|
|
1305
|
+
visibleMonth: m,
|
|
1306
|
+
locale,
|
|
1307
|
+
mode: props.mode ?? "single",
|
|
1308
|
+
value: state.value,
|
|
1309
|
+
focusedDate: state.focusedDate,
|
|
1310
|
+
isUnavailable: state.isUnavailable,
|
|
1311
|
+
weekendDays,
|
|
1312
|
+
firstDayOfWeek,
|
|
1313
|
+
onDayPress: (date) => state.selectDate(date, "click"),
|
|
1314
|
+
...renderDay ? { renderDay } : {}
|
|
1315
|
+
},
|
|
1316
|
+
`${m.year}-${m.month}`
|
|
1317
|
+
)) }),
|
|
1318
|
+
state.view === "month" && /* @__PURE__ */ jsx(View, { style: { alignItems: "center" }, children: /* @__PURE__ */ jsx(
|
|
1319
|
+
MonthGrid,
|
|
1320
|
+
{
|
|
1321
|
+
visibleMonth: anchor,
|
|
1322
|
+
locale,
|
|
1323
|
+
availableWidth: gridsRowWidth,
|
|
1324
|
+
onSelect: (month) => {
|
|
1325
|
+
setAnchor(new CalendarDate(anchor.year, month, 1));
|
|
1326
|
+
state.setView("day");
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
) }),
|
|
1330
|
+
state.view === "year" && /* @__PURE__ */ jsx(View, { style: { alignItems: "center" }, children: /* @__PURE__ */ jsx(
|
|
1331
|
+
YearGrid,
|
|
1332
|
+
{
|
|
1333
|
+
visibleMonth: anchor,
|
|
1334
|
+
availableWidth: gridsRowWidth,
|
|
1335
|
+
onSelect: (year) => {
|
|
1336
|
+
setAnchor(new CalendarDate(year, anchor.month, 1));
|
|
1337
|
+
state.setView("month");
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
) }),
|
|
1341
|
+
props.children && (props.caption ?? "title") !== "custom" ? /* @__PURE__ */ jsx(Footer, { children: props.children }) : null
|
|
1342
|
+
] }, `smc-${state.view}`)
|
|
1343
|
+
]
|
|
1344
|
+
}
|
|
1345
|
+
);
|
|
1346
|
+
}, "SingleOrMultiCalendar");
|
|
1347
|
+
var RangeCalendar = /* @__PURE__ */ __name((props) => {
|
|
1348
|
+
const { locale, renderDay, containerWidth } = props;
|
|
1349
|
+
const colors = useThemeColors();
|
|
1350
|
+
const firstDayOfWeek = props.firstDayOfWeek ?? getFirstDayOfWeek(locale);
|
|
1351
|
+
const weekendDays = props.weekendDays ?? getWeekendDays(locale);
|
|
1352
|
+
const visibleMonths = pickVisibleMonths(props.visibleMonths, containerWidth);
|
|
1353
|
+
const { innerWidth, gridsRowWidth } = surfaceMetrics(visibleMonths);
|
|
1354
|
+
const containerRef = useRef(null);
|
|
1355
|
+
const range = useRangeState({
|
|
1356
|
+
...props.value !== void 0 ? { value: props.value } : {},
|
|
1357
|
+
...props.defaultValue !== void 0 ? { defaultValue: props.defaultValue } : {},
|
|
1358
|
+
...props.onChange !== void 0 ? { onChange: props.onChange } : {},
|
|
1359
|
+
...props.minValue !== void 0 ? { minValue: props.minValue } : {},
|
|
1360
|
+
...props.maxValue !== void 0 ? { maxValue: props.maxValue } : {},
|
|
1361
|
+
...props.isDateUnavailable !== void 0 ? { isDateUnavailable: props.isDateUnavailable } : {},
|
|
1362
|
+
...props.minNights !== void 0 ? { minNights: props.minNights } : {},
|
|
1363
|
+
...props.maxNights !== void 0 ? { maxNights: props.maxNights } : {}
|
|
1364
|
+
});
|
|
1365
|
+
const initialFocus2 = range.value?.start ?? today(getLocalTimeZone());
|
|
1366
|
+
const [focusedDate, setFocusedDate] = useState(initialFocus2);
|
|
1367
|
+
const keyboardNavRef = useRef(false);
|
|
1368
|
+
useLayoutEffect(() => {
|
|
1369
|
+
focusDayCell(containerRef.current, focusedDate, keyboardNavRef.current);
|
|
1370
|
+
keyboardNavRef.current = false;
|
|
1371
|
+
}, [focusedDate, range.value]);
|
|
1372
|
+
const [anchor, setAnchor] = useState(initialFocus2);
|
|
1373
|
+
const [internalView, setInternalView] = useState(props.defaultView ?? "day");
|
|
1374
|
+
const isViewControlled = props.view !== void 0;
|
|
1375
|
+
const view = isViewControlled ? props.view : internalView;
|
|
1376
|
+
const setView = useCallback(
|
|
1377
|
+
(next) => {
|
|
1378
|
+
if (!isViewControlled) {
|
|
1379
|
+
setInternalView(next);
|
|
1380
|
+
}
|
|
1381
|
+
props.onViewChange?.(next);
|
|
1382
|
+
},
|
|
1383
|
+
[isViewControlled, props.onViewChange]
|
|
1384
|
+
);
|
|
1385
|
+
const months = useMemo(
|
|
1386
|
+
() => Array.from({ length: visibleMonths }, (_, i) => anchor.add({ months: i })),
|
|
1387
|
+
[anchor, visibleMonths]
|
|
1388
|
+
);
|
|
1389
|
+
const keyboard = useCalendarKeyboard({
|
|
1390
|
+
focusedDate,
|
|
1391
|
+
moveFocus: /* @__PURE__ */ __name((delta) => {
|
|
1392
|
+
setFocusedDate((f) => {
|
|
1393
|
+
let next = f;
|
|
1394
|
+
if (delta.days) {
|
|
1395
|
+
next = next.add({ days: delta.days });
|
|
1396
|
+
}
|
|
1397
|
+
if (delta.weeks) {
|
|
1398
|
+
next = next.add({ weeks: delta.weeks });
|
|
1399
|
+
}
|
|
1400
|
+
if (delta.months) {
|
|
1401
|
+
next = next.add({ months: delta.months });
|
|
1402
|
+
}
|
|
1403
|
+
if (delta.years) {
|
|
1404
|
+
next = next.add({ years: delta.years });
|
|
1405
|
+
}
|
|
1406
|
+
return next;
|
|
1407
|
+
});
|
|
1408
|
+
if (delta.months || delta.years) {
|
|
1409
|
+
setAnchor((a) => {
|
|
1410
|
+
let next = a;
|
|
1411
|
+
if (delta.months) {
|
|
1412
|
+
next = next.add({ months: delta.months });
|
|
1413
|
+
}
|
|
1414
|
+
if (delta.years) {
|
|
1415
|
+
next = next.add({ years: delta.years });
|
|
1416
|
+
}
|
|
1417
|
+
return next;
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
}, "moveFocus"),
|
|
1421
|
+
selectDate: /* @__PURE__ */ __name((date) => range.selectDate(date, "keyboard"), "selectDate"),
|
|
1422
|
+
setView,
|
|
1423
|
+
view,
|
|
1424
|
+
firstDayOfWeek
|
|
1425
|
+
});
|
|
1426
|
+
const onPrev = /* @__PURE__ */ __name(() => {
|
|
1427
|
+
if (view === "year") {
|
|
1428
|
+
setAnchor((a) => a.add({ years: -10 }));
|
|
1429
|
+
} else if (view === "month") {
|
|
1430
|
+
setAnchor((a) => a.add({ years: -1 }));
|
|
1431
|
+
} else {
|
|
1432
|
+
setAnchor((a) => a.add({ months: -1 }));
|
|
1433
|
+
}
|
|
1434
|
+
}, "onPrev");
|
|
1435
|
+
const onNext = /* @__PURE__ */ __name(() => {
|
|
1436
|
+
if (view === "year") {
|
|
1437
|
+
setAnchor((a) => a.add({ years: 10 }));
|
|
1438
|
+
} else if (view === "month") {
|
|
1439
|
+
setAnchor((a) => a.add({ years: 1 }));
|
|
1440
|
+
} else {
|
|
1441
|
+
setAnchor((a) => a.add({ months: 1 }));
|
|
1442
|
+
}
|
|
1443
|
+
}, "onNext");
|
|
1444
|
+
const [drilldownSlot, setDrilldownSlot] = useState(0);
|
|
1445
|
+
const onTitlePress = /* @__PURE__ */ __name((clicked) => {
|
|
1446
|
+
const slot = months.findIndex((m) => m.year === clicked.year && m.month === clicked.month);
|
|
1447
|
+
setDrilldownSlot(slot >= 0 ? slot : 0);
|
|
1448
|
+
if (clicked.compare(anchor) !== 0) {
|
|
1449
|
+
setAnchor(clicked);
|
|
1450
|
+
}
|
|
1451
|
+
setView(view === "day" ? "month" : view === "month" ? "year" : "day");
|
|
1452
|
+
}, "onTitlePress");
|
|
1453
|
+
return /* @__PURE__ */ jsxs(
|
|
1454
|
+
View,
|
|
1455
|
+
{
|
|
1456
|
+
ref: (node) => {
|
|
1457
|
+
containerRef.current = node;
|
|
1458
|
+
if (typeof props.ref === "function") {
|
|
1459
|
+
props.ref(node);
|
|
1460
|
+
} else if (props.ref) {
|
|
1461
|
+
props.ref.current = node;
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
...props.testID !== void 0 ? { testID: props.testID } : {},
|
|
1465
|
+
onKeyDown: (e) => {
|
|
1466
|
+
keyboardNavRef.current = true;
|
|
1467
|
+
keyboard.onKeyDown(e);
|
|
1468
|
+
},
|
|
1469
|
+
tabIndex: 0,
|
|
1470
|
+
style: {
|
|
1471
|
+
padding: SURFACE_PADDING,
|
|
1472
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
1473
|
+
borderRadius: 16,
|
|
1474
|
+
borderWidth: SURFACE_BORDER,
|
|
1475
|
+
borderColor: colors.semantic.border.default,
|
|
1476
|
+
shadowColor: "#000",
|
|
1477
|
+
shadowOpacity: 0.04,
|
|
1478
|
+
shadowRadius: 12,
|
|
1479
|
+
shadowOffset: { width: 0, height: 4 },
|
|
1480
|
+
width: innerWidth + 2 * SURFACE_PADDING + 2 * SURFACE_BORDER,
|
|
1481
|
+
maxWidth: "100%",
|
|
1482
|
+
alignSelf: "center"
|
|
1483
|
+
},
|
|
1484
|
+
children: [
|
|
1485
|
+
/* @__PURE__ */ jsx(
|
|
1486
|
+
Caption,
|
|
1487
|
+
{
|
|
1488
|
+
months,
|
|
1489
|
+
locale,
|
|
1490
|
+
view,
|
|
1491
|
+
caption: props.caption ?? "title",
|
|
1492
|
+
gridWidth: GRID_WIDTH,
|
|
1493
|
+
monthGap: MONTH_GAP,
|
|
1494
|
+
yearRange: resolveYearRange(props.yearRange, props.minValue, props.maxValue, anchor.year),
|
|
1495
|
+
onPrev,
|
|
1496
|
+
onNext,
|
|
1497
|
+
onTitlePress,
|
|
1498
|
+
onSetMonth: (slot, m) => {
|
|
1499
|
+
const picked = (months[slot] ?? anchor).set({ month: m, day: 1 });
|
|
1500
|
+
setAnchor(picked.subtract({ months: slot }));
|
|
1501
|
+
},
|
|
1502
|
+
onSetYear: (slot, y) => {
|
|
1503
|
+
const picked = (months[slot] ?? anchor).set({ year: y, day: 1 });
|
|
1504
|
+
setAnchor(picked.subtract({ months: slot }));
|
|
1505
|
+
},
|
|
1506
|
+
children: props.children
|
|
1507
|
+
}
|
|
1508
|
+
),
|
|
1509
|
+
/* @__PURE__ */ jsxs(FadeIn, { children: [
|
|
1510
|
+
view === "day" && /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", gap: MONTH_GAP, alignSelf: "center", width: gridsRowWidth }, children: months.map((m) => /* @__PURE__ */ jsx(
|
|
1511
|
+
DayGrid,
|
|
1512
|
+
{
|
|
1513
|
+
visibleMonth: m,
|
|
1514
|
+
locale,
|
|
1515
|
+
mode: "range",
|
|
1516
|
+
value: range.value,
|
|
1517
|
+
previewRange: range.previewRange,
|
|
1518
|
+
focusedDate,
|
|
1519
|
+
isUnavailable: range.isUnavailable,
|
|
1520
|
+
weekendDays,
|
|
1521
|
+
firstDayOfWeek,
|
|
1522
|
+
onDayPress: (date) => range.selectDate(date),
|
|
1523
|
+
onDayHover: (date) => range.setHoveredDate(date),
|
|
1524
|
+
...renderDay ? { renderDay } : {}
|
|
1525
|
+
},
|
|
1526
|
+
`${m.year}-${m.month}`
|
|
1527
|
+
)) }),
|
|
1528
|
+
view === "month" && /* @__PURE__ */ jsx(View, { style: { alignItems: "center" }, children: /* @__PURE__ */ jsx(
|
|
1529
|
+
MonthGrid,
|
|
1530
|
+
{
|
|
1531
|
+
visibleMonth: anchor,
|
|
1532
|
+
locale,
|
|
1533
|
+
availableWidth: gridsRowWidth,
|
|
1534
|
+
onSelect: (month) => {
|
|
1535
|
+
const picked = new CalendarDate(anchor.year, month, 1);
|
|
1536
|
+
setAnchor(picked.subtract({ months: drilldownSlot }));
|
|
1537
|
+
setView("day");
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
) }),
|
|
1541
|
+
view === "year" && /* @__PURE__ */ jsx(View, { style: { alignItems: "center" }, children: /* @__PURE__ */ jsx(
|
|
1542
|
+
YearGrid,
|
|
1543
|
+
{
|
|
1544
|
+
visibleMonth: anchor,
|
|
1545
|
+
availableWidth: gridsRowWidth,
|
|
1546
|
+
onSelect: (year) => {
|
|
1547
|
+
const picked = new CalendarDate(year, anchor.month, 1);
|
|
1548
|
+
setAnchor(picked.subtract({ months: drilldownSlot }));
|
|
1549
|
+
setView("month");
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
) }),
|
|
1553
|
+
props.children && (props.caption ?? "title") !== "custom" ? /* @__PURE__ */ jsx(Footer, { children: props.children }) : null
|
|
1554
|
+
] }, `range-${view}`)
|
|
1555
|
+
]
|
|
1556
|
+
}
|
|
1557
|
+
);
|
|
1558
|
+
}, "RangeCalendar");
|
|
1559
|
+
var CalendarCaption = /* @__PURE__ */ __name(({ children }) => /* @__PURE__ */ jsx(Fragment, { children }), "CalendarCaption");
|
|
1560
|
+
CalendarCaption.displayName = "CalendarCaption";
|
|
1561
|
+
var Calendar = CalendarRoot;
|
|
1562
|
+
Calendar.Caption = CalendarCaption;
|
|
1563
|
+
|
|
1564
|
+
export { Calendar, LocaleProvider, detectLocale, useCalendarCaption, useLocale };
|
|
1565
|
+
//# sourceMappingURL=chunk-X7APG7G2.js.map
|
|
1566
|
+
//# sourceMappingURL=chunk-X7APG7G2.js.map
|