plass-ui 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion/PlAccordion.d.ts +98 -0
- package/dist/components/accordion/PlAccordion.js +131 -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 +109 -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 +71 -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 +47 -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 +48 -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 +49 -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 +120 -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 +65 -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 +94 -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 +50 -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 +49 -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 +177 -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 +45 -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 +58 -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 +121 -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 +168 -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 +112 -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 +141 -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 +46 -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 +201 -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 +196 -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 +64 -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 +102 -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 +177 -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 +206 -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 +100 -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 +144 -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 +65 -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 +199 -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 +47 -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 +87 -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 +152 -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 +106 -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 +107 -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 +190 -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 +274 -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 +291 -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 +51 -0
- package/dist/components/grid/PlGridItem.d.ts +50 -0
- package/dist/components/grid/PlGridItem.js +34 -0
- package/dist/components/grid/index.d.ts +4 -0
- package/dist/components/grid/index.js +2 -0
- package/dist/components/highlight/PlHighlight.d.ts +90 -0
- package/dist/components/highlight/PlHighlight.js +185 -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 +294 -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 +58 -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 +37 -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 +160 -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 +209 -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 +150 -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 +111 -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 +109 -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 +77 -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 +159 -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 +324 -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 +154 -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 +113 -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 +34 -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 +47 -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 +40 -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 +99 -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 +101 -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 +411 -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 +206 -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 +115 -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 +142 -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 +132 -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 +74 -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 +131 -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 +210 -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 +182 -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 +126 -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 +136 -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 +97 -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 +207 -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 +174 -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 +65 -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 +117 -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 +143 -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 +75 -1
- package/dist/internal/animate.d.ts +161 -0
- package/dist/internal/animate.js +318 -0
- package/dist/internal/button-group.d.ts +27 -0
- package/dist/internal/button-group.js +19 -0
- package/dist/internal/calendar.d.ts +148 -0
- package/dist/internal/calendar.js +501 -0
- package/dist/internal/date.d.ts +173 -0
- package/dist/internal/date.js +353 -0
- package/dist/internal/format.d.ts +24 -0
- package/dist/internal/format.js +41 -0
- package/dist/internal/grid.d.ts +67 -0
- package/dist/internal/grid.js +143 -0
- package/dist/internal/icons.d.ts +86 -1
- package/dist/internal/icons.js +138 -1
- package/dist/internal/menu.d.ts +20 -0
- package/dist/internal/menu.js +18 -0
- package/dist/internal/picker.d.ts +118 -0
- package/dist/internal/picker.js +139 -0
- package/dist/internal/progress.d.ts +145 -0
- package/dist/internal/progress.js +167 -0
- package/dist/internal/sizer.d.ts +32 -0
- package/dist/internal/sizer.js +35 -0
- package/dist/internal/styles.d.ts +198 -8
- package/dist/internal/styles.js +636 -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 +1 -1
- package/package.json +31 -27
- package/README.md +0 -111
- package/dist/components/button/Button.js +0 -1
- package/dist/components/text-field/TextField.js +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Field } from '@base-ui/react/field';
|
|
4
|
+
import { Input } from '@base-ui/react/input';
|
|
5
|
+
import { Spinner } from '../../internal/icons.js';
|
|
6
|
+
import { controlHeightClasses, controlTextLeadingClasses, disabledClasses, fieldReadOnlyClasses, fieldRestClasses, focusWithinRingClasses, gapClasses, hasContent, iconClasses, metaTextClasses, paddingXClasses, radiusClasses, stackGapClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
|
|
7
|
+
/**
|
|
8
|
+
* Type scale and radius, shared by both modes. The line height is explicit here
|
|
9
|
+
* rather than `leading-none` as on PlButton, because in multiline mode it is what
|
|
10
|
+
* decides the height of a row — and it has to agree with the single-line
|
|
11
|
+
* heights below or a one-row textarea would not line up with an input.
|
|
12
|
+
*/
|
|
13
|
+
const sizeClasses = {
|
|
14
|
+
xs: `${gapClasses.xs} ${radiusClasses.xs} ${controlTextLeadingClasses.xs}`,
|
|
15
|
+
sm: `${gapClasses.sm} ${radiusClasses.sm} ${controlTextLeadingClasses.sm}`,
|
|
16
|
+
md: `${gapClasses.md} ${radiusClasses.md} ${controlTextLeadingClasses.md}`,
|
|
17
|
+
lg: `${gapClasses.lg} ${radiusClasses.lg} ${controlTextLeadingClasses.lg}`,
|
|
18
|
+
xl: `${gapClasses.xl} ${radiusClasses.xl} ${controlTextLeadingClasses.xl}`
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Multiline cannot use a fixed height — `rows` decides it. Instead the vertical
|
|
22
|
+
* padding is `(height - border - line-height) / 2`, which makes a one-row
|
|
23
|
+
* textarea exactly as tall as the single-line field of the same size. The
|
|
24
|
+
* `min-h-*` catches the variants that carry no border.
|
|
25
|
+
*
|
|
26
|
+
* These are keyed by `size` and never by `density`: density is horizontal
|
|
27
|
+
* padding only, and letting it touch this would make the same `rows` produce
|
|
28
|
+
* two different heights.
|
|
29
|
+
*/
|
|
30
|
+
const multilineClasses = {
|
|
31
|
+
xs: 'min-h-6 py-[3px]',
|
|
32
|
+
sm: 'min-h-8 py-[6px]',
|
|
33
|
+
md: 'min-h-10 py-[9px]',
|
|
34
|
+
lg: 'min-h-12 py-[11px]',
|
|
35
|
+
xl: 'min-h-14 py-[13px]'
|
|
36
|
+
};
|
|
37
|
+
const resizeClasses = {
|
|
38
|
+
none: 'resize-none',
|
|
39
|
+
vertical: 'resize-y',
|
|
40
|
+
horizontal: 'resize-x',
|
|
41
|
+
both: 'resize'
|
|
42
|
+
};
|
|
43
|
+
const shellBaseClasses = /* @__PURE__ */ [
|
|
44
|
+
// `group` so the adornments can answer the control's focus; `cursor-text`
|
|
45
|
+
// because the whole shell behaves as the field, padding included.
|
|
46
|
+
'group relative flex w-full cursor-text',
|
|
47
|
+
'[-webkit-tap-highlight-color:transparent]',
|
|
48
|
+
transitionClasses,
|
|
49
|
+
// The ring belongs to the shell, not to the control inside it, so it traces
|
|
50
|
+
// the glass edge rather than a rectangle floating inside it.
|
|
51
|
+
focusWithinRingClasses,
|
|
52
|
+
iconClasses
|
|
53
|
+
].join(' ');
|
|
54
|
+
/**
|
|
55
|
+
* The shell, the read-only treatment and the disabled treatment are the ones
|
|
56
|
+
* `internal/styles` defines for every field-shaped control — a Select's trigger
|
|
57
|
+
* is drawn on exactly the same box, and the two have to be indistinguishable.
|
|
58
|
+
*/
|
|
59
|
+
const restClasses = fieldRestClasses;
|
|
60
|
+
const readOnlyClasses = fieldReadOnlyClasses;
|
|
61
|
+
export const PlTextField = /* @__PURE__ */ React.forwardRef(function PlTextField({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, multiline = false, rows = 3, resize = 'vertical', label, description, error, invalid, startIcon, endIcon, loading = false, fullWidth = false, readOnly = false, disabled = false, type = 'text', className, style, ...props }, ref) {
|
|
62
|
+
const hasError = hasContent(error);
|
|
63
|
+
const isInvalid = invalid ?? hasError;
|
|
64
|
+
// Invalid re-points the whole slot family at `danger`, so the edge, the ring,
|
|
65
|
+
// the caret and the message all turn over together and no state needs its own
|
|
66
|
+
// set of tokens.
|
|
67
|
+
const family = isInvalid ? 'danger' : color;
|
|
68
|
+
const controlRef = React.useRef(null);
|
|
69
|
+
const setControlRef = React.useCallback((node) => {
|
|
70
|
+
controlRef.current = node;
|
|
71
|
+
if (typeof ref === 'function') {
|
|
72
|
+
ref(node);
|
|
73
|
+
}
|
|
74
|
+
else if (ref) {
|
|
75
|
+
ref.current = node;
|
|
76
|
+
}
|
|
77
|
+
}, [ref]);
|
|
78
|
+
const shellClasses = [
|
|
79
|
+
shellBaseClasses,
|
|
80
|
+
sizeClasses[size],
|
|
81
|
+
multiline
|
|
82
|
+
? `${multilineClasses[size]} items-start`
|
|
83
|
+
: `${controlHeightClasses[size]} items-center`,
|
|
84
|
+
paddingXClasses[density][size],
|
|
85
|
+
// An if/else rather than stacked `data-*` variants: two Tailwind variants
|
|
86
|
+
// of equal specificity resolve by their order in the generated stylesheet.
|
|
87
|
+
disabled ? disabledClasses[variant] : readOnly ? readOnlyClasses[variant] : restClasses[variant]
|
|
88
|
+
]
|
|
89
|
+
.filter(Boolean)
|
|
90
|
+
.join(' ');
|
|
91
|
+
const controlClasses = [
|
|
92
|
+
'min-w-0 flex-1 bg-transparent [font:inherit] text-inherit',
|
|
93
|
+
// Not `outline-none`: that utility zeroes `--tw-outline-style`, and the
|
|
94
|
+
// shell's focus ring is drawn with the same variable family. The shorthand
|
|
95
|
+
// takes the outline off this element and leaves the ring alone.
|
|
96
|
+
'[outline:none]',
|
|
97
|
+
'placeholder:text-(--plass-muted-fg)',
|
|
98
|
+
'caret-(--p-accent) selection:bg-(--p-soft-press)',
|
|
99
|
+
'disabled:cursor-not-allowed',
|
|
100
|
+
multiline ? `block ${resizeClasses[resize]}` : 'self-stretch'
|
|
101
|
+
].join(' ');
|
|
102
|
+
// `1lh` keeps an adornment centred on the first line rather than on the whole
|
|
103
|
+
// box, which is the only way it stays put when the control grows to 5 rows.
|
|
104
|
+
const adornmentClasses = 'inline-flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg) transition-[color] duration-(--plass-duration) group-focus-within:text-(--p-accent)';
|
|
105
|
+
return (_jsxs(Field.Root, { disabled: disabled, invalid: isInvalid, className: [
|
|
106
|
+
'flex-col align-top',
|
|
107
|
+
stackGapClasses[size],
|
|
108
|
+
fullWidth ? 'flex w-full' : 'inline-flex',
|
|
109
|
+
className ?? ''
|
|
110
|
+
]
|
|
111
|
+
.filter(Boolean)
|
|
112
|
+
.join(' '), style: { ...surfaceSlots(family, elevation), ...style }, children: [label ? (_jsx(Field.Label, { className: [
|
|
113
|
+
metaTextClasses[size],
|
|
114
|
+
'font-semibold',
|
|
115
|
+
disabled ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'
|
|
116
|
+
].join(' '), children: label })) : null, _jsxs("span", { className: shellClasses, onPointerDown: (event) => {
|
|
117
|
+
// Clicking the shell's own padding should put the caret in the field,
|
|
118
|
+
// the way clicking anywhere inside a native input does. Only when the
|
|
119
|
+
// shell itself was hit — a click on the control or on an adornment is
|
|
120
|
+
// left alone so text selection still works.
|
|
121
|
+
if (event.target === event.currentTarget && !disabled) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
controlRef.current?.focus();
|
|
124
|
+
}
|
|
125
|
+
}, children: [startIcon ? _jsx("span", { className: adornmentClasses, children: startIcon }) : null, _jsx(Input, { ref: setControlRef, className: controlClasses, disabled: disabled, readOnly: readOnly, "aria-busy": loading || undefined, "data-loading": loading || undefined, ...(multiline ? { render: _jsx("textarea", { rows: rows }) } : { type }), ...props }), loading ? (_jsx("span", { className: adornmentClasses, children: _jsx(Spinner, {}) })) : endIcon ? (_jsx("span", { className: adornmentClasses, children: endIcon })) : null] }), description ? (_jsx(Field.Description, { className: [metaTextClasses[size], 'text-(--plass-muted-fg)'].join(' '), children: description })) : null, hasError ? (_jsx(Field.Error, { match: true, className: [metaTextClasses[size], 'text-(--p-accent)'].join(' '), children: error })) : null] }));
|
|
126
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { PlTextField } from './PlTextField.js';
|
|
2
|
+
export type { PlTextFieldProps, PlTextFieldResize } from './PlTextField.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { PlTextField } from './PlTextField.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { PlassColor, PlassSize } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* When the line under a link is drawn.
|
|
6
|
+
*
|
|
7
|
+
* `always` is the default, and the reason is `color`: a link takes no colour
|
|
8
|
+
* family unless one is asked for, so with the line off there would be nothing
|
|
9
|
+
* at all distinguishing it from the sentence it sits in. That is also why this
|
|
10
|
+
* is not a boolean — "no underline" is a real choice for a link in a nav bar or
|
|
11
|
+
* a footer, where position already says what it is, and it should have to be
|
|
12
|
+
* spelled out rather than fallen into.
|
|
13
|
+
*/
|
|
14
|
+
export type PlTextLinkUnderline = 'always' | 'hover' | 'none';
|
|
15
|
+
export interface PlTextLinkProps extends Omit<React.ComponentPropsWithoutRef<'a'>, 'color'> {
|
|
16
|
+
/** Where the link goes. */
|
|
17
|
+
href: string;
|
|
18
|
+
/**
|
|
19
|
+
* When the underline is drawn.
|
|
20
|
+
* @default 'always'
|
|
21
|
+
*/
|
|
22
|
+
underline?: PlTextLinkUnderline;
|
|
23
|
+
/**
|
|
24
|
+
* Semantic colour role. Unlike every control in the library this has **no
|
|
25
|
+
* default** — a link in a paragraph is usually the paragraph's own colour
|
|
26
|
+
* with a line under it, and a component that arrived pre-dyed is one a page
|
|
27
|
+
* has to undo.
|
|
28
|
+
*/
|
|
29
|
+
color?: PlassColor;
|
|
30
|
+
/**
|
|
31
|
+
* The type scale. Also no default: a link inside a sentence is the size of
|
|
32
|
+
* the sentence. Set it for a link that stands on its own.
|
|
33
|
+
*/
|
|
34
|
+
size?: PlassSize;
|
|
35
|
+
/**
|
|
36
|
+
* Opens the link in a new tab, with the `rel` that keeps the new page from
|
|
37
|
+
* reaching back into this one.
|
|
38
|
+
*
|
|
39
|
+
* A window changing under the reader is the one thing about a link that
|
|
40
|
+
* cannot be seen before it happens, so this also turns `icon` on by default
|
|
41
|
+
* and adds a line for a screen reader.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
newTab?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The mark after the label. `true` draws the arrow leaving its box when
|
|
47
|
+
* `newTab` is on and the chain otherwise, `false` draws nothing, and a node
|
|
48
|
+
* of your own replaces the glyph.
|
|
49
|
+
*
|
|
50
|
+
* Left out, it follows `newTab`.
|
|
51
|
+
*/
|
|
52
|
+
icon?: React.ReactNode | boolean;
|
|
53
|
+
/**
|
|
54
|
+
* What a screen reader hears after the label on a `newTab` link. Never drawn.
|
|
55
|
+
* @default '(opens in a new tab)'
|
|
56
|
+
*/
|
|
57
|
+
newTabLabel?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Renders something other than an `<a>` — the `Link` a router brings, most of
|
|
60
|
+
* the time. `href` still goes through, so `render={<NextLink href="…" />}`
|
|
61
|
+
* needs it written once, on the `PlTextLink`.
|
|
62
|
+
*/
|
|
63
|
+
render?: useRender.RenderProp;
|
|
64
|
+
/** The label. */
|
|
65
|
+
children?: React.ReactNode;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A link, in a sentence or on its own.
|
|
69
|
+
*
|
|
70
|
+
* Everything about it is deliberately smaller than a PlButton. It has no
|
|
71
|
+
* surface, no height of its own and no colour unless asked — what it has is a
|
|
72
|
+
* line under it, which is the one mark a reader already knows means "this goes
|
|
73
|
+
* somewhere".
|
|
74
|
+
*
|
|
75
|
+
* The three things it does that a bare `<a>` does not: it draws that line on a
|
|
76
|
+
* schedule (`always`, or only under the pointer), it marks a link that opens a
|
|
77
|
+
* new tab both visibly and for a screen reader, and it takes `render`, so the
|
|
78
|
+
* `Link` a router brings can wear all of it.
|
|
79
|
+
*/
|
|
80
|
+
export declare const PlTextLink: React.ForwardRefExoticComponent<PlTextLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
4
|
+
import { ExternalLinkIcon, LinkIcon } from '../../internal/icons.js';
|
|
5
|
+
import { controlTextLeadingClasses, focusRingClasses, srOnlyClasses } from '../../internal/styles.js';
|
|
6
|
+
/**
|
|
7
|
+
* Whether the line is drawn, and — with the colour below — the only two things
|
|
8
|
+
* about a link that a prop changes. Everything else about the line is in
|
|
9
|
+
* `styles.css`, under `.plass-link`.
|
|
10
|
+
*
|
|
11
|
+
* Every utility here is written through `[&.plass-link]`, which doubles the
|
|
12
|
+
* component's own class into the selector and takes it to two classes. That is
|
|
13
|
+
* not decoration: `<a>` is, with `<td>`, one of the two tags a host stylesheet
|
|
14
|
+
* still styles by name — `.prose a`, `.vp-doc a`, every CSS framework — and all
|
|
15
|
+
* of those are a class plus a type, which outranks a plain utility. A link that
|
|
16
|
+
* lost its colour and its line inside a `.prose` block would have lost the only
|
|
17
|
+
* two things it is.
|
|
18
|
+
*
|
|
19
|
+
* Hover deliberately leaves the *text* colour alone. A link inside running
|
|
20
|
+
* prose that changes colour under the pointer drags the reader's eye off the
|
|
21
|
+
* line they were reading — the same rule the library applies to a control's
|
|
22
|
+
* label, on the one component that lives inside a sentence.
|
|
23
|
+
*/
|
|
24
|
+
const underlineClasses = {
|
|
25
|
+
always: '[&.plass-link]:underline',
|
|
26
|
+
hover: '[&.plass-link]:no-underline [&.plass-link]:hover:underline',
|
|
27
|
+
// Nothing to hover, on purpose. A link with no line and no colour is a link
|
|
28
|
+
// whose surroundings are saying what it is.
|
|
29
|
+
none: '[&.plass-link]:no-underline'
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Only two properties move, so this is written out rather than taken from
|
|
33
|
+
* `transitionClasses` — the house list has no `text-decoration-color` in it,
|
|
34
|
+
* and adding one there would put a property on every control in the library
|
|
35
|
+
* that no control draws.
|
|
36
|
+
*/
|
|
37
|
+
const transition = /* @__PURE__ */ [
|
|
38
|
+
'[transition-property:color,text-decoration-color]',
|
|
39
|
+
'[transition-duration:var(--plass-duration)]',
|
|
40
|
+
'[transition-timing-function:var(--plass-ease)]'
|
|
41
|
+
].join(' ');
|
|
42
|
+
const baseClasses = /* @__PURE__ */ [
|
|
43
|
+
// Both a style hook and the specificity. `styles.css` doubles this class to
|
|
44
|
+
// write the parts of the line that never vary — its thickness, its offset,
|
|
45
|
+
// its colour — above whatever the host page says about an `<a>`, and every
|
|
46
|
+
// utility that *does* vary is written through it for the same reason.
|
|
47
|
+
'plass-link',
|
|
48
|
+
'cursor-pointer',
|
|
49
|
+
// The glyph rides on the label at just under its cap height, rather than at
|
|
50
|
+
// the `1.2em` an icon inside a control takes: this one sits in a sentence,
|
|
51
|
+
// and an icon as tall as the line spaces the words around it apart.
|
|
52
|
+
'[&_svg]:pointer-events-none [&_svg]:inline [&_svg]:size-[0.95em] [&_svg]:shrink-0',
|
|
53
|
+
transition,
|
|
54
|
+
focusRingClasses,
|
|
55
|
+
'focus-visible:rounded-[0.25rem]'
|
|
56
|
+
].join(' ');
|
|
57
|
+
/**
|
|
58
|
+
* A link, in a sentence or on its own.
|
|
59
|
+
*
|
|
60
|
+
* Everything about it is deliberately smaller than a PlButton. It has no
|
|
61
|
+
* surface, no height of its own and no colour unless asked — what it has is a
|
|
62
|
+
* line under it, which is the one mark a reader already knows means "this goes
|
|
63
|
+
* somewhere".
|
|
64
|
+
*
|
|
65
|
+
* The three things it does that a bare `<a>` does not: it draws that line on a
|
|
66
|
+
* schedule (`always`, or only under the pointer), it marks a link that opens a
|
|
67
|
+
* new tab both visibly and for a screen reader, and it takes `render`, so the
|
|
68
|
+
* `Link` a router brings can wear all of it.
|
|
69
|
+
*/
|
|
70
|
+
export const PlTextLink = /* @__PURE__ */ React.forwardRef(function PlTextLink({ href, underline = 'always', color, size, newTab = false, icon, newTabLabel = '(opens in a new tab)', render, className, style, children, ...props }, ref) {
|
|
71
|
+
// `icon` left out follows `newTab`, which is the whole reason it is not a
|
|
72
|
+
// plain boolean with a `false` default: a link that takes over the window
|
|
73
|
+
// should say so, and a caller should have to ask for the silent version.
|
|
74
|
+
const mark = icon ?? newTab;
|
|
75
|
+
const glyph = mark === true ? newTab ? _jsx(ExternalLinkIcon, {}) : _jsx(LinkIcon, {}) : mark;
|
|
76
|
+
const classNames = [
|
|
77
|
+
baseClasses,
|
|
78
|
+
size ? controlTextLeadingClasses[size] : '',
|
|
79
|
+
underlineClasses[underline],
|
|
80
|
+
color ? '[&.plass-link]:text-(--p-accent)' : '[&.plass-link]:text-inherit',
|
|
81
|
+
className ?? ''
|
|
82
|
+
]
|
|
83
|
+
.filter(Boolean)
|
|
84
|
+
.join(' ');
|
|
85
|
+
/*
|
|
86
|
+
* The two line colours and the focus ring, as slots.
|
|
87
|
+
*
|
|
88
|
+
* `--p-ring` is set even when no family was asked for, because the ring is
|
|
89
|
+
* written as the `outline` shorthand and an undefined `var()` inside it
|
|
90
|
+
* makes the browser drop the whole declaration — an uncoloured link would
|
|
91
|
+
* lose its focus ring entirely rather than fall back to something plainer.
|
|
92
|
+
*
|
|
93
|
+
* The line rests at 45% of whatever the text is and goes to the full colour
|
|
94
|
+
* on hover, so it works the same on an inherited colour as on an accent one.
|
|
95
|
+
*/
|
|
96
|
+
const slots = {
|
|
97
|
+
'--p-underline': 'color-mix(in oklab, currentColor 45%, transparent)',
|
|
98
|
+
'--p-underline-hover': 'currentColor',
|
|
99
|
+
'--p-ring': `var(--plass-${color ?? 'primary'}-ring)`,
|
|
100
|
+
...(color ? { '--p-accent': `var(--plass-${color}-accent)` } : null)
|
|
101
|
+
};
|
|
102
|
+
/*
|
|
103
|
+
* `rel` is the one thing here a caller's own value is merged with rather
|
|
104
|
+
* than replaced by, and the reason is that the two purposes of the
|
|
105
|
+
* attribute have nothing to do with each other.
|
|
106
|
+
*
|
|
107
|
+
* `noopener` is what stops the new page reaching back through
|
|
108
|
+
* `window.opener`; `noreferrer` sits beside it for the browsers that still
|
|
109
|
+
* need the pair. The common reason to write a `rel` by hand is `nofollow`
|
|
110
|
+
* or `sponsored`, which is an SEO decision — and spelled as a plain
|
|
111
|
+
* override it would silently take the protection off a link that still
|
|
112
|
+
* opens in a new tab. Whatever was asked for is kept, with the two tokens
|
|
113
|
+
* added if they are not already there.
|
|
114
|
+
*/
|
|
115
|
+
const { rel: askedFor, ...rest } = props;
|
|
116
|
+
const rel = newTab
|
|
117
|
+
? [
|
|
118
|
+
...new Set([...(askedFor ?? '').split(/\s+/).filter(Boolean), 'noopener', 'noreferrer'])
|
|
119
|
+
].join(' ')
|
|
120
|
+
: askedFor;
|
|
121
|
+
return useRender({
|
|
122
|
+
render: render ?? _jsx("a", {}),
|
|
123
|
+
ref,
|
|
124
|
+
props: {
|
|
125
|
+
href,
|
|
126
|
+
target: newTab ? '_blank' : undefined,
|
|
127
|
+
className: classNames,
|
|
128
|
+
style: { ...slots, ...style },
|
|
129
|
+
children: (_jsxs(_Fragment, { children: [children, glyph ? _jsx("span", { className: "ms-[0.25em]", children: glyph }) : null, newTab ? (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: srOnlyClasses, children: newTabLabel })] })) : null] })),
|
|
130
|
+
...rest,
|
|
131
|
+
// After the spread on purpose: this is the merge above, not an override
|
|
132
|
+
// for a caller to win.
|
|
133
|
+
rel
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlTextLink } from './PlTextLink.js';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type PlassPickerLabels, type TimeUnit } from '../../internal/calendar.js';
|
|
3
|
+
import { type PlassPickerShellProps } from '../../internal/picker.js';
|
|
4
|
+
/**
|
|
5
|
+
* Which column of the clock a row belongs to. Re-exported so a caller writing a
|
|
6
|
+
* `shouldDisableTime` rule can name the argument it is handed.
|
|
7
|
+
*/
|
|
8
|
+
export type { TimeUnit };
|
|
9
|
+
export interface PlTimePickerProps extends PlassPickerShellProps {
|
|
10
|
+
/** The chosen time. A `Date`, so it carries a day as well — see `referenceDate`. */
|
|
11
|
+
value?: Date | null;
|
|
12
|
+
defaultValue?: Date | null;
|
|
13
|
+
onValueChange?: (value: Date | null) => void;
|
|
14
|
+
open?: boolean;
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
onOpenChange?: (open: boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The day a chosen time is written onto while there is no value yet.
|
|
19
|
+
* @default today
|
|
20
|
+
*/
|
|
21
|
+
referenceDate?: Date;
|
|
22
|
+
/** The earliest time of day that may be chosen. Only the clock is read. */
|
|
23
|
+
minTime?: Date | null;
|
|
24
|
+
/** The latest time of day that may be chosen. */
|
|
25
|
+
maxTime?: Date | null;
|
|
26
|
+
/**
|
|
27
|
+
* Blocks individual rows. Called once per row per column with the instant that
|
|
28
|
+
* row would produce and the column it is in, so a rule may be as coarse as
|
|
29
|
+
* "no afternoons" or as fine as one minute.
|
|
30
|
+
*/
|
|
31
|
+
shouldDisableTime?: (value: Date, unit: TimeUnit) => boolean;
|
|
32
|
+
/** A 12-hour dial with an AM/PM column. Defaults to whatever the locale does. */
|
|
33
|
+
hour12?: boolean;
|
|
34
|
+
/** Adds the seconds column. @default false */
|
|
35
|
+
showSeconds?: boolean;
|
|
36
|
+
/** How far apart the rows of each column are. @default 1 */
|
|
37
|
+
hourStep?: number;
|
|
38
|
+
minuteStep?: number;
|
|
39
|
+
secondStep?: number;
|
|
40
|
+
/**
|
|
41
|
+
* BCP 47 tag deciding whether the clock is on a 12-hour dial, what AM and PM
|
|
42
|
+
* are called, and how the trigger writes the time. Defaults to the browser's.
|
|
43
|
+
*/
|
|
44
|
+
locale?: string;
|
|
45
|
+
/**
|
|
46
|
+
* How the trigger writes the chosen time. Passed straight to `Intl`.
|
|
47
|
+
* @default { hour: 'numeric', minute: '2-digit' }, plus seconds when shown
|
|
48
|
+
*/
|
|
49
|
+
format?: Intl.DateTimeFormatOptions;
|
|
50
|
+
/** Shown in the trigger while nothing is chosen. */
|
|
51
|
+
placeholder?: React.ReactNode;
|
|
52
|
+
/** Offers the × that empties the control. @default false */
|
|
53
|
+
clearable?: boolean;
|
|
54
|
+
/** Offers the shortcut to the current time in the footer. @default true */
|
|
55
|
+
showNowButton?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Closes the popup as soon as any column is touched. `false` by default and
|
|
58
|
+
* unlike `PlDatePicker`, because a time is two answers and closing after the
|
|
59
|
+
* first one would make choosing 9:30 a matter of opening the popup twice.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
closeOnSelect?: boolean;
|
|
63
|
+
/** The strings the picker says. Every one has an English default. */
|
|
64
|
+
labels?: Partial<PlassPickerLabels>;
|
|
65
|
+
/** Identifies the field when a form is submitted, as `HH:MM` (`HH:MM:SS`). */
|
|
66
|
+
name?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A time of day, chosen from columns.
|
|
70
|
+
*
|
|
71
|
+
* Columns because they are the shape that answers what a time picker is actually
|
|
72
|
+
* asked: "half past nine" is two glances, and "any time at all, on the hour" is
|
|
73
|
+
* a column you never touch. A clock face is prettier and needs a `transform` to
|
|
74
|
+
* read, which this library does not have.
|
|
75
|
+
*
|
|
76
|
+
* The bounds are checked at the granularity of the column being drawn, which is
|
|
77
|
+
* the detail that separates a working time picker from a frustrating one. With a
|
|
78
|
+
* `minTime` of 09:30 the hour `9` stays available — the hour *contains* allowed
|
|
79
|
+
* minutes — and it is the minute column that greys out `00` through `25`. The
|
|
80
|
+
* naive check compares the whole candidate instant, hides the 9 entirely, and
|
|
81
|
+
* makes half past nine unreachable.
|
|
82
|
+
*
|
|
83
|
+
* The value is a `Date` rather than a string or a number of minutes, because
|
|
84
|
+
* everything else in this library that carries a moment is one, and because a
|
|
85
|
+
* time on its own has nowhere to record that it crossed a DST boundary.
|
|
86
|
+
* `referenceDate` is the day a bare time is written onto.
|
|
87
|
+
*/
|
|
88
|
+
export declare const PlTimePicker: React.ForwardRefExoticComponent<PlTimePickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { PlButton } from '../button/PlButton.js';
|
|
4
|
+
import { TimeGrid, usePickerLabels } from '../../internal/calendar.js';
|
|
5
|
+
import { ClockIcon } from '../../internal/icons.js';
|
|
6
|
+
import { PickerFooter, PickerShell } from '../../internal/picker.js';
|
|
7
|
+
import { displaySamples, formatDate, isHour12, isValidDate, secondsOfDay, timeUnitSpan, toISOTime, withPlaceholder, withTime } from '../../internal/date.js';
|
|
8
|
+
import { cx } from '../../internal/styles.js';
|
|
9
|
+
/**
|
|
10
|
+
* A time of day, chosen from columns.
|
|
11
|
+
*
|
|
12
|
+
* Columns because they are the shape that answers what a time picker is actually
|
|
13
|
+
* asked: "half past nine" is two glances, and "any time at all, on the hour" is
|
|
14
|
+
* a column you never touch. A clock face is prettier and needs a `transform` to
|
|
15
|
+
* read, which this library does not have.
|
|
16
|
+
*
|
|
17
|
+
* The bounds are checked at the granularity of the column being drawn, which is
|
|
18
|
+
* the detail that separates a working time picker from a frustrating one. With a
|
|
19
|
+
* `minTime` of 09:30 the hour `9` stays available — the hour *contains* allowed
|
|
20
|
+
* minutes — and it is the minute column that greys out `00` through `25`. The
|
|
21
|
+
* naive check compares the whole candidate instant, hides the 9 entirely, and
|
|
22
|
+
* makes half past nine unreachable.
|
|
23
|
+
*
|
|
24
|
+
* The value is a `Date` rather than a string or a number of minutes, because
|
|
25
|
+
* everything else in this library that carries a moment is one, and because a
|
|
26
|
+
* time on its own has nowhere to record that it crossed a DST boundary.
|
|
27
|
+
* `referenceDate` is the day a bare time is written onto.
|
|
28
|
+
*/
|
|
29
|
+
export const PlTimePicker = /* @__PURE__ */ React.forwardRef(function PlTimePicker({ value: valueProp, defaultValue, onValueChange, open: openProp, defaultOpen, onOpenChange, referenceDate, minTime, maxTime, shouldDisableTime, hour12: hour12Prop, showSeconds = false, hourStep = 1, minuteStep = 1, secondStep = 1, locale, format, placeholder, clearable = false, showNowButton = true, closeOnSelect = false, labels: labelOverrides, name, size = 'md', color = 'primary', density = 'default', readOnly = false, disabled = false, startIcon, ...shell }, ref) {
|
|
30
|
+
const labels = usePickerLabels(labelOverrides);
|
|
31
|
+
const hour12 = hour12Prop ?? isHour12(locale);
|
|
32
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue ?? null);
|
|
33
|
+
const value = valueProp !== undefined ? valueProp : uncontrolledValue;
|
|
34
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen ?? false);
|
|
35
|
+
const open = openProp ?? uncontrolledOpen;
|
|
36
|
+
// Held still for as long as the picker is mounted, so a popup left open
|
|
37
|
+
// across midnight does not quietly move the value it is writing onto a new
|
|
38
|
+
// day.
|
|
39
|
+
const [fallbackDay] = React.useState(() => referenceDate ?? new Date());
|
|
40
|
+
const setOpen = (next) => {
|
|
41
|
+
if (next && (readOnly || disabled)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (openProp === undefined) {
|
|
45
|
+
setUncontrolledOpen(next);
|
|
46
|
+
}
|
|
47
|
+
onOpenChange?.(next);
|
|
48
|
+
};
|
|
49
|
+
const commit = (next) => {
|
|
50
|
+
if (valueProp === undefined) {
|
|
51
|
+
setUncontrolledValue(next);
|
|
52
|
+
}
|
|
53
|
+
onValueChange?.(next);
|
|
54
|
+
};
|
|
55
|
+
const isBlocked = React.useCallback((candidate, unit) => {
|
|
56
|
+
const [from, to] = timeUnitSpan(unit, candidate);
|
|
57
|
+
if (isValidDate(minTime) && to < secondsOfDay(minTime)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (isValidDate(maxTime) && from > secondsOfDay(maxTime)) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return shouldDisableTime?.(candidate, unit) ?? false;
|
|
64
|
+
}, [minTime, maxTime, shouldDisableTime]);
|
|
65
|
+
/* Memoised because `samples` below is keyed on it, and the fallback is a
|
|
66
|
+
fresh object every render — which is the case that runs by default, since
|
|
67
|
+
`format` is optional. Left bare, the sizer re-formatted all twenty-four
|
|
68
|
+
sample instants on every render the picker saw. */
|
|
69
|
+
const displayFormat = React.useMemo(() => format ?? {
|
|
70
|
+
hour: 'numeric',
|
|
71
|
+
minute: '2-digit',
|
|
72
|
+
...(showSeconds ? { second: '2-digit' } : {})
|
|
73
|
+
}, [format, showSeconds]);
|
|
74
|
+
const now = new Date();
|
|
75
|
+
const nowValue = withTime(referenceDate ?? fallbackDay, {
|
|
76
|
+
hours: now.getHours(),
|
|
77
|
+
minutes: now.getMinutes(),
|
|
78
|
+
seconds: showSeconds ? now.getSeconds() : 0
|
|
79
|
+
});
|
|
80
|
+
const hasFooter = showNowButton || clearable || !closeOnSelect;
|
|
81
|
+
// Holds the trigger open at the width of the longest time it could show.
|
|
82
|
+
const samples = React.useMemo(() => withPlaceholder(displaySamples(locale, displayFormat), placeholder), [locale, displayFormat, placeholder]);
|
|
83
|
+
return (_jsx(PickerShell, { ...shell, size: size, color: color, density: density, readOnly: readOnly, disabled: disabled, triggerRef: ref, startIcon: startIcon ?? _jsx(ClockIcon, {}), display: isValidDate(value) ? formatDate(value, locale, displayFormat) : (placeholder ?? ''), samples: samples, empty: !isValidDate(value), clearable: clearable, onClear: () => commit(null), open: open, onOpenChange: setOpen, labels: labels, hiddenValues: name
|
|
84
|
+
? [{ name, value: isValidDate(value) ? toISOTime(value, showSeconds) : '' }]
|
|
85
|
+
: undefined, children: _jsxs("div", { className: cx('flex flex-col', hasFooter && 'gap-1.5'), children: [_jsx(TimeGrid, { size: size, density: density, locale: locale, value: isValidDate(value) ? value : null, referenceDate: referenceDate ?? fallbackDay, onChange: (next) => {
|
|
86
|
+
commit(next);
|
|
87
|
+
if (closeOnSelect) {
|
|
88
|
+
setOpen(false);
|
|
89
|
+
}
|
|
90
|
+
}, hour12: hour12, showSeconds: showSeconds, hourStep: hourStep, minuteStep: minuteStep, secondStep: secondStep, shouldDisableTime: isBlocked, labels: labels, autoFocus: true }), hasFooter ? (_jsxs(PickerFooter, { size: size, children: [clearable ? (_jsx(PlButton, { variant: "ghost", size: size, color: color, density: "compact", onClick: () => {
|
|
91
|
+
commit(null);
|
|
92
|
+
setOpen(false);
|
|
93
|
+
}, children: labels.clear })) : null, showNowButton ? (_jsx(PlButton, { variant: "ghost", size: size, color: color, density: "compact", disabled: isBlocked(nowValue, 'second'), onClick: () => {
|
|
94
|
+
commit(nowValue);
|
|
95
|
+
setOpen(false);
|
|
96
|
+
}, children: labels.now })) : null, !closeOnSelect ? (_jsx(PlButton, { variant: "solid", size: size, color: color, density: "compact", onClick: () => setOpen(false), children: labels.done })) : null] })) : null] }) }));
|
|
97
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlTimePicker } from './PlTimePicker.js';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { PlassColor, PlassDensity, PlassOrientation, PlassSize } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* How far along one item is.
|
|
6
|
+
*
|
|
7
|
+
* Three states rather than two, because "the one you are on" is not the same
|
|
8
|
+
* claim as "done", and a sequence that cannot say which step is current is a
|
|
9
|
+
* list. Each gets its own axis — a filled bullet, a filled bullet with a halo
|
|
10
|
+
* around it, an empty one — rather than three shades of the same thing.
|
|
11
|
+
*/
|
|
12
|
+
export type PlTimelineStatus = 'complete' | 'current' | 'upcoming';
|
|
13
|
+
/** How the line between two items is drawn. `none` leaves the gap open. */
|
|
14
|
+
export type PlTimelineConnector = 'solid' | 'dashed' | 'dotted' | 'none';
|
|
15
|
+
export interface PlTimelineProps extends Omit<React.ComponentPropsWithoutRef<'ol'>, 'color'> {
|
|
16
|
+
/**
|
|
17
|
+
* How far the sequence has got: the index of the item being worked on now.
|
|
18
|
+
* Everything before it is complete, everything after it is still to come.
|
|
19
|
+
*
|
|
20
|
+
* An index rather than a value, because a timeline has no selection — nothing
|
|
21
|
+
* here is chosen, and the only question is how far down the list reality has
|
|
22
|
+
* reached. Omit it and every item is `upcoming` unless it says otherwise; pass
|
|
23
|
+
* the item count to mark the whole sequence done.
|
|
24
|
+
*/
|
|
25
|
+
active?: number;
|
|
26
|
+
/** @default 'md' */
|
|
27
|
+
size?: PlassSize;
|
|
28
|
+
/** @default 'primary' */
|
|
29
|
+
color?: PlassColor;
|
|
30
|
+
/** Spacing between items. Never the type scale, never the bullet. */
|
|
31
|
+
density?: PlassDensity;
|
|
32
|
+
/**
|
|
33
|
+
* Which way the sequence runs. `vertical` is the default and the one that
|
|
34
|
+
* takes an arbitrary number of steps with an arbitrary amount to say about
|
|
35
|
+
* each; `horizontal` is the stepper across the top of a checkout, and it is
|
|
36
|
+
* only honest while every label is short.
|
|
37
|
+
* @default 'vertical'
|
|
38
|
+
*/
|
|
39
|
+
orientation?: PlassOrientation;
|
|
40
|
+
/** Renders something other than an `<ol>` — Base UI's own escape hatch. */
|
|
41
|
+
render?: useRender.RenderProp;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
export interface PlTimelineItemProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color' | 'title'> {
|
|
45
|
+
/** The heading of this step. */
|
|
46
|
+
title?: React.ReactNode;
|
|
47
|
+
/**
|
|
48
|
+
* When it happened — a date, a duration, a name. Set beside the title on a
|
|
49
|
+
* wide item and under it on a narrow one.
|
|
50
|
+
*/
|
|
51
|
+
meta?: React.ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* What goes inside the bullet: a number, an icon, an avatar. Omit it and the
|
|
54
|
+
* bullet is a plain disc, which is what a step with nothing to say about
|
|
55
|
+
* itself should be.
|
|
56
|
+
*/
|
|
57
|
+
bullet?: React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* Overrides what the timeline's `active` would have computed for this item — a
|
|
60
|
+
* step that failed and stopped the sequence, a step that was skipped.
|
|
61
|
+
*/
|
|
62
|
+
status?: PlTimelineStatus;
|
|
63
|
+
/** Overrides the timeline's colour family for this item alone. */
|
|
64
|
+
color?: PlassColor;
|
|
65
|
+
/**
|
|
66
|
+
* How the line to the next item is drawn.
|
|
67
|
+
* @default 'solid'
|
|
68
|
+
*/
|
|
69
|
+
connector?: PlTimelineConnector;
|
|
70
|
+
/** The body of the step. */
|
|
71
|
+
children?: React.ReactNode;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* One step.
|
|
75
|
+
*
|
|
76
|
+
* Its index is not a prop and cannot be: an item that had to be told where it
|
|
77
|
+
* was in the list would be an item every caller could put in the wrong place,
|
|
78
|
+
* and `active={2}` would stop meaning anything. The `PlTimeline` numbers its
|
|
79
|
+
* children as it walks them, and hands each one its index through a context.
|
|
80
|
+
*/
|
|
81
|
+
export declare const PlTimelineItem: React.ForwardRefExoticComponent<PlTimelineItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
82
|
+
/**
|
|
83
|
+
* A sequence of steps, in the order they happen in.
|
|
84
|
+
*
|
|
85
|
+
* There is no Base UI primitive under this and there should not be: a timeline
|
|
86
|
+
* has no selection, no roving focus and no keyboard contract — it is a list, and
|
|
87
|
+
* reaching for a composite primitive to draw one would hand every consumer's
|
|
88
|
+
* record of events the semantics of a widget.
|
|
89
|
+
*
|
|
90
|
+
* It is an `<ol>` for the reason it exists at all: the order *is* the content. A
|
|
91
|
+
* screen reader announcing "list of 5 items" over an unordered list would be
|
|
92
|
+
* describing something else.
|
|
93
|
+
*
|
|
94
|
+
* The children are numbered here rather than by a prop on each item, so `active`
|
|
95
|
+
* has something to count against and inserting a step in the middle does not
|
|
96
|
+
* mean renumbering the ones after it.
|
|
97
|
+
*/
|
|
98
|
+
export declare const PlTimeline: React.ForwardRefExoticComponent<PlTimelineProps & React.RefAttributes<HTMLOListElement>>;
|