material-plus-ui 1.5.0 → 1.7.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/README.md +2 -2
- package/dist/components/accordion/MPAccordion.d.ts +21 -1
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/alert/MPAlert.d.ts +33 -2
- 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 +2 -1
- 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 +156 -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.js +2 -1
- package/dist/components/avatar/MPAvatar.d.ts +10 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/badge/MPBadge.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 +10 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +19 -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.d.ts +49 -3
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.d.ts +160 -0
- package/dist/components/calendar/MPCalendar.js +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/MPCard.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +31 -7
- 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 +71 -5
- 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 +166 -0
- package/dist/components/config/MPConfigProvider.js +2 -0
- package/dist/components/config/index.d.ts +2 -0
- package/dist/components/config/index.js +1 -0
- package/dist/components/confirm/MPConfirmProvider.d.ts +143 -0
- package/dist/components/confirm/MPConfirmProvider.js +2 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- 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 +295 -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.d.ts +53 -2
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +24 -3
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.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 +23 -1
- 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 +100 -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/image/MPImage.d.ts +121 -0
- package/dist/components/image/MPImage.js +2 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- 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 +51 -1
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +21 -2
- 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.d.ts +3 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +1 -1
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.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 +92 -0
- package/dist/components/popconfirm/MPPopconfirm.js +2 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +1 -1
- 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/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- 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 +28 -5
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.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/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +27 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +20 -1
- package/dist/components/snackbar/MPSnackbar.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.d.ts +153 -0
- package/dist/components/stepper/MPStepper.js +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/index.js +1 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +24 -2
- 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/text-field/MPTextField.d.ts +38 -14
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline/MPTimeline.d.ts +10 -2
- 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/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 +17 -1
- package/dist/components/typography/MPTypography.js +1 -1
- package/dist/components/visually-hidden/MPVisuallyHidden.d.ts +60 -0
- package/dist/components/visually-hidden/MPVisuallyHidden.js +2 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/constants/glyphs.d.ts +4 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +2 -0
- package/dist/constants/icons.js +1 -1
- package/dist/hooks/index.d.ts +40 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +135 -0
- package/dist/hooks/useMPColorScheme.js +2 -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.d.ts +32 -0
- package/dist/hooks/useMPReducedMotion.js +2 -0
- package/dist/hooks/useMPShortcut.d.ts +105 -0
- package/dist/hooks/useMPShortcut.js +2 -0
- package/dist/hooks/useMPWindowClass.d.ts +55 -0
- package/dist/hooks/useMPWindowClass.js +2 -0
- package/dist/index.d.ts +43 -1
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +19 -4
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +205 -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.d.ts +15 -3
- package/dist/internal/Picker.js +1 -1
- 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 +471 -0
- package/dist/internal/chart.js +1 -0
- package/dist/internal/color-scheme.d.ts +28 -0
- package/dist/internal/color-scheme.js +2 -0
- package/dist/internal/config.d.ts +62 -0
- package/dist/internal/config.js +2 -0
- package/dist/internal/data-table.d.ts +162 -0
- package/dist/internal/data-table.js +1 -0
- package/dist/internal/date.d.ts +50 -3
- 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 +196 -1
- package/dist/internal/initials.d.ts +28 -0
- package/dist/internal/initials.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/confirm.d.ts +3 -0
- package/dist/internal/messages/confirm.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/picker.js +1 -1
- 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/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/progress.d.ts +14 -0
- 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 +86 -0
- package/dist/internal/step.js +1 -0
- 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 +48 -0
- package/dist/internal/window-class.js +2 -0
- 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 +2 -0
- 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 +2 -0
- package/dist/styles/confirm.css +2 -0
- 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/image.css +2 -0
- 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/panes.css +1 -1
- package/dist/styles/pie-chart.css +2 -0
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popconfirm.css +2 -0
- 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/shortcut.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 +2 -0
- 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/visually-hidden.css +2 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1423 -114
- package/dist/types.d.ts +628 -3
- package/package.json +8 -2
- 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,205 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChartValue } from './chart.js';
|
|
3
|
+
import type { MPChartCategory, MPChartLegend, MPChartTooltip, MPChartTooltipItem, MPSide, MPSize } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Everything a chart draws that is not the data.
|
|
6
|
+
*
|
|
7
|
+
* The legend, the hover panel, the spoken readout, the table behind the picture
|
|
8
|
+
* and the arrangement that holds them — the parts a pie chart and a line chart
|
|
9
|
+
* have in common, which is all of them except the plot.
|
|
10
|
+
*
|
|
11
|
+
* A file of its own for the reason `internal/density.ts` has one: the split
|
|
12
|
+
* stylesheet is cut along the import graph a **file** at a time, so a pie chart
|
|
13
|
+
* reaching into `ChartFrame.tsx` for a legend would carry the axes, the scales
|
|
14
|
+
* and the column hit-testing it has no use for. It arrives here instead, and
|
|
15
|
+
* the cartesian frame is one more consumer rather than the owner.
|
|
16
|
+
*/
|
|
17
|
+
/** What every framed chart takes, whatever it draws. */
|
|
18
|
+
export interface ChartBaseProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children' | 'title'> {
|
|
19
|
+
/**
|
|
20
|
+
* How tall the drawing is. A number is pixels; a string is any CSS length.
|
|
21
|
+
* Defaults to the `size` ladder.
|
|
22
|
+
*
|
|
23
|
+
* The axis labels are drawn **inside** this rather than under it, so a card
|
|
24
|
+
* sized to the chart is a card the chart fits in.
|
|
25
|
+
*/
|
|
26
|
+
height?: number | string;
|
|
27
|
+
/**
|
|
28
|
+
* How numbers are written everywhere they appear — the axis, the panel, the
|
|
29
|
+
* table. `Intl.NumberFormat` options, the same prop `MPStatistic` takes.
|
|
30
|
+
*
|
|
31
|
+
* Without it a tick is compacted past ten thousand, because four labels of
|
|
32
|
+
* seven digits is not an axis, it is a column of numbers beside a picture.
|
|
33
|
+
*/
|
|
34
|
+
format?: Intl.NumberFormatOptions;
|
|
35
|
+
/** Which language the chart's own words and dates are in. */
|
|
36
|
+
locale?: string;
|
|
37
|
+
/**
|
|
38
|
+
* What the chart is a chart **of**. Read out in place of the drawing, and
|
|
39
|
+
* used as the caption of the table behind it.
|
|
40
|
+
*/
|
|
41
|
+
label?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The legend. Drawn from two series up and left off below that, because a
|
|
44
|
+
* legend with one swatch in it restates the title.
|
|
45
|
+
*/
|
|
46
|
+
legend?: boolean | MPChartLegend;
|
|
47
|
+
/**
|
|
48
|
+
* What the pointer uncovers. On by default: a chart drawn in a browser is
|
|
49
|
+
* interactive, and a reader who wants March's number should not have to
|
|
50
|
+
* measure it against a gridline.
|
|
51
|
+
*/
|
|
52
|
+
tooltip?: boolean | MPChartTooltip;
|
|
53
|
+
/** What to draw when there is nothing to draw. */
|
|
54
|
+
empty?: React.ReactNode;
|
|
55
|
+
/** @default 'md' */
|
|
56
|
+
size?: MPSize;
|
|
57
|
+
}
|
|
58
|
+
export interface Visibility {
|
|
59
|
+
visible: boolean[];
|
|
60
|
+
hovered: number | null;
|
|
61
|
+
toggle: (index: number) => void;
|
|
62
|
+
setHovered: (index: number | null) => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Which entries are drawn, and which one the legend is being pointed at.
|
|
66
|
+
*
|
|
67
|
+
* Keyed by an entry's place in the array as it was passed, which is what stops
|
|
68
|
+
* a hidden one renumbering those after it. Colours come off that same index, so
|
|
69
|
+
* hiding Europe leaves Asia exactly the colour it already was.
|
|
70
|
+
*
|
|
71
|
+
* It takes anything that can say whether it starts hidden rather than a series
|
|
72
|
+
* specifically, because a pie's entries are its slices.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useVisibility(series: readonly {
|
|
75
|
+
hidden?: boolean;
|
|
76
|
+
}[]): Visibility;
|
|
77
|
+
export declare const LEGEND_SIDE: {
|
|
78
|
+
readonly top: "flex-col-reverse";
|
|
79
|
+
readonly bottom: "flex-col";
|
|
80
|
+
readonly left: "flex-row-reverse";
|
|
81
|
+
readonly right: "flex-row";
|
|
82
|
+
};
|
|
83
|
+
interface LegendProps {
|
|
84
|
+
/**
|
|
85
|
+
* What each entry is called. Names rather than series, because a pie's
|
|
86
|
+
* entries are its slices — the entity a legend identifies is not always a
|
|
87
|
+
* series, and a legend that insisted on one would be a legend a pie has to
|
|
88
|
+
* fake a series array for.
|
|
89
|
+
*/
|
|
90
|
+
names: readonly (string | undefined)[];
|
|
91
|
+
colors: readonly string[];
|
|
92
|
+
options: MPChartLegend;
|
|
93
|
+
visibility: Visibility;
|
|
94
|
+
size: MPSize;
|
|
95
|
+
values?: readonly (string | undefined)[];
|
|
96
|
+
swatch?: (index: number, color: string) => React.ReactNode;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The identity channel that does not depend on being able to see a colour.
|
|
100
|
+
*
|
|
101
|
+
* A swatch and a word, and the swatch is the only thing on the row wearing the
|
|
102
|
+
* series' colour — the name beside it stays in ordinary ink. That is the rule
|
|
103
|
+
* for every piece of text in a chart: a label written in the mark's colour is a
|
|
104
|
+
* label the reader has to decode before they can read it, and it fails outright
|
|
105
|
+
* in forced colours.
|
|
106
|
+
*
|
|
107
|
+
* Interactive by default, and each entry is a real `<button>` with
|
|
108
|
+
* `aria-pressed`. A legend that filters is a control, and a control that is a
|
|
109
|
+
* `<div>` with an `onClick` is one a keyboard cannot reach.
|
|
110
|
+
*/
|
|
111
|
+
export declare function ChartLegend({ names, colors, options, visibility, size, values, swatch }: LegendProps): React.JSX.Element;
|
|
112
|
+
interface PanelProps {
|
|
113
|
+
heading?: React.ReactNode;
|
|
114
|
+
items: readonly MPChartTooltipItem[];
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
flip: boolean;
|
|
118
|
+
size: MPSize;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* What the pointer uncovers, as a panel.
|
|
122
|
+
*
|
|
123
|
+
* `pointer-events-none` is the load-bearing part: a panel that could be hovered
|
|
124
|
+
* would sit under the pointer, take the hover from the plot, and close itself —
|
|
125
|
+
* then reopen, then close, for as long as the reader held still.
|
|
126
|
+
*/
|
|
127
|
+
export declare function ChartTooltipPanel({ heading, items, x, y, flip, size }: PanelProps): React.JSX.Element;
|
|
128
|
+
/**
|
|
129
|
+
* The same reading, said out loud instead of drawn.
|
|
130
|
+
*
|
|
131
|
+
* It cannot be the panel above, and that is a constraint rather than a
|
|
132
|
+
* preference: the panel is drawn inside the element carrying `role="img"`, and
|
|
133
|
+
* `img` is a leaf role — everything under it is cut out of the accessibility
|
|
134
|
+
* tree, so a live region in there announces to nobody. This is a **sibling** of
|
|
135
|
+
* the picture, clipped rather than painted, and it is what makes the arrow keys
|
|
136
|
+
* mean something to a reader who is not looking at the plot.
|
|
137
|
+
*
|
|
138
|
+
* Empty when nothing is active, so leaving the chart clears what was said
|
|
139
|
+
* rather than leaving the last column standing in the region forever.
|
|
140
|
+
*/
|
|
141
|
+
export declare function ChartStatus({ heading, items }: {
|
|
142
|
+
heading?: React.ReactNode;
|
|
143
|
+
items: readonly MPChartTooltipItem[];
|
|
144
|
+
}): React.JSX.Element;
|
|
145
|
+
interface TableProps {
|
|
146
|
+
id: string;
|
|
147
|
+
caption: string;
|
|
148
|
+
corner: React.ReactNode;
|
|
149
|
+
categories: readonly MPChartCategory[];
|
|
150
|
+
/** One per column, beside the category's own. */
|
|
151
|
+
names: readonly (string | undefined)[];
|
|
152
|
+
values: readonly (readonly ChartValue[])[];
|
|
153
|
+
format: (value: number) => string;
|
|
154
|
+
locale: string | undefined;
|
|
155
|
+
empty: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The numbers behind the picture, as a grid.
|
|
159
|
+
*
|
|
160
|
+
* Clipped rather than drawn. Every chart here ships one and it is what
|
|
161
|
+
* `aria-describedby` points at, so a reader who cannot see the plot has the
|
|
162
|
+
* data itself rather than a summary of it — and a reader who can see the plot
|
|
163
|
+
* is not made to scroll past a table they did not ask for.
|
|
164
|
+
*
|
|
165
|
+
* Rendered rather than built on demand, because it is the description of a
|
|
166
|
+
* focusable element: an `aria-describedby` pointing at an id that does not
|
|
167
|
+
* exist yet is an `aria-describedby` pointing at nothing.
|
|
168
|
+
*/
|
|
169
|
+
export declare function ChartTable({ id, caption, corner, categories, names, values, format, locale, empty }: TableProps): React.JSX.Element;
|
|
170
|
+
export interface ChartShellProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'color' | 'title'> {
|
|
171
|
+
size: MPSize;
|
|
172
|
+
/** The element the drawing is measured in and focused on. */
|
|
173
|
+
plotRef: React.RefObject<HTMLDivElement | null>;
|
|
174
|
+
/** Its accessible name, already resolved — never an optional prop passed straight through. */
|
|
175
|
+
name: string;
|
|
176
|
+
/** The id of the table describing it, or nothing when there is nothing to describe. */
|
|
177
|
+
describedBy?: string;
|
|
178
|
+
/** Whether there is anything here to walk. A chart with no data is not a tab stop. */
|
|
179
|
+
interactive: boolean;
|
|
180
|
+
height?: number | string;
|
|
181
|
+
/** The pointer and keyboard handlers, which are the plot's own business. */
|
|
182
|
+
plotProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
183
|
+
/** The drawing: an `<svg>`, or the empty state. */
|
|
184
|
+
children: React.ReactNode;
|
|
185
|
+
/** Floated over the drawing. */
|
|
186
|
+
tooltip?: React.ReactNode;
|
|
187
|
+
legend?: React.ReactNode;
|
|
188
|
+
legendSide?: MPSide;
|
|
189
|
+
status: {
|
|
190
|
+
heading?: React.ReactNode;
|
|
191
|
+
items: readonly MPChartTooltipItem[];
|
|
192
|
+
};
|
|
193
|
+
table?: React.ReactNode;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The arrangement: a plot, a legend on one of its four sides, a readout beside
|
|
197
|
+
* it and the table underneath.
|
|
198
|
+
*
|
|
199
|
+
* The readout is a **sibling** of the plot rather than a child, and that is a
|
|
200
|
+
* constraint rather than a layout preference — see `ChartStatus`. Putting the
|
|
201
|
+
* arrangement here is what keeps the two frames from disagreeing about it: the
|
|
202
|
+
* one place this is easy to get wrong is the one place it must not be.
|
|
203
|
+
*/
|
|
204
|
+
export declare function ChartShell({ size, plotRef, name, describedBy, interactive, height, plotProps, children, tooltip, legend, legendSide, status, table, className, ...rest }: ChartShellProps): React.JSX.Element;
|
|
205
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{VISUALLY_HIDDEN as a}from"./visually-hidden.js";import{cssLength as r}from"./length.js";import{PLOT_HEIGHT as i,formatCategory as s}from"./chart.js";export function useVisibility(e){const[t,l]=n.useState(()=>{const t=new Set;return e.forEach((e,l)=>{e.hidden&&t.add(l)}),t}),[a,r]=n.useState(null),i=n.useCallback(e=>{l(t=>{const l=new Set(t);return l.has(e)?l.delete(e):l.add(e),l})},[]);return{visible:e.map((e,l)=>!t.has(l)),hovered:a,toggle:i,setHovered:r}}export const LEGEND_SIDE={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"};const o={start:"justify-start",center:"justify-center",end:"justify-end"};export function ChartLegend({names:n,colors:a,options:r,visibility:i,size:s,values:c,swatch:m}){const d=!1!==r.interactive,u="xs"===s||"sm"===s?"text-mp-label-small":"text-mp-label-medium";return e("ul",{className:["mp-chart__legend flex flex-wrap items-center gap-x-4 gap-y-1",o[r.align??"center"],u].join(" "),children:n.map((n,r)=>{const s=i.visible[r],o=!s||null!==i.hovered&&i.hovered!==r,u=n??`${r+1}`,p=l(t,{children:[e("span",{className:"shrink-0","aria-hidden":"true",children:m?m(r,a[r]):e("span",{className:"block size-2.5 rounded-mp-full",style:{background:a[r]}})}),e("span",{className:"text-mp-on-surface-variant truncate",children:u}),c?.[r]?e("span",{className:"text-mp-on-surface tabular-nums",children:c[r]}):null]});return e("li",{className:"min-w-0",children:d?e("button",{type:"button","aria-pressed":s,onClick:()=>i.toggle(r),onPointerEnter:()=>i.setHovered(r),onPointerLeave:()=>i.setHovered(null),onFocus:()=>i.setHovered(r),onBlur:()=>i.setHovered(null),className:["flex min-w-0 cursor-pointer items-center gap-1.5 rounded-mp-xs","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2",o?"opacity-40":"",s?"":"line-through"].filter(Boolean).join(" "),children:p}):e("span",{className:"flex min-w-0 items-center gap-1.5 "+(o?"opacity-40":""),children:p})},r)})})}export function ChartTooltipPanel({heading:t,items:n,x:a,y:r,flip:i,size:s}){return l("div",{"aria-hidden":"true",className:["mp-chart__tooltip pointer-events-none absolute z-10 min-w-24 max-w-64","bg-mp-surface-container-high shadow-mp-2 rounded-mp-xs px-2.5 py-2","xs"===s||"sm"===s?"text-mp-label-small":"text-mp-label-medium"].join(" "),style:{left:a,top:r,transform:`translate(${i?"calc(-100% - 12px)":"12px"}, -50%)`},children:[null==t||""===t?null:e("div",{className:"text-mp-on-surface-variant mb-1 truncate",children:t}),e("ul",{className:"flex flex-col gap-0.5",children:n.map(t=>l("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"block size-2 shrink-0 rounded-mp-full",style:{background:t.color}}),t.name?e("span",{className:"text-mp-on-surface-variant min-w-0 truncate",children:t.name}):null,e("span",{className:"text-mp-on-surface ms-auto ps-2 tabular-nums",children:t.label??t.formatted})]},t.seriesIndex))})]})}export function ChartStatus({heading:r,items:i}){return e("span",{role:"status","aria-live":"polite",className:a,children:0===i.length?null:l(t,{children:[null==r||""===r?null:l(t,{children:[r,", "]}),i.map((e,t)=>l(n.Fragment,{children:[t>0?", ":null,e.name?`${e.name}: `:null,e.label??e.formatted]},e.seriesIndex))]})})}export function ChartTable({id:t,caption:n,corner:r,categories:i,names:o,values:c,format:m,locale:d,empty:u}){return e("div",{id:t,className:a,children:l("table",{children:[e("caption",{children:n}),e("thead",{children:l("tr",{children:[e("th",{scope:"col",children:r}),o.map((t,l)=>e("th",{scope:"col",children:t??l+1},l))]})}),e("tbody",{children:0===i.length?e("tr",{children:e("td",{colSpan:o.length+1,children:u})}):i.map((t,n)=>l("tr",{children:[e("th",{scope:"row",children:s(t,d)}),o.map((t,l)=>{const a=c[l]?.[n];return e("td",{children:a?.label??(null===a?.value||void 0===a?u:m(a.value))},l)})]},n))})]})})}export function ChartShell({size:t,plotRef:n,name:a,describedBy:s,interactive:o,height:c,plotProps:m,children:d,tooltip:u,legend:p,legendSide:h="bottom",status:f,table:x,className:v,...b}){return l("div",{"data-mp-size":t,className:["mp-chart flex min-w-0 flex-col gap-3",v??""].filter(Boolean).join(" "),...b,children:[l("div",{className:`flex min-w-0 gap-3 ${LEGEND_SIDE[h]}`,children:[l("div",{ref:n,role:"img",tabIndex:o?0:void 0,"aria-label":a,"aria-describedby":s,...m,className:["mp-chart__plot rounded-mp-xs relative min-w-0 flex-1","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2"].join(" "),style:{height:r(c)??i[t]},children:[d,u]}),p]}),e(ChartStatus,{heading:f.heading,items:f.items}),x]})}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ChartBaseProps } from './ChartChrome.js';
|
|
3
|
+
import { BandScale, ChartValue, PlotBox, ValueScale } from './chart.js';
|
|
4
|
+
import type { MPChartAxis, MPChartCategory, MPChartSeries, MPChartTooltipItem, MPSize } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* The frame a chart with two axes is drawn in.
|
|
7
|
+
*
|
|
8
|
+
* The plot box once the axes have taken their bands, the value scale, the band
|
|
9
|
+
* scale, the grid and the crosshair — everything that is identical on a line
|
|
10
|
+
* chart and a bar chart. What is left for a chart to do is its marks, and it is
|
|
11
|
+
* handed **pixels** to draw them at: a component that had to know which way
|
|
12
|
+
* round the axes run is a component that gets it wrong when somebody turns it
|
|
13
|
+
* sideways.
|
|
14
|
+
*
|
|
15
|
+
* The parts a chart with no axes also needs — the legend, the hover panel, the
|
|
16
|
+
* spoken readout, the table and the arrangement holding them — are in
|
|
17
|
+
* `ChartChrome.tsx`, so a pie chart can have them without carrying any of this.
|
|
18
|
+
*/
|
|
19
|
+
/** What a chart with two axes adds. */
|
|
20
|
+
export interface CartesianChartProps extends ChartBaseProps {
|
|
21
|
+
/** The series, in the order their colours are handed out. */
|
|
22
|
+
series: readonly MPChartSeries[];
|
|
23
|
+
/** The category axis' labels. Points may carry their own `x` instead. */
|
|
24
|
+
categories?: readonly MPChartCategory[];
|
|
25
|
+
/** The category axis. */
|
|
26
|
+
xAxis?: MPChartAxis;
|
|
27
|
+
/** The value axis. */
|
|
28
|
+
yAxis?: MPChartAxis;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One mark on a plot whose marks are not arranged in columns.
|
|
32
|
+
*
|
|
33
|
+
* A scatter has no shared categories, so there is no column for a pointer to be
|
|
34
|
+
* inside and nothing for a crosshair to be dropped through — the only question
|
|
35
|
+
* a reader can be asking is "which of these dots". A chart that says so hands
|
|
36
|
+
* the frame its marks and gets the nearest-mark search, the arrow keys and the
|
|
37
|
+
* panel's anchoring for free.
|
|
38
|
+
*/
|
|
39
|
+
export interface ChartMark {
|
|
40
|
+
/** Its series' place in the array as it was passed — where its colour is from. */
|
|
41
|
+
series: number;
|
|
42
|
+
/** Its own place within that series. */
|
|
43
|
+
index: number;
|
|
44
|
+
/** Its centre, in pixels from the chart's top-left. */
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
/** How big it is. Widens the hit target, so a bubble is easier to hit than a dot. */
|
|
48
|
+
r: number;
|
|
49
|
+
/**
|
|
50
|
+
* Its half-width and half-height, where the mark is a box rather than a disc.
|
|
51
|
+
*
|
|
52
|
+
* A span on a timeline is two hundred pixels of bar whose centre a pointer may
|
|
53
|
+
* never go near, so measuring to that centre would hand the row's short bar a
|
|
54
|
+
* hover the reader is plainly not making. Given these, the pointer is tested
|
|
55
|
+
* against the mark's **body**.
|
|
56
|
+
*/
|
|
57
|
+
rx?: number;
|
|
58
|
+
ry?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Where everything goes — the half of the context settled before the pointer is
|
|
62
|
+
* consulted.
|
|
63
|
+
*
|
|
64
|
+
* Split out because the marks are built from it: a chart hands the frame a
|
|
65
|
+
* builder, the frame runs it on the layout, and only then is there a list for
|
|
66
|
+
* the pointer to be nearest to. A builder that could read what is active would
|
|
67
|
+
* be reading a value that does not exist yet.
|
|
68
|
+
*/
|
|
69
|
+
export interface CartesianLayout {
|
|
70
|
+
plot: PlotBox;
|
|
71
|
+
/** Every series unpacked, in the order it was passed. */
|
|
72
|
+
values: readonly (readonly ChartValue[])[];
|
|
73
|
+
/** Which of them are drawn. */
|
|
74
|
+
visible: readonly boolean[];
|
|
75
|
+
/** And what colour each one is, by its original index. */
|
|
76
|
+
colors: readonly string[];
|
|
77
|
+
scale: ValueScale;
|
|
78
|
+
band: BandScale;
|
|
79
|
+
/** Bars run along the category axis rather than across it. */
|
|
80
|
+
horizontal: boolean;
|
|
81
|
+
/** Where a value sits along the value axis, in pixels from the chart's edge. */
|
|
82
|
+
valuePx: (value: number) => number;
|
|
83
|
+
/** Where a category's centre sits along the category axis, as an offset along it. */
|
|
84
|
+
categoryPx: (index: number) => number;
|
|
85
|
+
/** The two combined, whichever way round the chart runs. */
|
|
86
|
+
point: (index: number, value: number) => {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The scale the **category** axis runs on, where `xScale` made it a second
|
|
92
|
+
* value axis. `null` on every chart whose categories are columns.
|
|
93
|
+
*/
|
|
94
|
+
categoryScale: ValueScale | null;
|
|
95
|
+
/**
|
|
96
|
+
* Where a value sits along the category axis, in pixels from the chart's
|
|
97
|
+
* edge — the same absolute reckoning `valuePx` uses, and deliberately not
|
|
98
|
+
* `categoryPx`'s offset-along-the-axis. Only meaningful with `xScale="value"`.
|
|
99
|
+
*/
|
|
100
|
+
categoryValuePx: (value: number) => number;
|
|
101
|
+
/** Where the baseline sits along the value axis. */
|
|
102
|
+
zeroPx: number;
|
|
103
|
+
categories: readonly MPChartCategory[];
|
|
104
|
+
format: (value: number) => string;
|
|
105
|
+
size: MPSize;
|
|
106
|
+
}
|
|
107
|
+
/** The layout, plus everything the pointer decides. */
|
|
108
|
+
export interface CartesianContext extends CartesianLayout {
|
|
109
|
+
/** The series the legend is being hovered over, if any. */
|
|
110
|
+
hovered: number | null;
|
|
111
|
+
/** The category under the pointer, if any. */
|
|
112
|
+
activeIndex: number | null;
|
|
113
|
+
/** Every mark, where the chart supplied a builder. Empty otherwise. */
|
|
114
|
+
marks: readonly ChartMark[];
|
|
115
|
+
/** The one the pointer is on, or the one the arrow keys walked to. */
|
|
116
|
+
activeMark: ChartMark | null;
|
|
117
|
+
}
|
|
118
|
+
interface CartesianFrameProps extends CartesianChartProps {
|
|
119
|
+
/**
|
|
120
|
+
* Makes the category axis a second **value** axis instead of a row of
|
|
121
|
+
* columns. What a scatter needs and what nothing else does.
|
|
122
|
+
* @default 'band'
|
|
123
|
+
*/
|
|
124
|
+
xScale?: 'band' | 'value';
|
|
125
|
+
/**
|
|
126
|
+
* Builds every mark on the plot, which swaps the frame's column hit-testing
|
|
127
|
+
* for a nearest-mark search and makes the arrow keys walk this list. The
|
|
128
|
+
* result comes back on the context, so the marks are laid out once and drawn
|
|
129
|
+
* from the same array they are tested against.
|
|
130
|
+
*/
|
|
131
|
+
marks?: (layout: CartesianLayout) => readonly ChartMark[];
|
|
132
|
+
/**
|
|
133
|
+
* How far off a mark the pointer still counts as on it, in pixels, added to
|
|
134
|
+
* the mark's own radius. An 8px dot is not a hit target.
|
|
135
|
+
* @default 24
|
|
136
|
+
*/
|
|
137
|
+
markRadius?: number;
|
|
138
|
+
/** The legend's swatch, where a chart's marks are not all the same shape. */
|
|
139
|
+
swatch?: (index: number, color: string) => React.ReactNode;
|
|
140
|
+
/**
|
|
141
|
+
* The value axis' scale, already worked out.
|
|
142
|
+
*
|
|
143
|
+
* For an axis that is not a count. `valueScale` rounds to 1-2-5-10, which is
|
|
144
|
+
* the family a reader does arithmetic in and exactly the wrong one for an
|
|
145
|
+
* instant — sixty, twenty-four, seven, twelve. A chart whose axis has its own
|
|
146
|
+
* arithmetic builds the scale itself and hands it over.
|
|
147
|
+
*/
|
|
148
|
+
scale?: ValueScale;
|
|
149
|
+
/**
|
|
150
|
+
* The table behind the picture, for a chart whose data are not a grid of
|
|
151
|
+
* series against categories.
|
|
152
|
+
*
|
|
153
|
+
* The default one is right wherever the marks *are* that grid, and useless
|
|
154
|
+
* where they are not: a timeline's rows are the category axis and its marks
|
|
155
|
+
* are spans within them, so the frame has no cell to look an answer up in.
|
|
156
|
+
*/
|
|
157
|
+
table?: (id: string) => React.ReactNode;
|
|
158
|
+
/** What the panel says about a mark whose value is not a cell of the grid. */
|
|
159
|
+
markTooltip?: (mark: ChartMark) => {
|
|
160
|
+
heading: React.ReactNode;
|
|
161
|
+
items: readonly MPChartTooltipItem[];
|
|
162
|
+
} | null;
|
|
163
|
+
/** Bars, and only bars, run the other way. */
|
|
164
|
+
horizontal?: boolean;
|
|
165
|
+
/** The value axis measures totals rather than parts. */
|
|
166
|
+
stacked?: boolean;
|
|
167
|
+
/** A line chart may leave zero out; a bar chart may not. */
|
|
168
|
+
includeZero?: boolean;
|
|
169
|
+
/** How much of a band the marks take. Bars need room reserved; lines do not. */
|
|
170
|
+
bandRatio?: number;
|
|
171
|
+
/**
|
|
172
|
+
* Lines and areas sit **on** the category ticks; bars sit **between** them.
|
|
173
|
+
* The difference is one half-step, and getting it wrong is what leaves a line
|
|
174
|
+
* chart's first point floating a centimetre off the axis.
|
|
175
|
+
*/
|
|
176
|
+
inset?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Extra room at the **far end of the value axis**, for labels that ride the
|
|
179
|
+
* marks. The top of the plot on an upright chart and its right-hand edge on a
|
|
180
|
+
* horizontal one — a value label sits past the end of the mark, and which
|
|
181
|
+
* edge that is turns with the chart.
|
|
182
|
+
*/
|
|
183
|
+
headroom?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Room on **every** side, for marks drawn from their centre. `headroom` is
|
|
186
|
+
* not enough for those: a dot at the largest x hangs over the right edge and
|
|
187
|
+
* one at the smallest hangs over the value axis' own labels.
|
|
188
|
+
*/
|
|
189
|
+
markInset?: number;
|
|
190
|
+
/** Draws the marks. */
|
|
191
|
+
children: (context: CartesianContext) => React.ReactNode;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The frame: two axes, a grid, a crosshair, a legend, a panel and the table.
|
|
195
|
+
*/
|
|
196
|
+
export declare function CartesianFrame({ series, categories, xAxis, yAxis, horizontal, stacked, includeZero, bandRatio, inset, headroom, markInset, xScale, marks, markRadius, swatch, scale: givenScale, table: givenTable, markTooltip, height, format, locale: localeProp, label, legend, tooltip, empty, size: sizeProp, className, style, children, ...rest }: CartesianFrameProps): React.JSX.Element;
|
|
197
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useMPElementSize as i}from"../hooks/useMPElementSize.js";import{useMPLocale as a,useMPMessages as n}from"./locale.js";import{useMPSize as o}from"./config.js";import{CHART as r}from"./messages/chart.js";import{TABLE as s}from"./messages/table.js";import{ChartLegend as h,ChartShell as c,ChartTable as d,ChartTooltipPanel as u,useVisibility as m}from"./ChartChrome.js";import{CHART_FONT_SIZE as x,MARKER_RADIUS as f,PLOT_HEIGHT as p,bandScale as g,categoryAt as y,categoryCount as v,categoryExtent as k,fitsLast as b,formatCategory as M,formatStatistic as w,seriesColor as z,seriesExtent as S,showsTick as P,textWidth as A,tickStride as C,toValues as j,truncate as B,valueScale as $}from"./chart.js";const R=[],W="var(--_mp-color-outline-variant)",F="var(--_mp-color-outline)",N="var(--_mp-color-on-surface-variant)";function T({plot:l,scale:i,horizontal:a,categoryPx:n,categoryScale:o,categoryValuePx:r,valuePx:s,tickTexts:h,categoryTexts:c,valueAxis:d,categoryAxis:u,fontSize:m,zeroPx:x}){const f=!1!==d?.grid&&!d?.hidden,p=!u?.hidden&&(u?.grid??null!==o),g=e=>o?r(o.ticks[e]):(a?l.top:l.left)+n(e),y=C(c.length,a?l.height:l.width,a?1.8*m:Math.max(...c.map(e=>A(e,m)),1)+12),v=C(i.ticks.length,a?l.width:l.height,a?Math.max(...h.map(e=>A(e,m)),1)+16:2*m),k=c.length>1?Math.abs(g(1)-g(0)):l.width,M=i.ticks.length>1?Math.abs(s(i.ticks[1])-s(i.ticks[0])):l.height,w=b(c.length,y,k,a?1.8*m:A(c[c.length-1]??"",m)),z=b(i.ticks.length,v,M,a?A(h[h.length-1]??"",m):1.6*m);return t("g",{className:"mp-chart__axes",children:[i.ticks.map((n,o)=>{const r=s(n),c=Math.abs(n)<1e-9&&i.min<0,u=!d?.hidden&&P(o,i.ticks.length,v,z);return t("g",{children:[f?e("line",a?{x1:r,x2:r,y1:l.top,y2:l.top+l.height,stroke:c?F:W,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:r,y2:r,stroke:c?F:W,strokeWidth:1}):null,u?e("text",{x:a?r:l.left-8,y:a?l.top+l.height+m+6:r,textAnchor:a?"middle":"end",dominantBaseline:a?"auto":"central",fill:N,fontSize:m,children:h[o]}):null]},`v${o}`)}),c.map((i,n)=>{const o=g(n),r=!u?.hidden&&P(n,c.length,y,w);return t("g",{children:[p?e("line",a?{x1:l.left,x2:l.left+l.width,y1:o,y2:o,stroke:W,strokeWidth:1}:{x1:o,x2:o,y1:l.top,y2:l.top+l.height,stroke:W,strokeWidth:1}):null,r?e("text",{x:a?l.left-8:o,y:a?o:l.top+l.height+m+6,textAnchor:a?"end":"middle",dominantBaseline:a?"central":"auto",fill:N,fontSize:m,children:i}):null]},`c${n}`)}),e("line",a?{x1:x,x2:x,y1:l.top,y2:l.top+l.height,stroke:F,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:x,y2:x,stroke:F,strokeWidth:1}),d?.label&&!d.hidden?e("text",{x:a?l.left+l.width/2:m,y:a?l.top+l.height+2*m+12:l.top+l.height/2,textAnchor:"middle",dominantBaseline:a?"auto":"central",fill:N,fontSize:m,transform:a?void 0:`rotate(-90 ${m} ${l.top+l.height/2})`,children:d.label}):null,u?.label&&!u.hidden?e("text",{x:a?m:l.left+l.width/2,y:a?l.top+l.height/2:l.top+l.height+2*m+12,textAnchor:"middle",dominantBaseline:a?"central":"auto",fill:N,fontSize:m,transform:a?`rotate(-90 ${m} ${l.top+l.height/2})`:void 0,children:u.label}):null]})}export function CartesianFrame({series:b,categories:P,xAxis:C,yAxis:W,horizontal:N=!1,stacked:_=!1,includeZero:E=!0,bandRatio:I=1,inset:V=!1,headroom:D=0,markInset:X=0,xScale:Y="band",marks:Z,markRadius:L=24,swatch:H,scale:K,table:U,markTooltip:q,height:G,format:J,locale:O,label:Q,legend:ee,tooltip:te,empty:le,size:ie,className:ae,style:ne,children:oe,...re}){const se=o(ie),he=a(O),ce=n(r,he),de=n(s,he),ue=l.useRef(null),me=i(ue),xe=me.width,fe=l.useId(),pe=m(b),[ge,ye]=l.useState(null),[ve,ke]=l.useState(null),[be,Me]=l.useState(null),we=l.useCallback(e=>w(e,he,J,!0),[J,he]),ze=l.useMemo(()=>j(b),[b]),Se=l.useMemo(()=>b.map((e,t)=>z(t,e.color)),[b]),Pe=l.useMemo(()=>b.map(e=>e.name),[b]),Ae=v(b),Ce=l.useMemo(()=>Array.from({length:Ae},(e,t)=>y(t,P,ze)),[Ae,P,ze]),je=ze.filter((e,t)=>pe.visible[t]),Be=S(je,_),$e=x[se],Re=W,We=C,Fe=K??$(Be,{min:Re?.min,max:Re?.max,tickCount:Re?.tickCount,includeZero:E}),Ne="value"===Y?k(je,P):null,Te="value"===Y?$(Ne,{min:We?.min,max:We?.max,tickCount:We?.tickCount,includeZero:!1}):null,_e=Fe.ticks.map((e,t)=>Re?.tickFormat?String(Re.tickFormat(e,t)):we(e)),Ee=Te?Te.ticks.map((e,t)=>We?.tickFormat?String(We.tickFormat(e,t)):w(e,he,void 0,!0)):Ce.map((e,t)=>We?.tickFormat?String(We.tickFormat(e,t)):M(e,he)),Ie=_e.reduce((e,t)=>Math.max(e,A(t,$e)),0),Ve=$e+6,De=Re?.hidden?0:Ie+10+(Re?.label?Ve:0),Xe=(xe-(N?0:De)-16)/Math.max(1,Ae),Ye=Te?Ee:N||Xe-6>=2.4*$e?Ee.map(e=>B(e,N?150:Xe-6,$e)):Ee,Ze=Ye.reduce((e,t)=>Math.max(e,A(t,$e)),0),Le=N?We?.hidden?0:Ze+10+(We?.label?Ve:0):De,He=N?Re?.hidden?0:$e+12+(Re?.label?Ve:0):We?.hidden?0:$e+12+(We?.label?Ve:0),Ke=(N?We:Re)?.thickness??Le,Ue=(N?Re:We)?.thickness??He,qe=(N?12+D:Math.max(8,Ze/2))+X,Ge=f[se]+4+(N?0:D)+X,Je="number"==typeof G?G:void 0===G?p[se]:me.height,Oe={left:Ke+X,top:Ge,width:Math.max(0,xe-Ke-X-qe),height:Math.max(0,Je-Ge-Ue-X)},Qe=N?Oe.height:Oe.width,et=g(V?Math.max(1,Ae-1):Ae,Qe,I),tt=l.useCallback(e=>V?Ae<=1?Qe/2:Qe*e/(Ae-1):et.centre(e),[V,Ae,Qe,et]),lt=l.useCallback(e=>N?Oe.left+Fe.fraction(e)*Oe.width:Oe.top+(1-Fe.fraction(e))*Oe.height,[N,Oe.left,Oe.top,Oe.width,Oe.height,Fe]),it=l.useCallback(e=>N?Oe.top+(1-(Te?.fraction(e)??0))*Oe.height:Oe.left+(Te?.fraction(e)??0)*Oe.width,[N,Oe.left,Oe.top,Oe.width,Oe.height,Te]),at=l.useCallback((e,t)=>N?{x:lt(t),y:Oe.top+tt(e)}:{x:Oe.left+tt(e),y:lt(t)},[N,lt,tt,Oe.left,Oe.top]),nt=lt(Math.min(Math.max(0,Fe.min),Fe.max)),ot={plot:Oe,values:ze,visible:pe.visible,colors:Se,scale:Fe,band:et,horizontal:N,valuePx:lt,categoryPx:tt,point:at,categoryScale:Te,categoryValuePx:it,zeroPx:nt,categories:Ce,format:we,size:se},rt=Z?Z(ot):R,st=!1===te?{mode:"none"}:!0===te||void 0===te?{}:te,ht=st.mode??(Z?"item":"index"),ct=null===ve?null:rt[ve]??null,dt=Z?ct?ct.index:null:ge,ut=Z?rt.length:Ae,mt=()=>{ye(null),ke(null),Me(null)},xt=e=>{const t=null===e?null:Math.min(ut-1,Math.max(0,e));Z?ke(t):ye(t)},ft=e=>{Me(null);xt(((Z?ve:ge)??(e>0?-1:ut))+e)},pt=null===dt?[]:b.flatMap((e,t)=>{if(!pe.visible[t]||ct&&ct.series!==t)return[];const l=ze[t]?.[dt];return l&&null!==l.value?[{seriesIndex:t,name:e.name,color:l.color??Se[t],value:l.value,formatted:we(l.value),label:l.label}]:[]}),gt=ct&&q?q(ct):null,yt=gt?gt.items:"item"===ht&&pt.length>1&&null!==be?[pt.reduce((e,t)=>Math.abs(lt(t.value??0)-be)<Math.abs(lt(e.value??0)-be)?t:e)]:pt,vt=gt?gt.heading:ct?M(ze[ct.series]?.[ct.index]?.x??P?.[ct.index]??ct.index,he):null===dt?void 0:M(Ce[dt]??dt,he),kt=ct?ct.x:N?lt(yt[0]?.value??0):Oe.left+tt(dt??0),bt=ct?ct.y:N?Oe.top+tt(dt??0):Oe.top+Oe.height/2,Mt=ct?(ct.x-Oe.left)/Math.max(1,Oe.width)>.6:(N?Fe.fraction(yt[0]?.value??0):tt(dt??0)/Math.max(1,Qe))>.6,wt=!1===ee?{interactive:!1}:!0===ee||void 0===ee?{}:ee,zt=!0===ee||!1!==ee&&b.length>1,St=wt.side??"bottom",Pt={...ot,hovered:pe.hovered,activeIndex:dt,marks:rt,activeMark:ct},At=0===Ae||null===Be||"value"===Y&&null===Ne;return e(c,{...re,size:se,className:ae,style:ne,plotRef:ue,name:Q??ce.label,describedBy:At?void 0:fe,interactive:!At,height:G,legendSide:St,plotProps:{onPointerMove:At||"none"===ht?void 0:e=>{Z?ke(((e,t)=>{const l=ue.current;if(!l||0===rt.length)return null;const i=l.getBoundingClientRect(),a=e-i.left,n=t-i.top;let o=null,r=1/0,s=1/0;return rt.forEach((e,t)=>{const l=Math.hypot(e.x-a,e.y-n),i=void 0===e.rx?Math.max(0,l-e.r):Math.hypot(Math.max(0,Math.abs(e.x-a)-e.rx),Math.max(0,Math.abs(e.y-n)-(e.ry??e.rx)));i<=L&&(i<r||i===r&&l<s)&&(r=i,s=l,o=t)}),o})(e.clientX,e.clientY)):ye(((e,t)=>{const l=ue.current;if(!l||0===Ae)return null;const i=l.getBoundingClientRect(),a=N?t-i.top-Oe.top:e-i.left-Oe.left;if(a<-et.step||a>Qe+et.step)return null;const n=V?Ae<=1?0:Math.round(a/Qe*(Ae-1)):Math.floor(a/et.step);return Math.min(Ae-1,Math.max(0,n))})(e.clientX,e.clientY)),"item"===ht&&Me(((e,t)=>{const l=ue.current;if(!l)return null;const i=l.getBoundingClientRect();return N?e-i.left:t-i.top})(e.clientX,e.clientY))},onPointerLeave:mt,onKeyDown:At||"none"===ht?void 0:e=>{const t=N?"ArrowDown":"ArrowRight",l=N?"ArrowUp":"ArrowLeft";if(e.key===t)ft(1);else if(e.key===l)ft(-1);else if("Home"===e.key)xt(0);else if("End"===e.key)xt(ut-1);else{if("Escape"!==e.key)return;mt()}e.preventDefault()},onBlur:mt},tooltip:null!==dt&&yt.length>0&&"none"!==ht?st.render?e("div",{"aria-hidden":"true",className:"pointer-events-none absolute z-10",style:{left:kt,top:bt,transform:`translate(${Mt?"calc(-100% - 12px)":"12px"}, -50%)`},children:st.render({index:dt,category:Ce[dt]??dt,items:yt})}):e(u,{heading:vt,items:yt,x:kt,y:bt,flip:Mt,size:se}):null,legend:zt?e(h,{names:Pe,colors:Se,options:wt,visibility:pe,size:se,swatch:H,values:wt.showValue&&null!==dt?b.map((e,t)=>{const l=ze[t]?.[dt]?.value;return null==l?void 0:we(l)}):void 0}):null,status:{heading:vt,items:yt},table:At?null:U?.(fe)??e(d,{id:fe,caption:Q??ce.table,corner:We?.label??ce.category,categories:Ce,names:Pe,values:ze,format:we,locale:he,empty:de.empty}),children:At?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:le??de.empty}):xe>0&&Je>0?t("svg",{width:xe,height:Je,viewBox:`0 0 ${xe} ${Je}`,"aria-hidden":"true",className:"block overflow-visible",children:[e(T,{plot:Oe,scale:Fe,horizontal:N,categoryPx:tt,categoryScale:Te,categoryValuePx:it,valuePx:lt,tickTexts:_e,categoryTexts:Ye,valueAxis:Re,categoryAxis:We,fontSize:$e,zeroPx:nt}),null===dt||Z||"index"!==ht||!1===st.crosshair?null:(()=>{const t=tt(dt);return e("line",N?{x1:Oe.left,x2:Oe.left+Oe.width,y1:Oe.top+t,y2:Oe.top+t,stroke:F,strokeWidth:1}:{x1:Oe.left+t,x2:Oe.left+t,y1:Oe.top,y2:Oe.top+Oe.height,stroke:F,strokeWidth:1})})(),oe(Pt)]}):null})}
|
|
@@ -55,11 +55,20 @@ export interface MPFieldLabelProps extends MPFieldOutlineProps {
|
|
|
55
55
|
* outline is `pointer-events-none` so that clicks land on the control
|
|
56
56
|
* underneath, and a label inside it would stop being clickable.
|
|
57
57
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* pointer.
|
|
58
|
+
* It is `pointer-events-none` in both states, and for a different reason in
|
|
59
|
+
* each. Resting, it is lying over the text the caret goes into, and a click on
|
|
60
|
+
* it has to reach the control so the caret lands where the pointer did. A
|
|
61
|
+
* `<label for>` would only have focused the control, which puts the caret at the
|
|
62
|
+
* end of the text rather than under the pointer.
|
|
63
|
+
*
|
|
64
|
+
* Shrunk, it is out of the way and could safely take a click. What it cannot do
|
|
65
|
+
* is take one *halfway*. The press focuses the control, the focus is what starts
|
|
66
|
+
* the label rising, and the label arrives under the pointer before the button
|
|
67
|
+
* comes back up: the press goes down on the control and up on the label, and a
|
|
68
|
+
* press whose two ends disagree is delivered to their nearest common ancestor
|
|
69
|
+
* rather than to either. The control never sees the click. That is what made a
|
|
70
|
+
* picker asked for without its glyph — `startIcon={null}`, which is the whole
|
|
71
|
+
* point of `floatingLabel` on a picker — impossible to open with a mouse.
|
|
63
72
|
*/
|
|
64
73
|
export declare function MPFieldLabel({ size, label, required, htmlFor, shrunk, multiline }: MPFieldLabelProps): React.JSX.Element;
|
|
65
74
|
export interface MPFloatingLabel {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r,Fragment as t,jsxs as
|
|
2
|
+
import{jsx as r,Fragment as t,jsxs as o}from"react/jsx-runtime";import*as e from"react";import{Field as a}from"@base-ui/react/field";import{PROSE_TEXT as n}from"./scale.js";const i={xs:"start-1",sm:"start-2",md:"start-3",lg:"start-3",xl:"start-4"},s={xs:"top-[18px]",sm:"top-[18px]",md:"top-5",lg:"top-5",xl:"top-5"};function d(e,a){return o(t,{children:[e,a?r("span",{"aria-hidden":"true",children:" *"}):null]})}export function MPFieldOutline({label:t,required:o=!1,notched:e=!0}){return r("fieldset",{"aria-hidden":"true",className:["pointer-events-none absolute inset-0 -top-[5px] m-0 min-w-0 px-2 pt-0","rounded-mp-xs border border-mp-outline","transition-[border-color] duration-(--mp-sys-motion-duration-short4)","group-hover:border-mp-on-surface","group-focus-within:border-2 group-focus-within:border-mp-primary","group-data-focused:border-2 group-data-focused:border-mp-primary","group-data-invalid:border-mp-error","group-data-disabled:border-mp-on-surface/12"].join(" "),children:t?r("legend",{className:["text-mp-body-small invisible float-none block h-[11px] w-auto overflow-hidden p-0","leading-none","ease-mp-standard transition-[max-width,padding]","duration-(--mp-sys-motion-duration-short4)",e?"max-w-full px-1":"max-w-0 px-0"].join(" "),children:d(t,o)}):null})}export function MPFieldLabel({size:t,label:o,required:e=!1,htmlFor:p,shrunk:l=!0,multiline:u=!1}){return r(a.Label,{htmlFor:p,"data-mp-shrunk":l?"":void 0,className:["text-mp-on-surface-variant","ease-mp-standard transition-[color,top,font-size,max-width]","duration-(--mp-sys-motion-duration-short4)","pointer-events-none absolute -translate-y-1/2 px-1 leading-none",i[t],l?"text-mp-body-small top-0 max-w-none":[n[t],"max-w-[calc(100%-2rem)] truncate",u?s[t]:"top-1/2"].join(" "),"group-focus-within:text-mp-primary","group-data-focused:text-mp-primary","group-data-invalid:text-mp-error","group-data-disabled:text-mp-on-surface/38"].join(" "),children:d(o,e)})}export function useFloatingLabel({floating:r,filled:t,pinned:o=!1}){const[a,n]=e.useState(!1);return{shrunk:!r||t||a||o,focusProps:{onFocusCapture:()=>n(!0),onBlurCapture:r=>{r.currentTarget.contains(r.relatedTarget)||n(!1)}}}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MPPickerLabels } from './Calendar.js';
|
|
3
|
-
import type { MPColor, MPSize, MPStyleProps } from '../types.js';
|
|
3
|
+
import type { MPColor, MPControlEventProps, MPSize, MPStyleProps } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The strings a trigger is held open by, kept across renders that did not
|
|
6
6
|
* change what it could say.
|
|
@@ -25,6 +25,18 @@ import type { MPColor, MPSize, MPStyleProps } from '../types.js';
|
|
|
25
25
|
* never a wrong answer.
|
|
26
26
|
*/
|
|
27
27
|
export declare function useDisplaySamples(locale: string | undefined, options: Intl.DateTimeFormatOptions): string[];
|
|
28
|
+
/**
|
|
29
|
+
* The popup's room, one track tighter than a control's.
|
|
30
|
+
*
|
|
31
|
+
* A calendar is already a grid of forty-two padded cells; giving the sheet
|
|
32
|
+
* around it a control's 16px as well would put 24px of nothing between the last
|
|
33
|
+
* column and the edge.
|
|
34
|
+
*
|
|
35
|
+
* Exported because `MPCalendar` draws the same grid on a surface of its own, and
|
|
36
|
+
* a standalone calendar sitting one track wider than the identical calendar in a
|
|
37
|
+
* picker's popup is the drift a shared table exists to prevent.
|
|
38
|
+
*/
|
|
39
|
+
export declare const POPUP_PAD: Record<MPSize, string>;
|
|
28
40
|
/**
|
|
29
41
|
* The props a picker takes from its shell rather than inventing.
|
|
30
42
|
*
|
|
@@ -32,7 +44,7 @@ export declare function useDisplaySamples(locale: string | undefined, options: I
|
|
|
32
44
|
* the rows a reader of the docs is actually looking at — every one of the four
|
|
33
45
|
* pickers lists them, and they mean the same thing on all four.
|
|
34
46
|
*/
|
|
35
|
-
export interface MPPickerShellProps extends MPStyleProps {
|
|
47
|
+
export interface MPPickerShellProps extends MPStyleProps, MPControlEventProps<HTMLButtonElement> {
|
|
36
48
|
/**
|
|
37
49
|
* Which accent family the popup reads: the chosen day's fill, the band across
|
|
38
50
|
* a range, today's outline, the footer's confirm button.
|
|
@@ -130,7 +142,7 @@ interface InternalShellProps extends MPPickerShellProps {
|
|
|
130
142
|
* treatment, and the popup's `surface-container` at elevation 2 — which is the
|
|
131
143
|
* same floating sheet a menu and a select's list are drawn on.
|
|
132
144
|
*/
|
|
133
|
-
export declare function MPPickerShell({ slug, size, color, fullWidth, label, floatingLabel, description, errorMessage, startIcon, required, disabled, readOnly, id, className, style, display, samples, empty, clearable, onClear, open, onOpenChange, labels, hiddenValues, children, triggerRef }: InternalShellProps): React.JSX.Element;
|
|
145
|
+
export declare function MPPickerShell({ slug, size, color, fullWidth, label, floatingLabel, description, errorMessage, startIcon, required, disabled, readOnly, id, className, style, onKeyDown, onKeyUp, onFocus, onBlur, onClick, onDoubleClick, onContextMenu, display, samples, empty, clearable, onClear, open, onOpenChange, labels, hiddenValues, children, triggerRef }: InternalShellProps): React.JSX.Element;
|
|
134
146
|
/**
|
|
135
147
|
* The row of shortcuts under a picker's panel.
|
|
136
148
|
*
|
package/dist/internal/Picker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Field as r}from"@base-ui/react/field";import{Popover as i}from"@base-ui/react/popover";import{MPIcon as t}from"../components/icon/MPIcon.js";import{CloseIcon as l}from"../constants/icons.js";import{accentSlots as s}from"./accent.js";import{MPFieldLabel as a,MPFieldOutline as p,useFloatingLabel as c}from"./FieldOutline.js";import{MPStateLayer as u}from"./StateLayer.js";import{MPSupportingText as m}from"./SupportingText.js";import{MPWidthSizer as d}from"./WidthSizer.js";import{displaySamples as f}from"./date.js";import{CONTROL_ICON as h,hasContent as x,PROSE_TEXT as g}from"./scale.js";import{FADE as b,PORTAL_LAYER as y}from"./surface.js";export function useDisplaySamples(e,n){const r=`${e??""} ${JSON.stringify(n)}`;return o.useMemo(()=>f(e,n),[r])}const j={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}};export const POPUP_PAD={xs:"p-1.5",sm:"p-2",md:"p-2.5",lg:"p-3",xl:"p-3.5"};export function MPPickerShell({slug:f,size:v="md",color:P="primary",fullWidth:N=!1,label:k,floatingLabel:w=!0,description:C,errorMessage:O,startIcon:M,required:D=!1,disabled:F=!1,readOnly:S=!1,id:z,className:B,style:_,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,display:A,samples:E,empty:L,clearable:W=!1,onClear:J,open:V,onOpenChange:Z,labels:G,hiddenValues:H,children:Q,triggerRef:X}){const Y=x(O),ee=j[v],ne=o.useId(),oe=z??ne,re=W&&!L&&!(F||S),{shrunk:ie,focusProps:te}=c({floating:w&&x(k),filled:!L,pinned:V||x(M)});return n(r.Root,{disabled:F,invalid:Y,"data-mp-size":v,className:[`mp-${f} group flex-col align-top`,N?"flex w-full":"inline-flex w-fit",B??""].filter(Boolean).join(" "),style:{...s(P),..._},...te,children:[n(i.Root,{open:V,onOpenChange:Z,children:[n("div",{className:"relative w-full",children:[n(i.Trigger,{id:oe,ref:X,disabled:F,nativeButton:!0,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",ee.padding,re?"pe-10":"",ee.height,g[v],F?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(S?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[M?e("span",{className:["flex shrink-0 items-center",F?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null,n("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:["w-full truncate text-start",L&&!F?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:L&&!ie?null:A}),e(d,{samples:E??[]})]})]}),re?n("button",{type:"button","aria-label":G.clear,onClick:J,className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(u,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(t,{icon:l,size:h[v]})]}):null,e(p,{label:k,required:D,notched:ie}),x(k)?e(a,{size:v,label:k,required:D,htmlFor:oe,shrunk:ie}):null]}),e(i.Portal,{children:e(i.Positioner,{className:y,sideOffset:4,align:"start",children:e(i.Popup,{initialFocus:!1,style:s(P),className:[`mp-${f}__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container`,"text-mp-on-surface outline-none",POPUP_PAD[v],g[v],b].join(" "),children:Q})})})]}),e(m,{description:C,errorMessage:O,className:ee.padding}),H?.map((n,o)=>e("input",{type:"hidden",name:n.name,value:n.value},o))]})}export function MPPickerFooter({children:n}){return e("div",{className:"border-mp-outline-variant flex items-center justify-end gap-1 border-t pt-1.5",children:n})}export function MPPickerDivider(){return e("div",{"aria-hidden":"true",className:"bg-mp-outline-variant w-px self-stretch"})}export const FOOTER_SIZE={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};
|
|
@@ -14,6 +14,30 @@ import * as React from 'react';
|
|
|
14
14
|
* validity state; here the message's presence *is* the state, which is the same
|
|
15
15
|
* bargain `MPTextField.errorMessage` makes — there is no way to render a control
|
|
16
16
|
* that is visibly wrong with no explanation of why.
|
|
17
|
+
*
|
|
18
|
+
* ## The line arrives rather than appearing
|
|
19
|
+
*
|
|
20
|
+
* A field that turned invalid grew by a line of text between one frame and the
|
|
21
|
+
* next, and everything under it on the page moved down by that much. On a form
|
|
22
|
+
* validated on blur that is the whole page stepping as the reader tabs through
|
|
23
|
+
* it.
|
|
24
|
+
*
|
|
25
|
+
* So the space opens. `mp-supporting-text__reveal` in `styles.css` has the
|
|
26
|
+
* argument for the row it opens as and for why swapping a description for an
|
|
27
|
+
* error is a different animation from having something to say at all.
|
|
28
|
+
*
|
|
29
|
+
* What is worth knowing on this side is that the animation is **switched on by
|
|
30
|
+
* an attribute this component sets**, rather than by a class that is simply
|
|
31
|
+
* always there. A page load is not a change: a server-rendered form would
|
|
32
|
+
* otherwise grow six description lines out of nothing the moment it hydrated,
|
|
33
|
+
* which is a page assembling itself in front of a reader who asked for a form.
|
|
34
|
+
* The effect below only ever runs when it has watched the message change.
|
|
35
|
+
*
|
|
36
|
+
* The wrapper is drawn only when there is a message, and that is not a detail
|
|
37
|
+
* to lose either: every control that shows one puts it in a flex column with a
|
|
38
|
+
* `gap`, so an element that was always there would be a gap that was always
|
|
39
|
+
* there — two pixels under every checkbox in the library that has nothing to
|
|
40
|
+
* say.
|
|
17
41
|
*/
|
|
18
42
|
export declare function MPSupportingText({ description, errorMessage, className }: {
|
|
19
43
|
description?: React.ReactNode;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{Field as t}from"@base-ui/react/field";import{META_TEXT as a,hasContent as n}from"./scale.js";export function MPSupportingText({description:o,errorMessage:s,className:i}){const c=n(s)?"error":n(o)?"description":"none",m=r.useRef(null),p=r.useRef(c);r.useLayoutEffect(()=>{const e=m.current,r=p.current;p.current=c,e&&c!==r&&"none"!==c&&(e.dataset.mpReveal="none"===r?"open":"swap",e.style.animationName="none",e.offsetWidth,e.style.animationName="")},[c]);const l=["mp-supporting-text block min-h-0",a,"data-disabled:text-mp-on-surface/38",i??""].filter(Boolean).join(" ");return n(s)?e("div",{ref:m,className:"mp-supporting-text__reveal",children:e(t.Error,{match:!0,className:`${l} text-mp-error`,children:s})}):n(o)?e("div",{ref:m,className:"mp-supporting-text__reveal",children:e(t.Description,{className:`${l} text-mp-on-surface-variant`,children:o})}):e(t.Error,{className:`${l} text-mp-error`})}
|