material-plus-ui 1.6.0 → 1.8.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/LICENSE +1 -1
- package/README.md +20 -14
- package/dist/components/accordion/MPAccordion.d.ts +21 -1
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/alert/MPAlert.d.ts +34 -3
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/anchor/MPAnchor.d.ts +107 -0
- package/dist/components/anchor/MPAnchor.js +2 -0
- package/dist/components/anchor/index.d.ts +2 -0
- package/dist/components/anchor/index.js +1 -0
- package/dist/components/animate-appear/MPAnimateAppear.d.ts +2 -2
- package/dist/components/animate-appear/MPAnimateAppear.js +1 -1
- package/dist/components/animate-blink/MPAnimateBlink.d.ts +2 -2
- package/dist/components/animate-blink/MPAnimateBlink.js +2 -1
- package/dist/components/animate-counter/MPAnimateCounter.d.ts +67 -0
- package/dist/components/animate-counter/MPAnimateCounter.js +2 -0
- package/dist/components/animate-counter/index.d.ts +2 -0
- package/dist/components/animate-counter/index.js +1 -0
- package/dist/components/animate-fade/MPAnimateFade.d.ts +2 -2
- package/dist/components/animate-fade/MPAnimateFade.js +2 -1
- package/dist/components/animate-float/MPAnimateFloat.d.ts +53 -0
- package/dist/components/animate-float/MPAnimateFloat.js +2 -0
- package/dist/components/animate-float/index.d.ts +2 -0
- package/dist/components/animate-float/index.js +1 -0
- package/dist/components/animate-grow/MPAnimateGrow.d.ts +2 -2
- package/dist/components/animate-grow/MPAnimateGrow.js +2 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -0
- package/dist/components/animate-reveal/MPAnimateReveal.d.ts +64 -0
- package/dist/components/animate-reveal/MPAnimateReveal.js +2 -0
- package/dist/components/animate-reveal/index.d.ts +2 -0
- package/dist/components/animate-reveal/index.js +1 -0
- package/dist/components/animate-rotate/MPAnimateRotate.d.ts +2 -2
- package/dist/components/animate-rotate/MPAnimateRotate.js +2 -1
- package/dist/components/animate-scramble/MPAnimateScramble.d.ts +65 -0
- package/dist/components/animate-scramble/MPAnimateScramble.js +2 -0
- package/dist/components/animate-scramble/index.d.ts +2 -0
- package/dist/components/animate-scramble/index.js +1 -0
- package/dist/components/animate-shake/MPAnimateShake.d.ts +65 -0
- package/dist/components/animate-shake/MPAnimateShake.js +2 -0
- package/dist/components/animate-shake/index.d.ts +2 -0
- package/dist/components/animate-shake/index.js +1 -0
- package/dist/components/animate-slide/MPAnimateSlide.d.ts +2 -2
- package/dist/components/animate-slide/MPAnimateSlide.js +2 -1
- package/dist/components/animate-split/MPAnimateSplit.d.ts +56 -0
- package/dist/components/animate-split/MPAnimateSplit.js +2 -0
- package/dist/components/animate-split/index.d.ts +2 -0
- package/dist/components/animate-split/index.js +1 -0
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -1
- package/dist/components/animate-zoom/MPAnimateZoom.d.ts +2 -2
- package/dist/components/animate-zoom/MPAnimateZoom.js +2 -1
- package/dist/components/app-logo/MPAppLogo.d.ts +171 -0
- package/dist/components/app-logo/MPAppLogo.js +2 -0
- package/dist/components/app-logo/index.d.ts +2 -0
- package/dist/components/app-logo/index.js +1 -0
- package/dist/components/area-chart/MPAreaChart.d.ts +79 -0
- package/dist/components/area-chart/MPAreaChart.js +2 -0
- package/dist/components/area-chart/index.d.ts +2 -0
- package/dist/components/area-chart/index.js +1 -0
- package/dist/components/aspect-ratio/MPAspectRatio.d.ts +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +2 -1
- package/dist/components/avatar/MPAvatar.d.ts +10 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/bar-chart/MPBarChart.d.ts +74 -0
- package/dist/components/bar-chart/MPBarChart.js +2 -0
- package/dist/components/bar-chart/index.d.ts +2 -0
- package/dist/components/bar-chart/index.js +1 -0
- package/dist/components/blockquote/MPBlockquote.d.ts +18 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +2 -18
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/box/MPBox.d.ts +43 -8
- package/dist/components/box/MPBox.js +2 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.js +1 -1
- package/dist/components/card/MPCard.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +11 -2
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/code-block/MPCodeBlock.d.ts +177 -0
- package/dist/components/code-block/MPCodeBlock.js +2 -0
- package/dist/components/code-block/index.d.ts +2 -0
- package/dist/components/code-block/index.js +1 -0
- package/dist/components/collapsible/MPCollapsible.d.ts +12 -1
- package/dist/components/collapsible/MPCollapsible.js +1 -1
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +21 -4
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +12 -2
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +49 -7
- package/dist/components/config/MPConfigProvider.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/container/MPContainer.d.ts +9 -2
- package/dist/components/container/MPContainer.js +2 -1
- package/dist/components/data-list/MPDataList.d.ts +82 -0
- package/dist/components/data-list/MPDataList.js +2 -0
- package/dist/components/data-list/index.d.ts +2 -0
- package/dist/components/data-list/index.js +1 -0
- package/dist/components/data-table/MPDataTable.d.ts +314 -0
- package/dist/components/data-table/MPDataTable.js +2 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +1 -0
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +10 -2
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +8 -2
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/empty/MPEmpty.d.ts +10 -1
- package/dist/components/empty/MPEmpty.js +1 -1
- package/dist/components/fieldset/MPFieldset.js +1 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/flex/MPFlex.d.ts +95 -0
- package/dist/components/flex/MPFlex.js +2 -0
- package/dist/components/flex/index.d.ts +2 -0
- package/dist/components/flex/index.js +1 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/floating-bottom-navigation/MPFloatingBottomNavigation.d.ts +127 -0
- package/dist/components/floating-bottom-navigation/MPFloatingBottomNavigation.js +2 -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/footer/MPFooter.d.ts +24 -4
- package/dist/components/footer/MPFooter.js +1 -1
- package/dist/components/form/MPForm.js +1 -1
- package/dist/components/gauge-chart/MPGaugeChart.d.ts +78 -0
- package/dist/components/gauge-chart/MPGaugeChart.js +2 -0
- package/dist/components/gauge-chart/index.d.ts +2 -0
- package/dist/components/gauge-chart/index.js +1 -0
- package/dist/components/grid/MPGrid.d.ts +25 -8
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/header/MPHeader.d.ts +26 -4
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/heatmap-chart/MPHeatmapChart.d.ts +75 -0
- package/dist/components/heatmap-chart/MPHeatmapChart.js +2 -0
- package/dist/components/heatmap-chart/index.d.ts +2 -0
- package/dist/components/heatmap-chart/index.js +1 -0
- package/dist/components/hover-card/MPHoverCard.d.ts +101 -0
- package/dist/components/hover-card/MPHoverCard.js +2 -0
- package/dist/components/hover-card/index.d.ts +2 -0
- package/dist/components/hover-card/index.js +1 -0
- package/dist/components/icon/MPIcon.js +1 -1
- package/dist/components/image/MPImage.d.ts +122 -5
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/image/index.d.ts +1 -1
- package/dist/components/line-chart/MPLineChart.d.ts +66 -0
- package/dist/components/line-chart/MPLineChart.js +2 -0
- package/dist/components/line-chart/index.d.ts +2 -0
- package/dist/components/line-chart/index.js +1 -0
- package/dist/components/list/MPList.d.ts +23 -1
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +1 -1
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/meter/MPMeter.d.ts +87 -0
- package/dist/components/meter/MPMeter.js +2 -0
- package/dist/components/meter/index.d.ts +2 -0
- package/dist/components/meter/index.js +1 -0
- package/dist/components/mockup/MPMockup.d.ts +143 -0
- package/dist/components/mockup/MPMockup.js +2 -0
- package/dist/components/mockup/index.d.ts +2 -0
- package/dist/components/mockup/index.js +1 -0
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/pie-chart/MPPieChart.d.ts +77 -0
- package/dist/components/pie-chart/MPPieChart.js +2 -0
- package/dist/components/pie-chart/index.d.ts +2 -0
- package/dist/components/pie-chart/index.js +1 -0
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +2 -2
- package/dist/components/popover/MPPopover.d.ts +1 -0
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/portal/MPPortal.d.ts +75 -0
- package/dist/components/portal/MPPortal.js +2 -0
- package/dist/components/portal/index.d.ts +2 -0
- package/dist/components/portal/index.js +1 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.d.ts +66 -0
- package/dist/components/scatter-chart/MPScatterChart.js +2 -0
- package/dist/components/scatter-chart/index.d.ts +2 -0
- package/dist/components/scatter-chart/index.js +1 -0
- package/dist/components/scroll-area/MPScrollArea.d.ts +82 -0
- package/dist/components/scroll-area/MPScrollArea.js +2 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/scroll-zone/MPScrollZone.d.ts +165 -0
- package/dist/components/scroll-zone/MPScrollZone.js +2 -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/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +27 -4
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/show/MPShow.d.ts +78 -0
- package/dist/components/show/MPShow.js +2 -0
- package/dist/components/show/index.d.ts +2 -0
- package/dist/components/show/index.js +1 -0
- package/dist/components/sidebar/MPSidebar.d.ts +20 -1
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/sparkline/MPSparkline.d.ts +85 -0
- package/dist/components/sparkline/MPSparkline.js +2 -0
- package/dist/components/sparkline/index.d.ts +2 -0
- package/dist/components/sparkline/index.js +1 -0
- package/dist/components/spoiler/MPSpoiler.d.ts +12 -0
- package/dist/components/spoiler/MPSpoiler.js +1 -1
- package/dist/components/stack/MPStack.d.ts +198 -0
- package/dist/components/stack/MPStack.js +2 -0
- package/dist/components/stack/index.d.ts +2 -0
- package/dist/components/stack/index.js +1 -0
- package/dist/components/statistic/MPStatistic.d.ts +104 -0
- package/dist/components/statistic/MPStatistic.js +2 -0
- package/dist/components/statistic/index.d.ts +2 -0
- package/dist/components/statistic/index.js +1 -0
- package/dist/components/stepper/MPStepper.js +1 -1
- package/dist/components/table/MPTable.d.ts +25 -3
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/tabs/MPTabs.d.ts +12 -0
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.d.ts +63 -0
- package/dist/components/timeline-chart/MPTimelineChart.js +2 -0
- package/dist/components/timeline-chart/index.d.ts +2 -0
- package/dist/components/timeline-chart/index.js +1 -0
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/toolbar/MPToolbar.d.ts +106 -0
- package/dist/components/toolbar/MPToolbar.js +2 -0
- package/dist/components/toolbar/index.d.ts +2 -0
- package/dist/components/toolbar/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/tour/MPTour.d.ts +120 -0
- package/dist/components/tour/MPTour.js +2 -0
- package/dist/components/tour/index.d.ts +2 -0
- package/dist/components/tour/index.js +1 -0
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/tree-select/MPTreeSelect.d.ts +113 -0
- package/dist/components/tree-select/MPTreeSelect.js +2 -0
- package/dist/components/tree-select/index.d.ts +2 -0
- package/dist/components/tree-select/index.js +1 -0
- package/dist/components/tree-view/MPTreeView.d.ts +153 -0
- package/dist/components/tree-view/MPTreeView.js +2 -0
- package/dist/components/tree-view/index.d.ts +2 -0
- package/dist/components/tree-view/index.js +1 -0
- package/dist/components/typography/MPTypography.d.ts +10 -1
- package/dist/components/typography/MPTypography.js +2 -1
- package/dist/constants/glyphs.d.ts +33 -31
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +32 -31
- package/dist/constants/icons.js +1 -1
- package/dist/hooks/index.d.ts +22 -5
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useMPColorScheme.js +1 -0
- package/dist/hooks/useMPDisclosure.d.ts +58 -0
- package/dist/hooks/useMPDisclosure.js +2 -0
- package/dist/hooks/useMPElementSize.d.ts +55 -0
- package/dist/hooks/useMPElementSize.js +2 -0
- package/dist/hooks/useMPMediaQuery.d.ts +40 -0
- package/dist/hooks/useMPMediaQuery.js +2 -0
- package/dist/hooks/useMPOnScreen.d.ts +58 -0
- package/dist/hooks/useMPOnScreen.js +2 -0
- package/dist/hooks/useMPReducedMotion.js +1 -0
- package/dist/hooks/useMPWindowClass.d.ts +7 -0
- package/dist/hooks/useMPWindowClass.js +1 -0
- package/dist/index.d.ts +35 -1
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +199 -0
- package/dist/internal/ChartChrome.js +2 -0
- package/dist/internal/ChartFrame.d.ts +197 -0
- package/dist/internal/ChartFrame.js +2 -0
- package/dist/internal/FieldOutline.d.ts +14 -5
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/PopupArrow.d.ts +60 -0
- package/dist/internal/PopupArrow.js +2 -0
- package/dist/internal/SupportingText.d.ts +24 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate-core.d.ts +121 -0
- package/dist/internal/animate-core.js +1 -0
- package/dist/internal/animate.d.ts +75 -55
- package/dist/internal/animate.js +1 -1
- package/dist/internal/bottom-navigation.d.ts +58 -0
- package/dist/internal/bottom-navigation.js +2 -0
- package/dist/internal/chart.d.ts +461 -0
- package/dist/internal/chart.js +1 -0
- package/dist/internal/color-scheme.d.ts +0 -9
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/config.d.ts +24 -5
- package/dist/internal/config.js +1 -1
- package/dist/internal/data-table.d.ts +195 -0
- package/dist/internal/data-table.js +1 -0
- package/dist/internal/date.d.ts +22 -18
- package/dist/internal/date.js +1 -1
- package/dist/internal/density.d.ts +9 -0
- package/dist/internal/density.js +1 -0
- package/dist/internal/elevation.d.ts +26 -0
- package/dist/internal/elevation.js +1 -0
- package/dist/internal/highlight.d.ts +96 -0
- package/dist/internal/highlight.js +1 -0
- package/dist/internal/i18n.d.ts +180 -0
- package/dist/internal/initials.d.ts +28 -0
- package/dist/internal/initials.js +1 -0
- package/dist/internal/intl.d.ts +64 -0
- package/dist/internal/intl.js +1 -0
- package/dist/internal/mark.d.ts +52 -0
- package/dist/internal/mark.js +1 -0
- package/dist/internal/measure.d.ts +31 -0
- package/dist/internal/measure.js +1 -0
- package/dist/internal/messages/anchor.d.ts +3 -0
- package/dist/internal/messages/anchor.js +1 -0
- package/dist/internal/messages/chart.d.ts +3 -0
- package/dist/internal/messages/chart.js +1 -0
- package/dist/internal/messages/code.d.ts +3 -0
- package/dist/internal/messages/code.js +1 -0
- package/dist/internal/messages/data-table.d.ts +3 -0
- package/dist/internal/messages/data-table.js +1 -0
- package/dist/internal/messages/scroll.d.ts +3 -0
- package/dist/internal/messages/scroll.js +1 -0
- package/dist/internal/messages/sparkline.d.ts +3 -0
- package/dist/internal/messages/sparkline.js +1 -0
- package/dist/internal/messages/tour.d.ts +3 -0
- package/dist/internal/messages/tour.js +1 -0
- package/dist/internal/messages/transfer.d.ts +1 -1
- package/dist/internal/messages/transfer.js +1 -1
- package/dist/internal/mockup.d.ts +174 -0
- package/dist/internal/mockup.js +2 -0
- package/dist/internal/page-layout.d.ts +24 -5
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/responsive.d.ts +55 -0
- package/dist/internal/responsive.js +1 -0
- package/dist/internal/scale.d.ts +0 -17
- package/dist/internal/scale.js +1 -1
- package/dist/internal/step.d.ts +15 -0
- package/dist/internal/step.js +1 -1
- package/dist/internal/table.d.ts +53 -0
- package/dist/internal/table.js +1 -0
- package/dist/internal/text.d.ts +57 -0
- package/dist/internal/text.js +1 -0
- package/dist/internal/threshold.d.ts +19 -0
- package/dist/internal/threshold.js +1 -0
- package/dist/internal/time-scale.d.ts +44 -0
- package/dist/internal/time-scale.js +1 -0
- package/dist/internal/transition.d.ts +33 -0
- package/dist/internal/transition.js +1 -0
- package/dist/internal/visibility.d.ts +48 -0
- package/dist/internal/visibility.js +1 -0
- package/dist/internal/window-class.d.ts +29 -2
- package/dist/internal/window-class.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/anchor.css +2 -0
- package/dist/styles/animate-appear.css +1 -1
- package/dist/styles/animate-blink.css +1 -1
- package/dist/styles/animate-counter.css +2 -0
- package/dist/styles/animate-fade.css +1 -1
- package/dist/styles/animate-float.css +2 -0
- package/dist/styles/animate-grow.css +1 -1
- package/dist/styles/animate-headline.css +1 -1
- package/dist/styles/animate-lighting.css +1 -1
- package/dist/styles/animate-marquee.css +1 -1
- package/dist/styles/animate-reveal.css +2 -0
- package/dist/styles/animate-rotate.css +1 -1
- package/dist/styles/animate-scramble.css +2 -0
- package/dist/styles/animate-shake.css +2 -0
- package/dist/styles/animate-slide.css +1 -1
- package/dist/styles/animate-split.css +2 -0
- package/dist/styles/animate-typing.css +1 -1
- package/dist/styles/animate-zoom.css +1 -1
- package/dist/styles/app-logo.css +2 -0
- package/dist/styles/area-chart.css +2 -0
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/bar-chart.css +2 -0
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/chat-bubble.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/code-block.css +2 -0
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +1 -1
- package/dist/styles/config.css +1 -1
- package/dist/styles/confirm.css +1 -1
- package/dist/styles/container.css +1 -1
- package/dist/styles/data-list.css +2 -0
- package/dist/styles/data-table.css +2 -0
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/fieldset.css +1 -1
- package/dist/styles/file-picker.css +1 -1
- package/dist/styles/flex.css +2 -0
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/floating-bottom-navigation.css +2 -0
- package/dist/styles/footer.css +1 -1
- package/dist/styles/form.css +1 -1
- package/dist/styles/gauge-chart.css +2 -0
- package/dist/styles/grid.css +1 -1
- package/dist/styles/header.css +1 -1
- package/dist/styles/heatmap-chart.css +2 -0
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/hover-card.css +2 -0
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/icon.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/line-chart.css +2 -0
- package/dist/styles/list.css +1 -1
- package/dist/styles/locale.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/meter.css +2 -0
- package/dist/styles/mockup.css +2 -0
- package/dist/styles/navigation-menu.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +1 -1
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/pie-chart.css +2 -0
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popconfirm.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/portal.css +2 -0
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/rating.css +1 -1
- package/dist/styles/scatter-chart.css +2 -0
- package/dist/styles/scroll-area.css +2 -0
- package/dist/styles/scroll-zone.css +2 -0
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/show.css +2 -0
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/skeleton.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/sparkline.css +2 -0
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/stack.css +2 -0
- package/dist/styles/statistic.css +2 -0
- package/dist/styles/stepper.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text-link.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/timeline-chart.css +2 -0
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/toggle.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/toolbar.css +2 -0
- package/dist/styles/tour.css +2 -0
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/tree-select.css +2 -0
- package/dist/styles/tree-view.css +2 -0
- package/dist/styles/typography.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +2606 -185
- package/dist/types.d.ts +566 -5
- package/package.json +26 -25
- package/.fix.py +0 -92
- package/dist/components/avatar-group/MPAvatarGroup.d.ts +0 -74
- package/dist/components/avatar-group/MPAvatarGroup.js +0 -2
- package/dist/components/avatar-group/index.d.ts +0 -2
- package/dist/components/avatar-group/index.js +0 -1
- package/dist/internal/avatar-group.d.ts +0 -22
- package/dist/internal/avatar-group.js +0 -2
- package/dist/styles/avatar-group.css +0 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPThreshold } from '../../types.js';
|
|
3
|
+
export interface MPGaugeChartProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children'> {
|
|
4
|
+
/** The reading. */
|
|
5
|
+
value: number;
|
|
6
|
+
/** @default 0 */
|
|
7
|
+
min?: number;
|
|
8
|
+
/** @default 100 */
|
|
9
|
+
max?: number;
|
|
10
|
+
/**
|
|
11
|
+
* How far round the dial goes, in degrees, centred on twelve o'clock.
|
|
12
|
+
*
|
|
13
|
+
* `180` is a half dial sitting on its base; `240` is the classic gauge, open
|
|
14
|
+
* at the bottom. Past about 300 the two ends meet and the reader can no
|
|
15
|
+
* longer tell the start from the finish.
|
|
16
|
+
* @default 240
|
|
17
|
+
*/
|
|
18
|
+
sweep?: number;
|
|
19
|
+
/** What the reading is called, under the figure. */
|
|
20
|
+
label?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Where the reading changes colour. The last threshold it has reached wins,
|
|
23
|
+
* so they are listed smallest first.
|
|
24
|
+
*/
|
|
25
|
+
thresholds?: readonly MPThreshold[];
|
|
26
|
+
/**
|
|
27
|
+
* Paints the **track** in threshold bands as well as the fill, so a reader
|
|
28
|
+
* sees where the trouble starts before the needle gets there.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
bands?: boolean;
|
|
32
|
+
/** The family the dial carries before any threshold is reached. @default 'primary' */
|
|
33
|
+
color?: MPColor;
|
|
34
|
+
/** How the figure in the middle is written. */
|
|
35
|
+
format?: Intl.NumberFormatOptions;
|
|
36
|
+
/** Which language that figure is written in. */
|
|
37
|
+
locale?: string;
|
|
38
|
+
/** How tall the drawing is. Defaults to the `size` ladder. */
|
|
39
|
+
height?: number | string;
|
|
40
|
+
/** @default 'md' */
|
|
41
|
+
size?: MPSize;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One reading on a dial.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <MPGaugeChart value={72} label="CPU" thresholds={[{ from: 80, color: 'error' }]} />
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* ## Consider not using one
|
|
51
|
+
*
|
|
52
|
+
* A gauge spends a whole panel on a single number, and the arc adds nothing a
|
|
53
|
+
* reader could not get from the figure and a bar: an angle is judged less
|
|
54
|
+
* accurately than a length, and a dial's ends are the two places the eye is
|
|
55
|
+
* worst at. [MPStatistic](statistic) with an [MPMeter](../feedback/meter) under
|
|
56
|
+
* it says the same thing in a third of the room and reads better.
|
|
57
|
+
*
|
|
58
|
+
* What a gauge is genuinely good for is a **thresholded** reading somebody
|
|
59
|
+
* watches — a dial where the amber band is drawn on the face, so the question
|
|
60
|
+
* "how close is this to trouble" is answered by where the needle sits rather
|
|
61
|
+
* than by arithmetic. That is what `bands` is for, and it is the case worth
|
|
62
|
+
* reaching for this shape over the other two.
|
|
63
|
+
*
|
|
64
|
+
* ## It is a meter, in the markup
|
|
65
|
+
*
|
|
66
|
+
* `role="meter"` with the value, the minimum and the maximum on it — the same
|
|
67
|
+
* semantics [MPMeter](../feedback/meter) carries, because they are the same
|
|
68
|
+
* quantity in two shapes. There is no table behind it and no hover layer: a
|
|
69
|
+
* chart of one number has nothing a reader could uncover that the figure in the
|
|
70
|
+
* middle is not already saying.
|
|
71
|
+
*
|
|
72
|
+
* ## Thresholds name roles
|
|
73
|
+
*
|
|
74
|
+
* `{ from: 80, color: 'error' }` and never a hex, so a dial and a bar on the
|
|
75
|
+
* same page cannot disagree about where the amber starts. Both read the same
|
|
76
|
+
* resolver.
|
|
77
|
+
*/
|
|
78
|
+
export declare function MPGaugeChart({ value, min, max, sweep, label, thresholds, bands, color: colorProp, format, locale: localeProp, height, size: sizeProp, className, style, ...props }: MPGaugeChartProps): React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Meter as l}from"@base-ui/react/meter";import{useMPElementSize as r}from"../../hooks/useMPElementSize.js";import{useMPColor as o,useMPSize as m}from"../../internal/config.js";import{useMPLocale as i}from"../../internal/locale.js";import{accentSlots as s}from"../../internal/accent.js";import{thresholdColor as n}from"../../internal/threshold.js";import{progressFraction as c}from"../../internal/progress.js";import{CHART_FONT_SIZE as h,PLOT_HEIGHT as p,arcPath as f,formatStatistic as u}from"../../internal/chart.js";import{cssLength as d}from"../../internal/length.js";import{META_TEXT as x}from"../../internal/scale.js";const g={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-display-small"};export function MPGaugeChart({value:v,min:j=0,max:M=100,sweep:_=240,label:b,thresholds:y,bands:w=!1,color:N,format:P,locale:$,height:z,size:I,className:k,style:B,...R}){const C=m(I),E=o(N),G=i($),L=a.useRef(null),S=r(L),V=c(v,j,M)??0,W=n(v,E,y),q=h[C],A=S.width,D="number"==typeof z?z:void 0===z?p[C]:S.height,F=Math.min(300,Math.max(30,_))*Math.PI/180,H=F/2,J=H>Math.PI/2?Math.cos(Math.PI-H):0,K=Math.min(A/2,D/(1+J)),O=Math.max(0,K-2),Q=.78*O,T=A/2,U=O+2,X=-H,Y=H,Z=X+V*F,ee=a.useMemo(()=>{if(!w||!y||0===y.length)return[{from:0,to:1,color:E}];const e=[...y.map(e=>({at:c(e.from,j,M)??0,color:e.color})).filter(e=>e.at>0&&e.at<1).sort((e,t)=>e.at-t.at)],t=[];let a=0,l=E;for(const r of e)t.push({from:a,to:r.at,color:l}),a=r.at,l=r.color;return t.push({from:a,to:1,color:l}),t},[w,y,E,j,M]),te=u(v,G,P,!1);return t(l.Root,{value:v,min:j,max:M,format:P,"data-mp-size":C,className:["mp-gauge-chart flex min-w-0 flex-col items-center",k??""].filter(Boolean).join(" "),style:{...s(W),...B},...R,children:[t("div",{ref:L,className:"mp-gauge-chart__dial relative w-full",style:{height:d(z)??p[C]},children:[A>0&&O>0?t("svg",{width:A,height:D,viewBox:`0 0 ${A} ${D}`,"aria-hidden":"true",className:"block overflow-visible",children:[ee.map((t,a)=>e("path",{d:f(T,U,O,Q,X+t.from*F,X+t.to*F),fill:w?`var(--_mp-color-${t.color})`:"var(--_mp-color-on-surface)",opacity:w?.22:.12},a)),e("path",{d:f(T,U,O,Q,X,Z),fill:"var(--_mp-accent)"}),e("path",{d:f(T,U,O,Q,X,X+.004*F),fill:"var(--_mp-color-outline)"}),e("path",{d:f(T,U,O,Q,Y-.004*F,Y),fill:"var(--_mp-color-outline)"})]}):null,t("div",{className:"pointer-events-none absolute inset-x-0 flex flex-col items-center",style:{top:U-.45*Q},children:[e(l.Value,{className:`mp-gauge-chart__value text-mp-on-surface font-medium tabular-nums ${g[C]}`,children:e=>P?e:te}),b?e(l.Label,{className:`mp-gauge-chart__label text-mp-on-surface-variant ${x}`,style:{maxWidth:1.8*Q},children:b}):null]})]}),J>0?e("span",{"aria-hidden":"true",style:{height:q/2}}):null]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPGaugeChart}from"./MPGaugeChart.js";
|
|
@@ -15,19 +15,28 @@ export type MPGridAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
|
15
15
|
/** The same, for one item overriding the row it is in. */
|
|
16
16
|
export type MPGridAlignSelf = MPGridAlign | 'auto';
|
|
17
17
|
/**
|
|
18
|
-
* How wide one item is: a number of the grid's columns, or `'
|
|
18
|
+
* How wide one item is: a number of the grid's columns, `'grow'` or `'auto'`.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* cannot
|
|
24
|
-
* row have been laid out
|
|
25
|
-
*
|
|
20
|
+
* Neither word is a measurement, and they are the two ends of the same question
|
|
21
|
+
* a column count cannot answer. `'grow'` is "whatever the row has left after
|
|
22
|
+
* everybody else has taken theirs" — the width a thumbnail's neighbour wants,
|
|
23
|
+
* and one the arithmetic cannot reach because the remainder is only known once
|
|
24
|
+
* the other items in *that* row have been laid out. `'auto'` is "exactly what is
|
|
25
|
+
* inside me", which the arithmetic cannot reach either: what is inside an item
|
|
26
|
+
* is measured by the browser, and a share of twelve columns has to be written
|
|
27
|
+
* down in advance.
|
|
28
|
+
*
|
|
29
|
+
* They pair. A control bar whose left half is a set of transport buttons and
|
|
30
|
+
* whose right half is however many icon buttons the page turned out to need is
|
|
31
|
+
* `span="grow"` and `span="auto"`, and neither side has a number in it — which
|
|
32
|
+
* matters because the number would be wrong: four 32px buttons in `span={2}` of
|
|
33
|
+
* a 768px bar is 128px against 128px, and the pixel that sub-pixel rounding
|
|
34
|
+
* takes off wraps the last button onto a second row.
|
|
26
35
|
*
|
|
27
36
|
* Two growing items in a row split the remainder equally rather than by their
|
|
28
37
|
* contents, which is the useful half of what makes it predictable.
|
|
29
38
|
*/
|
|
30
|
-
export type MPGridSpan = number | 'grow';
|
|
39
|
+
export type MPGridSpan = number | 'grow' | 'auto';
|
|
31
40
|
export interface MPGridProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
32
41
|
/**
|
|
33
42
|
* How many columns a row is divided into. Every `span` and every `offset`
|
|
@@ -96,6 +105,14 @@ export interface MPGridItemProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
96
105
|
* when the picture's column count changes. It is responsive like any other
|
|
97
106
|
* value: `span={{ compact: 12, medium: 'grow' }}` stacks on a phone and fills
|
|
98
107
|
* the rest of the row from 600dp.
|
|
108
|
+
*
|
|
109
|
+
* `span="auto"` is the other end of that: exactly the width of what is inside
|
|
110
|
+
* the item, however much that turns out to be. It is the span for a group
|
|
111
|
+
* whose size is a runtime question — a row of icon buttons where how many
|
|
112
|
+
* there are depends on what the page can do — and it pairs with `'grow'`, one
|
|
113
|
+
* item taking what it needs and the other taking the rest. An `'auto'` item
|
|
114
|
+
* does not shrink, so contents wider than the row overflow rather than
|
|
115
|
+
* squeezing what is beside them.
|
|
99
116
|
* @default the grid's full width
|
|
100
117
|
*/
|
|
101
118
|
span?: MPResponsive<MPGridSpan>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";import{
|
|
2
|
+
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";import{classMap as n,responsiveSlots as r,withBaseline as s}from"../../internal/responsive.js";import{WINDOW_CLASSES as a}from"../../internal/window-class.js";function o(e){return String(Math.max(1,Math.round(e)))}function c(e){return String(Math.max(1,Math.round(e)))}function i(e){const t=n(e),r=Object.values(t),s=r.some(e=>"grow"===e),o=r.some(e=>"auto"===e),i={};for(const e of a){const n=t[e];void 0!==n&&("grow"!==n&&"auto"!==n&&(i[`--_mp-span-${e}`]=c(n)),s&&(i[`--_mp-grow-${e}`]="grow"===n?"1":"0"),o&&(i[`--_mp-width-${e}`]="auto"===n?"auto":"var(--_mp-span-width)"))}return i}function l(e){return String(Math.max(0,Math.round(e)))}function f(e){const t=.25*Math.max(0,e);return`${Number(t.toFixed(5))}rem`}const p={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between","space-around":"justify-around","space-evenly":"justify-evenly"},u={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch",baseline:"items-baseline"},m={start:"content-start",center:"content-center",end:"content-end","space-between":"content-between","space-around":"content-around","space-evenly":"content-evenly",stretch:"content-stretch"},d={auto:"self-auto",start:"self-start",center:"self-center",end:"self-end",stretch:"self-stretch",baseline:"self-baseline"};export const MPGrid=/*@__PURE__*/e.forwardRef(function({columns:e,spacing:n,rowSpacing:a,columnSpacing:c,justifyContent:i,alignItems:l,alignContent:d,wrap:g=!0,render:h,className:w,style:y,children:x,...j},b){return t({render:h,ref:b,props:{className:["mp-grid flex",g?"flex-wrap":"flex-nowrap","gap-x-(--_mp-gap-x) gap-y-(--_mp-gap-y)",i?p[i]:"",l?u[l]:"",d?m[d]:"",w??""].filter(Boolean).join(" "),style:{...r("cols",s(e,12),o),...r("gap-x",s(c??n,4),f),...r("gap-y",s(a??n,4),f),...y},children:x,...j}})});export const MPGridItem=/*@__PURE__*/e.forwardRef(function({span:e,offset:n,alignSelf:s,render:a,className:o,style:c,children:f,...p},u){return t({render:a,ref:u,props:{className:["mp-grid-item",s?d[s]:"",o??""].filter(Boolean).join(" "),"data-mp-offset":null==n?void 0:"",style:{...i(e),...r("offset",n,l),...c},children:f,...p}})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import type { MPAlign, MPPosition, MPSize, MPVariant } from '../../types.js';
|
|
3
|
+
import type { MPAlign, MPDensity, MPMeasure, MPPosition, MPResponsive, MPSize, MPElevation, MPVariant } from '../../types.js';
|
|
4
4
|
export interface MPHeaderProps extends Omit<React.ComponentPropsWithoutRef<'header'>, 'title'> {
|
|
5
5
|
/**
|
|
6
6
|
* The leading slot: the mark, the product's name, the thing that is the same
|
|
@@ -50,6 +50,16 @@ export interface MPHeaderProps extends Omit<React.ComponentPropsWithoutRef<'head
|
|
|
50
50
|
* @default 'tonal'
|
|
51
51
|
*/
|
|
52
52
|
variant?: MPVariant;
|
|
53
|
+
/**
|
|
54
|
+
* How far off the page the bar is lifted, on MD3's own scale.
|
|
55
|
+
*
|
|
56
|
+
* It moves the tone as well as the shadow — see `MPElevation`. A bar's
|
|
57
|
+
* `elevated` is level 2 rather than 1, because a bar sits over the page's
|
|
58
|
+
* content rather than in it; an explicit level says exactly what it says.
|
|
59
|
+
*
|
|
60
|
+
* Left unset, `variant` decides.
|
|
61
|
+
*/
|
|
62
|
+
elevation?: MPElevation;
|
|
53
63
|
/**
|
|
54
64
|
* The bar's height floor, its gutter and the air between its slots.
|
|
55
65
|
*
|
|
@@ -59,13 +69,25 @@ export interface MPHeaderProps extends Omit<React.ComponentPropsWithoutRef<'head
|
|
|
59
69
|
* @default 'md'
|
|
60
70
|
*/
|
|
61
71
|
size?: MPSize;
|
|
72
|
+
/**
|
|
73
|
+
* Takes room out of the bar's gutter.
|
|
74
|
+
*
|
|
75
|
+
* The height floor is `size`'s and stays where it is: a top app bar that a
|
|
76
|
+
* dense page shrank would move every fixed thing under it, and the bar is the
|
|
77
|
+
* one part of a screen a reader locates by position. What tightens is the
|
|
78
|
+
* room at its edges.
|
|
79
|
+
* @default 0
|
|
80
|
+
*/
|
|
81
|
+
density?: MPDensity;
|
|
62
82
|
/**
|
|
63
83
|
* Holds the row of slots to a measure and centres it while the sheet itself
|
|
64
|
-
* still spans the window. The same
|
|
65
|
-
* `maxWidth`
|
|
84
|
+
* still spans the window. The same prop [MPContainer](./container)'s
|
|
85
|
+
* `maxWidth` is — a rung of the size ladder, a CSS length of your own, or a
|
|
86
|
+
* map keyed by window size class — so a header and the container under it line
|
|
87
|
+
* up on one edge by being given the same value.
|
|
66
88
|
* @default 'none'
|
|
67
89
|
*/
|
|
68
|
-
maxWidth?:
|
|
90
|
+
maxWidth?: MPResponsive<MPMeasure>;
|
|
69
91
|
/**
|
|
70
92
|
* The gutter down each side of the row.
|
|
71
93
|
* @default true
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as i from"react";import{useRender as n}from"@base-ui/react/use-render";import{barSurface as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{hasContent as s}from"../../internal/scale.js";import{sheetPadX as l}from"../../internal/density.js";import{measureValue as m}from"../../internal/measure.js";import{useWindowMins as o}from"../../internal/window-class.js";import{responsiveSlots as d,withBaseline as c}from"../../internal/responsive.js";import{useMPDensity as p,useMPSize as f}from"../../internal/config.js";const x={xs:"min-h-12",sm:"min-h-14",md:"min-h-16",lg:"min-h-20",xl:"min-h-24"},u={xs:"text-mp-title-small",sm:"text-mp-title-medium",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},h={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-4",xl:"gap-5"},g={xs:"gap-3",sm:"gap-4",md:"gap-6",lg:"gap-8",xl:"gap-10"},j={static:"",absolute:"absolute inset-x-0 top-0 z-30",sticky:"sticky top-0 z-30",fixed:"fixed inset-x-0 top-0 z-40"},b={start:"shrink-0",center:"flex-1 basis-0",end:"shrink-0"},v={start:"flex min-w-0 flex-1 items-center justify-start",center:"flex min-w-0 shrink items-center justify-center",end:"flex min-w-0 flex-1 items-center justify-end"};export const MPHeader=/*@__PURE__*/i.forwardRef(function({brand:y,actions:w,align:N="start",position:k="sticky",variant:_="tonal",elevation:z,size:B,density:C,maxWidth:$="none",padded:H=!0,label:M,render:P,className:R,children:W,...q},A){const D=f(B),E=p(C),F=o(),{register:G}=i.useContext(a),I=i.useCallback(e=>{G("header",e),"function"==typeof A?A(e):A&&(A.current=e)},[G,A]);return n({render:P??e("header",{}),ref:I,props:{"aria-label":M,"data-mp-size":D,"data-mp-variant":_,className:["mp-header text-mp-on-surface box-border w-full min-w-0",r(_,z),"outlined"===_?"border-mp-outline-variant border-b":"",j[k],R??""].filter(Boolean).join(" "),children:t("div",{className:["flex w-full items-center",x[D],g[D],H?l(D,E):"","none"===$?"":"mp-measure mx-auto"].filter(Boolean).join(" "),style:"none"===$?void 0:d("measure",c($,"none"),e=>m(e,F)),children:[s(y)?e("div",{className:["mp-header__brand flex min-w-0 items-center",b[N],h[D],u[D]].join(" "),children:y}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null,s(W)?e("div",{className:`mp-header__middle ${v[N]} ${h[D]}`,children:W}):null,s(w)?e("div",{className:["mp-header__actions flex min-w-0 items-center justify-end",b[N],h[D]].join(" "),children:w}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null]}),...q}})});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChartBaseProps } from '../../internal/ChartChrome.js';
|
|
3
|
+
import type { MPChartAxis, MPChartCategory, MPChartSeries } from '../../types.js';
|
|
4
|
+
export interface MPHeatmapChartProps extends ChartBaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* The rows. Each series is one row and its `data` are that row's cells, in
|
|
7
|
+
* the order `categories` names the columns.
|
|
8
|
+
*/
|
|
9
|
+
series: readonly MPChartSeries[];
|
|
10
|
+
/** The column headings. */
|
|
11
|
+
categories?: readonly MPChartCategory[];
|
|
12
|
+
/** The column axis. Only `label`, `hidden` and `tickFormat` mean anything here. */
|
|
13
|
+
xAxis?: MPChartAxis;
|
|
14
|
+
/** The row axis, same three. */
|
|
15
|
+
yAxis?: MPChartAxis;
|
|
16
|
+
/**
|
|
17
|
+
* Where the colour scale starts and ends. Taken from the data otherwise.
|
|
18
|
+
*
|
|
19
|
+
* Worth pinning when two heatmaps are meant to be compared: without it each
|
|
20
|
+
* one scales to its own range, and the darkest cell of a quiet week looks
|
|
21
|
+
* exactly like the darkest cell of a bad one.
|
|
22
|
+
*/
|
|
23
|
+
min?: number;
|
|
24
|
+
max?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Writes each cell's value in it, where the cell is big enough to hold the
|
|
27
|
+
* text. One that does not fit is dropped rather than clipped.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
valueLabels?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A grid of cells, coloured by how much.
|
|
34
|
+
*
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <MPHeatmapChart
|
|
37
|
+
* categories={['Mon', 'Tue', 'Wed']}
|
|
38
|
+
* series={[
|
|
39
|
+
* { name: '09:00', data: [4, 9, 2] },
|
|
40
|
+
* { name: '10:00', data: [7, 12, 5] }
|
|
41
|
+
* ]}
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Two categorical axes and a magnitude in the cells. It is the shape for a
|
|
46
|
+
* pattern across two dimensions — a week by hour, a cohort by month — where
|
|
47
|
+
* what a reader is looking for is *where* the dense part is rather than what
|
|
48
|
+
* any one cell holds.
|
|
49
|
+
*
|
|
50
|
+
* ## Its colour is a ramp, not the palette
|
|
51
|
+
*
|
|
52
|
+
* The eight chart slots are an **identity** channel: they say which series, and
|
|
53
|
+
* nobody can tell whether slot 6 is more than slot 3. A cell's colour here has
|
|
54
|
+
* to say how much, so it comes from a sequential ramp instead — one hue, five
|
|
55
|
+
* steps, running pale to deep on a light page and deep to bright on a dark one,
|
|
56
|
+
* because "more" has to be further from the page in both.
|
|
57
|
+
*
|
|
58
|
+
* That also sidesteps the cap the palette runs into: every cell touches its
|
|
59
|
+
* neighbours, and colour separates only three touching series. A ramp is not
|
|
60
|
+
* being asked to separate anything — it is being asked to be ordered.
|
|
61
|
+
*
|
|
62
|
+
* ## Steps rather than a gradient
|
|
63
|
+
*
|
|
64
|
+
* A smooth fill looks better and reads worse. Given a gradient a reader can say
|
|
65
|
+
* "darker" and nothing else; given five steps they can match a cell to a band
|
|
66
|
+
* in the legend and come away with a number.
|
|
67
|
+
*
|
|
68
|
+
* ## Pin the scale to compare two of them
|
|
69
|
+
*
|
|
70
|
+
* By default each heatmap scales to its own range, so two side by side say
|
|
71
|
+
* nothing to each other — the darkest cell of a quiet week looks exactly like
|
|
72
|
+
* the darkest cell of a bad one. Give both the same `min` and `max` when the
|
|
73
|
+
* comparison is the point.
|
|
74
|
+
*/
|
|
75
|
+
export declare function MPHeatmapChart({ series, categories, xAxis, yAxis, min, max, valueLabels, height, format, locale: localeProp, label, legend, tooltip, empty, size: sizeProp, className, style, ...rest }: MPHeatmapChartProps): React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as t from"react";import{useMPElementSize as n}from"../../hooks/useMPElementSize.js";import{useMPLocale as a,useMPMessages as r}from"../../internal/locale.js";import{useMPSize as o}from"../../internal/config.js";import{CHART as i}from"../../internal/messages/chart.js";import{TABLE as m}from"../../internal/messages/table.js";import{ChartShell as s,ChartTable as c,ChartTooltipPanel as h}from"../../internal/ChartChrome.js";import{CHART_FONT_SIZE as u,MARK_GAP as d,PLOT_HEIGHT as f,RAMP_STEPS as p,formatCategory as x,formatStatistic as g,rampFill as v,rampInk as y,rampStep as w,textWidth as b,toValues as k,truncate as M}from"../../internal/chart.js";export function MPHeatmapChart({series:j,categories:A,xAxis:N,yAxis:S,min:$,max:_,valueLabels:z=!1,height:B,format:C,locale:P,label:D,legend:R,tooltip:L,empty:E,size:F,className:I,style:W,...H}){const K=o(F),U=a(P),X=r(i,U),Y=r(m,U),q=t.useRef(null),G=n(q),J=t.useId(),[O,Q]=t.useState(null),T=t.useMemo(()=>k(j),[j]),V=T.reduce((e,l)=>Math.max(e,l.length),0),Z=t.useCallback(e=>g(e,U,C,!0),[C,U]),ee=j.map((e,l)=>e.name??String(l+1)),le=Array.from({length:V},(e,l)=>N?.tickFormat?String(N.tickFormat(A?.[l]??l,l)):x(A?.[l]??l,U)),te=T.flat().filter(e=>null!==e.value),ne=$??(te.length>0?Math.min(...te.map(e=>e.value)):0),ae=_??(te.length>0?Math.max(...te.map(e=>e.value)):0),re=ae-ne||1,oe=u[K],ie=G.width,me="number"==typeof B?B:void 0===B?f[K]:G.height,se=ee.reduce((e,l)=>Math.max(e,b(l,oe)),0),ce=S?.hidden?0:S?.thickness??Math.min(140,se+10),he=N?.hidden?0:N?.thickness??oe+12,ue=ce,de=0,fe=Math.max(0,ie-ce),pe=Math.max(0,me-he),xe=V>0?fe/V:0,ge=T.length>0?pe/T.length:0,ve=(e,l)=>{Q(t=>{const n=t??{row:0,column:0};return{row:Math.min(T.length-1,Math.max(0,n.row+(t?e:0))),column:Math.min(V-1,Math.max(0,n.column+(t?l:0)))}})},ye=O?T[O.row]?.[O.column]??null:null,we=O&&ye&&null!==ye.value?[{seriesIndex:O.row,name:ee[O.row],color:v(w((ye.value-ne)/re)),value:ye.value,formatted:Z(ye.value),label:ye.label}]:[],be=!1===L?{mode:"none"}:!0===L||void 0===L?{}:L,ke=!1!==R&&te.length>0,Me=0===V||0===T.length||0===te.length,je=Array.from({length:V},(e,l)=>T.map(e=>e[l]??{value:null}));return e(s,{...H,size:K,className:["mp-heatmap-chart",I??""].filter(Boolean).join(" "),style:W,plotRef:q,name:D??X.label,describedBy:Me?void 0:J,interactive:!Me,height:B,legendSide:"bottom",plotProps:{onPointerMove:Me||"none"===be.mode?void 0:e=>Q(((e,l)=>{const t=q.current;if(!t||xe<=0||ge<=0)return null;const n=t.getBoundingClientRect(),a=Math.floor((e-n.left-ue)/xe),r=Math.floor((l-n.top-de)/ge);return a<0||a>=V||r<0||r>=T.length?null:{row:r,column:a}})(e.clientX,e.clientY)),onPointerLeave:()=>Q(null),onKeyDown:Me||"none"===be.mode?void 0:e=>{if("ArrowRight"===e.key)ve(0,1);else if("ArrowLeft"===e.key)ve(0,-1);else if("ArrowDown"===e.key)ve(1,0);else if("ArrowUp"===e.key)ve(-1,0);else{if("Escape"!==e.key)return;Q(null)}e.preventDefault()},onBlur:()=>Q(null)},tooltip:O&&we.length>0&&"none"!==be.mode?e(h,{heading:`${ee[O.row]} · ${le[O.column]}`,items:we,x:ue+(O.column+.5)*xe,y:de+(O.row+.5)*ge,flip:O.column>V/2,size:K}):null,legend:ke?l("div",{className:"mp-chart__legend flex items-center justify-center gap-2",children:[e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:Z(ne)}),e("span",{className:"flex","aria-hidden":"true",children:Array.from({length:p},(l,t)=>e("span",{className:"block h-3 w-6 first:rounded-s-mp-xs last:rounded-e-mp-xs",style:{background:v(t)}},t))}),e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:Z(ae)})]}):null,status:{heading:O?`${ee[O.row]} · ${le[O.column]}`:void 0,items:we},table:Me?null:e(c,{id:J,caption:D??X.table,corner:S?.label??X.category,categories:ee,names:le,values:je,format:Z,locale:U,empty:Y.empty}),children:Me?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:E??Y.empty}):ie>0&&me>0?l("svg",{width:ie,height:me,viewBox:`0 0 ${ie} ${me}`,"aria-hidden":"true",className:"block overflow-visible",children:[e("g",{className:"mp-heatmap-chart__cells",children:T.map((t,n)=>Array.from({length:V},(a,r)=>{const o=t[r],i=O?.row===n&&O?.column===r,m=ue+r*xe,s=de+n*ge,c=Math.max(0,xe-d),h=Math.max(0,ge-d);if(!o||null===o.value)return e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:"none",stroke:"var(--_mp-color-outline-variant)",strokeWidth:1,strokeDasharray:"2 2",rx:2},r);const u=w((o.value-ne)/re);return l("g",{children:[e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:o.color??v(u),rx:2,stroke:i?"var(--_mp-color-on-surface)":"none",strokeWidth:i?2:0}),z&&c>b(Z(o.value),oe)+8&&h>oe+4?e("text",{x:m+xe/2,y:s+ge/2,textAnchor:"middle",dominantBaseline:"central",fill:y(u),fontSize:oe,children:Z(o.value)}):null]},r)}))}),S?.hidden?null:ee.map((l,t)=>e("text",{x:ue-8,y:de+(t+.5)*ge,textAnchor:"end",dominantBaseline:"central",fill:"var(--_mp-color-on-surface-variant)",fontSize:oe,children:M(l,ce-10,oe)},`r${t}`)),N?.hidden?null:le.map((l,t)=>e("text",{x:ue+(t+.5)*xe,y:de+pe+oe+4,textAnchor:"middle",fill:"var(--_mp-color-on-surface-variant)",fontSize:oe,children:M(l,xe-2,oe)},`c${t}`))]}):null})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPHeatmapChart}from"./MPHeatmapChart.js";
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPAlign, MPDensity, MPSide, MPSize } from '../../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The same axes an `MPPopover` takes, and for the same reasons.
|
|
5
|
+
*
|
|
6
|
+
* No `variant`, because the five weights answer "how much does this surface
|
|
7
|
+
* assert itself against the page" and a card that arrives uninvited has already
|
|
8
|
+
* been answered for. No `color`, because MD3's answer for a small sheet
|
|
9
|
+
* anchored to something is `surface-container`, neutral — and a card that could
|
|
10
|
+
* be dyed would dye whatever preview somebody put in it. No `elevation`,
|
|
11
|
+
* because a card floating over the page is the whole idea and a prop that could
|
|
12
|
+
* sit it flat would undo it.
|
|
13
|
+
*/
|
|
14
|
+
export interface MPHoverCardProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title' | 'children'> {
|
|
15
|
+
/**
|
|
16
|
+
* What the card hangs off. Exactly one element, which must accept a ref and
|
|
17
|
+
* spread props — every Material Plus component does.
|
|
18
|
+
*
|
|
19
|
+
* Usually an `MPTextLink` or an `MPAvatar`: the two things a reader wants to
|
|
20
|
+
* know more about without leaving the sentence they are in.
|
|
21
|
+
*/
|
|
22
|
+
trigger: React.ReactElement;
|
|
23
|
+
/** The heading, rendered as the element that names the card. */
|
|
24
|
+
title?: React.ReactNode;
|
|
25
|
+
/** A line under it, and the card's accessible description. */
|
|
26
|
+
description?: React.ReactNode;
|
|
27
|
+
/** The body. */
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Which edge of the trigger it appears on. Flips when there is no room.
|
|
31
|
+
* @default 'bottom'
|
|
32
|
+
*/
|
|
33
|
+
side?: MPSide;
|
|
34
|
+
/** Where it sits along that edge. @default 'center' */
|
|
35
|
+
align?: MPAlign;
|
|
36
|
+
/** Distance from the trigger, in pixels. @default 8 */
|
|
37
|
+
sideOffset?: number;
|
|
38
|
+
/** Shift along that edge, in pixels. @default 0 */
|
|
39
|
+
alignOffset?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Draws the wedge pointing at the trigger.
|
|
42
|
+
*
|
|
43
|
+
* Off by default, as on `MPPopover`: a sheet eight pixels from what opened it
|
|
44
|
+
* does not need to say what it belongs to.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
arrow?: boolean;
|
|
48
|
+
/** Whether the card is open. Use with `onOpenChange` for a controlled one. */
|
|
49
|
+
open?: boolean;
|
|
50
|
+
/** Whether it starts open, for an uncontrolled one. */
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
onOpenChange?: (open: boolean) => void;
|
|
53
|
+
/**
|
|
54
|
+
* How long the pointer has to rest on the trigger before the card opens, in
|
|
55
|
+
* milliseconds. Base UI's own default is long enough that crossing a
|
|
56
|
+
* paragraph of links does not open four of them.
|
|
57
|
+
*/
|
|
58
|
+
delay?: number;
|
|
59
|
+
/**
|
|
60
|
+
* How long the card stays after the pointer has left, in milliseconds. This
|
|
61
|
+
* is what makes the gap between the trigger and the card crossable.
|
|
62
|
+
*/
|
|
63
|
+
closeDelay?: number;
|
|
64
|
+
/** A hard cap on the card's width, overriding the one `size` implies. */
|
|
65
|
+
width?: number | string;
|
|
66
|
+
/** The type scale and the room inside. @default 'md' */
|
|
67
|
+
size?: MPSize;
|
|
68
|
+
/** Takes room out of that padding, two pixels a face per step. @default 0 */
|
|
69
|
+
density?: MPDensity;
|
|
70
|
+
}
|
|
71
|
+
/** The wedge, at roughly a third of the sheet's corner per step. */
|
|
72
|
+
/**
|
|
73
|
+
* A card that opens when the pointer rests on something, holding a preview of
|
|
74
|
+
* what is on the other side of it.
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <MPHoverCard trigger={<MPTextLink href="/people/priya">Priya Raman</MPTextLink>} title="Priya Raman">
|
|
78
|
+
* Platform team. Joined 2023.
|
|
79
|
+
* </MPHoverCard>
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* ## Where it sits between the other two popups
|
|
83
|
+
*
|
|
84
|
+
* A tooltip is a **label**: one line, no interaction, and the pointer never
|
|
85
|
+
* reaches it. A popover is a panel that was **asked for** by a press, so it can
|
|
86
|
+
* hold a form. This one is uninvited like a tooltip and reachable like a
|
|
87
|
+
* popover — the pointer can cross into it, and a link inside it can be
|
|
88
|
+
* followed.
|
|
89
|
+
*
|
|
90
|
+
* ## Because it is uninvited, it is never the only way to anything
|
|
91
|
+
*
|
|
92
|
+
* A keyboard with no hover, a touchscreen with no pointer, and a screen reader
|
|
93
|
+
* all arrive by the trigger's own route instead. So whatever is in here has to
|
|
94
|
+
* exist on the page the trigger leads to as well. Treat it as a shortcut for
|
|
95
|
+
* the reader who has a pointer, never as the place a fact lives.
|
|
96
|
+
*
|
|
97
|
+
* That is also why there is no keyboard equivalent bolted on. A card that
|
|
98
|
+
* opened on focus would interrupt every keyboard reader tabbing through a
|
|
99
|
+
* paragraph of links, which is a worse answer than not opening at all.
|
|
100
|
+
*/
|
|
101
|
+
export declare function MPHoverCard({ trigger, title, description, children, side, align, sideOffset, alignOffset, arrow, open, defaultOpen, onOpenChange, delay, closeDelay, width, size: sizeProp, density: densityProp, className, style, ...props }: MPHoverCardProps): React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{POPUP_ARROW_SIZE as a,POPUP_ARROW_TURN as l,PopupArrow as n}from"../../internal/PopupArrow.js";import{PreviewCard as o}from"@base-ui/react/preview-card";import{cssLength as s}from"../../internal/length.js";import{sheetPad as t}from"../../internal/density.js";import{hasContent as d,META_TEXT as m,PROSE_TEXT as c,SHEET_GAP as p,SHEET_TITLE as f}from"../../internal/scale.js";import{FADE as u,PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPDensity as h,useMPSize as v}from"../../internal/config.js";const g={xs:"max-w-64",sm:"max-w-72",md:"max-w-96",lg:"max-w-md",xl:"max-w-xl"};export function MPHoverCard({trigger:w,title:j,description:y,children:b,side:N="bottom",align:O="center",sideOffset:P=8,alignOffset:_=0,arrow:$=!1,open:z,defaultOpen:C,onOpenChange:A,delay:D,closeDelay:B,width:H,size:I,density:M,className:R,style:T,...W}){const k=v(I),q=h(M),E=d(j)||d(y),F=a[k],G=i.useId(),J=`${G}-title`,K=`${G}-description`;return r(o.Root,{open:z,defaultOpen:C,onOpenChange:e=>A?.(e),children:[e(o.Trigger,{render:w,delay:D,closeDelay:B}),e(o.Portal,{children:e(o.Positioner,{className:x,side:N,align:O,sideOffset:P,alignOffset:_,children:r(o.Popup,{"data-mp-size":k,"aria-labelledby":d(j)?J:void 0,"aria-describedby":d(y)?K:void 0,className:["mp-hover-card rounded-mp-md relative flex flex-col outline-none","bg-mp-surface-container text-mp-on-surface shadow-mp-2","box-border",t(k,q),p[k],c[k],void 0===H?g[k]:"",u,R??""].filter(Boolean).join(" "),style:{...void 0===H?null:{maxWidth:s(H)},...T},...W,children:[$?e(o.Arrow,{className:l,children:e(n,{size:F,fill:"var(--_mp-color-surface-container)"})}):null,E?r("div",{className:"flex min-w-0 flex-col",children:[d(j)?e("div",{id:J,className:`mp-hover-card__title m-0 ${f[k]}`,children:j}):null,d(y)?e("div",{id:K,className:`mp-hover-card__description text-mp-on-surface-variant m-0 ${m}`,children:y}):null]}):null,d(b)?e("div",{className:"min-w-0",children:b}):null]})})})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPHoverCard}from"./MPHoverCard.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as i from"react";function o(e){return!i.isValidElement(e)}export const MPIcon=/*@__PURE__*/i.forwardRef(function({icon:r,size:t,color:
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as i from"react";function o(e){return!i.isValidElement(e)}export const MPIcon=/*@__PURE__*/i.forwardRef(function({icon:r,size:t,color:n,strokeWidth:l,center:s=!1,label:c,className:a,style:d,...m},f){const h=["mp-icon inline-flex shrink-0 items-center justify-center align-middle","[&>svg]:shrink-0 [&>img]:shrink-0",void 0===t?"":"[&>svg]:block [&>svg]:size-full [&>img]:block [&>img]:size-full",s?"justify-self-center":"",a??""].filter(Boolean).join(" ");return e("span",{ref:f,className:h,style:{...void 0===t?{}:{width:t,height:t,fontSize:t},...void 0===n?{}:{color:n},...d},role:c?"img":void 0,"aria-label":c,"aria-hidden":!c||void 0,...m,children:o(r)?i.createElement(r,{size:t,color:void 0===n?"currentColor":n,strokeWidth:l}):r})});
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MPSize } from '../../types.js';
|
|
3
|
-
/** How the picture is fitted into the box it was given. CSS's own
|
|
4
|
-
export type MPImageFit = 'cover' | 'contain' | 'fill' | 'none';
|
|
3
|
+
/** How the picture is fitted into the box it was given. CSS's own words. */
|
|
4
|
+
export type MPImageFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
5
5
|
/** What the picture is doing right now. */
|
|
6
6
|
export type MPImageState = 'loading' | 'loaded' | 'error';
|
|
7
|
+
/** A picture that stands in while the real one arrives. */
|
|
8
|
+
export interface MPImagePlaceholder {
|
|
9
|
+
/**
|
|
10
|
+
* A URL, a data URI, or a `Blob` such as a file the reader has just picked.
|
|
11
|
+
*
|
|
12
|
+
* A `Blob` is drawn through an object URL made for it, so keep the same Blob
|
|
13
|
+
* from one render to the next: a new one on every render makes a new URL on
|
|
14
|
+
* every render, and each of those renders again.
|
|
15
|
+
*/
|
|
16
|
+
src: string | Blob;
|
|
17
|
+
/**
|
|
18
|
+
* Blurs the stand-in. `true` is a 20px radius, and a number is a radius in
|
|
19
|
+
* pixels.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
blur?: boolean | number;
|
|
23
|
+
}
|
|
24
|
+
/** A turn in degrees, clockwise, a quarter at a time. */
|
|
25
|
+
export type MPImageRotate = 0 | 90 | 180 | 270;
|
|
26
|
+
/** Which way the picture is mirrored, along the axes it is shown on. */
|
|
27
|
+
export type MPImageFlip = 'none' | 'horizontal' | 'vertical' | 'both';
|
|
28
|
+
/**
|
|
29
|
+
* The part of the picture a crop keeps, in `object-position`'s words: the
|
|
30
|
+
* centre, a side, a corner, or two percentages across and down.
|
|
31
|
+
*/
|
|
32
|
+
export type MPImagePosition = 'center' | 'top' | 'right' | 'bottom' | 'left' | 'top left' | 'top right' | 'bottom left' | 'bottom right' | `${number}% ${number}%`;
|
|
7
33
|
export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>, 'onError'> {
|
|
8
34
|
/** Where the picture is. */
|
|
9
35
|
src?: string;
|
|
@@ -26,18 +52,44 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
|
|
|
26
52
|
*/
|
|
27
53
|
ratio?: number | string;
|
|
28
54
|
/**
|
|
29
|
-
* How the picture is fitted into that box.
|
|
55
|
+
* How the picture is fitted into that box. `scale-down` is `contain` that
|
|
56
|
+
* never enlarges a file smaller than the box.
|
|
30
57
|
* @default 'cover'
|
|
31
58
|
*/
|
|
32
59
|
fit?: MPImageFit;
|
|
60
|
+
/**
|
|
61
|
+
* The width of the file, or of the box when it is given without `height`.
|
|
62
|
+
*
|
|
63
|
+
* With `height` as well, the two are the file's size in pixels, as on an
|
|
64
|
+
* `<img>`, and they reserve its proportion. Alone, it makes the box that wide,
|
|
65
|
+
* no wider than its container, and as tall as the picture or `ratio` makes
|
|
66
|
+
* it. A number or a string of digits is pixels, and any other string is a CSS
|
|
67
|
+
* length.
|
|
68
|
+
*/
|
|
69
|
+
width?: number | string;
|
|
70
|
+
/**
|
|
71
|
+
* The height of the file, or of the box when it is given without `width`.
|
|
72
|
+
*
|
|
73
|
+
* With `width` as well, the two are the file's size in pixels. Alone, it makes
|
|
74
|
+
* the box that tall and as wide as its container, or as wide as `ratio` makes
|
|
75
|
+
* it when there is one. A number or a string of digits is pixels, and any
|
|
76
|
+
* other string is a CSS length.
|
|
77
|
+
*/
|
|
78
|
+
height?: number | string;
|
|
33
79
|
/**
|
|
34
80
|
* Drawn while the picture is on its way.
|
|
35
81
|
*
|
|
36
82
|
* A shimmer by default, on the surface the box sits on. `false` draws nothing,
|
|
37
83
|
* which is what a picture inside something that already has its own loading
|
|
38
84
|
* treatment wants.
|
|
85
|
+
*
|
|
86
|
+
* `{ src, blur }` draws a picture instead: a small copy of the file, a data
|
|
87
|
+
* URI or a `Blob`, fitted, placed, turned and mirrored like the picture, and
|
|
88
|
+
* blurred if `blur` says so. It gives way once the picture has faded in over
|
|
89
|
+
* it. Like the shimmer, it fills the box, so the box needs a reserved size: a
|
|
90
|
+
* `ratio`, or both `width` and `height`.
|
|
39
91
|
*/
|
|
40
|
-
placeholder?: React.ReactNode | false;
|
|
92
|
+
placeholder?: React.ReactNode | false | MPImagePlaceholder;
|
|
41
93
|
/**
|
|
42
94
|
* Drawn instead of the picture when it does not arrive.
|
|
43
95
|
*
|
|
@@ -64,8 +116,73 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
|
|
|
64
116
|
previewSrc?: string;
|
|
65
117
|
/** The label on the button `preview` turns the box into. */
|
|
66
118
|
previewLabel?: string;
|
|
67
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Called when the state changes, for a caller that wants to know.
|
|
121
|
+
*
|
|
122
|
+
* **This is the signal to use, not `onLoad`.** `onLoad` is the `<img>`'s own
|
|
123
|
+
* event and is passed straight through, so it does not fire for a picture the
|
|
124
|
+
* browser already has: the load has been and gone before React attached
|
|
125
|
+
* anything, which is the whole reason this component exists. `onStateChange`
|
|
126
|
+
* is reported from the `complete` check as well as from the event, so it
|
|
127
|
+
* arrives either way.
|
|
128
|
+
*/
|
|
68
129
|
onStateChange?: (state: MPImageState) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Turns the picture clockwise, in quarter turns.
|
|
132
|
+
*
|
|
133
|
+
* Only quarters, because a picture turned by any other angle stops covering
|
|
134
|
+
* its box, and filling the corners would mean enlarging it by an amount the
|
|
135
|
+
* caller would then want to tune. A quarter turn swaps the box's proportion:
|
|
136
|
+
* `width` and `height`, when both are given, are read as the file's size and
|
|
137
|
+
* reserve the turned shape, and without them the shape is read from the file
|
|
138
|
+
* once it arrives. An explicit `ratio` is the layout's shape and is kept.
|
|
139
|
+
*
|
|
140
|
+
* Drawn with the `rotate` property rather than `transform`, so a `transform`
|
|
141
|
+
* of your own, such as a hover zoom, still applies on top.
|
|
142
|
+
* @default 0
|
|
143
|
+
*/
|
|
144
|
+
rotate?: MPImageRotate;
|
|
145
|
+
/**
|
|
146
|
+
* Mirrors the picture along the axes it is shown on.
|
|
147
|
+
*
|
|
148
|
+
* `horizontal` swaps left and right on the screen whether or not the picture
|
|
149
|
+
* is turned. Drawn with the `scale` property, so it leaves `transform` free as
|
|
150
|
+
* `rotate` does, and `preview` opens the picture mirrored.
|
|
151
|
+
* @default 'none'
|
|
152
|
+
*/
|
|
153
|
+
flip?: MPImageFlip;
|
|
154
|
+
/**
|
|
155
|
+
* Which part of the picture a `cover` crop keeps, and where `contain`, `none`
|
|
156
|
+
* and `scale-down` leave their empty space.
|
|
157
|
+
*
|
|
158
|
+
* Read on the picture as it is shown, so `top` keeps the top of a picture
|
|
159
|
+
* that has been turned or mirrored. Physical rather than logical: the subject
|
|
160
|
+
* of a photograph does not move to the other side on a right-to-left page. A
|
|
161
|
+
* value in any other form reaches `object-position` as written.
|
|
162
|
+
* @default 'center'
|
|
163
|
+
*/
|
|
164
|
+
position?: MPImagePosition;
|
|
165
|
+
/**
|
|
166
|
+
* What fills the room `fit` leaves around the picture.
|
|
167
|
+
*
|
|
168
|
+
* `blur` draws the same picture behind itself, covering the box and blurred,
|
|
169
|
+
* the way a video player fills the sides of a portrait clip. It reuses the
|
|
170
|
+
* picture's request, and it is drawn only for a `fit` that can leave room:
|
|
171
|
+
* `contain`, `none` and `scale-down`. Any other string is a CSS `background`
|
|
172
|
+
* painted behind the picture: a colour, a custom property or a gradient.
|
|
173
|
+
* @default 'none'
|
|
174
|
+
*/
|
|
175
|
+
letterbox?: 'none' | 'blur' | (string & {});
|
|
176
|
+
/**
|
|
177
|
+
* Loads this picture first: the one a page is judged by, which is usually its
|
|
178
|
+
* Largest Contentful Paint.
|
|
179
|
+
*
|
|
180
|
+
* Sets `loading="eager"` and a high fetch priority. A `loading` or
|
|
181
|
+
* `fetchPriority` of your own still wins. Give it to one picture per page: a
|
|
182
|
+
* high priority on every picture raises none of them above the others.
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
priority?: boolean;
|
|
69
186
|
/** The corner and type scale of the placeholder and the fallback. @default 'md' */
|
|
70
187
|
size?: MPSize;
|
|
71
188
|
}
|