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,138 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassColor, PlassDensity, PlassSize } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* What is drawn between two steps of the trail.
|
|
5
|
+
*
|
|
6
|
+
* Four named marks rather than a free-for-all, because a separator is read
|
|
7
|
+
* hundreds of times a day and the difference between them is meaning, not
|
|
8
|
+
* decoration: a `chevron` and an `arrow` say "and then", a `slash` says "path",
|
|
9
|
+
* a `dot` says "these are peers of one thing". Anything else can still be passed
|
|
10
|
+
* as a node.
|
|
11
|
+
*/
|
|
12
|
+
export type PlBreadcrumbSeparator = 'chevron' | 'arrow' | 'slash' | 'dot';
|
|
13
|
+
export interface PlBreadcrumbProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'color'> {
|
|
14
|
+
/** @default 'md' */
|
|
15
|
+
size?: PlassSize;
|
|
16
|
+
/**
|
|
17
|
+
* The colour family a link picks up when it is hovered.
|
|
18
|
+
* @default 'primary'
|
|
19
|
+
*/
|
|
20
|
+
color?: PlassColor;
|
|
21
|
+
/**
|
|
22
|
+
* How tightly the steps pack. Spacing only.
|
|
23
|
+
* @default 'default'
|
|
24
|
+
*/
|
|
25
|
+
density?: PlassDensity;
|
|
26
|
+
/**
|
|
27
|
+
* The mark between two steps. One of the four names, or any node.
|
|
28
|
+
* @default 'chevron'
|
|
29
|
+
*/
|
|
30
|
+
separator?: PlBreadcrumbSeparator | React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* How many steps to show before the middle is folded away behind a `…`. Left
|
|
33
|
+
* out, the whole trail is shown however long it gets.
|
|
34
|
+
*/
|
|
35
|
+
maxItems?: number;
|
|
36
|
+
/**
|
|
37
|
+
* How many steps stay at the front of a folded trail.
|
|
38
|
+
* @default 1
|
|
39
|
+
*/
|
|
40
|
+
itemsBeforeCollapse?: number;
|
|
41
|
+
/**
|
|
42
|
+
* How many stay at the end.
|
|
43
|
+
* @default 1
|
|
44
|
+
*/
|
|
45
|
+
itemsAfterCollapse?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Whether pressing the `…` unfolds the trail in place. Turn it off to leave
|
|
48
|
+
* the fold as a plain mark.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
expandable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The name the trail is announced by. Never drawn.
|
|
54
|
+
* @default 'Breadcrumb'
|
|
55
|
+
*/
|
|
56
|
+
label?: string;
|
|
57
|
+
/**
|
|
58
|
+
* What the `…` is announced as. Never drawn.
|
|
59
|
+
* @default 'Show the hidden steps'
|
|
60
|
+
*/
|
|
61
|
+
expandLabel?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Emits the trail a second time as a `BreadcrumbList`, in a
|
|
64
|
+
* `<script type="application/ld+json">` beside the markup.
|
|
65
|
+
*
|
|
66
|
+
* Off by default, because a page can only have one of these and a great many
|
|
67
|
+
* apps already emit theirs from an SEO layer of their own — two would be a
|
|
68
|
+
* page describing itself twice. Turn it on where this component *is* the
|
|
69
|
+
* trail: correct markup alone is not what puts a path under a search result,
|
|
70
|
+
* and the structured data is.
|
|
71
|
+
*
|
|
72
|
+
* Every step goes in, including the ones a `maxItems` fold is hiding — what is
|
|
73
|
+
* collapsed is a matter of how much room the row has, and the path is the path
|
|
74
|
+
* either way.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
structuredData?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* What relative `href`s are resolved against for `structuredData` — the site's
|
|
80
|
+
* origin, as `https://example.com`.
|
|
81
|
+
*
|
|
82
|
+
* Search engines want an absolute URL there. Without this the `href`s are
|
|
83
|
+
* emitted exactly as written, which is right when they are already absolute
|
|
84
|
+
* and not much use when they are not.
|
|
85
|
+
*/
|
|
86
|
+
baseUrl?: string;
|
|
87
|
+
/** The `PlBreadcrumbItem`s. */
|
|
88
|
+
children?: React.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
export interface PlBreadcrumbItemProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color' | 'onClick'> {
|
|
91
|
+
/** Renders the step as a link. */
|
|
92
|
+
href?: string;
|
|
93
|
+
/** Fires when the step is pressed. Renders it as a button when there is no `href`. */
|
|
94
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
95
|
+
/** Content before the label — a home glyph, a repository avatar. */
|
|
96
|
+
startIcon?: React.ReactNode;
|
|
97
|
+
/** Content after the label. */
|
|
98
|
+
endIcon?: React.ReactNode;
|
|
99
|
+
/**
|
|
100
|
+
* Marks this step as the page you are on, which stops it being a link.
|
|
101
|
+
*
|
|
102
|
+
* The last step is the current one on its own, so this is only needed for a
|
|
103
|
+
* trail that ends somewhere the reader is not — and setting it anywhere takes
|
|
104
|
+
* the mark off the last step, because only one step in a trail can be it.
|
|
105
|
+
*/
|
|
106
|
+
current?: boolean;
|
|
107
|
+
/** Unavailable. Stops answering, keeps its place in the trail. */
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
/** The step's label. */
|
|
110
|
+
children?: React.ReactNode;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The trail of pages above the one being read.
|
|
114
|
+
*
|
|
115
|
+
* Two things make this more than a row of links. The first is that the last step
|
|
116
|
+
* is where the reader already is, so it is not a link at all — it carries
|
|
117
|
+
* `aria-current="page"` and stops being pressable, and the component works that
|
|
118
|
+
* out rather than asking every caller to remember it. The second is the fold: a
|
|
119
|
+
* trail seven levels deep is a trail nobody reads, so the middle collapses to a
|
|
120
|
+
* `…` that puts it back when pressed.
|
|
121
|
+
*
|
|
122
|
+
* The separators are drawn by the trail rather than by the steps. A step does
|
|
123
|
+
* not know whether anything follows it, and a mark that belonged to a step would
|
|
124
|
+
* have to be taken off the last one by hand.
|
|
125
|
+
*
|
|
126
|
+
* There is no `variant` and no `elevation`: a trail is a line of text above the
|
|
127
|
+
* page, not a surface laid on it.
|
|
128
|
+
*/
|
|
129
|
+
export declare const PlBreadcrumb: React.ForwardRefExoticComponent<PlBreadcrumbProps & React.RefAttributes<HTMLElement>>;
|
|
130
|
+
/**
|
|
131
|
+
* One step of the trail.
|
|
132
|
+
*
|
|
133
|
+
* It renders three different things and the caller picks by what they pass: an
|
|
134
|
+
* `<a>` with an `href`, a `<button>` with an `onClick`, and a plain `<span>` with
|
|
135
|
+
* neither — which is what the last step is, because the page you are already on
|
|
136
|
+
* is not somewhere to go.
|
|
137
|
+
*/
|
|
138
|
+
export declare const PlBreadcrumbItem: React.ForwardRefExoticComponent<PlBreadcrumbItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ArrowRightIcon, ChevronIcon, EllipsisIcon } from '../../internal/icons.js';
|
|
4
|
+
import { controlTextClasses, cx, focusRingClasses, gapClasses, hasContent, iconClasses, radiusClasses, transitionClasses } from '../../internal/styles.js';
|
|
5
|
+
const BreadcrumbContext = /* @__PURE__ */ React.createContext({
|
|
6
|
+
size: 'md',
|
|
7
|
+
last: false
|
|
8
|
+
});
|
|
9
|
+
/** Between the steps, and the only thing `density` touches. */
|
|
10
|
+
const trailGapClasses = {
|
|
11
|
+
default: { xs: 'gap-1', sm: 'gap-1.5', md: 'gap-2', lg: 'gap-2.5', xl: 'gap-3' },
|
|
12
|
+
compact: { xs: 'gap-0.5', sm: 'gap-1', md: 'gap-1', lg: 'gap-1.5', xl: 'gap-2' }
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A step's corner, read two steps down the radius ladder.
|
|
16
|
+
*
|
|
17
|
+
* `radiusClasses.md` is 12px, which on a line of text 20px tall is most of the
|
|
18
|
+
* way to a pill — and a breadcrumb step is not a `PlChip`. What the hover tint
|
|
19
|
+
* needs is a rectangle with the corners taken off, which is what the ladder says
|
|
20
|
+
* everywhere else; it just has to be read further down for something this short.
|
|
21
|
+
*/
|
|
22
|
+
const stepRadiusClasses = {
|
|
23
|
+
xs: radiusClasses.xs,
|
|
24
|
+
sm: radiusClasses.xs,
|
|
25
|
+
md: radiusClasses.xs,
|
|
26
|
+
lg: radiusClasses.sm,
|
|
27
|
+
xl: radiusClasses.sm
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The four marks.
|
|
31
|
+
*
|
|
32
|
+
* The two that point are glyphs turned rather than redrawn, the same allowance
|
|
33
|
+
* the no-transform rule makes for the chevron on a `PlAccordion`: the wedge is
|
|
34
|
+
* drawn pointing down once, and a trail turns it a quarter. Both turn back under
|
|
35
|
+
* RTL, because a trail runs the way the language does.
|
|
36
|
+
*/
|
|
37
|
+
function separatorMark(separator) {
|
|
38
|
+
switch (separator) {
|
|
39
|
+
case 'chevron':
|
|
40
|
+
return (_jsx("span", { className: "flex -rotate-90 items-center rtl:rotate-90", children: _jsx(ChevronIcon, {}) }));
|
|
41
|
+
case 'arrow':
|
|
42
|
+
return (_jsx("span", { className: "flex items-center rtl:rotate-180", children: _jsx(ArrowRightIcon, {}) }));
|
|
43
|
+
case 'slash':
|
|
44
|
+
return _jsx("span", { className: "opacity-70", children: "/" });
|
|
45
|
+
case 'dot':
|
|
46
|
+
return _jsx("span", { className: "opacity-70", children: "\u00B7" });
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const separatorNames = ['chevron', 'arrow', 'slash', 'dot'];
|
|
52
|
+
/**
|
|
53
|
+
* The words in a step, with everything that is not a word left out.
|
|
54
|
+
*
|
|
55
|
+
* A step's label is a `ReactNode` and `name` in the structured data is a string,
|
|
56
|
+
* so the tree is walked for its text. Only `children` is read — a `startIcon` is
|
|
57
|
+
* a picture of the thing rather than its name, and a home glyph contributing
|
|
58
|
+
* nothing is exactly right.
|
|
59
|
+
*/
|
|
60
|
+
function textOf(node) {
|
|
61
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
62
|
+
return String(node);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(node)) {
|
|
65
|
+
return node.map(textOf).join('');
|
|
66
|
+
}
|
|
67
|
+
if (React.isValidElement(node)) {
|
|
68
|
+
return textOf(node.props.children);
|
|
69
|
+
}
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A step's `href` as a search engine wants it: absolute.
|
|
74
|
+
*
|
|
75
|
+
* `new URL` is what resolves `../guide` against a base rather than pasting the
|
|
76
|
+
* two together, and it throws on anything it cannot make sense of — a base that
|
|
77
|
+
* is not a URL, an `href` that is a router-only path. Falling back to the `href`
|
|
78
|
+
* as written is better than dropping the entry: a relative URL is a weaker
|
|
79
|
+
* signal, an absent one is none.
|
|
80
|
+
*/
|
|
81
|
+
function absoluteHref(href, baseUrl) {
|
|
82
|
+
if (!baseUrl) {
|
|
83
|
+
return href;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
return new URL(href, baseUrl).href;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return href;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The trail as `schema.org`'s `BreadcrumbList`.
|
|
94
|
+
*
|
|
95
|
+
* `item` is omitted where a step has no `href`, which is the last step's usual
|
|
96
|
+
* case: a crawler reads a final entry without one as the page being looked at,
|
|
97
|
+
* and a `ListItem` pointing at nothing would be worse than one pointing nowhere.
|
|
98
|
+
*/
|
|
99
|
+
function breadcrumbListData(steps, baseUrl) {
|
|
100
|
+
const itemListElement = steps.map((step, index) => {
|
|
101
|
+
const { href, children } = step.props;
|
|
102
|
+
return {
|
|
103
|
+
'@type': 'ListItem',
|
|
104
|
+
position: index + 1,
|
|
105
|
+
name: textOf(children),
|
|
106
|
+
...(href ? { item: absoluteHref(href, baseUrl) } : null)
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
// `<` is escaped because this string is written into a `<script>`: a label
|
|
110
|
+
// holding `</script>` would otherwise close the tag and turn the rest of the
|
|
111
|
+
// JSON into markup.
|
|
112
|
+
return JSON.stringify({
|
|
113
|
+
'@context': 'https://schema.org',
|
|
114
|
+
'@type': 'BreadcrumbList',
|
|
115
|
+
itemListElement
|
|
116
|
+
}).replace(/</g, '\\u003c');
|
|
117
|
+
}
|
|
118
|
+
function isSeparatorName(value) {
|
|
119
|
+
return typeof value === 'string' && separatorNames.includes(value);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The trail of pages above the one being read.
|
|
123
|
+
*
|
|
124
|
+
* Two things make this more than a row of links. The first is that the last step
|
|
125
|
+
* is where the reader already is, so it is not a link at all — it carries
|
|
126
|
+
* `aria-current="page"` and stops being pressable, and the component works that
|
|
127
|
+
* out rather than asking every caller to remember it. The second is the fold: a
|
|
128
|
+
* trail seven levels deep is a trail nobody reads, so the middle collapses to a
|
|
129
|
+
* `…` that puts it back when pressed.
|
|
130
|
+
*
|
|
131
|
+
* The separators are drawn by the trail rather than by the steps. A step does
|
|
132
|
+
* not know whether anything follows it, and a mark that belonged to a step would
|
|
133
|
+
* have to be taken off the last one by hand.
|
|
134
|
+
*
|
|
135
|
+
* There is no `variant` and no `elevation`: a trail is a line of text above the
|
|
136
|
+
* page, not a surface laid on it.
|
|
137
|
+
*/
|
|
138
|
+
export const PlBreadcrumb = /* @__PURE__ */ React.forwardRef(function PlBreadcrumb({ size = 'md', color = 'primary', density = 'default', separator = 'chevron', maxItems, itemsBeforeCollapse = 1, itemsAfterCollapse = 1, expandable = true, label = 'Breadcrumb', expandLabel = 'Show the hidden steps', structuredData = false, baseUrl, className, style, children, ...props }, ref) {
|
|
139
|
+
const [unfolded, setUnfolded] = React.useState(false);
|
|
140
|
+
const steps = React.Children.toArray(children).filter(React.isValidElement);
|
|
141
|
+
const total = steps.length;
|
|
142
|
+
/*
|
|
143
|
+
* The last step is the page you are on — unless a step says it is. Exactly one
|
|
144
|
+
* element in a trail may carry `aria-current="page"`, so a caller who marks an
|
|
145
|
+
* earlier step has to take the mark off the last one, and doing that by hand
|
|
146
|
+
* would mean writing `current={false}` on a step that never asked for it.
|
|
147
|
+
*/
|
|
148
|
+
const claimed = steps.some((step) => step.props.current === true);
|
|
149
|
+
const folding = !unfolded &&
|
|
150
|
+
maxItems !== undefined &&
|
|
151
|
+
total > Math.max(maxItems, 1) &&
|
|
152
|
+
// A fold has to actually remove something. With `1` before and `1` after on
|
|
153
|
+
// a three-step trail the `…` would stand in for exactly one step, which is
|
|
154
|
+
// longer than the step it replaced.
|
|
155
|
+
total - itemsBeforeCollapse - itemsAfterCollapse > 1;
|
|
156
|
+
const shown = folding
|
|
157
|
+
? [
|
|
158
|
+
...steps.slice(0, Math.max(0, itemsBeforeCollapse)),
|
|
159
|
+
null,
|
|
160
|
+
...steps.slice(total - Math.max(0, itemsAfterCollapse))
|
|
161
|
+
]
|
|
162
|
+
: steps;
|
|
163
|
+
const mark = isSeparatorName(separator) ? separatorMark(separator) : separator;
|
|
164
|
+
const foldClassNames = cx('inline-flex items-center rounded-(--plass-radius-xs) px-0.5', 'text-(--plass-muted-fg)', transitionClasses, iconClasses, expandable
|
|
165
|
+
? cx('cursor-pointer hover:bg-(--p-soft) hover:text-(--p-accent)', focusRingClasses)
|
|
166
|
+
: '');
|
|
167
|
+
return (_jsxs("nav", { ref: ref, "aria-label": label, className: cx('flex', controlTextClasses[size], iconClasses, className), style: {
|
|
168
|
+
'--p-accent': `var(--plass-${color}-accent)`,
|
|
169
|
+
'--p-soft': `var(--plass-${color}-soft)`,
|
|
170
|
+
'--p-ring': `var(--plass-${color}-ring)`,
|
|
171
|
+
...style
|
|
172
|
+
}, ...props, children: [structuredData && total > 0 ? (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: breadcrumbListData(steps, baseUrl) } })) : null, _jsx("ol", {
|
|
173
|
+
// `role="list"` said out loud: Tailwind's reset takes the bullets off
|
|
174
|
+
// every `<ol>`, and Safari takes the list semantics off with them.
|
|
175
|
+
role: "list", className: cx('flex list-none flex-wrap items-center p-0', trailGapClasses[density][size]), children: shown.map((step, index) => (_jsxs(React.Fragment, { children: [index > 0 ? (_jsx("li", { "aria-hidden": "true", className: "flex shrink-0 items-center text-(--plass-muted-fg) select-none", children: mark })) : null, step ? (_jsx(BreadcrumbContext.Provider, { value: { size, last: !claimed && index === shown.length - 1 }, children: step })) : (_jsx("li", { className: "flex shrink-0 items-center", children: expandable ? (_jsx("button", { type: "button", className: foldClassNames, "aria-label": expandLabel, onClick: () => setUnfolded(true), children: _jsx(EllipsisIcon, {}) })) : (_jsx("span", { className: foldClassNames, "aria-hidden": "true", children: _jsx(EllipsisIcon, {}) })) }))] }, step ? (step.key ?? index) : 'fold'))) })] }));
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* One step of the trail.
|
|
179
|
+
*
|
|
180
|
+
* It renders three different things and the caller picks by what they pass: an
|
|
181
|
+
* `<a>` with an `href`, a `<button>` with an `onClick`, and a plain `<span>` with
|
|
182
|
+
* neither — which is what the last step is, because the page you are already on
|
|
183
|
+
* is not somewhere to go.
|
|
184
|
+
*/
|
|
185
|
+
export const PlBreadcrumbItem = /* @__PURE__ */ React.forwardRef(function PlBreadcrumbItem({ href, onClick, startIcon, endIcon, current, disabled = false, className, children, ...props }, ref) {
|
|
186
|
+
const { size, last } = React.useContext(BreadcrumbContext);
|
|
187
|
+
const isCurrent = current ?? last;
|
|
188
|
+
const interactive = Boolean(href || onClick) && !isCurrent && !disabled;
|
|
189
|
+
const stepClassNames = cx('inline-flex min-w-0 items-center px-1', gapClasses[size], stepRadiusClasses[size], transitionClasses,
|
|
190
|
+
// An if/else rather than stacked variants: two Tailwind classes of equal
|
|
191
|
+
// specificity resolve by their order in the generated stylesheet.
|
|
192
|
+
disabled
|
|
193
|
+
? 'cursor-not-allowed text-(--plass-muted-fg) opacity-50'
|
|
194
|
+
: isCurrent
|
|
195
|
+
? 'font-medium text-(--plass-fg)'
|
|
196
|
+
: interactive
|
|
197
|
+
? cx('cursor-pointer text-(--plass-muted-fg)', 'hover:bg-(--p-soft) hover:text-(--p-accent)', focusRingClasses)
|
|
198
|
+
: 'text-(--plass-muted-fg)');
|
|
199
|
+
const body = (_jsxs(_Fragment, { children: [hasContent(startIcon) ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: startIcon })) : null, _jsx("span", { className: "truncate", children: children }), hasContent(endIcon) ? (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: endIcon })) : null] }));
|
|
200
|
+
return (_jsx("li", { ref: ref, className: cx('flex min-w-0 items-center', className), ...props, children: interactive && href ? (_jsx("a", { href: href, className: stepClassNames, onClick: onClick, children: body })) : interactive ? (_jsx("button", { type: "button", className: stepClassNames, onClick: onClick, children: body })) : (_jsx("span", { className: stepClassNames, "aria-current": isCurrent ? 'page' : undefined, "aria-disabled": disabled || undefined, children: body })) }));
|
|
201
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlBreadcrumb, PlBreadcrumbItem } from './PlBreadcrumb.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import type { PlassElevation, PlassStyleProps } from '../../types';
|
|
4
|
-
export interface
|
|
3
|
+
import type { PlassElevation, PlassStyleProps } from '../../types.js';
|
|
4
|
+
export interface PlButtonProps extends PlassStyleProps, Omit<React.ComponentPropsWithoutRef<'button'>, 'color'> {
|
|
5
5
|
/**
|
|
6
6
|
* Drop shadow depth. `1` is the default, because a moulded key **rests on**
|
|
7
7
|
* the sheet rather than lying flush with it. Hover adds a level and pressing
|
|
@@ -39,4 +39,4 @@ export interface ButtonProps extends PlassStyleProps, Omit<React.ComponentPropsW
|
|
|
39
39
|
render?: useRender.RenderProp;
|
|
40
40
|
children?: React.ReactNode;
|
|
41
41
|
}
|
|
42
|
-
export declare const
|
|
42
|
+
export declare const PlButton: React.ForwardRefExoticComponent<PlButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button as BaseUIButton } from '@base-ui/react/button';
|
|
4
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
5
|
+
import { ButtonGroupContext } from '../../internal/button-group.js';
|
|
6
|
+
import { Spinner } from '../../internal/icons.js';
|
|
7
|
+
import { controlHeightClasses, controlSlots, controlSquareClasses, controlTextClasses, disabledClasses, focusRingClasses, gapClasses, glassClasses, hasContent, iconClasses, paddingXClasses, radiusClasses, readOnlyFilterClasses, transitionClasses } from '../../internal/styles.js';
|
|
8
|
+
/**
|
|
9
|
+
* The scales all come from `internal/styles` — a button's height *is* the
|
|
10
|
+
* library's control height, and the same numbers have to hold on a PlTextField,
|
|
11
|
+
* a Select and a Chip for a mixed row to keep its baseline.
|
|
12
|
+
*/
|
|
13
|
+
const sizeClasses = {
|
|
14
|
+
xs: `${controlHeightClasses.xs} ${gapClasses.xs} ${radiusClasses.xs} ${controlTextClasses.xs}`,
|
|
15
|
+
sm: `${controlHeightClasses.sm} ${gapClasses.sm} ${radiusClasses.sm} ${controlTextClasses.sm}`,
|
|
16
|
+
md: `${controlHeightClasses.md} ${gapClasses.md} ${radiusClasses.md} ${controlTextClasses.md}`,
|
|
17
|
+
lg: `${controlHeightClasses.lg} ${gapClasses.lg} ${radiusClasses.lg} ${controlTextClasses.lg}`,
|
|
18
|
+
xl: `${controlHeightClasses.xl} ${gapClasses.xl} ${radiusClasses.xl} ${controlTextClasses.xl}`
|
|
19
|
+
};
|
|
20
|
+
/** With no label there is nothing to pad against, so the button goes square. */
|
|
21
|
+
const iconOnlyClasses = {
|
|
22
|
+
xs: `${controlSquareClasses.xs} px-0`,
|
|
23
|
+
sm: `${controlSquareClasses.sm} px-0`,
|
|
24
|
+
md: `${controlSquareClasses.md} px-0`,
|
|
25
|
+
lg: `${controlSquareClasses.lg} px-0`,
|
|
26
|
+
xl: `${controlSquareClasses.xl} px-0`
|
|
27
|
+
};
|
|
28
|
+
const baseClasses = /* @__PURE__ */ [
|
|
29
|
+
// `relative` because `.plass-glow` hangs its two light layers off `::before`/`::after`.
|
|
30
|
+
'relative inline-flex shrink-0 select-none items-center justify-center',
|
|
31
|
+
'whitespace-nowrap align-middle font-semibold leading-none',
|
|
32
|
+
'[-webkit-tap-highlight-color:transparent] [touch-action:manipulation]',
|
|
33
|
+
transitionClasses,
|
|
34
|
+
focusRingClasses,
|
|
35
|
+
iconClasses
|
|
36
|
+
].join(' ');
|
|
37
|
+
/**
|
|
38
|
+
* The three materials.
|
|
39
|
+
*
|
|
40
|
+
* `solid` is the only one with a `background-image`, and that gradient is the
|
|
41
|
+
* whole of the form: two ends of the family swept across the control, with no
|
|
42
|
+
* highlight over the top of it. A filled control deliberately carries **no**
|
|
43
|
+
* gloss line — an inset white edge on a coloured surface is what reads as
|
|
44
|
+
* lacquer, and the sweep is already saying everything about the shape that
|
|
45
|
+
* needs saying. The hairline belongs to `glass`, which has a real cut edge.
|
|
46
|
+
*
|
|
47
|
+
* `glass` wears the family in its **text** rather than in its sheet, which is
|
|
48
|
+
* why `color="secondary"` is the neutral, quiet button and not a second grey
|
|
49
|
+
* variant nobody would remember the name of.
|
|
50
|
+
*/
|
|
51
|
+
const restClasses = {
|
|
52
|
+
solid: /* @__PURE__ */ [
|
|
53
|
+
'text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
54
|
+
'[box-shadow:var(--p-elev),var(--p-lift)]'
|
|
55
|
+
].join(' '),
|
|
56
|
+
glass: /* @__PURE__ */ [
|
|
57
|
+
glassClasses,
|
|
58
|
+
'border text-(--p-accent) bg-(--plass-glass)',
|
|
59
|
+
'[border-color:var(--plass-glass-line)]',
|
|
60
|
+
'[box-shadow:var(--p-elev),var(--plass-gloss-glass)]'
|
|
61
|
+
].join(' '),
|
|
62
|
+
// Nothing to catch the light on, and nothing to cast a shadow.
|
|
63
|
+
ghost: 'text-(--p-accent) bg-transparent'
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Hover lifts the control and turns the light up; press puts it down and turns
|
|
67
|
+
* the light down. Both are `filter: brightness()` rather than a second set of
|
|
68
|
+
* colours, because the fill is a gradient and a gradient cannot be transitioned
|
|
69
|
+
* — but light falling on one can. The pointer bloom `.plass-glow` draws rides
|
|
70
|
+
* on top of this; the brightness is the state, the bloom is where the pointer
|
|
71
|
+
* is.
|
|
72
|
+
*/
|
|
73
|
+
const hoverClasses = {
|
|
74
|
+
solid: /* @__PURE__ */ [
|
|
75
|
+
'hover:brightness-105',
|
|
76
|
+
'hover:[box-shadow:var(--p-elev-hover),var(--p-lift-hover)]',
|
|
77
|
+
'active:brightness-95',
|
|
78
|
+
'active:[box-shadow:var(--p-elev-press),var(--p-lift-press)]'
|
|
79
|
+
].join(' '),
|
|
80
|
+
glass: /* @__PURE__ */ [
|
|
81
|
+
'hover:bg-(--plass-glass-hover) hover:[border-color:var(--p-line)]',
|
|
82
|
+
'hover:[box-shadow:var(--p-elev-hover),var(--plass-gloss-glass)]',
|
|
83
|
+
'active:bg-(--plass-glass-press)',
|
|
84
|
+
'active:[box-shadow:var(--p-elev-press),var(--plass-gloss-glass)]'
|
|
85
|
+
].join(' '),
|
|
86
|
+
ghost: 'hover:bg-(--p-soft) active:bg-(--p-soft-hover)'
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Read-only keeps the shape, the colour and the edge but goes flat, loses its
|
|
90
|
+
* lift and drains most of the saturation.
|
|
91
|
+
*/
|
|
92
|
+
const readOnlyClasses = {
|
|
93
|
+
solid: /* @__PURE__ */ [
|
|
94
|
+
'cursor-default text-(--p-on-solid) [background-image:var(--p-fill)]',
|
|
95
|
+
`shadow-none ${readOnlyFilterClasses}`
|
|
96
|
+
].join(' '),
|
|
97
|
+
glass: /* @__PURE__ */ [
|
|
98
|
+
glassClasses,
|
|
99
|
+
'cursor-default border text-(--p-accent) bg-(--plass-glass)',
|
|
100
|
+
'[border-color:var(--plass-glass-line)]',
|
|
101
|
+
`[box-shadow:var(--plass-gloss-glass)] ${readOnlyFilterClasses}`
|
|
102
|
+
].join(' '),
|
|
103
|
+
ghost: `cursor-default text-(--p-accent) bg-transparent ${readOnlyFilterClasses}`
|
|
104
|
+
};
|
|
105
|
+
export const PlButton = /* @__PURE__ */ React.forwardRef(function PlButton({ variant: variantProp, size: sizeProp, color: colorProp, density: densityProp, elevation: elevationProp, startIcon, endIcon, loading = false, readOnly = false, fullWidth = false, disabled: disabledProp, render, className, style, children, onClick, onPointerMove, ...props }, ref) {
|
|
106
|
+
/*
|
|
107
|
+
* A `PlButtonGroup` around this button sets the axes once for the set. The
|
|
108
|
+
* button's own prop still wins — a row of secondary actions with one danger
|
|
109
|
+
* button in it is a real thing — and with no group around it the fallbacks
|
|
110
|
+
* are the defaults they always were.
|
|
111
|
+
*/
|
|
112
|
+
const group = React.useContext(ButtonGroupContext);
|
|
113
|
+
const variant = variantProp ?? group?.variant ?? 'solid';
|
|
114
|
+
const size = sizeProp ?? group?.size ?? 'md';
|
|
115
|
+
const color = colorProp ?? group?.color ?? 'primary';
|
|
116
|
+
const density = densityProp ?? group?.density ?? 'default';
|
|
117
|
+
const elevation = elevationProp ?? group?.elevation ?? 1;
|
|
118
|
+
const disabled = disabledProp ?? group?.disabled ?? false;
|
|
119
|
+
const iconOnly = !hasContent(children);
|
|
120
|
+
// `disabled` and `readOnly` change how the button looks; `loading` only stops
|
|
121
|
+
// it from firing.
|
|
122
|
+
const inert = loading || readOnly;
|
|
123
|
+
const interactive = !disabled && !inert;
|
|
124
|
+
const classNames = [
|
|
125
|
+
baseClasses,
|
|
126
|
+
sizeClasses[size],
|
|
127
|
+
iconOnly ? iconOnlyClasses[size] : paddingXClasses[density][size],
|
|
128
|
+
// Deliberately an if/else rather than stacked `data-*` variants: two
|
|
129
|
+
// Tailwind variants of equal specificity resolve by their order in the
|
|
130
|
+
// generated stylesheet, which is not something a component should depend on.
|
|
131
|
+
disabled
|
|
132
|
+
? disabledClasses[variant]
|
|
133
|
+
: readOnly
|
|
134
|
+
? readOnlyClasses[variant]
|
|
135
|
+
: restClasses[variant],
|
|
136
|
+
interactive ? `${hoverClasses[variant]} cursor-pointer` : '',
|
|
137
|
+
// The interaction light. Every variant takes it, because it is about where
|
|
138
|
+
// the pointer is rather than about what the surface is made of — the two
|
|
139
|
+
// colour slots behind it are what switch with the variant.
|
|
140
|
+
interactive ? 'plass-glow' : '',
|
|
141
|
+
loading ? 'cursor-progress' : '',
|
|
142
|
+
fullWidth ? 'w-full' : '',
|
|
143
|
+
className ?? ''
|
|
144
|
+
]
|
|
145
|
+
.filter(Boolean)
|
|
146
|
+
.join(' ');
|
|
147
|
+
/*
|
|
148
|
+
* `render` deliberately steps around Base UI's PlButton rather than being handed
|
|
149
|
+
* to it. Told to render a non-`<button>`, that component puts `role="button"`
|
|
150
|
+
* on whatever it was given — which is right for a `<div>` and wrong for the
|
|
151
|
+
* case this prop exists for: an `<a href>` under a `role="button"` stops being
|
|
152
|
+
* a link to everything that reads the page, and the link list, the status bar
|
|
153
|
+
* and the crawler all lose it.
|
|
154
|
+
*
|
|
155
|
+
* What Base UI's PlButton adds over a bare `<button>` is its disabled handling,
|
|
156
|
+
* and `disabled` is the one thing that cannot travel to an `<a>` anyway.
|
|
157
|
+
*/
|
|
158
|
+
return useRender({
|
|
159
|
+
render: render ?? _jsx(BaseUIButton, { disabled: disabled }),
|
|
160
|
+
ref,
|
|
161
|
+
props: {
|
|
162
|
+
className: classNames,
|
|
163
|
+
style: { ...controlSlots(color, elevation, variant), ...style },
|
|
164
|
+
'aria-disabled': inert || undefined,
|
|
165
|
+
'aria-busy': loading || undefined,
|
|
166
|
+
'data-loading': loading || undefined,
|
|
167
|
+
'data-readonly': readOnly || undefined,
|
|
168
|
+
onClick: (event) => {
|
|
169
|
+
if (inert) {
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
event.stopPropagation();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
onClick?.(event);
|
|
175
|
+
},
|
|
176
|
+
onPointerMove: (event) => {
|
|
177
|
+
// Feeds the two light layers in `styles.css`. Written straight to the
|
|
178
|
+
// element rather than held in state: this fires at pointer rate, and a
|
|
179
|
+
// `setState` here would re-render the tree on every mouse move. Reading
|
|
180
|
+
// `offsetX/offsetY` costs nothing — no `getBoundingClientRect`, so no
|
|
181
|
+
// forced layout. Icons carry `pointer-events: none`, so the offsets are
|
|
182
|
+
// always relative to the button itself.
|
|
183
|
+
//
|
|
184
|
+
// It runs while a finger is down too, which is what makes the light
|
|
185
|
+
// follow a drag on a touch screen — there is no hover there, and the
|
|
186
|
+
// `:active` layer is the one doing the work.
|
|
187
|
+
const element = event.currentTarget;
|
|
188
|
+
element.style.setProperty('--p-mx', `${event.nativeEvent.offsetX}px`);
|
|
189
|
+
element.style.setProperty('--p-my', `${event.nativeEvent.offsetY}px`);
|
|
190
|
+
onPointerMove?.(event);
|
|
191
|
+
},
|
|
192
|
+
...props,
|
|
193
|
+
children: (_jsxs(_Fragment, { children: [loading ? _jsx(Spinner, {}) : startIcon, children, endIcon] }))
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { PlButton } from './PlButton.js';
|
|
2
|
+
export type { PlButtonProps } from './PlButton.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export { PlButton } from './PlButton.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassElevation, PlassOrientation, PlassStyleProps } from '../../types.js';
|
|
3
|
+
export interface PlButtonGroupProps extends PlassStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* Which way the buttons run. A vertical group is a stacked menu of equal
|
|
6
|
+
* actions; a horizontal one is the default because that is what a toolbar is.
|
|
7
|
+
* @default 'horizontal'
|
|
8
|
+
*/
|
|
9
|
+
orientation?: PlassOrientation;
|
|
10
|
+
/** Drop shadow depth, passed to every button in the group. */
|
|
11
|
+
elevation?: PlassElevation;
|
|
12
|
+
/** Disables every button in the group at once. */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Stretches to the container and divides the width evenly between buttons. */
|
|
15
|
+
fullWidth?: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A run of buttons that belong together.
|
|
20
|
+
*
|
|
21
|
+
* Two things are happening here and only one of them is visual. The corners
|
|
22
|
+
* that face a neighbour are squared off — that is the look. The other half is
|
|
23
|
+
* that `variant`, `size`, `color`, `density`, `elevation` and `disabled` are
|
|
24
|
+
* stated once for the set rather than repeated on every button; a group where
|
|
25
|
+
* one button is a size out is the failure this exists to prevent.
|
|
26
|
+
*
|
|
27
|
+
* The buttons stay real `PlButton`s and nothing about them is replaced. Which
|
|
28
|
+
* also means this is **not** a segmented control and it does not manage
|
|
29
|
+
* selection: for one-of-a-set reach for `PlSegmentedButton`, which is what that
|
|
30
|
+
* actually is.
|
|
31
|
+
*/
|
|
32
|
+
export declare const PlButtonGroup: React.ForwardRefExoticComponent<PlButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
|