@punica/components 0.0.0-stage → 2.1.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/CHANGELOG.md +40 -0
- package/LICENSE +21 -0
- package/README.md +139 -2
- package/bin/punica-components.mjs +138 -0
- package/custom-elements.json +38745 -0
- package/dist/ai/index.d.ts +39 -0
- package/dist/ai/index.mjs +615 -0
- package/dist/ai/node.d.ts +5 -0
- package/dist/ai/node.mjs +625 -0
- package/dist/esm/chunks/chunk-25RFU6B5.js +25 -0
- package/dist/esm/chunks/chunk-2EK3PZFT.js +179 -0
- package/dist/esm/chunks/chunk-2KBDCVUH.js +20 -0
- package/dist/esm/chunks/chunk-2NCRRDPI.js +151 -0
- package/dist/esm/chunks/chunk-33GO7Z32.js +40 -0
- package/dist/esm/chunks/chunk-36BKRO3B.js +281 -0
- package/dist/esm/chunks/chunk-3DWJAU5S.js +607 -0
- package/dist/esm/chunks/chunk-3GOFXBR7.js +61 -0
- package/dist/esm/chunks/chunk-3H5QEUFO.js +21 -0
- package/dist/esm/chunks/chunk-3NHCLXYC.js +6 -0
- package/dist/esm/chunks/chunk-3NQ2RVWE.js +36 -0
- package/dist/esm/chunks/chunk-3SYFLID6.js +20 -0
- package/dist/esm/chunks/chunk-3TK5BG5K.js +322 -0
- package/dist/esm/chunks/chunk-3WLKVJO4.js +36 -0
- package/dist/esm/chunks/chunk-427DCAZS.js +49 -0
- package/dist/esm/chunks/chunk-4446KGJH.js +67 -0
- package/dist/esm/chunks/chunk-45UR4HAQ.js +128 -0
- package/dist/esm/chunks/chunk-46P3CPXM.js +81 -0
- package/dist/esm/chunks/chunk-4C3AUANN.js +271 -0
- package/dist/esm/chunks/chunk-4RURT4SK.js +142 -0
- package/dist/esm/chunks/chunk-4XJKCJQG.js +166 -0
- package/dist/esm/chunks/chunk-5PKJV3JP.js +61 -0
- package/dist/esm/chunks/chunk-5SSKNOUZ.js +141 -0
- package/dist/esm/chunks/chunk-5XB5CUJU.js +18 -0
- package/dist/esm/chunks/chunk-5XQX7D2B.js +27 -0
- package/dist/esm/chunks/chunk-6A5Q3TR2.js +73 -0
- package/dist/esm/chunks/chunk-6HE2DQS5.js +29 -0
- package/dist/esm/chunks/chunk-6IWDX7AR.js +32 -0
- package/dist/esm/chunks/chunk-6LO2ITXI.js +138 -0
- package/dist/esm/chunks/chunk-6NSNMUZE.js +36 -0
- package/dist/esm/chunks/chunk-6UQOC4YG.js +61 -0
- package/dist/esm/chunks/chunk-72ANEBJJ.js +138 -0
- package/dist/esm/chunks/chunk-7JTOYPC7.js +24 -0
- package/dist/esm/chunks/chunk-7O3D52ZO.js +27 -0
- package/dist/esm/chunks/chunk-7UN7TAOI.js +39 -0
- package/dist/esm/chunks/chunk-7WEISIJL.js +123 -0
- package/dist/esm/chunks/chunk-7YAUHJR2.js +225 -0
- package/dist/esm/chunks/chunk-7ZT7WUEL.js +35 -0
- package/dist/esm/chunks/chunk-ALU2KZWS.js +177 -0
- package/dist/esm/chunks/chunk-AMVMOCUW.js +81 -0
- package/dist/esm/chunks/chunk-APPQS53K.js +81 -0
- package/dist/esm/chunks/chunk-AVTATVAG.js +410 -0
- package/dist/esm/chunks/chunk-AZMUP33Z.js +56 -0
- package/dist/esm/chunks/chunk-B32J3O2V.js +21 -0
- package/dist/esm/chunks/chunk-B7YCX5VB.js +38 -0
- package/dist/esm/chunks/chunk-BBSDD7DS.js +55 -0
- package/dist/esm/chunks/chunk-BC657356.js +93 -0
- package/dist/esm/chunks/chunk-BFRWXGP4.js +44 -0
- package/dist/esm/chunks/chunk-BYZADSVQ.js +49 -0
- package/dist/esm/chunks/chunk-CDXX27FL.js +28 -0
- package/dist/esm/chunks/chunk-CKI34FQL.js +166 -0
- package/dist/esm/chunks/chunk-CNT47W5N.js +60 -0
- package/dist/esm/chunks/chunk-CU3RW3AS.js +515 -0
- package/dist/esm/chunks/chunk-CZ3R7GRW.js +73 -0
- package/dist/esm/chunks/chunk-DLEJ74RA.js +18 -0
- package/dist/esm/chunks/chunk-DPOPZQ7A.js +150 -0
- package/dist/esm/chunks/chunk-DYXHKPQU.js +18 -0
- package/dist/esm/chunks/chunk-E3XOZZSK.js +77 -0
- package/dist/esm/chunks/chunk-EJLQD3FS.js +89 -0
- package/dist/esm/chunks/chunk-ELY5HYAI.js +45 -0
- package/dist/esm/chunks/chunk-ELY5NJBV.js +152 -0
- package/dist/esm/chunks/chunk-EWIF3VBH.js +45 -0
- package/dist/esm/chunks/chunk-F2OASWR4.js +79 -0
- package/dist/esm/chunks/chunk-F4ODKLNS.js +62 -0
- package/dist/esm/chunks/chunk-F5HKSUTX.js +127 -0
- package/dist/esm/chunks/chunk-FFH6CIAJ.js +208 -0
- package/dist/esm/chunks/chunk-FFLBSXWE.js +21 -0
- package/dist/esm/chunks/chunk-FNTBMCUQ.js +184 -0
- package/dist/esm/chunks/chunk-FYSNICNC.js +71 -0
- package/dist/esm/chunks/chunk-G2QRQLP5.js +18 -0
- package/dist/esm/chunks/chunk-G36PG2LK.js +27 -0
- package/dist/esm/chunks/chunk-G5LARXMF.js +73 -0
- package/dist/esm/chunks/chunk-GQLNLUQX.js +42 -0
- package/dist/esm/chunks/chunk-GRWYCZQZ.js +73 -0
- package/dist/esm/chunks/chunk-GSXWSHYU.js +304 -0
- package/dist/esm/chunks/chunk-GVH32USX.js +48 -0
- package/dist/esm/chunks/chunk-GW3IYQNO.js +271 -0
- package/dist/esm/chunks/chunk-H4Q2HHZA.js +151 -0
- package/dist/esm/chunks/chunk-HDHVTBGS.js +330 -0
- package/dist/esm/chunks/chunk-HK6DEJO3.js +74 -0
- package/dist/esm/chunks/chunk-HUMTZKOD.js +114 -0
- package/dist/esm/chunks/chunk-HW2CN2JV.js +118 -0
- package/dist/esm/chunks/chunk-I6WGYC6M.js +50 -0
- package/dist/esm/chunks/chunk-ICGI6UOP.js +28 -0
- package/dist/esm/chunks/chunk-IYZKVVEX.js +285 -0
- package/dist/esm/chunks/chunk-J4HTWL4Q.js +34 -0
- package/dist/esm/chunks/chunk-J6FXZP6E.js +99 -0
- package/dist/esm/chunks/chunk-JTIBDZBU.js +392 -0
- package/dist/esm/chunks/chunk-K2OIQJ36.js +23 -0
- package/dist/esm/chunks/chunk-K5D5UHVI.js +99 -0
- package/dist/esm/chunks/chunk-K753LIJX.js +157 -0
- package/dist/esm/chunks/chunk-KV4Y5ZP5.js +105 -0
- package/dist/esm/chunks/chunk-KVWZQINH.js +44 -0
- package/dist/esm/chunks/chunk-LKKKFYM4.js +106 -0
- package/dist/esm/chunks/chunk-LKPOFLSP.js +337 -0
- package/dist/esm/chunks/chunk-LSDTMST7.js +6 -0
- package/dist/esm/chunks/chunk-LUASZ5NH.js +271 -0
- package/dist/esm/chunks/chunk-LUPYODQN.js +54 -0
- package/dist/esm/chunks/chunk-M3HQENQG.js +93 -0
- package/dist/esm/chunks/chunk-MCHPBSW4.js +155 -0
- package/dist/esm/chunks/chunk-MDEV5WIN.js +25 -0
- package/dist/esm/chunks/chunk-MF2ASALV.js +194 -0
- package/dist/esm/chunks/chunk-MIUSZNAX.js +62 -0
- package/dist/esm/chunks/chunk-NINGLTB2.js +194 -0
- package/dist/esm/chunks/chunk-NLFUTVKG.js +158 -0
- package/dist/esm/chunks/chunk-NNCGUKTM.js +44 -0
- package/dist/esm/chunks/chunk-NSCGX5GB.js +408 -0
- package/dist/esm/chunks/chunk-NTIMVMDT.js +51 -0
- package/dist/esm/chunks/chunk-OBUW2HDW.js +99 -0
- package/dist/esm/chunks/chunk-OKRRNW3E.js +202 -0
- package/dist/esm/chunks/chunk-PGWADMK3.js +198 -0
- package/dist/esm/chunks/chunk-PMGKVE2V.js +30 -0
- package/dist/esm/chunks/chunk-PMLVGWVZ.js +80 -0
- package/dist/esm/chunks/chunk-PXECURYJ.js +78 -0
- package/dist/esm/chunks/chunk-Q2766HFS.js +34 -0
- package/dist/esm/chunks/chunk-Q62K7757.js +22 -0
- package/dist/esm/chunks/chunk-Q7JNV3UN.js +192 -0
- package/dist/esm/chunks/chunk-QRJKBLYH.js +43 -0
- package/dist/esm/chunks/chunk-QRZWLIUQ.js +551 -0
- package/dist/esm/chunks/chunk-RKF3ZNBC.js +25 -0
- package/dist/esm/chunks/chunk-RMJM6NWT.js +58 -0
- package/dist/esm/chunks/chunk-ROTG34TD.js +81 -0
- package/dist/esm/chunks/chunk-RQ2NYS2W.js +51 -0
- package/dist/esm/chunks/chunk-RX5HOB7L.js +187 -0
- package/dist/esm/chunks/chunk-RYOY6CGB.js +174 -0
- package/dist/esm/chunks/chunk-S2P6I4PF.js +191 -0
- package/dist/esm/chunks/chunk-SCSGRIQM.js +27 -0
- package/dist/esm/chunks/chunk-SENDWPHS.js +115 -0
- package/dist/esm/chunks/chunk-SFY6NIVM.js +106 -0
- package/dist/esm/chunks/chunk-SHEACXCO.js +67 -0
- package/dist/esm/chunks/chunk-SII4GAN2.js +302 -0
- package/dist/esm/chunks/chunk-SIUUXS2M.js +172 -0
- package/dist/esm/chunks/chunk-SLXOGLX4.js +39 -0
- package/dist/esm/chunks/chunk-ST7UASSS.js +43 -0
- package/dist/esm/chunks/chunk-SUNHM3W2.js +211 -0
- package/dist/esm/chunks/chunk-SWTIN4AS.js +43 -0
- package/dist/esm/chunks/chunk-T2FH4DTZ.js +163 -0
- package/dist/esm/chunks/chunk-TK5H2DLW.js +157 -0
- package/dist/esm/chunks/chunk-U3SSEG6P.js +31 -0
- package/dist/esm/chunks/chunk-UNQEQ3F2.js +118 -0
- package/dist/esm/chunks/chunk-UP3ZQ5S6.js +155 -0
- package/dist/esm/chunks/chunk-UQFS4FAE.js +80 -0
- package/dist/esm/chunks/chunk-UZXXUKV6.js +124 -0
- package/dist/esm/chunks/chunk-VF4NHXZG.js +33 -0
- package/dist/esm/chunks/chunk-VIGFMBQW.js +337 -0
- package/dist/esm/chunks/chunk-VJBXT6L2.js +86 -0
- package/dist/esm/chunks/chunk-VM4IKZDR.js +211 -0
- package/dist/esm/chunks/chunk-VPCWI2SH.js +18 -0
- package/dist/esm/chunks/chunk-VR225VA6.js +29 -0
- package/dist/esm/chunks/chunk-WEGQW4SS.js +285 -0
- package/dist/esm/chunks/chunk-WHXEETCS.js +80 -0
- package/dist/esm/chunks/chunk-X2XT4SYI.js +71 -0
- package/dist/esm/chunks/chunk-X6Y3S66P.js +91 -0
- package/dist/esm/chunks/chunk-XBFOPEHZ.js +86 -0
- package/dist/esm/chunks/chunk-XE74KQOC.js +18 -0
- package/dist/esm/chunks/chunk-XNMQ4SC7.js +95 -0
- package/dist/esm/chunks/chunk-XWPDELI6.js +53 -0
- package/dist/esm/chunks/chunk-XWZPKK2I.js +6 -0
- package/dist/esm/chunks/chunk-XZSAOJUV.js +83 -0
- package/dist/esm/chunks/chunk-Y5BQXWLM.js +58 -0
- package/dist/esm/chunks/chunk-Y5HOTHVK.js +22 -0
- package/dist/esm/chunks/chunk-Y7B65FYJ.js +336 -0
- package/dist/esm/chunks/chunk-YIAEOUGS.js +46 -0
- package/dist/esm/chunks/chunk-YKL6MAIV.js +208 -0
- package/dist/esm/chunks/chunk-YPH3G6P7.js +125 -0
- package/dist/esm/chunks/chunk-YSGWORUD.js +36 -0
- package/dist/esm/chunks/chunk-ZB7DQSJK.js +204 -0
- package/dist/esm/chunks/chunk-ZC7JPIL7.js +182 -0
- package/dist/esm/chunks/chunk-ZGBBW7U4.js +35 -0
- package/dist/esm/chunks/chunk-ZIQREEEI.js +210 -0
- package/dist/esm/chunks/chunk-ZJ3UIJ46.js +30 -0
- package/dist/esm/chunks/chunk-ZK6JTE6K.js +826 -0
- package/dist/esm/chunks/chunk-ZPIJWNFB.js +150 -0
- package/dist/esm/chunks/chunk-ZQVI42RW.js +136 -0
- package/dist/esm/chunks/chunk-ZWP6KATC.js +25 -0
- package/dist/esm/chunks/chunk-ZY5YHMTQ.js +88 -0
- package/dist/esm/components/accordion/accordion.js +8 -0
- package/dist/esm/components/accordion/accordionGroup.js +7 -0
- package/dist/esm/components/agenda/agenda.js +9 -0
- package/dist/esm/components/alert/alert.js +8 -0
- package/dist/esm/components/alertDialog/alertDialog.js +14 -0
- package/dist/esm/components/appBar/appBar.js +7 -0
- package/dist/esm/components/appShell/appShell.js +11 -0
- package/dist/esm/components/aspectRatio/aspectRatio.js +7 -0
- package/dist/esm/components/autocomplete/autocomplete.js +14 -0
- package/dist/esm/components/avatar/avatar.js +7 -0
- package/dist/esm/components/avatarGroup/avatarGroup.js +11 -0
- package/dist/esm/components/badge/badge.js +7 -0
- package/dist/esm/components/banner/banner.js +9 -0
- package/dist/esm/components/blockquote/blockquote.js +7 -0
- package/dist/esm/components/bottomSheet/bottomSheet.js +9 -0
- package/dist/esm/components/box/box.js +7 -0
- package/dist/esm/components/breadcrumbs/breadcrumbItem.js +8 -0
- package/dist/esm/components/breadcrumbs/breadcrumbs.js +11 -0
- package/dist/esm/components/button/button.js +8 -0
- package/dist/esm/components/buttonGroup/buttonGroup.js +7 -0
- package/dist/esm/components/calendar/calendar.js +12 -0
- package/dist/esm/components/calendar/dates.js +44 -0
- package/dist/esm/components/card/card.js +7 -0
- package/dist/esm/components/card/cardActions.js +7 -0
- package/dist/esm/components/card/cardContent.js +7 -0
- package/dist/esm/components/card/cardHeader.js +7 -0
- package/dist/esm/components/card/cardMedia.js +7 -0
- package/dist/esm/components/carousel/carousel.js +9 -0
- package/dist/esm/components/carousel/carouselItem.js +7 -0
- package/dist/esm/components/center/center.js +7 -0
- package/dist/esm/components/chat/chatComposer.js +9 -0
- package/dist/esm/components/chat/chatDictationButton.js +8 -0
- package/dist/esm/components/chat/chatLayout.js +9 -0
- package/dist/esm/components/chat/chatMessage.js +9 -0
- package/dist/esm/components/chat/chatMessageBubble.js +7 -0
- package/dist/esm/components/chat/chatMessageList.js +8 -0
- package/dist/esm/components/chat/chatMessageMetadata.js +7 -0
- package/dist/esm/components/chat/chatSystemMessage.js +7 -0
- package/dist/esm/components/chat/chatToolCall.js +9 -0
- package/dist/esm/components/chat/chatToolCalls.js +8 -0
- package/dist/esm/components/chat/slots.js +6 -0
- package/dist/esm/components/checkbox/checkbox.js +9 -0
- package/dist/esm/components/checkboxGroup/checkboxGroup.js +10 -0
- package/dist/esm/components/chip/chip.js +8 -0
- package/dist/esm/components/citation/citation.js +11 -0
- package/dist/esm/components/code/code.js +7 -0
- package/dist/esm/components/codeBlock/codeBlock.js +8 -0
- package/dist/esm/components/collapsible/collapsible.js +7 -0
- package/dist/esm/components/commandPalette/commandGroup.js +7 -0
- package/dist/esm/components/commandPalette/commandItem.js +7 -0
- package/dist/esm/components/commandPalette/commandPalette.js +10 -0
- package/dist/esm/components/complexSelector/complexOption.js +9 -0
- package/dist/esm/components/complexSelector/complexSelector.js +16 -0
- package/dist/esm/components/complexSelector/optionGroup.js +7 -0
- package/dist/esm/components/container/container.js +7 -0
- package/dist/esm/components/contextMenu/contextMenu.js +12 -0
- package/dist/esm/components/datePicker/datePicker.js +15 -0
- package/dist/esm/components/dateRangeInput/dateRangeInput.js +15 -0
- package/dist/esm/components/dateTimeInput/dateTimeInput.js +18 -0
- package/dist/esm/components/dialog/dialog.js +11 -0
- package/dist/esm/components/dialog/dialogContent.js +7 -0
- package/dist/esm/components/dialog/dialogFooter.js +7 -0
- package/dist/esm/components/dialog/dialogHeader.js +7 -0
- package/dist/esm/components/dialog/modalSurface.js +8 -0
- package/dist/esm/components/divider/divider.js +7 -0
- package/dist/esm/components/drawer/drawer.js +10 -0
- package/dist/esm/components/emptyState/emptyState.js +7 -0
- package/dist/esm/components/field/field.js +7 -0
- package/dist/esm/components/fileInput/fileInput.js +9 -0
- package/dist/esm/components/formLayout/formLayout.js +7 -0
- package/dist/esm/components/grid/col.js +7 -0
- package/dist/esm/components/grid/row.js +7 -0
- package/dist/esm/components/heading/heading.js +7 -0
- package/dist/esm/components/hidden/hidden.js +7 -0
- package/dist/esm/components/hoverCard/hoverCard.js +9 -0
- package/dist/esm/components/icon/icon.js +8 -0
- package/dist/esm/components/iconButton/iconButton.js +8 -0
- package/dist/esm/components/infoTip/infoTip.js +10 -0
- package/dist/esm/components/input/input.js +9 -0
- package/dist/esm/components/inputGroup/inputGroup.js +9 -0
- package/dist/esm/components/inputGroup/inputGroupText.js +7 -0
- package/dist/esm/components/kbd/kbd.js +7 -0
- package/dist/esm/components/lightbox/lightbox.js +10 -0
- package/dist/esm/components/link/link.js +8 -0
- package/dist/esm/components/listView/list.js +7 -0
- package/dist/esm/components/listView/listItem.js +7 -0
- package/dist/esm/components/listbox/listbox.js +9 -0
- package/dist/esm/components/listbox/listboxItem.js +8 -0
- package/dist/esm/components/markdown/markdown.js +9 -0
- package/dist/esm/components/markdown/parser.js +9 -0
- package/dist/esm/components/markdown/url.js +6 -0
- package/dist/esm/components/menu/menu.js +11 -0
- package/dist/esm/components/menu/menuCheckboxItem.js +9 -0
- package/dist/esm/components/menu/menuDivider.js +7 -0
- package/dist/esm/components/menu/menuGroup.js +7 -0
- package/dist/esm/components/menu/menuItem.js +8 -0
- package/dist/esm/components/menu/menuRadioGroup.js +7 -0
- package/dist/esm/components/menu/menuRadioItem.js +9 -0
- package/dist/esm/components/metadataList/metadataList.js +9 -0
- package/dist/esm/components/metadataList/metadataListItem.js +8 -0
- package/dist/esm/components/mobileNav/mobileNav.js +10 -0
- package/dist/esm/components/numberInput/numberInput.js +9 -0
- package/dist/esm/components/outline/outline.js +8 -0
- package/dist/esm/components/overflowList/overflowList.js +11 -0
- package/dist/esm/components/pagination/pagination.js +8 -0
- package/dist/esm/components/paper/paper.js +7 -0
- package/dist/esm/components/popover/popover.js +9 -0
- package/dist/esm/components/powerSearch/powerSearch.js +14 -0
- package/dist/esm/components/progressBar/progressBar.js +7 -0
- package/dist/esm/components/qrCode/qrCode.js +9 -0
- package/dist/esm/components/radio/radio.js +7 -0
- package/dist/esm/components/radio/radioGroup.js +10 -0
- package/dist/esm/components/scrollArea/scrollArea.js +8 -0
- package/dist/esm/components/section/section.js +8 -0
- package/dist/esm/components/segmentedControl/segmentedControl.js +12 -0
- package/dist/esm/components/segmentedControl/segmentedControlItem.js +7 -0
- package/dist/esm/components/select/field.js +18 -0
- package/dist/esm/components/select/option.js +8 -0
- package/dist/esm/components/select/select.js +14 -0
- package/dist/esm/components/selectableCard/selectableCard.js +9 -0
- package/dist/esm/components/selectableCard/selectableCardGroup.js +13 -0
- package/dist/esm/components/sideNav/sideNav.js +9 -0
- package/dist/esm/components/sideNav/sideNavItem.js +9 -0
- package/dist/esm/components/sideNav/sideNavSection.js +8 -0
- package/dist/esm/components/skeleton/skeleton.js +7 -0
- package/dist/esm/components/slider/slider.js +9 -0
- package/dist/esm/components/spinner/spinner.js +7 -0
- package/dist/esm/components/split/split.js +8 -0
- package/dist/esm/components/splitButton/splitButton.js +12 -0
- package/dist/esm/components/stack/stack.js +7 -0
- package/dist/esm/components/statusDot/statusDot.js +7 -0
- package/dist/esm/components/stepper/step.js +8 -0
- package/dist/esm/components/stepper/stepper.js +7 -0
- package/dist/esm/components/switch/switch.js +8 -0
- package/dist/esm/components/tab/tab.js +7 -0
- package/dist/esm/components/tab/tabPanel.js +7 -0
- package/dist/esm/components/tab/tabs.js +8 -0
- package/dist/esm/components/table/table.js +7 -0
- package/dist/esm/components/table/tableBody.js +7 -0
- package/dist/esm/components/table/tableCell.js +7 -0
- package/dist/esm/components/table/tableFooter.js +7 -0
- package/dist/esm/components/table/tableHeader.js +7 -0
- package/dist/esm/components/table/tableHeaderCell.js +8 -0
- package/dist/esm/components/table/tableRow.js +7 -0
- package/dist/esm/components/table/tableSelectionToolbar.js +8 -0
- package/dist/esm/components/text/text.js +7 -0
- package/dist/esm/components/textarea/textarea.js +8 -0
- package/dist/esm/components/thumbnail/thumbnail.js +8 -0
- package/dist/esm/components/timePicker/timePicker.js +15 -0
- package/dist/esm/components/timer/timer.js +7 -0
- package/dist/esm/components/timestamp/timestamp.js +7 -0
- package/dist/esm/components/toast/toast.js +8 -0
- package/dist/esm/components/toast/toaster.js +12 -0
- package/dist/esm/components/toggleButton/toggleButton.js +8 -0
- package/dist/esm/components/toggleButtonGroup/toggleButtonGroup.js +10 -0
- package/dist/esm/components/tokenizer/tokenizer.js +14 -0
- package/dist/esm/components/toolbar/toolbar.js +8 -0
- package/dist/esm/components/tooltip/tooltip.js +9 -0
- package/dist/esm/components/topNav/topNav.js +11 -0
- package/dist/esm/components/topNav/topNavItem.js +11 -0
- package/dist/esm/components/topNav/topNavMegaMenu.js +7 -0
- package/dist/esm/components/topNav/topNavMegaMenuCard.js +8 -0
- package/dist/esm/components/topNav/topNavMegaMenuGroup.js +7 -0
- package/dist/esm/components/topNav/topNavMegaMenuItem.js +7 -0
- package/dist/esm/components/tree/tree.js +8 -0
- package/dist/esm/components/tree/treeItem.js +8 -0
- package/dist/esm/components/virtualList/virtualList.js +7 -0
- package/dist/esm/components/virtualTable/virtualTable.js +9 -0
- package/dist/esm/components/visuallyHidden/visuallyHidden.js +7 -0
- package/dist/esm/core/a11y.js +22 -0
- package/dist/esm/core/element.js +14 -0
- package/dist/esm/core/form.js +6 -0
- package/dist/esm/core/overlay.js +8 -0
- package/dist/esm/index.js +779 -0
- package/dist/llms-full.txt +8890 -0
- package/dist/llms.txt +275 -0
- package/dist/punica-components.min.js +14283 -0
- package/dist/tokens.css +158 -0
- package/dist/types/index.d.ts +6753 -0
- package/dist/types/react.d.ts +1914 -0
- package/dist/vscode.css-custom-data.json +3892 -0
- package/dist/vscode.html-custom-data.json +6912 -0
- package/dist/web-types.json +12404 -0
- package/docs/MIGRATION-2.0.md +112 -0
- package/docs/contract.md +130 -0
- package/docs/migration/chat.md +309 -0
- package/docs/migration/content.md +806 -0
- package/docs/migration/data.md +140 -0
- package/docs/migration/display.md +625 -0
- package/docs/migration/form-basic.md +262 -0
- package/docs/migration/navigation.md +368 -0
- package/docs/migration/overlays.md +261 -0
- package/docs/migration/pickers.md +194 -0
- package/package.json +131 -4
- package/scripts/codemod-2.0.mjs +50 -0
- package/scripts/codemod-rules.mjs +102 -0
- package/skills/punica-components/SKILL.md +48 -0
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRtl
|
|
3
|
+
} from "./chunk-4RURT4SK.js";
|
|
4
|
+
import {
|
|
5
|
+
icons
|
|
6
|
+
} from "./chunk-YSGWORUD.js";
|
|
7
|
+
import {
|
|
8
|
+
PunicaElement,
|
|
9
|
+
define
|
|
10
|
+
} from "./chunk-Y7B65FYJ.js";
|
|
11
|
+
|
|
12
|
+
// src/components/agenda/agenda.css
|
|
13
|
+
var agenda_default = ":host {\n --punica-agenda-background: var(--punica-color-surface);\n --punica-agenda-muted-background: var(--punica-color-bg);\n --punica-agenda-border-color: var(--punica-color-border);\n --punica-agenda-radius: var(--punica-radius);\n --punica-agenda-today-color: var(--punica-color-primary);\n --punica-agenda-gutter-width: var(--punica-space-64);\n --punica-agenda-day-hour-height: calc(var(--punica-space-40) * 3);\n --punica-agenda-week-hour-height: var(--punica-space-48);\n --punica-agenda-month-cell-height: calc(var(--punica-space-40) * 3);\n\n display: block;\n block-size: 100%;\n font-family: var(--punica-font-family);\n font-size: var(--punica-font-size-sm);\n color: var(--punica-color-text);\n}\n\n[hidden] {\n display: none !important;\n}\n\n/* Read out, not shown. */\n.sr {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\n.agenda {\n container: agenda / inline-size;\n display: flex;\n flex-direction: column;\n block-size: 100%;\n background: var(--punica-agenda-background);\n}\n\n/* ---------------------------------------------------------------- toolbar */\n\n.toolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--punica-space-8);\n padding: var(--punica-space-8) var(--punica-space-16);\n border-block-end: var(--punica-border-width) solid var(--punica-agenda-border-color);\n}\n\n.nav,\n.views {\n display: flex;\n align-items: center;\n gap: var(--punica-space-4);\n}\n\n.title {\n flex: 1;\n min-inline-size: 0;\n font-size: var(--punica-font-size);\n font-weight: var(--punica-font-weight-bold);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.toolbar button {\n all: unset;\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-block-size: var(--punica-size-sm);\n min-inline-size: var(--punica-size-sm);\n border: var(--punica-border-width) solid var(--punica-agenda-border-color);\n border-radius: var(--punica-radius);\n font-size: var(--punica-font-size-sm);\n font-weight: var(--punica-font-weight-semi-bold);\n cursor: pointer;\n user-select: none;\n transition: background-color var(--punica-duration-fast) var(--punica-ease),\n border-color var(--punica-duration-fast) var(--punica-ease);\n}\n.toolbar .text-button {\n padding-inline: var(--punica-space-12);\n}\n.toolbar button:hover {\n background: var(--punica-color-hover);\n}\n/* The pressed view keeps the text colour: the accent on the selected tint\n falls under 4.5:1 in the dark theme. */\n.toolbar button[aria-pressed='true'] {\n background: var(--punica-color-selected);\n border-color: var(--punica-agenda-today-color);\n color: var(--punica-color-text);\n}\n:host(:dir(rtl)) .nav-button .icon {\n transform: scaleX(-1);\n}\n\nbutton:focus-visible,\n[role='gridcell']:focus-visible {\n outline: var(--punica-focus-ring);\n outline-offset: var(--punica-focus-ring-offset);\n}\n\n.content {\n flex: 1;\n min-block-size: 0;\n overflow: auto;\n}\n\n/* ------------------------------------------------------------------ events */\n\n.event,\n.month-event {\n --_c: var(--punica-color-primary);\n all: unset;\n box-sizing: border-box;\n border-radius: var(--punica-radius-sm);\n background: color-mix(in srgb, var(--_c) 16%, var(--punica-agenda-background));\n color: var(--punica-color-text);\n cursor: pointer;\n overflow: hidden;\n}\n[data-color='secondary'] {\n --_c: var(--punica-color-secondary);\n}\n[data-color='error'] {\n --_c: var(--punica-color-error);\n}\n[data-color='warning'] {\n --_c: var(--punica-color-warning);\n}\n[data-color='info'] {\n --_c: var(--punica-color-info);\n}\n[data-color='success'] {\n --_c: var(--punica-color-success);\n}\n[data-color='neutral'] {\n --_c: var(--punica-color-neutral-dark);\n}\n.event:hover,\n.month-event:hover {\n background: color-mix(in srgb, var(--_c) 28%, var(--punica-agenda-background));\n}\n.event:focus-visible,\n.month-event:focus-visible,\n.more-events:focus-visible,\n.day-column:focus-visible {\n outline-offset: calc(-1 * var(--punica-focus-ring-width));\n}\n\n.event-title {\n font-weight: var(--punica-font-weight-semi-bold);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* ------------------------------------------------------- day and week view */\n\n.timed {\n --_hour: var(--punica-agenda-day-hour-height);\n display: grid;\n grid-template-columns: var(--punica-agenda-gutter-width) minmax(0, 1fr);\n}\n\n.hours {\n grid-column: 1;\n}\n.hour {\n block-size: var(--_hour);\n padding: var(--punica-space-8) var(--punica-space-4);\n border-block-start: var(--punica-border-width) solid var(--punica-agenda-border-color);\n border-inline-end: var(--punica-border-width) solid var(--punica-agenda-border-color);\n text-align: end;\n font-size: var(--punica-font-size-xs);\n color: var(--punica-color-text);\n}\n.clock-text {\n display: block;\n font-weight: var(--punica-font-weight-medium);\n}\n.clock-period {\n display: block;\n opacity: 0.8;\n}\n\n.timed .grid {\n grid-column: 2;\n min-inline-size: 0;\n}\n.columns,\n.week-header {\n display: grid;\n grid-template-columns: repeat(var(--_days), minmax(0, 1fr));\n}\n.timed {\n /* The all-day lane above the hours: one row per all-day event of the fullest day. */\n --_lane-row: calc(var(--punica-space-24) + var(--punica-space-2));\n --_lane: calc(var(--_lane-rows, 0) * var(--_lane-row) + min(var(--_lane-rows, 0), 1) * var(--punica-space-6));\n}\n.columns {\n block-size: calc(var(--_hour) * var(--_hours) + var(--_lane));\n}\n.hours {\n padding-block-start: var(--_lane);\n}\n\n.day-column {\n position: relative;\n background-image: linear-gradient(to bottom, var(--punica-agenda-border-color) var(--punica-border-width), transparent var(--punica-border-width));\n background-size: 100% var(--_hour);\n background-position: 0 var(--_lane);\n background-repeat: repeat-y;\n}\n\n.event {\n position: absolute;\n display: flex;\n flex-direction: column;\n inset-block-start: calc(var(--_lane) + var(--_hour) * var(--_top) + var(--punica-space-2));\n block-size: calc(var(--_hour) * var(--_size) - var(--punica-space-4));\n inset-inline-start: calc(100% * var(--_column) / var(--_columns) + var(--punica-space-2));\n inline-size: calc(100% / var(--_columns) - var(--punica-space-4));\n padding: var(--punica-space-8);\n border-inline-start: var(--punica-space-4) solid var(--_c);\n font-size: var(--punica-font-size-sm);\n}\n.event-time {\n font-size: var(--punica-font-size-xs);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.event.all-day {\n justify-content: center;\n inset-block-start: calc(var(--_row) * var(--_lane-row) + var(--punica-space-2));\n inset-inline: var(--punica-space-2);\n inline-size: auto;\n block-size: var(--punica-space-24);\n padding-block: 0;\n padding-inline: var(--punica-space-8);\n font-size: var(--punica-font-size-xs);\n}\n\n/* A short event keeps its title and gives up its time line. */\n.event {\n container-type: size;\n}\n@container (max-block-size: 30px) {\n .event-time {\n display: none;\n }\n .event-title {\n margin-block-start: calc(-1 * var(--punica-space-4));\n line-height: 1.2;\n }\n}\n@container (max-block-size: 16px) {\n .event-title {\n font-size: var(--punica-font-size-xs);\n }\n}\n\n/* An event cut by the hour range fades at the cut. */\n.event.clipped-start::before,\n.event.clipped-end::after {\n content: '';\n position: absolute;\n inset-inline: 0;\n block-size: var(--punica-space-6);\n pointer-events: none;\n}\n.event.clipped-start::before {\n inset-block-start: 0;\n background: linear-gradient(to bottom, color-mix(in srgb, var(--punica-color-black) 20%, transparent), transparent);\n}\n.event.clipped-end::after {\n inset-block-end: 0;\n background: linear-gradient(to top, color-mix(in srgb, var(--punica-color-black) 20%, transparent), transparent);\n}\n\n/* week */\n.week-view {\n --_hour: var(--punica-agenda-week-hour-height);\n grid-template-rows: auto auto;\n gap: var(--punica-space-8) var(--punica-space-2);\n padding: var(--punica-space-16);\n}\n.week-view .corner {\n grid-area: 1 / 1;\n background: var(--punica-agenda-muted-background);\n}\n/* The day headers stay while the hours scroll under them. */\n.week-view .corner,\n.week-view .week-header {\n position: sticky;\n inset-block-start: 0;\n z-index: 1;\n}\n.week-view .week-header {\n background: var(--punica-agenda-background);\n box-shadow: 0 calc(-1 * var(--punica-space-16)) 0 var(--punica-agenda-background), 0 var(--punica-space-8) 0 var(--punica-agenda-background);\n}\n.week-view .hours {\n grid-row: 2;\n}\n.week-view .grid {\n grid-row: 1 / span 2;\n display: grid;\n grid-template-rows: subgrid;\n}\n.week-view .columns,\n.week-header {\n gap: var(--punica-space-2);\n}\n/* An hour's label sits at the line where the hour starts, as in the day view. */\n.week-view .hour {\n display: flex;\n align-items: flex-start;\n justify-content: flex-end;\n gap: var(--punica-space-2);\n padding: var(--punica-space-4) 0 0;\n padding-inline-end: var(--punica-space-8);\n border-inline-end: 0;\n white-space: nowrap;\n}\n.week-view .clock-text,\n.week-view .clock-period {\n display: inline;\n font-weight: var(--punica-font-weight-regular);\n opacity: 1;\n}\n.week-view .day-column {\n border-inline-start: var(--punica-border-width) solid var(--punica-agenda-border-color);\n background-color: var(--punica-agenda-muted-background);\n}\n.week-view .event {\n padding: var(--punica-space-4) var(--punica-space-8);\n font-size: var(--punica-font-size-xs);\n}\n\n.day-header {\n display: flex;\n flex-direction: column;\n align-items: center;\n min-inline-size: 0;\n}\n.week-header .day-header {\n padding: var(--punica-space-12);\n background: var(--punica-agenda-muted-background);\n border-radius: var(--punica-agenda-radius);\n}\n.week-header .day-header.today {\n background: var(--punica-agenda-today-color);\n color: var(--punica-color-on-accent);\n}\n.week-header .day-name {\n font-size: var(--punica-font-size-xs);\n font-weight: var(--punica-font-weight-medium);\n margin-block-end: var(--punica-space-4);\n}\n.week-header .day-number {\n font-size: var(--punica-font-size-xl);\n font-weight: var(--punica-font-weight-bold);\n}\n\n/* -------------------------------------------------------------- month view */\n\n.month-view {\n display: flex;\n flex-direction: column;\n gap: var(--punica-space-8);\n padding: var(--punica-space-16);\n}\n.month-header,\n.month-row {\n display: grid;\n grid-template-columns: repeat(7, minmax(0, 1fr));\n gap: var(--punica-space-8);\n}\n.month-header .day-header {\n padding: var(--punica-space-12);\n font-weight: var(--punica-font-weight-semi-bold);\n}\n.month-cell {\n min-inline-size: 0;\n min-block-size: var(--punica-agenda-month-cell-height);\n padding: var(--punica-space-8);\n border: var(--punica-border-width) solid var(--punica-agenda-border-color);\n border-radius: var(--punica-agenda-radius);\n background: var(--punica-agenda-background);\n transition: background-color var(--punica-duration) var(--punica-ease),\n box-shadow var(--punica-duration) var(--punica-ease);\n}\n.month-cell:hover {\n background: var(--punica-agenda-muted-background);\n box-shadow: var(--punica-shadow-xs);\n}\n.month-cell.empty {\n background: var(--punica-agenda-muted-background);\n border-color: transparent;\n box-shadow: none;\n}\n.month-cell.today {\n background: color-mix(in srgb, var(--punica-agenda-today-color) 10%, var(--punica-agenda-background));\n border-color: var(--punica-agenda-today-color);\n}\n.cell-header {\n margin-block-end: var(--punica-space-8);\n}\n.month-cell .day-number {\n font-size: var(--punica-font-size);\n font-weight: var(--punica-font-weight-bold);\n}\n.month-cell.today .day-number {\n color: var(--punica-agenda-today-color);\n}\n.cell-events {\n display: flex;\n flex-direction: column;\n gap: var(--punica-space-4);\n}\n.month-event {\n display: flex;\n align-items: center;\n gap: var(--punica-space-4);\n padding: var(--punica-space-4) var(--punica-space-8);\n font-size: var(--punica-font-size-xs);\n}\n.month-event .event-title {\n font-weight: var(--punica-font-weight-regular);\n}\n.event-dot {\n flex: none;\n inline-size: var(--punica-space-6);\n block-size: var(--punica-space-6);\n border-radius: 50%;\n background: var(--_c);\n}\n.more-events {\n all: unset;\n box-sizing: border-box;\n align-self: flex-start;\n margin-block-start: var(--punica-space-4);\n border-radius: var(--punica-radius-sm);\n font-size: var(--punica-font-size-xs);\n font-style: italic;\n cursor: pointer;\n}\n.more-events:hover {\n text-decoration: underline;\n}\n\n/* A narrow agenda gives its month days the room it has. */\n.month-cell .day-number {\n white-space: nowrap;\n}\n@container agenda (max-width: 600px) {\n .month-view {\n gap: var(--punica-space-2);\n padding: var(--punica-space-4);\n }\n .month-header,\n .month-row {\n gap: var(--punica-space-2);\n }\n .month-header .day-header {\n padding: var(--punica-space-4) 0;\n font-size: var(--punica-font-size-xs);\n }\n .month-cell {\n padding: var(--punica-space-4) var(--punica-space-2);\n }\n .month-cell .day-number {\n font-size: var(--punica-font-size-sm);\n }\n .month-event {\n justify-content: center;\n padding: var(--punica-space-4) var(--punica-space-2);\n }\n /* A dot per event; the title stays in the button's name. */\n .month-event .event-title {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n .month-event .event-dot {\n inline-size: var(--punica-space-8);\n block-size: var(--punica-space-8);\n }\n .week-view {\n padding: var(--punica-space-4);\n }\n .week-header .day-header {\n padding: var(--punica-space-6) 0;\n }\n .week-header .day-name {\n max-inline-size: 100%;\n overflow: hidden;\n text-overflow: clip;\n white-space: nowrap;\n }\n .week-header .day-number {\n font-size: var(--punica-font-size);\n }\n}\n\n/* --------------------------------------------------------------- year view */\n\n.year-view {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(calc(var(--punica-space-128) * 2), 1fr));\n gap: var(--punica-space-24);\n padding: var(--punica-space-16);\n}\n.year-month {\n padding: var(--punica-space-16);\n border: var(--punica-border-width) solid var(--punica-agenda-border-color);\n border-radius: var(--punica-agenda-radius);\n background: var(--punica-agenda-background);\n}\n.year-month-name {\n margin-block-end: var(--punica-space-12);\n font-size: var(--punica-font-size);\n font-weight: var(--punica-font-weight-bold);\n}\n.year-month-grid {\n display: flex;\n flex-direction: column;\n gap: var(--punica-space-4);\n}\n.year-day-names,\n.year-days {\n display: grid;\n grid-template-columns: repeat(7, minmax(0, 1fr));\n gap: var(--punica-space-4);\n}\n.year-day-names {\n margin-block-end: var(--punica-space-4);\n font-size: var(--punica-font-size-xs);\n font-weight: var(--punica-font-weight-semi-bold);\n}\n.year-day {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n aspect-ratio: 1;\n border-radius: var(--punica-radius-sm);\n font-size: var(--punica-font-size-xs);\n cursor: pointer;\n transition: background-color var(--punica-duration) var(--punica-ease);\n}\n.year-day:hover {\n background: var(--punica-color-hover);\n}\n.year-day.today {\n background: var(--punica-agenda-today-color);\n color: var(--punica-color-on-accent);\n font-weight: var(--punica-font-weight-bold);\n}\n.year-day.has-events::after {\n content: '';\n position: absolute;\n inset-block-end: var(--punica-space-2);\n inline-size: var(--punica-space-4);\n block-size: var(--punica-space-4);\n border-radius: 50%;\n background: var(--punica-agenda-today-color);\n}\n.year-day.today.has-events::after {\n background: var(--punica-color-on-accent);\n}\n.year-day.empty {\n cursor: default;\n background: none;\n}\n\n@media (forced-colors: active) {\n .event,\n .month-event {\n border: var(--punica-border-width) solid CanvasText;\n }\n .week-header .day-header.today,\n .month-cell.today,\n .year-day.today,\n .toolbar button[aria-pressed='true'] {\n outline: var(--punica-focus-ring-width) solid Highlight;\n outline-offset: calc(-1 * var(--punica-focus-ring-width));\n }\n .year-day.has-events::after {\n background: CanvasText;\n }\n button:focus-visible,\n [role='gridcell']:focus-visible {\n outline-color: Highlight;\n }\n}\n";
|
|
14
|
+
|
|
15
|
+
// src/components/agenda/agenda.js
|
|
16
|
+
var VIEWS = ["day", "week", "month", "year"];
|
|
17
|
+
var PALETTE = ["primary", "secondary", "error", "warning", "info", "success", "neutral"];
|
|
18
|
+
var CYCLE = ["info", "secondary", "success", "warning", "primary", "neutral"];
|
|
19
|
+
var MS_DAY = 864e5;
|
|
20
|
+
var MAX_SPAN = 366;
|
|
21
|
+
var toDay = (y, m, d) => Math.round(Date.UTC(y, m, d) / MS_DAY);
|
|
22
|
+
var fields = (n) => {
|
|
23
|
+
const t = new Date(n * MS_DAY);
|
|
24
|
+
return { y: t.getUTCFullYear(), m: t.getUTCMonth(), d: t.getUTCDate(), w: t.getUTCDay() };
|
|
25
|
+
};
|
|
26
|
+
var utc = (n) => new Date(n * MS_DAY);
|
|
27
|
+
var iso = (n) => utc(n).toISOString().slice(0, 10);
|
|
28
|
+
var localDay = (date) => toDay(date.getFullYear(), date.getMonth(), date.getDate());
|
|
29
|
+
function parseDay(value) {
|
|
30
|
+
if (value == null || value === "") return null;
|
|
31
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(value));
|
|
32
|
+
if (match) {
|
|
33
|
+
const n = toDay(+match[1], +match[2] - 1, +match[3]);
|
|
34
|
+
return iso(n) === match[0] ? n : null;
|
|
35
|
+
}
|
|
36
|
+
const date = new Date(
|
|
37
|
+
/** @type {any} */
|
|
38
|
+
value
|
|
39
|
+
);
|
|
40
|
+
return Number.isNaN(date.getTime()) ? null : localDay(date);
|
|
41
|
+
}
|
|
42
|
+
function toDate(value) {
|
|
43
|
+
if (value == null) return null;
|
|
44
|
+
let date;
|
|
45
|
+
const match = typeof value === "string" && /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
46
|
+
if (match) date = new Date(+match[1], +match[2] - 1, +match[3]);
|
|
47
|
+
else date = new Date(value instanceof Date ? value.getTime() : (
|
|
48
|
+
/** @type {any} */
|
|
49
|
+
value
|
|
50
|
+
));
|
|
51
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
52
|
+
}
|
|
53
|
+
function addMonths(n, count) {
|
|
54
|
+
const { y, m, d } = fields(n);
|
|
55
|
+
const last = fields(toDay(y, m + count + 1, 0)).d;
|
|
56
|
+
return toDay(y, m + count, Math.min(d, last));
|
|
57
|
+
}
|
|
58
|
+
function h(tag, attrs = {}, children = []) {
|
|
59
|
+
const el = document.createElement(tag);
|
|
60
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
61
|
+
if (value == null || value === false) continue;
|
|
62
|
+
if (name === "class") el.className = String(value);
|
|
63
|
+
else if (name === "text") el.textContent = String(value);
|
|
64
|
+
else el.setAttribute(name, value === true ? "" : String(value));
|
|
65
|
+
}
|
|
66
|
+
for (const child of children) if (child) el.appendChild(child);
|
|
67
|
+
return el;
|
|
68
|
+
}
|
|
69
|
+
var fill = (template, count) => String(template ?? "").replace("{count}", String(count));
|
|
70
|
+
var PunicaAgenda = class extends PunicaElement {
|
|
71
|
+
static properties = {
|
|
72
|
+
view: { default: "day" },
|
|
73
|
+
date: {},
|
|
74
|
+
locale: {},
|
|
75
|
+
firstDayOfWeek: { type: Number },
|
|
76
|
+
startHour: { type: Number, default: 0 },
|
|
77
|
+
endHour: { type: Number, default: 24 },
|
|
78
|
+
noToolbar: { type: Boolean },
|
|
79
|
+
label: {},
|
|
80
|
+
labelPrevious: { default: "Previous" },
|
|
81
|
+
labelNext: { default: "Next" },
|
|
82
|
+
labelToday: {},
|
|
83
|
+
labelDay: {},
|
|
84
|
+
labelWeek: {},
|
|
85
|
+
labelMonth: {},
|
|
86
|
+
labelYear: {},
|
|
87
|
+
labelMore: { default: "+{count} more" },
|
|
88
|
+
labelEvents: { default: "{count} events" },
|
|
89
|
+
events: { type: Array, attribute: false }
|
|
90
|
+
};
|
|
91
|
+
static styles = agenda_default;
|
|
92
|
+
static template = `
|
|
93
|
+
<div part="base" class="agenda">
|
|
94
|
+
<div part="toolbar" class="toolbar">
|
|
95
|
+
<div class="nav">
|
|
96
|
+
<button part="nav-button" class="nav-button" type="button" data-step="-1">${icons.chevronStart}</button>
|
|
97
|
+
<button part="today-button" class="text-button" type="button" data-today></button>
|
|
98
|
+
<button part="nav-button" class="nav-button" type="button" data-step="1">${icons.chevronEnd}</button>
|
|
99
|
+
</div>
|
|
100
|
+
<div part="title" class="title" aria-live="polite"></div>
|
|
101
|
+
<div class="views" role="group">
|
|
102
|
+
<button part="view-button" class="text-button" type="button" data-view="day"></button>
|
|
103
|
+
<button part="view-button" class="text-button" type="button" data-view="week"></button>
|
|
104
|
+
<button part="view-button" class="text-button" type="button" data-view="month"></button>
|
|
105
|
+
<button part="view-button" class="text-button" type="button" data-view="year"></button>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
<div part="content" class="content"></div>
|
|
109
|
+
</div>
|
|
110
|
+
`;
|
|
111
|
+
#base = this.$(".agenda");
|
|
112
|
+
#toolbar = this.$(".toolbar");
|
|
113
|
+
#title = this.$(".title");
|
|
114
|
+
#content = this.$(".content");
|
|
115
|
+
/** Normalised events. @type {any[]} */
|
|
116
|
+
#items = [];
|
|
117
|
+
/** day → events on it. @type {Map<number, any[]>} */
|
|
118
|
+
#byDay = /* @__PURE__ */ new Map();
|
|
119
|
+
/** day → its cell in the view. @type {Map<number, HTMLElement>} */
|
|
120
|
+
#cells = /* @__PURE__ */ new Map();
|
|
121
|
+
/** cell → signature of the events drawn in it. @type {WeakMap<Element, string>} */
|
|
122
|
+
#drawn = /* @__PURE__ */ new WeakMap();
|
|
123
|
+
/** The day that holds the grid's tab stop. */
|
|
124
|
+
#cursor = 0;
|
|
125
|
+
#structure = "";
|
|
126
|
+
/** @type {Record<string, any> | null} */
|
|
127
|
+
#formats = null;
|
|
128
|
+
/** A timed view was built and has not yet been scrolled to its first event. */
|
|
129
|
+
#scrollPending = false;
|
|
130
|
+
constructor() {
|
|
131
|
+
super();
|
|
132
|
+
this.#toolbar.addEventListener("click", (event) => this.#onToolbarClick(event));
|
|
133
|
+
this.#content.addEventListener("click", (event) => this.#onContentClick(event));
|
|
134
|
+
this.#content.addEventListener("keydown", (event) => this.#onKeydown(event));
|
|
135
|
+
for (const type of ["wheel", "pointerdown", "keydown"]) {
|
|
136
|
+
this.#content.addEventListener(type, () => this.#scrollPending = false, { passive: true });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
update(changed) {
|
|
140
|
+
if (changed.has("events")) this.#index();
|
|
141
|
+
if (changed.has("date") || changed.has("view")) this.#cursor = this.#anchor;
|
|
142
|
+
if (changed.has("locale")) this.#formats = null;
|
|
143
|
+
this.#toolbar.hidden = this.noToolbar;
|
|
144
|
+
if (this.label) {
|
|
145
|
+
this.#base.setAttribute("role", "group");
|
|
146
|
+
this.#base.setAttribute("aria-label", this.label);
|
|
147
|
+
} else {
|
|
148
|
+
this.#base.removeAttribute("role");
|
|
149
|
+
this.#base.removeAttribute("aria-label");
|
|
150
|
+
}
|
|
151
|
+
this.#render();
|
|
152
|
+
}
|
|
153
|
+
/* ------------------------------------------------------------ public API */
|
|
154
|
+
/**
|
|
155
|
+
* Adds one event to `events`.
|
|
156
|
+
* @param {AgendaEvent} event
|
|
157
|
+
*/
|
|
158
|
+
addEvent(event) {
|
|
159
|
+
this.events = [...Array.isArray(this.events) ? this.events : [], event];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Moves to the previous or next period of the current view.
|
|
163
|
+
* @param {-1 | 1} direction
|
|
164
|
+
*/
|
|
165
|
+
navigate(direction) {
|
|
166
|
+
if (direction !== -1 && direction !== 1) return;
|
|
167
|
+
this.date = iso(this.#step(this.#anchor, direction));
|
|
168
|
+
}
|
|
169
|
+
/** Moves to the period that contains today. */
|
|
170
|
+
today() {
|
|
171
|
+
this.date = iso(localDay(/* @__PURE__ */ new Date()));
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The first and last date of the period shown, as `YYYY-MM-DD`.
|
|
175
|
+
* @returns {{ start: string, end: string }}
|
|
176
|
+
*/
|
|
177
|
+
get range() {
|
|
178
|
+
const [start, end] = this.#period(this.#view, this.#anchor);
|
|
179
|
+
return { start: iso(start), end: iso(end) };
|
|
180
|
+
}
|
|
181
|
+
/** Moves focus to the active day of the grid. */
|
|
182
|
+
focus(options) {
|
|
183
|
+
const cell = this.#cells.get(this.#cursor);
|
|
184
|
+
if (cell) cell.focus({ preventScroll: this.#view === "day" || this.#view === "week", ...options });
|
|
185
|
+
else super.focus(options);
|
|
186
|
+
}
|
|
187
|
+
/* -------------------------------------------------------------- settings */
|
|
188
|
+
get #view() {
|
|
189
|
+
return VIEWS.includes(this.view) ? this.view : "day";
|
|
190
|
+
}
|
|
191
|
+
/** The date the period is built around. */
|
|
192
|
+
get #anchor() {
|
|
193
|
+
return parseDay(this.date) ?? localDay(/* @__PURE__ */ new Date());
|
|
194
|
+
}
|
|
195
|
+
get #locale() {
|
|
196
|
+
const wanted = this.locale || this.closest("[lang]")?.lang || typeof navigator !== "undefined" && navigator.language || "en";
|
|
197
|
+
try {
|
|
198
|
+
return Intl.DateTimeFormat.supportedLocalesOf([wanted])[0] || "en";
|
|
199
|
+
} catch {
|
|
200
|
+
return "en";
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** 0 (Sunday) to 6 (Saturday). */
|
|
204
|
+
get #weekStart() {
|
|
205
|
+
const own = this.firstDayOfWeek;
|
|
206
|
+
if (own != null && Number.isInteger(own) && own >= 0 && own <= 7) return own % 7;
|
|
207
|
+
try {
|
|
208
|
+
const locale = (
|
|
209
|
+
/** @type {any} */
|
|
210
|
+
new Intl.Locale(this.#locale)
|
|
211
|
+
);
|
|
212
|
+
const info = typeof locale.getWeekInfo === "function" ? locale.getWeekInfo() : locale.weekInfo;
|
|
213
|
+
if (info?.firstDay) return info.firstDay % 7;
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
return 1;
|
|
217
|
+
}
|
|
218
|
+
/** Whole hours the day and week views span. */
|
|
219
|
+
get #hours() {
|
|
220
|
+
const hour = (value, fallback) => value == null || !Number.isFinite(value) ? fallback : Math.max(0, Math.min(24, value));
|
|
221
|
+
const start = Math.floor(hour(this.startHour, 0));
|
|
222
|
+
const end = Math.ceil(hour(this.endHour, 24));
|
|
223
|
+
return end > start ? [start, end] : [0, 24];
|
|
224
|
+
}
|
|
225
|
+
/** Intl formatters for the current locale, built once per locale. */
|
|
226
|
+
get #fmt() {
|
|
227
|
+
if (this.#formats?.locale === this.#locale) return this.#formats;
|
|
228
|
+
const locale = this.#locale;
|
|
229
|
+
const date = (options) => new Intl.DateTimeFormat(locale, { calendar: "gregory", timeZone: "UTC", ...options });
|
|
230
|
+
const formats = {
|
|
231
|
+
locale,
|
|
232
|
+
full: date({ dateStyle: "full" }),
|
|
233
|
+
long: date({ dateStyle: "long" }),
|
|
234
|
+
monthYear: date({ month: "long", year: "numeric" }),
|
|
235
|
+
month: date({ month: "long" }),
|
|
236
|
+
year: date({ year: "numeric" }),
|
|
237
|
+
dayNumber: date({ day: "numeric" }),
|
|
238
|
+
weekdayShort: date({ weekday: "short" }),
|
|
239
|
+
weekdayNarrow: date({ weekday: "narrow" }),
|
|
240
|
+
weekdayLong: date({ weekday: "long" }),
|
|
241
|
+
hour: date({ hour: "2-digit", minute: "2-digit" }),
|
|
242
|
+
// Event instants are read in the local time zone.
|
|
243
|
+
time: new Intl.DateTimeFormat(locale, { hour: "numeric", minute: "2-digit" }),
|
|
244
|
+
when: new Intl.DateTimeFormat(locale, { calendar: "gregory", dateStyle: "medium", timeStyle: "short" }),
|
|
245
|
+
number: new Intl.NumberFormat(locale)
|
|
246
|
+
};
|
|
247
|
+
return this.#formats = formats;
|
|
248
|
+
}
|
|
249
|
+
/** The locale's own word for a view or for today, capitalised. */
|
|
250
|
+
#word(kind) {
|
|
251
|
+
const locale = this.#locale;
|
|
252
|
+
const english = { day: "Day", week: "Week", month: "Month", year: "Year", today: "Today" }[kind];
|
|
253
|
+
try {
|
|
254
|
+
const text = kind === "today" ? new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "day") : new Intl.DisplayNames(locale, { type: "dateTimeField" }).of(kind === "week" ? "weekOfYear" : kind);
|
|
255
|
+
return text ? text.charAt(0).toLocaleUpperCase(locale) + text.slice(1) : english;
|
|
256
|
+
} catch {
|
|
257
|
+
return english;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/* ----------------------------------------------------------------- dates */
|
|
261
|
+
/** @returns {[number, number]} first and last day of the period around `anchor` */
|
|
262
|
+
#period(view, anchor) {
|
|
263
|
+
const { y, m, w } = fields(anchor);
|
|
264
|
+
if (view === "week") {
|
|
265
|
+
const start = anchor - (w - this.#weekStart + 7) % 7;
|
|
266
|
+
return [start, start + 6];
|
|
267
|
+
}
|
|
268
|
+
if (view === "month") return [toDay(y, m, 1), toDay(y, m + 1, 0)];
|
|
269
|
+
if (view === "year") return [toDay(y, 0, 1), toDay(y, 11, 31)];
|
|
270
|
+
return [anchor, anchor];
|
|
271
|
+
}
|
|
272
|
+
#step(day, direction) {
|
|
273
|
+
const view = this.#view;
|
|
274
|
+
if (view === "week") return day + 7 * direction;
|
|
275
|
+
if (view === "month") return addMonths(day, direction);
|
|
276
|
+
if (view === "year") return addMonths(day, 12 * direction);
|
|
277
|
+
return day + direction;
|
|
278
|
+
}
|
|
279
|
+
/* ---------------------------------------------------------------- events */
|
|
280
|
+
#index() {
|
|
281
|
+
const list = Array.isArray(this.events) ? this.events : [];
|
|
282
|
+
this.#items = [];
|
|
283
|
+
this.#byDay = /* @__PURE__ */ new Map();
|
|
284
|
+
list.forEach((raw, index) => {
|
|
285
|
+
if (!raw || typeof raw !== "object") return;
|
|
286
|
+
const start = toDate(raw.start);
|
|
287
|
+
if (!start) return;
|
|
288
|
+
let end = toDate(raw.end) || start;
|
|
289
|
+
if (end < start) end = start;
|
|
290
|
+
const startDay = localDay(start);
|
|
291
|
+
let endDay = localDay(end);
|
|
292
|
+
let endMin = end.getHours() * 60 + end.getMinutes();
|
|
293
|
+
if (endDay > startDay && endMin === 0) {
|
|
294
|
+
endDay -= 1;
|
|
295
|
+
endMin = 1440;
|
|
296
|
+
}
|
|
297
|
+
const title = raw.title == null ? "" : String(raw.title);
|
|
298
|
+
const startMin = start.getHours() * 60 + start.getMinutes();
|
|
299
|
+
const bare = (value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
300
|
+
const allDay = startMin === 0 && endMin === 1440 || end.getTime() - start.getTime() >= MS_DAY || bare(raw.start) && (raw.end == null || bare(raw.end));
|
|
301
|
+
const color = PALETTE.includes(raw.color) ? raw.color : CYCLE[index % CYCLE.length];
|
|
302
|
+
const item = {
|
|
303
|
+
raw,
|
|
304
|
+
index,
|
|
305
|
+
value: raw.id ?? index,
|
|
306
|
+
title,
|
|
307
|
+
color,
|
|
308
|
+
start,
|
|
309
|
+
end,
|
|
310
|
+
startDay,
|
|
311
|
+
endDay,
|
|
312
|
+
startMin,
|
|
313
|
+
endMin,
|
|
314
|
+
allDay,
|
|
315
|
+
key: `${index}:${start.getTime()}:${end.getTime()}:${color}:${title}`
|
|
316
|
+
};
|
|
317
|
+
this.#items.push(item);
|
|
318
|
+
const last = Math.min(endDay, startDay + MAX_SPAN);
|
|
319
|
+
for (let day = startDay; day <= last; day++) {
|
|
320
|
+
const bucket = this.#byDay.get(day);
|
|
321
|
+
if (bucket) bucket.push(item);
|
|
322
|
+
else this.#byDay.set(day, [item]);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
const order = (a, b) => a.start - b.start || b.end - a.end || a.index - b.index;
|
|
326
|
+
for (const bucket of this.#byDay.values()) bucket.sort(order);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Minutes of `day` an event covers, drawn at least `least` minutes tall so
|
|
330
|
+
* its title fits.
|
|
331
|
+
*/
|
|
332
|
+
#span(item, day, least = 15) {
|
|
333
|
+
const from = day === item.startDay ? item.startMin : 0;
|
|
334
|
+
const to = day === item.endDay ? item.endMin : 1440;
|
|
335
|
+
return [from, Math.max(to, Math.min(1440, from + least))];
|
|
336
|
+
}
|
|
337
|
+
/** Date and time of an event in full, for the part of its name that is not on screen. */
|
|
338
|
+
#when(item) {
|
|
339
|
+
return item.end > item.start ? this.#fmt.when.formatRange(item.start, item.end) : this.#fmt.when.format(item.start);
|
|
340
|
+
}
|
|
341
|
+
#timeText(item, range) {
|
|
342
|
+
const { time } = this.#fmt;
|
|
343
|
+
return range && item.end > item.start ? time.formatRange(item.start, item.end) : time.format(item.start);
|
|
344
|
+
}
|
|
345
|
+
/* ---------------------------------------------------------------- render */
|
|
346
|
+
#render() {
|
|
347
|
+
const view = this.#view;
|
|
348
|
+
const anchor = this.#anchor;
|
|
349
|
+
const [start, end] = this.#period(view, anchor);
|
|
350
|
+
const today = localDay(/* @__PURE__ */ new Date());
|
|
351
|
+
const fmt = this.#fmt;
|
|
352
|
+
if (this.#cursor < start || this.#cursor > end) this.#cursor = anchor;
|
|
353
|
+
for (const button of this.#toolbar.querySelectorAll("button")) {
|
|
354
|
+
if (button.dataset.step) {
|
|
355
|
+
button.setAttribute("aria-label", (button.dataset.step === "1" ? this.labelNext : this.labelPrevious) || "");
|
|
356
|
+
} else if (button.dataset.view) {
|
|
357
|
+
const name = button.dataset.view;
|
|
358
|
+
const own = this[`label${name[0].toUpperCase()}${name.slice(1)}`];
|
|
359
|
+
setText(button, own || this.#word(name));
|
|
360
|
+
button.setAttribute("aria-pressed", String(name === view));
|
|
361
|
+
} else {
|
|
362
|
+
setText(button, this.labelToday || this.#word("today"));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
let title;
|
|
366
|
+
if (view === "day") title = fmt.full.format(utc(anchor));
|
|
367
|
+
else if (view === "week") title = fmt.long.formatRange(utc(start), utc(end));
|
|
368
|
+
else if (view === "month") title = fmt.monthYear.format(utc(anchor));
|
|
369
|
+
else title = fmt.year.format(utc(anchor));
|
|
370
|
+
setText(this.#title, title);
|
|
371
|
+
this.toggleState("today", today >= start && today <= end);
|
|
372
|
+
const [hourStart, hourEnd] = this.#hours;
|
|
373
|
+
const structure = [view, start, end, fmt.locale, this.#weekStart, hourStart, hourEnd, today, this.labelMore, this.labelEvents].join("|");
|
|
374
|
+
const rebuilt = structure !== this.#structure;
|
|
375
|
+
if (rebuilt) {
|
|
376
|
+
const active = this.shadowRoot.activeElement;
|
|
377
|
+
const hadFocus = !!active && this.#content.contains(active);
|
|
378
|
+
this.#structure = structure;
|
|
379
|
+
this.#cells = /* @__PURE__ */ new Map();
|
|
380
|
+
this.#content.dataset.view = view;
|
|
381
|
+
let tree;
|
|
382
|
+
if (view === "month") tree = this.#buildMonth(anchor, today);
|
|
383
|
+
else if (view === "year") tree = this.#buildYear(anchor, today);
|
|
384
|
+
else tree = this.#buildTimed(view, start, end, today);
|
|
385
|
+
this.#content.replaceChildren(tree);
|
|
386
|
+
if (hadFocus) this.#focusCell(this.#cursor);
|
|
387
|
+
}
|
|
388
|
+
for (const [day, cell] of this.#cells) {
|
|
389
|
+
const items = this.#byDay.get(day) || [];
|
|
390
|
+
const signature = items.map((item) => item.key).join("\n");
|
|
391
|
+
if (this.#drawn.get(cell) === signature) continue;
|
|
392
|
+
this.#drawn.set(cell, signature);
|
|
393
|
+
if (view === "month") this.#drawMonthDay(cell, day, items);
|
|
394
|
+
else if (view === "year") this.#drawYearDay(cell, day, items);
|
|
395
|
+
else this.#drawTimedDay(cell, day, items);
|
|
396
|
+
}
|
|
397
|
+
if (view === "day" || view === "week") {
|
|
398
|
+
let lane = 0;
|
|
399
|
+
for (const day of this.#cells.keys()) {
|
|
400
|
+
lane = Math.max(lane, (this.#byDay.get(day) || []).filter((item) => item.allDay).length);
|
|
401
|
+
}
|
|
402
|
+
this.#content.firstElementChild?.style.setProperty("--_lane-rows", String(lane));
|
|
403
|
+
if (rebuilt) this.#scrollPending = true;
|
|
404
|
+
if (this.#scrollPending) this.#scrollToFirst();
|
|
405
|
+
}
|
|
406
|
+
this.#rove();
|
|
407
|
+
}
|
|
408
|
+
/** Brings the period's first timed event into view, or the start of the hours. */
|
|
409
|
+
#scrollToFirst() {
|
|
410
|
+
const content = this.#content;
|
|
411
|
+
const first = [...content.querySelectorAll(".event:not(.all-day)")].reduce(
|
|
412
|
+
(best, el) => best && best.offsetTop <= el.offsetTop ? best : el,
|
|
413
|
+
null
|
|
414
|
+
);
|
|
415
|
+
if (!first) {
|
|
416
|
+
content.scrollTop = 0;
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
this.#scrollPending = false;
|
|
420
|
+
const origin = content.getBoundingClientRect().top - content.scrollTop;
|
|
421
|
+
const top = first.getBoundingClientRect().top - origin;
|
|
422
|
+
const columns = content.querySelector(".columns");
|
|
423
|
+
const header = columns ? columns.getBoundingClientRect().top - origin : 0;
|
|
424
|
+
const fits = top + first.offsetHeight <= content.clientHeight;
|
|
425
|
+
content.scrollTop = fits ? 0 : Math.max(0, top - header - 8);
|
|
426
|
+
}
|
|
427
|
+
/** A day column is taller than the view, so focusing it must not scroll. */
|
|
428
|
+
#focusCell(day) {
|
|
429
|
+
const stacked = this.#view === "month" || this.#view === "year";
|
|
430
|
+
this.#cells.get(day)?.focus({ preventScroll: !stacked });
|
|
431
|
+
}
|
|
432
|
+
/** One cell is in the tab order: the cursor's. */
|
|
433
|
+
#rove() {
|
|
434
|
+
for (const [day, cell] of this.#cells) cell.tabIndex = day === this.#cursor ? 0 : -1;
|
|
435
|
+
}
|
|
436
|
+
#dayLabel(day, count) {
|
|
437
|
+
const date = this.#fmt.full.format(utc(day));
|
|
438
|
+
return count ? `${date}, ${fill(this.labelEvents, this.#fmt.number.format(count))}` : date;
|
|
439
|
+
}
|
|
440
|
+
/** Weekday header cells for the seven days from `start`. */
|
|
441
|
+
#weekdayHeaders(start, format, today, withNumber) {
|
|
442
|
+
const fmt = this.#fmt;
|
|
443
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
444
|
+
const day = start + i;
|
|
445
|
+
const cell = h("div", {
|
|
446
|
+
class: `day-header${withNumber && day === today ? " today" : ""}`,
|
|
447
|
+
part: "day-header",
|
|
448
|
+
role: "columnheader",
|
|
449
|
+
"aria-label": withNumber ? fmt.full.format(utc(day)) : fmt.weekdayLong.format(utc(day))
|
|
450
|
+
});
|
|
451
|
+
cell.appendChild(h("span", { class: "day-name", text: fmt[format].format(utc(day)) }));
|
|
452
|
+
if (withNumber) cell.appendChild(h("span", { class: "day-number", text: fmt.dayNumber.format(utc(day)) }));
|
|
453
|
+
return cell;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
/* ----------------------------------------------------- day and week view */
|
|
457
|
+
#buildTimed(view, start, end, today) {
|
|
458
|
+
const fmt = this.#fmt;
|
|
459
|
+
const [hourStart, hourEnd] = this.#hours;
|
|
460
|
+
const root = h("div", { class: `timed ${view}-view` });
|
|
461
|
+
root.style.setProperty("--_hours", String(hourEnd - hourStart));
|
|
462
|
+
root.style.setProperty("--_days", String(end - start + 1));
|
|
463
|
+
const gutter = h("div", { class: "hours", "aria-hidden": "true" });
|
|
464
|
+
for (let hour = hourStart; hour < hourEnd; hour++) {
|
|
465
|
+
const parts = fmt.hour.formatToParts(new Date(Date.UTC(2024, 0, 1, hour)));
|
|
466
|
+
const period = parts.find((p) => p.type === "dayPeriod")?.value || "";
|
|
467
|
+
const clock = parts.filter((p) => p.type !== "dayPeriod").map((p) => p.value).join("").trim();
|
|
468
|
+
gutter.appendChild(
|
|
469
|
+
h("div", { class: "hour" }, [h("span", { class: "clock-text", text: clock }), period ? h("span", { class: "clock-period", text: period }) : null])
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
const grid = h("div", {
|
|
473
|
+
class: "grid",
|
|
474
|
+
part: "grid",
|
|
475
|
+
role: "grid",
|
|
476
|
+
"aria-label": view === "day" ? fmt.full.format(utc(start)) : fmt.long.formatRange(utc(start), utc(end))
|
|
477
|
+
});
|
|
478
|
+
if (view === "week") {
|
|
479
|
+
root.appendChild(h("div", { class: "corner", "aria-hidden": "true" }));
|
|
480
|
+
grid.appendChild(h("div", { class: "week-header", role: "row" }, this.#weekdayHeaders(start, "weekdayShort", today, true)));
|
|
481
|
+
}
|
|
482
|
+
const row = h("div", { class: "columns", role: "row" });
|
|
483
|
+
for (let day = start; day <= end; day++) {
|
|
484
|
+
const cell = h("div", {
|
|
485
|
+
class: `day-column${day === today ? " today" : ""}`,
|
|
486
|
+
part: "day",
|
|
487
|
+
role: "gridcell",
|
|
488
|
+
"data-day": day,
|
|
489
|
+
"aria-current": day === today ? "date" : null
|
|
490
|
+
});
|
|
491
|
+
this.#cells.set(day, cell);
|
|
492
|
+
row.appendChild(cell);
|
|
493
|
+
}
|
|
494
|
+
grid.appendChild(row);
|
|
495
|
+
root.append(gutter, grid);
|
|
496
|
+
return root;
|
|
497
|
+
}
|
|
498
|
+
#drawTimedDay(cell, day, items) {
|
|
499
|
+
const [hourStart, hourEnd] = this.#hours;
|
|
500
|
+
const from = hourStart * 60;
|
|
501
|
+
const to = hourEnd * 60;
|
|
502
|
+
const day_ = this.#view === "day";
|
|
503
|
+
const least = day_ ? 15 : 30;
|
|
504
|
+
const shown = [];
|
|
505
|
+
const lane = [];
|
|
506
|
+
for (const item of items) {
|
|
507
|
+
if (item.allDay) {
|
|
508
|
+
lane.push(item);
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const [s, e] = this.#span(item, day, least);
|
|
512
|
+
if (e <= from || s >= to) continue;
|
|
513
|
+
shown.push({ item, s: Math.max(s, from), e: Math.min(e, to), clippedStart: s < from, clippedEnd: e > to });
|
|
514
|
+
}
|
|
515
|
+
layout(shown);
|
|
516
|
+
cell.replaceChildren(
|
|
517
|
+
h("span", { class: "sr day-label", text: this.#dayLabel(day, lane.length + shown.length) }),
|
|
518
|
+
...lane.map((item, row) => {
|
|
519
|
+
const button = h(
|
|
520
|
+
"button",
|
|
521
|
+
{
|
|
522
|
+
type: "button",
|
|
523
|
+
class: "event all-day",
|
|
524
|
+
part: "event",
|
|
525
|
+
tabindex: -1,
|
|
526
|
+
"data-index": item.index,
|
|
527
|
+
"data-color": item.color
|
|
528
|
+
},
|
|
529
|
+
[h("span", { class: "event-title", text: item.title }), h("span", { class: "sr event-when", text: this.#when(item) })]
|
|
530
|
+
);
|
|
531
|
+
button.style.setProperty("--_row", String(row));
|
|
532
|
+
return button;
|
|
533
|
+
}),
|
|
534
|
+
...shown.map((box) => {
|
|
535
|
+
const { item } = box;
|
|
536
|
+
const button = h(
|
|
537
|
+
"button",
|
|
538
|
+
{
|
|
539
|
+
type: "button",
|
|
540
|
+
class: `event${box.clippedStart ? " clipped-start" : ""}${box.clippedEnd ? " clipped-end" : ""}`,
|
|
541
|
+
part: "event",
|
|
542
|
+
tabindex: -1,
|
|
543
|
+
"data-index": item.index,
|
|
544
|
+
"data-color": item.color
|
|
545
|
+
},
|
|
546
|
+
[
|
|
547
|
+
h("span", { class: "event-title", text: item.title }),
|
|
548
|
+
h("span", { class: "sr event-when", text: this.#when(item) }),
|
|
549
|
+
h("span", { class: "event-time", "aria-hidden": "true", text: this.#timeText(item, day_) })
|
|
550
|
+
]
|
|
551
|
+
);
|
|
552
|
+
button.style.setProperty("--_top", String((box.s - from) / 60));
|
|
553
|
+
button.style.setProperty("--_size", String((box.e - box.s) / 60));
|
|
554
|
+
button.style.setProperty("--_column", String(box.column));
|
|
555
|
+
button.style.setProperty("--_columns", String(box.columns));
|
|
556
|
+
return button;
|
|
557
|
+
})
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
/* ------------------------------------------------------------ month view */
|
|
561
|
+
#buildMonth(anchor, today) {
|
|
562
|
+
const fmt = this.#fmt;
|
|
563
|
+
const [first, last] = this.#period("month", anchor);
|
|
564
|
+
const lead = (fields(first).w - this.#weekStart + 7) % 7;
|
|
565
|
+
const gridStart = first - lead;
|
|
566
|
+
const grid = h("div", { class: "month-view grid", part: "grid", role: "grid", "aria-label": fmt.monthYear.format(utc(anchor)) });
|
|
567
|
+
grid.appendChild(h("div", { class: "month-header", role: "row" }, this.#weekdayHeaders(gridStart, "weekdayShort", today, false)));
|
|
568
|
+
for (let weekStart = gridStart; weekStart <= last; weekStart += 7) {
|
|
569
|
+
const row = h("div", { class: "month-row", role: "row" });
|
|
570
|
+
for (let day = weekStart; day < weekStart + 7; day++) {
|
|
571
|
+
if (day < first || day > last) {
|
|
572
|
+
row.appendChild(h("div", { class: "month-cell empty", role: "gridcell" }));
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
const cell = h(
|
|
576
|
+
"div",
|
|
577
|
+
{
|
|
578
|
+
class: `month-cell${day === today ? " today" : ""}`,
|
|
579
|
+
part: "day",
|
|
580
|
+
role: "gridcell",
|
|
581
|
+
"data-day": day,
|
|
582
|
+
"aria-current": day === today ? "date" : null
|
|
583
|
+
},
|
|
584
|
+
[
|
|
585
|
+
h("div", { class: "cell-header" }, [
|
|
586
|
+
h("span", { class: "day-number", "aria-hidden": "true", text: fmt.dayNumber.format(utc(day)) }),
|
|
587
|
+
h("span", { class: "sr day-label" })
|
|
588
|
+
]),
|
|
589
|
+
h("div", { class: "cell-events" })
|
|
590
|
+
]
|
|
591
|
+
);
|
|
592
|
+
this.#cells.set(day, cell);
|
|
593
|
+
row.appendChild(cell);
|
|
594
|
+
}
|
|
595
|
+
grid.appendChild(row);
|
|
596
|
+
}
|
|
597
|
+
return grid;
|
|
598
|
+
}
|
|
599
|
+
#drawMonthDay(cell, day, items) {
|
|
600
|
+
setText(cell.querySelector(".day-label"), this.#dayLabel(day, items.length));
|
|
601
|
+
const nodes = items.slice(0, 3).map(
|
|
602
|
+
(item) => h(
|
|
603
|
+
"button",
|
|
604
|
+
{
|
|
605
|
+
type: "button",
|
|
606
|
+
class: "month-event",
|
|
607
|
+
part: "event",
|
|
608
|
+
tabindex: -1,
|
|
609
|
+
"data-index": item.index,
|
|
610
|
+
"data-color": item.color
|
|
611
|
+
},
|
|
612
|
+
[h("span", { class: "event-dot" }), h("span", { class: "event-title", text: item.title }), h("span", { class: "sr event-when", text: this.#when(item) })]
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
if (items.length > 3) {
|
|
616
|
+
nodes.push(
|
|
617
|
+
h("button", {
|
|
618
|
+
type: "button",
|
|
619
|
+
class: "more-events",
|
|
620
|
+
part: "more-button",
|
|
621
|
+
tabindex: -1,
|
|
622
|
+
"data-open-day": day,
|
|
623
|
+
text: fill(this.labelMore, this.#fmt.number.format(items.length - 3))
|
|
624
|
+
})
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
cell.querySelector(".cell-events").replaceChildren(...nodes);
|
|
628
|
+
}
|
|
629
|
+
/* ------------------------------------------------------------- year view */
|
|
630
|
+
#buildYear(anchor, today) {
|
|
631
|
+
const fmt = this.#fmt;
|
|
632
|
+
const { y } = fields(anchor);
|
|
633
|
+
const root = h("div", { class: "year-view" });
|
|
634
|
+
for (let month = 0; month < 12; month++) {
|
|
635
|
+
const first = toDay(y, month, 1);
|
|
636
|
+
const last = toDay(y, month + 1, 0);
|
|
637
|
+
const gridStart = first - (fields(first).w - this.#weekStart + 7) % 7;
|
|
638
|
+
const grid = h("div", { class: "year-month-grid grid", part: "grid", role: "grid", "aria-label": fmt.monthYear.format(utc(first)) });
|
|
639
|
+
grid.appendChild(h("div", { class: "year-day-names", role: "row" }, this.#weekdayHeaders(gridStart, "weekdayNarrow", today, false)));
|
|
640
|
+
for (let weekStart = gridStart; weekStart <= last; weekStart += 7) {
|
|
641
|
+
const row = h("div", { class: "year-days", role: "row" });
|
|
642
|
+
for (let day = weekStart; day < weekStart + 7; day++) {
|
|
643
|
+
if (day < first || day > last) {
|
|
644
|
+
row.appendChild(h("div", { class: "year-day empty", role: "gridcell" }));
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
const cell = h(
|
|
648
|
+
"div",
|
|
649
|
+
{
|
|
650
|
+
class: `year-day${day === today ? " today" : ""}`,
|
|
651
|
+
part: "day",
|
|
652
|
+
role: "gridcell",
|
|
653
|
+
"data-day": day,
|
|
654
|
+
"data-open-day": day,
|
|
655
|
+
"aria-current": day === today ? "date" : null
|
|
656
|
+
},
|
|
657
|
+
[h("span", { "aria-hidden": "true", text: fmt.dayNumber.format(utc(day)) }), h("span", { class: "sr day-label" })]
|
|
658
|
+
);
|
|
659
|
+
this.#cells.set(day, cell);
|
|
660
|
+
row.appendChild(cell);
|
|
661
|
+
}
|
|
662
|
+
grid.appendChild(row);
|
|
663
|
+
}
|
|
664
|
+
root.appendChild(h("div", { class: "year-month" }, [h("div", { class: "year-month-name", "aria-hidden": "true", text: fmt.month.format(utc(first)) }), grid]));
|
|
665
|
+
}
|
|
666
|
+
return root;
|
|
667
|
+
}
|
|
668
|
+
#drawYearDay(cell, day, items) {
|
|
669
|
+
cell.classList.toggle("has-events", items.length > 0);
|
|
670
|
+
setText(cell.querySelector(".day-label"), this.#dayLabel(day, items.length));
|
|
671
|
+
}
|
|
672
|
+
/* ----------------------------------------------------------- interaction */
|
|
673
|
+
/** A move the user made: sets the state, tells the page, draws at once. */
|
|
674
|
+
#go(day, view = this.#view) {
|
|
675
|
+
const before = this.#structure;
|
|
676
|
+
this.view = view;
|
|
677
|
+
this.date = iso(day);
|
|
678
|
+
this.#cursor = day;
|
|
679
|
+
this.#render();
|
|
680
|
+
if (this.#structure !== before) this.emit("change", { view: this.#view, date: iso(day) });
|
|
681
|
+
}
|
|
682
|
+
#onToolbarClick(event) {
|
|
683
|
+
const button = (
|
|
684
|
+
/** @type {Element} */
|
|
685
|
+
event.target.closest?.("button")
|
|
686
|
+
);
|
|
687
|
+
if (!button) return;
|
|
688
|
+
if (button.dataset.step) this.#go(this.#step(this.#cursor, Number(button.dataset.step)));
|
|
689
|
+
else if (button.dataset.view) this.#go(this.#cursor, button.dataset.view);
|
|
690
|
+
else this.#go(localDay(/* @__PURE__ */ new Date()));
|
|
691
|
+
}
|
|
692
|
+
#onContentClick(event) {
|
|
693
|
+
const target = (
|
|
694
|
+
/** @type {Element} */
|
|
695
|
+
event.target
|
|
696
|
+
);
|
|
697
|
+
const button = target.closest("button[data-index]");
|
|
698
|
+
if (button) {
|
|
699
|
+
const item = this.#items.find((it) => it.index === Number(button.dataset.index));
|
|
700
|
+
if (item) this.emit("select", { value: item.value, item: item.raw });
|
|
701
|
+
this.#moveCursor(button.closest("[data-day]"));
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const opener = target.closest("[data-open-day]");
|
|
705
|
+
if (opener) {
|
|
706
|
+
this.#open(Number(opener.dataset.openDay));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
this.#moveCursor(target.closest("[data-day]"));
|
|
710
|
+
}
|
|
711
|
+
#moveCursor(cell) {
|
|
712
|
+
if (!cell) return;
|
|
713
|
+
this.#cursor = Number(cell.dataset.day);
|
|
714
|
+
this.#rove();
|
|
715
|
+
}
|
|
716
|
+
/** Opens one day in the day view, keeping focus in the grid. */
|
|
717
|
+
#open(day) {
|
|
718
|
+
this.#go(day, "day");
|
|
719
|
+
this.#focusCell(day);
|
|
720
|
+
}
|
|
721
|
+
/** Moves the cursor to a day, changing period when it lies outside. */
|
|
722
|
+
#focusDay(day) {
|
|
723
|
+
if (!this.#cells.has(day)) this.#go(day);
|
|
724
|
+
this.#cursor = day;
|
|
725
|
+
this.#rove();
|
|
726
|
+
this.#focusCell(day);
|
|
727
|
+
}
|
|
728
|
+
#onKeydown(event) {
|
|
729
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
730
|
+
const target = (
|
|
731
|
+
/** @type {HTMLElement} */
|
|
732
|
+
event.target
|
|
733
|
+
);
|
|
734
|
+
const cell = (
|
|
735
|
+
/** @type {HTMLElement | null} */
|
|
736
|
+
target.closest("[data-day]")
|
|
737
|
+
);
|
|
738
|
+
if (!cell) return;
|
|
739
|
+
const day = Number(cell.dataset.day);
|
|
740
|
+
const view = this.#view;
|
|
741
|
+
const inCell = target === cell;
|
|
742
|
+
const buttons = (
|
|
743
|
+
/** @type {HTMLElement[]} */
|
|
744
|
+
[...cell.querySelectorAll("button")]
|
|
745
|
+
);
|
|
746
|
+
const at = buttons.indexOf(
|
|
747
|
+
/** @type {any} */
|
|
748
|
+
target.closest("button")
|
|
749
|
+
);
|
|
750
|
+
const flip = isRtl(this) ? -1 : 1;
|
|
751
|
+
const stacked = view === "month" || view === "year";
|
|
752
|
+
const done = () => event.preventDefault();
|
|
753
|
+
switch (event.key) {
|
|
754
|
+
case "ArrowRight":
|
|
755
|
+
this.#focusDay(day + flip);
|
|
756
|
+
return done();
|
|
757
|
+
case "ArrowLeft":
|
|
758
|
+
this.#focusDay(day - flip);
|
|
759
|
+
return done();
|
|
760
|
+
case "ArrowDown":
|
|
761
|
+
if (!inCell) buttons[Math.min(buttons.length - 1, at + 1)]?.focus();
|
|
762
|
+
else if (stacked) this.#focusDay(day + 7);
|
|
763
|
+
else buttons[0]?.focus();
|
|
764
|
+
return done();
|
|
765
|
+
case "ArrowUp":
|
|
766
|
+
if (!inCell) (buttons[at - 1] || cell).focus();
|
|
767
|
+
else if (stacked) this.#focusDay(day - 7);
|
|
768
|
+
return done();
|
|
769
|
+
case "Home":
|
|
770
|
+
case "End": {
|
|
771
|
+
if (!inCell) buttons.at(event.key === "Home" ? 0 : -1)?.focus();
|
|
772
|
+
else if (view !== "day") {
|
|
773
|
+
const offset = (fields(day).w - this.#weekStart + 7) % 7;
|
|
774
|
+
this.#focusDay(event.key === "Home" ? day - offset : day + 6 - offset);
|
|
775
|
+
}
|
|
776
|
+
return done();
|
|
777
|
+
}
|
|
778
|
+
case "PageUp":
|
|
779
|
+
this.#focusDay(this.#step(day, -1));
|
|
780
|
+
return done();
|
|
781
|
+
case "PageDown":
|
|
782
|
+
this.#focusDay(this.#step(day, 1));
|
|
783
|
+
return done();
|
|
784
|
+
case "Escape":
|
|
785
|
+
if (!inCell) {
|
|
786
|
+
cell.focus();
|
|
787
|
+
done();
|
|
788
|
+
}
|
|
789
|
+
return;
|
|
790
|
+
case "Enter":
|
|
791
|
+
case " ":
|
|
792
|
+
if (!inCell) return;
|
|
793
|
+
if (view === "year") this.#open(day);
|
|
794
|
+
else buttons[0]?.focus();
|
|
795
|
+
return done();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
function setText(el, text) {
|
|
800
|
+
if (el.textContent !== text) el.textContent = text;
|
|
801
|
+
}
|
|
802
|
+
function layout(boxes) {
|
|
803
|
+
let cluster = [];
|
|
804
|
+
let ends = [];
|
|
805
|
+
let clusterEnd = -1;
|
|
806
|
+
const close = () => {
|
|
807
|
+
for (const box of cluster) box.columns = ends.length;
|
|
808
|
+
cluster = [];
|
|
809
|
+
ends = [];
|
|
810
|
+
};
|
|
811
|
+
for (const box of boxes) {
|
|
812
|
+
if (cluster.length && box.s >= clusterEnd) close();
|
|
813
|
+
let column = ends.findIndex((end) => end <= box.s);
|
|
814
|
+
if (column < 0) column = ends.length;
|
|
815
|
+
ends[column] = box.e;
|
|
816
|
+
box.column = column;
|
|
817
|
+
cluster.push(box);
|
|
818
|
+
clusterEnd = Math.max(clusterEnd, box.e);
|
|
819
|
+
}
|
|
820
|
+
close();
|
|
821
|
+
}
|
|
822
|
+
define("punica-agenda", PunicaAgenda);
|
|
823
|
+
|
|
824
|
+
export {
|
|
825
|
+
PunicaAgenda
|
|
826
|
+
};
|