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,139 @@
|
|
|
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 { Popover } from '@base-ui/react/popover';
|
|
5
|
+
import { CloseIcon } from './icons.js';
|
|
6
|
+
import { WidthSizer } from './sizer.js';
|
|
7
|
+
import { chipRemoveClasses, controlHeightClasses, controlTextLeadingClasses, cx, disabledClasses, fieldReadOnlyClasses, fieldRestClasses, focusWithinRingClasses, gapClasses, glassClasses, iconClasses, metaTextClasses, paddingXClasses, radiusClasses, stackGapClasses, surfaceSlots, transitionClasses } from './styles.js';
|
|
8
|
+
/**
|
|
9
|
+
* The shell all four pickers wear: a field-shaped trigger with a popup hanging
|
|
10
|
+
* off it.
|
|
11
|
+
*
|
|
12
|
+
* It is here rather than in one of the components for the reason the calendar
|
|
13
|
+
* is: four components need it, and none of them should have to import another.
|
|
14
|
+
* What it draws is deliberately not new — the trigger is `fieldRestClasses`,
|
|
15
|
+
* the same box a `PlTextField` and a `PlSelect`'s trigger are drawn on, to the
|
|
16
|
+
* pixel. A form where the date field is a different height, radius or material
|
|
17
|
+
* from the text field beside it is a form that looks assembled rather than
|
|
18
|
+
* designed.
|
|
19
|
+
*
|
|
20
|
+
* The one thing the pickers do *not* offer is typing a date into the trigger.
|
|
21
|
+
* Parsing a date out of free text is locale-dependent in a way that cannot be
|
|
22
|
+
* done honestly without a date library, and a field that understands `27/7/26`
|
|
23
|
+
* in one browser and not the next is worse than one that never claimed to. So
|
|
24
|
+
* the trigger is a button, exactly as a select's is, and the calendar is where
|
|
25
|
+
* the answer comes from.
|
|
26
|
+
*/
|
|
27
|
+
/* ---------------------------------------------------------------------------
|
|
28
|
+
* Colour
|
|
29
|
+
* ------------------------------------------------------------------------- */
|
|
30
|
+
/**
|
|
31
|
+
* The popup's slots: a container's undyed sheet with the *control* fill added
|
|
32
|
+
* back on top.
|
|
33
|
+
*
|
|
34
|
+
* Neither generator in `internal/styles` says this on its own, and the reason is
|
|
35
|
+
* that a picker's popup is both things at once. It is a container — it holds a
|
|
36
|
+
* grid of forty-two days, and dyeing the sheet under them would put every one of
|
|
37
|
+
* them on a background it was not chosen against — and it also holds the one
|
|
38
|
+
* filled token in the library that has to be found without being read, which is
|
|
39
|
+
* the day you picked. So the sheet stays clear glass and the family arrives in
|
|
40
|
+
* the two fill slots the chosen cell reads.
|
|
41
|
+
*/
|
|
42
|
+
export function popupSlots(color, elevation) {
|
|
43
|
+
return {
|
|
44
|
+
...surfaceSlots(color, elevation),
|
|
45
|
+
'--p-fill': `var(--plass-${color}-fill)`,
|
|
46
|
+
'--p-on-solid': `var(--plass-${color}-on-solid)`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/* ---------------------------------------------------------------------------
|
|
50
|
+
* Surfaces
|
|
51
|
+
* ------------------------------------------------------------------------- */
|
|
52
|
+
/** The trigger's box. A `PlTextField`'s shell, unchanged. */
|
|
53
|
+
const triggerShellClasses = /* @__PURE__ */ [
|
|
54
|
+
'group relative flex w-full items-center select-none',
|
|
55
|
+
'[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
|
|
56
|
+
transitionClasses,
|
|
57
|
+
focusWithinRingClasses,
|
|
58
|
+
iconClasses
|
|
59
|
+
].join(' ');
|
|
60
|
+
/**
|
|
61
|
+
* The popup. Like every floating surface in the library it carries a shadow by
|
|
62
|
+
* default, at level 3 — as far as the ladder goes without hovering — because it
|
|
63
|
+
* is genuinely off the page rather than merely on top of it.
|
|
64
|
+
*/
|
|
65
|
+
export const pickerPopupClasses = /* @__PURE__ */ [
|
|
66
|
+
glassClasses,
|
|
67
|
+
'border text-(--plass-fg) bg-(--plass-glass-press)',
|
|
68
|
+
'[border-color:var(--plass-glass-line)]',
|
|
69
|
+
'[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]',
|
|
70
|
+
'[outline:none]',
|
|
71
|
+
// Opacity only. A calendar that slid into place would move the cell the
|
|
72
|
+
// pointer was already reaching for.
|
|
73
|
+
'[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
|
|
74
|
+
'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
|
|
75
|
+
].join(' ');
|
|
76
|
+
/** The popup's own padding, one track tighter than a control's. */
|
|
77
|
+
export const popupPaddingClasses = {
|
|
78
|
+
xs: 'p-1.5',
|
|
79
|
+
sm: 'p-2',
|
|
80
|
+
md: 'p-2.5',
|
|
81
|
+
lg: 'p-3',
|
|
82
|
+
xl: 'p-3.5'
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* A trigger, a label, the two lines of text under it, and a popup.
|
|
86
|
+
*
|
|
87
|
+
* Everything about it that is visible is a decision already made elsewhere: the
|
|
88
|
+
* shell classes, the read-only and disabled treatments, the label's type scale
|
|
89
|
+
* and the way `invalid` re-points the whole colour family at `danger` so the
|
|
90
|
+
* edge, the ring and the message turn over together.
|
|
91
|
+
*/
|
|
92
|
+
export function PickerShell({ variant = 'glass', size = 'md', color = 'primary', density = 'default', elevation = 0, label, description, error, invalid, startIcon, fullWidth = false, disabled = false, readOnly = false, required = false, id, className, style, display, samples, empty, clearable = false, onClear, open, onOpenChange, labels, hiddenValues, children, triggerRef, ...props }) {
|
|
93
|
+
const generatedId = React.useId();
|
|
94
|
+
const triggerId = id ?? `${generatedId}-trigger`;
|
|
95
|
+
const labelId = `${generatedId}-label`;
|
|
96
|
+
const descriptionId = `${generatedId}-description`;
|
|
97
|
+
const errorId = `${generatedId}-error`;
|
|
98
|
+
const hasError = error !== undefined && error !== null && error !== false && error !== '';
|
|
99
|
+
const isInvalid = invalid ?? hasError;
|
|
100
|
+
const family = isInvalid ? 'danger' : color;
|
|
101
|
+
const inert = disabled || readOnly;
|
|
102
|
+
const describedBy = [description ? descriptionId : null, hasError ? errorId : null].filter(Boolean).join(' ') ||
|
|
103
|
+
undefined;
|
|
104
|
+
return (_jsxs(Field.Root, { disabled: disabled, invalid: isInvalid, className: cx('flex-col align-top', stackGapClasses[size], fullWidth ? 'flex w-full' : 'inline-flex', className), style: { ...surfaceSlots(family, elevation), ...style }, ...props, children: [label ? (_jsx(Field.Label, { id: labelId, htmlFor: triggerId, className: cx(metaTextClasses[size], 'font-semibold', disabled ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'), children: label })) : null, _jsxs(Popover.Root, { open: open, onOpenChange: (next) => onOpenChange(next), children: [_jsxs("span", { className: cx(triggerShellClasses, controlHeightClasses[size], controlTextLeadingClasses[size], radiusClasses[size], gapClasses[size], paddingXClasses[density][size],
|
|
105
|
+
// An if/else rather than stacked variants: two Tailwind classes of
|
|
106
|
+
// equal specificity resolve by their order in the generated sheet.
|
|
107
|
+
disabled
|
|
108
|
+
? disabledClasses[variant]
|
|
109
|
+
: readOnly
|
|
110
|
+
? fieldReadOnlyClasses[variant]
|
|
111
|
+
: fieldRestClasses[variant]), children: [_jsxs(Popover.Trigger, { id: triggerId, ref: triggerRef, disabled: disabled, "aria-labelledby": label ? labelId : undefined, "aria-describedby": describedBy, "aria-required": required || undefined, "aria-invalid": isInvalid || undefined, className: cx('flex min-w-0 flex-1 items-center bg-transparent text-start [font:inherit] text-inherit', gapClasses[size], '[outline:none]', inert ? 'cursor-default' : 'cursor-pointer'), children: [startIcon ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center text-(--plass-muted-fg)", children: startIcon })) : null, _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: cx('w-full truncate', empty ? 'text-(--plass-muted-fg)' : 'text-(--plass-fg)'), children: display }), _jsx(WidthSizer, { samples: samples ?? [] })] })] }), clearable && !empty && !inert ? (_jsx("button", { type: "button", "aria-label": labels.clear, className: cx(chipRemoveClasses, 'text-(--plass-muted-fg)'), onClick: (event) => {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
onClear();
|
|
114
|
+
}, children: _jsx(CloseIcon, {}) })) : null] }), _jsx(Popover.Portal, { children: _jsx(Popover.Positioner, { className: "plass-portal z-50 [outline:none]", sideOffset: 6, align: "start", children: _jsx(Popover.Popup
|
|
115
|
+
// Base UI is told to leave the focus alone so the calendar can take
|
|
116
|
+
// it into the grid itself. Its own move would land on the popup
|
|
117
|
+
// element and run *after* the grid's, undoing it.
|
|
118
|
+
, {
|
|
119
|
+
// Base UI is told to leave the focus alone so the calendar can take
|
|
120
|
+
// it into the grid itself. Its own move would land on the popup
|
|
121
|
+
// element and run *after* the grid's, undoing it.
|
|
122
|
+
initialFocus: false, className: cx(pickerPopupClasses, radiusClasses[size], popupPaddingClasses[size], controlTextLeadingClasses[size]), style: popupSlots(family, 3), children: children }) }) })] }), description ? (_jsx(Field.Description, { id: descriptionId, className: cx(metaTextClasses[size], 'text-(--plass-muted-fg)'), children: description })) : null, hasError ? (_jsx(Field.Error, { id: errorId, match: true, className: cx(metaTextClasses[size], 'text-(--p-accent)'), children: error })) : null, hiddenValues?.map((entry, index) => (_jsx("input", { type: "hidden", name: entry.name, value: entry.value }, index)))] }));
|
|
123
|
+
}
|
|
124
|
+
/* ---------------------------------------------------------------------------
|
|
125
|
+
* The footer
|
|
126
|
+
* ------------------------------------------------------------------------- */
|
|
127
|
+
/**
|
|
128
|
+
* The row of shortcuts under a picker's panel.
|
|
129
|
+
*
|
|
130
|
+
* A hairline above it rather than a gap, because the actions act on the panel
|
|
131
|
+
* and a gap would read as a second popup stacked under the first.
|
|
132
|
+
*/
|
|
133
|
+
export function PickerFooter({ size, children }) {
|
|
134
|
+
return (_jsx("div", { className: cx('flex items-center justify-end border-t pt-1.5', '[border-color:var(--plass-divider)]', gapClasses[size]), children: children }));
|
|
135
|
+
}
|
|
136
|
+
/** The vertical hairline between a calendar and the clock beside it. */
|
|
137
|
+
export function PickerDivider() {
|
|
138
|
+
return _jsx("div", { "aria-hidden": "true", className: "w-px self-stretch bg-(--plass-divider)" });
|
|
139
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the three progress indicators share.
|
|
3
|
+
*
|
|
4
|
+
* `PlProgressLinear`, `PlProgressCircular` and `PlProgressBox` are three shapes
|
|
5
|
+
* answering one question — how far along is this, and is it moving at all — so
|
|
6
|
+
* everything that is *not* the shape belongs here: the colour slots, the size
|
|
7
|
+
* ladders, and the arithmetic that turns `value`/`min`/`max` into a fraction.
|
|
8
|
+
*
|
|
9
|
+
* What is left in each component is the shape, which is the point: it is the
|
|
10
|
+
* only thing that genuinely differs.
|
|
11
|
+
*/
|
|
12
|
+
import type * as React from 'react';
|
|
13
|
+
import type { PlassColor, PlassSize } from '../types.js';
|
|
14
|
+
/**
|
|
15
|
+
* The props all three take.
|
|
16
|
+
*
|
|
17
|
+
* Declared once and extended rather than written three times, because the whole
|
|
18
|
+
* claim being made is that these are one component in three shapes: a `value`
|
|
19
|
+
* of `null` has to mean the same thing on a bar, a ring and a row of plates, or
|
|
20
|
+
* the trio is three components that happen to share a prefix.
|
|
21
|
+
*/
|
|
22
|
+
export interface PlassProgressProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children'> {
|
|
23
|
+
/**
|
|
24
|
+
* How far along, between `min` and `max`.
|
|
25
|
+
*
|
|
26
|
+
* `null` — the default — is the indeterminate case: something is happening
|
|
27
|
+
* and nobody knows how much of it is left. That is the default on purpose. An
|
|
28
|
+
* indicator that has not been told a value should say so rather than draw an
|
|
29
|
+
* empty bar, which is a claim that no progress has been made.
|
|
30
|
+
* @default null
|
|
31
|
+
*/
|
|
32
|
+
value?: number | null;
|
|
33
|
+
/** @default 0 */
|
|
34
|
+
min?: number;
|
|
35
|
+
/** @default 100 */
|
|
36
|
+
max?: number;
|
|
37
|
+
/** A name for what is loading. Read out with the value by a screen reader. */
|
|
38
|
+
label?: React.ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Shows the value as text beside the shape. A percentage of the range unless
|
|
41
|
+
* `format` says otherwise.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
showValue?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* How to format the value when it is shown — `Intl.NumberFormat` options, so
|
|
47
|
+
* bytes and currencies work as well as plain numbers. Without it the value is
|
|
48
|
+
* a percentage of `min`…`max`, which is the only formatting that holds for a
|
|
49
|
+
* range nobody described.
|
|
50
|
+
*/
|
|
51
|
+
format?: Intl.NumberFormatOptions;
|
|
52
|
+
/** @default 'md' */
|
|
53
|
+
size?: PlassSize;
|
|
54
|
+
/** @default 'primary' */
|
|
55
|
+
color?: PlassColor;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The slots an indicator reads.
|
|
59
|
+
*
|
|
60
|
+
* An indicator **is** the coloured thing — unlike a PlBox, which holds other
|
|
61
|
+
* people's content — so it gets `--p-fill`, the family's own gradient, and the
|
|
62
|
+
* filled part of a bar is made of exactly the same material as the button that
|
|
63
|
+
* submits the form it is in.
|
|
64
|
+
*
|
|
65
|
+
* There is no elevation ladder and no `--p-lift` here, on purpose. An indicator
|
|
66
|
+
* is cut *into* the surface it sits on, the way a groove is, and a groove does
|
|
67
|
+
* not float.
|
|
68
|
+
*/
|
|
69
|
+
export declare function progressSlots(color: PlassColor): React.CSSProperties;
|
|
70
|
+
/**
|
|
71
|
+
* How thick the linear groove is.
|
|
72
|
+
*
|
|
73
|
+
* Its own ladder rather than a fraction of `controlHeightClasses`: a bar is not
|
|
74
|
+
* a control you can put a label inside, and at `md` it wants to be the weight
|
|
75
|
+
* of a rule between two paragraphs rather than a quarter of a button.
|
|
76
|
+
*
|
|
77
|
+
* They are `PlSlider`'s rail thicknesses, and deliberately: a rail and a bar are
|
|
78
|
+
* the same channel, one of which you drag and one of which you watch.
|
|
79
|
+
*/
|
|
80
|
+
export declare const barThicknessClasses: Record<PlassSize, string>;
|
|
81
|
+
/**
|
|
82
|
+
* The diameter of the ring, in pixels.
|
|
83
|
+
*
|
|
84
|
+
* Numbers rather than classes because the same value has to reach the SVG's
|
|
85
|
+
* `viewBox` arithmetic, and a ring is one of the few things in the library that
|
|
86
|
+
* cannot be described by a Tailwind class alone.
|
|
87
|
+
*
|
|
88
|
+
* They sit just under the control ladder at every step — a `md` ring is 20px
|
|
89
|
+
* inside a 40px control — so a ring dropped into a button, a field or a table
|
|
90
|
+
* row never makes the row taller than it already was.
|
|
91
|
+
*/
|
|
92
|
+
export declare const ringDiameters: Record<PlassSize, number>;
|
|
93
|
+
/** The ring's stroke, thickening with the ring so the hole stays in proportion. */
|
|
94
|
+
export declare const ringStrokes: Record<PlassSize, number>;
|
|
95
|
+
/**
|
|
96
|
+
* One plate of a `PlProgressBox`, on the tick ladder — an indicator beside a
|
|
97
|
+
* label, not a control you can put one inside.
|
|
98
|
+
*/
|
|
99
|
+
export declare const plateSizeClasses: Record<PlassSize, string>;
|
|
100
|
+
/** The corner cut off a plate: the same ~30% the tick boxes take. */
|
|
101
|
+
export declare const plateRadiusClasses: Record<PlassSize, string>;
|
|
102
|
+
/** Between the plates. Tight — they are one object, not a row of squares. */
|
|
103
|
+
export declare const plateGapClasses: Record<PlassSize, string>;
|
|
104
|
+
/**
|
|
105
|
+
* The groove an indicator is cut into, and the transition that fills it.
|
|
106
|
+
*
|
|
107
|
+
* `--plass-track` is the one neutral ink the library grooves with — a
|
|
108
|
+
* PlSlider's rail and a PlSwitch's off track are the same colour — so a form
|
|
109
|
+
* with a slider, a switch and a progress bar in it is made of one material
|
|
110
|
+
* rather than three.
|
|
111
|
+
*
|
|
112
|
+
* The fill is `--p-fill`, and it is a `background-image` rather than a colour
|
|
113
|
+
* because that is what a Plass fill *is*: a gradient that turns in hue. Which is
|
|
114
|
+
* also why the movement is on `width` and never on the paint: a gradient cannot
|
|
115
|
+
* be transitioned, and a length can.
|
|
116
|
+
*/
|
|
117
|
+
export declare const trackClasses = "bg-(--plass-track)";
|
|
118
|
+
/** The bar's own duration, one step slower than a control's, so a fill reads as travel. */
|
|
119
|
+
export declare const fillTransitionClasses = "[transition:width_var(--plass-duration-slow)_var(--plass-ease)]";
|
|
120
|
+
/**
|
|
121
|
+
* `value` as a fraction of the range, or `null` when there is nothing to say.
|
|
122
|
+
*
|
|
123
|
+
* The clamp is not defensive programming for its own sake — `value` usually
|
|
124
|
+
* arrives from a division somewhere, and a bar that renders 140% wide because
|
|
125
|
+
* one request finished twice is a worse bug than a bar that sits full.
|
|
126
|
+
*/
|
|
127
|
+
export declare function progressFraction(value: number | null | undefined, min: number, max: number): number | null;
|
|
128
|
+
/**
|
|
129
|
+
* What the value reads as, both on screen and to a screen reader.
|
|
130
|
+
*
|
|
131
|
+
* Base UI's own default is `${value}%`, which is right only when the range
|
|
132
|
+
* happens to be 0–100 — "3%" for step 3 of 4 is worse than saying nothing. So
|
|
133
|
+
* the percentage is computed from the fraction, and a caller who passed
|
|
134
|
+
* `format` gets Base UI's formatted string instead, because at that point they
|
|
135
|
+
* have said what the number means.
|
|
136
|
+
*/
|
|
137
|
+
export declare function progressText(fraction: number | null, formatted: string | null, hasFormat: boolean): string | null;
|
|
138
|
+
/**
|
|
139
|
+
* The same string, shaped for Base UI's `getAriaValueText`.
|
|
140
|
+
*
|
|
141
|
+
* `undefined` when there is no value, which hands the indeterminate case back
|
|
142
|
+
* to Base UI — it already announces indeterminate progress, and re-inventing
|
|
143
|
+
* that here would be one more English string the library has to own.
|
|
144
|
+
*/
|
|
145
|
+
export declare function progressAriaText(fraction: number | null, hasFormat: boolean): ((formatted: string | null) => string) | undefined;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the three progress indicators share.
|
|
3
|
+
*
|
|
4
|
+
* `PlProgressLinear`, `PlProgressCircular` and `PlProgressBox` are three shapes
|
|
5
|
+
* answering one question — how far along is this, and is it moving at all — so
|
|
6
|
+
* everything that is *not* the shape belongs here: the colour slots, the size
|
|
7
|
+
* ladders, and the arithmetic that turns `value`/`min`/`max` into a fraction.
|
|
8
|
+
*
|
|
9
|
+
* What is left in each component is the shape, which is the point: it is the
|
|
10
|
+
* only thing that genuinely differs.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The slots an indicator reads.
|
|
14
|
+
*
|
|
15
|
+
* An indicator **is** the coloured thing — unlike a PlBox, which holds other
|
|
16
|
+
* people's content — so it gets `--p-fill`, the family's own gradient, and the
|
|
17
|
+
* filled part of a bar is made of exactly the same material as the button that
|
|
18
|
+
* submits the form it is in.
|
|
19
|
+
*
|
|
20
|
+
* There is no elevation ladder and no `--p-lift` here, on purpose. An indicator
|
|
21
|
+
* is cut *into* the surface it sits on, the way a groove is, and a groove does
|
|
22
|
+
* not float.
|
|
23
|
+
*/
|
|
24
|
+
export function progressSlots(color) {
|
|
25
|
+
return {
|
|
26
|
+
'--p-fill': `var(--plass-${color}-fill)`,
|
|
27
|
+
// The two ends of that gradient on their own, which only the ring needs: an
|
|
28
|
+
// SVG stroke cannot take a CSS gradient, so an arc has to build a
|
|
29
|
+
// `<linearGradient>` out of the same two stops the bar's fill is made of.
|
|
30
|
+
// Without them a ring would be a flat arc beside a swept bar.
|
|
31
|
+
'--p-solid': `var(--plass-${color}-solid)`,
|
|
32
|
+
'--p-solid-to': `var(--plass-${color}-solid-to)`,
|
|
33
|
+
'--p-accent': `var(--plass-${color}-accent)`,
|
|
34
|
+
'--p-soft': `var(--plass-${color}-soft)`,
|
|
35
|
+
'--p-soft-press': `var(--plass-${color}-soft-press)`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* How thick the linear groove is.
|
|
40
|
+
*
|
|
41
|
+
* Its own ladder rather than a fraction of `controlHeightClasses`: a bar is not
|
|
42
|
+
* a control you can put a label inside, and at `md` it wants to be the weight
|
|
43
|
+
* of a rule between two paragraphs rather than a quarter of a button.
|
|
44
|
+
*
|
|
45
|
+
* They are `PlSlider`'s rail thicknesses, and deliberately: a rail and a bar are
|
|
46
|
+
* the same channel, one of which you drag and one of which you watch.
|
|
47
|
+
*/
|
|
48
|
+
export const barThicknessClasses = {
|
|
49
|
+
xs: 'h-1',
|
|
50
|
+
sm: 'h-1.5',
|
|
51
|
+
md: 'h-1.5',
|
|
52
|
+
lg: 'h-2',
|
|
53
|
+
xl: 'h-2.5'
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The diameter of the ring, in pixels.
|
|
57
|
+
*
|
|
58
|
+
* Numbers rather than classes because the same value has to reach the SVG's
|
|
59
|
+
* `viewBox` arithmetic, and a ring is one of the few things in the library that
|
|
60
|
+
* cannot be described by a Tailwind class alone.
|
|
61
|
+
*
|
|
62
|
+
* They sit just under the control ladder at every step — a `md` ring is 20px
|
|
63
|
+
* inside a 40px control — so a ring dropped into a button, a field or a table
|
|
64
|
+
* row never makes the row taller than it already was.
|
|
65
|
+
*/
|
|
66
|
+
export const ringDiameters = {
|
|
67
|
+
xs: 14,
|
|
68
|
+
sm: 16,
|
|
69
|
+
md: 20,
|
|
70
|
+
lg: 26,
|
|
71
|
+
xl: 32
|
|
72
|
+
};
|
|
73
|
+
/** The ring's stroke, thickening with the ring so the hole stays in proportion. */
|
|
74
|
+
export const ringStrokes = {
|
|
75
|
+
xs: 1.5,
|
|
76
|
+
sm: 1.75,
|
|
77
|
+
md: 2,
|
|
78
|
+
lg: 2.5,
|
|
79
|
+
xl: 3
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* One plate of a `PlProgressBox`, on the tick ladder — an indicator beside a
|
|
83
|
+
* label, not a control you can put one inside.
|
|
84
|
+
*/
|
|
85
|
+
export const plateSizeClasses = {
|
|
86
|
+
xs: 'size-2',
|
|
87
|
+
sm: 'size-2.5',
|
|
88
|
+
md: 'size-3',
|
|
89
|
+
lg: 'size-4',
|
|
90
|
+
xl: 'size-5'
|
|
91
|
+
};
|
|
92
|
+
/** The corner cut off a plate: the same ~30% the tick boxes take. */
|
|
93
|
+
export const plateRadiusClasses = {
|
|
94
|
+
xs: 'rounded-[0.1875rem]',
|
|
95
|
+
sm: 'rounded-[0.25rem]',
|
|
96
|
+
md: 'rounded-[0.28125rem]',
|
|
97
|
+
lg: 'rounded-[0.375rem]',
|
|
98
|
+
xl: 'rounded-[0.4375rem]'
|
|
99
|
+
};
|
|
100
|
+
/** Between the plates. Tight — they are one object, not a row of squares. */
|
|
101
|
+
export const plateGapClasses = {
|
|
102
|
+
xs: 'gap-1',
|
|
103
|
+
sm: 'gap-1',
|
|
104
|
+
md: 'gap-1.5',
|
|
105
|
+
lg: 'gap-1.5',
|
|
106
|
+
xl: 'gap-2'
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* The groove an indicator is cut into, and the transition that fills it.
|
|
110
|
+
*
|
|
111
|
+
* `--plass-track` is the one neutral ink the library grooves with — a
|
|
112
|
+
* PlSlider's rail and a PlSwitch's off track are the same colour — so a form
|
|
113
|
+
* with a slider, a switch and a progress bar in it is made of one material
|
|
114
|
+
* rather than three.
|
|
115
|
+
*
|
|
116
|
+
* The fill is `--p-fill`, and it is a `background-image` rather than a colour
|
|
117
|
+
* because that is what a Plass fill *is*: a gradient that turns in hue. Which is
|
|
118
|
+
* also why the movement is on `width` and never on the paint: a gradient cannot
|
|
119
|
+
* be transitioned, and a length can.
|
|
120
|
+
*/
|
|
121
|
+
export const trackClasses = 'bg-(--plass-track)';
|
|
122
|
+
/** The bar's own duration, one step slower than a control's, so a fill reads as travel. */
|
|
123
|
+
export const fillTransitionClasses = '[transition:width_var(--plass-duration-slow)_var(--plass-ease)]';
|
|
124
|
+
/**
|
|
125
|
+
* `value` as a fraction of the range, or `null` when there is nothing to say.
|
|
126
|
+
*
|
|
127
|
+
* The clamp is not defensive programming for its own sake — `value` usually
|
|
128
|
+
* arrives from a division somewhere, and a bar that renders 140% wide because
|
|
129
|
+
* one request finished twice is a worse bug than a bar that sits full.
|
|
130
|
+
*/
|
|
131
|
+
export function progressFraction(value, min, max) {
|
|
132
|
+
if (value === null || value === undefined || Number.isNaN(value)) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
if (max <= min) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
return Math.min(1, Math.max(0, (value - min) / (max - min)));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* What the value reads as, both on screen and to a screen reader.
|
|
142
|
+
*
|
|
143
|
+
* Base UI's own default is `${value}%`, which is right only when the range
|
|
144
|
+
* happens to be 0–100 — "3%" for step 3 of 4 is worse than saying nothing. So
|
|
145
|
+
* the percentage is computed from the fraction, and a caller who passed
|
|
146
|
+
* `format` gets Base UI's formatted string instead, because at that point they
|
|
147
|
+
* have said what the number means.
|
|
148
|
+
*/
|
|
149
|
+
export function progressText(fraction, formatted, hasFormat) {
|
|
150
|
+
if (fraction === null) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return hasFormat ? formatted : `${Math.round(fraction * 100)}%`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The same string, shaped for Base UI's `getAriaValueText`.
|
|
157
|
+
*
|
|
158
|
+
* `undefined` when there is no value, which hands the indeterminate case back
|
|
159
|
+
* to Base UI — it already announces indeterminate progress, and re-inventing
|
|
160
|
+
* that here would be one more English string the library has to own.
|
|
161
|
+
*/
|
|
162
|
+
export function progressAriaText(fraction, hasFormat) {
|
|
163
|
+
if (fraction === null) {
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
return (formatted) => progressText(fraction, formatted, hasFormat) ?? '';
|
|
167
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Holds a control open at the width of the widest thing it could ever say.
|
|
4
|
+
*
|
|
5
|
+
* A control that is not `fullWidth` is sized by what it is *currently* saying,
|
|
6
|
+
* which for anything whose value changes means the box changes with it. A
|
|
7
|
+
* PlSelect showing `Seoul` is narrower than the same one showing
|
|
8
|
+
* `Washington DC`. Either way the field moves under the pointer that just used
|
|
9
|
+
* it, and the whole row of controls beside it shuffles along.
|
|
10
|
+
*
|
|
11
|
+
* So the alternatives are laid out too, stacked in a box clipped to no height.
|
|
12
|
+
* The control's intrinsic width becomes the widest of them and stops depending
|
|
13
|
+
* on the value.
|
|
14
|
+
*
|
|
15
|
+
* Three things it deliberately is not:
|
|
16
|
+
*
|
|
17
|
+
* - **Not `hidden`, and not `display: none`.** Both take the box out of layout,
|
|
18
|
+
* and a box that is not laid out reserves nothing.
|
|
19
|
+
* - **Not read out.** `aria-hidden`, or a screen reader would announce every
|
|
20
|
+
* value the control might hold before the one it does.
|
|
21
|
+
* - **Not text.** A string sample is drawn as generated content off a data
|
|
22
|
+
* attribute rather than as a text node. `content: attr(…)` lays out exactly
|
|
23
|
+
* like text, so it reserves the same width — but it leaves nothing for
|
|
24
|
+
* `getByText` or a screen reader's find-in-page to trip over, and a caller's
|
|
25
|
+
* test asking for the option they selected keeps finding one element rather
|
|
26
|
+
* than two. Only a sample that is not a string — an option whose label is a
|
|
27
|
+
* node — has to be rendered for real, because there is nothing to put in an
|
|
28
|
+
* attribute.
|
|
29
|
+
*/
|
|
30
|
+
export declare function WidthSizer({ samples }: {
|
|
31
|
+
samples: readonly React.ReactNode[];
|
|
32
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Holds a control open at the width of the widest thing it could ever say.
|
|
4
|
+
*
|
|
5
|
+
* A control that is not `fullWidth` is sized by what it is *currently* saying,
|
|
6
|
+
* which for anything whose value changes means the box changes with it. A
|
|
7
|
+
* PlSelect showing `Seoul` is narrower than the same one showing
|
|
8
|
+
* `Washington DC`. Either way the field moves under the pointer that just used
|
|
9
|
+
* it, and the whole row of controls beside it shuffles along.
|
|
10
|
+
*
|
|
11
|
+
* So the alternatives are laid out too, stacked in a box clipped to no height.
|
|
12
|
+
* The control's intrinsic width becomes the widest of them and stops depending
|
|
13
|
+
* on the value.
|
|
14
|
+
*
|
|
15
|
+
* Three things it deliberately is not:
|
|
16
|
+
*
|
|
17
|
+
* - **Not `hidden`, and not `display: none`.** Both take the box out of layout,
|
|
18
|
+
* and a box that is not laid out reserves nothing.
|
|
19
|
+
* - **Not read out.** `aria-hidden`, or a screen reader would announce every
|
|
20
|
+
* value the control might hold before the one it does.
|
|
21
|
+
* - **Not text.** A string sample is drawn as generated content off a data
|
|
22
|
+
* attribute rather than as a text node. `content: attr(…)` lays out exactly
|
|
23
|
+
* like text, so it reserves the same width — but it leaves nothing for
|
|
24
|
+
* `getByText` or a screen reader's find-in-page to trip over, and a caller's
|
|
25
|
+
* test asking for the option they selected keeps finding one element rather
|
|
26
|
+
* than two. Only a sample that is not a string — an option whose label is a
|
|
27
|
+
* node — has to be rendered for real, because there is nothing to put in an
|
|
28
|
+
* attribute.
|
|
29
|
+
*/
|
|
30
|
+
export function WidthSizer({ samples }) {
|
|
31
|
+
if (samples.length === 0) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (_jsx("span", { "aria-hidden": "true", className: "invisible h-0 min-h-0 overflow-hidden", children: samples.map((sample, index) => typeof sample === 'string' ? (_jsx("span", { "data-sample": sample, className: "block whitespace-nowrap before:content-[attr(data-sample)]" }, `${index}:${sample}`)) : (_jsx("span", { className: "block whitespace-nowrap", children: sample }, index))) }));
|
|
35
|
+
}
|