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,209 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Menu as BaseUIMenu } from '@base-ui/react/menu';
|
|
4
|
+
import { ContextMenu as BaseUIContextMenu } from '@base-ui/react/context-menu';
|
|
5
|
+
import { MenuContext } from '../../internal/menu.js';
|
|
6
|
+
import { CheckIcon, ChevronIcon, DotIcon } from '../../internal/icons.js';
|
|
7
|
+
import { controlTextLeadingClasses, cx, gapClasses, glassClasses, hasContent, iconClasses, metaTextClasses, radiusClasses, surfaceSlots, transitionClasses } from '../../internal/styles.js';
|
|
8
|
+
/* ---------------------------------------------------------------------------
|
|
9
|
+
* The surface
|
|
10
|
+
* ------------------------------------------------------------------------- */
|
|
11
|
+
/**
|
|
12
|
+
* The popup, which is `PlSelect`'s popup to the pixel — deliberately, because a
|
|
13
|
+
* select *is* a menu that remembers what you picked, and two floating lists of
|
|
14
|
+
* rows that do not match are two lists the eye has to learn separately.
|
|
15
|
+
*/
|
|
16
|
+
const popupClasses = /* @__PURE__ */ [
|
|
17
|
+
glassClasses,
|
|
18
|
+
'max-h-[min(24rem,var(--available-height))] min-w-40 overflow-y-auto overscroll-contain',
|
|
19
|
+
'border bg-(--plass-glass-press) p-1',
|
|
20
|
+
'[border-color:var(--plass-glass-line)]',
|
|
21
|
+
'[box-shadow:var(--plass-shadow-3),var(--plass-gloss-glass)]',
|
|
22
|
+
'[outline:none]',
|
|
23
|
+
// Opacity only. A menu that slides in has moved the row you were already
|
|
24
|
+
// reaching for, which is the one thing a menu must never do.
|
|
25
|
+
'[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
|
|
26
|
+
'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
|
|
27
|
+
].join(' ');
|
|
28
|
+
/**
|
|
29
|
+
* A row's padding, and a ladder of its own rather than the sheet track.
|
|
30
|
+
*
|
|
31
|
+
* A `PlList` row spans a sheet that something else decided the width of; a menu
|
|
32
|
+
* row is inside a popup that is exactly as wide as its longest label. The sheet
|
|
33
|
+
* track's `px-5` at `md` would add 40px to a menu that says "Cut", which is how
|
|
34
|
+
* a five-row menu ends up the width of a dialog.
|
|
35
|
+
*/
|
|
36
|
+
const rowPaddingClasses = {
|
|
37
|
+
default: {
|
|
38
|
+
xs: 'px-1.5 py-0.5',
|
|
39
|
+
sm: 'px-2 py-1',
|
|
40
|
+
md: 'px-2.5 py-1.5',
|
|
41
|
+
lg: 'px-3 py-2',
|
|
42
|
+
xl: 'px-3.5 py-2.5'
|
|
43
|
+
},
|
|
44
|
+
compact: {
|
|
45
|
+
xs: 'px-1 py-0.5',
|
|
46
|
+
sm: 'px-1.5 py-0.5',
|
|
47
|
+
md: 'px-2 py-1',
|
|
48
|
+
lg: 'px-2.5 py-1',
|
|
49
|
+
xl: 'px-3 py-1.5'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A row sits one step down the radius ladder from the popup it is inside: a
|
|
54
|
+
* tile cut out of a sheet cannot carry the sheet's own corner, or the two curves
|
|
55
|
+
* fight along the edge.
|
|
56
|
+
*/
|
|
57
|
+
const rowRadiusClasses = {
|
|
58
|
+
xs: radiusClasses.xs,
|
|
59
|
+
sm: radiusClasses.xs,
|
|
60
|
+
md: radiusClasses.sm,
|
|
61
|
+
lg: radiusClasses.sm,
|
|
62
|
+
xl: radiusClasses.md
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The row, in every one of its shapes — plain, link, submenu trigger, checkbox,
|
|
66
|
+
* radio. They differ in which Base UI part renders them and in nothing else.
|
|
67
|
+
*
|
|
68
|
+
* `data-highlighted` rather than `:hover`, exactly as on a `PlSelect` option: it
|
|
69
|
+
* is also what the arrow keys move, so the mouse and the keyboard light the same
|
|
70
|
+
* row instead of the keyboard lighting nothing.
|
|
71
|
+
*
|
|
72
|
+
* `accented` is a parameter rather than a class the caller appends, and that is
|
|
73
|
+
* not a style preference. Appending `text-(--p-accent)` next to the default
|
|
74
|
+
* `text-(--plass-fg)` puts two utilities of equal specificity on one element,
|
|
75
|
+
* and which of them wins is decided by their order in the generated stylesheet
|
|
76
|
+
* rather than by the order they were written in — so `color="danger"` on a row
|
|
77
|
+
* would silently do nothing. Branching here is what makes only one of the two
|
|
78
|
+
* exist.
|
|
79
|
+
*/
|
|
80
|
+
function rowClasses(size, density, accented, className) {
|
|
81
|
+
return cx('relative flex w-full cursor-pointer items-center select-none', accented ? 'text-(--p-accent)' : 'text-(--plass-fg)', rowPaddingClasses[density][size], rowRadiusClasses[size], gapClasses[size], controlTextLeadingClasses[size], transitionClasses, iconClasses, 'data-[highlighted]:bg-(--p-soft-hover)', 'data-[popup-open]:bg-(--p-soft)', 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
|
|
82
|
+
// Base UI moves focus onto the highlighted row itself, so a ring here would
|
|
83
|
+
// draw a rectangle inside the popup on every arrow press. The tint is the
|
|
84
|
+
// focus indicator, which is what makes it the same one the mouse gets.
|
|
85
|
+
'[outline:none]', className);
|
|
86
|
+
}
|
|
87
|
+
/** The fixed-width slot a check, a dot or a `startIcon` lands in. */
|
|
88
|
+
const slotClasses = 'flex h-[1lh] w-[1.2em] shrink-0 items-center justify-center';
|
|
89
|
+
/** The muted run of text a shortcut is set in, at the end of the row. */
|
|
90
|
+
function shortcutClasses(size) {
|
|
91
|
+
return cx('ms-2 shrink-0 text-(--plass-muted-fg) tabular-nums', metaTextClasses[size]);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The label, and the description under it when there is one.
|
|
95
|
+
*
|
|
96
|
+
* `min-w-0` so a long label truncates rather than pushing the shortcut off the
|
|
97
|
+
* end of a popup that has already been positioned.
|
|
98
|
+
*/
|
|
99
|
+
function RowBody({ children, description, size }) {
|
|
100
|
+
if (!hasContent(description)) {
|
|
101
|
+
return _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: children });
|
|
102
|
+
}
|
|
103
|
+
return (_jsxs("span", { className: "flex min-w-0 flex-1 flex-col text-start", children: [_jsx("span", { className: "truncate", children: children }), _jsx("span", { className: cx('truncate text-(--plass-muted-fg)', metaTextClasses[size]), children: description })] }));
|
|
104
|
+
}
|
|
105
|
+
/* ---------------------------------------------------------------------------
|
|
106
|
+
* The parts
|
|
107
|
+
* ------------------------------------------------------------------------- */
|
|
108
|
+
/**
|
|
109
|
+
* One row of a menu.
|
|
110
|
+
*
|
|
111
|
+
* Renders a real `<a>` when it is given an `href` and Base UI's own item
|
|
112
|
+
* otherwise — the same split `PlListItem` makes, for the same reason. A menu of
|
|
113
|
+
* links that are not links cannot be opened in a new tab, cannot be copied, and
|
|
114
|
+
* tells a screen reader the wrong thing about every one of them.
|
|
115
|
+
*/
|
|
116
|
+
export function PlMenuItem({ onClick, href, target, startIcon, endIcon, shortcut, description, color, closeOnClick = true, disabled = false, label, children, className, style }) {
|
|
117
|
+
const { size, density } = React.useContext(MenuContext);
|
|
118
|
+
const body = (_jsxs(_Fragment, { children: [hasContent(startIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: startIcon })) : null, _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
|
|
119
|
+
// A row can name its own family — `color="danger"` on the one that deletes —
|
|
120
|
+
// and the slots are re-declared on the row so the tint, the hairline and the
|
|
121
|
+
// text all turn over together rather than one of them staying indigo.
|
|
122
|
+
const slots = color ? surfaceSlots(color, 0) : undefined;
|
|
123
|
+
const rowStyle = slots || style ? { ...slots, ...style } : undefined;
|
|
124
|
+
if (href !== undefined) {
|
|
125
|
+
return (_jsx(BaseUIMenu.LinkItem, { href: href, target: target, label: label, closeOnClick: closeOnClick, onClick: onClick, className: rowClasses(size, density, Boolean(color), className), style: rowStyle, children: body }));
|
|
126
|
+
}
|
|
127
|
+
return (_jsx(BaseUIMenu.Item, { disabled: disabled, label: label, closeOnClick: closeOnClick, onClick: onClick, className: rowClasses(size, density, Boolean(color), className), style: rowStyle, children: body }));
|
|
128
|
+
}
|
|
129
|
+
/** A row that ticks. The tick lands in the same slot a `startIcon` would. */
|
|
130
|
+
export function PlMenuCheckboxItem({ checked, defaultChecked, onCheckedChange, endIcon, shortcut, description, color, closeOnClick = false, disabled = false, label, children, className, style }) {
|
|
131
|
+
const { size, density } = React.useContext(MenuContext);
|
|
132
|
+
const slots = color ? surfaceSlots(color, 0) : undefined;
|
|
133
|
+
return (_jsxs(BaseUIMenu.CheckboxItem, { checked: checked, defaultChecked: defaultChecked, onCheckedChange: (next) => onCheckedChange?.(next), disabled: disabled, label: label, closeOnClick: closeOnClick, className: rowClasses(size, density, Boolean(color), className), style: slots || style ? { ...slots, ...style } : undefined, children: [_jsx("span", { className: cx(slotClasses, 'text-(--p-accent)'), children: _jsx(BaseUIMenu.CheckboxItemIndicator, { className: "flex items-center justify-center", children: _jsx(CheckIcon, {}) }) }), _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
|
|
134
|
+
}
|
|
135
|
+
/** One choice out of a set. Wraps the rows that make up the set. */
|
|
136
|
+
export function PlMenuRadioGroup({ value, defaultValue, onValueChange, disabled = false, children, className }) {
|
|
137
|
+
return (_jsx(BaseUIMenu.RadioGroup, { value: value, defaultValue: defaultValue, onValueChange: (next) => onValueChange?.(next), disabled: disabled, className: className, children: children }));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A row inside a `PlMenuRadioGroup`.
|
|
141
|
+
*
|
|
142
|
+
* Marked with a dot rather than a tick, which is the same distinction
|
|
143
|
+
* `PlCheckbox` and `PlRadioGroup` make everywhere else: a tick says "and", a dot
|
|
144
|
+
* says "instead of".
|
|
145
|
+
*/
|
|
146
|
+
export function PlMenuRadioItem({ value, endIcon, shortcut, description, color, closeOnClick = false, disabled = false, label, children, className, style }) {
|
|
147
|
+
const { size, density } = React.useContext(MenuContext);
|
|
148
|
+
const slots = color ? surfaceSlots(color, 0) : undefined;
|
|
149
|
+
return (_jsxs(BaseUIMenu.RadioItem, { value: value, disabled: disabled, label: label, closeOnClick: closeOnClick, className: rowClasses(size, density, Boolean(color), className), style: slots || style ? { ...slots, ...style } : undefined, children: [_jsx("span", { className: cx(slotClasses, 'text-(--p-accent)'), children: _jsx(BaseUIMenu.RadioItemIndicator, { className: "flex items-center justify-center", children: _jsx(DotIcon, {}) }) }), _jsx(RowBody, { description: description, size: size, children: children }), hasContent(endIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: endIcon })) : null, hasContent(shortcut) ? _jsx("span", { className: shortcutClasses(size), children: shortcut }) : null] }));
|
|
150
|
+
}
|
|
151
|
+
/** A named run of rows. The label is a heading, not a row — it cannot be picked. */
|
|
152
|
+
export function PlMenuGroup({ label, children, className }) {
|
|
153
|
+
const { size, density } = React.useContext(MenuContext);
|
|
154
|
+
return (_jsxs(BaseUIMenu.Group, { className: className, children: [hasContent(label) ? (_jsx(BaseUIMenu.GroupLabel, { className: cx(rowPaddingClasses[density][size], metaTextClasses[size], 'font-semibold tracking-wide text-(--plass-muted-fg) uppercase'), children: label })) : null, children] }));
|
|
155
|
+
}
|
|
156
|
+
/** The hairline between two runs of rows. */
|
|
157
|
+
export function PlMenuSeparator({ className, ...props }) {
|
|
158
|
+
return (_jsx(BaseUIMenu.Separator, { className: cx('-mx-1 my-1 h-px bg-(--plass-divider)', className), ...props }));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A menu inside a menu.
|
|
162
|
+
*
|
|
163
|
+
* The row that opens it is the same row every other item is, wearing a chevron —
|
|
164
|
+
* and it opens on hover, on <kbd>Enter</kbd> and on the arrow key that points at
|
|
165
|
+
* it, all of which is Base UI's. What is here is the surface and the glyph.
|
|
166
|
+
*
|
|
167
|
+
* Nesting is unlimited: a `PlMenuSubmenu` renders its children inside a popup
|
|
168
|
+
* that is itself a menu, so a submenu of a submenu needs no different component.
|
|
169
|
+
*/
|
|
170
|
+
export function PlMenuSubmenu({ label, startIcon, disabled = false, side = 'right', sideOffset = 4, children, className, style }) {
|
|
171
|
+
const { size, density, color } = React.useContext(MenuContext);
|
|
172
|
+
return (_jsxs(BaseUIMenu.SubmenuRoot, { children: [_jsxs(BaseUIMenu.SubmenuTrigger, { disabled: disabled, className: rowClasses(size, density, false), children: [hasContent(startIcon) ? (_jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg)'), children: startIcon })) : null, _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: label }), _jsx("span", { className: cx(slotClasses, 'text-(--plass-muted-fg) -rotate-90'), children: _jsx(ChevronIcon, {}) })] }), _jsx(BaseUIMenu.Portal, { children: _jsx(BaseUIMenu.Positioner, { className: "plass-portal z-50 [outline:none]", side: side, sideOffset: sideOffset, align: "start", children: _jsx(BaseUIMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: children }) }) })] }));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* A list of actions that appears when something is pressed.
|
|
176
|
+
*
|
|
177
|
+
* Everything that makes a menu a menu rather than a floating list of `<div>`s is
|
|
178
|
+
* Base UI's: roving focus with the arrow keys, <kbd>Home</kbd> and
|
|
179
|
+
* <kbd>End</kbd>, typeahead, <kbd>Esc</kbd>, closing on an outside click,
|
|
180
|
+
* restoring focus to the trigger, submenus opening on hover with the safe
|
|
181
|
+
* triangle so a diagonal reach does not close them, and the `menu` / `menuitem`
|
|
182
|
+
* roles that make any of it mean something to a screen reader. What is here is
|
|
183
|
+
* the surface, the ladders and the row layout.
|
|
184
|
+
*
|
|
185
|
+
* The rows are **composed rather than passed as data** — the opposite of
|
|
186
|
+
* `PlSelect`, and deliberately. A select's options are values from a list a
|
|
187
|
+
* caller already has; a menu's rows are *code*, each one a different handler, a
|
|
188
|
+
* different icon, sometimes a submenu. Data would mean an `items` type with a
|
|
189
|
+
* variant for every shape a row can take, which is a component tree spelled as a
|
|
190
|
+
* discriminated union.
|
|
191
|
+
*/
|
|
192
|
+
export function PlMenu({ size = 'md', color = 'primary', density = 'default', trigger, open, defaultOpen, onOpenChange, side = 'bottom', align = 'start', sideOffset = 6, modal = true, openOnHover = false, loopFocus = true, disabled = false, className, style, children }) {
|
|
193
|
+
const context = React.useMemo(() => ({ size, color, density }), [size, color, density]);
|
|
194
|
+
return (_jsx(MenuContext.Provider, { value: context, children: _jsxs(BaseUIMenu.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next), modal: modal, loopFocus: loopFocus, disabled: disabled, children: [trigger ? (_jsx(BaseUIMenu.Trigger, { render: trigger, openOnHover: openOnHover, disabled: disabled })) : null, _jsx(BaseUIMenu.Portal, { children: _jsx(BaseUIMenu.Positioner, { className: "plass-portal z-50 [outline:none]", side: side, align: align, sideOffset: sideOffset, children: _jsx(BaseUIMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: children }) }) })] }) }));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The same menu, opened by a right-click or a long press instead of by a button.
|
|
198
|
+
*
|
|
199
|
+
* It takes the rows as `content` and the area as `children`, which is
|
|
200
|
+
* `PlTooltip`'s shape rather than `PlMenu`'s — because here the trigger is not
|
|
201
|
+
* one element you hand over, it is a region of the page, and the region is the
|
|
202
|
+
* thing being wrapped. Base UI positions the popup at the pointer rather than
|
|
203
|
+
* against an anchor, and the long press is what makes it reachable on a touch
|
|
204
|
+
* screen at all.
|
|
205
|
+
*/
|
|
206
|
+
export function PlContextMenu({ size = 'md', color = 'primary', density = 'default', content, children, open, defaultOpen, onOpenChange, loopFocus = true, disabled = false, className, style }) {
|
|
207
|
+
const context = React.useMemo(() => ({ size, color, density }), [size, color, density]);
|
|
208
|
+
return (_jsx(MenuContext.Provider, { value: context, children: _jsxs(BaseUIContextMenu.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: (next) => onOpenChange?.(next), loopFocus: loopFocus, disabled: disabled, children: [_jsx(BaseUIContextMenu.Trigger, { children: children }), _jsx(BaseUIContextMenu.Portal, { children: _jsx(BaseUIContextMenu.Positioner, { className: "plass-portal z-50 [outline:none]", children: _jsx(BaseUIContextMenu.Popup, { className: cx(popupClasses, radiusClasses[size], controlTextLeadingClasses[size], className), style: { ...surfaceSlots(color, 3), ...style }, children: content }) }) })] }) }));
|
|
209
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PlContextMenu, PlMenu, PlMenuCheckboxItem, PlMenuGroup, PlMenuItem, PlMenuRadioGroup, PlMenuRadioItem, PlMenuSeparator, PlMenuSubmenu } from './PlMenu.js';
|
|
2
|
+
export type { PlContextMenuProps, PlMenuCheckboxItemProps, PlMenuGroupProps, PlMenuItemProps, PlMenuProps, PlMenuRadioGroupProps, PlMenuRadioItemProps, PlMenuSeparatorProps, PlMenuSubmenuProps } from './PlMenu.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlContextMenu, PlMenu, PlMenuCheckboxItem, PlMenuGroup, PlMenuItem, PlMenuRadioGroup, PlMenuRadioItem, PlMenuSeparator, PlMenuSubmenu } from './PlMenu.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Dialog as BaseUIDialog } from '@base-ui/react/dialog';
|
|
3
|
+
import type { PlassStyleProps } from '../../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A modal takes `size`, `color` and `density` and stops there.
|
|
6
|
+
*
|
|
7
|
+
* There is no `variant`: the three materials answer "how much does this surface
|
|
8
|
+
* assert itself against the page around it", and a modal has already taken the
|
|
9
|
+
* page. There is no `elevation` either — see `popupClasses`.
|
|
10
|
+
*/
|
|
11
|
+
export interface PlModalProps extends Pick<PlassStyleProps, 'size' | 'color' | 'density'>, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'children'> {
|
|
12
|
+
/** The modal is shown. Use with `onOpenChange` for a controlled modal. */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/** Whether it starts open, for an uncontrolled one. */
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
onOpenChange?: (open: boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The element that opens the modal, wired up by Base UI. Optional — a
|
|
19
|
+
* controlled modal opened from somewhere else in the app needs no trigger at
|
|
20
|
+
* all, and passing one here is only a convenience for the common case.
|
|
21
|
+
*/
|
|
22
|
+
trigger?: React.ReactElement;
|
|
23
|
+
/** The heading. Rendered as the `<h2>` that names the modal. */
|
|
24
|
+
title?: React.ReactNode;
|
|
25
|
+
/** A line under the title, and the modal's accessible description. */
|
|
26
|
+
description?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The bottom row. Laid out end-aligned, so a pair of buttons needs no wrapper
|
|
29
|
+
* of its own — and `PlModalClose` is what makes one of them dismiss.
|
|
30
|
+
*/
|
|
31
|
+
actions?: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Scores the sheet between the header, the body and the actions instead of
|
|
34
|
+
* separating them with space. Worth turning on the moment the body scrolls:
|
|
35
|
+
* the lines are what say the header stayed put.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
dividers?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Shows the × in the corner.
|
|
41
|
+
*
|
|
42
|
+
* On by default, unlike most booleans in the library. A modal takes the page
|
|
43
|
+
* away until it is answered, and the visible way out should not have to be
|
|
44
|
+
* remembered.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
showClose?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Accessible name of the × button. Never drawn.
|
|
50
|
+
* @default 'Close'
|
|
51
|
+
*/
|
|
52
|
+
closeLabel?: string;
|
|
53
|
+
/**
|
|
54
|
+
* A hard cap on the sheet's width, overriding the one `size` implies. Numbers
|
|
55
|
+
* are pixels. For the modal whose content decides its width — a wide table, a
|
|
56
|
+
* narrow confirmation — rather than for tuning the scale, which is `size`.
|
|
57
|
+
*/
|
|
58
|
+
width?: number | string;
|
|
59
|
+
/**
|
|
60
|
+
* The sheet takes the full width its `size` allows.
|
|
61
|
+
*
|
|
62
|
+
* On by default, which is the other way round from every other component.
|
|
63
|
+
* Elsewhere `fullWidth` means "fill the container"; a modal's container is
|
|
64
|
+
* the viewport, and a modal that shrank to fit two words would be a tooltip.
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
fullWidth?: boolean;
|
|
68
|
+
/** Fills the viewport edge to edge. For a mobile-sized screen, or an editor. */
|
|
69
|
+
fullScreen?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Whether the page behind is taken away. `'trap-focus'` keeps the page
|
|
72
|
+
* scrollable and clickable while still holding focus inside.
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
modal?: boolean | 'trap-focus';
|
|
76
|
+
/**
|
|
77
|
+
* Whether pressing Escape or clicking outside closes the modal. Turn it off
|
|
78
|
+
* for the one that has to be answered — and then give it actions that answer
|
|
79
|
+
* it, because there will be no other way out.
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
dismissible?: boolean;
|
|
83
|
+
/** The body. */
|
|
84
|
+
children?: React.ReactNode;
|
|
85
|
+
}
|
|
86
|
+
export type PlModalCloseProps = React.ComponentPropsWithoutRef<typeof BaseUIDialog.Close>;
|
|
87
|
+
/**
|
|
88
|
+
* Closes the modal it is inside.
|
|
89
|
+
*
|
|
90
|
+
* Exported because an uncontrolled modal has no `setOpen` for its Cancel button
|
|
91
|
+
* to call, and the alternative — making every modal controlled — is a piece of
|
|
92
|
+
* state per modal that exists only to answer a button.
|
|
93
|
+
*
|
|
94
|
+
* `render` is Base UI's own escape hatch, so a real Plass button dismisses:
|
|
95
|
+
* `<PlModalClose render={<PlButton variant="ghost">Cancel</PlButton>} />`.
|
|
96
|
+
*/
|
|
97
|
+
export declare const PlModalClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
98
|
+
/**
|
|
99
|
+
* A sheet that takes the page away until it is answered.
|
|
100
|
+
*
|
|
101
|
+
* The sections are props rather than compound sub-components, exactly as they
|
|
102
|
+
* are on PlCard: the arrangement of a modal is fixed — heading, description,
|
|
103
|
+
* body, actions — and what a caller wants to decide is what goes in each slot.
|
|
104
|
+
* Base UI owns everything hard about it: the focus trap, the scroll lock, the
|
|
105
|
+
* `aria-labelledby` / `aria-describedby` wiring, restoring focus to the trigger,
|
|
106
|
+
* and the inert page behind.
|
|
107
|
+
*
|
|
108
|
+
* What is left here is the surface, the width ladder and the scroll behaviour —
|
|
109
|
+
* the header and the actions stay put while only the body scrolls, which is why
|
|
110
|
+
* `dividers` matters more here than on a PlCard.
|
|
111
|
+
*/
|
|
112
|
+
export declare function PlModal({ size, color, density, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, width, fullWidth, fullScreen, modal, dismissible, className, style, children, ...props }: PlModalProps): React.JSX.Element;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog as BaseUIDialog } from '@base-ui/react/dialog';
|
|
3
|
+
import { CloseIcon } from '../../internal/icons.js';
|
|
4
|
+
import { focusRingClasses, glassClasses, hasContent, metaTextClasses, radiusClasses, sheetBodyClasses, sheetHeaderGapClasses, sheetLineClasses, sheetPaddingXClasses, sheetPaddingYClasses, sheetSectionGapClasses, sheetTitleClasses, surfaceSlots } from '../../internal/styles.js';
|
|
5
|
+
/**
|
|
6
|
+
* How wide the sheet is allowed to get, per `size`.
|
|
7
|
+
*
|
|
8
|
+
* `size` and the width are one axis here rather than two. A second five-value
|
|
9
|
+
* scale spelled `maxWidth` would be a second spelling of an idea the library
|
|
10
|
+
* already has a word for, and the case it exists for — "small type, wide sheet"
|
|
11
|
+
* — is what the `width` escape hatch is.
|
|
12
|
+
*
|
|
13
|
+
* The steps are wider apart than the control ladder because they answer a
|
|
14
|
+
* different question: not how big is this thing, but how long a line of text is
|
|
15
|
+
* comfortable inside it.
|
|
16
|
+
*/
|
|
17
|
+
const maxWidthClasses = {
|
|
18
|
+
xs: 'max-w-80',
|
|
19
|
+
sm: 'max-w-96',
|
|
20
|
+
md: 'max-w-lg',
|
|
21
|
+
lg: 'max-w-2xl',
|
|
22
|
+
xl: 'max-w-4xl'
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The sheet, and — with the PlSelect popup — one of the two surfaces in the
|
|
26
|
+
* library that is *supposed* to float. So unlike everything else it carries a
|
|
27
|
+
* shadow by default, at level 3.
|
|
28
|
+
*
|
|
29
|
+
* It is the glass at its most opaque, because what is behind it is arbitrary:
|
|
30
|
+
* a modal floats over whatever the page happens to be, and a 62%-translucent
|
|
31
|
+
* pane over a photograph is a pane you read the photograph through.
|
|
32
|
+
*
|
|
33
|
+
* There is no `elevation` prop for the same reason there is no `variant`: a
|
|
34
|
+
* modal that could be told to sit flat on the page would be a modal that could
|
|
35
|
+
* be told to stop being one.
|
|
36
|
+
*/
|
|
37
|
+
const popupClasses = /* @__PURE__ */ [
|
|
38
|
+
glassClasses,
|
|
39
|
+
'relative flex w-full flex-col overflow-hidden',
|
|
40
|
+
'border text-(--plass-fg) bg-(--plass-glass-press)',
|
|
41
|
+
'[border-color:var(--plass-glass-line)]',
|
|
42
|
+
'[box-shadow:var(--plass-shadow-4),var(--plass-gloss-glass)]',
|
|
43
|
+
'[outline:none]',
|
|
44
|
+
// Opacity only. A modal that scales or slides in drags its own text across
|
|
45
|
+
// the screen for 200ms, which is the exact thing the house style is against —
|
|
46
|
+
// and unlike a control, this one is full of text.
|
|
47
|
+
'[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
|
|
48
|
+
'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
|
|
49
|
+
].join(' ');
|
|
50
|
+
const backdropClasses = /* @__PURE__ */ [
|
|
51
|
+
'fixed inset-0 z-50 bg-(--plass-scrim)',
|
|
52
|
+
'[backdrop-filter:blur(2px)] [-webkit-backdrop-filter:blur(2px)]',
|
|
53
|
+
'[transition:opacity_var(--plass-duration)_var(--plass-ease)]',
|
|
54
|
+
'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0'
|
|
55
|
+
].join(' ');
|
|
56
|
+
/**
|
|
57
|
+
* Closes the modal it is inside.
|
|
58
|
+
*
|
|
59
|
+
* Exported because an uncontrolled modal has no `setOpen` for its Cancel button
|
|
60
|
+
* to call, and the alternative — making every modal controlled — is a piece of
|
|
61
|
+
* state per modal that exists only to answer a button.
|
|
62
|
+
*
|
|
63
|
+
* `render` is Base UI's own escape hatch, so a real Plass button dismisses:
|
|
64
|
+
* `<PlModalClose render={<PlButton variant="ghost">Cancel</PlButton>} />`.
|
|
65
|
+
*/
|
|
66
|
+
export const PlModalClose = BaseUIDialog.Close;
|
|
67
|
+
/**
|
|
68
|
+
* A sheet that takes the page away until it is answered.
|
|
69
|
+
*
|
|
70
|
+
* The sections are props rather than compound sub-components, exactly as they
|
|
71
|
+
* are on PlCard: the arrangement of a modal is fixed — heading, description,
|
|
72
|
+
* body, actions — and what a caller wants to decide is what goes in each slot.
|
|
73
|
+
* Base UI owns everything hard about it: the focus trap, the scroll lock, the
|
|
74
|
+
* `aria-labelledby` / `aria-describedby` wiring, restoring focus to the trigger,
|
|
75
|
+
* and the inert page behind.
|
|
76
|
+
*
|
|
77
|
+
* What is left here is the surface, the width ladder and the scroll behaviour —
|
|
78
|
+
* the header and the actions stay put while only the body scrolls, which is why
|
|
79
|
+
* `dividers` matters more here than on a PlCard.
|
|
80
|
+
*/
|
|
81
|
+
export function PlModal({ size = 'md', color = 'primary', density = 'default', open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers = false, showClose = true, closeLabel = 'Close', width, fullWidth = true, fullScreen = false, modal = true, dismissible = true, className, style, children, ...props }) {
|
|
82
|
+
const insetX = sheetPaddingXClasses[density][size];
|
|
83
|
+
const insetY = sheetPaddingYClasses[density][size];
|
|
84
|
+
// With dividers the lines have to reach both edges, so the sheet gives up its
|
|
85
|
+
// padding and every section takes it on instead — the same trade PlCard makes.
|
|
86
|
+
const sectionClasses = dividers ? `${insetX} ${insetY}` : insetX;
|
|
87
|
+
const hasHeader = hasContent(title) || hasContent(description);
|
|
88
|
+
const hasActions = hasContent(actions);
|
|
89
|
+
return (_jsxs(BaseUIDialog.Root, { open: open, defaultOpen: defaultOpen, modal: modal, disablePointerDismissal: !dismissible, onOpenChange: (next, details) => {
|
|
90
|
+
// `disablePointerDismissal` covers the click outside; Escape has no prop
|
|
91
|
+
// of its own, so it is cancelled here by the reason it arrives with.
|
|
92
|
+
if (!dismissible && !next && details.reason === 'escape-key') {
|
|
93
|
+
details.cancel();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
onOpenChange?.(next);
|
|
97
|
+
}, children: [trigger ? _jsx(BaseUIDialog.Trigger, { render: trigger }) : null, _jsxs(BaseUIDialog.Portal, { children: [_jsx(BaseUIDialog.Backdrop, { className: `plass-portal ${backdropClasses}` }), _jsx(BaseUIDialog.Viewport, { className: [
|
|
98
|
+
'plass-portal fixed inset-0 z-50 flex justify-center',
|
|
99
|
+
// `items-center` alone would clip the top of a modal taller than the
|
|
100
|
+
// viewport, because a centred flex item cannot scroll past its own
|
|
101
|
+
// container's start edge. The popup caps its height instead and
|
|
102
|
+
// scrolls its body, so the header and the actions stay put.
|
|
103
|
+
fullScreen ? 'items-stretch' : 'items-center p-4'
|
|
104
|
+
].join(' '), children: _jsxs(BaseUIDialog.Popup, { className: [
|
|
105
|
+
popupClasses,
|
|
106
|
+
sheetBodyClasses[size],
|
|
107
|
+
fullScreen
|
|
108
|
+
? 'h-full max-w-none rounded-none'
|
|
109
|
+
: `max-h-full ${radiusClasses[size]} ${width === undefined ? maxWidthClasses[size] : ''}`,
|
|
110
|
+
!fullScreen && !fullWidth ? 'w-auto' : '',
|
|
111
|
+
dividers ? '' : `${insetY} ${sheetSectionGapClasses[size]}`,
|
|
112
|
+
className ?? ''
|
|
113
|
+
]
|
|
114
|
+
.filter(Boolean)
|
|
115
|
+
.join(' '), style: {
|
|
116
|
+
...surfaceSlots(color, 3),
|
|
117
|
+
...(width === undefined
|
|
118
|
+
? null
|
|
119
|
+
: { maxWidth: typeof width === 'number' ? `${width}px` : width }),
|
|
120
|
+
...style
|
|
121
|
+
}, ...props, children: [hasHeader || showClose ? (_jsxs("div", { className: `flex shrink-0 items-start gap-3 ${sectionClasses}`, children: [_jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${sheetHeaderGapClasses[size]}`, children: [hasContent(title) ? (_jsx(BaseUIDialog.Title, { className: `m-0 font-semibold ${sheetTitleClasses[size]}`, children: title })) : null, hasContent(description) ? (_jsx(BaseUIDialog.Description, { className: `m-0 text-(--plass-muted-fg) ${metaTextClasses[size]}`, children: description })) : null] }), showClose ? (_jsx(BaseUIDialog.Close, { "aria-label": closeLabel, className: [
|
|
122
|
+
'flex size-[1.6em] shrink-0 cursor-pointer items-center justify-center',
|
|
123
|
+
'rounded-full text-(--plass-muted-fg)',
|
|
124
|
+
'[&_svg]:size-[1.1em] [&_svg]:shrink-0',
|
|
125
|
+
'[transition:background-color_var(--plass-duration)_var(--plass-ease),color_var(--plass-duration)_var(--plass-ease)]',
|
|
126
|
+
'hover:bg-(--p-soft) hover:text-(--plass-fg)',
|
|
127
|
+
focusRingClasses
|
|
128
|
+
].join(' '), children: _jsx(CloseIcon, {}) })) : null] })) : null, hasContent(children) ? (_jsx("div", { className: [
|
|
129
|
+
'min-h-0 flex-1 overflow-y-auto overscroll-contain',
|
|
130
|
+
sectionClasses,
|
|
131
|
+
dividers && (hasHeader || showClose) ? sheetLineClasses : '',
|
|
132
|
+
// A scroll container clips at its padding box, and a focus
|
|
133
|
+
// ring is drawn 2px outside the control that owns it — so a
|
|
134
|
+
// field at the top or bottom of an unruled body would have its
|
|
135
|
+
// ring sliced off. The padding is room for the ring and the
|
|
136
|
+
// negative margin hands the space straight back, so nothing on
|
|
137
|
+
// the sheet moves. Only without `dividers`: with them the body
|
|
138
|
+
// already carries `insetY`, and pulling it up would drag the
|
|
139
|
+
// rule into the section above.
|
|
140
|
+
dividers ? '' : '-my-1 py-1'
|
|
141
|
+
]
|
|
142
|
+
.filter(Boolean)
|
|
143
|
+
.join(' '), children: children })) : null, hasActions ? (_jsx("div", { className: [
|
|
144
|
+
'flex shrink-0 flex-wrap items-center justify-end gap-2',
|
|
145
|
+
sectionClasses,
|
|
146
|
+
dividers ? sheetLineClasses : ''
|
|
147
|
+
]
|
|
148
|
+
.filter(Boolean)
|
|
149
|
+
.join(' '), children: actions })) : null] }) })] })] }));
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PlModal, PlModalClose } from './PlModal.js';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PlassElevation, PlassStyleProps } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where the two steppers sit.
|
|
5
|
+
*
|
|
6
|
+
* - `end` — both at the trailing edge, the way a spinner has always looked.
|
|
7
|
+
* - `split` — minus at the start, plus at the end, with the number between them.
|
|
8
|
+
* For a quantity that is nudged rather than typed.
|
|
9
|
+
* - `none` — no buttons. The field is still a number field: the arrow keys, the
|
|
10
|
+
* clamping and the formatting all stay.
|
|
11
|
+
*
|
|
12
|
+
* There is deliberately no stacked pair of half-height chevrons. At `xs` each
|
|
13
|
+
* arrow would be under three pixels tall, and a target that small is a target
|
|
14
|
+
* nobody hits.
|
|
15
|
+
*/
|
|
16
|
+
export type PlNumberFieldSteppers = 'end' | 'split' | 'none';
|
|
17
|
+
export interface PlNumberFieldProps extends PlassStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'children'> {
|
|
18
|
+
/**
|
|
19
|
+
* Drop shadow depth. `0` is the default — a field is a well cut into the
|
|
20
|
+
* sheet, not a key resting on it.
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
elevation?: PlassElevation;
|
|
24
|
+
/** The number. Use with `onValueChange` for a controlled field. */
|
|
25
|
+
value?: number | null;
|
|
26
|
+
/** The initial number, for an uncontrolled field. */
|
|
27
|
+
defaultValue?: number;
|
|
28
|
+
/** Called on every change — typing, stepping, the wheel. */
|
|
29
|
+
onValueChange?: (value: number | null) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Called when the value settles: on blur after typing, on pointer release
|
|
32
|
+
* after a press, and together with `onValueChange` for the keyboard.
|
|
33
|
+
*/
|
|
34
|
+
onValueCommitted?: (value: number | null) => void;
|
|
35
|
+
/** The bottom of the range. Stepping stops here. */
|
|
36
|
+
min?: number;
|
|
37
|
+
/** The top of the range. */
|
|
38
|
+
max?: number;
|
|
39
|
+
/**
|
|
40
|
+
* How far one step goes. `'any'` turns step validation off.
|
|
41
|
+
* @default 1
|
|
42
|
+
*/
|
|
43
|
+
step?: number | 'any';
|
|
44
|
+
/**
|
|
45
|
+
* The step taken while Shift is held.
|
|
46
|
+
* @default 10
|
|
47
|
+
*/
|
|
48
|
+
largeStep?: number;
|
|
49
|
+
/**
|
|
50
|
+
* The step taken while Alt is held.
|
|
51
|
+
* @default 0.1
|
|
52
|
+
*/
|
|
53
|
+
smallStep?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Whether stepping snaps to multiples of the step.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
snapOnStep?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the wheel changes the value while the field is focused and hovered.
|
|
61
|
+
* Off by default: a page that scrolls under the pointer and a field that
|
|
62
|
+
* changes under it are the same gesture, and only one of them was meant.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
allowWheelScrub?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* How the number is written — currency, percent, decimal places. Passed
|
|
68
|
+
* straight to `Intl.NumberFormat`, so the field shows `$1,240.00` and still
|
|
69
|
+
* reports `1240`.
|
|
70
|
+
*/
|
|
71
|
+
format?: Intl.NumberFormatOptions;
|
|
72
|
+
/** Which locale the number is written and parsed in. Defaults to the runtime's. */
|
|
73
|
+
locale?: Intl.LocalesArgument;
|
|
74
|
+
/**
|
|
75
|
+
* Where the steppers sit, or `none` for a field without them.
|
|
76
|
+
* @default 'end'
|
|
77
|
+
*/
|
|
78
|
+
steppers?: PlNumberFieldSteppers;
|
|
79
|
+
/**
|
|
80
|
+
* Accessible name of the increment button. Never drawn.
|
|
81
|
+
* @default 'Increase'
|
|
82
|
+
*/
|
|
83
|
+
incrementLabel?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Accessible name of the decrement button. Never drawn.
|
|
86
|
+
* @default 'Decrease'
|
|
87
|
+
*/
|
|
88
|
+
decrementLabel?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Label above the control, wired to it by Base UI's Field. There is no
|
|
91
|
+
* floating variant on purpose: floating labels need a `transform`.
|
|
92
|
+
*/
|
|
93
|
+
label?: React.ReactNode;
|
|
94
|
+
/** Helper text below the control. */
|
|
95
|
+
description?: React.ReactNode;
|
|
96
|
+
/** Error message below the control. Its presence also turns the field invalid. */
|
|
97
|
+
error?: React.ReactNode;
|
|
98
|
+
/** Forces the invalid state without a message. Defaults to `!!error`. */
|
|
99
|
+
invalid?: boolean;
|
|
100
|
+
/** Content placed before the number — a currency mark, a unit, an icon. */
|
|
101
|
+
startIcon?: React.ReactNode;
|
|
102
|
+
/** Content placed after the number, before the steppers. */
|
|
103
|
+
endIcon?: React.ReactNode;
|
|
104
|
+
/** Stretches to the width of the container. */
|
|
105
|
+
fullWidth?: boolean;
|
|
106
|
+
/** Unavailable. */
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
/** The number is shown but cannot be changed. */
|
|
109
|
+
readOnly?: boolean;
|
|
110
|
+
/** Whether a value must be entered before the form is submitted. */
|
|
111
|
+
required?: boolean;
|
|
112
|
+
/** Identifies the field when a form is submitted. */
|
|
113
|
+
name?: string;
|
|
114
|
+
/** Placeholder shown while the field is empty. */
|
|
115
|
+
placeholder?: string;
|
|
116
|
+
id?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A field that only holds a number.
|
|
120
|
+
*
|
|
121
|
+
* The shell is a `PlTextField`'s, to the pixel, because a form where the
|
|
122
|
+
* quantity box is a different height or radius from the boxes around it is a
|
|
123
|
+
* form that looks assembled rather than designed. What is added on top is a real
|
|
124
|
+
* numeric control: arrow keys and the steppers move by `step` (Shift for
|
|
125
|
+
* `largeStep`, Alt for `smallStep`), the value clamps to `min`/`max`, and
|
|
126
|
+
* `format` writes it as currency or a percentage while `value` stays a plain
|
|
127
|
+
* number.
|
|
128
|
+
*
|
|
129
|
+
* Base UI owns the hard parts — parsing what was typed against the locale,
|
|
130
|
+
* clamping, the press-and-hold repeat on the steppers, and the hidden input that
|
|
131
|
+
* submits with a form.
|
|
132
|
+
*/
|
|
133
|
+
export declare function PlNumberField({ variant, size, color, density, elevation, value, defaultValue, onValueChange, onValueCommitted, min, max, step, largeStep, smallStep, snapOnStep, allowWheelScrub, format, locale, steppers, incrementLabel, decrementLabel, label, description, error, invalid, startIcon, endIcon, fullWidth, disabled, readOnly, required, name, placeholder, id, className, style, ...props }: PlNumberFieldProps): React.JSX.Element;
|