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,94 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { isInfinite, lengthValue, repeatValue, directionValue, useAnimationRun } from '../../internal/animate.js';
|
|
4
|
+
import { cx } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Content scrolling steadily past, forever.
|
|
7
|
+
*
|
|
8
|
+
* The content is laid down twice, and each copy travels exactly its own length
|
|
9
|
+
* plus the gap — so the moment the first copy has left, the second is standing
|
|
10
|
+
* precisely where it began. There is no seam, no jump and no frame where the
|
|
11
|
+
* strip is empty, and none of that depends on measuring anything.
|
|
12
|
+
*
|
|
13
|
+
* What *is* measured is only the speed. A duration would mean a strip of four
|
|
14
|
+
* logos and a strip of forty crossing the same box in the same time, with the
|
|
15
|
+
* long one becoming unreadable; `speed` is pixels per second, so both move at
|
|
16
|
+
* the pace of a reader instead. The strip is re-measured whenever it changes
|
|
17
|
+
* size.
|
|
18
|
+
*
|
|
19
|
+
* `pauseOnHover` is on by default and is not decoration: content moving past a
|
|
20
|
+
* pointer cannot be clicked reliably, and a link inside a marquee that never
|
|
21
|
+
* stops is a link nobody can follow.
|
|
22
|
+
*
|
|
23
|
+
* Only the first copy is read out. The rest carry `aria-hidden`, or a screen
|
|
24
|
+
* reader would announce everything on the strip as many times as it was laid
|
|
25
|
+
* down.
|
|
26
|
+
*/
|
|
27
|
+
export const PlAnimateMarquee = /* @__PURE__ */ React.forwardRef(function PlAnimateMarquee({ duration, delay = 0, easing, repeat = 'infinite', alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, orientation = 'horizontal', reverse = false, speed = 60, gap = '2rem', copies = 2, pauseOnHover = true, className, style, children, ...props }, ref) {
|
|
28
|
+
const run = useAnimationRun({
|
|
29
|
+
trigger,
|
|
30
|
+
play,
|
|
31
|
+
once,
|
|
32
|
+
threshold,
|
|
33
|
+
paused,
|
|
34
|
+
infinite: isInfinite(repeat)
|
|
35
|
+
});
|
|
36
|
+
const boxRef = React.useRef(null);
|
|
37
|
+
const trackRef = React.useRef(null);
|
|
38
|
+
const [travel, setTravel] = React.useState(0);
|
|
39
|
+
const vertical = orientation === 'vertical';
|
|
40
|
+
/**
|
|
41
|
+
* How far one copy has to go, in pixels: its own length plus the gap after
|
|
42
|
+
* it. The gap is read back off the computed style rather than parsed out of
|
|
43
|
+
* the prop, because `'2rem'` is only a number once a font size has been
|
|
44
|
+
* resolved — and the one on the page is the one that matters.
|
|
45
|
+
*/
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
const box = boxRef.current;
|
|
48
|
+
const track = trackRef.current;
|
|
49
|
+
if (!box || !track) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const measure = () => {
|
|
53
|
+
const styles = getComputedStyle(box);
|
|
54
|
+
const gapPx = parseFloat(vertical ? styles.rowGap : styles.columnGap) || 0;
|
|
55
|
+
const size = vertical ? track.offsetHeight : track.offsetWidth;
|
|
56
|
+
setTravel(size + gapPx);
|
|
57
|
+
};
|
|
58
|
+
measure();
|
|
59
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const observer = new ResizeObserver(measure);
|
|
63
|
+
observer.observe(track);
|
|
64
|
+
observer.observe(box);
|
|
65
|
+
return () => observer.disconnect();
|
|
66
|
+
}, [vertical, children]);
|
|
67
|
+
// An explicit duration wins; otherwise the measurement decides, and until the
|
|
68
|
+
// first measurement lands there is a sane number rather than `0ms`, which
|
|
69
|
+
// browsers read as "finish immediately".
|
|
70
|
+
const runDuration = duration ?? (travel > 0 ? (travel / speed) * 1000 : 12000);
|
|
71
|
+
const track = (index) => (_jsx("div", { ref: index === 0 ? trackRef : undefined, className: "plass-marquee-track", "aria-hidden": index === 0 ? undefined : 'true', children: children }, index));
|
|
72
|
+
return (_jsx("div", { ref: (node) => {
|
|
73
|
+
boxRef.current = node;
|
|
74
|
+
run.ref(node);
|
|
75
|
+
if (typeof ref === 'function') {
|
|
76
|
+
ref(node);
|
|
77
|
+
}
|
|
78
|
+
else if (ref) {
|
|
79
|
+
ref.current = node;
|
|
80
|
+
}
|
|
81
|
+
}, className: cx('plass-marquee', vertical && 'plass-marquee-vertical', className), style: {
|
|
82
|
+
'--p-anim-gap': lengthValue(gap),
|
|
83
|
+
// Linear unless a caller insists otherwise: an eased marquee slows at
|
|
84
|
+
// both ends of a loop that has no ends, which reads as the page
|
|
85
|
+
// stuttering.
|
|
86
|
+
...(easing ? { '--p-anim-ease': easing } : {}),
|
|
87
|
+
'--p-anim-duration': `${Math.round(runDuration)}ms`,
|
|
88
|
+
'--p-anim-delay': `${delay}ms`,
|
|
89
|
+
'--p-anim-repeat': repeatValue(repeat),
|
|
90
|
+
'--p-anim-direction': directionValue(reverse ? 'out' : 'in', alternate),
|
|
91
|
+
'--p-anim-state': run.state,
|
|
92
|
+
...style
|
|
93
|
+
}, "data-plass-animation": "marquee", "data-state": run.state, "data-pause-on-hover": pauseOnHover ? '' : undefined, ...run.handlers, ...props, children: Array.from({ length: Math.max(1, copies) }, (_, index) => track(index)) }));
|
|
94
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlAnimateMarquee } from './PlAnimateMarquee.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { PlassAnimateMode, PlassAnimateProps } from '../../types.js';
|
|
4
|
+
export interface PlAnimateRotateProps extends PlassAnimateProps, React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the content turns into place or out of it.
|
|
7
|
+
* @default 'in'
|
|
8
|
+
*/
|
|
9
|
+
mode?: PlassAnimateMode;
|
|
10
|
+
/**
|
|
11
|
+
* The angle it starts at, in degrees. Negative is anticlockwise.
|
|
12
|
+
* @default -180
|
|
13
|
+
*/
|
|
14
|
+
from?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The angle it ends at, in degrees. Together with `from` this is what makes
|
|
17
|
+
* one component cover both a quarter turn into place and an endless spin:
|
|
18
|
+
* `from={0} to={360} repeat="infinite"`.
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
to?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Which point it turns about — any CSS `transform-origin`.
|
|
24
|
+
* @default 'center'
|
|
25
|
+
*/
|
|
26
|
+
origin?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Fades in as it turns. Turn it off for a continuous spin, where a repeating
|
|
29
|
+
* fade would read as flickering.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
fade?: boolean;
|
|
33
|
+
/** Renders something other than a `<div>`. Base UI's own escape hatch. */
|
|
34
|
+
render?: useRender.RenderProp;
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Content turning about a point.
|
|
39
|
+
*
|
|
40
|
+
* Two angles rather than one, which is what lets this be both effects a
|
|
41
|
+
* rotation is ever used for. `from` alone is an arrival — something swinging
|
|
42
|
+
* into place and stopping. `from` and `to` together with `repeat="infinite"`
|
|
43
|
+
* and `easing="linear"` is a spin that never lands, which is what a badge, a
|
|
44
|
+
* loading mark or a decorative glyph wants.
|
|
45
|
+
*
|
|
46
|
+
* Rotation is the one movement the design language allows on a glyph without
|
|
47
|
+
* argument — a chevron is turned rather than redrawn all over the library. What
|
|
48
|
+
* it is not for is text: a rotated word is resampled along its whole length,
|
|
49
|
+
* which is precisely what the rule against transforming a control exists to
|
|
50
|
+
* prevent.
|
|
51
|
+
*/
|
|
52
|
+
export declare const PlAnimateRotate: React.ForwardRefExoticComponent<PlAnimateRotateProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { isInfinite, useAnimateElement } from '../../internal/animate.js';
|
|
4
|
+
import { cx } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Content turning about a point.
|
|
7
|
+
*
|
|
8
|
+
* Two angles rather than one, which is what lets this be both effects a
|
|
9
|
+
* rotation is ever used for. `from` alone is an arrival — something swinging
|
|
10
|
+
* into place and stopping. `from` and `to` together with `repeat="infinite"`
|
|
11
|
+
* and `easing="linear"` is a spin that never lands, which is what a badge, a
|
|
12
|
+
* loading mark or a decorative glyph wants.
|
|
13
|
+
*
|
|
14
|
+
* Rotation is the one movement the design language allows on a glyph without
|
|
15
|
+
* argument — a chevron is turned rather than redrawn all over the library. What
|
|
16
|
+
* it is not for is text: a rotated word is resampled along its whole length,
|
|
17
|
+
* which is precisely what the rule against transforming a control exists to
|
|
18
|
+
* prevent.
|
|
19
|
+
*/
|
|
20
|
+
export const PlAnimateRotate = /* @__PURE__ */ React.forwardRef(function PlAnimateRotate({ duration = 440, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = -180, to = 0, origin = 'center', fade = true, render, className, style, children, ...props }, ref) {
|
|
21
|
+
const animate = useAnimateElement({
|
|
22
|
+
effect: 'rotate',
|
|
23
|
+
duration,
|
|
24
|
+
delay,
|
|
25
|
+
easing,
|
|
26
|
+
repeat,
|
|
27
|
+
alternate,
|
|
28
|
+
mode,
|
|
29
|
+
angle: `${from}deg`,
|
|
30
|
+
angleTo: `${to}deg`,
|
|
31
|
+
opacity: fade ? 0 : 1,
|
|
32
|
+
trigger,
|
|
33
|
+
play,
|
|
34
|
+
once,
|
|
35
|
+
threshold,
|
|
36
|
+
paused,
|
|
37
|
+
infinite: isInfinite(repeat)
|
|
38
|
+
});
|
|
39
|
+
return useRender({
|
|
40
|
+
render,
|
|
41
|
+
ref: [ref, animate.ref],
|
|
42
|
+
props: {
|
|
43
|
+
...props,
|
|
44
|
+
className: cx(animate.className, className),
|
|
45
|
+
style: { transformOrigin: origin, ...animate.style, ...style },
|
|
46
|
+
...animate.props,
|
|
47
|
+
children
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlAnimateRotate } from './PlAnimateRotate.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { PlassAnimateMode, PlassAnimateProps, PlassSide } from '../../types.js';
|
|
4
|
+
export interface PlAnimateSlideProps extends PlassAnimateProps, React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the content slides in or slides away. `out` leaves by the same edge
|
|
7
|
+
* it would have come from.
|
|
8
|
+
* @default 'in'
|
|
9
|
+
*/
|
|
10
|
+
mode?: PlassAnimateMode;
|
|
11
|
+
/**
|
|
12
|
+
* Which edge it travels from. Physical, as `PlassSide` is everywhere — a
|
|
13
|
+
* panel coming down from the top comes from the top in every writing
|
|
14
|
+
* direction.
|
|
15
|
+
* @default 'bottom'
|
|
16
|
+
*/
|
|
17
|
+
from?: PlassSide;
|
|
18
|
+
/**
|
|
19
|
+
* How far it travels — a CSS length, or a number in pixels. `'100%'` is the
|
|
20
|
+
* element's own width or height, which is what makes it appear from behind
|
|
21
|
+
* its own edge.
|
|
22
|
+
* @default '100%'
|
|
23
|
+
*/
|
|
24
|
+
distance?: number | string;
|
|
25
|
+
/**
|
|
26
|
+
* Fades in as it slides.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
fade?: boolean;
|
|
30
|
+
/** Renders something other than a `<div>`. Base UI's own escape hatch. */
|
|
31
|
+
render?: useRender.RenderProp;
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Content travelling in from one edge.
|
|
36
|
+
*
|
|
37
|
+
* The default distance is the element's own size, so it starts exactly out of
|
|
38
|
+
* frame and arrives without ever having been half drawn somewhere it does not
|
|
39
|
+
* belong. Put it in a box with `overflow: hidden` and the effect is a panel
|
|
40
|
+
* appearing from behind that box's edge.
|
|
41
|
+
*
|
|
42
|
+
* A slide moves the element, so what is *around* it does not move: this is a
|
|
43
|
+
* `translate` rather than a change of layout, and nothing on the page reflows
|
|
44
|
+
* while it runs. For a much shorter travel over a list of things, one after
|
|
45
|
+
* another, use PlAnimateAppear.
|
|
46
|
+
*/
|
|
47
|
+
export declare const PlAnimateSlide: React.ForwardRefExoticComponent<PlAnimateSlideProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { isInfinite, slideOffsets, useAnimateElement } from '../../internal/animate.js';
|
|
4
|
+
import { cx } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Content travelling in from one edge.
|
|
7
|
+
*
|
|
8
|
+
* The default distance is the element's own size, so it starts exactly out of
|
|
9
|
+
* frame and arrives without ever having been half drawn somewhere it does not
|
|
10
|
+
* belong. Put it in a box with `overflow: hidden` and the effect is a panel
|
|
11
|
+
* appearing from behind that box's edge.
|
|
12
|
+
*
|
|
13
|
+
* A slide moves the element, so what is *around* it does not move: this is a
|
|
14
|
+
* `translate` rather than a change of layout, and nothing on the page reflows
|
|
15
|
+
* while it runs. For a much shorter travel over a list of things, one after
|
|
16
|
+
* another, use PlAnimateAppear.
|
|
17
|
+
*/
|
|
18
|
+
export const PlAnimateSlide = /* @__PURE__ */ React.forwardRef(function PlAnimateSlide({ duration = 360, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = 'bottom', distance = '100%', fade = true, render, className, style, children, ...props }, ref) {
|
|
19
|
+
const { x, y } = slideOffsets(from, distance);
|
|
20
|
+
const animate = useAnimateElement({
|
|
21
|
+
effect: 'slide',
|
|
22
|
+
duration,
|
|
23
|
+
delay,
|
|
24
|
+
easing,
|
|
25
|
+
repeat,
|
|
26
|
+
alternate,
|
|
27
|
+
mode,
|
|
28
|
+
x,
|
|
29
|
+
y,
|
|
30
|
+
opacity: fade ? 0 : 1,
|
|
31
|
+
trigger,
|
|
32
|
+
play,
|
|
33
|
+
once,
|
|
34
|
+
threshold,
|
|
35
|
+
paused,
|
|
36
|
+
infinite: isInfinite(repeat)
|
|
37
|
+
});
|
|
38
|
+
return useRender({
|
|
39
|
+
render,
|
|
40
|
+
ref: [ref, animate.ref],
|
|
41
|
+
props: {
|
|
42
|
+
...props,
|
|
43
|
+
className: cx(animate.className, className),
|
|
44
|
+
style: { ...animate.style, ...style },
|
|
45
|
+
...animate.props,
|
|
46
|
+
children
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlAnimateSlide } from './PlAnimateSlide.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassAnimateProps } from '../../types.js';
|
|
3
|
+
export interface PlAnimateTypingProps extends Omit<PlassAnimateProps, 'alternate' | 'easing'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
4
|
+
/** The text, when it is easier to pass than to nest. Overrides `children`. */
|
|
5
|
+
text?: string;
|
|
6
|
+
/**
|
|
7
|
+
* How fast it is typed, in characters per second.
|
|
8
|
+
* @default 24
|
|
9
|
+
*/
|
|
10
|
+
speed?: number;
|
|
11
|
+
/**
|
|
12
|
+
* How long the finished text is held before it repeats, in milliseconds.
|
|
13
|
+
* @default 1400
|
|
14
|
+
*/
|
|
15
|
+
hold?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Deletes the text again before repeating, rather than clearing it in one
|
|
18
|
+
* frame. Only means anything when `repeat` is more than once.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
erase?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* How fast it is deleted, in characters per second. Deleting is usually about
|
|
24
|
+
* twice as fast as typing, which is what a person actually does.
|
|
25
|
+
* @default twice `speed`
|
|
26
|
+
*/
|
|
27
|
+
eraseSpeed?: number;
|
|
28
|
+
/**
|
|
29
|
+
* The block after the text.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
caret?: boolean;
|
|
33
|
+
/** What the caret is drawn as. @default '|' */
|
|
34
|
+
caretChar?: React.ReactNode;
|
|
35
|
+
/** The text to type. Only text is typed — see below. */
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Text appearing one character at a time.
|
|
40
|
+
*
|
|
41
|
+
* The whole string is in the document from the first frame — in a clipped box
|
|
42
|
+
* for a screen reader, which reads it once and is not made to sit through the
|
|
43
|
+
* performance — and what animates is a visible copy that is `aria-hidden`. So
|
|
44
|
+
* the effect costs a reader who cannot see it nothing, and costs a reader who
|
|
45
|
+
* can nothing either: the box is not laid out from the characters that have
|
|
46
|
+
* arrived, so the text around it does not reflow on every frame.
|
|
47
|
+
*
|
|
48
|
+
* `repeat`, `hold` and `erase` are what make it a loop: type, hold, delete,
|
|
49
|
+
* type again. Without `erase` a repeat clears in one frame, which is right for
|
|
50
|
+
* a line that is being replaced rather than rewritten.
|
|
51
|
+
*
|
|
52
|
+
* Only text is typed. Pass a string, or strings; an element among the children
|
|
53
|
+
* contributes its text and nothing about its markup, because there is no honest
|
|
54
|
+
* way to reveal half of a link.
|
|
55
|
+
*/
|
|
56
|
+
export declare const PlAnimateTyping: React.ForwardRefExoticComponent<PlAnimateTypingProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { isInfinite, useAnimationRun, usePrefersReducedMotion } from '../../internal/animate.js';
|
|
4
|
+
import { srOnlyClasses } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Everything typeable in a node, flattened.
|
|
7
|
+
*
|
|
8
|
+
* Elements are deliberately not walked into. A typewriter reveals a string one
|
|
9
|
+
* grapheme at a time, and there is no honest way to reveal half of a `<strong>`
|
|
10
|
+
* — the effect is over text, so its input is text.
|
|
11
|
+
*/
|
|
12
|
+
function textOf(node) {
|
|
13
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
14
|
+
return String(node);
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(node)) {
|
|
17
|
+
return node.map(textOf).join('');
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The text split the way a reader would split it.
|
|
23
|
+
*
|
|
24
|
+
* Not `[...text]`, and not `text.split('')`. A code point is not a character:
|
|
25
|
+
* `👩👩👧` is seven of them, `한` typed on a Korean keyboard can be three, and a
|
|
26
|
+
* typewriter that advances by code points spends four frames assembling an
|
|
27
|
+
* emoji out of parts that mean nothing on their own. `Intl.Segmenter` knows
|
|
28
|
+
* where the boundaries actually are; the spread is the fallback for a runtime
|
|
29
|
+
* that does not have it.
|
|
30
|
+
*/
|
|
31
|
+
function graphemesOf(text, locale) {
|
|
32
|
+
if (typeof Intl !== 'undefined' && 'Segmenter' in Intl) {
|
|
33
|
+
const segmenter = new Intl.Segmenter(locale, { granularity: 'grapheme' });
|
|
34
|
+
return [...segmenter.segment(text)].map((segment) => segment.segment);
|
|
35
|
+
}
|
|
36
|
+
return [...text];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Text appearing one character at a time.
|
|
40
|
+
*
|
|
41
|
+
* The whole string is in the document from the first frame — in a clipped box
|
|
42
|
+
* for a screen reader, which reads it once and is not made to sit through the
|
|
43
|
+
* performance — and what animates is a visible copy that is `aria-hidden`. So
|
|
44
|
+
* the effect costs a reader who cannot see it nothing, and costs a reader who
|
|
45
|
+
* can nothing either: the box is not laid out from the characters that have
|
|
46
|
+
* arrived, so the text around it does not reflow on every frame.
|
|
47
|
+
*
|
|
48
|
+
* `repeat`, `hold` and `erase` are what make it a loop: type, hold, delete,
|
|
49
|
+
* type again. Without `erase` a repeat clears in one frame, which is right for
|
|
50
|
+
* a line that is being replaced rather than rewritten.
|
|
51
|
+
*
|
|
52
|
+
* Only text is typed. Pass a string, or strings; an element among the children
|
|
53
|
+
* contributes its text and nothing about its markup, because there is no honest
|
|
54
|
+
* way to reveal half of a link.
|
|
55
|
+
*/
|
|
56
|
+
export const PlAnimateTyping = /* @__PURE__ */ React.forwardRef(function PlAnimateTyping({ text, speed = 24, hold = 1400, erase = false, eraseSpeed, caret = true, caretChar = '|', duration, delay = 0, repeat = 1, paused, trigger = 'mount', play, once = true, threshold = 0.2, className, style, children, ...props }, ref) {
|
|
57
|
+
const run = useAnimationRun({
|
|
58
|
+
trigger,
|
|
59
|
+
play,
|
|
60
|
+
once,
|
|
61
|
+
threshold,
|
|
62
|
+
paused,
|
|
63
|
+
infinite: isInfinite(repeat)
|
|
64
|
+
});
|
|
65
|
+
const reduced = usePrefersReducedMotion();
|
|
66
|
+
const source = text ?? textOf(children);
|
|
67
|
+
const graphemes = React.useMemo(() => graphemesOf(source), [source]);
|
|
68
|
+
const total = graphemes.length;
|
|
69
|
+
const [shown, setShown] = React.useState(0);
|
|
70
|
+
/**
|
|
71
|
+
* How far along it is, outside React's state.
|
|
72
|
+
*
|
|
73
|
+
* The typing loop is a chain of timeouts rather than a render, so pausing
|
|
74
|
+
* tears it down and resuming builds a new one — and a new one has to know
|
|
75
|
+
* where the old one stopped. Reading `shown` would put the effect in a loop
|
|
76
|
+
* with its own output.
|
|
77
|
+
*/
|
|
78
|
+
const progress = React.useRef(0);
|
|
79
|
+
/**
|
|
80
|
+
* `duration` is honoured as the time for the whole string, because a caller
|
|
81
|
+
* who has set a duration on every other PlAnimate component will reach for it
|
|
82
|
+
* here too. `speed` is the natural unit for a typewriter — a long paragraph
|
|
83
|
+
* and a short one should be typed at the same pace, not in the same time — so
|
|
84
|
+
* it is the default and the duration overrides it.
|
|
85
|
+
*/
|
|
86
|
+
const typeDelay = duration && total > 0 ? duration / total : 1000 / Math.max(speed, 1);
|
|
87
|
+
const deleteDelay = 1000 / Math.max(eraseSpeed ?? speed * 2, 1);
|
|
88
|
+
// A new string starts a new performance rather than continuing the last.
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
progress.current = 0;
|
|
91
|
+
}, [total]);
|
|
92
|
+
React.useEffect(() => {
|
|
93
|
+
if (reduced || total === 0) {
|
|
94
|
+
// Not "nothing happens" — the text is simply there, which is the only
|
|
95
|
+
// outcome that still delivers what the component was carrying.
|
|
96
|
+
setShown(total);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!run.started) {
|
|
100
|
+
// Waiting is empty, not finished: a typewriter that showed its whole
|
|
101
|
+
// string until it scrolled into view and then blanked would be worse than
|
|
102
|
+
// no effect at all.
|
|
103
|
+
progress.current = 0;
|
|
104
|
+
setShown(0);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (paused) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let cancelled = false;
|
|
111
|
+
let timer;
|
|
112
|
+
let count = progress.current;
|
|
113
|
+
let pass = 1;
|
|
114
|
+
let deleting = false;
|
|
115
|
+
const passes = repeat === 'infinite' ? Infinity : Math.max(1, repeat);
|
|
116
|
+
if (count >= total && passes === 1) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const step = () => {
|
|
120
|
+
if (cancelled) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (deleting) {
|
|
124
|
+
count -= 1;
|
|
125
|
+
progress.current = count;
|
|
126
|
+
setShown(count);
|
|
127
|
+
if (count <= 0) {
|
|
128
|
+
deleting = false;
|
|
129
|
+
pass += 1;
|
|
130
|
+
}
|
|
131
|
+
timer = setTimeout(step, deleting ? deleteDelay : typeDelay);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
count += 1;
|
|
135
|
+
progress.current = count;
|
|
136
|
+
setShown(count);
|
|
137
|
+
if (count < total) {
|
|
138
|
+
timer = setTimeout(step, typeDelay);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (pass >= passes) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (erase) {
|
|
145
|
+
deleting = true;
|
|
146
|
+
timer = setTimeout(step, hold);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
pass += 1;
|
|
150
|
+
timer = setTimeout(() => {
|
|
151
|
+
if (cancelled) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
count = 0;
|
|
155
|
+
progress.current = 0;
|
|
156
|
+
setShown(0);
|
|
157
|
+
timer = setTimeout(step, typeDelay);
|
|
158
|
+
}, hold);
|
|
159
|
+
};
|
|
160
|
+
setShown(count);
|
|
161
|
+
// Resuming picks up at the next character; starting waits out the delay.
|
|
162
|
+
timer = setTimeout(step, count === 0 ? delay : typeDelay);
|
|
163
|
+
return () => {
|
|
164
|
+
cancelled = true;
|
|
165
|
+
clearTimeout(timer);
|
|
166
|
+
};
|
|
167
|
+
}, [run.started, paused, reduced, total, typeDelay, deleteDelay, delay, hold, erase, repeat]);
|
|
168
|
+
return (_jsxs("div", { ref: (node) => {
|
|
169
|
+
run.ref(node);
|
|
170
|
+
if (typeof ref === 'function') {
|
|
171
|
+
ref(node);
|
|
172
|
+
}
|
|
173
|
+
else if (ref) {
|
|
174
|
+
ref.current = node;
|
|
175
|
+
}
|
|
176
|
+
}, className: className, style: style, "data-plass-animation": "typing", "data-state": run.state, ...run.handlers, ...props, children: [_jsx("span", { className: srOnlyClasses, children: source }), _jsxs("span", { "aria-hidden": "true", className: "whitespace-pre-wrap", children: [graphemes.slice(0, shown).join(''), caret ? _jsx("span", { className: "plass-caret", children: caretChar }) : null] })] }));
|
|
177
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlAnimateTyping } from './PlAnimateTyping.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { PlassAnimateMode, PlassAnimateProps } from '../../types.js';
|
|
4
|
+
export interface PlAnimateZoomProps extends PlassAnimateProps, React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the content comes forward or falls away.
|
|
7
|
+
* @default 'in'
|
|
8
|
+
*/
|
|
9
|
+
mode?: PlassAnimateMode;
|
|
10
|
+
/**
|
|
11
|
+
* The scale it starts from, as a multiple of its final size. Above `1` it
|
|
12
|
+
* arrives oversized and settles back, which reads as coming *towards* the
|
|
13
|
+
* reader rather than up out of the page.
|
|
14
|
+
* @default 0.4
|
|
15
|
+
*/
|
|
16
|
+
from?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Fades in as it zooms.
|
|
19
|
+
* @default true
|
|
20
|
+
*/
|
|
21
|
+
fade?: boolean;
|
|
22
|
+
/** Renders something other than a `<div>`. Base UI's own escape hatch. */
|
|
23
|
+
render?: useRender.RenderProp;
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Content arriving from the middle of where it will end up.
|
|
28
|
+
*
|
|
29
|
+
* The same arithmetic as Grow at more than twice the distance, and always about
|
|
30
|
+
* the centre — which is the whole difference. A Grow unfolds from somewhere; a
|
|
31
|
+
* Zoom comes at you. Use it for the one thing on a screen that is meant to
|
|
32
|
+
* interrupt: a confirmation, a result, a number that has just landed.
|
|
33
|
+
*
|
|
34
|
+
* There is no `origin`, on purpose. A zoom anchored to a corner is a grow, and
|
|
35
|
+
* the library does not offer two spellings of one idea.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PlAnimateZoom: React.ForwardRefExoticComponent<PlAnimateZoomProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { isInfinite, useAnimateElement } from '../../internal/animate.js';
|
|
4
|
+
import { cx } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Content arriving from the middle of where it will end up.
|
|
7
|
+
*
|
|
8
|
+
* The same arithmetic as Grow at more than twice the distance, and always about
|
|
9
|
+
* the centre — which is the whole difference. A Grow unfolds from somewhere; a
|
|
10
|
+
* Zoom comes at you. Use it for the one thing on a screen that is meant to
|
|
11
|
+
* interrupt: a confirmation, a result, a number that has just landed.
|
|
12
|
+
*
|
|
13
|
+
* There is no `origin`, on purpose. A zoom anchored to a corner is a grow, and
|
|
14
|
+
* the library does not offer two spellings of one idea.
|
|
15
|
+
*/
|
|
16
|
+
export const PlAnimateZoom = /* @__PURE__ */ React.forwardRef(function PlAnimateZoom({ duration = 320, delay = 0, easing, repeat = 1, alternate, paused, trigger = 'mount', play, once = true, threshold = 0.2, mode = 'in', from = 0.4, fade = true, render, className, style, children, ...props }, ref) {
|
|
17
|
+
const animate = useAnimateElement({
|
|
18
|
+
effect: 'zoom',
|
|
19
|
+
duration,
|
|
20
|
+
delay,
|
|
21
|
+
easing,
|
|
22
|
+
repeat,
|
|
23
|
+
alternate,
|
|
24
|
+
mode,
|
|
25
|
+
scale: from,
|
|
26
|
+
opacity: fade ? 0 : 1,
|
|
27
|
+
trigger,
|
|
28
|
+
play,
|
|
29
|
+
once,
|
|
30
|
+
threshold,
|
|
31
|
+
paused,
|
|
32
|
+
infinite: isInfinite(repeat)
|
|
33
|
+
});
|
|
34
|
+
return useRender({
|
|
35
|
+
render,
|
|
36
|
+
ref: [ref, animate.ref],
|
|
37
|
+
props: {
|
|
38
|
+
...props,
|
|
39
|
+
className: cx(animate.className, className),
|
|
40
|
+
style: { transformOrigin: 'center', ...animate.style, ...style },
|
|
41
|
+
...animate.props,
|
|
42
|
+
children
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlAnimateZoom } from './PlAnimateZoom.js';
|