@consumidor-positivo/aurora 1.1.0 → 1.3.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/README.md +59 -3
- package/astro/AdBox/index.astro +28 -0
- package/astro/Alert/index.astro +257 -0
- package/astro/BadgeInfo/index.astro +55 -0
- package/astro/BadgeState/index.astro +79 -0
- package/astro/Button/index.astro +93 -0
- package/astro/Card/Container/index.astro +44 -0
- package/astro/Card/Emphasis/index.astro +39 -0
- package/astro/Card/Image/index.astro +26 -0
- package/astro/Card/Root/index.astro +53 -0
- package/astro/Card/Tag/index.astro +26 -0
- package/astro/Chip/index.astro +48 -0
- package/astro/ChipBanner/index.astro +160 -0
- package/astro/Container/index.astro +16 -0
- package/astro/Divider/index.astro +27 -0
- package/astro/Drawer/index.astro +95 -0
- package/astro/Footer/index.astro +329 -0
- package/astro/Header/Actions/index.astro +19 -0
- package/astro/Header/Badges/index.astro +19 -0
- package/astro/Header/Button/index.astro +16 -0
- package/astro/Header/Hamburger/index.astro +28 -0
- package/astro/Header/Logo/index.astro +25 -0
- package/astro/Header/Navbar/index.astro +24 -0
- package/astro/Header/NavbarLink/index.astro +137 -0
- package/astro/Header/Navigation/index.astro +11 -0
- package/astro/Header/Profile/index.astro +81 -0
- package/astro/Header/index.astro +19 -0
- package/astro/Icon/index.astro +49 -0
- package/astro/Image/index.astro +26 -0
- package/astro/LazyImage/index.astro +55 -0
- package/astro/LinkButton/index.astro +54 -0
- package/astro/Logo/ac/BadgeFullWhite.astro +20 -0
- package/astro/Logo/ac/BadgeWhite.astro +23 -0
- package/astro/Logo/ac/BadgeWhiteStroke.astro +27 -0
- package/astro/Logo/ac/BadgeWhiteStrokeDefault.astro +28 -0
- package/astro/Logo/ac/Badget.astro +24 -0
- package/astro/Logo/ac/Primary.astro +28 -0
- package/astro/Logo/ac/PrimaryFillWhite.astro +28 -0
- package/astro/Logo/ac/PrimaryFullWhite.astro +20 -0
- package/astro/Logo/ac/PrimaryNegative.astro +20 -0
- package/astro/Logo/ac/PrimaryWhite.astro +20 -0
- package/astro/Logo/ac/Tertiary.astro +28 -0
- package/astro/Logo/ac/TertiaryWhite.astro +72 -0
- package/astro/Logo/cp/BadgeWhiteStroke.astro +10 -0
- package/astro/Logo/cp/Badget.astro +14 -0
- package/astro/Logo/cp/Primary.astro +32 -0
- package/astro/Logo/cp/PrimaryFillWhite.astro +63 -0
- package/astro/Logo/cp/PrimaryFullWhite.astro +27 -0
- package/astro/Logo/cp/PrimaryLogoWhite.astro +67 -0
- package/astro/Logo/cp/PrimaryNegative.astro +27 -0
- package/astro/Logo/cp/PrimaryWhite.astro +27 -0
- package/astro/Logo/index.astro +29 -0
- package/astro/Modal/index.astro +213 -0
- package/astro/NavbarVertical/Link/index.astro +101 -0
- package/astro/NavbarVertical/index.astro +27 -0
- package/astro/NotificationsBar/Link/index.astro +70 -0
- package/astro/NotificationsBar/List/index.astro +38 -0
- package/astro/NotificationsBar/index.astro +24 -0
- package/astro/PartnerBanner/index.astro +52 -0
- package/astro/ProfileNav/index.astro +34 -0
- package/astro/ProgressBar/index.astro +70 -0
- package/astro/Skeleton/index.astro +50 -0
- package/astro/SpecialButton/index.astro +331 -0
- package/astro/Spinner/index.astro +75 -0
- package/astro/SubHeader/index.astro +57 -0
- package/astro/Switch/Card/index.astro +69 -0
- package/astro/Switch/Pure/index.astro +47 -0
- package/astro/Tabs/TabPanel/index.astro +23 -0
- package/astro/Tabs/index.astro +142 -0
- package/astro/Text/index.astro +75 -0
- package/astro/Tooltip/index.astro +38 -0
- package/astro/form/Checkbox/Field/index.astro +68 -0
- package/astro/form/Checkbox/Group/index.astro +79 -0
- package/astro/form/Datepicker/Calendar/index.astro +53 -0
- package/astro/form/Datepicker/CalendarHeader/index.astro +57 -0
- package/astro/form/Datepicker/Segment/index.astro +53 -0
- package/astro/form/Datepicker/index.astro +756 -0
- package/astro/form/EmailField/index.astro +237 -0
- package/astro/form/Field/ErrorMessage/index.astro +20 -0
- package/astro/form/Field/Input/index.astro +15 -0
- package/astro/form/Field/InputHolder/index.astro +28 -0
- package/astro/form/Field/Label/index.astro +80 -0
- package/astro/form/Field/Message/index.astro +29 -0
- package/astro/form/Field/Root/index.astro +37 -0
- package/astro/form/Field/TextArea/index.astro +69 -0
- package/astro/form/InputField/index.astro +96 -0
- package/astro/form/PasswordField/index.astro +123 -0
- package/astro/form/Radio/Field/index.astro +52 -0
- package/astro/form/Radio/Group/index.astro +78 -0
- package/astro/form/SelectField/index.astro +561 -0
- package/astro/form/TextareaField/index.astro +81 -0
- package/astro/form/TokenField/index.astro +211 -0
- package/astro/icons/default/IconActivity.astro +10 -0
- package/astro/icons/default/IconAi.astro +10 -0
- package/astro/icons/default/IconAiBox.astro +10 -0
- package/astro/icons/default/IconAirplay.astro +10 -0
- package/astro/icons/default/IconAlertCircle.astro +10 -0
- package/astro/icons/default/IconAlertOctagon.astro +10 -0
- package/astro/icons/default/IconAlertTriangle.astro +10 -0
- package/astro/icons/default/IconAlignCenter.astro +10 -0
- package/astro/icons/default/IconAlignJustify.astro +10 -0
- package/astro/icons/default/IconAlignLeft.astro +10 -0
- package/astro/icons/default/IconAlignRight.astro +10 -0
- package/astro/icons/default/IconAnchor.astro +10 -0
- package/astro/icons/default/IconAperture.astro +10 -0
- package/astro/icons/default/IconArchive.astro +10 -0
- package/astro/icons/default/IconArrowDown.astro +10 -0
- package/astro/icons/default/IconArrowDownCircle.astro +10 -0
- package/astro/icons/default/IconArrowDownLeft.astro +10 -0
- package/astro/icons/default/IconArrowDownRight.astro +10 -0
- package/astro/icons/default/IconArrowLeft.astro +10 -0
- package/astro/icons/default/IconArrowLeftCircle.astro +10 -0
- package/astro/icons/default/IconArrowRight.astro +10 -0
- package/astro/icons/default/IconArrowRightCircle.astro +10 -0
- package/astro/icons/default/IconArrowUp.astro +10 -0
- package/astro/icons/default/IconArrowUpCircle.astro +10 -0
- package/astro/icons/default/IconArrowUpLeft.astro +10 -0
- package/astro/icons/default/IconArrowUpRight.astro +10 -0
- package/astro/icons/default/IconAtSign.astro +10 -0
- package/astro/icons/default/IconAward.astro +10 -0
- package/astro/icons/default/IconBank.astro +10 -0
- package/astro/icons/default/IconBarChart.astro +10 -0
- package/astro/icons/default/IconBarChart2.astro +10 -0
- package/astro/icons/default/IconBarCode.astro +10 -0
- package/astro/icons/default/IconBarCode2.astro +10 -0
- package/astro/icons/default/IconBattery.astro +10 -0
- package/astro/icons/default/IconBatteryCharging.astro +10 -0
- package/astro/icons/default/IconBell.astro +10 -0
- package/astro/icons/default/IconBellOff.astro +10 -0
- package/astro/icons/default/IconBluetooth.astro +10 -0
- package/astro/icons/default/IconBold.astro +10 -0
- package/astro/icons/default/IconBook.astro +10 -0
- package/astro/icons/default/IconBookOpen.astro +10 -0
- package/astro/icons/default/IconBookmark.astro +10 -0
- package/astro/icons/default/IconBox.astro +10 -0
- package/astro/icons/default/IconBriefcase.astro +10 -0
- package/astro/icons/default/IconCake.astro +10 -0
- package/astro/icons/default/IconCalendar.astro +10 -0
- package/astro/icons/default/IconCamera.astro +10 -0
- package/astro/icons/default/IconCameraOff.astro +10 -0
- package/astro/icons/default/IconCar.astro +10 -0
- package/astro/icons/default/IconCast.astro +10 -0
- package/astro/icons/default/IconCheck.astro +10 -0
- package/astro/icons/default/IconCheckCircle.astro +10 -0
- package/astro/icons/default/IconCheckSquare.astro +10 -0
- package/astro/icons/default/IconChevronDown.astro +10 -0
- package/astro/icons/default/IconChevronLeft.astro +10 -0
- package/astro/icons/default/IconChevronRight.astro +10 -0
- package/astro/icons/default/IconChevronUp.astro +10 -0
- package/astro/icons/default/IconChevronsDown.astro +10 -0
- package/astro/icons/default/IconChevronsLeft.astro +10 -0
- package/astro/icons/default/IconChevronsRight.astro +10 -0
- package/astro/icons/default/IconChevronsUp.astro +10 -0
- package/astro/icons/default/IconChrome.astro +10 -0
- package/astro/icons/default/IconCircle.astro +10 -0
- package/astro/icons/default/IconClipboard.astro +10 -0
- package/astro/icons/default/IconClock.astro +10 -0
- package/astro/icons/default/IconCloud.astro +10 -0
- package/astro/icons/default/IconCloudDrizzle.astro +10 -0
- package/astro/icons/default/IconCloudLightning.astro +10 -0
- package/astro/icons/default/IconCloudOff.astro +10 -0
- package/astro/icons/default/IconCloudRain.astro +10 -0
- package/astro/icons/default/IconCloudSnow.astro +10 -0
- package/astro/icons/default/IconCode.astro +10 -0
- package/astro/icons/default/IconCodepen.astro +10 -0
- package/astro/icons/default/IconCodesandbox.astro +10 -0
- package/astro/icons/default/IconCoffee.astro +10 -0
- package/astro/icons/default/IconCoin.astro +10 -0
- package/astro/icons/default/IconCollapseClose.astro +10 -0
- package/astro/icons/default/IconCollapseOpen.astro +10 -0
- package/astro/icons/default/IconColumns.astro +10 -0
- package/astro/icons/default/IconCommand.astro +10 -0
- package/astro/icons/default/IconCompass.astro +10 -0
- package/astro/icons/default/IconCookie.astro +10 -0
- package/astro/icons/default/IconCopy.astro +10 -0
- package/astro/icons/default/IconCornerDownLeft.astro +10 -0
- package/astro/icons/default/IconCornerDownRight.astro +10 -0
- package/astro/icons/default/IconCornerLeftDown.astro +10 -0
- package/astro/icons/default/IconCornerLeftUp.astro +10 -0
- package/astro/icons/default/IconCornerRightDown.astro +10 -0
- package/astro/icons/default/IconCornerRightUp.astro +10 -0
- package/astro/icons/default/IconCornerUpLeft.astro +10 -0
- package/astro/icons/default/IconCornerUpRight.astro +10 -0
- package/astro/icons/default/IconCpu.astro +10 -0
- package/astro/icons/default/IconCreditCard.astro +10 -0
- package/astro/icons/default/IconCrop.astro +10 -0
- package/astro/icons/default/IconCrosshair.astro +10 -0
- package/astro/icons/default/IconDatabase.astro +10 -0
- package/astro/icons/default/IconDelete.astro +10 -0
- package/astro/icons/default/IconDisc.astro +10 -0
- package/astro/icons/default/IconDivide.astro +10 -0
- package/astro/icons/default/IconDivideCircle.astro +10 -0
- package/astro/icons/default/IconDivideSquare.astro +10 -0
- package/astro/icons/default/IconDollarSign.astro +10 -0
- package/astro/icons/default/IconDownload.astro +10 -0
- package/astro/icons/default/IconDownloadCloud.astro +10 -0
- package/astro/icons/default/IconDribbble.astro +10 -0
- package/astro/icons/default/IconDroplet.astro +10 -0
- package/astro/icons/default/IconEdit.astro +10 -0
- package/astro/icons/default/IconEdit2.astro +10 -0
- package/astro/icons/default/IconEdit3.astro +10 -0
- package/astro/icons/default/IconExternalLink.astro +10 -0
- package/astro/icons/default/IconEye.astro +10 -0
- package/astro/icons/default/IconEyeOff.astro +10 -0
- package/astro/icons/default/IconFacebook.astro +10 -0
- package/astro/icons/default/IconFastForward.astro +10 -0
- package/astro/icons/default/IconFeather.astro +10 -0
- package/astro/icons/default/IconFigma.astro +10 -0
- package/astro/icons/default/IconFile.astro +10 -0
- package/astro/icons/default/IconFileMinus.astro +10 -0
- package/astro/icons/default/IconFilePdf.astro +10 -0
- package/astro/icons/default/IconFilePlus.astro +10 -0
- package/astro/icons/default/IconFileText.astro +10 -0
- package/astro/icons/default/IconFilm.astro +10 -0
- package/astro/icons/default/IconFilter.astro +10 -0
- package/astro/icons/default/IconFirecracker.astro +10 -0
- package/astro/icons/default/IconFlag.astro +10 -0
- package/astro/icons/default/IconFolder.astro +10 -0
- package/astro/icons/default/IconFolderMinus.astro +10 -0
- package/astro/icons/default/IconFolderPlus.astro +10 -0
- package/astro/icons/default/IconFramer.astro +10 -0
- package/astro/icons/default/IconFrown.astro +10 -0
- package/astro/icons/default/IconGift.astro +10 -0
- package/astro/icons/default/IconGitBranch.astro +10 -0
- package/astro/icons/default/IconGitCommit.astro +10 -0
- package/astro/icons/default/IconGitMerge.astro +10 -0
- package/astro/icons/default/IconGitPullRequest.astro +10 -0
- package/astro/icons/default/IconGithub.astro +10 -0
- package/astro/icons/default/IconGitlab.astro +10 -0
- package/astro/icons/default/IconGiveMoney.astro +10 -0
- package/astro/icons/default/IconGlasses.astro +10 -0
- package/astro/icons/default/IconGlobe.astro +10 -0
- package/astro/icons/default/IconGraduationHat.astro +10 -0
- package/astro/icons/default/IconGrid.astro +10 -0
- package/astro/icons/default/IconHardDrive.astro +10 -0
- package/astro/icons/default/IconHash.astro +10 -0
- package/astro/icons/default/IconHeadphones.astro +10 -0
- package/astro/icons/default/IconHeart.astro +10 -0
- package/astro/icons/default/IconHelpCircle.astro +10 -0
- package/astro/icons/default/IconHexagon.astro +10 -0
- package/astro/icons/default/IconHome.astro +10 -0
- package/astro/icons/default/IconHomeChimney.astro +10 -0
- package/astro/icons/default/IconId.astro +10 -0
- package/astro/icons/default/IconImage.astro +10 -0
- package/astro/icons/default/IconInbox.astro +10 -0
- package/astro/icons/default/IconInfo.astro +10 -0
- package/astro/icons/default/IconInstagram.astro +10 -0
- package/astro/icons/default/IconItalic.astro +10 -0
- package/astro/icons/default/IconKey.astro +10 -0
- package/astro/icons/default/IconLaptop.astro +10 -0
- package/astro/icons/default/IconLayers.astro +10 -0
- package/astro/icons/default/IconLayout.astro +10 -0
- package/astro/icons/default/IconLifeBuoy.astro +10 -0
- package/astro/icons/default/IconLightBulb.astro +10 -0
- package/astro/icons/default/IconLink.astro +10 -0
- package/astro/icons/default/IconLink2.astro +10 -0
- package/astro/icons/default/IconLinkedin.astro +10 -0
- package/astro/icons/default/IconLips.astro +10 -0
- package/astro/icons/default/IconList.astro +10 -0
- package/astro/icons/default/IconLoader.astro +10 -0
- package/astro/icons/default/IconLock.astro +10 -0
- package/astro/icons/default/IconLogIn.astro +10 -0
- package/astro/icons/default/IconLogOut.astro +10 -0
- package/astro/icons/default/IconMail.astro +10 -0
- package/astro/icons/default/IconMap.astro +10 -0
- package/astro/icons/default/IconMapPin.astro +10 -0
- package/astro/icons/default/IconMaximize.astro +10 -0
- package/astro/icons/default/IconMaximize2.astro +10 -0
- package/astro/icons/default/IconMeh.astro +10 -0
- package/astro/icons/default/IconMenu.astro +10 -0
- package/astro/icons/default/IconMessageCircle.astro +10 -0
- package/astro/icons/default/IconMessageSquare.astro +10 -0
- package/astro/icons/default/IconMic.astro +10 -0
- package/astro/icons/default/IconMicOff.astro +10 -0
- package/astro/icons/default/IconMinimize.astro +10 -0
- package/astro/icons/default/IconMinimize2.astro +10 -0
- package/astro/icons/default/IconMinus.astro +10 -0
- package/astro/icons/default/IconMinusCircle.astro +10 -0
- package/astro/icons/default/IconMinusSquare.astro +10 -0
- package/astro/icons/default/IconMoney.astro +10 -0
- package/astro/icons/default/IconMonitor.astro +10 -0
- package/astro/icons/default/IconMoon.astro +10 -0
- package/astro/icons/default/IconMoreHorizontal.astro +10 -0
- package/astro/icons/default/IconMoreVertical.astro +10 -0
- package/astro/icons/default/IconMousePointer.astro +10 -0
- package/astro/icons/default/IconMove.astro +10 -0
- package/astro/icons/default/IconMusic.astro +10 -0
- package/astro/icons/default/IconNavigation.astro +10 -0
- package/astro/icons/default/IconNavigation2.astro +10 -0
- package/astro/icons/default/IconNegotiation.astro +10 -0
- package/astro/icons/default/IconObjective.astro +10 -0
- package/astro/icons/default/IconOctagon.astro +10 -0
- package/astro/icons/default/IconPackage.astro +10 -0
- package/astro/icons/default/IconPaperclip.astro +10 -0
- package/astro/icons/default/IconPause.astro +10 -0
- package/astro/icons/default/IconPauseCircle.astro +10 -0
- package/astro/icons/default/IconPenTool.astro +10 -0
- package/astro/icons/default/IconPencilPack.astro +10 -0
- package/astro/icons/default/IconPercent.astro +10 -0
- package/astro/icons/default/IconPercentBalloon.astro +10 -0
- package/astro/icons/default/IconPhone.astro +10 -0
- package/astro/icons/default/IconPhoneCall.astro +10 -0
- package/astro/icons/default/IconPhoneForwarded.astro +10 -0
- package/astro/icons/default/IconPhoneIncoming.astro +10 -0
- package/astro/icons/default/IconPhoneMissed.astro +10 -0
- package/astro/icons/default/IconPhoneOff.astro +10 -0
- package/astro/icons/default/IconPhoneOutgoing.astro +10 -0
- package/astro/icons/default/IconPieChart.astro +10 -0
- package/astro/icons/default/IconPix.astro +10 -0
- package/astro/icons/default/IconPlane.astro +10 -0
- package/astro/icons/default/IconPlay.astro +10 -0
- package/astro/icons/default/IconPlayCircle.astro +10 -0
- package/astro/icons/default/IconPlus.astro +10 -0
- package/astro/icons/default/IconPlusCircle.astro +10 -0
- package/astro/icons/default/IconPlusSquare.astro +10 -0
- package/astro/icons/default/IconPocket.astro +10 -0
- package/astro/icons/default/IconPower.astro +10 -0
- package/astro/icons/default/IconPrinter.astro +10 -0
- package/astro/icons/default/IconQrCode.astro +10 -0
- package/astro/icons/default/IconRadio.astro +10 -0
- package/astro/icons/default/IconRefreshCcw.astro +10 -0
- package/astro/icons/default/IconRefreshCw.astro +10 -0
- package/astro/icons/default/IconRepeat.astro +10 -0
- package/astro/icons/default/IconRewind.astro +10 -0
- package/astro/icons/default/IconRotateCcw.astro +10 -0
- package/astro/icons/default/IconRotateCw.astro +10 -0
- package/astro/icons/default/IconRss.astro +10 -0
- package/astro/icons/default/IconSave.astro +10 -0
- package/astro/icons/default/IconSaveMoney.astro +10 -0
- package/astro/icons/default/IconSchoolBag.astro +10 -0
- package/astro/icons/default/IconScissors.astro +10 -0
- package/astro/icons/default/IconSearch.astro +10 -0
- package/astro/icons/default/IconSend.astro +10 -0
- package/astro/icons/default/IconServer.astro +10 -0
- package/astro/icons/default/IconSettings.astro +10 -0
- package/astro/icons/default/IconShare.astro +10 -0
- package/astro/icons/default/IconShare2.astro +10 -0
- package/astro/icons/default/IconShield.astro +10 -0
- package/astro/icons/default/IconShieldLocked.astro +10 -0
- package/astro/icons/default/IconShieldOff.astro +10 -0
- package/astro/icons/default/IconShoppingBag.astro +10 -0
- package/astro/icons/default/IconShoppingCart.astro +10 -0
- package/astro/icons/default/IconShuffle.astro +10 -0
- package/astro/icons/default/IconSidebar.astro +10 -0
- package/astro/icons/default/IconSkipBack.astro +10 -0
- package/astro/icons/default/IconSkipForward.astro +10 -0
- package/astro/icons/default/IconSlack.astro +10 -0
- package/astro/icons/default/IconSlash.astro +10 -0
- package/astro/icons/default/IconSliders.astro +10 -0
- package/astro/icons/default/IconSmartphone.astro +10 -0
- package/astro/icons/default/IconSmartphoneSms.astro +10 -0
- package/astro/icons/default/IconSmile.astro +10 -0
- package/astro/icons/default/IconSpark.astro +10 -0
- package/astro/icons/default/IconSpeaker.astro +10 -0
- package/astro/icons/default/IconSquare.astro +10 -0
- package/astro/icons/default/IconStar.astro +10 -0
- package/astro/icons/default/IconStopCircle.astro +10 -0
- package/astro/icons/default/IconSun.astro +10 -0
- package/astro/icons/default/IconSunrise.astro +10 -0
- package/astro/icons/default/IconSunset.astro +10 -0
- package/astro/icons/default/IconTable.astro +10 -0
- package/astro/icons/default/IconTablet.astro +10 -0
- package/astro/icons/default/IconTag.astro +10 -0
- package/astro/icons/default/IconTarget.astro +10 -0
- package/astro/icons/default/IconTerminal.astro +10 -0
- package/astro/icons/default/IconThermometer.astro +10 -0
- package/astro/icons/default/IconThumbsDown.astro +10 -0
- package/astro/icons/default/IconThumbsUp.astro +10 -0
- package/astro/icons/default/IconTiktok.astro +10 -0
- package/astro/icons/default/IconToggleLeft.astro +10 -0
- package/astro/icons/default/IconToggleRight.astro +10 -0
- package/astro/icons/default/IconTool.astro +10 -0
- package/astro/icons/default/IconTrash.astro +10 -0
- package/astro/icons/default/IconTrash2.astro +10 -0
- package/astro/icons/default/IconTrello.astro +10 -0
- package/astro/icons/default/IconTrendingDown.astro +10 -0
- package/astro/icons/default/IconTrendingUp.astro +10 -0
- package/astro/icons/default/IconTriangle.astro +10 -0
- package/astro/icons/default/IconTrophy.astro +10 -0
- package/astro/icons/default/IconTruck.astro +10 -0
- package/astro/icons/default/IconTv.astro +10 -0
- package/astro/icons/default/IconTwitch.astro +10 -0
- package/astro/icons/default/IconTwitter.astro +10 -0
- package/astro/icons/default/IconType.astro +10 -0
- package/astro/icons/default/IconUmbrella.astro +10 -0
- package/astro/icons/default/IconUnderline.astro +10 -0
- package/astro/icons/default/IconUnlock.astro +10 -0
- package/astro/icons/default/IconUpload.astro +10 -0
- package/astro/icons/default/IconUploadCloud.astro +10 -0
- package/astro/icons/default/IconUser.astro +10 -0
- package/astro/icons/default/IconUserCheck.astro +10 -0
- package/astro/icons/default/IconUserMinus.astro +10 -0
- package/astro/icons/default/IconUserPlus.astro +10 -0
- package/astro/icons/default/IconUserX.astro +10 -0
- package/astro/icons/default/IconUsers.astro +10 -0
- package/astro/icons/default/IconVelocimeter.astro +10 -0
- package/astro/icons/default/IconVideo.astro +10 -0
- package/astro/icons/default/IconVideoOff.astro +10 -0
- package/astro/icons/default/IconVoicemail.astro +10 -0
- package/astro/icons/default/IconVolume1.astro +10 -0
- package/astro/icons/default/IconVolume2.astro +10 -0
- package/astro/icons/default/IconVolumeX.astro +10 -0
- package/astro/icons/default/IconWarning.astro +10 -0
- package/astro/icons/default/IconWatch.astro +10 -0
- package/astro/icons/default/IconWebsite.astro +10 -0
- package/astro/icons/default/IconWhatsapp.astro +10 -0
- package/astro/icons/default/IconWifi.astro +10 -0
- package/astro/icons/default/IconWifiOff.astro +10 -0
- package/astro/icons/default/IconWind.astro +10 -0
- package/astro/icons/default/IconX.astro +10 -0
- package/astro/icons/default/IconXCircle.astro +10 -0
- package/astro/icons/default/IconXOctagon.astro +10 -0
- package/astro/icons/default/IconXSquare.astro +10 -0
- package/astro/icons/default/IconYoutube.astro +10 -0
- package/astro/icons/default/IconZap.astro +10 -0
- package/astro/icons/default/IconZapOff.astro +10 -0
- package/astro/icons/default/IconZoomIn.astro +10 -0
- package/astro/icons/default/IconZoomOut.astro +10 -0
- package/astro/icons/social/IconSocialGoogle.astro +10 -0
- package/astro/runtime/package.json +6 -0
- package/astro/tokens/package.json +6 -0
- package/dist/astro/runtime/elementController.d.ts +6 -0
- package/dist/astro/runtime/factories.d.ts +5 -0
- package/dist/astro/runtime/index.d.ts +2 -0
- package/dist/astro/runtime/index.es.js +68 -0
- package/dist/astro/runtime/index.es.js.map +1 -0
- package/dist/astro/runtime/types.d.ts +28 -0
- package/dist/{tokens-C4yCunfz.js → astro/tokens/index.es.js} +101 -101
- package/dist/astro/tokens/index.es.js.map +1 -0
- package/dist/components/AdBox/index.es.js +1 -1
- package/dist/components/Alert/index.es.js +3 -3
- package/dist/components/BadgeInfo/index.es.js +2 -2
- package/dist/components/BadgeState/index.es.js +2 -2
- package/dist/components/Button/index.es.js +2 -2
- package/dist/components/Card/Container/index.es.js +26 -0
- package/dist/components/Card/Container/index.es.js.map +1 -0
- package/dist/components/{Emphasis → Card/Emphasis}/index.es.js +1 -1
- package/dist/components/Card/Emphasis/index.es.js.map +1 -0
- package/dist/components/Card/Image/index.es.js +18 -0
- package/dist/components/Card/Image/index.es.js.map +1 -0
- package/dist/components/Card/Root/index.es.js +44 -0
- package/dist/components/Card/Root/index.es.js.map +1 -0
- package/dist/components/{Tag → Card/Tag}/index.es.js +1 -1
- package/dist/components/Card/Tag/index.es.js.map +1 -0
- package/dist/components/Card/index.es.js +16 -21
- package/dist/components/Card/index.es.js.map +1 -1
- package/dist/components/Card/styles.css +1 -1
- package/dist/components/Card/styles2.css +1 -0
- package/dist/components/Chip/index.es.js +1 -1
- package/dist/components/ChipBanner/index.es.js +1 -1
- package/dist/components/Container/index.es.js +1 -1
- package/dist/components/Divider/index.es.js +1 -1
- package/dist/components/Drawer/index.es.js +1 -1
- package/dist/components/Field/styles.css +1 -1
- package/dist/components/Field/styles2.css +1 -0
- package/dist/components/Field/styles3.css +1 -0
- package/dist/components/Footer/index.es.js +2 -2
- package/dist/components/Footer/styles.css +1 -1
- package/dist/components/Group/styles2.css +1 -0
- package/dist/components/Header/Actions/index.es.js +22 -0
- package/dist/components/Header/Actions/index.es.js.map +1 -0
- package/dist/components/Header/Badges/index.es.js +16 -0
- package/dist/components/Header/Badges/index.es.js.map +1 -0
- package/dist/components/Header/Button/index.es.js +21 -0
- package/dist/components/Header/Button/index.es.js.map +1 -0
- package/dist/components/Header/Hamburger/index.es.js +29 -0
- package/dist/components/Header/Hamburger/index.es.js.map +1 -0
- package/dist/components/Header/Logo/index.es.js +30 -0
- package/dist/components/Header/Logo/index.es.js.map +1 -0
- package/dist/components/Header/Navbar/index.es.js +14 -0
- package/dist/components/Header/Navbar/index.es.js.map +1 -0
- package/dist/components/Header/NavbarLink/index.es.js +104 -0
- package/dist/components/Header/NavbarLink/index.es.js.map +1 -0
- package/dist/components/Header/Navigation/index.es.js +11 -0
- package/dist/components/Header/Navigation/index.es.js.map +1 -0
- package/dist/components/Header/Profile/index.es.js +80 -0
- package/dist/components/Header/Profile/index.es.js.map +1 -0
- package/dist/components/Header/Wrap/index.es.js +24 -0
- package/dist/components/Header/Wrap/index.es.js.map +1 -0
- package/dist/components/Header/index.d.ts +9 -9
- package/dist/components/Header/index.es.js +11 -290
- package/dist/components/Header/index.es.js.map +1 -1
- package/dist/components/Icon/index.es.js +1 -1
- package/dist/components/Image/index.es.js +1 -1
- package/dist/components/IsMobile/index.es.js +1 -1
- package/dist/components/LinkButton/index.es.js +1 -1
- package/dist/components/Modal/index.es.js +1 -1
- package/dist/components/NavbarVertical/index.es.js +2 -2
- package/dist/components/NavbarVertical/styles.css +1 -1
- package/dist/components/NotificationsBar/index.es.js +1 -1
- package/dist/components/PartnerBanner/index.es.js +1 -1
- package/dist/components/ProgressBar/index.es.js +2 -2
- package/dist/components/{Carousel → Prototype/Carousel}/index.es.js +8 -8
- package/dist/components/Prototype/Carousel/index.es.js.map +1 -0
- package/dist/components/Skeleton/index.es.js +1 -1
- package/dist/components/SpecialButton/index.es.js +2 -2
- package/dist/components/Spinner/index.es.js +2 -2
- package/dist/components/SubHeader/index.es.js +1 -1
- package/dist/components/Switch/Card/index.es.js +25 -0
- package/dist/components/Switch/Card/index.es.js.map +1 -0
- package/dist/components/{Pure → Switch/Pure}/index.es.js +1 -1
- package/dist/components/Switch/Pure/index.es.js.map +1 -0
- package/dist/components/Tabs/index.es.js +1 -1
- package/dist/components/Tabs/styles.css +1 -1
- package/dist/components/Text/index.es.js +3 -3
- package/dist/components/Tooltip/index.es.js +1 -1
- package/dist/components/Transition/index.es.js +1 -1
- package/dist/components/form/Checkbox/Field/index.es.js +60 -0
- package/dist/components/form/Checkbox/Field/index.es.js.map +1 -0
- package/dist/components/{Checkbox → form/Checkbox/Group}/index.es.js +8 -66
- package/dist/components/form/Checkbox/Group/index.es.js.map +1 -0
- package/dist/components/form/Checkbox/index.es.js +14 -0
- package/dist/components/form/Checkbox/index.es.js.map +1 -0
- package/dist/components/form/Datepicker/Calendar/index.es.js +10 -0
- package/dist/components/form/Datepicker/CalendarHeader/index.es.js +12 -0
- package/dist/components/{PortalHolder → form/Datepicker/PortalHolder}/index.es.js +3 -3
- package/dist/components/form/Datepicker/PortalHolder/index.es.js.map +1 -0
- package/dist/components/form/Datepicker/Segment/index.es.js +12 -0
- package/dist/components/{Datepicker → form/Datepicker}/index.es.js +8 -8
- package/dist/components/form/Datepicker/index.es.js.map +1 -0
- package/dist/components/{EmailField → form/EmailField}/index.es.js +3 -3
- package/dist/components/form/EmailField/index.es.js.map +1 -0
- package/dist/components/form/Field/ErrorMessage/index.es.js.map +1 -0
- package/dist/components/{Input → form/Field/Input}/index.es.js +1 -1
- package/dist/components/form/Field/Input/index.es.js.map +1 -0
- package/dist/components/form/Field/InputHolder/index.es.js.map +1 -0
- package/dist/components/{Label → form/Field/Label}/index.es.js +6 -6
- package/dist/components/form/Field/Label/index.es.js.map +1 -0
- package/dist/components/form/Field/Message/index.es.js.map +1 -0
- package/dist/components/{Root → form/Field/Root}/index.es.js +1 -1
- package/dist/components/form/Field/Root/index.es.js.map +1 -0
- package/dist/components/{TextArea → form/Field/TextArea}/index.es.js +2 -2
- package/dist/components/form/Field/TextArea/index.es.js.map +1 -0
- package/dist/components/form/Field/index.es.js +20 -0
- package/dist/components/form/Field/index.es.js.map +1 -0
- package/dist/components/{InputField → form/InputField}/index.es.js +1 -1
- package/dist/components/form/InputField/index.es.js.map +1 -0
- package/dist/components/{PasswordField → form/PasswordField}/index.es.js +2 -2
- package/dist/components/form/PasswordField/index.es.js.map +1 -0
- package/dist/components/{Field → form/Radio/Field}/index.es.js +2 -2
- package/dist/components/form/Radio/Field/index.es.js.map +1 -0
- package/dist/components/{Group → form/Radio/Group}/index.es.js +5 -5
- package/dist/components/form/Radio/Group/index.es.js.map +1 -0
- package/dist/components/{Radio → form/Radio}/index.es.js +2 -2
- package/dist/components/form/Radio/index.es.js.map +1 -0
- package/dist/components/{SelectField → form/SelectField}/index.es.js +13 -13
- package/dist/components/form/SelectField/index.es.js.map +1 -0
- package/dist/components/{TextareaField → form/TextareaField}/index.es.js +1 -1
- package/dist/components/form/TextareaField/index.es.js.map +1 -0
- package/dist/components/{TokenField → form/TokenField}/index.es.js +2 -2
- package/dist/components/form/TokenField/index.es.js.map +1 -0
- package/dist/components/globalStyles/index.es.js +2 -0
- package/dist/components/globalStyles/index.es.js.map +1 -0
- package/dist/components/globalStyles/styles.css +1 -0
- package/dist/components/icons/default/index.es.js +655 -0
- package/dist/components/icons/social/index.es.js +5 -0
- package/dist/components/index/styles.css +1 -1
- package/dist/components/index/styles2.css +1 -1
- package/dist/components/index/styles3.css +1 -1
- package/dist/components/misc/Conditional/index.es.js.map +1 -0
- package/dist/components/misc/DynamicTagComponent/index.es.js.map +1 -0
- package/dist/components/{Portal → misc/Portal}/index.es.js +2 -2
- package/dist/components/misc/Portal/index.es.js.map +1 -0
- package/dist/components/misc/index.es.js +1 -1
- package/dist/{index-C6Q03EyZ.js → index-BW2ZU5Hx.js} +2 -30
- package/dist/{index-C6Q03EyZ.js.map → index-BW2ZU5Hx.js.map} +1 -1
- package/dist/{index-DHwXRotU.js → index-Bkl5OBIY.js} +6 -6
- package/dist/{index-DHwXRotU.js.map → index-Bkl5OBIY.js.map} +1 -1
- package/dist/{index-BgBOcVUP.js → index-CZfMkAoF.js} +4 -4
- package/dist/{index-BgBOcVUP.js.map → index-CZfMkAoF.js.map} +1 -1
- package/dist/{index-DnQGzfVW.js → index-Cw1KtRQr.js} +4 -4
- package/dist/{index-DnQGzfVW.js.map → index-Cw1KtRQr.js.map} +1 -1
- package/dist/main.es.js +117 -201
- package/dist/main.es.js.map +1 -1
- package/package.json +27 -10
- package/dist/components/AdBox/AdBox.test.d.ts +0 -1
- package/dist/components/Alert/Alert.test.d.ts +0 -1
- package/dist/components/BadgeInfo/BadgeInfo.test.d.ts +0 -1
- package/dist/components/BadgeState/BadgeState.test.d.ts +0 -1
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/components/Calendar/index.es.js +0 -10
- package/dist/components/CalendarHeader/index.es.js +0 -12
- package/dist/components/Card/Card.test.d.ts +0 -1
- package/dist/components/Carousel/index.es.js.map +0 -1
- package/dist/components/Checkbox/index.es.js.map +0 -1
- package/dist/components/Checkbox/styles.css +0 -1
- package/dist/components/ChipBanner/ChipBanner.test.d.ts +0 -1
- package/dist/components/Conditional/index.es.js.map +0 -1
- package/dist/components/Container/Container.test.d.ts +0 -1
- package/dist/components/Datepicker/index.es.js.map +0 -1
- package/dist/components/Drawer/Drawer.test.d.ts +0 -1
- package/dist/components/DynamicTagComponent/index.es.js.map +0 -1
- package/dist/components/EmailField/index.es.js.map +0 -1
- package/dist/components/Emphasis/index.es.js.map +0 -1
- package/dist/components/ErrorMessage/index.es.js.map +0 -1
- package/dist/components/Field/index.es.js.map +0 -1
- package/dist/components/Footer/Footer.test.d.ts +0 -1
- package/dist/components/Group/index.es.js.map +0 -1
- package/dist/components/Header/Header.test.d.ts +0 -1
- package/dist/components/Image/Image.test.d.ts +0 -1
- package/dist/components/Input/index.es.js.map +0 -1
- package/dist/components/InputField/index.es.js.map +0 -1
- package/dist/components/InputHolder/index.es.js.map +0 -1
- package/dist/components/IsMobile/IsMobile.test.d.ts +0 -1
- package/dist/components/Label/index.es.js.map +0 -1
- package/dist/components/LazyImage/LazyImage.test.d.ts +0 -1
- package/dist/components/LinkButton/LinkButton.test.d.ts +0 -1
- package/dist/components/Logo/Logo.test.d.ts +0 -1
- package/dist/components/Message/index.es.js.map +0 -1
- package/dist/components/Modal/Modal.test.d.ts +0 -1
- package/dist/components/NavbarVertical/NavbarVertical.test.d.ts +0 -1
- package/dist/components/NotificationsBar/NotificationsBar.test.d.ts +0 -1
- package/dist/components/PartnerBanner/PartnerBanner.test.d.ts +0 -1
- package/dist/components/PasswordField/index.es.js.map +0 -1
- package/dist/components/Portal/index.es.js.map +0 -1
- package/dist/components/PortalHolder/index.es.js.map +0 -1
- package/dist/components/ProfileNav/ProfileNav.test.d.ts +0 -1
- package/dist/components/ProgressBar/ProgressBar.test.d.ts +0 -1
- package/dist/components/Prototype/Carousel/Carousel.test.d.ts +0 -1
- package/dist/components/Pure/index.es.js.map +0 -1
- package/dist/components/Radio/index.es.js.map +0 -1
- package/dist/components/Root/index.es.js.map +0 -1
- package/dist/components/Segment/index.es.js +0 -12
- package/dist/components/SelectField/index.es.js.map +0 -1
- package/dist/components/Skeleton/Skeleton.test.d.ts +0 -1
- package/dist/components/SpecialButton/SpecialButton.test.d.ts +0 -1
- package/dist/components/Spinner/Spinner.test.d.ts +0 -1
- package/dist/components/SubHeader/SubHeader.test.d.ts +0 -1
- package/dist/components/Switch/Card/Card.test.d.ts +0 -1
- package/dist/components/Switch/Pure/Switch.test.d.ts +0 -1
- package/dist/components/Tabs/Tabs.test.d.ts +0 -1
- package/dist/components/Tag/index.es.js.map +0 -1
- package/dist/components/Text/Text.test.d.ts +0 -1
- package/dist/components/TextArea/index.es.js.map +0 -1
- package/dist/components/TextareaField/index.es.js.map +0 -1
- package/dist/components/TokenField/index.es.js.map +0 -1
- package/dist/components/Transition/Transition.test.d.ts +0 -1
- package/dist/components/dataTestId.test.d.ts +0 -1
- package/dist/components/default/index.es.js +0 -655
- package/dist/components/form/Checkbox/Checkbox.test.d.ts +0 -1
- package/dist/components/form/Datepicker/Datepicker.test.d.ts +0 -1
- package/dist/components/form/EmailField/EmailField.test.d.ts +0 -1
- package/dist/components/form/Field/Field.test.d.ts +0 -1
- package/dist/components/form/InputField/InputField.test.d.ts +0 -1
- package/dist/components/form/PasswordField/PasswordField.test.d.ts +0 -1
- package/dist/components/form/Radio/Radio.test.d.ts +0 -1
- package/dist/components/form/SelectField/SelectField.test.d.ts +0 -1
- package/dist/components/form/TextareaField/TextareaField.test.d.ts +0 -1
- package/dist/components/form/TokenField/TokenField.test.d.ts +0 -1
- package/dist/components/icons/Icon.test/index.es.js +0 -36183
- package/dist/components/icons/Icon.test/index.es.js.map +0 -1
- package/dist/components/icons/Icon.test.d.ts +0 -1
- package/dist/components/index/styles4.css +0 -1
- package/dist/components/main/styles.css +0 -1
- package/dist/components/misc/misc.test.d.ts +0 -1
- package/dist/components/social/index.es.js +0 -5
- package/dist/index-ZE6zszxw.js +0 -20
- package/dist/index-ZE6zszxw.js.map +0 -1
- package/dist/magic-string.es-D_W5SHWE.js +0 -1074
- package/dist/magic-string.es-D_W5SHWE.js.map +0 -1
- package/dist/tokens-C4yCunfz.js.map +0 -1
- /package/dist/components/Header/{parts/HeaderActions.d.ts → Actions/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderBadges.d.ts → Badges/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderButton.d.ts → Button/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderHamburger.d.ts → Hamburger/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderLogo.d.ts → Logo/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderNavbar.d.ts → Navbar/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderNavbarLink.d.ts → NavbarLink/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderNavigation.d.ts → Navigation/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderProfile.d.ts → Profile/index.d.ts} +0 -0
- /package/dist/components/Header/{parts/HeaderWrap.d.ts → Wrap/index.d.ts} +0 -0
- /package/dist/components/{Calendar → form/Datepicker/Calendar}/index.es.js.map +0 -0
- /package/dist/components/{CalendarHeader → form/Datepicker/CalendarHeader}/index.es.js.map +0 -0
- /package/dist/components/{Segment → form/Datepicker/Segment}/index.es.js.map +0 -0
- /package/dist/components/{ErrorMessage → form/Field/ErrorMessage}/index.es.js +0 -0
- /package/dist/components/{InputHolder → form/Field/InputHolder}/index.es.js +0 -0
- /package/dist/components/{Message → form/Field/Message}/index.es.js +0 -0
- /package/dist/components/{default → icons/default}/index.es.js.map +0 -0
- /package/dist/components/{social → icons/social}/index.es.js.map +0 -0
- /package/dist/components/{Conditional → misc/Conditional}/index.es.js +0 -0
- /package/dist/components/{DynamicTagComponent → misc/DynamicTagComponent}/index.es.js +0 -0
- /package/dist/{components/Tooltip/Tooltip.test.d.ts → core/styles/globalStyles.d.ts} +0 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from 'astro/types'
|
|
3
|
+
import InputField from '../InputField/index.astro'
|
|
4
|
+
import DatepickerCalendar from './Calendar/index.astro'
|
|
5
|
+
import IconCalendar from '../../icons/default/IconCalendar.astro'
|
|
6
|
+
import { COLOR_NEUTRAL_40 } from '@consumidor-positivo/aurora/astro/tokens'
|
|
7
|
+
import '../../../dist/components/Datepicker/styles.css'
|
|
8
|
+
|
|
9
|
+
export type AUCalendarDateShape = { day: number; month: number; year: number }
|
|
10
|
+
export type DefaultValue = 'empty' | 'now' | AUCalendarDateShape
|
|
11
|
+
|
|
12
|
+
type FieldProps = Pick<
|
|
13
|
+
HTMLAttributes<'input'>,
|
|
14
|
+
'id' | 'name' | 'required' | 'autocomplete' | 'style' | 'class'
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Same props and markup as the React `DatepickerField`: an `InputField` with
|
|
19
|
+
* the DD/MM/YYYY mask and the calendar dialog. The React grid comes from
|
|
20
|
+
* `react-aria-components` 1.17; the inline controller reproduces its markup
|
|
21
|
+
* (roles, `aria-label` per day from `Intl`, roving `tabindex`, the `data-*`
|
|
22
|
+
* states the stylesheet uses), its keyboard (arrows, Home, End, PageUp,
|
|
23
|
+
* PageDown, Enter, space) and its live-region announcements, on top of the
|
|
24
|
+
* Aurora hooks it ports step by step: the mask and validation, the month and
|
|
25
|
+
* year pickers, the mobile sheet with Cancel and Confirm, the portal below
|
|
26
|
+
* 600px and the outside click above it.
|
|
27
|
+
*
|
|
28
|
+
* Differences from React: `value` is the initial date; `onChange` becomes
|
|
29
|
+
* `au:datechange` (`detail.value`, the date or `null` for an invalid one) and
|
|
30
|
+
* `onBlur` becomes `au:dateblur` (`detail.value`), both bubbling from the root.
|
|
31
|
+
* `format` has no counterpart: only the DD/MM/YYYY adapter ships. With
|
|
32
|
+
* `defaultValue="now"` the field starts empty in the HTML and the controller
|
|
33
|
+
* fills today, since "now" is the browser's day, not the build's. The
|
|
34
|
+
* calendar strings follow the browser language like react-aria; pt-BR and
|
|
35
|
+
* en-US are bundled, other languages fall back to en-US. Every other HTML
|
|
36
|
+
* attribute goes to the `<input>`, as the React spreads its props.
|
|
37
|
+
*/
|
|
38
|
+
export type Props = FieldProps & {
|
|
39
|
+
label?: string
|
|
40
|
+
showOptionalLabel?: boolean
|
|
41
|
+
requiredInput?: boolean
|
|
42
|
+
success?: boolean
|
|
43
|
+
error?: boolean
|
|
44
|
+
errorMessage?: string
|
|
45
|
+
helpMessage?: string
|
|
46
|
+
disabled?: boolean
|
|
47
|
+
/** Use the calendar dialog to pick a date. */
|
|
48
|
+
calendar?: boolean
|
|
49
|
+
placeholder?: string
|
|
50
|
+
/** Initial date. */
|
|
51
|
+
value?: AUCalendarDateShape | null
|
|
52
|
+
/** Default date, as the React uncontrolled mode. */
|
|
53
|
+
defaultValue?: DefaultValue
|
|
54
|
+
/** Makes the calendar dialog the top z-indexed item on the page (below 600px). */
|
|
55
|
+
withPortal?: boolean
|
|
56
|
+
/** Min allowed date, defaults to 1900-01-01. */
|
|
57
|
+
minValue?: AUCalendarDateShape
|
|
58
|
+
/** Max allowed date, defaults to 2100-12-31. */
|
|
59
|
+
maxValue?: AUCalendarDateShape
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const {
|
|
63
|
+
calendar = true,
|
|
64
|
+
placeholder,
|
|
65
|
+
disabled = false,
|
|
66
|
+
value,
|
|
67
|
+
defaultValue = 'empty',
|
|
68
|
+
withPortal = true,
|
|
69
|
+
minValue = { day: 1, month: 1, year: 1900 },
|
|
70
|
+
maxValue = { day: 31, month: 12, year: 2100 },
|
|
71
|
+
...rest
|
|
72
|
+
} = Astro.props
|
|
73
|
+
|
|
74
|
+
const pad = (n: number) => String(n).padStart(2, '0')
|
|
75
|
+
const toString = (date: AUCalendarDateShape) => `${pad(date.day)}/${pad(date.month)}/${date.year}`
|
|
76
|
+
const toIso = (date: AUCalendarDateShape) => `${date.year}-${pad(date.month)}-${pad(date.day)}`
|
|
77
|
+
|
|
78
|
+
// Same precedence as `useDatepicker`: `value` wins, then a dated `defaultValue`.
|
|
79
|
+
const initial: AUCalendarDateShape | null =
|
|
80
|
+
value && value.day ? value : typeof defaultValue === 'object' ? defaultValue : null
|
|
81
|
+
const inputDate = initial ? toString(initial) : ''
|
|
82
|
+
const focused = initial ?? null
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
<div
|
|
86
|
+
class="au-datepicker"
|
|
87
|
+
data-element="au-datepicker"
|
|
88
|
+
data-au-datepicker-min={toIso(minValue)}
|
|
89
|
+
data-au-datepicker-max={toIso(maxValue)}
|
|
90
|
+
data-au-datepicker-selected={initial ? toIso(initial) : undefined}
|
|
91
|
+
data-au-datepicker-now={defaultValue === 'now' && !initial ? '' : undefined}
|
|
92
|
+
data-au-datepicker-portal={withPortal ? '' : undefined}
|
|
93
|
+
data-au-datepicker-calendar={calendar ? '' : undefined}>
|
|
94
|
+
<InputField
|
|
95
|
+
class="au-datepicker__input"
|
|
96
|
+
{...rest}
|
|
97
|
+
maxlength={10}
|
|
98
|
+
value={inputDate}
|
|
99
|
+
type="tel"
|
|
100
|
+
disabled={disabled}
|
|
101
|
+
placeholder={placeholder || 'DD/MM/YYYY'}>
|
|
102
|
+
{
|
|
103
|
+
calendar && (
|
|
104
|
+
<button
|
|
105
|
+
slot="right"
|
|
106
|
+
type="button"
|
|
107
|
+
class="au-datepicker__calendar-holder"
|
|
108
|
+
aria-label="Abrir calendário">
|
|
109
|
+
<IconCalendar rawColor={disabled ? COLOR_NEUTRAL_40 : undefined} />
|
|
110
|
+
</button>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
</InputField>
|
|
114
|
+
{
|
|
115
|
+
calendar && (
|
|
116
|
+
<template data-au-datepicker-calendar>
|
|
117
|
+
<DatepickerCalendar
|
|
118
|
+
minYear={minValue.year}
|
|
119
|
+
maxYear={maxValue.year}
|
|
120
|
+
month={focused?.month ?? 1}
|
|
121
|
+
year={focused?.year ?? minValue.year}
|
|
122
|
+
/>
|
|
123
|
+
</template>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<script>
|
|
129
|
+
import { elementController } from '@consumidor-positivo/aurora/astro/runtime'
|
|
130
|
+
|
|
131
|
+
type DateShape = { day: number; month: number; year: number }
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// Dates. Plain gregorian arithmetic, the subset of @internationalized/date
|
|
135
|
+
// the React Datepicker uses.
|
|
136
|
+
const BREAKPOINT_MD = '600px'
|
|
137
|
+
const above = (breakpoint: string) => window.matchMedia(`screen and (min-width: ${breakpoint})`).matches
|
|
138
|
+
const pad = (n: number) => String(n).padStart(2, '0')
|
|
139
|
+
const toNative = (d: DateShape) => new Date(d.year, d.month - 1, d.day)
|
|
140
|
+
const fromNative = (n: Date): DateShape => ({ day: n.getDate(), month: n.getMonth() + 1, year: n.getFullYear() })
|
|
141
|
+
const daysInMonth = (year: number, month: number) => new Date(year, month, 0).getDate()
|
|
142
|
+
const compare = (a: DateShape, b: DateShape) => a.year - b.year || a.month - b.month || a.day - b.day
|
|
143
|
+
const isSameDay = (a: DateShape | null | undefined, b: DateShape | null | undefined) => !!a && !!b && compare(a, b) === 0
|
|
144
|
+
const addDays = (d: DateShape, days: number) => fromNative(new Date(d.year, d.month - 1, d.day + days))
|
|
145
|
+
// `CalendarDate.add({months})` keeps the day and constrains it to the month.
|
|
146
|
+
const addMonths = (d: DateShape, months: number) => {
|
|
147
|
+
const total = d.year * 12 + (d.month - 1) + months
|
|
148
|
+
const year = Math.floor(total / 12)
|
|
149
|
+
const month = (total % 12) + 1
|
|
150
|
+
return { year, month, day: Math.min(d.day, daysInMonth(year, month)) }
|
|
151
|
+
}
|
|
152
|
+
const addYears = (d: DateShape, years: number) => ({
|
|
153
|
+
year: d.year + years,
|
|
154
|
+
month: d.month,
|
|
155
|
+
day: Math.min(d.day, daysInMonth(d.year + years, d.month)),
|
|
156
|
+
})
|
|
157
|
+
const startOfMonth = (d: DateShape): DateShape => ({ ...d, day: 1 })
|
|
158
|
+
const endOfMonth = (d: DateShape): DateShape => ({ ...d, day: daysInMonth(d.year, d.month) })
|
|
159
|
+
const today = () => fromNative(new Date())
|
|
160
|
+
const parseIso = (iso: string): DateShape => {
|
|
161
|
+
const [year, month, day] = iso.split('-').map(Number)
|
|
162
|
+
return { year, month, day }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// First day of the week per region (CLDR, as @internationalized/date ships
|
|
166
|
+
// it; regions that start on Sunday are omitted).
|
|
167
|
+
const WEEK_START: Record<string, number> = { '001': 1, AD: 1, AE: 6, AF: 6, AI: 1, AL: 1, AM: 1, AN: 1, AR: 1, AT: 1, AU: 1, AX: 1, AZ: 1, BA: 1, BE: 1, BG: 1, BH: 6, BM: 1, BN: 1, BY: 1, CH: 1, CL: 1, CM: 1, CN: 1, CR: 1, CY: 1, CZ: 1, DE: 1, DJ: 6, DK: 1, DZ: 6, EC: 1, EE: 1, EG: 6, ES: 1, FI: 1, FJ: 1, FO: 1, FR: 1, GB: 1, GE: 1, GF: 1, GP: 1, GR: 1, HR: 1, HU: 1, IE: 1, IQ: 6, IR: 6, IS: 1, IT: 1, JO: 6, KG: 1, KW: 6, KZ: 1, LB: 1, LI: 1, LK: 1, LT: 1, LU: 1, LV: 1, LY: 6, MC: 1, MD: 1, ME: 1, MK: 1, MN: 1, MQ: 1, MV: 5, MY: 1, NL: 1, NO: 1, NZ: 1, OM: 6, PL: 1, QA: 6, RE: 1, RO: 1, RS: 1, RU: 1, SD: 6, SE: 1, SI: 1, SK: 1, SM: 1, SY: 6, TJ: 1, TM: 1, TR: 1, UA: 1, UY: 1, UZ: 1, VA: 1, VN: 1, XK: 1 }
|
|
168
|
+
function getWeekStart(locale: string) {
|
|
169
|
+
try {
|
|
170
|
+
const inst = new Intl.Locale(locale)
|
|
171
|
+
const info = (inst as unknown as { getWeekInfo?: () => { firstDay: number } }).getWeekInfo?.()
|
|
172
|
+
if (info) return info.firstDay % 7
|
|
173
|
+
const region = inst.maximize().region
|
|
174
|
+
return region ? WEEK_START[region] || 0 : 0
|
|
175
|
+
} catch {
|
|
176
|
+
return 0
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// The react-aria calendar strings the Datepicker reaches.
|
|
181
|
+
const STRINGS: Record<string, Record<string, string>> = {
|
|
182
|
+
'pt-BR': {
|
|
183
|
+
next: 'Próximo',
|
|
184
|
+
minimumDate: 'Primeira data disponível',
|
|
185
|
+
maximumDate: 'Última data disponível',
|
|
186
|
+
dateSelected: '{date} selecionado',
|
|
187
|
+
todayDate: 'Hoje, {date}',
|
|
188
|
+
todayDateSelected: 'Hoje, {date} selecionado',
|
|
189
|
+
selectedDateDescription: 'Data selecionada: {date}',
|
|
190
|
+
},
|
|
191
|
+
'en-US': {
|
|
192
|
+
next: 'Next',
|
|
193
|
+
minimumDate: 'First available date',
|
|
194
|
+
maximumDate: 'Last available date',
|
|
195
|
+
dateSelected: '{date} selected',
|
|
196
|
+
todayDate: 'Today, {date}',
|
|
197
|
+
todayDateSelected: 'Today, {date} selected',
|
|
198
|
+
selectedDateDescription: 'Selected Date: {date}',
|
|
199
|
+
},
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Same DOM as react-aria's LiveAnnouncer, created on first use.
|
|
203
|
+
let announcerNode: HTMLElement | null = null
|
|
204
|
+
function announce(message: string, assertiveness: 'assertive' | 'polite' = 'assertive', timeout = 7000) {
|
|
205
|
+
if (!announcerNode) {
|
|
206
|
+
announcerNode = document.createElement('div')
|
|
207
|
+
announcerNode.dataset.liveAnnouncer = 'true'
|
|
208
|
+
Object.assign(announcerNode.style, {
|
|
209
|
+
border: '0',
|
|
210
|
+
clip: 'rect(0 0 0 0)',
|
|
211
|
+
clipPath: 'inset(50%)',
|
|
212
|
+
height: '1px',
|
|
213
|
+
margin: '-1px',
|
|
214
|
+
overflow: 'hidden',
|
|
215
|
+
padding: '0',
|
|
216
|
+
position: 'absolute',
|
|
217
|
+
width: '1px',
|
|
218
|
+
whiteSpace: 'nowrap',
|
|
219
|
+
})
|
|
220
|
+
for (const live of ['assertive', 'polite']) {
|
|
221
|
+
const log = document.createElement('div')
|
|
222
|
+
log.setAttribute('role', 'log')
|
|
223
|
+
log.setAttribute('aria-live', live)
|
|
224
|
+
log.setAttribute('aria-relevant', 'additions')
|
|
225
|
+
announcerNode.appendChild(log)
|
|
226
|
+
}
|
|
227
|
+
document.body.prepend(announcerNode)
|
|
228
|
+
}
|
|
229
|
+
const log = announcerNode.children[assertiveness === 'assertive' ? 0 : 1]
|
|
230
|
+
const node = document.createElement('div')
|
|
231
|
+
node.textContent = message
|
|
232
|
+
log.appendChild(node)
|
|
233
|
+
if (message !== '') window.setTimeout(() => node.remove(), timeout)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// react-aria's interaction modality: keyboard focus shows `data-focus-visible`.
|
|
237
|
+
let modality: 'keyboard' | 'pointer' = 'pointer'
|
|
238
|
+
const toPointer = () => {
|
|
239
|
+
modality = 'pointer'
|
|
240
|
+
document.querySelectorAll('.au-datepicker__calendar-day[data-focus-visible]').forEach((cell) => cell.removeAttribute('data-focus-visible'))
|
|
241
|
+
}
|
|
242
|
+
document.addEventListener('keydown', () => { modality = 'keyboard' }, true)
|
|
243
|
+
document.addEventListener('pointerdown', toPointer, true)
|
|
244
|
+
document.addEventListener('pointermove', toPointer, true)
|
|
245
|
+
|
|
246
|
+
// ---------------------------------------------------------------------------
|
|
247
|
+
elementController('au-datepicker', ({ root, query, emit }) => {
|
|
248
|
+
const input = query<HTMLInputElement>('.au-field__input')
|
|
249
|
+
const template = query<HTMLTemplateElement>('template[data-au-datepicker-calendar]')
|
|
250
|
+
if (!input) return
|
|
251
|
+
const field = input
|
|
252
|
+
|
|
253
|
+
// Controller settings only; React's root carries no such attributes.
|
|
254
|
+
const minValue = parseIso(root.dataset.auDatepickerMin ?? '1900-01-01')
|
|
255
|
+
const maxValue = parseIso(root.dataset.auDatepickerMax ?? '2100-12-31')
|
|
256
|
+
const withPortal = root.hasAttribute('data-au-datepicker-portal')
|
|
257
|
+
const hasCalendar = root.hasAttribute('data-au-datepicker-calendar')
|
|
258
|
+
const startsNow = root.hasAttribute('data-au-datepicker-now')
|
|
259
|
+
let selectedDate: DateShape | null = root.dataset.auDatepickerSelected ? parseIso(root.dataset.auDatepickerSelected) : null
|
|
260
|
+
for (const name of ['min', 'max', 'selected', 'now', 'portal', 'calendar']) root.removeAttribute(`data-au-datepicker-${name}`)
|
|
261
|
+
|
|
262
|
+
const disabled = field.disabled
|
|
263
|
+
const locale = navigator.language || 'en-US'
|
|
264
|
+
const strings = STRINGS[locale] ?? STRINGS[locale.split('-')[0] === 'pt' ? 'pt-BR' : 'en-US']
|
|
265
|
+
const t = (key: string, date = '') => strings[key].replace('{date}', date)
|
|
266
|
+
const monthFormatter = new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' })
|
|
267
|
+
const dayLabelFormatter = new Intl.DateTimeFormat(locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })
|
|
268
|
+
const dayNumberFormatter = new Intl.DateTimeFormat(locale, { day: 'numeric' })
|
|
269
|
+
const weekdayFormatter = new Intl.DateTimeFormat(locale, { weekday: 'short' })
|
|
270
|
+
const weekStart = getWeekStart(locale)
|
|
271
|
+
|
|
272
|
+
// ---- the field (useDatepicker) -----------------------------------------
|
|
273
|
+
const format = {
|
|
274
|
+
placeholder: 'DD/MM/YYYY',
|
|
275
|
+
maskDate(dateStr: string) {
|
|
276
|
+
let fmt = dateStr.replace(/\D/g, '')
|
|
277
|
+
if (fmt.length > 2) fmt = `${fmt.slice(0, 2)}/${fmt.slice(2)}`
|
|
278
|
+
if (fmt.length > 5) fmt = `${fmt.slice(0, 5)}/${fmt.slice(5)}`
|
|
279
|
+
return fmt
|
|
280
|
+
},
|
|
281
|
+
validateFormat: (dateStr: string) => /^\d{2}\/\d{2}\/\d{4}$/.test(dateStr),
|
|
282
|
+
toCalendarDate(dateStr: string): DateShape {
|
|
283
|
+
const [day, month, year] = dateStr.split('/').map(Number)
|
|
284
|
+
return { day, month, year }
|
|
285
|
+
},
|
|
286
|
+
toString: (d: DateShape) => `${pad(d.day)}/${pad(d.month)}/${d.year}`,
|
|
287
|
+
validate(dateStr: string) {
|
|
288
|
+
const [day, month, year] = dateStr.split('/').map(Number)
|
|
289
|
+
const date = new Date(year, month - 1, day)
|
|
290
|
+
const olderThanMin = date < toNative(minValue)
|
|
291
|
+
const exceedsMax = date > toNative(maxValue)
|
|
292
|
+
return date.getDate() === day && date.getMonth() + 1 === month && date.getFullYear() === year && !olderThanMin && !exceedsMax
|
|
293
|
+
},
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// `isMobileInputWithCalendar`, computed once like the React `useMemo`.
|
|
297
|
+
if (!above(BREAKPOINT_MD) && hasCalendar) field.setAttribute('inputmode', 'none')
|
|
298
|
+
|
|
299
|
+
if (startsNow && !selectedDate) {
|
|
300
|
+
selectedDate = today()
|
|
301
|
+
field.value = format.toString(selectedDate)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let isCalendarVisible = false
|
|
305
|
+
|
|
306
|
+
function handleLoseFocus(event: MouseEvent) {
|
|
307
|
+
if (!root.contains(event.target as Node)) {
|
|
308
|
+
closeCalendar()
|
|
309
|
+
document.removeEventListener('mousedown', handleLoseFocus)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// `useOutsideClick` with the MD breakpoint: only above it.
|
|
313
|
+
function listenOutsideClick() {
|
|
314
|
+
if (!above(BREAKPOINT_MD)) return
|
|
315
|
+
document.addEventListener('mousedown', handleLoseFocus)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function handleInputChange() {
|
|
319
|
+
const maskedValue = format.maskDate(field.value)
|
|
320
|
+
field.value = maskedValue
|
|
321
|
+
if (!format.validateFormat(maskedValue)) return
|
|
322
|
+
const isDateValid = format.validate(maskedValue)
|
|
323
|
+
const newFieldValue = isDateValid ? format.toCalendarDate(maskedValue) : null
|
|
324
|
+
selectedDate = newFieldValue
|
|
325
|
+
// The React calendar only follows a dated `value` (`if (!value) return`),
|
|
326
|
+
// so an invalid date leaves the previous selection in the calendar.
|
|
327
|
+
if (newFieldValue) calendar?.setValue(newFieldValue)
|
|
328
|
+
emit('au:datechange', { value: newFieldValue })
|
|
329
|
+
if (!isDateValid) field.value = ''
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function openCalendar() {
|
|
333
|
+
if (!isCalendarVisible && disabled) return
|
|
334
|
+
listenOutsideClick()
|
|
335
|
+
if (isCalendarVisible) return
|
|
336
|
+
isCalendarVisible = true
|
|
337
|
+
calendar?.show()
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function closeCalendar() {
|
|
341
|
+
if (!isCalendarVisible) return
|
|
342
|
+
isCalendarVisible = false
|
|
343
|
+
calendar?.hide()
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function updateDateFromCalendar(pickerDate: DateShape) {
|
|
347
|
+
selectedDate = pickerDate
|
|
348
|
+
field.value = format.toString(pickerDate)
|
|
349
|
+
calendar?.setValue(pickerDate)
|
|
350
|
+
emit('au:datechange', { value: pickerDate })
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
field.addEventListener('input', handleInputChange)
|
|
354
|
+
field.addEventListener('focus', openCalendar)
|
|
355
|
+
field.addEventListener('blur', () => emit('au:dateblur', { value: selectedDate }))
|
|
356
|
+
query<HTMLButtonElement>('.au-datepicker__calendar-holder')?.addEventListener('click', () => field.focus())
|
|
357
|
+
|
|
358
|
+
// ---- the calendar (useCalendar + react-aria) ---------------------------
|
|
359
|
+
type Calendar = {
|
|
360
|
+
show(): void
|
|
361
|
+
hide(): void
|
|
362
|
+
setValue(date: DateShape | null): void
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const calendar: Calendar | null = template ? createCalendar(template) : null
|
|
366
|
+
|
|
367
|
+
function createCalendar(template: HTMLTemplateElement): Calendar {
|
|
368
|
+
const calendarEl = template.content.firstElementChild as HTMLElement
|
|
369
|
+
template.remove()
|
|
370
|
+
const base = calendarEl.querySelector<HTMLElement>('.au-datepicker__calendar-base')!
|
|
371
|
+
const title = base.querySelector<HTMLElement>(':scope > div > h2')!
|
|
372
|
+
const grid = base.querySelector<HTMLTableElement>('table')!
|
|
373
|
+
const headerCells = Array.from(grid.querySelectorAll<HTMLElement>('thead th'))
|
|
374
|
+
const body = grid.querySelector<HTMLElement>('tbody')!
|
|
375
|
+
const hiddenNext = base.querySelector<HTMLButtonElement>(':scope > div:last-child > button')!
|
|
376
|
+
const prevButton = base.querySelector<HTMLButtonElement>('.au-datepicker__header > button:first-child')!
|
|
377
|
+
const nextButton = base.querySelector<HTMLButtonElement>('.au-datepicker__header > button:last-child')!
|
|
378
|
+
const segments = Array.from(base.querySelectorAll<HTMLElement>('.au-datepicker__segment'))
|
|
379
|
+
const cancelButton = calendarEl.querySelector<HTMLButtonElement>('.au-datepicker__calendar-cancel')!
|
|
380
|
+
const confirmButton = calendarEl.querySelector<HTMLButtonElement>('.au-datepicker__calendar-actions-dock > button:last-child')!
|
|
381
|
+
const backdrop = calendarEl.querySelector<HTMLElement>('.au-datepicker__calendar-backdrop')!
|
|
382
|
+
|
|
383
|
+
// react-stately calendar state.
|
|
384
|
+
let value: DateShape | null = selectedDate
|
|
385
|
+
let focusedDate: DateShape = constrain(value ?? today())
|
|
386
|
+
let startDate: DateShape = startOfMonth(focusedDate)
|
|
387
|
+
let isFocused = true // `autoFocus`
|
|
388
|
+
let mounted = false
|
|
389
|
+
let enterTimer: number | undefined
|
|
390
|
+
let leaveTimer: number | undefined
|
|
391
|
+
let lastRange = ''
|
|
392
|
+
let lastSelectedDescription = ''
|
|
393
|
+
let showing = false
|
|
394
|
+
let lastFocusKey = ''
|
|
395
|
+
const portalDoor = document.createElement('div')
|
|
396
|
+
|
|
397
|
+
function constrain(date: DateShape) {
|
|
398
|
+
if (compare(date, minValue) < 0) return minValue
|
|
399
|
+
if (compare(date, maxValue) > 0) return maxValue
|
|
400
|
+
return date
|
|
401
|
+
}
|
|
402
|
+
const isInvalid = (date: DateShape) => compare(date, minValue) < 0 || compare(date, maxValue) > 0
|
|
403
|
+
const endDate = () => endOfMonth(startDate)
|
|
404
|
+
const isCellDisabled = (date: DateShape) => compare(date, startDate) < 0 || compare(date, endDate()) > 0 || isInvalid(date)
|
|
405
|
+
const isSelected = (date: DateShape) => value !== null && isSameDay(date, value) && !isCellDisabled(date)
|
|
406
|
+
const rangeDescription = () => monthFormatter.format(toNative(startDate))
|
|
407
|
+
const selectedDescription = () => (value ? t('selectedDateDescription', dayLabelFormatter.format(toNative(value))) : '')
|
|
408
|
+
|
|
409
|
+
function setFocusedDate(date: DateShape) {
|
|
410
|
+
focusedDate = constrain(date)
|
|
411
|
+
if (compare(focusedDate, startDate) < 0 || compare(focusedDate, endDate()) > 0) startDate = startOfMonth(focusedDate)
|
|
412
|
+
render()
|
|
413
|
+
}
|
|
414
|
+
// `focusNextPage` / `focusPreviousPage`, one month per page.
|
|
415
|
+
function focusPage(direction: 1 | -1) {
|
|
416
|
+
focusedDate = constrain(addMonths(focusedDate, direction))
|
|
417
|
+
startDate = startOfMonth(constrain(addMonths(startDate, direction)))
|
|
418
|
+
render()
|
|
419
|
+
}
|
|
420
|
+
function setValue(next: DateShape | null) {
|
|
421
|
+
value = next
|
|
422
|
+
if (next) focusedDate = constrain(next)
|
|
423
|
+
if (compare(focusedDate, startDate) < 0 || compare(focusedDate, endDate()) > 0) startDate = startOfMonth(focusedDate)
|
|
424
|
+
render()
|
|
425
|
+
}
|
|
426
|
+
function selectDate(date: DateShape, byPointer = false) {
|
|
427
|
+
// `calendarChange`: on desktop the pick is final and closes; on mobile
|
|
428
|
+
// it only moves the selection until "Confirmar".
|
|
429
|
+
value = constrain(date)
|
|
430
|
+
focusedDate = value
|
|
431
|
+
if (!byPointer) isFocused = true
|
|
432
|
+
render()
|
|
433
|
+
if (!above(BREAKPOINT_MD)) return
|
|
434
|
+
triggerChange(value)
|
|
435
|
+
}
|
|
436
|
+
function triggerChange(date: DateShape) {
|
|
437
|
+
updateDateFromCalendar(date)
|
|
438
|
+
closeCalendar()
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// ---- rendering ---------------------------------------------------------
|
|
442
|
+
function weekdays() {
|
|
443
|
+
const start = addDays(today(), -((toNative(today()).getDay() - weekStart + 7) % 7))
|
|
444
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
445
|
+
const day = weekdayFormatter.format(toNative(addDays(start, i)))
|
|
446
|
+
// `fmtWeekday` in `useCalendar`.
|
|
447
|
+
return `${day.charAt(0).toUpperCase()}${day.slice(1)}`.replace('.', '')
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
function datesInWeek(weekIndex: number): DateShape[] {
|
|
451
|
+
const from = addDays(startDate, weekIndex * 7)
|
|
452
|
+
const offset = (toNative(from).getDay() - weekStart + 7) % 7
|
|
453
|
+
const first = addDays(from, -offset)
|
|
454
|
+
return Array.from({ length: 7 }, (_, i) => addDays(first, i))
|
|
455
|
+
}
|
|
456
|
+
function weeksInMonth() {
|
|
457
|
+
const offset = (toNative(startDate).getDay() - weekStart + 7) % 7
|
|
458
|
+
return Math.ceil((offset + daysInMonth(startDate.year, startDate.month)) / 7)
|
|
459
|
+
}
|
|
460
|
+
function cellLabel(date: DateShape) {
|
|
461
|
+
let label = dayLabelFormatter.format(toNative(date))
|
|
462
|
+
const selected = isSelected(date)
|
|
463
|
+
if (isSameDay(date, today())) label = t(selected ? 'todayDateSelected' : 'todayDate', label)
|
|
464
|
+
else if (selected) label = t('dateSelected', label)
|
|
465
|
+
if (isSameDay(date, minValue)) label += `, ${t('minimumDate')}`
|
|
466
|
+
else if (isSameDay(date, maxValue)) label += `, ${t('maximumDate')}`
|
|
467
|
+
return label
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const cells = new Map<string, HTMLElement>()
|
|
471
|
+
const segmentResets: Array<() => void> = []
|
|
472
|
+
function renderGrid() {
|
|
473
|
+
const weeks = weeksInMonth()
|
|
474
|
+
const rows = Array.from(body.children) as HTMLTableRowElement[]
|
|
475
|
+
while (rows.length > weeks) rows.pop()!.remove()
|
|
476
|
+
cells.clear()
|
|
477
|
+
for (let w = 0; w < weeks; w++) {
|
|
478
|
+
let row = rows[w]
|
|
479
|
+
if (!row) {
|
|
480
|
+
row = document.createElement('tr')
|
|
481
|
+
body.appendChild(row)
|
|
482
|
+
}
|
|
483
|
+
const dates = datesInWeek(w)
|
|
484
|
+
const tds = Array.from(row.children) as HTMLTableCellElement[]
|
|
485
|
+
while (tds.length > 7) tds.pop()!.remove()
|
|
486
|
+
dates.forEach((date, i) => {
|
|
487
|
+
let td = tds[i]
|
|
488
|
+
if (!td) {
|
|
489
|
+
td = document.createElement('td')
|
|
490
|
+
td.setAttribute('role', 'gridcell')
|
|
491
|
+
td.appendChild(createCell())
|
|
492
|
+
row!.appendChild(td)
|
|
493
|
+
}
|
|
494
|
+
renderCell(td, date)
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function createCell() {
|
|
499
|
+
const cell = document.createElement('div')
|
|
500
|
+
cell.dataset.reactAriaPressable = 'true'
|
|
501
|
+
cell.setAttribute('role', 'button')
|
|
502
|
+
cell.className = 'au-datepicker__calendar-day'
|
|
503
|
+
cell.dataset.rac = ''
|
|
504
|
+
// useHover (mouse only) and usePress with `preventFocusOnPress`: the
|
|
505
|
+
// press never moves focus, the pick happens on release.
|
|
506
|
+
let pressing = false
|
|
507
|
+
cell.addEventListener('pointerenter', (e) => { if (e.pointerType !== 'touch' && !cell.hasAttribute('aria-disabled')) cell.dataset.hovered = 'true' })
|
|
508
|
+
cell.addEventListener('pointerleave', () => { delete cell.dataset.hovered; pressing = false })
|
|
509
|
+
cell.addEventListener('mousedown', (e) => e.preventDefault())
|
|
510
|
+
cell.addEventListener('pointerdown', () => { pressing = !cell.hasAttribute('aria-disabled') })
|
|
511
|
+
cell.addEventListener('pointerup', () => {
|
|
512
|
+
if (!pressing) return
|
|
513
|
+
pressing = false
|
|
514
|
+
const date = cellDate(cell)
|
|
515
|
+
if (date) selectDate(date, true)
|
|
516
|
+
})
|
|
517
|
+
cell.addEventListener('pointercancel', () => { pressing = false })
|
|
518
|
+
cell.addEventListener('focus', () => {
|
|
519
|
+
const date = cellDate(cell)
|
|
520
|
+
if (date && !cell.hasAttribute('aria-disabled')) {
|
|
521
|
+
focusedDate = date
|
|
522
|
+
isFocused = true
|
|
523
|
+
render()
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
cell.addEventListener('contextmenu', (e) => e.preventDefault())
|
|
527
|
+
return cell
|
|
528
|
+
}
|
|
529
|
+
const cellDate = (cell: HTMLElement) => (cell.dataset.auDate ? parseIso(cell.dataset.auDate) : null)
|
|
530
|
+
function renderCell(td: HTMLTableCellElement, date: DateShape) {
|
|
531
|
+
const cell = td.firstElementChild as HTMLElement
|
|
532
|
+
const disabledCell = isCellDisabled(date)
|
|
533
|
+
const selected = isSelected(date)
|
|
534
|
+
const outsideMonth = date.month !== startDate.month || date.year !== startDate.year
|
|
535
|
+
const focusedCell = isFocused && isSameDay(date, focusedDate) && !outsideMonth
|
|
536
|
+
const iso = `${date.year}-${pad(date.month)}-${pad(date.day)}`
|
|
537
|
+
cell.dataset.auDate = iso
|
|
538
|
+
cells.set(iso, cell)
|
|
539
|
+
|
|
540
|
+
setAttr(td, 'aria-disabled', disabledCell ? 'true' : null)
|
|
541
|
+
setAttr(td, 'aria-selected', selected ? 'true' : null)
|
|
542
|
+
|
|
543
|
+
setAttr(cell, 'tabindex', disabledCell ? null : isSameDay(date, focusedDate) ? '0' : '-1')
|
|
544
|
+
setAttr(cell, 'aria-disabled', disabledCell ? 'true' : null)
|
|
545
|
+
setAttr(cell, 'aria-label', cellLabel(date))
|
|
546
|
+
setAttr(cell, 'data-focused', focusedCell ? 'true' : null)
|
|
547
|
+
setAttr(cell, 'data-disabled', disabledCell ? 'true' : null)
|
|
548
|
+
setAttr(cell, 'data-focus-visible', focusedCell && modality === 'keyboard' && document.activeElement === cell ? 'true' : null)
|
|
549
|
+
setAttr(cell, 'data-outside-visible-range', outsideMonth ? 'true' : null)
|
|
550
|
+
setAttr(cell, 'data-outside-month', outsideMonth ? 'true' : null)
|
|
551
|
+
setAttr(cell, 'data-selected', selected ? 'true' : null)
|
|
552
|
+
setAttr(cell, 'data-today', isSameDay(date, today()) ? 'true' : null)
|
|
553
|
+
const text = dayNumberFormatter.formatToParts(toNative(date)).find((p) => p.type === 'day')?.value ?? String(date.day)
|
|
554
|
+
if (cell.textContent !== text) cell.textContent = text
|
|
555
|
+
}
|
|
556
|
+
function setAttr(el: Element, name: string, val: string | null) {
|
|
557
|
+
if (val === null) el.removeAttribute(name)
|
|
558
|
+
else if (el.getAttribute(name) !== val) el.setAttribute(name, val)
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function renderSegments() {
|
|
562
|
+
segments.forEach((segment, index) => {
|
|
563
|
+
const current = index === 0 ? focusedDate.month : focusedDate.year
|
|
564
|
+
const button = segment.querySelector<HTMLButtonElement>('.au-datepicker__segment-input')!
|
|
565
|
+
const items = Array.from(segment.querySelectorAll<HTMLLIElement>('.au-datepicker__segment-list-item'))
|
|
566
|
+
let label = ''
|
|
567
|
+
items.forEach((item) => {
|
|
568
|
+
const active = Number(item.dataset.auValue) === current
|
|
569
|
+
item.classList.toggle('au-datepicker__segment-list-item--active', active)
|
|
570
|
+
item.setAttribute('aria-selected', String(active))
|
|
571
|
+
if (active) label = item.textContent?.trim() ?? ''
|
|
572
|
+
})
|
|
573
|
+
if (button.firstChild?.nodeType === 3) {
|
|
574
|
+
if (button.firstChild.nodeValue !== label) button.firstChild.nodeValue = label
|
|
575
|
+
} else button.prepend(label)
|
|
576
|
+
})
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function render() {
|
|
580
|
+
const range = rangeDescription()
|
|
581
|
+
base.setAttribute('aria-label', range)
|
|
582
|
+
title.textContent = range
|
|
583
|
+
grid.setAttribute('aria-label', range)
|
|
584
|
+
hiddenNext.setAttribute('aria-label', t('next'))
|
|
585
|
+
hiddenNext.disabled = isInvalid(addDays(endDate(), 1))
|
|
586
|
+
weekdays().forEach((day, i) => { if (headerCells[i].textContent !== day) headerCells[i].textContent = day })
|
|
587
|
+
renderGrid()
|
|
588
|
+
renderSegments()
|
|
589
|
+
confirmButton.classList.toggle('au-btn--disabled', value === null)
|
|
590
|
+
confirmButton.disabled = value === null
|
|
591
|
+
|
|
592
|
+
// react-aria announces the visible range when it changes with the
|
|
593
|
+
// grid unfocused, and the selected date whenever it changes.
|
|
594
|
+
if (mounted && range !== lastRange && !isFocused) announce(range)
|
|
595
|
+
lastRange = range
|
|
596
|
+
const description = selectedDescription()
|
|
597
|
+
if (mounted && description !== lastSelectedDescription && description) announce(description, 'polite', 4000)
|
|
598
|
+
lastSelectedDescription = description
|
|
599
|
+
|
|
600
|
+
// The react-aria cell effect: when a cell becomes the focused one
|
|
601
|
+
// while the calendar is focused, it takes DOM focus wherever it was
|
|
602
|
+
// (the field included), except on mount, where the field's own focus
|
|
603
|
+
// wins.
|
|
604
|
+
const focusKey = isFocused ? `${focusedDate.year}-${pad(focusedDate.month)}-${pad(focusedDate.day)}` : ''
|
|
605
|
+
const focused = focusKey ? cells.get(focusKey) : undefined
|
|
606
|
+
if (focused && focusKey !== lastFocusKey && !showing && document.activeElement !== focused) {
|
|
607
|
+
focused.focus({ preventScroll: true })
|
|
608
|
+
setAttr(focused, 'data-focus-visible', modality === 'keyboard' ? 'true' : null)
|
|
609
|
+
}
|
|
610
|
+
lastFocusKey = focusKey
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// ---- keyboard (useCalendarGrid) ----------------------------------------
|
|
614
|
+
grid.addEventListener('keydown', (event) => {
|
|
615
|
+
const stop = () => { event.preventDefault(); event.stopPropagation() }
|
|
616
|
+
switch (event.key) {
|
|
617
|
+
case 'Enter':
|
|
618
|
+
case ' ':
|
|
619
|
+
event.preventDefault()
|
|
620
|
+
selectDate(focusedDate)
|
|
621
|
+
break
|
|
622
|
+
case 'PageUp':
|
|
623
|
+
stop()
|
|
624
|
+
if (event.shiftKey) setFocusedDate(addYears(focusedDate, -1))
|
|
625
|
+
else setFocusedDate(addMonths(focusedDate, -1))
|
|
626
|
+
break
|
|
627
|
+
case 'PageDown':
|
|
628
|
+
stop()
|
|
629
|
+
if (event.shiftKey) setFocusedDate(addYears(focusedDate, 1))
|
|
630
|
+
else setFocusedDate(addMonths(focusedDate, 1))
|
|
631
|
+
break
|
|
632
|
+
case 'End':
|
|
633
|
+
stop()
|
|
634
|
+
setFocusedDate(endOfMonth(focusedDate))
|
|
635
|
+
break
|
|
636
|
+
case 'Home':
|
|
637
|
+
stop()
|
|
638
|
+
setFocusedDate(startOfMonth(focusedDate))
|
|
639
|
+
break
|
|
640
|
+
case 'ArrowLeft':
|
|
641
|
+
stop()
|
|
642
|
+
setFocusedDate(addDays(focusedDate, -1))
|
|
643
|
+
break
|
|
644
|
+
case 'ArrowUp':
|
|
645
|
+
stop()
|
|
646
|
+
setFocusedDate(addDays(focusedDate, -7))
|
|
647
|
+
break
|
|
648
|
+
case 'ArrowRight':
|
|
649
|
+
stop()
|
|
650
|
+
setFocusedDate(addDays(focusedDate, 1))
|
|
651
|
+
break
|
|
652
|
+
case 'ArrowDown':
|
|
653
|
+
stop()
|
|
654
|
+
setFocusedDate(addDays(focusedDate, 7))
|
|
655
|
+
break
|
|
656
|
+
}
|
|
657
|
+
})
|
|
658
|
+
grid.addEventListener('focusin', () => { isFocused = true; render() })
|
|
659
|
+
grid.addEventListener('focusout', () => { isFocused = false; render() })
|
|
660
|
+
|
|
661
|
+
// ---- header (useCalendarHeader + useSegment) ---------------------------
|
|
662
|
+
prevButton.addEventListener('click', () => focusPage(-1))
|
|
663
|
+
nextButton.addEventListener('click', () => focusPage(1))
|
|
664
|
+
segments.forEach((segment, index) => {
|
|
665
|
+
const button = segment.querySelector<HTMLButtonElement>('.au-datepicker__segment-input')!
|
|
666
|
+
const list = segment.querySelector<HTMLElement>('.au-datepicker__segment-list')!
|
|
667
|
+
let open = false
|
|
668
|
+
const setOpen = (next: boolean) => {
|
|
669
|
+
open = next
|
|
670
|
+
segment.classList.toggle('au-datepicker__segment--open', open)
|
|
671
|
+
button.setAttribute('aria-expanded', String(open))
|
|
672
|
+
if (open) list.querySelector<HTMLElement>('.au-datepicker__segment-list-item--active')?.scrollIntoView({ block: 'center', inline: 'center' })
|
|
673
|
+
}
|
|
674
|
+
const outside = (event: MouseEvent) => {
|
|
675
|
+
if (segment.contains(event.target as Node)) return
|
|
676
|
+
setOpen(false)
|
|
677
|
+
document.removeEventListener('mousedown', outside)
|
|
678
|
+
}
|
|
679
|
+
segmentResets.push(() => { if (open) setOpen(false); document.removeEventListener('mousedown', outside) })
|
|
680
|
+
button.addEventListener('click', () => {
|
|
681
|
+
setOpen(true)
|
|
682
|
+
if (above(BREAKPOINT_MD)) document.addEventListener('mousedown', outside)
|
|
683
|
+
})
|
|
684
|
+
segment.querySelectorAll<HTMLButtonElement>('.au-datepicker__segment-list-header button').forEach((close) => close.addEventListener('click', () => setOpen(false)))
|
|
685
|
+
list.addEventListener('click', (event) => {
|
|
686
|
+
const item = (event.target as Element | null)?.closest<HTMLElement>('.au-datepicker__segment-list-item')
|
|
687
|
+
if (!item) return
|
|
688
|
+
const picked = Number(item.dataset.auValue)
|
|
689
|
+
const next = index === 0
|
|
690
|
+
? { year: focusedDate.year, month: picked, day: Math.min(focusedDate.day, daysInMonth(focusedDate.year, picked)) }
|
|
691
|
+
: { year: picked, month: focusedDate.month, day: Math.min(focusedDate.day, daysInMonth(picked, focusedDate.month)) }
|
|
692
|
+
setFocusedDate(next)
|
|
693
|
+
setOpen(false)
|
|
694
|
+
})
|
|
695
|
+
})
|
|
696
|
+
|
|
697
|
+
cancelButton.addEventListener('click', closeCalendar)
|
|
698
|
+
confirmButton.addEventListener('click', () => { if (value) triggerChange(value) })
|
|
699
|
+
backdrop.addEventListener('click', closeCalendar)
|
|
700
|
+
|
|
701
|
+
// ---- mount / unmount (useCalendar delays + PortalHolder) ---------------
|
|
702
|
+
function mount() {
|
|
703
|
+
if (mounted) return
|
|
704
|
+
mounted = true
|
|
705
|
+
if (!above(BREAKPOINT_MD) && withPortal) {
|
|
706
|
+
let portalRoot = document.getElementById('au-portal')
|
|
707
|
+
if (!portalRoot) {
|
|
708
|
+
portalRoot = document.createElement('div')
|
|
709
|
+
portalRoot.id = 'au-portal'
|
|
710
|
+
document.body.appendChild(portalRoot)
|
|
711
|
+
}
|
|
712
|
+
portalRoot.appendChild(portalDoor)
|
|
713
|
+
portalDoor.appendChild(calendarEl)
|
|
714
|
+
} else {
|
|
715
|
+
root.appendChild(calendarEl)
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function unmount() {
|
|
719
|
+
if (!mounted) return
|
|
720
|
+
mounted = false
|
|
721
|
+
calendarEl.remove()
|
|
722
|
+
portalDoor.remove()
|
|
723
|
+
cells.clear()
|
|
724
|
+
// React mounts a fresh calendar every time: no hover left over and
|
|
725
|
+
// every picker closed.
|
|
726
|
+
body.querySelectorAll<HTMLElement>('[data-hovered]').forEach((cell) => { delete cell.dataset.hovered })
|
|
727
|
+
segmentResets.forEach((reset) => reset())
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return {
|
|
731
|
+
show() {
|
|
732
|
+
window.clearTimeout(leaveTimer)
|
|
733
|
+
// `defaultFocusDate` → `setFocusedDate` on the header effect.
|
|
734
|
+
if (value) { focusedDate = constrain(value); startDate = startOfMonth(focusedDate) }
|
|
735
|
+
isFocused = true
|
|
736
|
+
lastRange = rangeDescription()
|
|
737
|
+
lastSelectedDescription = selectedDescription()
|
|
738
|
+
showing = true
|
|
739
|
+
render()
|
|
740
|
+
showing = false
|
|
741
|
+
lastFocusKey = `${focusedDate.year}-${pad(focusedDate.month)}-${pad(focusedDate.day)}`
|
|
742
|
+
mount()
|
|
743
|
+
enterTimer = window.setTimeout(() => calendarEl.classList.add('au-datepicker__calendar--visible'), 100)
|
|
744
|
+
},
|
|
745
|
+
hide() {
|
|
746
|
+
window.clearTimeout(enterTimer)
|
|
747
|
+
calendarEl.classList.remove('au-datepicker__calendar--visible')
|
|
748
|
+
leaveTimer = window.setTimeout(unmount, 200)
|
|
749
|
+
},
|
|
750
|
+
setValue(next) {
|
|
751
|
+
setValue(next)
|
|
752
|
+
},
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
})
|
|
756
|
+
</script>
|