plass-ui 0.0.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/PlAccordion.d.ts +98 -0
- package/dist/components/accordion/PlAccordion.js +1 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/PlAlert.d.ts +50 -0
- package/dist/components/alert/PlAlert.js +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/animate-appear/PlAnimateAppear.d.ts +55 -0
- package/dist/components/animate-appear/PlAnimateAppear.js +1 -0
- package/dist/components/animate-appear/index.d.ts +2 -0
- package/dist/components/animate-appear/index.js +1 -0
- package/dist/components/animate-blink/PlAnimateBlink.d.ts +30 -0
- package/dist/components/animate-blink/PlAnimateBlink.js +1 -0
- package/dist/components/animate-blink/index.d.ts +2 -0
- package/dist/components/animate-blink/index.js +1 -0
- package/dist/components/animate-fade/PlAnimateFade.d.ts +35 -0
- package/dist/components/animate-fade/PlAnimateFade.js +1 -0
- package/dist/components/animate-fade/index.d.ts +2 -0
- package/dist/components/animate-fade/index.js +1 -0
- package/dist/components/animate-grow/PlAnimateGrow.d.ts +45 -0
- package/dist/components/animate-grow/PlAnimateGrow.js +1 -0
- package/dist/components/animate-grow/index.d.ts +2 -0
- package/dist/components/animate-grow/index.js +1 -0
- package/dist/components/animate-headline/PlAnimateHeadline.d.ts +55 -0
- package/dist/components/animate-headline/PlAnimateHeadline.js +1 -0
- package/dist/components/animate-headline/index.d.ts +2 -0
- package/dist/components/animate-headline/index.js +1 -0
- package/dist/components/animate-lighting/PlAnimateLighting.d.ts +67 -0
- package/dist/components/animate-lighting/PlAnimateLighting.js +1 -0
- package/dist/components/animate-lighting/index.d.ts +2 -0
- package/dist/components/animate-lighting/index.js +1 -0
- package/dist/components/animate-marquee/PlAnimateMarquee.d.ts +65 -0
- package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -0
- package/dist/components/animate-marquee/index.d.ts +2 -0
- package/dist/components/animate-marquee/index.js +1 -0
- package/dist/components/animate-rotate/PlAnimateRotate.d.ts +52 -0
- package/dist/components/animate-rotate/PlAnimateRotate.js +1 -0
- package/dist/components/animate-rotate/index.d.ts +2 -0
- package/dist/components/animate-rotate/index.js +1 -0
- package/dist/components/animate-slide/PlAnimateSlide.d.ts +47 -0
- package/dist/components/animate-slide/PlAnimateSlide.js +1 -0
- package/dist/components/animate-slide/index.d.ts +2 -0
- package/dist/components/animate-slide/index.js +1 -0
- package/dist/components/animate-typing/PlAnimateTyping.d.ts +56 -0
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -0
- package/dist/components/animate-typing/index.d.ts +2 -0
- package/dist/components/animate-typing/index.js +1 -0
- package/dist/components/animate-zoom/PlAnimateZoom.d.ts +37 -0
- package/dist/components/animate-zoom/PlAnimateZoom.js +1 -0
- package/dist/components/animate-zoom/index.d.ts +2 -0
- package/dist/components/animate-zoom/index.js +1 -0
- package/dist/components/aspect-ratio/PlAspectRatio.d.ts +64 -0
- package/dist/components/aspect-ratio/PlAspectRatio.js +1 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +1 -0
- package/dist/components/avatar/PlAvatar.d.ts +102 -0
- package/dist/components/avatar/PlAvatar.js +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/badge/PlBadge.d.ts +86 -0
- package/dist/components/badge/PlBadge.js +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/blockquote/PlBlockquote.d.ts +64 -0
- package/dist/components/blockquote/PlBlockquote.js +1 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/blockquote/index.js +1 -0
- package/dist/components/bottom-navigation/PlBottomNavigation.d.ts +111 -0
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -0
- package/dist/components/bottom-navigation/index.d.ts +2 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/box/PlBox.d.ts +50 -0
- package/dist/components/box/PlBox.js +1 -0
- package/dist/components/box/index.d.ts +2 -0
- package/dist/components/box/index.js +1 -0
- package/dist/components/breadcrumb/PlBreadcrumb.d.ts +138 -0
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/{Button.d.ts → PlButton.d.ts} +3 -3
- package/dist/components/button/PlButton.js +1 -0
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/PlButtonGroup.d.ts +32 -0
- package/dist/components/button-group/PlButtonGroup.js +1 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card/PlCard.d.ts +81 -0
- package/dist/components/card/PlCard.js +1 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/carousel/PlCarousel.d.ts +78 -0
- package/dist/components/carousel/PlCarousel.js +1 -0
- package/dist/components/carousel/index.d.ts +2 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/chat-bubble/PlChatBubble.d.ts +127 -0
- package/dist/components/chat-bubble/PlChatBubble.js +1 -0
- package/dist/components/chat-bubble/index.d.ts +2 -0
- package/dist/components/chat-bubble/index.js +1 -0
- package/dist/components/checkbox/PlCheckbox.d.ts +39 -0
- package/dist/components/checkbox/PlCheckbox.js +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/PlChip.d.ts +55 -0
- package/dist/components/chip/PlChip.js +1 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/collapsible/PlCollapsible.d.ts +84 -0
- package/dist/components/collapsible/PlCollapsible.js +1 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox/PlCombobox.d.ts +140 -0
- package/dist/components/combobox/PlCombobox.js +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/container/PlContainer.d.ts +66 -0
- package/dist/components/container/PlContainer.js +1 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/container/index.js +1 -0
- package/dist/components/date-picker/PlDatePicker.d.ts +73 -0
- package/dist/components/date-picker/PlDatePicker.js +1 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/PlDateRangePicker.d.ts +91 -0
- package/dist/components/date-range-picker/PlDateRangePicker.js +1 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/date-time-picker/PlDateTimePicker.d.ts +74 -0
- package/dist/components/date-time-picker/PlDateTimePicker.js +1 -0
- package/dist/components/date-time-picker/index.d.ts +2 -0
- package/dist/components/date-time-picker/index.js +1 -0
- package/dist/components/divider/PlDivider.d.ts +73 -0
- package/dist/components/divider/PlDivider.js +1 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/PlDrawer.d.ts +144 -0
- package/dist/components/drawer/PlDrawer.js +1 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/file-picker/PlFilePicker.d.ts +105 -0
- package/dist/components/file-picker/PlFilePicker.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -0
- package/dist/components/file-picker/index.js +1 -0
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.d.ts +118 -0
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -0
- package/dist/components/floating-bottom-navigation/index.d.ts +2 -0
- package/dist/components/floating-bottom-navigation/index.js +1 -0
- package/dist/components/grid/PlGrid.d.ts +67 -0
- package/dist/components/grid/PlGrid.js +1 -0
- package/dist/components/grid/PlGridItem.d.ts +50 -0
- package/dist/components/grid/PlGridItem.js +1 -0
- package/dist/components/grid/index.d.ts +4 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/highlight/PlHighlight.d.ts +90 -0
- package/dist/components/highlight/PlHighlight.js +1 -0
- package/dist/components/highlight/index.d.ts +2 -0
- package/dist/components/highlight/index.js +1 -0
- package/dist/components/hot-keys/PlHotKeys.d.ts +93 -0
- package/dist/components/hot-keys/PlHotKeys.js +1 -0
- package/dist/components/hot-keys/index.d.ts +2 -0
- package/dist/components/hot-keys/index.js +1 -0
- package/dist/components/icon/PlIcon.d.ts +62 -0
- package/dist/components/icon/PlIcon.js +1 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/icon-button/PlIconButton.d.ts +39 -0
- package/dist/components/icon-button/PlIconButton.js +1 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/list/PlList.d.ts +82 -0
- package/dist/components/list/PlList.js +1 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/menu/PlMenu.d.ts +210 -0
- package/dist/components/menu/PlMenu.js +1 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/modal/PlModal.d.ts +112 -0
- package/dist/components/modal/PlModal.js +1 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/number-field/PlNumberField.d.ts +133 -0
- package/dist/components/number-field/PlNumberField.js +1 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/otp-field/PlOtpField.d.ts +82 -0
- package/dist/components/otp-field/PlOtpField.js +1 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +1 -0
- package/dist/components/overlay/PlOverlay.d.ts +96 -0
- package/dist/components/overlay/PlOverlay.js +1 -0
- package/dist/components/overlay/index.d.ts +2 -0
- package/dist/components/overlay/index.js +1 -0
- package/dist/components/pagination/PlPagination.d.ts +88 -0
- package/dist/components/pagination/PlPagination.js +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/panes/PlPanes.d.ts +79 -0
- package/dist/components/panes/PlPanes.js +1 -0
- package/dist/components/panes/index.d.ts +2 -0
- package/dist/components/panes/index.js +1 -0
- package/dist/components/pill/PlPill.d.ts +81 -0
- package/dist/components/pill/PlPill.js +1 -0
- package/dist/components/pill/index.d.ts +2 -0
- package/dist/components/pill/index.js +1 -0
- package/dist/components/popover/PlPopover.d.ts +107 -0
- package/dist/components/popover/PlPopover.js +1 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/progress-box/PlProgressBox.d.ts +32 -0
- package/dist/components/progress-box/PlProgressBox.js +1 -0
- package/dist/components/progress-box/index.d.ts +2 -0
- package/dist/components/progress-box/index.js +1 -0
- package/dist/components/progress-circular/PlProgressCircular.d.ts +22 -0
- package/dist/components/progress-circular/PlProgressCircular.js +1 -0
- package/dist/components/progress-circular/index.d.ts +2 -0
- package/dist/components/progress-circular/index.js +1 -0
- package/dist/components/progress-linear/PlProgressLinear.d.ts +31 -0
- package/dist/components/progress-linear/PlProgressLinear.js +1 -0
- package/dist/components/progress-linear/index.d.ts +2 -0
- package/dist/components/progress-linear/index.js +1 -0
- package/dist/components/radio-group/PlRadioGroup.d.ts +54 -0
- package/dist/components/radio-group/PlRadioGroup.js +1 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/rating/PlRating.d.ts +90 -0
- package/dist/components/rating/PlRating.js +1 -0
- package/dist/components/rating/index.d.ts +2 -0
- package/dist/components/rating/index.js +1 -0
- package/dist/components/scroll-zone/PlScrollZone.d.ts +132 -0
- package/dist/components/scroll-zone/PlScrollZone.js +1 -0
- package/dist/components/scroll-zone/index.d.ts +2 -0
- package/dist/components/scroll-zone/index.js +1 -0
- package/dist/components/segmented-button/PlSegmentedButton.d.ts +79 -0
- package/dist/components/segmented-button/PlSegmentedButton.js +1 -0
- package/dist/components/segmented-button/index.d.ts +2 -0
- package/dist/components/segmented-button/index.js +1 -0
- package/dist/components/select/PlSelect.d.ts +77 -0
- package/dist/components/select/PlSelect.js +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/skeleton/PlSkeleton.d.ts +73 -0
- package/dist/components/skeleton/PlSkeleton.js +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/slider/PlSlider.d.ts +44 -0
- package/dist/components/slider/PlSlider.js +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/spoiler/PlSpoiler.d.ts +84 -0
- package/dist/components/spoiler/PlSpoiler.js +1 -0
- package/dist/components/spoiler/index.d.ts +2 -0
- package/dist/components/spoiler/index.js +1 -0
- package/dist/components/switch/PlSwitch.d.ts +42 -0
- package/dist/components/switch/PlSwitch.js +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/PlTable.d.ts +112 -0
- package/dist/components/table/PlTable.js +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/PlTabs.d.ts +94 -0
- package/dist/components/tabs/PlTabs.js +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/text-field/{TextField.d.ts → PlTextField.d.ts} +5 -5
- package/dist/components/text-field/PlTextField.js +1 -0
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/text-field/index.js +1 -1
- package/dist/components/text-link/PlTextLink.d.ts +80 -0
- package/dist/components/text-link/PlTextLink.js +1 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/time-picker/PlTimePicker.d.ts +88 -0
- package/dist/components/time-picker/PlTimePicker.js +1 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/time-picker/index.js +1 -0
- package/dist/components/timeline/PlTimeline.d.ts +98 -0
- package/dist/components/timeline/PlTimeline.js +1 -0
- package/dist/components/timeline/index.d.ts +2 -0
- package/dist/components/timeline/index.js +1 -0
- package/dist/components/toast/PlToast.d.ts +122 -0
- package/dist/components/toast/PlToast.js +1 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toolbar/PlToolbar.d.ts +68 -0
- package/dist/components/toolbar/PlToolbar.js +1 -0
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/index.js +1 -0
- package/dist/components/tooltip/PlTooltip.d.ts +92 -0
- package/dist/components/tooltip/PlTooltip.js +1 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/typography/PlTypography.d.ts +66 -0
- package/dist/components/typography/PlTypography.js +1 -0
- package/dist/components/typography/index.d.ts +2 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/css/accordion.css +2 -0
- package/dist/css/alert.css +2 -0
- package/dist/css/animate-appear.css +2 -0
- package/dist/css/animate-blink.css +2 -0
- package/dist/css/animate-fade.css +2 -0
- package/dist/css/animate-grow.css +2 -0
- package/dist/css/animate-headline.css +2 -0
- package/dist/css/animate-lighting.css +2 -0
- package/dist/css/animate-marquee.css +2 -0
- package/dist/css/animate-rotate.css +2 -0
- package/dist/css/animate-slide.css +2 -0
- package/dist/css/animate-typing.css +2 -0
- package/dist/css/animate-zoom.css +2 -0
- package/dist/css/aspect-ratio.css +2 -0
- package/dist/css/avatar.css +2 -0
- package/dist/css/badge.css +2 -0
- package/dist/css/base.css +4 -0
- package/dist/css/blockquote.css +2 -0
- package/dist/css/bottom-navigation.css +2 -0
- package/dist/css/box.css +2 -0
- package/dist/css/breadcrumb.css +2 -0
- package/dist/css/button-group.css +2 -0
- package/dist/css/button.css +2 -0
- package/dist/css/card.css +2 -0
- package/dist/css/carousel.css +2 -0
- package/dist/css/chat-bubble.css +2 -0
- package/dist/css/checkbox.css +2 -0
- package/dist/css/chip.css +2 -0
- package/dist/css/collapsible.css +2 -0
- package/dist/css/combobox.css +2 -0
- package/dist/css/container.css +2 -0
- package/dist/css/date-picker.css +2 -0
- package/dist/css/date-range-picker.css +2 -0
- package/dist/css/date-time-picker.css +2 -0
- package/dist/css/divider.css +2 -0
- package/dist/css/drawer.css +2 -0
- package/dist/css/file-picker.css +2 -0
- package/dist/css/floating-bottom-navigation.css +2 -0
- package/dist/css/grid.css +2 -0
- package/dist/css/highlight.css +2 -0
- package/dist/css/hot-keys.css +2 -0
- package/dist/css/icon-button.css +2 -0
- package/dist/css/icon.css +2 -0
- package/dist/css/list.css +2 -0
- package/dist/css/menu.css +2 -0
- package/dist/css/modal.css +2 -0
- package/dist/css/number-field.css +2 -0
- package/dist/css/otp-field.css +2 -0
- package/dist/css/overlay.css +2 -0
- package/dist/css/pagination.css +2 -0
- package/dist/css/panes.css +2 -0
- package/dist/css/pill.css +2 -0
- package/dist/css/popover.css +2 -0
- package/dist/css/progress-box.css +2 -0
- package/dist/css/progress-circular.css +2 -0
- package/dist/css/progress-linear.css +2 -0
- package/dist/css/radio-group.css +2 -0
- package/dist/css/rating.css +2 -0
- package/dist/css/scroll-zone.css +2 -0
- package/dist/css/segmented-button.css +2 -0
- package/dist/css/select.css +2 -0
- package/dist/css/skeleton.css +2 -0
- package/dist/css/slider.css +2 -0
- package/dist/css/spoiler.css +2 -0
- package/dist/css/switch.css +2 -0
- package/dist/css/table.css +2 -0
- package/dist/css/tabs.css +2 -0
- package/dist/css/text-field.css +2 -0
- package/dist/css/text-link.css +2 -0
- package/dist/css/time-picker.css +2 -0
- package/dist/css/timeline.css +2 -0
- package/dist/css/toast.css +2 -0
- package/dist/css/toolbar.css +2 -0
- package/dist/css/tooltip.css +2 -0
- package/dist/css/typography.css +2 -0
- package/dist/index.d.ts +75 -3
- package/dist/index.js +1 -1
- package/dist/internal/animate.d.ts +161 -0
- package/dist/internal/animate.js +1 -0
- package/dist/internal/button-group.d.ts +27 -0
- package/dist/internal/button-group.js +2 -0
- package/dist/internal/calendar.d.ts +148 -0
- package/dist/internal/calendar.js +1 -0
- package/dist/internal/date.d.ts +173 -0
- package/dist/internal/date.js +1 -0
- package/dist/internal/format.d.ts +24 -0
- package/dist/internal/format.js +1 -0
- package/dist/internal/grid.d.ts +67 -0
- package/dist/internal/grid.js +1 -0
- package/dist/internal/icons.d.ts +86 -1
- package/dist/internal/icons.js +1 -1
- package/dist/internal/menu.d.ts +20 -0
- package/dist/internal/menu.js +1 -0
- package/dist/internal/picker.d.ts +118 -0
- package/dist/internal/picker.js +1 -0
- package/dist/internal/progress.d.ts +145 -0
- package/dist/internal/progress.js +1 -0
- package/dist/internal/sizer.d.ts +32 -0
- package/dist/internal/sizer.js +1 -0
- package/dist/internal/styles.d.ts +198 -8
- package/dist/internal/styles.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +899 -125
- package/dist/tokens.css +1275 -0
- package/dist/types.d.ts +150 -8
- package/dist/types.js +0 -8
- package/package.json +32 -27
- package/README.md +0 -111
- package/dist/components/button/Button.js +0 -1
- package/dist/components/text-field/TextField.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types";export*from"./components/button";export*from"./components/text-field";
|
|
1
|
+
export*from"./types.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/badge/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/collapsible/index.js";export*from"./components/combobox/index.js";export*from"./components/container/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/file-picker/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/grid/index.js";export*from"./components/highlight/index.js";export*from"./components/hot-keys/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/list/index.js";export*from"./components/menu/index.js";export*from"./components/modal/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pill/index.js";export*from"./components/popover/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/spoiler/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/toast/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/typography/index.js";
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machinery every `PlAnimate*` component runs on.
|
|
3
|
+
*
|
|
4
|
+
* It lives in `internal/` for the reason `button-group.ts` and `progress.ts`
|
|
5
|
+
* do: eleven components need it and none of them should have to import another.
|
|
6
|
+
*
|
|
7
|
+
* ## The shape of it
|
|
8
|
+
*
|
|
9
|
+
* Every effect is one `@keyframes` in `styles.css` running from a state written
|
|
10
|
+
* entirely in custom properties to the element's natural one. Nothing here
|
|
11
|
+
* generates CSS — it fills `--p-anim-*` slots and the stylesheet decides what
|
|
12
|
+
* they mean, which is the same split `controlSlots()` makes for colour and for
|
|
13
|
+
* the same reason: Tailwind only ever sees class names that appear literally in
|
|
14
|
+
* the source, so a class per duration would not survive the first prop.
|
|
15
|
+
*
|
|
16
|
+
* Because the from-state is the *keyframe* rather than a second class, running
|
|
17
|
+
* an effect backwards is `animation-direction: reverse` and nothing else. That
|
|
18
|
+
* is what makes `mode="out"` free on the five that offer it.
|
|
19
|
+
*
|
|
20
|
+
* ## Where the design language draws the line
|
|
21
|
+
*
|
|
22
|
+
* A Plass **control** never moves — a key that scales resamples its label, and
|
|
23
|
+
* that rule holds without exception. What moves here is content a caller has
|
|
24
|
+
* asked to have moved, and it moves on the independent `translate`, `scale` and
|
|
25
|
+
* `rotate` properties rather than on the `transform` shorthand, so a caller's
|
|
26
|
+
* own transform on the same element survives.
|
|
27
|
+
*
|
|
28
|
+
* ## What is deliberately not here
|
|
29
|
+
*
|
|
30
|
+
* An effect that has to know what its children *are* — a marquee that lays them
|
|
31
|
+
* down twice, a headline that swaps between them, a typewriter that counts
|
|
32
|
+
* graphemes — cannot be a class name and a few numbers. Those are components,
|
|
33
|
+
* and their logic stays in their own files.
|
|
34
|
+
*/
|
|
35
|
+
import * as React from 'react';
|
|
36
|
+
import type { PlassAnimateRepeat, PlassAnimateTrigger, PlassAnimation, PlassSide } from '../types.js';
|
|
37
|
+
/**
|
|
38
|
+
* Which keyframe an effect runs.
|
|
39
|
+
*
|
|
40
|
+
* `grow` and `zoom` share one: they are the same arithmetic at two strengths,
|
|
41
|
+
* and a second identical `@keyframes` would only be a second place to fix a
|
|
42
|
+
* bug. What separates them is their defaults and their origin, and an origin is
|
|
43
|
+
* a property rather than a keyframe.
|
|
44
|
+
*/
|
|
45
|
+
export declare const animationClasses: Record<PlassAnimation, string>;
|
|
46
|
+
/** The class that reads the slots. Always paired with one of the above. */
|
|
47
|
+
export declare const animBaseClass = "plass-anim";
|
|
48
|
+
/** A number is pixels; a string is already a CSS length. */
|
|
49
|
+
export declare function lengthValue(value: number | string): string;
|
|
50
|
+
/** `'infinite'` reaches CSS as the word; a count reaches it as the number. */
|
|
51
|
+
export declare function repeatValue(repeat: PlassAnimateRepeat): string;
|
|
52
|
+
export declare function isInfinite(repeat: PlassAnimateRepeat | undefined): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* `normal`, `reverse`, `alternate`, `alternate-reverse` — the four CSS already
|
|
55
|
+
* has, assembled from the two props that mean something to a caller.
|
|
56
|
+
*
|
|
57
|
+
* `mode="out"` is a reversed run rather than a keyframe of its own, which is
|
|
58
|
+
* also why a reversed animation ends held on its own first frame: `fill-mode`
|
|
59
|
+
* is `both`, so a faded-out element stays faded out instead of snapping back.
|
|
60
|
+
*/
|
|
61
|
+
export declare function directionValue(mode: 'in' | 'out', alternate: boolean | undefined): string;
|
|
62
|
+
export interface AnimationSlotOptions {
|
|
63
|
+
duration: number;
|
|
64
|
+
delay: number;
|
|
65
|
+
easing?: string;
|
|
66
|
+
repeat: PlassAnimateRepeat;
|
|
67
|
+
alternate?: boolean;
|
|
68
|
+
mode?: 'in' | 'out';
|
|
69
|
+
/** Where the animated properties start. Only the ones an effect reads. */
|
|
70
|
+
opacity?: number;
|
|
71
|
+
scale?: number;
|
|
72
|
+
x?: string;
|
|
73
|
+
y?: string;
|
|
74
|
+
angle?: string;
|
|
75
|
+
angleTo?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The `--p-anim-*` slots, as an inline style object.
|
|
79
|
+
*
|
|
80
|
+
* Inline rather than utilities for the reason the colour slots are: these are
|
|
81
|
+
* per-instance numbers, and Tailwind cannot generate a class for a duration it
|
|
82
|
+
* has never seen written down.
|
|
83
|
+
*/
|
|
84
|
+
export declare function animationSlots(options: AnimationSlotOptions): React.CSSProperties;
|
|
85
|
+
/**
|
|
86
|
+
* Which way a slide starts, given the edge it comes from.
|
|
87
|
+
*
|
|
88
|
+
* `PlassSide` is physical everywhere in the library and it stays physical here:
|
|
89
|
+
* something arriving from the top of the window arrives from the top in every
|
|
90
|
+
* writing direction.
|
|
91
|
+
*/
|
|
92
|
+
export declare function slideOffsets(from: PlassSide, distance: number | string): {
|
|
93
|
+
x: string;
|
|
94
|
+
y: string;
|
|
95
|
+
};
|
|
96
|
+
export declare function usePrefersReducedMotion(): boolean;
|
|
97
|
+
export interface AnimationRunOptions {
|
|
98
|
+
trigger: PlassAnimateTrigger;
|
|
99
|
+
play?: boolean;
|
|
100
|
+
once: boolean;
|
|
101
|
+
threshold: number;
|
|
102
|
+
paused?: boolean;
|
|
103
|
+
/** An infinite effect stops when the pointer leaves; a finite one finishes. */
|
|
104
|
+
infinite: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface AnimationRun {
|
|
107
|
+
/** Goes on the animated element. */
|
|
108
|
+
ref: React.RefCallback<HTMLElement>;
|
|
109
|
+
/** `running` or `paused`, for `--p-anim-state`. */
|
|
110
|
+
state: 'running' | 'paused';
|
|
111
|
+
/** Whether the animation has been let go at all. */
|
|
112
|
+
started: boolean;
|
|
113
|
+
/** Spread onto the element when `trigger` is `hover`; empty otherwise. */
|
|
114
|
+
handlers: React.HTMLAttributes<HTMLElement>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Starts, restarts and holds an animation.
|
|
118
|
+
*
|
|
119
|
+
* Two things here are less obvious than they look.
|
|
120
|
+
*
|
|
121
|
+
* **Waiting is `animation-play-state: paused`, not a second class.** An element
|
|
122
|
+
* that has not been triggered yet has to already look like its own first frame,
|
|
123
|
+
* or a `visible` fade would be fully drawn until it scrolled into view and then
|
|
124
|
+
* blink out to start. With `fill-mode: both` a paused animation shows exactly
|
|
125
|
+
* that frame, so waiting and running are one animation in two states rather
|
|
126
|
+
* than two states to keep in step.
|
|
127
|
+
*
|
|
128
|
+
* **Restarting reaches for the DOM.** There is no way to rewind a CSS animation
|
|
129
|
+
* from React: re-rendering with the same class changes nothing, and a `key`
|
|
130
|
+
* would restart the animation by unmounting the children, taking their state
|
|
131
|
+
* with it. Clearing `animation-name`, reading a layout property to force the
|
|
132
|
+
* style to settle, and putting it back is the one move that rewinds the element
|
|
133
|
+
* and leaves everything inside it alone.
|
|
134
|
+
*/
|
|
135
|
+
export declare function useAnimationRun({ trigger, play, once, threshold, paused, infinite }: AnimationRunOptions): AnimationRun;
|
|
136
|
+
export interface AnimateElementParams extends AnimationSlotOptions, AnimationRunOptions {
|
|
137
|
+
/** Which keyframe. `null` for the components that write their own. */
|
|
138
|
+
effect: PlassAnimation | null;
|
|
139
|
+
}
|
|
140
|
+
export interface AnimateElement {
|
|
141
|
+
ref: React.RefCallback<HTMLElement>;
|
|
142
|
+
className: string;
|
|
143
|
+
style: React.CSSProperties;
|
|
144
|
+
/** The hover handlers and the two data attributes, ready to be spread. */
|
|
145
|
+
props: React.HTMLAttributes<HTMLElement> & Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Everything a one-keyframe `PlAnimate*` root needs, in one call.
|
|
149
|
+
*
|
|
150
|
+
* The six effect components differ only in their defaults and in which slots
|
|
151
|
+
* they fill, so this is where the identical two-thirds of each of them lives.
|
|
152
|
+
* The ones that have to understand their children — Appear, Headline, Marquee,
|
|
153
|
+
* Typing — call `useAnimationRun` directly and put the classes where their own
|
|
154
|
+
* structure needs them, which is why `effect` is allowed to be `null`.
|
|
155
|
+
*
|
|
156
|
+
* `data-plass-animation` and `data-state` are here rather than in each
|
|
157
|
+
* component because they are the same two facts every time, and because a test
|
|
158
|
+
* that has to assert on a class name is a test that breaks when a class name
|
|
159
|
+
* changes.
|
|
160
|
+
*/
|
|
161
|
+
export declare function useAnimateElement(params: AnimateElementParams): AnimateElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";export const animationClasses={fade:"plass-anim-fade",grow:"plass-anim-scale",slide:"plass-anim-slide",zoom:"plass-anim-scale",rotate:"plass-anim-rotate",blink:"plass-anim-blink"};export const animBaseClass="plass-anim";export function lengthValue(e){return"number"==typeof e?`${e}px`:e}export function repeatValue(e){return"infinite"===e?"infinite":String(e)}export function isInfinite(e){return"infinite"===e}export function directionValue(e,n){return"out"===e?n?"alternate-reverse":"reverse":n?"alternate":"normal"}export function animationSlots(e){const n={"--p-anim-duration":`${e.duration}ms`,"--p-anim-delay":`${e.delay}ms`,"--p-anim-repeat":repeatValue(e.repeat),"--p-anim-direction":directionValue(e.mode??"in",e.alternate)};return e.easing&&(n["--p-anim-ease"]=e.easing),void 0!==e.opacity&&(n["--p-anim-opacity"]=String(e.opacity)),void 0!==e.scale&&(n["--p-anim-scale"]=String(e.scale)),void 0!==e.x&&(n["--p-anim-x"]=e.x),void 0!==e.y&&(n["--p-anim-y"]=e.y),void 0!==e.angle&&(n["--p-anim-angle"]=e.angle),void 0!==e.angleTo&&(n["--p-anim-angle-to"]=e.angleTo),n}export function slideOffsets(e,n){const t=lengthValue(n),a="number"==typeof n?-n+"px":`calc(-1 * ${t})`;switch(e){case"top":return{x:"0px",y:a};case"bottom":return{x:"0px",y:t};case"left":return{x:a,y:"0px"};default:return{x:t,y:"0px"}}}const n="(prefers-reduced-motion: reduce)";function subscribeToMotion(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(n);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function readMotion(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(n).matches}function motionOnServer(){return!1}export function usePrefersReducedMotion(){return e.useSyncExternalStore(subscribeToMotion,readMotion,motionOnServer)}export function useAnimationRun({trigger:n,play:t,once:a,threshold:i,paused:o,infinite:r}){const s=e.useRef(null),[u,c]=e.useState("mount"===n),[l,p]=e.useState(0),d=e.useCallback(()=>{c(!0),p(e=>e+1)},[]);e.useLayoutEffect(()=>{const e=s.current;if(!e||0===l)return;const n=[e,...e.querySelectorAll(".plass-anim, .plass-marquee-track")];for(const e of n)e.style.animationName="none";e.offsetWidth;for(const e of n)e.style.animationName=""},[l]),e.useEffect(()=>{if("visible"!==n)return;const e=s.current;if(!e||"undefined"==typeof IntersectionObserver)return void c(!0);const t=new IntersectionObserver(([e])=>{e.isIntersecting?(d(),a&&t.disconnect()):a||c(!1)},{threshold:i});return t.observe(e),()=>t.disconnect()},[n,a,i,d]),e.useEffect(()=>{"manual"===n&&(t?d():c(!1))},[n,t,d]);const f="hover"===n?{onPointerEnter:d,onFocus:d,onPointerLeave:()=>{r&&c(!1)},onBlur:()=>{r&&c(!1)}}:{};return{ref:e.useCallback(e=>{s.current=e},[]),state:u&&!o?"running":"paused",started:u,handlers:f}}export function useAnimateElement(e){const{effect:n,trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s,...u}=e,c=useAnimationRun({trigger:t,play:a,once:i,threshold:o,paused:r,infinite:s});return{ref:c.ref,className:n?`plass-anim ${animationClasses[n]}`:"",style:{...animationSlots(u),"--p-anim-state":c.state},props:{...c.handlers,"data-plass-animation":n??void 0,"data-state":c.state}}}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a `PlButton` inherits from the `PlButtonGroup` around it.
|
|
3
|
+
*
|
|
4
|
+
* A context rather than `React.Children.map` with `cloneElement`, and a file of
|
|
5
|
+
* its own rather than something the group exports, for one reason each.
|
|
6
|
+
*
|
|
7
|
+
* Cloning breaks the moment a caller wraps one of the buttons in a `PlTooltip`,
|
|
8
|
+
* a `<Fragment>` or a `.map()` — which is most of the time — and a context
|
|
9
|
+
* reaches the button wherever it ended up. And it lives here rather than beside
|
|
10
|
+
* the group so that `PlButton` can read it without the two components importing
|
|
11
|
+
* each other, which is the arrangement `internal/menu.ts` already has.
|
|
12
|
+
*
|
|
13
|
+
* Every field is optional, and every one of them means *not specified* rather
|
|
14
|
+
* than a value: a button falls back to its own default, so a `PlButtonGroup`
|
|
15
|
+
* with no props of its own changes nothing except the corners.
|
|
16
|
+
*/
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
import type { PlassColor, PlassDensity, PlassElevation, PlassSize, PlassVariant } from '../types.js';
|
|
19
|
+
export interface PlassButtonGroupContextValue {
|
|
20
|
+
variant?: PlassVariant;
|
|
21
|
+
size?: PlassSize;
|
|
22
|
+
color?: PlassColor;
|
|
23
|
+
density?: PlassDensity;
|
|
24
|
+
elevation?: PlassElevation;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare const ButtonGroupContext: React.Context<PlassButtonGroupContextValue | null>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type TimeUnit } from './date.js';
|
|
3
|
+
import type { PlassColor, PlassDensity, PlassSize, PlassWeekday } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The calendar grid and the clock columns, written once for the four pickers.
|
|
6
|
+
*
|
|
7
|
+
* They live in `internal/` for the reason `button-group.ts` does: a
|
|
8
|
+
* `PlDateTimePicker` is a date picker and a time picker in one popup and a
|
|
9
|
+
* `PlDateRangePicker` is two calendars, so three components need this and none
|
|
10
|
+
* of them should have to import another. The one thing it reaches *up* for is
|
|
11
|
+
* `PlButton` — the header's steppers are buttons, they are not a new kind of
|
|
12
|
+
* control, and `PlPagination` already makes that argument.
|
|
13
|
+
*
|
|
14
|
+
* The day cells are deliberately **not** `PlButton`s. A cell has states a
|
|
15
|
+
* button has no vocabulary for — inside a range, at the end of a range, today,
|
|
16
|
+
* belonging to the month next door — and four of them have to be told apart at
|
|
17
|
+
* a glance in a grid of forty-two.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Every string a picker says that is not a date.
|
|
21
|
+
*
|
|
22
|
+
* One object rather than eighteen props. These are a set: a caller who has to
|
|
23
|
+
* translate "Previous month" has to translate "Next month" in the same breath,
|
|
24
|
+
* and a component with eighteen `*Label` props is a component whose signature is
|
|
25
|
+
* mostly apology. The dates themselves are never in here — those come from
|
|
26
|
+
* `Intl`, which already knows what July is called in more languages than this
|
|
27
|
+
* file ever will.
|
|
28
|
+
*/
|
|
29
|
+
export interface PlassPickerLabels {
|
|
30
|
+
/** The calendar's steppers, in day view. */
|
|
31
|
+
previousMonth: string;
|
|
32
|
+
nextMonth: string;
|
|
33
|
+
/** The same steppers in month view, where they move by a year. */
|
|
34
|
+
previousYear: string;
|
|
35
|
+
nextYear: string;
|
|
36
|
+
/** And in year view, where they move by a page of twelve. */
|
|
37
|
+
previousYears: string;
|
|
38
|
+
nextYears: string;
|
|
39
|
+
/** The two header buttons that open the month grid and the year grid. */
|
|
40
|
+
chooseMonth: string;
|
|
41
|
+
chooseYear: string;
|
|
42
|
+
/** The footer's actions. */
|
|
43
|
+
today: string;
|
|
44
|
+
now: string;
|
|
45
|
+
clear: string;
|
|
46
|
+
done: string;
|
|
47
|
+
/** The clock's columns. */
|
|
48
|
+
hour: string;
|
|
49
|
+
minute: string;
|
|
50
|
+
second: string;
|
|
51
|
+
meridiem: string;
|
|
52
|
+
/** Which end of a range the calendar is currently asking for. */
|
|
53
|
+
start: string;
|
|
54
|
+
end: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const defaultPickerLabels: PlassPickerLabels;
|
|
57
|
+
/** Merges a caller's overrides over the defaults, once per render. */
|
|
58
|
+
export declare function usePickerLabels(overrides?: Partial<PlassPickerLabels>): PlassPickerLabels;
|
|
59
|
+
export interface CalendarProps {
|
|
60
|
+
size: PlassSize;
|
|
61
|
+
color: PlassColor;
|
|
62
|
+
locale?: string;
|
|
63
|
+
weekStartsOn: PlassWeekday;
|
|
64
|
+
/** The month on screen. Controlled, so two panels can be kept a month apart. */
|
|
65
|
+
month: Date;
|
|
66
|
+
onMonthChange: (month: Date) => void;
|
|
67
|
+
/** The days drawn filled — one for a single picker, up to two for a range. */
|
|
68
|
+
selected: readonly (Date | null | undefined)[];
|
|
69
|
+
/** The two ends the band is drawn between. Both `null` outside range mode. */
|
|
70
|
+
rangeStart?: Date | null;
|
|
71
|
+
rangeEnd?: Date | null;
|
|
72
|
+
onSelect: (date: Date) => void;
|
|
73
|
+
/** The day under the pointer, for a range that is only half chosen. */
|
|
74
|
+
onPreviewChange?: (date: Date | null) => void;
|
|
75
|
+
minDate?: Date | null;
|
|
76
|
+
maxDate?: Date | null;
|
|
77
|
+
shouldDisableDate?: (date: Date) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Draws the leading and trailing days that belong to the neighbouring months.
|
|
80
|
+
*
|
|
81
|
+
* On by default, because clicking the 1st of next month from this month's
|
|
82
|
+
* panel is a real shortcut. A two-month range picker turns it *off*, and not
|
|
83
|
+
* as a matter of taste: with both panels showing six full weeks, the 1st of
|
|
84
|
+
* August appears twice — once as a trailing day of July and once as itself —
|
|
85
|
+
* and two cells with the same name in the same popup is ambiguous to a
|
|
86
|
+
* pointer and outright broken to a screen reader.
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
showOutsideDays?: boolean;
|
|
90
|
+
/** Takes the focus on mount — the popup has just opened. */
|
|
91
|
+
autoFocus?: boolean;
|
|
92
|
+
showPreviousButton?: boolean;
|
|
93
|
+
showNextButton?: boolean;
|
|
94
|
+
labels: PlassPickerLabels;
|
|
95
|
+
className?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One month, with a way to reach every other one.
|
|
99
|
+
*
|
|
100
|
+
* Three views on the same footprint: the days of a month, the twelve months of
|
|
101
|
+
* a year, twelve years at a time. They are deliberately the same width *and*
|
|
102
|
+
* the same height — the day view is seven rows counting its header, and the
|
|
103
|
+
* other two stretch four rows and three rows across that same height — so
|
|
104
|
+
* switching view never resizes the popup under the pointer that opened it.
|
|
105
|
+
*
|
|
106
|
+
* Arrow keys move by one cell, `PageUp`/`PageDown` by a month (a year with
|
|
107
|
+
* Shift), `Home`/`End` to the ends of the week, and running off an edge steps
|
|
108
|
+
* the calendar rather than stopping. One roving tab stop, so `Tab` leaves the
|
|
109
|
+
* grid instead of walking forty-two cells — the pattern the ARIA date-picker
|
|
110
|
+
* practice describes, and the reason none of the cells is a `disabled` button.
|
|
111
|
+
*/
|
|
112
|
+
export declare function Calendar({ size, color, locale, weekStartsOn, month, onMonthChange, selected, rangeStart, rangeEnd, onSelect, onPreviewChange, minDate, maxDate, shouldDisableDate, showOutsideDays, autoFocus, showPreviousButton, showNextButton, labels, className }: CalendarProps): React.JSX.Element;
|
|
113
|
+
export type { TimeUnit };
|
|
114
|
+
export interface TimeGridProps {
|
|
115
|
+
size: PlassSize;
|
|
116
|
+
density: PlassDensity;
|
|
117
|
+
locale?: string;
|
|
118
|
+
/** The time on screen, or `null` while nothing has been chosen. */
|
|
119
|
+
value: Date | null;
|
|
120
|
+
/** The day the columns write into while `value` is still `null`. */
|
|
121
|
+
referenceDate: Date;
|
|
122
|
+
onChange: (value: Date) => void;
|
|
123
|
+
/** A 12-hour dial with an AM/PM column. Defaults to whatever the locale does. */
|
|
124
|
+
hour12: boolean;
|
|
125
|
+
showSeconds: boolean;
|
|
126
|
+
hourStep: number;
|
|
127
|
+
minuteStep: number;
|
|
128
|
+
secondStep: number;
|
|
129
|
+
shouldDisableTime?: (value: Date, unit: TimeUnit) => boolean;
|
|
130
|
+
/** Takes the focus on mount — the popup has just opened. */
|
|
131
|
+
autoFocus?: boolean;
|
|
132
|
+
labels: PlassPickerLabels;
|
|
133
|
+
className?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Hours, minutes and — when asked for — seconds, as columns you scroll rather
|
|
137
|
+
* than as a dial you drag.
|
|
138
|
+
*
|
|
139
|
+
* Columns because they are the shape that answers what a time picker is actually
|
|
140
|
+
* asked: "half past nine" is two glances, and "any time at all, on the hour" is
|
|
141
|
+
* a column you never touch. A clock face is prettier and needs a `transform` to
|
|
142
|
+
* read, which this library does not have.
|
|
143
|
+
*
|
|
144
|
+
* The chosen row in each column is scrolled into view once, on open. That is the
|
|
145
|
+
* only imperative work here and it is not optional: a column of sixty minutes
|
|
146
|
+
* that opens at `00` while the value is `45` has hidden its own answer.
|
|
147
|
+
*/
|
|
148
|
+
export declare function TimeGrid({ size, density, locale, value, referenceDate, onChange, hour12, showSeconds, hourStep, minuteStep, secondStep, shouldDisableTime, autoFocus, labels, className }: TimeGridProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{PlButton as r}from"../components/button/PlButton.js";import{ChevronIcon as s}from"./icons.js";import{dateFormatter as n}from"./format.js";import{addDays as l,addMonths as a,addYears as i,calendarWeeks as c,compareDay as u,daysInMonth as d,isDayOutside as m,isMonthBeforeYear as h,isSameDay as p,isSameMonth as g,isValidDate as f,makeDate as v,meridiemLabels as x,monthLabels as b,startOfDay as y,startOfMonth as w,today as D,weekdayLabels as N,withTime as C,YEAR_PAGE_SIZE as M,yearPageStart as S}from"./date.js";import{controlHeightClasses as P,controlTextClasses as k,cx as Y,gapClasses as z,metaTextClasses as A,srOnlyClasses as F,transitionClasses as j}from"./styles.js";export const defaultPickerLabels={previousMonth:"Previous month",nextMonth:"Next month",previousYear:"Previous year",nextYear:"Next year",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",today:"Today",now:"Now",clear:"Clear",done:"Done",hour:"Hour",minute:"Minute",second:"Second",meridiem:"AM/PM",start:"Start",end:"End"};export function usePickerLabels(e){return t.useMemo(()=>e?{...defaultPickerLabels,...e}:defaultPickerLabels,[e])}const E={xs:"1.5rem",sm:"2rem",md:"2.5rem",lg:"3rem",xl:"3.5rem"},H={xs:"rounded-(--plass-radius-xs)",sm:"rounded-(--plass-radius-xs)",md:"rounded-(--plass-radius-sm)",lg:"rounded-(--plass-radius-md)",xl:"rounded-(--plass-radius-lg)"},R={xs:"rounded-s-(--plass-radius-xs)",sm:"rounded-s-(--plass-radius-xs)",md:"rounded-s-(--plass-radius-sm)",lg:"rounded-s-(--plass-radius-md)",xl:"rounded-s-(--plass-radius-lg)"},T={xs:"rounded-e-(--plass-radius-xs)",sm:"rounded-e-(--plass-radius-xs)",md:"rounded-e-(--plass-radius-sm)",lg:"rounded-e-(--plass-radius-md)",xl:"rounded-e-(--plass-radius-lg)"},B=/* @__PURE__ */["relative flex items-center justify-center tabular-nums select-none","[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]",j,"focus-visible:z-10 focus-visible:[outline:2px_solid_var(--p-ring)]","focus-visible:[outline-offset:-2px]"].join(" ");function Cell({children:t,label:r,selected:s,inRange:n=!1,rangeEdge:l=null,current:a=!1,muted:i=!1,disabled:c=!1,focused:u=!1,size:d,className:m,onClick:h,onPointerEnter:p,onKeyDown:g}){return o("button",{type:"button",role:"gridcell","aria-label":r,"aria-selected":s,"aria-current":a?"date":void 0,"aria-disabled":c||void 0,tabIndex:u?0:-1,"data-focus-target":u?"true":void 0,className:Y(B,"start"===l?R[d]:"end"===l?T[d]:"middle"===l?"rounded-none":H[d],c?"cursor-not-allowed text-(--plass-muted-fg) opacity-50":s?"cursor-pointer font-semibold text-(--p-on-solid) [background-image:var(--p-fill)] hover:brightness-105 active:brightness-95":n?"cursor-pointer bg-(--p-soft) text-(--plass-fg) hover:bg-(--p-soft-hover) active:bg-(--p-soft-press)":a?"cursor-pointer font-semibold text-(--p-accent) hover:bg-(--p-soft) active:bg-(--p-soft-hover)":i?"cursor-pointer text-(--plass-muted-fg) hover:bg-(--p-soft) active:bg-(--p-soft-hover)":"cursor-pointer text-(--plass-fg) hover:bg-(--p-soft) active:bg-(--p-soft-hover)",m),onClick:()=>{c||h()},onPointerEnter:p,onKeyDown:g,children:[t,a?e("span",{"aria-hidden":"true",className:"absolute bottom-[0.18em] size-[0.22em] rounded-full bg-current"}):null]})}function Header({size:n,color:l,view:a,month:i,locale:c,labels:u,showPreviousButton:d,showNextButton:m,onStep:p,onViewChange:g}){const f=b(c,"long")[i.getMonth()],v=String(i.getFullYear()),x=h(c),y="day"===a?[u.previousMonth,u.nextMonth]:"month"===a?[u.previousYear,u.nextYear]:[u.previousYears,u.nextYears],stepper=(o,t)=>t?e(r,{variant:"ghost",size:n,color:l,density:"compact","aria-label":y[-1===o?0:1],onClick:()=>p(o),startIcon:e("span",{className:Y("flex items-center",-1===o?"rotate-90 rtl:-rotate-90":"-rotate-90 rtl:rotate-90"),children:e(s,{})})}):e("span",{"aria-hidden":"true",className:Y(P[n],"w-(--p-cell)")}),disclosure=o=>e("span",{className:Y("flex items-center text-(--plass-muted-fg)","[transition:rotate_var(--plass-duration)_var(--plass-ease)]",o&&"rotate-180"),children:e(s,{})}),w=e(r,{variant:"ghost",size:n,color:l,density:"compact","aria-label":u.chooseMonth,"aria-expanded":"month"===a,onClick:()=>g("month"===a?"day":"month"),endIcon:disclosure("month"===a),children:f},"month"),D=e(r,{variant:"ghost",size:n,color:l,density:"compact",className:"tabular-nums","aria-label":u.chooseYear,"aria-expanded":"year"===a,onClick:()=>g("year"===a?"day":"year"),endIcon:disclosure("year"===a),children:v},"year"),N=S(i.getFullYear());return o("div",{className:"flex items-center justify-between gap-1",children:[stepper(-1,d),e("div",{className:Y("flex min-w-0 flex-1 items-center justify-center",z[n]),children:"year"===a?e("span",{className:Y("flex items-center font-semibold tabular-nums text-(--plass-fg)",P[n],k[n]),children:`${N}–${N+M-1}`}):"month"===a?D:o(t.Fragment,x?{children:[w,D]}:{children:[D,w]})}),stepper(1,m)]})}export function Calendar({size:r,color:s,locale:n,weekStartsOn:l,month:c,onMonthChange:u,selected:d,rangeStart:h=null,rangeEnd:p=null,onSelect:x,onPreviewChange:b,minDate:N,maxDate:C,shouldDisableDate:S,showOutsideDays:P=!0,autoFocus:k=!1,showPreviousButton:A=!0,showNextButton:F=!0,labels:j,className:H}){const[R,T]=t.useState("day"),B=t.useMemo(()=>d.filter(f),[d]),[L,G]=t.useState(()=>{const e=B.find(e=>g(e,c));return e?y(e):g(D(),c)?D():w(c)}),K=t.useRef(k),I=t.useRef(null);t.useEffect(()=>{G(e=>g(e,c)?e:w(c))},[c]),t.useLayoutEffect(()=>{K.current&&(K.current=!1,I.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const O=t.useCallback(e=>m(e,N,C)||(S?.(e)??!1),[N,C,S]),changeView=e=>{K.current=!0,T(e)},moveCursor=e=>{K.current=!0,u(e)};return o("div",{ref:I,className:Y("flex flex-col",z[r],H),style:{"--p-cell":E[r]},onPointerLeave:()=>b?.(null),children:[e(Header,{size:r,color:s,view:R,month:c,locale:n,labels:j,showPreviousButton:A,showNextButton:F,onStep:e=>{u("day"===R?a(c,e):i(c,"month"===R?e:e*M))},onViewChange:changeView}),e("div",{className:"h-[calc(var(--p-cell)*7)] w-[calc(var(--p-cell)*7)]",children:"day"===R?e(DayGrid,{size:r,locale:n,weekStartsOn:l,month:c,chosen:B,rangeStart:h,rangeEnd:p,focusedDate:L,showOutsideDays:P,isDisabled:O,onSelect:e=>{G(e),x(e)},onPreviewChange:b,onMoveFocus:e=>{K.current=!0,G(e),g(e,c)||u(w(e))}}):"month"===R?e(MonthGrid,{size:r,locale:n,month:c,chosen:B,minDate:N,maxDate:C,onMoveCursor:moveCursor,onPick:e=>{u(v(c.getFullYear(),e,1)),changeView("day")}}):e(YearGrid,{size:r,month:c,chosen:B,minDate:N,maxDate:C,onMoveCursor:moveCursor,onPick:e=>{u(v(e,c.getMonth(),1)),changeView("month")}})})]})}function DayGrid({size:t,locale:r,weekStartsOn:s,month:i,chosen:d,rangeStart:m,rangeEnd:h,focusedDate:v,showOutsideDays:x,isDisabled:b,onSelect:y,onPreviewChange:w,onMoveFocus:C}){const M=c(i,s),S=N(r,s,"short"),P=N(r,s,"long"),z=n(r,{dateStyle:"full"}),F=function orderedRange(e,o){return f(e)&&f(o)?u(e,o)<=0?[e,o]:[o,e]:null}(m,h),j=D();return o("div",{role:"grid",className:"flex h-full flex-col",children:[e("div",{role:"row",className:"grid grid-cols-7",children:S.map((o,r)=>e("span",{role:"columnheader","aria-label":P[r],className:Y("flex h-(--p-cell) items-center justify-center font-semibold text-(--plass-muted-fg) select-none",A[t]),children:o},r))}),M.map((o,r)=>e("div",{role:"row",className:"grid grid-cols-7",children:o.map(o=>{const r=!g(o,i);if(r&&!x)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--p-cell)"},o.getTime());const n=d.some(e=>p(e,o)),c=null!==F&&u(o,F[0])>=0&&u(o,F[1])<=0,m=null!==F&&c&&p(o,F[0]),h=null!==F&&c&&p(o,F[1]);return e(Cell,{size:t,label:z.format(o),selected:n,inRange:c&&!n,rangeEdge:c?m&&h?"both":m?"start":h?"end":"middle":null,current:p(o,j)&&!n,muted:r,disabled:b(o),focused:p(o,v),className:Y("size-(--p-cell)",k[t]),onClick:()=>y(o),onPointerEnter:()=>w?.(o),onKeyDown:e=>((e,o)=>{const t=(o.getDay()-s+7)%7,r={ArrowLeft:()=>l(o,-1),ArrowRight:()=>l(o,1),ArrowUp:()=>l(o,-7),ArrowDown:()=>l(o,7),Home:()=>l(o,-t),End:()=>l(o,6-t),PageUp:()=>a(o,e.shiftKey?-12:-1),PageDown:()=>a(o,e.shiftKey?12:1)}[e.key];r&&(e.preventDefault(),C(r()))})(e,o),children:o.getDate()},o.getTime())})},r))]})}function MonthGrid({size:o,locale:t,month:r,chosen:s,minDate:n,maxDate:l,onMoveCursor:i,onPick:c}){const m=b(t,"short"),h=b(t,"long"),p=r.getFullYear(),g=new Date,onKeyDown=e=>{const o={ArrowLeft:-1,ArrowRight:1,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==o&&(e.preventDefault(),i(a(w(r),o)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(t=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(a=>{const i=3*t+a,x=v(p,i,1),b=v(p,i,d(p,i));return e(Cell,{size:o,label:`${h[i]} ${p}`,selected:s.some(e=>e.getFullYear()===p&&e.getMonth()===i),current:g.getFullYear()===p&&g.getMonth()===i,disabled:f(n)&&u(b,n)<0||f(l)&&u(x,l)>0,focused:i===r.getMonth(),className:Y("h-(--p-cell) w-full",k[o]),onClick:()=>c(i),onKeyDown,children:m[i]},i)})},t))})}function YearGrid({size:o,month:t,chosen:r,minDate:s,maxDate:n,onMoveCursor:l,onPick:a}){const c=S(t.getFullYear()),u=(new Date).getFullYear(),onKeyDown=e=>{const o={ArrowLeft:-1,ArrowRight:1,ArrowUp:-4,ArrowDown:4,PageUp:-M,PageDown:M}[e.key];void 0!==o&&(e.preventDefault(),l(i(w(t),o)))};return e("div",{role:"grid",className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(l=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(i=>{const d=c+4*l+i;return e(Cell,{size:o,label:String(d),selected:r.some(e=>e.getFullYear()===d),current:d===u,disabled:f(s)&&d<s.getFullYear()||f(n)&&d>n.getFullYear(),focused:d===t.getFullYear(),className:Y("h-(--p-cell) w-full",k[o]),onClick:()=>a(d),onKeyDown,children:d},d)})},l))})}function revealInColumn(e){const o=e.parentElement;if(!o)return;const t=e.getBoundingClientRect(),r=o.getBoundingClientRect(),s=t.top-r.top-o.clientTop+o.scrollTop,n=s+t.height;s<o.scrollTop?o.scrollTop=s:n>o.scrollTop+o.clientHeight&&(o.scrollTop=n-o.clientHeight)}export function TimeGrid({size:r,density:s,locale:l,value:a,referenceDate:i,onChange:c,hour12:u,showSeconds:d,hourStep:m,minuteStep:h,secondStep:p,shouldDisableTime:g,autoFocus:f=!1,labels:v,className:b}){const y=a??i,w=t.useRef(null),[D,N]=t.useMemo(()=>x(l),[l]);t.useEffect(()=>{const e=w.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(revealInColumn),f){const o=e?.querySelector('[role="listbox"]');(o?.querySelector('[data-chosen="true"]')??o?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[f]);const M=t.useMemo(()=>{const e=Math.ceil((u?12:24)/m),o=Array.from({length:e},(e,o)=>o*m);return u?o.map(e=>0===e?12:e):o},[u,m]),S=t.useMemo(()=>Array.from({length:Math.ceil(60/h)},(e,o)=>o*h),[h]),z=t.useMemo(()=>Array.from({length:Math.ceil(60/p)},(e,o)=>o*p),[p]),pad=e=>String(e).padStart(2,"0"),A=u?y.getHours()%12||12:y.getHours(),column=(o,t,s,n,l)=>e("div",{role:"listbox","aria-label":t,className:Y("flex flex-col gap-0.5 overflow-y-auto overscroll-contain","h-[calc(var(--p-cell)*7)] w-[calc(var(--p-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"),children:s.map(t=>{const s=((e,o)=>C(y,"hour"===e?{hours:u?o%12+(y.getHours()>=12?12:0):o}:"minute"===e?{minutes:o}:"second"===e?{seconds:o}:{hours:y.getHours()%12+12*o}))(o,t),i=null!==a&&n(t),d=g?.(s,o)??!1;return e("button",{type:"button",role:"option","aria-selected":i,"aria-disabled":d||void 0,"data-chosen":i?"true":void 0,className:Y(B,H[r],P[r],k[r],"w-full shrink-0",d?"cursor-not-allowed text-(--plass-muted-fg) opacity-50":i?"cursor-pointer font-semibold text-(--p-on-solid) [background-image:var(--p-fill)] hover:brightness-105 active:brightness-95":"cursor-pointer text-(--plass-fg) hover:bg-(--p-soft) active:bg-(--p-soft-hover)"),onClick:()=>{d||c(s)},children:l(t)},t)})},o);return o("div",{ref:w,className:Y("flex","compact"===s?"gap-0.5":"gap-1",b),style:{"--p-cell":E[r]},children:[column("hour",v.hour,M,e=>e===A,e=>u?String(e):pad(e)),column("minute",v.minute,S,e=>e===y.getMinutes(),pad),d?column("second",v.second,z,e=>e===y.getSeconds(),pad):null,u?column("meridiem",v.meridiem,[0,1],e=>(y.getHours()>=12?1:0)===e,e=>0===e?D:N):null,e("span",{className:F,"aria-live":"polite",children:null===a?"":n(l,{hour:"numeric",minute:"2-digit",...d?{second:"2-digit"}:{}}).format(a)})]})}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arithmetic and the naming the four pickers share.
|
|
3
|
+
*
|
|
4
|
+
* No date library under it, deliberately. Plass has one runtime dependency —
|
|
5
|
+
* Base UI — and a component library that quietly adds `date-fns`, or worse
|
|
6
|
+
* picks a side in the dayjs/luxon/Temporal argument on its consumer's behalf,
|
|
7
|
+
* has made a decision that was not its to make. Everything here is either
|
|
8
|
+
* `Date` arithmetic, which is a dozen lines, or `Intl`, which the platform
|
|
9
|
+
* already ships and which knows more about month names in more languages than
|
|
10
|
+
* any bundled table ever will.
|
|
11
|
+
*
|
|
12
|
+
* **That is also the whole of the localisation story.** There is no table of
|
|
13
|
+
* translated month names to import and no per-language module to register: the
|
|
14
|
+
* only strings a picker says that `Intl` has no opinion about are the labels on
|
|
15
|
+
* its own buttons, and those are one `labels` prop with English defaults. A
|
|
16
|
+
* project that ships in twelve languages pays nothing for eleven of them.
|
|
17
|
+
*
|
|
18
|
+
* Two rules hold everywhere below:
|
|
19
|
+
*
|
|
20
|
+
* - **Local time, always.** A calendar day is a thing a person is looking at on
|
|
21
|
+
* a wall, not an instant on a line. `makeDate(2026, 6, 27)` is midnight local
|
|
22
|
+
* and every comparison here is made on the local Y/M/D triple, so a picker in
|
|
23
|
+
* Seoul and a picker in São Paulo both light up the cell that says 27.
|
|
24
|
+
* - **Nothing is mutated.** `Date` is mutable and every method on it that
|
|
25
|
+
* sounds like a question is actually a command. Each function here copies
|
|
26
|
+
* first, so a `value` handed in by a caller is never the object that comes
|
|
27
|
+
* back out.
|
|
28
|
+
*/
|
|
29
|
+
import type { PlassWeekday } from '../types.js';
|
|
30
|
+
/** Which unit the calendar is currently letting you pick. */
|
|
31
|
+
export type CalendarView = 'day' | 'month' | 'year';
|
|
32
|
+
/** How many years one page of the year grid holds. Four columns of three. */
|
|
33
|
+
export declare const YEAR_PAGE_SIZE = 12;
|
|
34
|
+
/**
|
|
35
|
+
* A local midnight on the given Y/M/D, with out-of-range parts normalised —
|
|
36
|
+
* month `12` rolls into January, day `0` into the last day of the month before.
|
|
37
|
+
*
|
|
38
|
+
* Built through `setFullYear` rather than `new Date(year, month, day)` because
|
|
39
|
+
* the multi-argument constructor maps years 0–99 onto 1900–1999. Nobody is
|
|
40
|
+
* going to pick a date in the year 47, but a component that silently rewrites
|
|
41
|
+
* the year it was handed is a component that will eventually be blamed for
|
|
42
|
+
* something else.
|
|
43
|
+
*/
|
|
44
|
+
export declare function makeDate(year: number, month: number, day: number): Date;
|
|
45
|
+
/** Is this a `Date` that stands for a real instant? `new Date('nope')` is not. */
|
|
46
|
+
export declare function isValidDate(value: unknown): value is Date;
|
|
47
|
+
/** The same day with the clock wound back to midnight. */
|
|
48
|
+
export declare function startOfDay(date: Date): Date;
|
|
49
|
+
/** The first day of the month this date is in, at midnight. */
|
|
50
|
+
export declare function startOfMonth(date: Date): Date;
|
|
51
|
+
/** How many days a month has, leap years included. */
|
|
52
|
+
export declare function daysInMonth(year: number, month: number): number;
|
|
53
|
+
/** Today, at midnight. The one place the pickers read the clock for a *date*. */
|
|
54
|
+
export declare function today(): Date;
|
|
55
|
+
export declare function addDays(date: Date, amount: number): Date;
|
|
56
|
+
/**
|
|
57
|
+
* Months, with the day of the month clamped rather than allowed to overflow.
|
|
58
|
+
*
|
|
59
|
+
* 31 January plus one month is 28 February, not 3 March. The naive
|
|
60
|
+
* `setMonth(getMonth() + 1)` gives the second answer, which is why stepping a
|
|
61
|
+
* calendar forward from a 31st with it skips February entirely.
|
|
62
|
+
*/
|
|
63
|
+
export declare function addMonths(date: Date, amount: number): Date;
|
|
64
|
+
export declare function addYears(date: Date, amount: number): Date;
|
|
65
|
+
/** Negative, zero or positive, the way a sort comparator wants it. */
|
|
66
|
+
export declare function compareDay(a: Date, b: Date): number;
|
|
67
|
+
export declare function isSameDay(a: Date | null | undefined, b: Date | null | undefined): boolean;
|
|
68
|
+
export declare function isSameMonth(a: Date | null | undefined, b: Date | null | undefined): boolean;
|
|
69
|
+
/** Holds a date inside `[min, max]`, at whatever precision the bounds carry. */
|
|
70
|
+
export declare function clampDate(date: Date, min?: Date | null, max?: Date | null): Date;
|
|
71
|
+
/**
|
|
72
|
+
* Is this calendar *day* outside the allowed span?
|
|
73
|
+
*
|
|
74
|
+
* Day-granular on purpose. A `maxDate` of 27 July at 09:00 still leaves the
|
|
75
|
+
* 27th pickable — the bound is about which days exist, and the time of day is
|
|
76
|
+
* the time picker's problem. `PlDateTimePicker` re-checks at full precision
|
|
77
|
+
* once an hour has been chosen.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isDayOutside(date: Date, min?: Date | null, max?: Date | null): boolean;
|
|
80
|
+
/** Seconds since local midnight — what `minTime`/`maxTime` are compared on. */
|
|
81
|
+
export declare function secondsOfDay(date: Date): number;
|
|
82
|
+
/** Which column of a clock a candidate time is being offered for. */
|
|
83
|
+
export type TimeUnit = 'hour' | 'minute' | 'second' | 'meridiem';
|
|
84
|
+
/**
|
|
85
|
+
* The span of the day one row of one column covers, in seconds since midnight.
|
|
86
|
+
*
|
|
87
|
+
* This is the detail that separates a working time picker from a frustrating
|
|
88
|
+
* one. A bound has to be checked against the *span* a row stands for, not
|
|
89
|
+
* against one instant inside it: with a `minTime` of 09:30, the hour `9` covers
|
|
90
|
+
* 09:00:00–09:59:59, which overlaps what is allowed, so it stays available and
|
|
91
|
+
* the minute column is where `00` through `25` grey out. Comparing the whole
|
|
92
|
+
* candidate instead hides the 9 and makes half past nine unreachable.
|
|
93
|
+
*/
|
|
94
|
+
export declare function timeUnitSpan(unit: TimeUnit, at: Date): [number, number];
|
|
95
|
+
/** The same instant with one or more clock fields replaced. */
|
|
96
|
+
export declare function withTime(date: Date, parts: {
|
|
97
|
+
hours?: number;
|
|
98
|
+
minutes?: number;
|
|
99
|
+
seconds?: number;
|
|
100
|
+
}): Date;
|
|
101
|
+
/** `date`'s calendar day wearing `time`'s clock. */
|
|
102
|
+
export declare function mergeDateAndTime(date: Date, time: Date): Date;
|
|
103
|
+
/**
|
|
104
|
+
* Six weeks of seven days, always — including the leading and trailing days
|
|
105
|
+
* that belong to the neighbouring months.
|
|
106
|
+
*
|
|
107
|
+
* Six rows whatever the month, and that is the whole point. A February that
|
|
108
|
+
* starts on a Sunday needs four rows and a 31-day month starting on a Saturday
|
|
109
|
+
* needs six; a grid that renders only the rows it needs is a grid that changes
|
|
110
|
+
* height when you step a month forward, moving every cell out from under the
|
|
111
|
+
* pointer that just pressed one. The same reason `PlPagination` pins its slot
|
|
112
|
+
* count.
|
|
113
|
+
*/
|
|
114
|
+
export declare function calendarWeeks(month: Date, weekStartsOn: PlassWeekday): Date[][];
|
|
115
|
+
/** The first year on the page a given year falls on. 2026 becomes 2016 at 12 a page. */
|
|
116
|
+
export declare function yearPageStart(year: number): number;
|
|
117
|
+
/** Formats a date, tolerating the `null` a cleared picker holds. */
|
|
118
|
+
export declare function formatDate(date: Date | null | undefined, locale: string | undefined, options: Intl.DateTimeFormatOptions): string;
|
|
119
|
+
/**
|
|
120
|
+
* Every distinct string those instants format to. Deduplicated, because a
|
|
121
|
+
* date-only format collapses twenty-four of them into a handful.
|
|
122
|
+
*/
|
|
123
|
+
export declare function displaySamples(locale: string | undefined, options: Intl.DateTimeFormatOptions): string[];
|
|
124
|
+
/**
|
|
125
|
+
* The samples plus the placeholder, when the placeholder is a string.
|
|
126
|
+
*
|
|
127
|
+
* An empty picker shows the placeholder, which can easily be longer than any
|
|
128
|
+
* date — "Pick a departure date" against "3 Aug 2026" — and a trigger that
|
|
129
|
+
* shrinks the moment the first date is chosen is the same jump from the other
|
|
130
|
+
* direction. A `ReactNode` placeholder is left out: there is nothing to measure
|
|
131
|
+
* without rendering it twice.
|
|
132
|
+
*/
|
|
133
|
+
export declare function withPlaceholder(samples: string[], placeholder: unknown): string[];
|
|
134
|
+
/**
|
|
135
|
+
* The three machine-readable spellings, for the hidden input that makes a
|
|
136
|
+
* picker submit with a form.
|
|
137
|
+
*
|
|
138
|
+
* Local, not UTC, and that is the whole point: `toISOString()` on a `Date`
|
|
139
|
+
* standing for 27 July in Seoul gives `2026-07-26T15:00:00Z`, and a form field
|
|
140
|
+
* that quietly reports the day before the one on screen is the single most
|
|
141
|
+
* expensive bug a date picker can ship. The shapes are the ones the native
|
|
142
|
+
* `<input type="date">`, `type="time"` and `type="datetime-local"` submit, so a
|
|
143
|
+
* server that already parses those needs no new code.
|
|
144
|
+
*/
|
|
145
|
+
export declare function toISODate(date: Date): string;
|
|
146
|
+
export declare function toISOTime(date: Date, withSeconds?: boolean): string;
|
|
147
|
+
export declare function toISODateTime(date: Date, withSeconds?: boolean): string;
|
|
148
|
+
/**
|
|
149
|
+
* The seven column headers, rotated so the first one is `weekStartsOn`.
|
|
150
|
+
*
|
|
151
|
+
* `short` rather than `narrow`: narrow gives `S`, `M`, `T`, `W`, `T`, `F`, `S`
|
|
152
|
+
* in English, where two pairs are indistinguishable. The full name goes on the
|
|
153
|
+
* header's `aria-label` so a screen reader hears "Monday" rather than "Mon".
|
|
154
|
+
*/
|
|
155
|
+
export declare function weekdayLabels(locale: string | undefined, weekStartsOn: PlassWeekday, weekday?: 'narrow' | 'short' | 'long'): string[];
|
|
156
|
+
/** The twelve month names, January first, in the locale's own words. */
|
|
157
|
+
export declare function monthLabels(locale: string | undefined, month?: 'short' | 'long'): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Does this locale write the month before the year?
|
|
160
|
+
*
|
|
161
|
+
* The calendar's header is two separate buttons — one that opens the month grid
|
|
162
|
+
* and one that opens the year grid — so it cannot just print what `Intl` gives
|
|
163
|
+
* it. Asking `formatToParts` which part came first is how the two buttons end
|
|
164
|
+
* up in the order the reader expects: `July 2026` in English, `2026년 7월` in
|
|
165
|
+
* Korean. Getting this wrong is subtle and reads as broken to exactly the
|
|
166
|
+
* people it is wrong for.
|
|
167
|
+
*/
|
|
168
|
+
export declare function isMonthBeforeYear(locale: string | undefined): boolean;
|
|
169
|
+
/** Does this locale put a clock on a 12-hour dial? */
|
|
170
|
+
export declare function isHour12(locale: string | undefined): boolean;
|
|
171
|
+
/** What this locale calls AM and PM. */
|
|
172
|
+
export declare function meridiemLabels(locale: string | undefined): [string, string];
|
|
173
|
+
export declare function localeWeekStart(locale: string | undefined): PlassWeekday;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dateFormatter as t}from"./format.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,r){const n=new Date(0);return n.setFullYear(t,e,r),n.setHours(0,0,0,0),n}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}export function addDays(t,e){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}export function addMonths(t,e){const r=new Date(t.getTime()),n=makeDate(t.getFullYear(),t.getMonth()+e,1);return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),daysInMonth(n.getFullYear(),n.getMonth()))),r}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function clampDate(t,e,r){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(r)&&t.getTime()>r.getTime()?new Date(r.getTime()):t}export function isDayOutside(t,e,r){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(r)&&compareDay(t,r)>0}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const r=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(r/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(r/60);return[t,t+59]}if("second"===t)return[r,r];const n=e.getHours()<12?0:43200;return[n,n+43200-1]}export function withTime(t,e){const r=new Date(t.getTime());return r.setHours(e.hours??r.getHours(),e.minutes??r.getMinutes(),e.seconds??r.getSeconds(),0),r}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const r=startOfMonth(t),n=(r.getDay()-e+7)%7,o=addDays(r,-n);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,r)=>addDays(o,7*e+r)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,r,n){return isValidDate(e)?t(r,n).format(e):""}const e=/* @__PURE__ */Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(r,n){const o=t(r,n);return[...new Set(e.map(t=>o.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISODate(t){const pad=t=>String(t).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${pad(t.getMonth()+1)}-${pad(t.getDate())}`}export function toISOTime(t,e=!1){const pad=t=>String(t).padStart(2,"0"),r=`${pad(t.getHours())}:${pad(t.getMinutes())}`;return e?`${r}:${pad(t.getSeconds())}`:r}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const r=/* @__PURE__ */makeDate(2021,7,1);export function weekdayLabels(e,n,o="short"){const a=t(e,{weekday:o});return Array.from({length:7},(t,e)=>a.format(addDays(r,(n+e)%7)))}export function monthLabels(e,r="short"){const n=t(e,{month:r});return Array.from({length:12},(t,e)=>n.format(makeDate(2021,e,1)))}export function isMonthBeforeYear(e){const n=t(e,{year:"numeric",month:"long"}).formatToParts(r);return n.findIndex(t=>"month"===t.type)<n.findIndex(t=>"year"===t.type)}export function isHour12(e){const r=t(e,{hour:"numeric"}).resolvedOptions();return r.hourCycle?"h11"===r.hourCycle||"h12"===r.hourCycle:!0===r.hour12}export function meridiemLabels(e){const n=t(e,{hour:"numeric",hour12:!0}),read=t=>{const e=n.formatToParts(withTime(r,{hours:t})).find(t=>"dayPeriod"===t.type);return e?.value??(t<12?"AM":"PM")};return[read(9),read(21)]}export function localeWeekStart(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,r=new Intl.Locale(e),n="function"==typeof r.getWeekInfo?r.getWeekInfo():r.weekInfo;if("number"==typeof n?.firstDay)return n.firstDay%7}catch{}return 0}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `Intl` formatters, memoised.
|
|
3
|
+
*
|
|
4
|
+
* Here rather than inline for one reason: constructing a formatter is the
|
|
5
|
+
* expensive half of using one. On V8, `new Intl.DateTimeFormat(...).format(d)`
|
|
6
|
+
* costs about 16us and `format(d)` on a formatter that already exists costs
|
|
7
|
+
* about 0.3us — fifty-five times the work for the same string.
|
|
8
|
+
*
|
|
9
|
+
* That ratio only matters where the call is in a loop or in a render, and in the
|
|
10
|
+
* pickers it is both: a calendar builds seven weekday names and twelve month
|
|
11
|
+
* names for a 42-cell month view, and it builds them again on every step, every
|
|
12
|
+
* hover and every keystroke.
|
|
13
|
+
*
|
|
14
|
+
* The cache is unbounded on purpose. The keys are not user data — they come from
|
|
15
|
+
* a component's own option objects, of which any one page has a handful — so
|
|
16
|
+
* there is nothing here that grows with the size of anything.
|
|
17
|
+
*
|
|
18
|
+
* The options object is deliberately **not** part of the key by identity. A
|
|
19
|
+
* caller writing `format={{ dateStyle: 'medium' }}` inline hands over a new
|
|
20
|
+
* object on every render, which is the ordinary way that prop gets written, and
|
|
21
|
+
* keying on identity would miss every time and cache nothing but garbage.
|
|
22
|
+
*/
|
|
23
|
+
/** A memoised `Intl.DateTimeFormat`. */
|
|
24
|
+
export declare function dateFormatter(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=new Map;export function dateFormatter(e,n){const r=function cacheKey(t,e){return`${t??""}\0${e?JSON.stringify(e):""}`}(e,n);let o=t.get(r);return o||(o=new Intl.DateTimeFormat(e,n),t.set(r,o)),o}
|