@astryx-vue/core 0.21.0 → 0.23.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/AlertDialog/index.js +1 -1
- package/dist/{AlertDialog-0UUojm_Q.js → AlertDialog-DXOTr1D7.js} +4 -4
- package/dist/AppShell/index.d.ts +1 -1
- package/dist/AppShell/index.js +1 -1
- package/dist/{AppShell-6rvfUu8p.js → AppShell-Cmu6bMY6.js} +76 -21
- package/dist/Avatar/index.js +1 -1
- package/dist/{Avatar-CXpGcula.js → Avatar-dMcn3j8Z.js} +1 -1
- package/dist/AvatarGroup/index.d.ts +1 -1
- package/dist/Banner/index.d.ts +1 -1
- package/dist/Banner/index.js +1 -1
- package/dist/{Banner-fmkd6nXw.js → Banner-CTY9qV89.js} +2 -2
- package/dist/BottomSheet/index.d.ts +1 -1
- package/dist/BottomSheet/index.js +2 -2
- package/dist/{BottomSheet-DrKtyVVo.js → BottomSheet-DyJJtZZU.js} +5 -5
- package/dist/{BottomSheet-DqAuZBgA.js → BottomSheet-ZOjuZya0.js} +3 -3
- package/dist/Breadcrumbs/index.js +2 -2
- package/dist/{Breadcrumbs-uaApwhFB.js → Breadcrumbs-mlCoLtma.js} +5 -2
- package/dist/Button/index.d.ts +1 -1
- package/dist/Button/index.js +1 -1
- package/dist/{Button-CQAjaQa0.js → Button-TiYG0btL.js} +4 -4
- package/dist/ButtonGroup/index.d.ts +1 -1
- package/dist/Calendar/index.d.ts +2 -2
- package/dist/Calendar/index.js +3 -2
- package/dist/Calendar-B6TZYEge.js +105 -0
- package/dist/{Calendar-ydp0vJdO.js → Calendar-CUMnYIhe.js} +182 -257
- package/dist/Card/index.d.ts +1 -1
- package/dist/Card/index.js +1 -1
- package/dist/{Card-BbKFHWuD.js → Card-D_OJxmwD.js} +1 -1
- package/dist/Carousel/index.d.ts +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/{Carousel-C3O9Uavl.js → Carousel-DsXup1mZ.js} +2 -2
- package/dist/Center/index.d.ts +1 -1
- package/dist/Chat/index.d.ts +1 -1
- package/dist/Chat/index.js +1 -1
- package/dist/{Chat-CmjK6fBy.js → Chat-DqYT_S9M.js} +7 -6
- package/dist/CheckboxInput/index.d.ts +1 -1
- package/dist/CheckboxInput/index.js +1 -1
- package/dist/{CheckboxInput-D6ow4VuS.js → CheckboxInput-BNwTTDHu.js} +3 -3
- package/dist/CheckboxList/index.d.ts +1 -1
- package/dist/CheckboxList/index.js +1 -1
- package/dist/{CheckboxList-CPaRsgRQ.js → CheckboxList-BLY16jPG.js} +3 -3
- package/dist/Citation/index.js +1 -1
- package/dist/{Citation-CSgRYxGU.js → Citation-Ijf06x0V.js} +1 -1
- package/dist/ClickableCard/index.d.ts +1 -1
- package/dist/ClickableCard/index.js +1 -1
- package/dist/{ClickableCard-DMX5z-QV.js → ClickableCard-CVQ7XS4L.js} +1 -1
- package/dist/Code/index.js +2 -2
- package/dist/{Code-rmiC0XfO.js → Code-5rZyPwty.js} +1 -1
- package/dist/{CodeBlock-DMG9rLQN.js → CodeBlock-5KoJDvWd.js} +3 -3
- package/dist/Collapsible/index.js +1 -1
- package/dist/{Collapsible-BVoNZijw.js → Collapsible-B1qW6OuL.js} +3 -1
- package/dist/CommandPalette/index.js +1 -1
- package/dist/{CommandPalette-CmOytlWq.js → CommandPalette-B2riNg_7.js} +3 -3
- package/dist/ComplexSelector/index.d.ts +1 -1
- package/dist/ComplexSelector/index.js +1 -1
- package/dist/{ComplexSelector-mfEoIHtI.js → ComplexSelector-CVCIsgAU.js} +4 -4
- package/dist/{ComponentIcon-BRXBBKeG.js → ComponentIcon-Dw4xQxg3.js} +3 -3
- package/dist/ContextMenu/index.d.ts +1 -1
- package/dist/ContextMenu/index.js +2 -2
- package/dist/{ContextMenu-DDvOR25x.js → ContextMenu-DYLdP-Ok.js} +7 -7
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.js +1 -1
- package/dist/{DateInput-pDh6H44y.js → DateInput-D9Jv70H7.js} +1210 -108
- package/dist/DateRangeInput/index.d.ts +1 -1
- package/dist/DateRangeInput/index.js +1 -1
- package/dist/{DateRangeInput-CQDfoXX5.js → DateRangeInput-BsB2kg_q.js} +75 -55
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.js +1 -1
- package/dist/{DateTimeInput-CZjere9H.js → DateTimeInput-BDyKPKGD.js} +26 -13
- package/dist/Dialog/index.d.ts +1 -1
- package/dist/Dialog/index.js +3 -3
- package/dist/{Dialog-XIB0KZ-m.js → Dialog-DUlWQH8R.js} +1 -1
- package/dist/{Dialog-BRlZ7n83.js → Dialog-JCB5s-T-.js} +4 -4
- package/dist/{DialogHeader-DF6jFDq3.js → DialogHeader-C6hZZxdv.js} +3 -3
- package/dist/Drawer/index.d.ts +1 -1
- package/dist/Drawer/index.js +1 -1
- package/dist/{Drawer-BYUELPLs.js → Drawer-BDuiw1-g.js} +2 -2
- package/dist/DropdownMenu/index.js +3 -3
- package/dist/{DropdownMenu-BBXFl5Mu.js → DropdownMenu-BVEOMFwc.js} +9 -9
- package/dist/{DropdownMenu-DY3yFENC.js → DropdownMenu-PjqSkkQs.js} +6 -6
- package/dist/EmptyState/index.js +1 -1
- package/dist/{EmptyState-cs-L9Ovg.js → EmptyState-CnFkYtcS.js} +3 -3
- package/dist/Field/index.js +3 -3
- package/dist/{Field-BQ3q-K5D.js → Field-D4UmRHlD.js} +2 -2
- package/dist/{FieldIcon-DMtfe1Ne.js → FieldIcon-BU1ZWAuo.js} +1 -1
- package/dist/{FieldInfoTip-MgGzYEq0.js → FieldInfoTip-BSqcEcUx.js} +2 -2
- package/dist/{FieldLabel-yH6KAVyU.js → FieldLabel-CZbayYFD.js} +2 -2
- package/dist/FieldStatus/index.js +1 -1
- package/dist/{FieldStatus-DSUCli4W.js → FieldStatus-DmCWPT6U.js} +1 -1
- package/dist/FileInput/index.d.ts +1 -1
- package/dist/FileInput/index.js +1 -1
- package/dist/{FileInput-R8CqJrA5.js → FileInput-8oYiJsq_.js} +4 -4
- package/dist/Grid/index.d.ts +1 -1
- package/dist/Grid/index.js +1 -1
- package/dist/{Grid-C0mp7fha.js → Grid-DTnDDT0Q.js} +2 -2
- package/dist/Heading/index.d.ts +1 -1
- package/dist/Heading/index.js +1 -1
- package/dist/{Heading-DkCkHEG-.js → Heading-COtyAhtB.js} +1 -1
- package/dist/HoverCard/index.js +1 -1
- package/dist/{HoverCard-D0KqUCXI.js → HoverCard-DGlOpk4x.js} +4 -4
- package/dist/Icon/index.js +3 -3
- package/dist/{Icon-BCHo7W0x.js → Icon-Dk0jccgU.js} +2 -1
- package/dist/{Icon-B2aULLnn.js → Icon-M1Rlknd0.js} +2 -1
- package/dist/IconButton/index.js +1 -1
- package/dist/{IconButton-DR9_545-.js → IconButton-CwjHTIBg.js} +1 -1
- package/dist/Indicator/index.js +1 -1
- package/dist/InfoTip/index.d.ts +1 -1
- package/dist/InfoTip/index.js +1 -1
- package/dist/{InfoTip-BfgtAgck.js → InfoTip-CNZateDb.js} +2 -2
- package/dist/{InputClearButton-DaFtlyKR.js → InputClearButton-CzCP41sx.js} +2 -2
- package/dist/InputGroup/index.js +1 -1
- package/dist/{InputGroup-1CLPKULR.js → InputGroup-CfUGHDNz.js} +1 -1
- package/dist/InternationalizationProvider/index.d.ts +1 -1
- package/dist/InternationalizationProvider/index.js +1 -1
- package/dist/{InternationalizationProvider-Ddo_-tLK.js → InternationalizationProvider-DaZS5Dch.js} +5 -2
- package/dist/{LayerContentBoundary-lxUfJk2v.js → LayerContentBoundary-LCQLyxBT.js} +1 -1
- package/dist/Layout/index.d.ts +1 -1
- package/dist/Layout/index.js +2 -2
- package/dist/{Layout-DP2vrvTv.js → Layout-DOIeCgs4.js} +2 -2
- package/dist/{LayoutPanel-DuroKU_A.js → LayoutPanel-C7Wsid2W.js} +34 -14
- package/dist/Lightbox/index.js +1 -1
- package/dist/{Lightbox-DyaSfJix.js → Lightbox-Dzzd2Vqe.js} +4 -4
- package/dist/Link/index.d.ts +1 -1
- package/dist/Link/index.js +1 -1
- package/dist/{Link-JVAfvoxT.js → Link-B7OJQ0zl.js} +2 -2
- package/dist/List/index.d.ts +1 -1
- package/dist/Markdown/index.js +1 -1
- package/dist/{Markdown-DtnPfhP0.js → Markdown-Cbj-nqhN.js} +4 -4
- package/dist/{MediaTheme-DfcdEWx-.js → MediaTheme-UM8oOqwX.js} +1 -1
- package/dist/MobileNav/index.js +2 -1
- package/dist/{MobileNavToggle-CPNsCIFR.js → MobileNavToggle-BlcdCg8M.js} +6 -8
- package/dist/MoreMenu/index.d.ts +1 -1
- package/dist/MoreMenu/index.js +1 -1
- package/dist/{MoreMenu-DQjrchg5.js → MoreMenu-DAhOiau3.js} +5 -5
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.js +1 -1
- package/dist/{MultiSelector-sJ-LUrze.js → MultiSelector-ERv5u6r4.js} +11 -10
- package/dist/{NavDisclosure-CE79mxpa.js → NavDisclosure-CqAThYgR.js} +13 -4
- package/dist/{NavHeadingSurface-EsNdvhx7.js → NavHeadingSurface-DJ4pWvEi.js} +16 -15
- package/dist/NavItem/index.d.ts +1 -1
- package/dist/NavMenu/index.js +3 -3
- package/dist/{NavMenu-_Mo1yWZC.js → NavMenu-BtA_Xbmr.js} +8 -6
- package/dist/{NavMenuItem-CDHKFOKi.js → NavMenuItem-BxfjAf1T.js} +7 -4
- package/dist/NumberInput/index.d.ts +1 -1
- package/dist/NumberInput/index.js +1 -1
- package/dist/{NumberInput-Bpc2c39W.js → NumberInput-Bl5TFhGD.js} +5 -5
- package/dist/OverflowList/index.d.ts +1 -1
- package/dist/OverflowList/index.js +1 -1
- package/dist/{OverflowList-Dx_Iw8xd.js → OverflowList-CumJl6X_.js} +2 -2
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/index.js +1 -1
- package/dist/{Pagination-D7sbjDKw.js → Pagination-DuTUReOl.js} +271 -135
- package/dist/Popover/index.d.ts +1 -1
- package/dist/Popover/index.js +1 -1
- package/dist/{Popover-Bhi0b1x0.js → Popover-DpR4rwiW.js} +6 -6
- package/dist/PowerSearch/index.d.ts +1 -1
- package/dist/PowerSearch/index.js +1 -1
- package/dist/{PowerSearch-B13bgXSs.js → PowerSearch-CewQJzEt.js} +34 -33
- package/dist/ProgressBar/index.js +1 -1
- package/dist/{ProgressBar-BtEaKOhz.js → ProgressBar-Dp-0xquN.js} +1 -1
- package/dist/Radio/index.d.ts +1 -1
- package/dist/Radio/index.js +1 -1
- package/dist/{RadioGroup-CFqN0t92.js → RadioGroup-DrCL5-AN.js} +3 -3
- package/dist/RadioList/index.d.ts +1 -1
- package/dist/RadioList/index.js +1 -1
- package/dist/{RadioList-DVNkGcpc.js → RadioList-CRi4E1zq.js} +1 -1
- package/dist/Resizable/index.d.ts +1 -1
- package/dist/Resizable/index.js +1 -1
- package/dist/{ResizeHandle-4-krI-cQ.js → ResizeHandle-BMSbAFdP.js} +43 -27
- package/dist/ScrollableArea/index.d.ts +1 -1
- package/dist/SelectableCard/index.d.ts +1 -1
- package/dist/SelectableCard/index.js +1 -1
- package/dist/{SelectableCard-DUTtyApJ.js → SelectableCard-Dp-LsEcf.js} +1 -1
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.js +1 -1
- package/dist/{Selector-sGqS3qNy.js → Selector-D6yzPO5O.js} +9 -9
- package/dist/SideNav/index.d.ts +1 -1
- package/dist/SideNav/index.js +1 -1
- package/dist/{SideNav-Dw9MydVe.js → SideNav-z_6FwEJy.js} +13 -58
- package/dist/Slider/index.js +1 -1
- package/dist/{Slider-BkVTjzrx.js → Slider-DMHlRq7q.js} +2 -2
- package/dist/Stack/index.d.ts +1 -1
- package/dist/StatusDot/index.js +1 -1
- package/dist/{StatusDot-D4S8b-FU.js → StatusDot-B3oOyRF7.js} +1 -1
- package/dist/Stepper/index.js +1 -1
- package/dist/{Stepper-CQd4YlPC.js → Stepper-CgOdL36_.js} +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DU-MRs1W.js → Switch-OPRkoPLi.js} +2 -2
- package/dist/TabList/index.d.ts +1 -1
- package/dist/TabList/index.js +1 -1
- package/dist/{TabList-CmB55DUS.js → TabList-FkoypUk0.js} +62 -23
- package/dist/Table/index.d.ts +1 -1
- package/dist/Table/index.js +1 -1
- package/dist/{Table-BUh0OjeU.js → Table-CCjpL_Ku.js} +16 -16
- package/dist/Text/index.d.ts +1 -1
- package/dist/Text/index.js +1 -1
- package/dist/{Text-BBQUFWb_.js → Text-v1ep26uD.js} +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{TextArea-BVppzw5n.js → TextArea-BilHnmSs.js} +5 -5
- package/dist/TextInput/index.d.ts +1 -1
- package/dist/TextInput/index.js +1 -1
- package/dist/{TextInput-CmxKsaUt.js → TextInput-D6tHM2sA.js} +4 -4
- package/dist/Theme/index.js +3 -2
- package/dist/{Theme-1RJVaRgz.js → Theme-BmTbbiAD.js} +6 -22
- package/dist/Thumbnail/index.js +1 -1
- package/dist/{Thumbnail-_KR0IRj-.js → Thumbnail-llGdnQM8.js} +3 -3
- package/dist/{TimeField-Dbr2MOqX.js → TimeField-C5rcoaVu.js} +7 -7
- package/dist/TimeInput/index.d.ts +1 -1
- package/dist/TimeInput/index.js +1 -1
- package/dist/{TimeInput-hzZ3tuAw.js → TimeInput-D0N8nwrI.js} +2 -2
- package/dist/Timer/index.d.ts +1 -1
- package/dist/Timer/index.js +1 -1
- package/dist/{Timer-UnFtEgGb.js → Timer-65PfuoQ7.js} +1 -1
- package/dist/Timestamp/index.d.ts +1 -1
- package/dist/Timestamp/index.js +2 -2
- package/dist/{Timestamp-DiPZTa4W.js → Timestamp-rYC8mE3r.js} +20 -12
- package/dist/Toast/index.js +1 -1
- package/dist/{Toast-kV5KuJdD.js → Toast-BtQ-4Y6Z.js} +3 -3
- package/dist/ToggleButton/index.d.ts +1 -1
- package/dist/ToggleButton/index.js +1 -1
- package/dist/{ToggleButton-DZ3n-izd.js → ToggleButton-DTrNL430.js} +1 -1
- package/dist/Token/index.d.ts +1 -1
- package/dist/Tokenizer/index.js +1 -1
- package/dist/{Tokenizer-e8BisAF8.js → Tokenizer-DdddkJb1.js} +6 -5
- package/dist/Toolbar/index.d.ts +1 -1
- package/dist/Toolbar/index.js +1 -1
- package/dist/{Toolbar-B4Vltu-j.js → Toolbar-DSWH8ll4.js} +25 -2
- package/dist/Tooltip/index.js +2 -2
- package/dist/{Tooltip-CPyoc4cM.js → Tooltip-CByjfHBZ.js} +1 -1
- package/dist/TopNav/index.d.ts +1 -1
- package/dist/TopNav/index.js +1 -1
- package/dist/{TopNav-OOGD2uOp.js → TopNav-C1wpttKX.js} +168 -61
- package/dist/TreeList/index.js +1 -1
- package/dist/{TreeList-DJQvL5tG.js → TreeList-DOAcS3PM.js} +1 -1
- package/dist/Typeahead/index.js +2 -2
- package/dist/{Typeahead--CFFYPMl.js → Typeahead-6y_r-VNU.js} +6 -6
- package/dist/adaptationTypes-Beao49TN.js +19 -0
- package/dist/{assertOptions-DLEhkmM-.js → assertOptions-og3t30Fh.js} +2 -1
- package/dist/calendar-C7py_wtb.js +351 -0
- package/dist/calendarFormat-_CEZIMZG.js +123 -0
- package/dist/closeOnActivate-D1KgKWwm.js +13 -0
- package/dist/{componentIcons-CFr2L6o3.js → componentIcons-BBJqmilP.js} +1 -1
- package/dist/composables/index.js +11 -11
- package/dist/{composables-DSx0MWv0.js → composables-COCeg92e.js} +2 -2
- package/dist/context-Cws_tXTr.js +7 -0
- package/dist/{context-CjX2RSDn.js → context-D-Hwh-Jf.js} +1 -1
- package/dist/context-D8MAZio1.js +7 -0
- package/dist/{date-input-rUD8YAow.js → date-input-CRdc2H3c.js} +6 -2
- package/dist/focusLeaving-Dqm8Yj4T.js +53 -0
- package/dist/{focusReturn-CiSQAp52.js → focusReturn-C1cFL3WM.js} +1 -1
- package/dist/{format-mffyPc-L.js → format-6G9QuGy1.js} +12 -4
- package/dist/{formatInstant-BDWUIxS7.js → formatInstant-CjCwl6JS.js} +8 -6
- package/dist/{index-PffxihMx.d.ts → index-B3U6GJKl.d.ts} +2 -2
- package/dist/{index-DSoQE84m.d.ts → index-B5MCvW75.d.ts} +229 -57
- package/dist/{index-BgT6mH3U.d.ts → index-BB9acgK8.d.ts} +1 -1
- package/dist/{index-C3FgFPrM.d.ts → index-BDJQW9cW.d.ts} +10 -10
- package/dist/{index-ZbNwGVkS.d.ts → index-BKnyTWPM.d.ts} +1 -1
- package/dist/{index-BTljzczH.d.ts → index-C-kIxNCq.d.ts} +8 -11
- package/dist/{index-waTkqxTz.d.ts → index-C89cIh4E.d.ts} +1 -1
- package/dist/{index-Cm36VS1A.d.ts → index-C9uW39Mj.d.ts} +1 -1
- package/dist/{index-FeZXsFO-.d.ts → index-CBOv5j3c.d.ts} +3 -3
- package/dist/{index-DFLPv9io.d.ts → index-CP-fJFcJ.d.ts} +1 -1
- package/dist/{index-Bgk1Rj2A.d.ts → index-CTjkJP4x.d.ts} +1 -1
- package/dist/{index-BdZCLUgY.d.ts → index-CnVjgLP5.d.ts} +9 -1
- package/dist/{index-DB1EP38S.d.ts → index-CpLLSVCn.d.ts} +8 -6
- package/dist/{index-rdwI-mcm.d.ts → index-CtYlR9Cu.d.ts} +1 -1
- package/dist/{index-B1eCxBCY.d.ts → index-DCyYldjP.d.ts} +7 -1
- package/dist/{index-B8K2sDmO.d.ts → index-DXHmlFcC.d.ts} +2 -2
- package/dist/{index-fd--aE4B.d.ts → index-DbNGGCM0.d.ts} +4 -3
- package/dist/{index-BOzyKBg8.d.ts → index-Dc6mU3rv.d.ts} +3 -3
- package/dist/{index-BL4mH8aK.d.ts → index-NOxH5oYj.d.ts} +4 -3
- package/dist/{index-DE1genab.d.ts → index-QnlWyUxN.d.ts} +2 -2
- package/dist/{index-CNzSg1OM.d.ts → index-SRA6e30Q.d.ts} +5 -5
- package/dist/{index-BA8exXNP.d.ts → index-X4S7_dmq.d.ts} +1 -1
- package/dist/{index-Dge6tyPE.d.ts → index-ZKBj_1nu.d.ts} +1 -1
- package/dist/{index-BZNoML0r.d.ts → index-ZT45ZWd5.d.ts} +7 -7
- package/dist/{index-CQ-sq76o.d.ts → index-_FjbcSgD.d.ts} +8 -2
- package/dist/{index-fz8XqpNd.d.ts → index-beOIC0Qk.d.ts} +13 -0
- package/dist/{index-DFTrqCmp.d.ts → index-nk2xIHpr.d.ts} +1 -1
- package/dist/index.d.ts +31 -31
- package/dist/index.js +117 -116
- package/dist/inputPresentation-DES0JwkL.js +203 -0
- package/dist/interactionModality-CedLz5PC.js +130 -0
- package/dist/{interactionModality-JFDvbtbb.js → layerDepth-D3Rh8T5C.js} +1 -125
- package/dist/{layerFocusReturn-DJ5mlqYj.js → layerFocusReturn-KvH6DMFT.js} +1 -1
- package/dist/{loadCatalog-DsEKSY3U.js → loadCatalog-BeQt6Uq-.js} +9 -1
- package/dist/{loadCatalog-C4h9SmJs.d.ts → loadCatalog-C8mRnC0E.d.ts} +5 -1
- package/dist/locale/index.d.ts +4 -4
- package/dist/locale/index.js +4 -4
- package/dist/{locale-C-Y-13BP.js → locale-B4FpGKpc.js} +6 -2
- package/dist/{dateParser-BKoaawL9.js → plainDate-CaTDErKr.js} +1 -132
- package/dist/{power-search-CqcsJT1F.d.ts → power-search-CuMzfLwW.d.ts} +13 -1
- package/dist/resizableChannel-LElsNkSY.js +33 -0
- package/dist/{stillPointerGate-BTISispN.js → stillPointerGate-1Tgkns0J.js} +1 -1
- package/dist/{themeIcons-CqGF0fwW.js → themeIcons-1O7ymucc.js} +1 -7
- package/dist/{tooltipFocusRules-DPsyi9L5.js → tooltipFocusRules-vIH7PZh1.js} +3 -2
- package/dist/{tooltipTriggerRules-Dazz57_v.js → tooltipTriggerRules-DoBAbfGc.js} +1 -1
- package/dist/{triggerVariant-BDVvyLtv.js → triggerVariant-DG0VhG-X.js} +1 -1
- package/dist/useCalendarGrid-0WvxbeFC.js +179 -0
- package/dist/{useCombobox-DTDT9dRx.js → useCombobox-BqkTY3bw.js} +1 -1
- package/dist/{useDismiss-N66C48zd.js → useDismiss-CMIsdIOQ.js} +1 -1
- package/dist/{useFocusTrap-DzspshsM.js → useFocusTrap-DTz_d7IP.js} +3 -2
- package/dist/{useIndicator--9mGGlT2.js → useIndicator-PFDBNOvX.js} +2 -2
- package/dist/{useInputStatusIcon-D1WRYTOZ.js → useInputStatusIcon-CrgeMzrf.js} +2 -2
- package/dist/{useMenuDrillIn-RZwY55RM.js → useMenuDrillIn-f3m-59Qb.js} +1 -1
- package/dist/{useMenuPress-Cm7LVmHJ.js → useMenuPress-wqRDvUMW.js} +2 -2
- package/dist/{useResizable-C9FtmPir.js → useResizable-hv4NYIUi.js} +6 -3
- package/dist/{useRestoreFocus-CEbfcwWb.js → useRestoreFocus-BxooFhas.js} +2 -2
- package/dist/{useTooltip-BfOruqIL.js → useTooltip-BwqzEtoF.js} +5 -5
- package/dist/{useTouchTriggerInternal-TQnpDkL0.js → useTouchTriggerInternal-Bdm_M4aa.js} +2 -1
- package/dist/{useTruncationTooltip-CbzoB-1m.js → useTruncationTooltip-CRhoPzeu.js} +4 -4
- package/dist/{useTypeahead-BGmDZyPB.js → useTypeahead-BGpvWkzm.js} +1 -1
- package/dist/{useTypeaheadMenuConfig-BZaduAP4.js → useTypeaheadMenuConfig-GvdIymRg.js} +2 -2
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
- package/reset.css +0 -19
- package/styles/app-shell.css +118 -1
- package/styles/aspect-ratio.css +4 -3
- package/styles/breadcrumbs.css +1 -0
- package/styles/collapsible.css +1 -0
- package/styles/layout.css +22 -5
- package/styles/nav-item.css +9 -3
- package/styles/nav-menu.css +3 -0
- package/styles/pagination.css +2 -2
- package/styles/resize-handle.css +64 -35
- package/styles/scrollable-area.css +13 -0
- package/styles/tab-list.css +7 -3
- package/styles/tab-menu.css +1 -0
- package/styles/toolbar.css +39 -3
- package/styles/top-nav.css +141 -11
- package/dist/inputPresentation-BOyHkCDr.js +0 -62
- package/dist/resizableChannel-3vivrEcT.js +0 -20
- package/dist/{index-5FGt4HsB.d.ts → index-BqhgeAT4.d.ts} +1 -1
|
@@ -1,34 +1,240 @@
|
|
|
1
|
-
import { n as _sfc_main$4 } from "./BottomSheet-
|
|
2
|
-
import { t as _sfc_main$5 } from "./Icon-
|
|
1
|
+
import { n as _sfc_main$4 } from "./BottomSheet-DyJJtZZU.js";
|
|
2
|
+
import { t as _sfc_main$5 } from "./Icon-Dk0jccgU.js";
|
|
3
3
|
import { r as useInputGroupDisabled } from "./context-Bg7eSJ47.js";
|
|
4
4
|
import { i as useSize } from "./SizeContext-BbaF-SEx.js";
|
|
5
|
-
import {
|
|
5
|
+
import { a as noteOutsideDismissal, c as currentGesture, s as isImeKeyEvent } from "./layerDepth-D3Rh8T5C.js";
|
|
6
6
|
import { t as _sfc_main$6 } from "./VisuallyHidden-cpmsV-0M.js";
|
|
7
7
|
import { t as _sfc_main$7 } from "./ButtonTooltip-CNKOQHYR.js";
|
|
8
8
|
import { t as useButtonTooltip } from "./useButtonTooltip-DjCaZMp_.js";
|
|
9
9
|
import { t as useMediaQuery } from "./useMediaQuery-BzXGT1Aw.js";
|
|
10
10
|
import { n as resolveDateSurface, t as resolveDatePresentation } from "./useDatePresentation-C07PnOCw.js";
|
|
11
|
-
import { t as _sfc_main$8 } from "./FieldIcon-
|
|
11
|
+
import { t as _sfc_main$8 } from "./FieldIcon-BU1ZWAuo.js";
|
|
12
12
|
import { a as useAstryxLocale, o as useComponentMessages } from "./context-B8IEFCDR.js";
|
|
13
13
|
import { t as usePendingChange } from "./usePendingChange-ib-h8FZK.js";
|
|
14
14
|
import { t as useResolvedLabelHidden } from "./useResolvedLabelHidden-B2rlWiaI.js";
|
|
15
|
-
import {
|
|
15
|
+
import { t as unicodeRegExp } from "./unicodeRegExp-B7yQnpFC.js";
|
|
16
|
+
import { n as toAsciiDigits, t as INVISIBLE_CHARS } from "./unicodeDigits-_BYIJcAu.js";
|
|
17
|
+
import { C as plainDateIsAfter, F as plainDateToday, L as dateTimeFormatFor, M as plainDateToDate, d as getDaysInMonth, l as SHARED_DATE_FORMAT_OPTIONS, p as plainDateAddDays, u as formatSharedDate, v as plainDateFormat, w as plainDateIsBefore, y as plainDateFromDate } from "./plainDate-CaTDErKr.js";
|
|
18
|
+
import { _ as isCalendarSystemAvailable, a as calendarAddMonths, b as isInCalendarMonth, c as calendarDayOfMonth, d as calendarMonthLabelDay, f as calendarMonthOf, g as calendarYearMonthOf, h as calendarShiftYears, i as warnCalendarOnce, l as calendarMonthFromYearMonth, o as calendarDateFromFields, p as calendarMonthsInCalendarYear, r as useCalendarSystem, s as calendarDateFromMonthKey, u as calendarMonthKey, v as isGregorianAligned, y as isGregorianCalendar } from "./calendar-C7py_wtb.js";
|
|
19
|
+
import { a as weekdayNames, i as standaloneShortWeekdayNames, n as formatDayNumber } from "./format-6G9QuGy1.js";
|
|
16
20
|
import { t as calendarMessages } from "./calendar-Cs2vIPsV.js";
|
|
17
|
-
import { a as
|
|
21
|
+
import { a as formatCalendarMonthName, i as formatCalendarMonthLabel, o as formatCalendarYearLabel, t as calendarDisplayName } from "./calendarFormat-_CEZIMZG.js";
|
|
22
|
+
import { a as formatWeekdayDate, f as weekStartIndex, l as sameCalendarDay, t as buildMonthWeeks, u as toCalendarDate, y as toCalendarDay } from "./useCalendarGrid-0WvxbeFC.js";
|
|
23
|
+
import { i as isOutsideCalendarBounds, n as resolveCalendarKey, r as isCalendarDateDisabled, t as _sfc_main$9 } from "./Calendar-CUMnYIhe.js";
|
|
18
24
|
import { t as _sfc_main$10 } from "./Spinner-DEVPDsD0.js";
|
|
19
25
|
import { a as useEntryErrorBehavior, i as useAriaRequired } from "./context-DsNhYm5O.js";
|
|
20
|
-
import { t as _sfc_main$11 } from "./Field-
|
|
26
|
+
import { t as _sfc_main$11 } from "./Field-D4UmRHlD.js";
|
|
21
27
|
import { t as useFieldPartStyling } from "./fieldParts-CbWvZLhH.js";
|
|
22
28
|
import { t as useBusyAnnouncement } from "./busyAnnouncement-CExubuYm.js";
|
|
23
|
-
import { t as _sfc_main$12 } from "./Popover-
|
|
24
|
-
import { t as dateInputMessages } from "./date-input-
|
|
25
|
-
import { t as formatInstant } from "./formatInstant-
|
|
26
|
-
import {
|
|
29
|
+
import { t as _sfc_main$12 } from "./Popover-DpR4rwiW.js";
|
|
30
|
+
import { t as dateInputMessages } from "./date-input-CRdc2H3c.js";
|
|
31
|
+
import { t as formatInstant } from "./formatInstant-CjCwl6JS.js";
|
|
32
|
+
import { n as calendarPickerPresentation, u as parseDateInput } from "./inputPresentation-DES0JwkL.js";
|
|
27
33
|
import { t as _sfc_main$13 } from "./PickerWheel-DNX3yrUd.js";
|
|
28
34
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, getCurrentInstance, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, onScopeDispose, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, unref, useAttrs, useId, useTemplateRef, watch, withCtx } from "vue";
|
|
29
|
-
import { CalendarDate } from "@internationalized/date";
|
|
30
35
|
import "../styles/calendar.css";
|
|
31
36
|
import "../styles/date-input.css";
|
|
37
|
+
//#region src/DateInput/DateInputPassThrough.ts
|
|
38
|
+
/** 没有标签、说明和状态时代替 Field 的外壳:只渲染默认插槽,不加任何元素。 */
|
|
39
|
+
var DateInputPassThrough_default = defineComponent({
|
|
40
|
+
name: "DateInputPassThrough",
|
|
41
|
+
setup(_, { slots }) {
|
|
42
|
+
return () => slots.default?.({});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/utils/calendarDateIntl.ts
|
|
47
|
+
const NUMERIC = {
|
|
48
|
+
year: "numeric",
|
|
49
|
+
month: "numeric",
|
|
50
|
+
day: "numeric"
|
|
51
|
+
};
|
|
52
|
+
const LONG = SHARED_DATE_FORMAT_OPTIONS.date_long;
|
|
53
|
+
const YEAR_ONLY = { year: "numeric" };
|
|
54
|
+
const ERA_AND_YEAR = {
|
|
55
|
+
era: "short",
|
|
56
|
+
year: "numeric"
|
|
57
|
+
};
|
|
58
|
+
/** 农历和朝鲜历:年份按六十年一轮起名,闰月写成平月加记号。 */
|
|
59
|
+
const LUNISOLAR = /* @__PURE__ */ new Set(["chinese", "dangi"]);
|
|
60
|
+
/** 不写纪元的历法。 */
|
|
61
|
+
const WITHOUT_ERA = /* @__PURE__ */ new Set([
|
|
62
|
+
"gregory",
|
|
63
|
+
"iso8601",
|
|
64
|
+
"chinese",
|
|
65
|
+
"dangi"
|
|
66
|
+
]);
|
|
67
|
+
const LATIN_MARKS = unicodeRegExp("(\\p{Script=Latin})\\p{Mn}+", "gu");
|
|
68
|
+
/** 文本框读写的历法。`iso8601` 和当前环境显示不了的历法按公历读写。 */
|
|
69
|
+
function textCalendar(calendar) {
|
|
70
|
+
if (calendar === "iso8601" || !isCalendarSystemAvailable(calendar)) return "gregory";
|
|
71
|
+
return calendar;
|
|
72
|
+
}
|
|
73
|
+
/** `relatedYear`、`yearName` 这类片段类型在旧的 TS 声明里没有。 */
|
|
74
|
+
function partType(part) {
|
|
75
|
+
return part.type;
|
|
76
|
+
}
|
|
77
|
+
function utcDate(pd) {
|
|
78
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
79
|
+
date.setUTCFullYear(pd.year, pd.month - 1, pd.day);
|
|
80
|
+
return date;
|
|
81
|
+
}
|
|
82
|
+
/** 按历法写一个公历日期的格式片段。 */
|
|
83
|
+
function partsOf(locale, calendar, options, pd) {
|
|
84
|
+
return dateTimeFormatFor(locale, {
|
|
85
|
+
...options,
|
|
86
|
+
calendar,
|
|
87
|
+
timeZone: "UTC"
|
|
88
|
+
}).formatToParts(utcDate(pd));
|
|
89
|
+
}
|
|
90
|
+
/** 把文字归成一种可比较的写法:ASCII 数字、小写、去掉拉丁字母的重音。 */
|
|
91
|
+
function normalizeDateText(text, locale) {
|
|
92
|
+
if (/^[\x20-\x7E]*$/.test(text)) {
|
|
93
|
+
const ascii = text.replaceAll("`", "'");
|
|
94
|
+
return /[A-Z]/.test(ascii) ? ascii.toLocaleLowerCase(locale) : ascii;
|
|
95
|
+
}
|
|
96
|
+
const folded = text.normalize("NFKC").replace(INVISIBLE_CHARS, "").replace(/[\u202A-\u202E]/g, "").replace(/[\u05F3\u2018\u2019\u02BB\u02BC\u02BF`]/g, "'").replace(/[\u05F4\u201C\u201D]/g, "\"");
|
|
97
|
+
let result = (toAsciiDigits(folded) ?? folded).toLocaleLowerCase(locale);
|
|
98
|
+
if (/[\u00C0-\u024F\u1E00-\u1EFF]/.test(result)) result = result.normalize("NFD").replace(LATIN_MARKS, "$1").normalize("NFC");
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
/** 一个公历日期在这种历法里的年份数,从 `Intl` 读。 */
|
|
102
|
+
function calendarYearOf(calendar, pd) {
|
|
103
|
+
const year = partsOf("en", calendar, YEAR_ONLY, pd).find((part) => partType(part) === "relatedYear" || part.type === "year");
|
|
104
|
+
return Number(normalizeDateText(year?.value ?? "", "en"));
|
|
105
|
+
}
|
|
106
|
+
/** `Intl` 给一个日期写的纪元名和纪元年。 */
|
|
107
|
+
function calendarEraYear(locale, calendar, pd) {
|
|
108
|
+
const parts = partsOf(locale, calendar, ERA_AND_YEAR, pd);
|
|
109
|
+
const year = parts.find((part) => part.type === "year" || partType(part) === "relatedYear");
|
|
110
|
+
return {
|
|
111
|
+
era: parts.find((part) => part.type === "era")?.value ?? "",
|
|
112
|
+
year: Number(normalizeDateText(year?.value ?? "", locale))
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** 格式片段里年、月、日出现的顺序。 */
|
|
116
|
+
function fieldOrder(parts) {
|
|
117
|
+
const order = [];
|
|
118
|
+
for (const part of parts) {
|
|
119
|
+
const type = partType(part) === "relatedYear" ? "year" : part.type;
|
|
120
|
+
if ((type === "year" || type === "month" || type === "day") && !order.includes(type)) order.push(type);
|
|
121
|
+
}
|
|
122
|
+
return order;
|
|
123
|
+
}
|
|
124
|
+
const eraChangeCache = /* @__PURE__ */ new Map();
|
|
125
|
+
/** 1900 到 2100 年之间纪元有没有换过。只有换过,不写纪元的年份才可能读成两个日期。 */
|
|
126
|
+
function hasEraChange(calendar) {
|
|
127
|
+
let result = eraChangeCache.get(calendar);
|
|
128
|
+
if (result == null) {
|
|
129
|
+
const eraOf = (date) => calendarEraYear("en", calendar, date).era;
|
|
130
|
+
result = eraOf({
|
|
131
|
+
year: 1900,
|
|
132
|
+
month: 1,
|
|
133
|
+
day: 1
|
|
134
|
+
}) !== eraOf({
|
|
135
|
+
year: 2100,
|
|
136
|
+
month: 12,
|
|
137
|
+
day: 31
|
|
138
|
+
});
|
|
139
|
+
eraChangeCache.set(calendar, result);
|
|
140
|
+
}
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
const displayOptionCache = /* @__PURE__ */ new WeakMap();
|
|
144
|
+
/**
|
|
145
|
+
* 给不写纪元的格式补上纪元,免得年份被当成公历年份。补了纪元会打乱字段顺序时保留语言自己的写法;
|
|
146
|
+
* 纪元换过的历法退而用不打乱顺序的窄纪元,例如阿姆哈拉语和历的 "1/1/8 R"。
|
|
147
|
+
*/
|
|
148
|
+
function displayOptions(locale, calendar, options) {
|
|
149
|
+
if (WITHOUT_ERA.has(calendar)) return options;
|
|
150
|
+
let byLocale = displayOptionCache.get(options);
|
|
151
|
+
if (byLocale == null) {
|
|
152
|
+
byLocale = /* @__PURE__ */ new Map();
|
|
153
|
+
displayOptionCache.set(options, byLocale);
|
|
154
|
+
}
|
|
155
|
+
const key = `${locale}|${calendar}`;
|
|
156
|
+
let result = byLocale.get(key);
|
|
157
|
+
if (result == null) {
|
|
158
|
+
const sample = {
|
|
159
|
+
year: 2026,
|
|
160
|
+
month: 11,
|
|
161
|
+
day: 2
|
|
162
|
+
};
|
|
163
|
+
const parts = partsOf(locale, calendar, options, sample);
|
|
164
|
+
result = options;
|
|
165
|
+
const order = fieldOrder(parts).join();
|
|
166
|
+
if (!parts.some((part) => part.type === "era")) {
|
|
167
|
+
const widths = hasEraChange(calendar) ? ["short", "narrow"] : ["short"];
|
|
168
|
+
for (const era of widths) {
|
|
169
|
+
const withEra = {
|
|
170
|
+
...options,
|
|
171
|
+
era
|
|
172
|
+
};
|
|
173
|
+
if (fieldOrder(partsOf(locale, calendar, withEra, sample)).join() === order) {
|
|
174
|
+
result = withEra;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
byLocale.set(key, result);
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/utils/calendarDateText.ts
|
|
185
|
+
/**
|
|
186
|
+
* 农历和朝鲜历的日期。有的语言只用六十年一轮的年份名写年(德语的 "24. M09 bing-wu"),
|
|
187
|
+
* 读不回唯一的日期,这时把年份名换成相关的公历年份数。
|
|
188
|
+
*/
|
|
189
|
+
function formatLunisolar(pd, options, locale, calendar) {
|
|
190
|
+
const parts = partsOf(locale, calendar, options, pd);
|
|
191
|
+
if (parts.some((part) => partType(part) === "relatedYear")) return parts.map((part) => part.value).join("");
|
|
192
|
+
const { numberingSystem } = dateTimeFormatFor(locale, {
|
|
193
|
+
...options,
|
|
194
|
+
calendar,
|
|
195
|
+
timeZone: "UTC"
|
|
196
|
+
}).resolvedOptions();
|
|
197
|
+
const year = new Intl.NumberFormat(locale, {
|
|
198
|
+
numberingSystem,
|
|
199
|
+
useGrouping: false
|
|
200
|
+
}).format(calendarYearOf(calendar, pd));
|
|
201
|
+
return parts.map((part) => /^year(?:Name)?$/.test(partType(part)) ? year : part.value).join("");
|
|
202
|
+
}
|
|
203
|
+
function formatInCalendar(pd, options, locale, calendar) {
|
|
204
|
+
if (LUNISOLAR.has(calendar)) return formatLunisolar(pd, options, locale, calendar);
|
|
205
|
+
const display = displayOptions(locale, calendar, options);
|
|
206
|
+
const text = plainDateFormat(pd, {
|
|
207
|
+
...display,
|
|
208
|
+
calendar
|
|
209
|
+
}, locale);
|
|
210
|
+
const eraOf = (date) => calendarEraYear("en", calendar, date).era;
|
|
211
|
+
if (!hasEraChange(calendar) || eraOf(pd) === eraOf({
|
|
212
|
+
year: 9999,
|
|
213
|
+
month: 12,
|
|
214
|
+
day: 31
|
|
215
|
+
}) || partsOf(locale, calendar, display, pd).some((part) => part.type === "era")) return text;
|
|
216
|
+
const withEra = partsOf(locale, calendar, {
|
|
217
|
+
...options,
|
|
218
|
+
era: "short"
|
|
219
|
+
}, pd);
|
|
220
|
+
const at = withEra.findIndex((part) => part.type === "era");
|
|
221
|
+
const era = withEra.slice(at === 0 ? 0 : at - 1, at === 0 ? 2 : at + 1).map((part) => part.value).join("");
|
|
222
|
+
return at === 0 ? era + text : text + era;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 日期字段在某种历法里提交后的文字。公历的文字和 Timestamp 的日期文字一样;`system_date` 永远是 ISO 日期。
|
|
226
|
+
* 别的历法补上纪元,免得年份被当成公历年份。
|
|
227
|
+
*/
|
|
228
|
+
function formatCalendarDateText(pd, format, locale, calendar) {
|
|
229
|
+
const resolved = textCalendar(calendar);
|
|
230
|
+
if (format === "system_date" || resolved === "gregory") return formatSharedDate(pd, format, locale);
|
|
231
|
+
return formatInCalendar(pd, SHARED_DATE_FORMAT_OPTIONS[format], locale, resolved);
|
|
232
|
+
}
|
|
233
|
+
/** 历法数字写法的示例日期,带纪元,例如 "۱۴۰۵/۸/۸"。 */
|
|
234
|
+
function formatCalendarDateHint(pd, locale, calendar) {
|
|
235
|
+
return formatInCalendar(pd, NUMERIC, locale, textCalendar(calendar));
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
32
238
|
//#region src/DateInput/dateText.ts
|
|
33
239
|
/** 本地日期写成 `YYYY-MM-DD`。 */
|
|
34
240
|
function toIsoDate(date) {
|
|
@@ -43,12 +249,15 @@ function parseTypedDate(text) {
|
|
|
43
249
|
if (Number.isNaN(date.getTime()) || date.getFullYear() !== Number(year) || date.getMonth() !== Number(month) - 1 || date.getDate() !== Number(day)) return null;
|
|
44
250
|
return date;
|
|
45
251
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
252
|
+
/**
|
|
253
|
+
* 已提交日期的显示文字。别的历法按那种历法写,带上纪元;自定义格式函数和 `system_date` 永远拿到公历 ISO 日期。
|
|
254
|
+
*/
|
|
255
|
+
function formatCommittedDate(date, format, locale, calendar = "gregory") {
|
|
48
256
|
if (!date) return "";
|
|
49
257
|
const iso = toIsoDate(date);
|
|
50
258
|
if (typeof format === "function") return format(iso);
|
|
51
259
|
if (format === "system_date") return iso;
|
|
260
|
+
if (textCalendar(calendar) !== "gregory") return formatCalendarDateText(plainDateFromDate(date), format ?? "date_long", locale, calendar);
|
|
52
261
|
return formatInstant(date, format ?? "date_long", locale);
|
|
53
262
|
}
|
|
54
263
|
/** 把字符串写法的状态展开成 `{ type }`,`default` 当作没有状态。 */
|
|
@@ -58,14 +267,812 @@ function resolveDateStatus(status) {
|
|
|
58
267
|
return status;
|
|
59
268
|
}
|
|
60
269
|
//#endregion
|
|
270
|
+
//#region src/utils/calendarDateLexicon.ts
|
|
271
|
+
const YEAR_ONLY_SAMPLE_YEAR = 2026;
|
|
272
|
+
const LONG_WITH_ERA = {
|
|
273
|
+
...LONG,
|
|
274
|
+
era: "long"
|
|
275
|
+
};
|
|
276
|
+
const LONG_WITH_WEEKDAY = {
|
|
277
|
+
...LONG,
|
|
278
|
+
weekday: "short"
|
|
279
|
+
};
|
|
280
|
+
const ERA_WIDTHS = {
|
|
281
|
+
long: {
|
|
282
|
+
era: "long",
|
|
283
|
+
year: "numeric"
|
|
284
|
+
},
|
|
285
|
+
short: {
|
|
286
|
+
era: "short",
|
|
287
|
+
year: "numeric"
|
|
288
|
+
},
|
|
289
|
+
narrow: {
|
|
290
|
+
era: "narrow",
|
|
291
|
+
year: "numeric"
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
const WEEKDAY_FORMATS = [
|
|
295
|
+
{ weekday: "long" },
|
|
296
|
+
{ weekday: "short" },
|
|
297
|
+
{
|
|
298
|
+
...LONG,
|
|
299
|
+
weekday: "long"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
...LONG,
|
|
303
|
+
weekday: "short"
|
|
304
|
+
}
|
|
305
|
+
];
|
|
306
|
+
const MONTH_WIDTHS = [
|
|
307
|
+
LONG,
|
|
308
|
+
{
|
|
309
|
+
year: "numeric",
|
|
310
|
+
month: "short",
|
|
311
|
+
day: "numeric"
|
|
312
|
+
},
|
|
313
|
+
NUMERIC,
|
|
314
|
+
{ month: "long" },
|
|
315
|
+
{ month: "short" }
|
|
316
|
+
];
|
|
317
|
+
const LETTER$1 = unicodeRegExp("[\\p{L}\\p{M}]");
|
|
318
|
+
const ONLY_SEPARATORS = unicodeRegExp("^[\\p{P}\\p{S}]+$");
|
|
319
|
+
const NOT_WORDS$1 = unicodeRegExp("[\\d\\p{P}\\p{S}]+", "gu");
|
|
320
|
+
/** 每个纪元里的一个公历日期。名字从 `Intl` 读,代码是 ECMA-402 的纪元标识。 */
|
|
321
|
+
const ERA_SAMPLES = {
|
|
322
|
+
"gregory": {
|
|
323
|
+
ce: "2000-06-15",
|
|
324
|
+
bce: "-000100-06-15"
|
|
325
|
+
},
|
|
326
|
+
"japanese": {
|
|
327
|
+
meiji: "1900-06-15",
|
|
328
|
+
taisho: "1920-06-15",
|
|
329
|
+
showa: "1950-06-15",
|
|
330
|
+
heisei: "2000-06-15",
|
|
331
|
+
reiwa: "2026-06-15"
|
|
332
|
+
},
|
|
333
|
+
"roc": {
|
|
334
|
+
roc: "2026-06-15",
|
|
335
|
+
broc: "1900-06-15"
|
|
336
|
+
},
|
|
337
|
+
"buddhist": { be: "2026-06-15" },
|
|
338
|
+
"ethiopic": {
|
|
339
|
+
am: "2026-06-15",
|
|
340
|
+
aa: "-005600-06-15"
|
|
341
|
+
},
|
|
342
|
+
"ethioaa": { aa: "2026-06-15" },
|
|
343
|
+
"coptic": { am: "2026-06-15" },
|
|
344
|
+
"persian": { ap: "2026-06-15" },
|
|
345
|
+
"hebrew": { am: "2026-06-15" },
|
|
346
|
+
"indian": { shaka: "2026-06-15" },
|
|
347
|
+
"islamic-umalqura": { ah: "2026-06-15" },
|
|
348
|
+
"islamic-civil": { ah: "2026-06-15" },
|
|
349
|
+
"islamic-tbla": { ah: "2026-06-15" }
|
|
350
|
+
};
|
|
351
|
+
function isoToPlainDate(iso) {
|
|
352
|
+
const match = /^(-?\d+)-(\d+)-(\d+)$/.exec(iso);
|
|
353
|
+
return {
|
|
354
|
+
year: +match[1],
|
|
355
|
+
month: +match[2],
|
|
356
|
+
day: +match[3]
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/** 农历闰月的键是平月的键加 "bis"。 */
|
|
360
|
+
function isLeapMonthKey(key) {
|
|
361
|
+
return key.endsWith("bis");
|
|
362
|
+
}
|
|
363
|
+
function commonMonthKey(key) {
|
|
364
|
+
return key.replace(/bis$/, "");
|
|
365
|
+
}
|
|
366
|
+
/** 用来学月份名的月:几个历法年的月份,闰月也能碰到。 */
|
|
367
|
+
function sampleMonths(calendar) {
|
|
368
|
+
if (isGregorianAligned(calendar)) return Array.from({ length: 12 }, (_, i) => ({
|
|
369
|
+
key: String(i + 1),
|
|
370
|
+
ordinal: i + 1,
|
|
371
|
+
mid: {
|
|
372
|
+
year: YEAR_ONLY_SAMPLE_YEAR,
|
|
373
|
+
month: i + 1,
|
|
374
|
+
day: 15
|
|
375
|
+
}
|
|
376
|
+
}));
|
|
377
|
+
const reference = calendarYearOf(calendar, {
|
|
378
|
+
year: YEAR_ONLY_SAMPLE_YEAR,
|
|
379
|
+
month: 6,
|
|
380
|
+
day: 15
|
|
381
|
+
});
|
|
382
|
+
const sampled = [];
|
|
383
|
+
for (let year = reference - 1; year <= reference + 3; year++) {
|
|
384
|
+
let month = calendarMonthFromYearMonth(calendar, {
|
|
385
|
+
year,
|
|
386
|
+
month: 1
|
|
387
|
+
});
|
|
388
|
+
const count = calendarMonthsInCalendarYear(calendar, year);
|
|
389
|
+
for (let ordinal = 1; ordinal <= count; ordinal++) {
|
|
390
|
+
sampled.push({
|
|
391
|
+
key: calendarMonthKey(calendar, month),
|
|
392
|
+
ordinal,
|
|
393
|
+
mid: calendarMonthLabelDay(month)
|
|
394
|
+
});
|
|
395
|
+
month = calendarAddMonths(calendar, month, 1);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return sampled;
|
|
399
|
+
}
|
|
400
|
+
const lexicons = /* @__PURE__ */ new Map();
|
|
401
|
+
/** 一种语言、一种历法的词表,第一次用到时建好并缓存。建一次要格式化几百个日期,适合在字段获得焦点时调用。 */
|
|
402
|
+
function getCalendarDateLexicon(locale, calendar) {
|
|
403
|
+
const resolved = textCalendar(calendar);
|
|
404
|
+
const key = `${locale}|${resolved}`;
|
|
405
|
+
let lexicon = lexicons.get(key);
|
|
406
|
+
if (lexicon == null) {
|
|
407
|
+
lexicon = buildLexicon(locale, resolved);
|
|
408
|
+
lexicons.set(key, lexicon);
|
|
409
|
+
}
|
|
410
|
+
return lexicon;
|
|
411
|
+
}
|
|
412
|
+
function learnMonths(draft, locales, calendar, sampled, norm) {
|
|
413
|
+
const addMonth = (text, { key, ordinal }) => {
|
|
414
|
+
const name = norm(text);
|
|
415
|
+
const match = /^(\D*)(\d+)(\D*)$/.exec(name);
|
|
416
|
+
const isOwnNumber = [ordinal, Number.parseInt(key, 10)].includes(Number(match?.[2]));
|
|
417
|
+
if (!name || /\d/.test(name) && (!LETTER$1.test(name) || isOwnNumber)) {
|
|
418
|
+
if (match != null && (match[1] || match[3])) draft.templates.set(`${match[1]}#${match[3]}`, {
|
|
419
|
+
pre: match[1],
|
|
420
|
+
post: match[3],
|
|
421
|
+
isLeap: isLeapMonthKey(key)
|
|
422
|
+
});
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
let keys = draft.months.get(name);
|
|
426
|
+
if (keys == null) {
|
|
427
|
+
keys = /* @__PURE__ */ new Set();
|
|
428
|
+
draft.months.set(name, keys);
|
|
429
|
+
}
|
|
430
|
+
keys.add(key);
|
|
431
|
+
};
|
|
432
|
+
const baseText = /* @__PURE__ */ new Map();
|
|
433
|
+
for (const month of sampled) for (const loc of locales) MONTH_WIDTHS.forEach((options, width) => {
|
|
434
|
+
const text = partsOf(loc, calendar, options, month.mid).find((part) => part.type === "month")?.value;
|
|
435
|
+
if (text == null) return;
|
|
436
|
+
const baseKey = `${loc}|${width}|${commonMonthKey(month.key)}`;
|
|
437
|
+
if (isLeapMonthKey(month.key)) {
|
|
438
|
+
const base = baseText.get(baseKey);
|
|
439
|
+
if (base != null && text.includes(base) && !/\d/.test(base)) {
|
|
440
|
+
const marker = norm(text.replace(base, ""));
|
|
441
|
+
if (marker) {
|
|
442
|
+
draft.leapMarkers.add(marker);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
} else baseText.set(baseKey, text);
|
|
447
|
+
addMonth(text, month);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
function learnLiterals(draft, locale, locales, calendar, sampled, norm) {
|
|
451
|
+
const addSkip = (text, words = draft.skip) => {
|
|
452
|
+
for (const word of norm(text).replace(NOT_WORDS$1, " ").split(/\s+/)) if (word) words.add(word);
|
|
453
|
+
};
|
|
454
|
+
const literalFormats = [];
|
|
455
|
+
for (const options of [
|
|
456
|
+
NUMERIC,
|
|
457
|
+
LONG,
|
|
458
|
+
SHARED_DATE_FORMAT_OPTIONS.date,
|
|
459
|
+
SHARED_DATE_FORMAT_OPTIONS.date_weekday,
|
|
460
|
+
LONG_WITH_WEEKDAY
|
|
461
|
+
]) literalFormats.push(options, displayOptions(locale, calendar, options));
|
|
462
|
+
const literalDates = sampled.slice(0, 14).map((month) => month.mid);
|
|
463
|
+
for (const loc of locales) {
|
|
464
|
+
for (const options of literalFormats) for (const pd of literalDates) {
|
|
465
|
+
const parts = partsOf(loc, calendar, options, pd);
|
|
466
|
+
for (const [k, part] of parts.entries()) {
|
|
467
|
+
if (part.type === "literal" || partType(part) === "yearName") addSkip(part.value);
|
|
468
|
+
if (part.type === "literal" && parts[k - 1]?.type === "year") addSkip(part.value, draft.yearMarkers);
|
|
469
|
+
}
|
|
470
|
+
const tail = parts.at(-1);
|
|
471
|
+
if (loc === locale && tail?.type === "literal") {
|
|
472
|
+
const trailer = norm(tail.value).replace(/\s+/g, "");
|
|
473
|
+
if (ONLY_SEPARATORS.test(trailer)) draft.trailers.add(trailer);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
for (let day = 0; day < 7; day++) {
|
|
477
|
+
const pd = {
|
|
478
|
+
year: YEAR_ONLY_SAMPLE_YEAR,
|
|
479
|
+
month: 11,
|
|
480
|
+
day: 1 + day
|
|
481
|
+
};
|
|
482
|
+
for (const options of WEEKDAY_FORMATS) {
|
|
483
|
+
const text = partsOf(loc, calendar, options, pd).find((part) => part.type === "weekday")?.value;
|
|
484
|
+
if (text != null) {
|
|
485
|
+
addSkip(text);
|
|
486
|
+
addSkip(text, draft.weekdays);
|
|
487
|
+
if (/\d/.test(norm(text))) draft.skip.add(norm(text));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
const hint = displayOptions(locale, calendar, NUMERIC);
|
|
493
|
+
for (const part of partsOf(locale, calendar, hint, literalDates[0])) {
|
|
494
|
+
const separator = norm(part.value).replace(/\s+/g, "");
|
|
495
|
+
if (part.type === "literal" && separator) draft.separators.add(separator);
|
|
496
|
+
}
|
|
497
|
+
if (LUNISOLAR.has(calendar)) {
|
|
498
|
+
for (let year = 1996; year < 2057; year++) for (const loc of locales) for (const part of partsOf(loc, calendar, LONG, {
|
|
499
|
+
year,
|
|
500
|
+
month: 6,
|
|
501
|
+
day: 15
|
|
502
|
+
})) if (partType(part) === "yearName") addSkip(part.value);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function learnEras(locale, locales, calendar, norm) {
|
|
506
|
+
const eras = /* @__PURE__ */ new Map();
|
|
507
|
+
const yearAliases = /* @__PURE__ */ new Map();
|
|
508
|
+
const eraArithmetic = /* @__PURE__ */ new Map();
|
|
509
|
+
const literalFormats = [
|
|
510
|
+
NUMERIC,
|
|
511
|
+
LONG,
|
|
512
|
+
SHARED_DATE_FORMAT_OPTIONS.date,
|
|
513
|
+
SHARED_DATE_FORMAT_OPTIONS.date_weekday,
|
|
514
|
+
LONG_WITH_WEEKDAY
|
|
515
|
+
].flatMap((options) => [options, displayOptions(locale, calendar, options)]);
|
|
516
|
+
const eraWidths = calendar === "japanese" ? [
|
|
517
|
+
"long",
|
|
518
|
+
"short",
|
|
519
|
+
"narrow"
|
|
520
|
+
] : ["long", "short"];
|
|
521
|
+
for (const [code, iso] of Object.entries(ERA_SAMPLES[calendar] ?? {})) {
|
|
522
|
+
const sample = isoToPlainDate(iso);
|
|
523
|
+
for (const loc of locales) for (const options of [...eraWidths.map((width) => ERA_WIDTHS[width]), ...literalFormats]) {
|
|
524
|
+
const text = partsOf(loc, calendar, options, sample).find((part) => part.type === "era")?.value;
|
|
525
|
+
if (text != null && norm(text)) eras.set(norm(text), code);
|
|
526
|
+
}
|
|
527
|
+
const eraYear = (pd) => calendarEraYear("en", calendar, pd).year;
|
|
528
|
+
const year = eraYear(sample);
|
|
529
|
+
const isForward = eraYear({
|
|
530
|
+
...sample,
|
|
531
|
+
year: sample.year + 1
|
|
532
|
+
}) > year;
|
|
533
|
+
const base = isForward ? sample.year - year : sample.year + year;
|
|
534
|
+
eraArithmetic.set(code, {
|
|
535
|
+
base,
|
|
536
|
+
isForward
|
|
537
|
+
});
|
|
538
|
+
const firstYear = {
|
|
539
|
+
year: isForward ? base + 1 : base - 1,
|
|
540
|
+
month: 12,
|
|
541
|
+
day: 31
|
|
542
|
+
};
|
|
543
|
+
if (isGregorianAligned(calendar) && firstYear.year > 0) {
|
|
544
|
+
const text = partsOf(locale, calendar, LONG_WITH_ERA, firstYear).find((part) => part.type === "year")?.value;
|
|
545
|
+
if (text != null && !/\d/.test(norm(text))) yearAliases.set(norm(text), "1");
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
if (calendar === "japanese") eraArithmetic.set("ce", {
|
|
549
|
+
base: 0,
|
|
550
|
+
isForward: true
|
|
551
|
+
});
|
|
552
|
+
return {
|
|
553
|
+
eras,
|
|
554
|
+
yearAliases,
|
|
555
|
+
eraArithmetic
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
/** 月份数字是序号(希伯来历)还是月份键的数字(农历)。用一个写数字的语言探一下。 */
|
|
559
|
+
function readsMonthOrdinal(calendar, sampled) {
|
|
560
|
+
const shifted = sampled.find((month) => month.ordinal !== Number.parseInt(month.key, 10));
|
|
561
|
+
if (shifted == null) return false;
|
|
562
|
+
const text = partsOf("sv", calendar, NUMERIC, shifted.mid).find((part) => part.type === "month")?.value;
|
|
563
|
+
return Number(normalizeDateText(text ?? "", "sv").replace(/\D+/g, "")) === shifted.ordinal;
|
|
564
|
+
}
|
|
565
|
+
function buildLexicon(locale, calendar) {
|
|
566
|
+
const locales = locale === "en" ? ["en"] : [locale, "en"];
|
|
567
|
+
const norm = (text) => normalizeDateText(text, locale).trim();
|
|
568
|
+
const draft = {
|
|
569
|
+
months: /* @__PURE__ */ new Map(),
|
|
570
|
+
templates: /* @__PURE__ */ new Map(),
|
|
571
|
+
leapMarkers: /* @__PURE__ */ new Set(),
|
|
572
|
+
skip: /* @__PURE__ */ new Set(),
|
|
573
|
+
trailers: /* @__PURE__ */ new Set(),
|
|
574
|
+
yearMarkers: /* @__PURE__ */ new Set(),
|
|
575
|
+
separators: /* @__PURE__ */ new Set(),
|
|
576
|
+
weekdays: /* @__PURE__ */ new Set()
|
|
577
|
+
};
|
|
578
|
+
const sampled = sampleMonths(calendar);
|
|
579
|
+
learnMonths(draft, locales, calendar, sampled, norm);
|
|
580
|
+
learnLiterals(draft, locale, locales, calendar, sampled, norm);
|
|
581
|
+
const { eras, yearAliases, eraArithmetic } = learnEras(locale, locales, calendar, norm);
|
|
582
|
+
for (const marker of draft.leapMarkers) draft.skip.delete(marker);
|
|
583
|
+
for (const word of [
|
|
584
|
+
...draft.months.keys(),
|
|
585
|
+
...eras.keys(),
|
|
586
|
+
...yearAliases.keys()
|
|
587
|
+
]) draft.skip.delete(word);
|
|
588
|
+
const vocabularySet = /* @__PURE__ */ new Set([
|
|
589
|
+
...draft.months.keys(),
|
|
590
|
+
...eras.keys(),
|
|
591
|
+
...draft.skip,
|
|
592
|
+
...draft.leapMarkers,
|
|
593
|
+
...yearAliases.keys()
|
|
594
|
+
]);
|
|
595
|
+
const sample = {
|
|
596
|
+
year: YEAR_ONLY_SAMPLE_YEAR,
|
|
597
|
+
month: 11,
|
|
598
|
+
day: 2
|
|
599
|
+
};
|
|
600
|
+
return {
|
|
601
|
+
locale,
|
|
602
|
+
calendar,
|
|
603
|
+
order: fieldOrder(partsOf(locale, calendar, NUMERIC, sample)),
|
|
604
|
+
nameOrder: fieldOrder(partsOf(locale, calendar, LONG, sample)),
|
|
605
|
+
months: draft.months,
|
|
606
|
+
monthTemplates: [...draft.templates.values()].sort((a, b) => b.pre.length + b.post.length - (a.pre.length + a.post.length)),
|
|
607
|
+
leapMarkers: draft.leapMarkers,
|
|
608
|
+
eras,
|
|
609
|
+
yearAliases,
|
|
610
|
+
trailers: draft.trailers,
|
|
611
|
+
yearMarkers: draft.yearMarkers,
|
|
612
|
+
separators: draft.separators,
|
|
613
|
+
weekdays: draft.weekdays,
|
|
614
|
+
vocabulary: [...vocabularySet].sort((a, b) => b.length - a.length),
|
|
615
|
+
vocabularySet,
|
|
616
|
+
isNumericMonthOrdinal: readsMonthOrdinal(calendar, sampled),
|
|
617
|
+
eraArithmetic
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/utils/calendarDateTokens.ts
|
|
622
|
+
const LETTER = unicodeRegExp("[\\p{L}\\p{M}]");
|
|
623
|
+
const SEPARATOR = unicodeRegExp("[\\p{P}\\p{S}]");
|
|
624
|
+
const NOT_WORDS = unicodeRegExp("[\\d\\p{P}\\p{S}]+", "gu");
|
|
625
|
+
const SPACELESS = unicodeRegExp("[\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\p{Script=Hangul}\\p{Script=Thai}\\p{Script=Lao}\\p{Script=Khmer}\\p{Script=Myanmar}]");
|
|
626
|
+
function tokenize(s, lex, isDigitNameRead = true) {
|
|
627
|
+
const out = [];
|
|
628
|
+
let hasDigitName = false;
|
|
629
|
+
let i = 0;
|
|
630
|
+
const end = s.trimEnd().length;
|
|
631
|
+
while (i < end) {
|
|
632
|
+
const ch = s[i];
|
|
633
|
+
if (/\s/.test(ch)) {
|
|
634
|
+
i++;
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
const template = matchTemplate(s, i, lex);
|
|
638
|
+
if (template != null) {
|
|
639
|
+
out.push(template.token);
|
|
640
|
+
i = template.end;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
const digitName = isDigitNameRead && /\d/.test(ch) && matchWord(s, i, lex);
|
|
644
|
+
if (digitName) {
|
|
645
|
+
out.push(wordToken(digitName, lex));
|
|
646
|
+
hasDigitName = true;
|
|
647
|
+
i += digitName.length;
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (/\d/.test(ch)) {
|
|
651
|
+
let j = i;
|
|
652
|
+
while (j < s.length && /\d/.test(s[j])) j++;
|
|
653
|
+
out.push({
|
|
654
|
+
t: "num",
|
|
655
|
+
v: s.slice(i, j)
|
|
656
|
+
});
|
|
657
|
+
i = j;
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
const word = matchWord(s, i, lex);
|
|
661
|
+
if (word != null) {
|
|
662
|
+
out.push(wordToken(word, lex));
|
|
663
|
+
i += word.length;
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
if (SEPARATOR.test(ch)) {
|
|
667
|
+
let j = i;
|
|
668
|
+
while (j < end && (SEPARATOR.test(s[j]) || /\s/.test(s[j]))) j++;
|
|
669
|
+
out.push({
|
|
670
|
+
t: "sep",
|
|
671
|
+
v: s.slice(i, j).replace(/\s+/g, "")
|
|
672
|
+
});
|
|
673
|
+
i = j;
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
let j = i;
|
|
677
|
+
while (j < end && LETTER.test(s[j])) j++;
|
|
678
|
+
const run = s.slice(i, j);
|
|
679
|
+
const joined = matchJoinedWord(s, i, lex);
|
|
680
|
+
if (joined != null) {
|
|
681
|
+
out.push(wordToken(joined, lex));
|
|
682
|
+
i += joined.length;
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
const keys = monthByPrefix(run, lex);
|
|
686
|
+
if (keys != null) {
|
|
687
|
+
out.push({
|
|
688
|
+
t: "month",
|
|
689
|
+
keys
|
|
690
|
+
});
|
|
691
|
+
i = j;
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
if (j >= end && run && lex.vocabulary.some((w) => w.startsWith(run))) return "incomplete";
|
|
695
|
+
return "unreadable";
|
|
696
|
+
}
|
|
697
|
+
const canBeDay = (token, k) => {
|
|
698
|
+
const next = out.slice(k + 1).find((t) => t.t !== "sep");
|
|
699
|
+
const isYear = next?.t === "word" && next.isYearMarker === true;
|
|
700
|
+
return token.t === "num" && Number(token.v) <= 31 && !isYear;
|
|
701
|
+
};
|
|
702
|
+
if (hasDigitName && !out.some(canBeDay)) return tokenize(s, lex, false);
|
|
703
|
+
return out;
|
|
704
|
+
}
|
|
705
|
+
function matchTemplate(s, i, lex) {
|
|
706
|
+
for (const template of lex.monthTemplates) {
|
|
707
|
+
if (!s.startsWith(template.pre, i)) continue;
|
|
708
|
+
const digits = /^\d+/.exec(s.slice(i + template.pre.length));
|
|
709
|
+
if (digits == null) continue;
|
|
710
|
+
const after = i + template.pre.length + digits[0].length;
|
|
711
|
+
if (template.post && !s.startsWith(template.post, after)) continue;
|
|
712
|
+
if (!template.post && !template.pre) continue;
|
|
713
|
+
return {
|
|
714
|
+
token: {
|
|
715
|
+
t: "monthNum",
|
|
716
|
+
v: digits[0],
|
|
717
|
+
isLeap: template.isLeap
|
|
718
|
+
},
|
|
719
|
+
end: after + template.post.length
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
return null;
|
|
723
|
+
}
|
|
724
|
+
/** 在 `i` 处最长的、结尾处可以断词的已知词。 */
|
|
725
|
+
function matchWord(s, i, lex) {
|
|
726
|
+
for (const word of lex.vocabulary) {
|
|
727
|
+
if (!s.startsWith(word, i)) continue;
|
|
728
|
+
const next = s[i + word.length] ?? "";
|
|
729
|
+
const last = word[word.length - 1];
|
|
730
|
+
if (!LETTER.test(next) || SPACELESS.test(next) || SPACELESS.test(last) || !LETTER.test(last)) return word;
|
|
731
|
+
}
|
|
732
|
+
return null;
|
|
733
|
+
}
|
|
734
|
+
/** 和下一个词连写的已知词,例如月份名前的希伯来文 ב,或者月份名后的闰月记号("Eighth Monthbis")。 */
|
|
735
|
+
function matchJoinedWord(s, i, lex) {
|
|
736
|
+
for (const word of lex.vocabulary) if (s.startsWith(word, i) && lex.vocabulary.some((w) => s.startsWith(w, i + word.length))) return word;
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
function wordToken(word, lex) {
|
|
740
|
+
const isWeekday = lex.weekdays.has(word.replace(NOT_WORDS, ""));
|
|
741
|
+
const keys = lex.months.get(word);
|
|
742
|
+
if (keys != null) return {
|
|
743
|
+
t: "month",
|
|
744
|
+
keys,
|
|
745
|
+
isWeekday
|
|
746
|
+
};
|
|
747
|
+
const era = lex.eras.get(word);
|
|
748
|
+
if (era != null) return {
|
|
749
|
+
t: "era",
|
|
750
|
+
code: era,
|
|
751
|
+
isWeekday
|
|
752
|
+
};
|
|
753
|
+
if (lex.leapMarkers.has(word)) return { t: "leap" };
|
|
754
|
+
const alias = lex.yearAliases.get(word);
|
|
755
|
+
if (alias != null) return {
|
|
756
|
+
t: "num",
|
|
757
|
+
v: alias,
|
|
758
|
+
isAlias: true
|
|
759
|
+
};
|
|
760
|
+
return {
|
|
761
|
+
t: "word",
|
|
762
|
+
isYearMarker: lex.yearMarkers.has(word)
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function sameKeys(a, b) {
|
|
766
|
+
return a.size === b.size && [...a].every((key) => b.has(key));
|
|
767
|
+
}
|
|
768
|
+
/** 打了一个月份名的开头,而且只有一个月份名这样开头时,就是那个月。 */
|
|
769
|
+
function monthByPrefix(run, lex) {
|
|
770
|
+
if (run.length < 3) return null;
|
|
771
|
+
let found = null;
|
|
772
|
+
for (const [name, keys] of lex.months) if (name.startsWith(run)) {
|
|
773
|
+
if (found != null && !sameKeys(found, keys)) return null;
|
|
774
|
+
found = keys;
|
|
775
|
+
}
|
|
776
|
+
return found;
|
|
777
|
+
}
|
|
778
|
+
/** 星期几的词也可能是月份名或纪元名(法语 "mar.")。文字里还有别的月份或纪元时,第一个这样的词是星期几。 */
|
|
779
|
+
function weekdaysAsWords(tokens) {
|
|
780
|
+
let out = tokens;
|
|
781
|
+
for (const kinds of [["month", "monthNum"], ["era"]]) {
|
|
782
|
+
const named = out.filter((t) => kinds.includes(t.t));
|
|
783
|
+
const weekday = named.find((t) => "isWeekday" in t && t.isWeekday);
|
|
784
|
+
if (named.length > 1 && weekday != null) out = out.map((t) => t === weekday ? { t: "word" } : t);
|
|
785
|
+
}
|
|
786
|
+
return out;
|
|
787
|
+
}
|
|
788
|
+
/** 数字之间的分隔符是不是同一种。语言自己的数字写法里的两种分隔符也算一种,例如印地语佛历的 "1/1`/2443"。 */
|
|
789
|
+
function sameSeparators(tokens, lex) {
|
|
790
|
+
let previous = null;
|
|
791
|
+
let seenNumber = false;
|
|
792
|
+
let pending = null;
|
|
793
|
+
for (const token of tokens) if (token.t === "num") {
|
|
794
|
+
if (seenNumber) {
|
|
795
|
+
const separator = pending ?? "";
|
|
796
|
+
if (previous != null && separator !== previous && !(lex.separators.has(separator) && lex.separators.has(previous))) return false;
|
|
797
|
+
previous = separator;
|
|
798
|
+
}
|
|
799
|
+
seenNumber = true;
|
|
800
|
+
pending = null;
|
|
801
|
+
} else if (token.t === "sep") pending = token.v;
|
|
802
|
+
else {
|
|
803
|
+
pending = null;
|
|
804
|
+
seenNumber = false;
|
|
805
|
+
previous = null;
|
|
806
|
+
}
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
function lastNumber(tokens) {
|
|
810
|
+
const last = tokens.filter((token) => token.t !== "sep").at(-1);
|
|
811
|
+
return last?.t === "num" ? last : void 0;
|
|
812
|
+
}
|
|
813
|
+
//#endregion
|
|
814
|
+
//#region src/utils/calendarDateParser.ts
|
|
815
|
+
const INCOMPLETE = { kind: "incomplete" };
|
|
816
|
+
const UNREADABLE = { kind: "unreadable" };
|
|
817
|
+
const EMPTY = { kind: "empty" };
|
|
818
|
+
/** 给数字分配年月日。有月份名时数字是年和日,没有时按语言的数字顺序。 */
|
|
819
|
+
function assignFields(tokens, nums, lex) {
|
|
820
|
+
const assigned = /* @__PURE__ */ new Map();
|
|
821
|
+
const monthToken = tokens.filter((token) => token.t === "month" || token.t === "monthNum")[0];
|
|
822
|
+
if (monthToken == null) {
|
|
823
|
+
if (nums.length < 2) return INCOMPLETE;
|
|
824
|
+
if (nums.length > 3 || !sameSeparators(tokens, lex)) return UNREADABLE;
|
|
825
|
+
let order = nums.length === 2 ? lex.order.filter((field) => field !== "year") : lex.order;
|
|
826
|
+
if (nums.length === 3 && order[0] !== "year" && nums[0].v.length >= 3) order = [
|
|
827
|
+
"year",
|
|
828
|
+
"month",
|
|
829
|
+
"day"
|
|
830
|
+
];
|
|
831
|
+
if (nums.length === 2 && nums.some((n) => n.v.length >= 3)) return INCOMPLETE;
|
|
832
|
+
nums.forEach((n, k) => assigned.set(n, order[k]));
|
|
833
|
+
return { assigned };
|
|
834
|
+
}
|
|
835
|
+
let monthKey;
|
|
836
|
+
let monthOrdinal;
|
|
837
|
+
if (monthToken.t === "month") {
|
|
838
|
+
if (monthToken.keys.size !== 1) return UNREADABLE;
|
|
839
|
+
monthKey = [...monthToken.keys][0];
|
|
840
|
+
} else if (monthToken.t === "monthNum") {
|
|
841
|
+
if (lex.isNumericMonthOrdinal) monthOrdinal = Number(monthToken.v);
|
|
842
|
+
else monthKey = String(Number(monthToken.v)) + (monthToken.isLeap ? "bis" : "");
|
|
843
|
+
}
|
|
844
|
+
if (nums.length === 0 || nums.length > 2) return nums.length === 0 ? INCOMPLETE : UNREADABLE;
|
|
845
|
+
let rest = lex.nameOrder.filter((field) => field !== "month");
|
|
846
|
+
const long = nums.filter((n) => n.v.length >= 3 && !n.isAlias);
|
|
847
|
+
if (nums.length === 1) rest = long.length === 1 ? ["year"] : ["day"];
|
|
848
|
+
else if (long.length === 1) rest = nums[0] === long[0] ? ["year", "day"] : ["day", "year"];
|
|
849
|
+
nums.forEach((n, k) => assigned.set(n, rest[k]));
|
|
850
|
+
return {
|
|
851
|
+
assigned,
|
|
852
|
+
monthKey,
|
|
853
|
+
monthOrdinal
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* 按词表的历法读打进来的文字,值是公历日期。结果分得清空字段、半截日期、读不成的文字、
|
|
858
|
+
* 历法里没有的日子、超出范围的日子和一个日期。
|
|
859
|
+
*/
|
|
860
|
+
function parseCalendarDate(text, lex, options = {}) {
|
|
861
|
+
const s = normalizeDateText(text, lex.locale).trim();
|
|
862
|
+
if (!s) return EMPTY;
|
|
863
|
+
const { isDateDisabled, isoIsGregorian = false } = options;
|
|
864
|
+
if (isoIsGregorian) {
|
|
865
|
+
const iso = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
|
|
866
|
+
if (iso != null) return finish(gregorianDate(+iso[1], +iso[2], +iso[3]), true, isDateDisabled);
|
|
867
|
+
}
|
|
868
|
+
const read = tokenize(s, lex);
|
|
869
|
+
if (read === "incomplete" || read === "unreadable") return read === "incomplete" ? INCOMPLETE : UNREADABLE;
|
|
870
|
+
const tokens = weekdaysAsWords(read);
|
|
871
|
+
const nums = tokens.filter((token) => token.t === "num");
|
|
872
|
+
const monthCount = tokens.filter((token) => token.t === "month" || token.t === "monthNum").length;
|
|
873
|
+
const eraCodes = new Set(tokens.flatMap((token) => token.t === "era" ? [token.code] : []));
|
|
874
|
+
const isLeap = tokens.some((token) => token.t === "leap" || token.t === "monthNum" && token.isLeap);
|
|
875
|
+
if (monthCount > 1 || eraCodes.size > 1) return UNREADABLE;
|
|
876
|
+
if (nums.length === 0 && monthCount === 0) return eraCodes.size > 0 ? INCOMPLETE : UNREADABLE;
|
|
877
|
+
const typedEra = eraCodes.size === 1 ? [...eraCodes][0] : void 0;
|
|
878
|
+
const fields = assignFields(tokens, nums, lex);
|
|
879
|
+
if ("kind" in fields) return fields;
|
|
880
|
+
const { assigned } = fields;
|
|
881
|
+
let { monthKey, monthOrdinal } = fields;
|
|
882
|
+
const tokenOf = (field) => nums.find((n) => assigned.get(n) === field);
|
|
883
|
+
const dayToken = tokenOf("day");
|
|
884
|
+
const yearToken = tokenOf("year");
|
|
885
|
+
const monthNumToken = tokenOf("month");
|
|
886
|
+
if (dayToken == null) return INCOMPLETE;
|
|
887
|
+
if (monthNumToken != null) {
|
|
888
|
+
if (lex.isNumericMonthOrdinal) monthOrdinal = Number(monthNumToken.v);
|
|
889
|
+
else monthKey = String(Number(monthNumToken.v));
|
|
890
|
+
}
|
|
891
|
+
if (monthKey != null && isLeap && !isLeapMonthKey(monthKey)) monthKey += "bis";
|
|
892
|
+
const day = Number(dayToken.v);
|
|
893
|
+
const monthNumber = monthOrdinal ?? (monthKey == null ? 0 : Number.parseInt(monthKey, 10) || 1);
|
|
894
|
+
if (day < 1 || day > 31 || monthNumber < 1 || monthNumber > 13) return [dayToken, monthNumToken].some((t) => t?.v === "0") ? INCOMPLETE : UNREADABLE;
|
|
895
|
+
const today = options.today ?? plainDateToday();
|
|
896
|
+
const dateFields = { day };
|
|
897
|
+
if (monthKey != null) dateFields.monthKey = monthKey;
|
|
898
|
+
else dateFields.month = monthOrdinal;
|
|
899
|
+
const year = readYear(dateFields, yearToken, typedEra, tokens, lex, today);
|
|
900
|
+
if (year === "incomplete" || year === "unreadable") return year === "incomplete" ? INCOMPLETE : UNREADABLE;
|
|
901
|
+
const date = resolveDate(lex, dateFields, today);
|
|
902
|
+
return finish(date, yearToken != null && year.isComplete && isLastFieldClosed(tokens, lex, assigned, date), isDateDisabled);
|
|
903
|
+
}
|
|
904
|
+
/** 把年份写进 `fields`。没打年份时用今天所在的年份;两位年份就近补世纪;和历、民国的短年份是纪元年。 */
|
|
905
|
+
function readYear(fields, yearToken, typedEra, tokens, lex, today) {
|
|
906
|
+
if (yearToken == null) {
|
|
907
|
+
applyDefaultYear(fields, lex, today);
|
|
908
|
+
return { isComplete: false };
|
|
909
|
+
}
|
|
910
|
+
const digits = yearToken.isAlias ? 1 : yearToken.v.length;
|
|
911
|
+
const year = Number(yearToken.v);
|
|
912
|
+
const isYearLast = lastNumber(tokens) === yearToken;
|
|
913
|
+
const { calendar } = lex;
|
|
914
|
+
if (typedEra != null) {
|
|
915
|
+
fields.era = typedEra;
|
|
916
|
+
fields.eraYear = year;
|
|
917
|
+
return { isComplete: true };
|
|
918
|
+
}
|
|
919
|
+
if (calendar === "japanese" && digits <= 2) {
|
|
920
|
+
const era = currentEra(lex, today);
|
|
921
|
+
if (era == null) return "unreadable";
|
|
922
|
+
fields.era = era;
|
|
923
|
+
fields.eraYear = year;
|
|
924
|
+
return { isComplete: !isYearLast };
|
|
925
|
+
}
|
|
926
|
+
if (calendar === "japanese" && digits === 4) {
|
|
927
|
+
fields.era = "ce";
|
|
928
|
+
fields.eraYear = year;
|
|
929
|
+
return { isComplete: true };
|
|
930
|
+
}
|
|
931
|
+
if (calendar === "roc") {
|
|
932
|
+
fields.era = "roc";
|
|
933
|
+
fields.eraYear = year;
|
|
934
|
+
return { isComplete: digits >= 4 || !isYearLast };
|
|
935
|
+
}
|
|
936
|
+
if (digits === 2) {
|
|
937
|
+
fields.year = windowedYear(year, calendarYearOf(calendar, today));
|
|
938
|
+
return { isComplete: false };
|
|
939
|
+
}
|
|
940
|
+
if (digits >= 4) {
|
|
941
|
+
fields.year = year;
|
|
942
|
+
return { isComplete: true };
|
|
943
|
+
}
|
|
944
|
+
return "incomplete";
|
|
945
|
+
}
|
|
946
|
+
function finish(date, isComplete, isDateDisabled) {
|
|
947
|
+
if (date == null) return {
|
|
948
|
+
kind: "nonexistent",
|
|
949
|
+
isComplete
|
|
950
|
+
};
|
|
951
|
+
if (isDateDisabled?.(date)) return {
|
|
952
|
+
kind: "outOfRange",
|
|
953
|
+
date,
|
|
954
|
+
isComplete
|
|
955
|
+
};
|
|
956
|
+
return {
|
|
957
|
+
kind: "value",
|
|
958
|
+
date,
|
|
959
|
+
isComplete
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function monthsInYearOf(lex, date) {
|
|
963
|
+
if (date == null) return 13;
|
|
964
|
+
return calendarMonthsInCalendarYear(lex.calendar, calendarYearMonthOf(lex.calendar, calendarMonthOf(lex.calendar, date)).year);
|
|
965
|
+
}
|
|
966
|
+
/** 文字是不是不会再长了:末尾没有分隔符,最后一个字段也接不了下一位数字。 */
|
|
967
|
+
function isLastFieldClosed(tokens, lex, assigned, date) {
|
|
968
|
+
const last = tokens.at(-1);
|
|
969
|
+
if (last == null) return false;
|
|
970
|
+
if (last.t === "sep") return lex.trailers.has(last.v);
|
|
971
|
+
if (last.t !== "num") return true;
|
|
972
|
+
const field = assigned.get(last);
|
|
973
|
+
if (field === "year" || last.v.length >= 2) return true;
|
|
974
|
+
const value = Number(last.v);
|
|
975
|
+
if (field === "day") return value * 10 > 31;
|
|
976
|
+
return value * 10 > monthsInYearOf(lex, date);
|
|
977
|
+
}
|
|
978
|
+
/** 两位年份补成离今年最近的世纪:最多往前 80 年、往后 19 年。 */
|
|
979
|
+
function windowedYear(twoDigits, current) {
|
|
980
|
+
let year = current - current % 100 + twoDigits;
|
|
981
|
+
if (year > current + 19) year -= 100;
|
|
982
|
+
else if (year < current - 80) year += 100;
|
|
983
|
+
return year;
|
|
984
|
+
}
|
|
985
|
+
function currentEra(lex, today) {
|
|
986
|
+
const { era } = calendarEraYear("en", lex.calendar, today);
|
|
987
|
+
return lex.eras.get(normalizeDateText(era, lex.locale).trim());
|
|
988
|
+
}
|
|
989
|
+
function applyDefaultYear(fields, lex, today) {
|
|
990
|
+
if (isGregorianAligned(lex.calendar) && lex.eraArithmetic.size > 0 && !WITHOUT_ERA.has(lex.calendar)) {
|
|
991
|
+
const { era, year } = calendarEraYear("en", lex.calendar, today);
|
|
992
|
+
const code = lex.eras.get(normalizeDateText(era, lex.locale).trim());
|
|
993
|
+
if (code != null) {
|
|
994
|
+
fields.era = code;
|
|
995
|
+
fields.eraYear = year;
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
fields.year = calendarYearOf(lex.calendar, today);
|
|
1000
|
+
}
|
|
1001
|
+
function gregorianDate(year, month, day) {
|
|
1002
|
+
if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 || day > getDaysInMonth(year, month)) return null;
|
|
1003
|
+
return {
|
|
1004
|
+
year,
|
|
1005
|
+
month,
|
|
1006
|
+
day
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
/** 月日跟公历不同的历法里,别的纪元的年份换成今天这个纪元的年份要加的数:埃塞俄比亚历的世界纪元比现行纪元多 5500 年。 */
|
|
1010
|
+
const ERA_YEAR_OFFSETS = { ethiopic: { aa: -5500 } };
|
|
1011
|
+
function yearInCurrentEra(lex, era, eraYear, today) {
|
|
1012
|
+
if (eraYear == null) return void 0;
|
|
1013
|
+
if (era === currentEra(lex, today)) return eraYear;
|
|
1014
|
+
const offset = ERA_YEAR_OFFSETS[lex.calendar]?.[era];
|
|
1015
|
+
return offset == null ? void 0 : eraYear + offset;
|
|
1016
|
+
}
|
|
1017
|
+
/** 历法字段对应的公历日期,这一天不存在时返回 null。 */
|
|
1018
|
+
function resolveDate(lex, fields, today) {
|
|
1019
|
+
const { calendar } = lex;
|
|
1020
|
+
if (!isGregorianAligned(calendar)) {
|
|
1021
|
+
const year = fields.era == null ? fields.year : yearInCurrentEra(lex, fields.era, fields.eraYear, today);
|
|
1022
|
+
if (year == null) return null;
|
|
1023
|
+
const date = fields.monthKey != null ? calendarDateFromMonthKey(calendar, {
|
|
1024
|
+
year,
|
|
1025
|
+
monthKey: fields.monthKey,
|
|
1026
|
+
day: fields.day
|
|
1027
|
+
}) : calendarDateFromFields(calendar, {
|
|
1028
|
+
year,
|
|
1029
|
+
month: fields.month ?? 0,
|
|
1030
|
+
day: fields.day
|
|
1031
|
+
});
|
|
1032
|
+
return date != null && date.year >= 1 && date.year <= 9999 ? date : null;
|
|
1033
|
+
}
|
|
1034
|
+
if (fields.monthKey != null && isLeapMonthKey(fields.monthKey)) return null;
|
|
1035
|
+
const month = fields.month ?? Number(fields.monthKey);
|
|
1036
|
+
let gregorianYear;
|
|
1037
|
+
if (fields.era != null) {
|
|
1038
|
+
const arithmetic = lex.eraArithmetic.get(fields.era);
|
|
1039
|
+
if (arithmetic == null || fields.eraYear == null || fields.eraYear < 1) return null;
|
|
1040
|
+
gregorianYear = arithmetic.isForward ? arithmetic.base + fields.eraYear : arithmetic.base - fields.eraYear;
|
|
1041
|
+
} else gregorianYear = (lex.eraArithmetic.get(calendar === "buddhist" ? "be" : "ce")?.base ?? 0) + (fields.year ?? 0);
|
|
1042
|
+
const date = gregorianDate(gregorianYear, month, fields.day);
|
|
1043
|
+
if (date == null || calendar !== "japanese" || fields.era === "ce") return date;
|
|
1044
|
+
const written = calendarEraYear("en", calendar, date);
|
|
1045
|
+
return lex.eras.get(normalizeDateText(written.era, lex.locale).trim()) === fields.era && written.year === fields.eraYear ? date : null;
|
|
1046
|
+
}
|
|
1047
|
+
//#endregion
|
|
61
1048
|
//#region src/DateInput/dateEntry.ts
|
|
62
1049
|
const ISO_DATE = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
63
1050
|
const ISO_PREFIX = /^\d{1,4}(?:-(?:\d{1,2}(?:-\d?)?)?)?$/;
|
|
1051
|
+
/** 按历法读:月份名、纪元和数字都按那种历法认,`system_date` 下 ISO 形状的文字仍是公历日期。 */
|
|
1052
|
+
function parseCalendarEntry(text, locale, isBlocked, calendar, format) {
|
|
1053
|
+
const result = parseCalendarDate(text, getCalendarDateLexicon(locale, calendar), {
|
|
1054
|
+
isoIsGregorian: format === "system_date",
|
|
1055
|
+
isDateDisabled: (date) => isBlocked(plainDateToDate(date))
|
|
1056
|
+
});
|
|
1057
|
+
switch (result.kind) {
|
|
1058
|
+
case "empty":
|
|
1059
|
+
case "incomplete": return { kind: "incomplete" };
|
|
1060
|
+
case "unreadable": return { kind: "unreadable" };
|
|
1061
|
+
case "nonexistent": return result.isComplete ? { kind: "nonexistent" } : { kind: "incomplete" };
|
|
1062
|
+
default: return {
|
|
1063
|
+
kind: result.kind,
|
|
1064
|
+
date: plainDateToDate(result.date),
|
|
1065
|
+
isComplete: result.isComplete
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
64
1069
|
/**
|
|
65
|
-
*
|
|
1070
|
+
* 读打进来的文字。公历下 `YYYY-M-D` 打完整(日子是两位,或者一位但不会再变)就算完整;
|
|
66
1071
|
* 还能接着打的 ISO 前缀算半截;其余文字交给 `parseDateInput`,读出来的日子只在 Enter 或失焦时提交。
|
|
1072
|
+
* 别的历法按那种历法的写法读。
|
|
67
1073
|
*/
|
|
68
|
-
function parseDateEntry(text, locale, isBlocked) {
|
|
1074
|
+
function parseDateEntry(text, locale, isBlocked, calendar = "gregory", format) {
|
|
1075
|
+
if (textCalendar(calendar) !== "gregory") return parseCalendarEntry(text, locale, isBlocked, calendar, format);
|
|
69
1076
|
const trimmed = text.trim();
|
|
70
1077
|
const iso = ISO_DATE.exec(trimmed);
|
|
71
1078
|
if (iso) {
|
|
@@ -126,12 +1133,12 @@ function toEntryError(result, text, bounds) {
|
|
|
126
1133
|
date: toIsoDate(result.date)
|
|
127
1134
|
};
|
|
128
1135
|
}
|
|
129
|
-
/**
|
|
130
|
-
function dateEntryMessage(result, bounds, format, locale, messages) {
|
|
1136
|
+
/** 拒绝时字段下方显示的那句话。边界日期按字段的显示格式和历法写,自定义格式函数时用长日期。 */
|
|
1137
|
+
function dateEntryMessage(result, bounds, format, locale, messages, calendar = "gregory") {
|
|
131
1138
|
if (result.kind === "nonexistent") return messages.nonexistentDate;
|
|
132
1139
|
if (result.kind === "outOfRange" || result.kind === "value") {
|
|
133
1140
|
const boundFormat = typeof format === "function" ? "date_long" : format;
|
|
134
|
-
const write = (date) => date ? formatCommittedDate(date, boundFormat, locale) : "";
|
|
1141
|
+
const write = (date) => date ? formatCommittedDate(date, boundFormat, locale, calendar) : "";
|
|
135
1142
|
const which = !isOutsideBounds(result.date, bounds) ? "other" : bounds.min != null && bounds.max != null ? "both" : bounds.min != null ? "min" : "max";
|
|
136
1143
|
return messages.outOfRangeDate(which, write(bounds.min), write(bounds.max));
|
|
137
1144
|
}
|
|
@@ -547,30 +1554,37 @@ const _sfc_main$3 = /*@__PURE__*/ defineComponent({
|
|
|
547
1554
|
};
|
|
548
1555
|
}
|
|
549
1556
|
});
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
return year * 12 + (month - 1);
|
|
1557
|
+
/** 月日跟公历不同的历法一个月一个月地数太慢,按平均月长折成天数。 */
|
|
1558
|
+
const REACH_DAYS = Math.round(18262.125);
|
|
1559
|
+
function isMonthBefore(a, b) {
|
|
1560
|
+
return plainDateIsBefore(a.start, b.start);
|
|
555
1561
|
}
|
|
556
|
-
function
|
|
557
|
-
|
|
558
|
-
return {
|
|
559
|
-
year,
|
|
560
|
-
month: index - year * 12 + 1
|
|
561
|
-
};
|
|
1562
|
+
function isMonthAfter(a, b) {
|
|
1563
|
+
return plainDateIsAfter(a.start, b.start);
|
|
562
1564
|
}
|
|
563
|
-
function
|
|
564
|
-
return
|
|
1565
|
+
function isMonthOutside(month, window) {
|
|
1566
|
+
return isMonthBefore(month, window.min) || isMonthAfter(month, window.max);
|
|
1567
|
+
}
|
|
1568
|
+
function clampMonth(month, window) {
|
|
1569
|
+
if (isMonthBefore(month, window.min)) return window.min;
|
|
1570
|
+
if (isMonthAfter(month, window.max)) return window.max;
|
|
1571
|
+
return month;
|
|
565
1572
|
}
|
|
566
1573
|
/** 底部面板能翻到的月份。最小和最大日期会把窗口收进去。 */
|
|
567
|
-
function
|
|
568
|
-
const now =
|
|
569
|
-
|
|
570
|
-
let
|
|
571
|
-
|
|
572
|
-
if (
|
|
573
|
-
|
|
1574
|
+
function reachableMonths(calendar, min, max, today) {
|
|
1575
|
+
const now = calendarMonthOf(calendar, plainDateFromDate(today));
|
|
1576
|
+
const reach = (direction) => isGregorianAligned(calendar) ? calendarAddMonths(calendar, now, direction * 600) : calendarMonthOf(calendar, plainDateAddDays(now.start, direction * REACH_DAYS));
|
|
1577
|
+
let low = reach(-1);
|
|
1578
|
+
let high = reach(1);
|
|
1579
|
+
if (min) {
|
|
1580
|
+
const first = calendarMonthOf(calendar, plainDateFromDate(min));
|
|
1581
|
+
if (isMonthAfter(first, low)) low = first;
|
|
1582
|
+
}
|
|
1583
|
+
if (max) {
|
|
1584
|
+
const last = calendarMonthOf(calendar, plainDateFromDate(max));
|
|
1585
|
+
if (isMonthBefore(last, high)) high = last;
|
|
1586
|
+
}
|
|
1587
|
+
if (isMonthAfter(low, high)) low = high;
|
|
574
1588
|
return {
|
|
575
1589
|
min: low,
|
|
576
1590
|
max: high
|
|
@@ -596,7 +1610,7 @@ const _hoisted_5$2 = { class: "astryx-calendar-day" };
|
|
|
596
1610
|
const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
597
1611
|
__name: "TouchMonthGrid",
|
|
598
1612
|
props: {
|
|
599
|
-
|
|
1613
|
+
calendar: {},
|
|
600
1614
|
month: {},
|
|
601
1615
|
selected: {},
|
|
602
1616
|
min: {},
|
|
@@ -614,7 +1628,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
614
1628
|
const weekStart = computed(() => weekStartIndex(props.weekStartsOn));
|
|
615
1629
|
const selectedDate = computed(() => props.selected ? toCalendarDate(props.selected) : null);
|
|
616
1630
|
const todayDate = computed(() => toCalendarDate(props.today));
|
|
617
|
-
const focused = shallowRef(
|
|
1631
|
+
const focused = shallowRef(toCalendarDay(props.month.start));
|
|
618
1632
|
const headers = computed(() => {
|
|
619
1633
|
const shorts = standaloneShortWeekdayNames(locale.value);
|
|
620
1634
|
const longs = weekdayNames(locale.value, "long");
|
|
@@ -626,8 +1640,8 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
626
1640
|
};
|
|
627
1641
|
});
|
|
628
1642
|
});
|
|
629
|
-
const weeks = computed(() =>
|
|
630
|
-
const label = computed(() =>
|
|
1643
|
+
const weeks = computed(() => buildMonthWeeks(props.calendar, props.month, weekStart.value, false));
|
|
1644
|
+
const label = computed(() => formatCalendarMonthLabel(props.calendar, props.month, locale.value));
|
|
631
1645
|
function blocked(date) {
|
|
632
1646
|
return isCalendarDateDisabled(date, {
|
|
633
1647
|
min: props.min,
|
|
@@ -636,10 +1650,10 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
636
1650
|
dateConstraints: props.dateConstraints
|
|
637
1651
|
});
|
|
638
1652
|
}
|
|
639
|
-
watch(() =>
|
|
640
|
-
if (focused.value
|
|
641
|
-
const
|
|
642
|
-
focused.value =
|
|
1653
|
+
watch(() => props.month, (month) => {
|
|
1654
|
+
if (isInCalendarMonth(focused.value, month)) return;
|
|
1655
|
+
const day = Math.min(calendarDayOfMonth(props.calendar, focused.value), month.length);
|
|
1656
|
+
focused.value = toCalendarDay(month.start).add({ days: day - 1 });
|
|
643
1657
|
}, { immediate: true });
|
|
644
1658
|
function pick(date, outside) {
|
|
645
1659
|
if (outside || blocked(date)) return;
|
|
@@ -653,15 +1667,19 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
653
1667
|
focused: focused.value,
|
|
654
1668
|
weekStartsOn: weekStart.value,
|
|
655
1669
|
numberOfMonths: 1,
|
|
656
|
-
|
|
657
|
-
|
|
1670
|
+
viewStart: toCalendarDay(props.month.start),
|
|
1671
|
+
calendar: props.calendar,
|
|
658
1672
|
isOutOfBounds: (date) => isOutsideCalendarBounds(date, props.min, props.max),
|
|
659
1673
|
isDisabled: (date) => blocked(date)
|
|
660
1674
|
});
|
|
661
1675
|
if (!move) return;
|
|
662
1676
|
event.preventDefault();
|
|
663
1677
|
focused.value = move.date;
|
|
664
|
-
if (move.date
|
|
1678
|
+
if (!isInCalendarMonth(move.date, props.month)) emit("update:view", {
|
|
1679
|
+
year: move.date.year,
|
|
1680
|
+
month: move.date.month,
|
|
1681
|
+
day: move.date.day
|
|
1682
|
+
});
|
|
665
1683
|
}
|
|
666
1684
|
return (_ctx, _cache) => {
|
|
667
1685
|
return openBlock(), createElementBlock("div", {
|
|
@@ -699,7 +1717,7 @@ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
|
|
|
699
1717
|
tabindex: !day.outside && unref(sameCalendarDay)(day.date, focused.value) ? 0 : -1,
|
|
700
1718
|
"aria-disabled": day.outside || blocked(day.date) || void 0,
|
|
701
1719
|
"aria-current": !day.outside && unref(sameCalendarDay)(day.date, todayDate.value) ? "date" : void 0,
|
|
702
|
-
"aria-label": unref(formatWeekdayDate)(day.date, unref(locale)),
|
|
1720
|
+
"aria-label": unref(formatWeekdayDate)(day.date, unref(locale), __props.calendar),
|
|
703
1721
|
onClick: ($event) => pick(day.date, day.outside)
|
|
704
1722
|
}, [createElementVNode("span", _hoisted_5$2, toDisplayString(unref(formatDayNumber)(day.day, unref(locale))), 1)], 10, _hoisted_4$2)]);
|
|
705
1723
|
}), 128))]);
|
|
@@ -735,6 +1753,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
735
1753
|
isDateDisabled: {},
|
|
736
1754
|
dateConstraints: {},
|
|
737
1755
|
weekStartsOn: {},
|
|
1756
|
+
calendar: {},
|
|
738
1757
|
saveLabel: {},
|
|
739
1758
|
saveDisabled: {
|
|
740
1759
|
type: Boolean,
|
|
@@ -758,6 +1777,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
758
1777
|
dateInput: dateInputMessages
|
|
759
1778
|
});
|
|
760
1779
|
const locale = useAstryxLocale();
|
|
1780
|
+
const calendar = useCalendarSystem(() => props.calendar, "DateInput");
|
|
761
1781
|
const wheelsOpen = ref(false);
|
|
762
1782
|
const dragX = ref(null);
|
|
763
1783
|
const coarse = useMediaQuery("(pointer: coarse)");
|
|
@@ -765,45 +1785,56 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
765
1785
|
const prevRef = useTemplateRef("prev");
|
|
766
1786
|
const nextRef = useTemplateRef("next");
|
|
767
1787
|
const today = shallowRef(null);
|
|
768
|
-
const range = computed(() =>
|
|
769
|
-
|
|
770
|
-
const
|
|
1788
|
+
const range = computed(() => reachableMonths(calendar.value, props.min, props.max, today.value ?? /* @__PURE__ */ new Date()));
|
|
1789
|
+
/** 面板显示的历法月,挂载后才有。 */
|
|
1790
|
+
const view = shallowRef(null);
|
|
1791
|
+
function monthContaining(date) {
|
|
1792
|
+
return clampMonth(calendarMonthOf(calendar.value, date instanceof Date ? plainDateFromDate(date) : date), range.value);
|
|
1793
|
+
}
|
|
771
1794
|
onMounted(() => {
|
|
772
1795
|
const now = /* @__PURE__ */ new Date();
|
|
773
|
-
const opening = props.selected ?? now;
|
|
774
1796
|
today.value = now;
|
|
775
|
-
view.value =
|
|
1797
|
+
view.value = monthContaining(props.selected ?? now);
|
|
1798
|
+
});
|
|
1799
|
+
watch(calendar, () => {
|
|
1800
|
+
if (view.value) view.value = monthContaining(view.value.start);
|
|
1801
|
+
});
|
|
1802
|
+
const cursor = computed(() => view.value ? calendarYearMonthOf(calendar.value, view.value) : {
|
|
1803
|
+
year: 0,
|
|
1804
|
+
month: 1
|
|
776
1805
|
});
|
|
777
|
-
const monthLabel = computed(() =>
|
|
1806
|
+
const monthLabel = computed(() => view.value ? formatCalendarMonthLabel(calendar.value, view.value, locale.value) : "");
|
|
778
1807
|
const resolvedSaveLabel = computed(() => props.saveLabel ?? messages.value.dateInput.savePicking);
|
|
779
1808
|
const rtl = computed(() => typeof document !== "undefined" && document.documentElement.dir === "rtl");
|
|
780
|
-
const canPrev = computed(() => view.value
|
|
781
|
-
const canNext = computed(() => view.value
|
|
1809
|
+
const canPrev = computed(() => view.value != null && isMonthAfter(view.value, range.value.min));
|
|
1810
|
+
const canNext = computed(() => view.value != null && isMonthBefore(view.value, range.value.max));
|
|
782
1811
|
const prevIcon = computed(() => rtl.value ? "chevronRight" : "chevronLeft");
|
|
783
1812
|
const nextIcon = computed(() => rtl.value ? "chevronLeft" : "chevronRight");
|
|
784
1813
|
const monthOptions = computed(() => {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
const
|
|
1814
|
+
if (!view.value) return [];
|
|
1815
|
+
const { year } = cursor.value;
|
|
1816
|
+
return Array.from({ length: calendarMonthsInCalendarYear(calendar.value, year) }, (_, index) => {
|
|
1817
|
+
const month = calendarMonthFromYearMonth(calendar.value, {
|
|
1818
|
+
year,
|
|
1819
|
+
month: index + 1
|
|
1820
|
+
});
|
|
789
1821
|
return {
|
|
790
|
-
value: String(
|
|
791
|
-
label:
|
|
792
|
-
disabled:
|
|
1822
|
+
value: String(index + 1),
|
|
1823
|
+
label: formatCalendarMonthName(calendar.value, month, locale.value),
|
|
1824
|
+
disabled: isMonthOutside(month, range.value)
|
|
793
1825
|
};
|
|
794
1826
|
});
|
|
795
1827
|
});
|
|
796
1828
|
const yearOptions = computed(() => {
|
|
797
|
-
|
|
798
|
-
const
|
|
1829
|
+
if (!view.value) return [];
|
|
1830
|
+
const start = calendarYearMonthOf(calendar.value, range.value.min).year;
|
|
1831
|
+
const end = calendarYearMonthOf(calendar.value, range.value.max).year;
|
|
799
1832
|
const options = [];
|
|
800
1833
|
for (let year = start; year <= end; year += 1) {
|
|
801
|
-
const
|
|
802
|
-
const december = monthIndex(year, 12);
|
|
1834
|
+
const at = year === cursor.value.year ? view.value : void 0;
|
|
803
1835
|
options.push({
|
|
804
1836
|
value: String(year),
|
|
805
|
-
label:
|
|
806
|
-
disabled: december < range.value.min || january > range.value.max
|
|
1837
|
+
label: formatCalendarYearLabel(calendar.value, year, locale.value, at)
|
|
807
1838
|
});
|
|
808
1839
|
}
|
|
809
1840
|
return options;
|
|
@@ -813,8 +1844,8 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
813
1844
|
* 焦点在它上面时,先等另一个箭头画出来,再把焦点交给它;两个箭头都消失就交给月份标题。
|
|
814
1845
|
*/
|
|
815
1846
|
function showMonth(target) {
|
|
816
|
-
const prevHides = target
|
|
817
|
-
const nextHides = target
|
|
1847
|
+
const prevHides = !isMonthAfter(target, range.value.min);
|
|
1848
|
+
const nextHides = !isMonthBefore(target, range.value.max);
|
|
818
1849
|
const active = typeof document === "undefined" ? null : document.activeElement;
|
|
819
1850
|
const onPrev = prevHides && active != null && active === prevRef.value;
|
|
820
1851
|
const onNext = nextHides && active != null && active === nextRef.value;
|
|
@@ -826,7 +1857,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
826
1857
|
});
|
|
827
1858
|
}
|
|
828
1859
|
function move(amount) {
|
|
829
|
-
showMonth(
|
|
1860
|
+
if (view.value) showMonth(clampMonth(calendarAddMonths(calendar.value, view.value, amount), range.value));
|
|
830
1861
|
}
|
|
831
1862
|
function allowed(date) {
|
|
832
1863
|
return !isCalendarDateDisabled(toCalendarDate(date), {
|
|
@@ -844,30 +1875,32 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
844
1875
|
function carrySelection(target) {
|
|
845
1876
|
const selected = props.selected;
|
|
846
1877
|
if (!coarse.value || !selected) return;
|
|
847
|
-
const
|
|
848
|
-
|
|
849
|
-
let date = new Date(year, month - 1, Math.min(selected.getDate(), lastDay));
|
|
1878
|
+
const day = Math.min(calendarDayOfMonth(calendar.value, plainDateFromDate(selected)), target.length);
|
|
1879
|
+
let date = plainDateToDate(plainDateAddDays(target.start, day - 1));
|
|
850
1880
|
if (props.min && date < props.min) date = new Date(props.min.getFullYear(), props.min.getMonth(), props.min.getDate());
|
|
851
1881
|
if (props.max && date > props.max) date = new Date(props.max.getFullYear(), props.max.getMonth(), props.max.getDate());
|
|
852
1882
|
if (allowed(date) && date.getTime() !== selected.getTime()) emit("pick", date);
|
|
853
1883
|
}
|
|
854
1884
|
function setMonth(value) {
|
|
855
|
-
const target =
|
|
856
|
-
|
|
1885
|
+
const target = calendarMonthFromYearMonth(calendar.value, {
|
|
1886
|
+
year: cursor.value.year,
|
|
1887
|
+
month: Number(value)
|
|
1888
|
+
});
|
|
1889
|
+
if (isMonthOutside(target, range.value)) return;
|
|
857
1890
|
view.value = target;
|
|
858
1891
|
carrySelection(target);
|
|
859
1892
|
}
|
|
860
1893
|
function setYear(value) {
|
|
1894
|
+
if (!view.value) return;
|
|
861
1895
|
const year = Number(value);
|
|
862
|
-
const target =
|
|
863
|
-
if (
|
|
1896
|
+
const target = monthContaining(calendarShiftYears(calendar.value, view.value.start, year - cursor.value.year));
|
|
1897
|
+
if (calendarYearMonthOf(calendar.value, target).year !== year) return;
|
|
864
1898
|
view.value = target;
|
|
865
1899
|
carrySelection(target);
|
|
866
1900
|
}
|
|
867
1901
|
function onReset() {
|
|
868
1902
|
if (props.isDisabled) return;
|
|
869
|
-
|
|
870
|
-
view.value = clampMonthIndex(monthIndex(now.getFullYear(), now.getMonth() + 1), range.value.min, range.value.max);
|
|
1903
|
+
view.value = monthContaining(/* @__PURE__ */ new Date());
|
|
871
1904
|
wheelsOpen.value = false;
|
|
872
1905
|
emit("reset");
|
|
873
1906
|
}
|
|
@@ -881,11 +1914,11 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
881
1914
|
if (Math.abs(delta) < 48) return;
|
|
882
1915
|
move((rtl.value ? delta > 0 : delta < 0) ? 1 : -1);
|
|
883
1916
|
}
|
|
884
|
-
function onView(
|
|
885
|
-
showMonth(
|
|
1917
|
+
function onView(date) {
|
|
1918
|
+
showMonth(monthContaining(date));
|
|
886
1919
|
}
|
|
887
1920
|
return (_ctx, _cache) => {
|
|
888
|
-
return today.value ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
1921
|
+
return today.value && view.value ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
889
1922
|
createElementVNode("div", _hoisted_2$1, [createElementVNode("button", {
|
|
890
1923
|
ref: "title",
|
|
891
1924
|
type: "button",
|
|
@@ -945,8 +1978,8 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
945
1978
|
onPointerdown: onPointerDown,
|
|
946
1979
|
onPointerup: onPointerUp
|
|
947
1980
|
}, [createVNode(_sfc_main$2, {
|
|
948
|
-
|
|
949
|
-
month:
|
|
1981
|
+
calendar: unref(calendar),
|
|
1982
|
+
month: view.value,
|
|
950
1983
|
selected: __props.selected,
|
|
951
1984
|
min: __props.min,
|
|
952
1985
|
max: __props.max,
|
|
@@ -957,7 +1990,7 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
|
|
|
957
1990
|
onPick: _cache[3] || (_cache[3] = ($event) => emit("pick", $event)),
|
|
958
1991
|
"onUpdate:view": onView
|
|
959
1992
|
}, null, 8, [
|
|
960
|
-
"
|
|
1993
|
+
"calendar",
|
|
961
1994
|
"month",
|
|
962
1995
|
"selected",
|
|
963
1996
|
"min",
|
|
@@ -1032,6 +2065,51 @@ function useCalendarDismiss(options) {
|
|
|
1032
2065
|
return { onFieldFocusOut };
|
|
1033
2066
|
}
|
|
1034
2067
|
//#endregion
|
|
2068
|
+
//#region src/DateInput/useCalendarPresentation.ts
|
|
2069
|
+
/** 日期字段的历法,以及这种历法允许的打开方式。显式传了 `native` 却用不上时开发期警告一次。 */
|
|
2070
|
+
function useCalendarPresentation(options) {
|
|
2071
|
+
const calendar = useCalendarSystem(options.calendar, options.source);
|
|
2072
|
+
const isNativeCalendar = computed(() => isGregorianCalendar(calendar.value));
|
|
2073
|
+
watch(() => options.presentation() === "native" && !isNativeCalendar.value, (overridden) => {
|
|
2074
|
+
if (!overridden) return;
|
|
2075
|
+
warnCalendarOnce(`presentation-native-calendar:${options.source}:${calendar.value}`, options.source, `presentation="native" shows the Astryx picker in the "${calendar.value}" calendar, because the native date control shows only Gregorian dates: the popover on a fine pointer and the bottom sheet on a coarse pointer.`);
|
|
2076
|
+
}, { immediate: true });
|
|
2077
|
+
return {
|
|
2078
|
+
calendar,
|
|
2079
|
+
presentation: computed(() => calendarPickerPresentation(resolveDatePresentation(options.presentation(), options.nativePicker?.()), isNativeCalendar.value))
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
/** 今天;字段不收今天时取离今天最近的能选的日子。一年内都找不到时取收进范围的今天。 */
|
|
2083
|
+
function nearestAcceptedDate(today, options) {
|
|
2084
|
+
const min = options.min();
|
|
2085
|
+
const max = options.max();
|
|
2086
|
+
let start = today;
|
|
2087
|
+
if (min != null && isOutsideBounds(start, { min })) start = new Date(min.getFullYear(), min.getMonth(), min.getDate());
|
|
2088
|
+
if (max != null && isOutsideBounds(start, { max })) start = new Date(max.getFullYear(), max.getMonth(), max.getDate());
|
|
2089
|
+
for (let offset = 0; offset <= 366; offset += 1) for (const sign of offset === 0 ? [1] : [1, -1]) {
|
|
2090
|
+
const candidate = new Date(start.getFullYear(), start.getMonth(), start.getDate() + sign * offset);
|
|
2091
|
+
if (!isOutsideBounds(candidate, {
|
|
2092
|
+
min,
|
|
2093
|
+
max
|
|
2094
|
+
}) && !options.isBlocked(candidate)) return candidate;
|
|
2095
|
+
}
|
|
2096
|
+
return start;
|
|
2097
|
+
}
|
|
2098
|
+
/** 日期字段按历法补充的文字:格式提示和读屏说明。 */
|
|
2099
|
+
function useCalendarFieldText(options) {
|
|
2100
|
+
const providerCalendar = useCalendarSystem();
|
|
2101
|
+
const isProviderCalendar = computed(() => isGregorianCalendar(options.calendar.value) ? isGregorianCalendar(providerCalendar.value) : options.calendar.value === providerCalendar.value);
|
|
2102
|
+
return {
|
|
2103
|
+
formatHint: () => {
|
|
2104
|
+
if (isGregorianCalendar(options.calendar.value)) return null;
|
|
2105
|
+
const now = /* @__PURE__ */ new Date();
|
|
2106
|
+
const example = nearestAcceptedDate(new Date(now.getFullYear(), now.getMonth(), now.getDate()), options);
|
|
2107
|
+
return options.messages().formatHint(formatCalendarDateHint(plainDateFromDate(example), options.locale(), options.calendar.value));
|
|
2108
|
+
},
|
|
2109
|
+
calendarDescription: computed(() => isProviderCalendar.value ? null : options.messages().calendarDescription(calendarDisplayName(options.calendar.value, options.locale())))
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
//#endregion
|
|
1035
2113
|
//#region src/DateInput/useTypedDateEntry.ts
|
|
1036
2114
|
/**
|
|
1037
2115
|
* 日期文本框的打字状态:显示的文字、拒绝和提交。
|
|
@@ -1052,10 +2130,11 @@ function useTypedDateEntry(options) {
|
|
|
1052
2130
|
let reported = null;
|
|
1053
2131
|
/** Enter 或失焦刚刚留下被拒的文字。这一刻传进来的新值不顶掉文字,调用方可以在这里恢复自己的值。 */
|
|
1054
2132
|
let isRevealing = false;
|
|
2133
|
+
const calendar = () => options.calendar?.() ?? "gregory";
|
|
1055
2134
|
function parse(text) {
|
|
1056
|
-
return parseDateEntry(text, options.locale(), options.isBlocked);
|
|
2135
|
+
return parseDateEntry(text, options.locale(), options.isBlocked, calendar(), options.format());
|
|
1057
2136
|
}
|
|
1058
|
-
const committedText = computed(() => formatCommittedDate(options.value(), options.format(), options.locale()));
|
|
2137
|
+
const committedText = computed(() => formatCommittedDate(options.value(), options.format(), options.locale(), calendar()));
|
|
1059
2138
|
const displayValue = computed(() => pending.value ?? committedText.value);
|
|
1060
2139
|
const typed = computed(() => pending.value !== null && pending.value.trim() ? parse(pending.value) : null);
|
|
1061
2140
|
const ownError = computed(() => dateEntryErrorKind(typed.value, isRejectionCommitted.value, options.behavior()));
|
|
@@ -1072,7 +2151,7 @@ function useTypedDateEntry(options) {
|
|
|
1072
2151
|
result: kept
|
|
1073
2152
|
} : null;
|
|
1074
2153
|
});
|
|
1075
|
-
const message = computed(() => shown.value ? dateEntryMessage(shown.value.result, options.bounds(), options.format(), options.locale(), options.messages()) : null);
|
|
2154
|
+
const message = computed(() => shown.value ? dateEntryMessage(shown.value.result, options.bounds(), options.format(), options.locale(), options.messages(), calendar()) : null);
|
|
1076
2155
|
const entryError = computed(() => shown.value ? toEntryError(shown.value.result, shown.value.text, options.bounds()) : null);
|
|
1077
2156
|
const callerError = computed(() => {
|
|
1078
2157
|
const status = options.status();
|
|
@@ -1161,6 +2240,7 @@ function useTypedDateEntry(options) {
|
|
|
1161
2240
|
displayValue,
|
|
1162
2241
|
isPending: computed(() => pending.value !== null && !(isRejectionCommitted.value && typed.value?.kind === "unreadable")),
|
|
1163
2242
|
isInvalid: computed(() => shown.value != null),
|
|
2243
|
+
isFocused: computed(() => isFocused.value),
|
|
1164
2244
|
fieldStatus,
|
|
1165
2245
|
alertMessage,
|
|
1166
2246
|
onInput,
|
|
@@ -1221,7 +2301,6 @@ const _hoisted_10 = {
|
|
|
1221
2301
|
role: "alert"
|
|
1222
2302
|
};
|
|
1223
2303
|
const _hoisted_11 = ["name", "value"];
|
|
1224
|
-
const TOUCH_POINTER_QUERY = "(pointer: coarse)";
|
|
1225
2304
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
1226
2305
|
name: "AstryxDateInput",
|
|
1227
2306
|
inheritAttrs: false,
|
|
@@ -1271,6 +2350,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1271
2350
|
nativePicker: {},
|
|
1272
2351
|
numberOfMonths: { default: 1 },
|
|
1273
2352
|
weekStartsOn: {},
|
|
2353
|
+
calendar: {},
|
|
1274
2354
|
width: {},
|
|
1275
2355
|
entryErrorBehavior: {},
|
|
1276
2356
|
containerClass: { type: [
|
|
@@ -1339,19 +2419,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1339
2419
|
});
|
|
1340
2420
|
const hideLabel = useResolvedLabelHidden(() => props.isLabelHidden, () => props.labelHidden);
|
|
1341
2421
|
const ariaRequired = useAriaRequired(props);
|
|
1342
|
-
const PassThrough = defineComponent({
|
|
1343
|
-
name: "DateInputPassThrough",
|
|
1344
|
-
setup(_, { slots }) {
|
|
1345
|
-
return () => slots.default?.({});
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
1348
2422
|
const generatedId = `astryx-date-input-${useId()}`;
|
|
1349
2423
|
const inputId = computed(() => props.id ?? generatedId);
|
|
1350
2424
|
const popupId = computed(() => `${inputId.value}-popup`);
|
|
1351
2425
|
const messages = useComponentMessages({ dateInput: dateInputMessages });
|
|
1352
2426
|
const locale = useAstryxLocale();
|
|
1353
|
-
const isCoarsePointer = useMediaQuery(
|
|
1354
|
-
const resolvedPlaceholder = computed(() => props.placeholder ?? messages.value.dateInput.placeholder);
|
|
2427
|
+
const isCoarsePointer = useMediaQuery("(pointer: coarse)");
|
|
1355
2428
|
const resolvedClearLabel = computed(() => props.clearLabel ?? messages.value.dateInput.clear(props.label));
|
|
1356
2429
|
const dialogLabel = computed(() => props.label || messages.value.dateInput.dialogLabel);
|
|
1357
2430
|
const inputRef = useTemplateRef("inputRef");
|
|
@@ -1366,7 +2439,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1366
2439
|
const showsDisabledMessage = computed(() => locked.value && disabledMessage.value != null);
|
|
1367
2440
|
const disabledTooltip = useButtonTooltip(showsDisabledMessage);
|
|
1368
2441
|
const showsClear = computed(() => (props.hasClear || props.clearable) && Boolean(props.modelValue) && !locked.value);
|
|
1369
|
-
const policy =
|
|
2442
|
+
const { calendar, presentation: policy } = useCalendarPresentation({
|
|
2443
|
+
source: "DateInput",
|
|
2444
|
+
calendar: () => props.calendar,
|
|
2445
|
+
presentation: () => props.presentation,
|
|
2446
|
+
nativePicker: () => props.nativePicker
|
|
2447
|
+
});
|
|
1370
2448
|
const surface = computed(() => resolveDateSurface(policy.value, isCoarsePointer.value));
|
|
1371
2449
|
const useSheet = computed(() => surface.value === "sheet");
|
|
1372
2450
|
const popupWidth = computed(() => props.numberOfMonths === 2 ? "min(36rem, calc(100vw - 16px))" : 280);
|
|
@@ -1413,6 +2491,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1413
2491
|
value: () => props.modelValue,
|
|
1414
2492
|
format: () => props.format,
|
|
1415
2493
|
locale: () => locale.value,
|
|
2494
|
+
calendar: () => calendar.value,
|
|
1416
2495
|
bounds: () => ({
|
|
1417
2496
|
min: props.min,
|
|
1418
2497
|
max: props.max
|
|
@@ -1427,10 +2506,20 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1427
2506
|
reportEntryError: (error) => emit("entryErrorChange", error)
|
|
1428
2507
|
});
|
|
1429
2508
|
const inputValue = entry.displayValue;
|
|
2509
|
+
const calendarText = useCalendarFieldText({
|
|
2510
|
+
calendar,
|
|
2511
|
+
locale: () => locale.value,
|
|
2512
|
+
messages: () => messages.value.dateInput,
|
|
2513
|
+
min: () => props.min,
|
|
2514
|
+
max: () => props.max,
|
|
2515
|
+
isBlocked: (date) => !allowed(date)
|
|
2516
|
+
});
|
|
2517
|
+
const calendarDescriptionId = `${generatedId}-calendar`;
|
|
2518
|
+
const resolvedPlaceholder = computed(() => props.placeholder ?? (entry.isFocused.value && !inputValue.value && calendarText.formatHint() || messages.value.dateInput.placeholder));
|
|
1430
2519
|
const statusValue = entry.fieldStatus;
|
|
1431
2520
|
const statusType = computed(() => statusValue.value?.type);
|
|
1432
2521
|
const showsField = computed(() => Boolean(props.label || props.description || statusValue.value?.message));
|
|
1433
|
-
const shell = computed(() => showsField.value ? _sfc_main$11 :
|
|
2522
|
+
const shell = computed(() => showsField.value ? _sfc_main$11 : DateInputPassThrough_default);
|
|
1434
2523
|
const fieldBindings = computed(() => showsField.value ? {
|
|
1435
2524
|
label: props.label ?? "",
|
|
1436
2525
|
inputId: inputId.value,
|
|
@@ -1446,10 +2535,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1446
2535
|
} : {});
|
|
1447
2536
|
const toggleLabel = computed(() => isOpen.value ? messages.value.dateInput.closeCalendar : messages.value.dateInput.openCalendar);
|
|
1448
2537
|
function describedBy(fieldIds) {
|
|
2538
|
+
const calendarId = calendarText.calendarDescription.value ? calendarDescriptionId : void 0;
|
|
1449
2539
|
return [
|
|
1450
2540
|
attrs["aria-describedby"],
|
|
1451
2541
|
props.describedBy,
|
|
1452
2542
|
fieldIds,
|
|
2543
|
+
calendarId,
|
|
1453
2544
|
showsDisabledMessage.value ? disabledMessageId : void 0
|
|
1454
2545
|
].filter(Boolean).join(" ") || void 0;
|
|
1455
2546
|
}
|
|
@@ -1642,6 +2733,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1642
2733
|
"date-constraints": props.dateConstraints,
|
|
1643
2734
|
"number-of-months": props.numberOfMonths,
|
|
1644
2735
|
"week-starts-on": props.weekStartsOn,
|
|
2736
|
+
calendar: unref(calendar),
|
|
1645
2737
|
"onUpdate:modelValue": onCalendarChange
|
|
1646
2738
|
}, null, 8, [
|
|
1647
2739
|
"model-value",
|
|
@@ -1650,7 +2742,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1650
2742
|
"is-date-disabled",
|
|
1651
2743
|
"date-constraints",
|
|
1652
2744
|
"number-of-months",
|
|
1653
|
-
"week-starts-on"
|
|
2745
|
+
"week-starts-on",
|
|
2746
|
+
"calendar"
|
|
1654
2747
|
])], 8, _hoisted_8)) : createCommentVNode("v-if", true)]),
|
|
1655
2748
|
default: withCtx(() => [createElementVNode("div", {
|
|
1656
2749
|
class: "astryx-date-input-wrapper",
|
|
@@ -1743,6 +2836,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1743
2836
|
"is-date-disabled": props.isDateDisabled,
|
|
1744
2837
|
"date-constraints": props.dateConstraints,
|
|
1745
2838
|
"week-starts-on": props.weekStartsOn,
|
|
2839
|
+
calendar: unref(calendar),
|
|
1746
2840
|
"is-disabled": unref(isDisabled),
|
|
1747
2841
|
onPick: onCalendarChange,
|
|
1748
2842
|
onSave: onSheetSave,
|
|
@@ -1754,6 +2848,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1754
2848
|
"is-date-disabled",
|
|
1755
2849
|
"date-constraints",
|
|
1756
2850
|
"week-starts-on",
|
|
2851
|
+
"calendar",
|
|
1757
2852
|
"is-disabled"
|
|
1758
2853
|
])], 8, _hoisted_9)]),
|
|
1759
2854
|
_: 1
|
|
@@ -1768,15 +2863,22 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1768
2863
|
], 46, _hoisted_1)]),
|
|
1769
2864
|
_: 3
|
|
1770
2865
|
}, 16, ["class", "style"])),
|
|
1771
|
-
|
|
2866
|
+
unref(calendarText).calendarDescription.value && surface.value !== "native" ? (openBlock(), createBlock(_sfc_main$6, {
|
|
1772
2867
|
key: 2,
|
|
2868
|
+
id: calendarDescriptionId
|
|
2869
|
+
}, {
|
|
2870
|
+
default: withCtx(() => [createTextVNode(toDisplayString(unref(calendarText).calendarDescription.value), 1)]),
|
|
2871
|
+
_: 1
|
|
2872
|
+
})) : createCommentVNode("v-if", true),
|
|
2873
|
+
showsDisabledMessage.value && surface.value !== "native" ? (openBlock(), createBlock(_sfc_main$6, {
|
|
2874
|
+
key: 3,
|
|
1773
2875
|
id: disabledMessageId
|
|
1774
2876
|
}, {
|
|
1775
2877
|
default: withCtx(() => [createTextVNode(toDisplayString(disabledMessage.value), 1)]),
|
|
1776
2878
|
_: 1
|
|
1777
2879
|
})) : createCommentVNode("v-if", true),
|
|
1778
2880
|
showsDisabledMessage.value && surface.value !== "native" ? (openBlock(), createBlock(_sfc_main$7, {
|
|
1779
|
-
key:
|
|
2881
|
+
key: 4,
|
|
1780
2882
|
id: `${disabledMessageId}-tooltip`,
|
|
1781
2883
|
anchor: containerRef.value,
|
|
1782
2884
|
open: unref(disabledTooltip).isOpen.value,
|
|
@@ -1796,4 +2898,4 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
1796
2898
|
}
|
|
1797
2899
|
});
|
|
1798
2900
|
//#endregion
|
|
1799
|
-
export { _sfc_main$1 as
|
|
2901
|
+
export { formatCommittedDate as i, useCalendarPresentation as n, _sfc_main$1 as r, _sfc_main as t };
|