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,411 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { PlIconButton } from '../icon-button/PlIconButton.js';
|
|
4
|
+
import { spacingValue } from '../../internal/grid.js';
|
|
5
|
+
import { ChevronIcon } from '../../internal/icons.js';
|
|
6
|
+
import { cx } from '../../internal/styles.js';
|
|
7
|
+
/**
|
|
8
|
+
* How far the buttons sit in from the edge they are held against.
|
|
9
|
+
*
|
|
10
|
+
* Padding on the overlay rather than an inset on each button, so the two are
|
|
11
|
+
* written once and a zone with only one of them drawn keeps the other's
|
|
12
|
+
* position.
|
|
13
|
+
*/
|
|
14
|
+
const buttonInsetClasses = {
|
|
15
|
+
xs: 'p-1',
|
|
16
|
+
sm: 'p-1.5',
|
|
17
|
+
md: 'p-2',
|
|
18
|
+
lg: 'p-3',
|
|
19
|
+
xl: 'p-4'
|
|
20
|
+
};
|
|
21
|
+
/** And the air between an inline button and the strip it flanks. */
|
|
22
|
+
const buttonGapClasses = {
|
|
23
|
+
xs: 'gap-1',
|
|
24
|
+
sm: 'gap-1.5',
|
|
25
|
+
md: 'gap-2',
|
|
26
|
+
lg: 'gap-3',
|
|
27
|
+
xl: 'gap-4'
|
|
28
|
+
};
|
|
29
|
+
/** How far a press has to travel before it stops being a click. */
|
|
30
|
+
const DRAG_THRESHOLD = 4;
|
|
31
|
+
/** Under this, a press in `hold` mode was a tap and moves one item instead. */
|
|
32
|
+
const TAP_MS = 140;
|
|
33
|
+
/** A reader who has asked for less motion gets the cut rather than the travel. */
|
|
34
|
+
function scrollBehavior() {
|
|
35
|
+
return typeof window !== 'undefined' &&
|
|
36
|
+
window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
|
|
37
|
+
? 'auto'
|
|
38
|
+
: 'smooth';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A strip of anything, laid out in one direction and scrolled in it.
|
|
42
|
+
*
|
|
43
|
+
* The mechanism is an ordinary scroll container, and everything the component
|
|
44
|
+
* offers is a way of driving one. Swiping on a phone, two-finger dragging on a
|
|
45
|
+
* trackpad, the wheel, the arrow keys and the scrollbar are the browser's own
|
|
46
|
+
* and are never intercepted; what is added on top is a pair of buttons for the
|
|
47
|
+
* pointer that has neither a wheel nor a finger, and a mouse drag for the strip
|
|
48
|
+
* that reads as something to pull rather than something to page.
|
|
49
|
+
*
|
|
50
|
+
* Nothing is transformed. A translated track would have to argue for an
|
|
51
|
+
* exception to the house rule; a scroll offset does not, and it is also what
|
|
52
|
+
* makes the strip run the other way under RTL without being told, keeps the
|
|
53
|
+
* scrollbar honest, and lets the browser scroll a focused child into view.
|
|
54
|
+
*
|
|
55
|
+
* It draws no sheet of its own, and there is no `elevation` to give it one: a
|
|
56
|
+
* shelf is a way of laying children out, and the children arrive with their own
|
|
57
|
+
* surfaces. `variant`, `size`, `color` and `density` reach the two buttons,
|
|
58
|
+
* which are real `PlIconButton`s.
|
|
59
|
+
*
|
|
60
|
+
* `lines` is what separates this from a `PlCarousel`: a carousel is one thing at
|
|
61
|
+
* a time and knows which one, a scroll zone is a shelf that happens to be longer
|
|
62
|
+
* than the room it is in.
|
|
63
|
+
*/
|
|
64
|
+
export const PlScrollZone = /* @__PURE__ */ React.forwardRef(function PlScrollZone({ orientation = 'horizontal', lines = 1, spacing = 2, buttons = 'auto', buttonPlacement = 'overlay', mode = 'item', step = 1, speed = 900, snap = false, drag = true, scrollbar = false, variant = 'glass', size = 'md', color = 'primary', density = 'default', label, previousLabel = 'Previous', nextLabel = 'Next', className, style, children, ...props }, ref) {
|
|
65
|
+
const horizontal = orientation === 'horizontal';
|
|
66
|
+
const rows = Math.max(1, Math.round(lines));
|
|
67
|
+
const items = Math.max(1, Math.round(step));
|
|
68
|
+
const scrollerRef = React.useRef(null);
|
|
69
|
+
const trackRef = React.useRef(null);
|
|
70
|
+
/**
|
|
71
|
+
* Whether there is anything left in each direction, as one object so a
|
|
72
|
+
* measurement that changed nothing costs no render.
|
|
73
|
+
*/
|
|
74
|
+
const [reach, setReach] = React.useState({ back: false, forward: false });
|
|
75
|
+
const measure = React.useCallback(() => {
|
|
76
|
+
const element = scrollerRef.current;
|
|
77
|
+
if (!element) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const extent = horizontal ? element.clientWidth : element.clientHeight;
|
|
81
|
+
const total = horizontal ? element.scrollWidth : element.scrollHeight;
|
|
82
|
+
// `abs`, because a right-to-left container counts its scroll backwards
|
|
83
|
+
// from zero. How far along we are is a distance either way.
|
|
84
|
+
const along = Math.abs(horizontal ? element.scrollLeft : element.scrollTop);
|
|
85
|
+
setReach((previous) => {
|
|
86
|
+
const back = along > 1;
|
|
87
|
+
const forward = total - extent - along > 1;
|
|
88
|
+
return previous.back === back && previous.forward === forward
|
|
89
|
+
? previous
|
|
90
|
+
: { back, forward };
|
|
91
|
+
});
|
|
92
|
+
}, [horizontal]);
|
|
93
|
+
/*
|
|
94
|
+
* Three things change what the buttons should say, and only one of them is
|
|
95
|
+
* an event: the strip being scrolled, the zone being resized, and the
|
|
96
|
+
* content inside it changing size. The observer covers the last two —
|
|
97
|
+
* including the case that matters most, a zone that mounts inside a closed
|
|
98
|
+
* `PlAccordion` or an unselected `PlTab` and is zero wide until it is
|
|
99
|
+
* opened.
|
|
100
|
+
*/
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
const element = scrollerRef.current;
|
|
103
|
+
const track = trackRef.current;
|
|
104
|
+
if (!element) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
measure();
|
|
108
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const observer = new ResizeObserver(measure);
|
|
112
|
+
observer.observe(element);
|
|
113
|
+
if (track) {
|
|
114
|
+
observer.observe(track);
|
|
115
|
+
}
|
|
116
|
+
return () => observer.disconnect();
|
|
117
|
+
}, [measure]);
|
|
118
|
+
/** Which way "forward" is on the physical axis: flipped under RTL. */
|
|
119
|
+
const forwardSign = React.useCallback(() => {
|
|
120
|
+
const element = scrollerRef.current;
|
|
121
|
+
if (!element || !horizontal) {
|
|
122
|
+
return 1;
|
|
123
|
+
}
|
|
124
|
+
return getComputedStyle(element).direction === 'rtl' ? -1 : 1;
|
|
125
|
+
}, [horizontal]);
|
|
126
|
+
const scrollByPixels = React.useCallback((distance, smooth) => {
|
|
127
|
+
const element = scrollerRef.current;
|
|
128
|
+
if (!element) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const behavior = smooth ? scrollBehavior() : 'auto';
|
|
132
|
+
element.scrollBy(horizontal ? { left: distance, behavior } : { top: distance, behavior });
|
|
133
|
+
}, [horizontal]);
|
|
134
|
+
/**
|
|
135
|
+
* Where each child starts, measured from the leading edge of the viewport
|
|
136
|
+
* and signed so that ahead is positive in both writing directions.
|
|
137
|
+
*
|
|
138
|
+
* Distinct offsets rather than one per child, which is what makes `lines`
|
|
139
|
+
* work: four children stacked two by two are two columns, and pressing next
|
|
140
|
+
* once should move one column rather than half of one.
|
|
141
|
+
*/
|
|
142
|
+
const itemStarts = React.useCallback(() => {
|
|
143
|
+
const element = scrollerRef.current;
|
|
144
|
+
const track = trackRef.current;
|
|
145
|
+
if (!element || !track) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const rtl = horizontal && getComputedStyle(element).direction === 'rtl';
|
|
149
|
+
const edge = horizontal ? (rtl ? 'right' : 'left') : 'top';
|
|
150
|
+
const sign = rtl ? -1 : 1;
|
|
151
|
+
const origin = element.getBoundingClientRect()[edge];
|
|
152
|
+
const starts = [];
|
|
153
|
+
for (const child of Array.from(track.children)) {
|
|
154
|
+
const start = Math.round((child.getBoundingClientRect()[edge] - origin) * sign);
|
|
155
|
+
if (!starts.includes(start)) {
|
|
156
|
+
starts.push(start);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return starts.sort((a, b) => a - b);
|
|
160
|
+
}, [horizontal]);
|
|
161
|
+
/** One press, in whichever unit `mode` is counted in. */
|
|
162
|
+
const advance = React.useCallback((forward, unit = mode) => {
|
|
163
|
+
const element = scrollerRef.current;
|
|
164
|
+
if (!element) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const sign = forwardSign();
|
|
168
|
+
const extent = horizontal ? element.clientWidth : element.clientHeight;
|
|
169
|
+
if (unit === 'page') {
|
|
170
|
+
scrollByPixels(extent * (forward ? 1 : -1) * sign, true);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// An item, and it is measured rather than assumed: the children of a
|
|
174
|
+
// scroll zone are whatever the caller put there, so no two of them are
|
|
175
|
+
// necessarily the same width.
|
|
176
|
+
const starts = itemStarts();
|
|
177
|
+
const ahead = starts.filter((start) => start > 1);
|
|
178
|
+
const behind = starts.filter((start) => start < -1);
|
|
179
|
+
const target = forward ? ahead[items - 1] : behind[behind.length - items];
|
|
180
|
+
if (target === undefined) {
|
|
181
|
+
// Nothing that far along: go as far as there is. Without this, the
|
|
182
|
+
// last half-item of a strip would be unreachable by button.
|
|
183
|
+
scrollByPixels(extent * (forward ? 1 : -1) * sign, true);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
scrollByPixels(target * sign, true);
|
|
187
|
+
}, [forwardSign, horizontal, itemStarts, items, mode, scrollByPixels]);
|
|
188
|
+
/*
|
|
189
|
+
* `hold` — a frame loop rather than an interval, so the strip moves at
|
|
190
|
+
* `speed` pixels a second whatever the display is doing. The whole gesture
|
|
191
|
+
* is torn down through one ref, because the `pointerup` that would normally
|
|
192
|
+
* end it never arrives if the zone is unmounted mid-press.
|
|
193
|
+
*/
|
|
194
|
+
const holdRef = React.useRef(null);
|
|
195
|
+
React.useEffect(() => () => holdRef.current?.(), []);
|
|
196
|
+
const beginHold = React.useCallback((forward, stop) => {
|
|
197
|
+
if (holdRef.current) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const sign = forwardSign();
|
|
201
|
+
const started = performance.now();
|
|
202
|
+
let previous = started;
|
|
203
|
+
let frame = 0;
|
|
204
|
+
const tick = (now) => {
|
|
205
|
+
const elapsed = now - previous;
|
|
206
|
+
previous = now;
|
|
207
|
+
scrollByPixels(((speed * elapsed) / 1000) * (forward ? 1 : -1) * sign, false);
|
|
208
|
+
frame = requestAnimationFrame(tick);
|
|
209
|
+
};
|
|
210
|
+
frame = requestAnimationFrame(tick);
|
|
211
|
+
const release = () => {
|
|
212
|
+
cancelAnimationFrame(frame);
|
|
213
|
+
holdRef.current = null;
|
|
214
|
+
window.removeEventListener(stop, release);
|
|
215
|
+
window.removeEventListener('pointercancel', release);
|
|
216
|
+
// A press released outside the browser window throws neither of the
|
|
217
|
+
// two above, and a frame loop nobody can stop is the worst kind.
|
|
218
|
+
window.removeEventListener('blur', release);
|
|
219
|
+
// A press shorter than a hold was a click, and a click that scrolled
|
|
220
|
+
// three pixels reads as a broken button.
|
|
221
|
+
if (performance.now() - started < TAP_MS) {
|
|
222
|
+
advance(forward, 'item');
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
holdRef.current = release;
|
|
226
|
+
window.addEventListener(stop, release);
|
|
227
|
+
window.addEventListener('pointercancel', release);
|
|
228
|
+
window.addEventListener('blur', release);
|
|
229
|
+
}, [advance, forwardSign, scrollByPixels, speed]);
|
|
230
|
+
/*
|
|
231
|
+
* Dragging. Mouse and pen only — a finger already scrolls, and the browser's
|
|
232
|
+
* own scrolling has momentum, rubber-banding and a scrollbar that no handler
|
|
233
|
+
* reproduces.
|
|
234
|
+
*/
|
|
235
|
+
const dragRef = React.useRef(null);
|
|
236
|
+
React.useEffect(() => () => dragRef.current?.(), []);
|
|
237
|
+
function beginDrag(event) {
|
|
238
|
+
if (!drag || event.pointerType === 'touch' || event.button !== 0) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
// A press released outside the page never reaches the listeners below, so
|
|
242
|
+
// the drag before this one is torn down here rather than never.
|
|
243
|
+
dragRef.current?.();
|
|
244
|
+
const element = event.currentTarget;
|
|
245
|
+
const fromX = event.clientX;
|
|
246
|
+
const fromY = event.clientY;
|
|
247
|
+
const fromLeft = element.scrollLeft;
|
|
248
|
+
const fromTop = element.scrollTop;
|
|
249
|
+
let dragging = false;
|
|
250
|
+
// Taken off the document for the length of the drag rather than fixed
|
|
251
|
+
// with `preventDefault`, which would also stop the browser focusing what
|
|
252
|
+
// was pressed. Written prefixed and through `setProperty` because WebKit
|
|
253
|
+
// implements only `-webkit-user-select`.
|
|
254
|
+
const selection = document.body.style.getPropertyValue('-webkit-user-select');
|
|
255
|
+
const move = (moveEvent) => {
|
|
256
|
+
const dx = moveEvent.clientX - fromX;
|
|
257
|
+
const dy = moveEvent.clientY - fromY;
|
|
258
|
+
if (!dragging) {
|
|
259
|
+
if (Math.abs(horizontal ? dx : dy) < DRAG_THRESHOLD) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
dragging = true;
|
|
263
|
+
element.setPointerCapture(moveEvent.pointerId);
|
|
264
|
+
element.dataset.dragging = 'true';
|
|
265
|
+
document.body.style.setProperty('-webkit-user-select', 'none');
|
|
266
|
+
}
|
|
267
|
+
if (horizontal) {
|
|
268
|
+
element.scrollLeft = fromLeft - dx;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
element.scrollTop = fromTop - dy;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
const release = () => {
|
|
275
|
+
dragRef.current = null;
|
|
276
|
+
element.removeEventListener('pointermove', move);
|
|
277
|
+
element.removeEventListener('pointerup', end);
|
|
278
|
+
element.removeEventListener('pointercancel', release);
|
|
279
|
+
delete element.dataset.dragging;
|
|
280
|
+
if (selection) {
|
|
281
|
+
document.body.style.setProperty('-webkit-user-select', selection);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
document.body.style.removeProperty('-webkit-user-select');
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const end = () => {
|
|
288
|
+
const moved = dragging;
|
|
289
|
+
release();
|
|
290
|
+
if (!moved) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
// The `pointerup` that ends a drag is still followed by a click, and
|
|
294
|
+
// that click lands on whatever card the strip happened to stop under.
|
|
295
|
+
// It is swallowed on the way down, and the listener is dropped on the
|
|
296
|
+
// next task in case no click was coming.
|
|
297
|
+
const swallow = (clickEvent) => {
|
|
298
|
+
clickEvent.stopPropagation();
|
|
299
|
+
clickEvent.preventDefault();
|
|
300
|
+
};
|
|
301
|
+
element.addEventListener('click', swallow, { capture: true, once: true });
|
|
302
|
+
window.setTimeout(() => element.removeEventListener('click', swallow, true), 0);
|
|
303
|
+
};
|
|
304
|
+
dragRef.current = release;
|
|
305
|
+
element.addEventListener('pointermove', move);
|
|
306
|
+
element.addEventListener('pointerup', end);
|
|
307
|
+
element.addEventListener('pointercancel', release);
|
|
308
|
+
}
|
|
309
|
+
function pressHandlers(forward) {
|
|
310
|
+
if (mode !== 'hold') {
|
|
311
|
+
return { onClick: () => advance(forward) };
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
onPointerDown: (event) => {
|
|
315
|
+
if (event.button !== 0) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
beginHold(forward, 'pointerup');
|
|
319
|
+
},
|
|
320
|
+
// The keyboard's own half of a hold. Without it the button is a control
|
|
321
|
+
// a pointer can use and a keyboard cannot, which is the one thing a
|
|
322
|
+
// scroll affordance must never be.
|
|
323
|
+
onKeyDown: (event) => {
|
|
324
|
+
if (event.key !== 'Enter' && event.key !== ' ') {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
beginHold(forward, 'keyup');
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const drawn = buttons !== 'none' && (buttons === 'always' || reach.back || reach.forward);
|
|
333
|
+
const inline = buttonPlacement === 'inline';
|
|
334
|
+
function scrollButton(forward) {
|
|
335
|
+
const available = forward ? reach.forward : reach.back;
|
|
336
|
+
// An overlay button with nowhere to go is not drawn at all; an inline one
|
|
337
|
+
// leaves its lane behind, because a lane that came and went would resize
|
|
338
|
+
// the strip under the pointer that had just reached the end of it.
|
|
339
|
+
// `inert` rather than `hidden`, so the space is kept and the button is out
|
|
340
|
+
// of the tab order and out of the accessibility tree while it is
|
|
341
|
+
// invisible.
|
|
342
|
+
if (buttons === 'auto' && !available && !inline) {
|
|
343
|
+
return _jsx("span", {});
|
|
344
|
+
}
|
|
345
|
+
const turn = horizontal
|
|
346
|
+
? forward
|
|
347
|
+
? '-rotate-90 rtl:rotate-90'
|
|
348
|
+
: 'rotate-90 rtl:-rotate-90'
|
|
349
|
+
: forward
|
|
350
|
+
? ''
|
|
351
|
+
: 'rotate-180';
|
|
352
|
+
const spare = buttons === 'auto' && !available;
|
|
353
|
+
const button = (_jsx(PlIconButton, { variant: variant, size: size, color: color, density: density, elevation: 1, label: forward ? nextLabel : previousLabel, disabled: !available, className: "pointer-events-auto",
|
|
354
|
+
// Drawn pointing down and turned, which is the one allowance the
|
|
355
|
+
// no-transform rule makes.
|
|
356
|
+
icon: _jsx("span", { className: cx('flex items-center', turn), children: _jsx(ChevronIcon, {}) }), ...pressHandlers(forward) }));
|
|
357
|
+
if (!inline) {
|
|
358
|
+
return button;
|
|
359
|
+
}
|
|
360
|
+
return (_jsx("span", { className: cx('flex shrink-0 items-center justify-center', spare ? 'invisible' : ''), inert: spare, children: button }));
|
|
361
|
+
}
|
|
362
|
+
return (_jsxs("div", { ref: ref,
|
|
363
|
+
// A flex column, so a zone that was given a height passes it to the
|
|
364
|
+
// scroller: a vertical strip only scrolls if something bounds it, and
|
|
365
|
+
// the thing a caller sizes is the component rather than the box inside
|
|
366
|
+
// it.
|
|
367
|
+
className: cx('relative flex min-w-0', inline && horizontal ? 'flex-row items-stretch' : 'flex-col', inline ? buttonGapClasses[size] : '', className),
|
|
368
|
+
// One slot rather than the whole set: a scroll zone draws no sheet, so
|
|
369
|
+
// the family only ever shows up in the focus ring the scroller takes.
|
|
370
|
+
// The buttons are real `PlIconButton`s and carry their own.
|
|
371
|
+
style: { '--p-ring': `var(--plass-${color}-ring)`, ...style }, ...props, children: [drawn && inline ? scrollButton(false) : null, _jsx("div", { ref: scrollerRef,
|
|
372
|
+
// Focusable, so the strip can be scrolled with the arrow keys by
|
|
373
|
+
// whoever is not using a pointer. That is the browser's own key
|
|
374
|
+
// handling on a scroll container, which means it is already right
|
|
375
|
+
// under RTL — a handler of ours mapping ArrowRight to "forward" would
|
|
376
|
+
// not have been.
|
|
377
|
+
tabIndex: 0, role: label ? 'group' : undefined, "aria-label": label, className: cx(
|
|
378
|
+
// `grow` with the basis left at `auto`, never `flex-1`: a zero basis
|
|
379
|
+
// in a column whose own height is `auto` resolves to no height at
|
|
380
|
+
// all, and a horizontal strip would come out flat.
|
|
381
|
+
'min-h-0 min-w-0 grow', horizontal ? 'overflow-x-auto overflow-y-hidden' : 'overflow-y-auto overflow-x-hidden', snap ? (horizontal ? 'snap-x snap-mandatory' : 'snap-y snap-mandatory') : '', scrollbar ? '' : '[scrollbar-width:none] [&::-webkit-scrollbar]:hidden', drag && (reach.back || reach.forward)
|
|
382
|
+
? 'cursor-grab data-[dragging]:cursor-grabbing'
|
|
383
|
+
: '', 'focus-visible:[outline:2px_solid_var(--p-ring)] focus-visible:[outline-offset:-2px]'), onScroll: measure, onPointerDown: beginDrag, children: _jsx("div", { ref: trackRef, className: cx(snap ? '[&>*]:snap-start' : ''),
|
|
384
|
+
// The whole track is laid out inline rather than in utilities, for
|
|
385
|
+
// the reason `internal/grid.ts` gives: `repeat(3, auto)` is a count
|
|
386
|
+
// the caller picked and Tailwind only ever sees class names written
|
|
387
|
+
// out literally. Half of the declaration in a class and half of it
|
|
388
|
+
// here would be two places to read one layout.
|
|
389
|
+
//
|
|
390
|
+
// A grid rather than a flex row, because `lines` is exactly the
|
|
391
|
+
// thing flex cannot state: a wrapping row wraps at the viewport, and
|
|
392
|
+
// what is wanted here is a fixed number of rows and as many columns
|
|
393
|
+
// as it takes.
|
|
394
|
+
style: {
|
|
395
|
+
display: 'grid',
|
|
396
|
+
gap: spacingValue(spacing),
|
|
397
|
+
gridAutoFlow: horizontal ? 'column' : 'row',
|
|
398
|
+
...(horizontal
|
|
399
|
+
? {
|
|
400
|
+
// `max-content`, or the track would be squeezed back to the
|
|
401
|
+
// width of the box it is supposed to be longer than.
|
|
402
|
+
width: 'max-content',
|
|
403
|
+
gridTemplateRows: `repeat(${rows}, auto)`,
|
|
404
|
+
gridAutoColumns: 'max-content'
|
|
405
|
+
}
|
|
406
|
+
: {
|
|
407
|
+
gridTemplateColumns: `repeat(${rows}, minmax(0, 1fr))`,
|
|
408
|
+
gridAutoRows: 'max-content'
|
|
409
|
+
})
|
|
410
|
+
}, children: children }) }), drawn && inline ? scrollButton(true) : null, drawn && !inline ? (_jsxs("div", { className: cx('pointer-events-none absolute inset-0 flex justify-between', horizontal ? 'items-center' : 'flex-col items-center', buttonInsetClasses[size]), children: [scrollButton(false), scrollButton(true)] })) : null] }));
|
|
411
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlScrollZone } from './PlScrollZone.js';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassElevation, PlassStyleProps, PlassVariant } from '../../types.js';
|
|
3
|
+
/** A segment's value. The same restraint `PlSelect` puts on its own. */
|
|
4
|
+
export type PlSegmentValue = string | number;
|
|
5
|
+
export interface PlSegmentedButtonProps extends Omit<PlassStyleProps, 'variant'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'onChange'> {
|
|
6
|
+
/**
|
|
7
|
+
* What the groove and the tile riding in it are made of.
|
|
8
|
+
*
|
|
9
|
+
* - `solid` — a groove cut into the sheet with a **tinted-glass key** riding
|
|
10
|
+
* in it. The loudest, and the one for a control a screen is about to be
|
|
11
|
+
* steered by.
|
|
12
|
+
* - `glass` — the same groove with a hairline round it and a clear tile
|
|
13
|
+
* rather than a coloured one. The default.
|
|
14
|
+
* - `ghost` — no groove at all: the segments sit straight on the page and only
|
|
15
|
+
* the chosen one has a surface.
|
|
16
|
+
* @default 'glass'
|
|
17
|
+
*/
|
|
18
|
+
variant?: PlassVariant;
|
|
19
|
+
/** The chosen segment. Use with `onValueChange` for a controlled set. */
|
|
20
|
+
value?: PlSegmentValue | null;
|
|
21
|
+
/** Which starts chosen, for an uncontrolled set. */
|
|
22
|
+
defaultValue?: PlSegmentValue | null;
|
|
23
|
+
onValueChange?: (value: PlSegmentValue | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Drop shadow depth of the groove. `0` is the default — a groove is cut into
|
|
26
|
+
* the page, not laid on it.
|
|
27
|
+
* @default 0
|
|
28
|
+
*/
|
|
29
|
+
elevation?: PlassElevation;
|
|
30
|
+
/** Disables every segment at once. */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Shows which one is chosen but does not let it be changed. */
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
/** Identifies the value when a form is submitted. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** The segments share the full width, each taking an equal part of it. */
|
|
37
|
+
fullWidth?: boolean;
|
|
38
|
+
children?: React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
export interface PlSegmentProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'value' | 'color'> {
|
|
41
|
+
/** Identifies the segment. What `onValueChange` reports. */
|
|
42
|
+
value: PlSegmentValue;
|
|
43
|
+
/** Content before the label. Sized in `em`, so it tracks the label. */
|
|
44
|
+
startIcon?: React.ReactNode;
|
|
45
|
+
/** Content after the label — a count, a status dot. */
|
|
46
|
+
endIcon?: React.ReactNode;
|
|
47
|
+
/** Unavailable, but still part of the set. */
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* One choice in a segmented button.
|
|
53
|
+
*
|
|
54
|
+
* It has no `size`, no `color` and no `variant` of its own: all three belong to
|
|
55
|
+
* the set, which is the only place they can be set once and mean the same thing
|
|
56
|
+
* for every segment.
|
|
57
|
+
*/
|
|
58
|
+
export declare const PlSegment: React.ForwardRefExoticComponent<PlSegmentProps & React.RefAttributes<HTMLElement>>;
|
|
59
|
+
/**
|
|
60
|
+
* Two or more choices in one pill, exactly one of them taken.
|
|
61
|
+
*
|
|
62
|
+
* Underneath it is a radio group, and that is the whole accessibility argument:
|
|
63
|
+
* a segmented button *is* "exactly one of these", so it gets
|
|
64
|
+
* `role="radiogroup"`, one tab stop for the set, arrow keys within it, and
|
|
65
|
+
* `aria-checked` on the one that is taken. Building it out of `aria-pressed`
|
|
66
|
+
* toggles — which is what a row of buttons would give — would announce four
|
|
67
|
+
* independent switches, three of which happen to be off.
|
|
68
|
+
*
|
|
69
|
+
* The tile slides because its `left`, `top`, `width` and `height` are measured
|
|
70
|
+
* off the chosen segment and animated. Nothing is transformed: the tile is an
|
|
71
|
+
* empty box, and no label is resampled while it travels. That is what lets the
|
|
72
|
+
* house no-transform rule survive a component whose entire point is that
|
|
73
|
+
* something moves.
|
|
74
|
+
*
|
|
75
|
+
* `left`, not `inset-inline-start`: `offsetLeft` is a distance from the left
|
|
76
|
+
* edge and stays one under RTL, and pairing a physical measurement with a
|
|
77
|
+
* logical property is what would break the direction.
|
|
78
|
+
*/
|
|
79
|
+
export declare const PlSegmentedButton: React.ForwardRefExoticComponent<PlSegmentedButtonProps & React.RefAttributes<HTMLDivElement>>;
|