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
package/dist/index.d.ts
CHANGED
|
@@ -4,21 +4,30 @@ export * from './constants/icons.js';
|
|
|
4
4
|
export * from './hooks/index.js';
|
|
5
5
|
export * from './components/accordion/index.js';
|
|
6
6
|
export * from './components/alert/index.js';
|
|
7
|
+
export * from './components/anchor/index.js';
|
|
8
|
+
export * from './components/app-logo/index.js';
|
|
7
9
|
export * from './components/animate-appear/index.js';
|
|
8
10
|
export * from './components/animate-blink/index.js';
|
|
11
|
+
export * from './components/animate-counter/index.js';
|
|
9
12
|
export * from './components/animate-fade/index.js';
|
|
13
|
+
export * from './components/animate-float/index.js';
|
|
10
14
|
export * from './components/animate-grow/index.js';
|
|
11
15
|
export * from './components/animate-headline/index.js';
|
|
12
16
|
export * from './components/animate-lighting/index.js';
|
|
13
17
|
export * from './components/animate-marquee/index.js';
|
|
18
|
+
export * from './components/animate-reveal/index.js';
|
|
14
19
|
export * from './components/animate-rotate/index.js';
|
|
20
|
+
export * from './components/animate-scramble/index.js';
|
|
21
|
+
export * from './components/animate-shake/index.js';
|
|
15
22
|
export * from './components/animate-slide/index.js';
|
|
23
|
+
export * from './components/animate-split/index.js';
|
|
16
24
|
export * from './components/animate-typing/index.js';
|
|
17
25
|
export * from './components/animate-zoom/index.js';
|
|
26
|
+
export * from './components/area-chart/index.js';
|
|
18
27
|
export * from './components/aspect-ratio/index.js';
|
|
19
28
|
export * from './components/avatar/index.js';
|
|
20
|
-
export * from './components/avatar-group/index.js';
|
|
21
29
|
export * from './components/badge/index.js';
|
|
30
|
+
export * from './components/bar-chart/index.js';
|
|
22
31
|
export * from './components/blockquote/index.js';
|
|
23
32
|
export * from './components/bottom-navigation/index.js';
|
|
24
33
|
export * from './components/box/index.js';
|
|
@@ -31,6 +40,7 @@ export * from './components/carousel/index.js';
|
|
|
31
40
|
export * from './components/chat-bubble/index.js';
|
|
32
41
|
export * from './components/checkbox/index.js';
|
|
33
42
|
export * from './components/chip/index.js';
|
|
43
|
+
export * from './components/code-block/index.js';
|
|
34
44
|
export * from './components/collapsible/index.js';
|
|
35
45
|
export * from './components/config/index.js';
|
|
36
46
|
export * from './components/confirm/index.js';
|
|
@@ -38,6 +48,8 @@ export * from './components/color-picker/index.js';
|
|
|
38
48
|
export * from './components/combobox/index.js';
|
|
39
49
|
export * from './components/command-palette/index.js';
|
|
40
50
|
export * from './components/container/index.js';
|
|
51
|
+
export * from './components/data-list/index.js';
|
|
52
|
+
export * from './components/data-table/index.js';
|
|
41
53
|
export * from './components/date-picker/index.js';
|
|
42
54
|
export * from './components/date-range-picker/index.js';
|
|
43
55
|
export * from './components/date-time-picker/index.js';
|
|
@@ -47,19 +59,27 @@ export * from './components/drawer/index.js';
|
|
|
47
59
|
export * from './components/empty/index.js';
|
|
48
60
|
export * from './components/fieldset/index.js';
|
|
49
61
|
export * from './components/file-picker/index.js';
|
|
62
|
+
export * from './components/flex/index.js';
|
|
50
63
|
export * from './components/floating-action-button/index.js';
|
|
64
|
+
export * from './components/floating-bottom-navigation/index.js';
|
|
51
65
|
export * from './components/footer/index.js';
|
|
52
66
|
export * from './components/form/index.js';
|
|
67
|
+
export * from './components/gauge-chart/index.js';
|
|
53
68
|
export * from './components/grid/index.js';
|
|
54
69
|
export * from './components/header/index.js';
|
|
70
|
+
export * from './components/heatmap-chart/index.js';
|
|
55
71
|
export * from './components/highlight/index.js';
|
|
72
|
+
export * from './components/hover-card/index.js';
|
|
56
73
|
export * from './components/icon/index.js';
|
|
57
74
|
export * from './components/icon-button/index.js';
|
|
58
75
|
export * from './components/image/index.js';
|
|
76
|
+
export * from './components/line-chart/index.js';
|
|
59
77
|
export * from './components/list/index.js';
|
|
60
78
|
export * from './components/locale/index.js';
|
|
61
79
|
export * from './components/menu/index.js';
|
|
62
80
|
export * from './components/menubar/index.js';
|
|
81
|
+
export * from './components/meter/index.js';
|
|
82
|
+
export * from './components/mockup/index.js';
|
|
63
83
|
export * from './components/navigation-menu/index.js';
|
|
64
84
|
export * from './components/number-field/index.js';
|
|
65
85
|
export * from './components/otp-field/index.js';
|
|
@@ -67,22 +87,31 @@ export * from './components/overlay/index.js';
|
|
|
67
87
|
export * from './components/page-layout/index.js';
|
|
68
88
|
export * from './components/pagination/index.js';
|
|
69
89
|
export * from './components/panes/index.js';
|
|
90
|
+
export * from './components/pie-chart/index.js';
|
|
70
91
|
export * from './components/pill/index.js';
|
|
71
92
|
export * from './components/popconfirm/index.js';
|
|
72
93
|
export * from './components/popover/index.js';
|
|
94
|
+
export * from './components/portal/index.js';
|
|
73
95
|
export * from './components/progress-box/index.js';
|
|
74
96
|
export * from './components/progress-circular/index.js';
|
|
75
97
|
export * from './components/progress-linear/index.js';
|
|
76
98
|
export * from './components/radio-group/index.js';
|
|
77
99
|
export * from './components/rating/index.js';
|
|
100
|
+
export * from './components/scatter-chart/index.js';
|
|
101
|
+
export * from './components/scroll-area/index.js';
|
|
102
|
+
export * from './components/scroll-zone/index.js';
|
|
78
103
|
export * from './components/segmented-button/index.js';
|
|
79
104
|
export * from './components/select/index.js';
|
|
80
105
|
export * from './components/shortcut/index.js';
|
|
106
|
+
export * from './components/show/index.js';
|
|
81
107
|
export * from './components/sidebar/index.js';
|
|
82
108
|
export * from './components/skeleton/index.js';
|
|
83
109
|
export * from './components/slider/index.js';
|
|
84
110
|
export * from './components/snackbar/index.js';
|
|
85
111
|
export * from './components/spoiler/index.js';
|
|
112
|
+
export * from './components/sparkline/index.js';
|
|
113
|
+
export * from './components/stack/index.js';
|
|
114
|
+
export * from './components/statistic/index.js';
|
|
86
115
|
export * from './components/stepper/index.js';
|
|
87
116
|
export * from './components/switch/index.js';
|
|
88
117
|
export * from './components/table/index.js';
|
|
@@ -91,9 +120,14 @@ export * from './components/text-field/index.js';
|
|
|
91
120
|
export * from './components/text-link/index.js';
|
|
92
121
|
export * from './components/time-picker/index.js';
|
|
93
122
|
export * from './components/timeline/index.js';
|
|
123
|
+
export * from './components/timeline-chart/index.js';
|
|
94
124
|
export * from './components/toggle/index.js';
|
|
95
125
|
export * from './components/toggle-group/index.js';
|
|
126
|
+
export * from './components/toolbar/index.js';
|
|
96
127
|
export * from './components/tooltip/index.js';
|
|
128
|
+
export * from './components/tour/index.js';
|
|
97
129
|
export * from './components/transfer/index.js';
|
|
130
|
+
export * from './components/tree-select/index.js';
|
|
131
|
+
export * from './components/tree-view/index.js';
|
|
98
132
|
export * from './components/typography/index.js';
|
|
99
133
|
export * from './components/visually-hidden/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./types.js";export{registerMPMessages}from"./internal/i18n.js";export*from"./constants/icons.js";export*from"./hooks/index.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/
|
|
1
|
+
export*from"./types.js";export{registerMPMessages}from"./internal/i18n.js";export*from"./constants/icons.js";export*from"./hooks/index.js";export*from"./components/accordion/index.js";export*from"./components/alert/index.js";export*from"./components/anchor/index.js";export*from"./components/app-logo/index.js";export*from"./components/animate-appear/index.js";export*from"./components/animate-blink/index.js";export*from"./components/animate-counter/index.js";export*from"./components/animate-fade/index.js";export*from"./components/animate-float/index.js";export*from"./components/animate-grow/index.js";export*from"./components/animate-headline/index.js";export*from"./components/animate-lighting/index.js";export*from"./components/animate-marquee/index.js";export*from"./components/animate-reveal/index.js";export*from"./components/animate-rotate/index.js";export*from"./components/animate-scramble/index.js";export*from"./components/animate-shake/index.js";export*from"./components/animate-slide/index.js";export*from"./components/animate-split/index.js";export*from"./components/animate-typing/index.js";export*from"./components/animate-zoom/index.js";export*from"./components/area-chart/index.js";export*from"./components/aspect-ratio/index.js";export*from"./components/avatar/index.js";export*from"./components/badge/index.js";export*from"./components/bar-chart/index.js";export*from"./components/blockquote/index.js";export*from"./components/bottom-navigation/index.js";export*from"./components/box/index.js";export*from"./components/breadcrumb/index.js";export*from"./components/button/index.js";export*from"./components/button-group/index.js";export*from"./components/calendar/index.js";export*from"./components/card/index.js";export*from"./components/carousel/index.js";export*from"./components/chat-bubble/index.js";export*from"./components/checkbox/index.js";export*from"./components/chip/index.js";export*from"./components/code-block/index.js";export*from"./components/collapsible/index.js";export*from"./components/config/index.js";export*from"./components/confirm/index.js";export*from"./components/color-picker/index.js";export*from"./components/combobox/index.js";export*from"./components/command-palette/index.js";export*from"./components/container/index.js";export*from"./components/data-list/index.js";export*from"./components/data-table/index.js";export*from"./components/date-picker/index.js";export*from"./components/date-range-picker/index.js";export*from"./components/date-time-picker/index.js";export*from"./components/dialog/index.js";export*from"./components/divider/index.js";export*from"./components/drawer/index.js";export*from"./components/empty/index.js";export*from"./components/fieldset/index.js";export*from"./components/file-picker/index.js";export*from"./components/flex/index.js";export*from"./components/floating-action-button/index.js";export*from"./components/floating-bottom-navigation/index.js";export*from"./components/footer/index.js";export*from"./components/form/index.js";export*from"./components/gauge-chart/index.js";export*from"./components/grid/index.js";export*from"./components/header/index.js";export*from"./components/heatmap-chart/index.js";export*from"./components/highlight/index.js";export*from"./components/hover-card/index.js";export*from"./components/icon/index.js";export*from"./components/icon-button/index.js";export*from"./components/image/index.js";export*from"./components/line-chart/index.js";export*from"./components/list/index.js";export*from"./components/locale/index.js";export*from"./components/menu/index.js";export*from"./components/menubar/index.js";export*from"./components/meter/index.js";export*from"./components/mockup/index.js";export*from"./components/navigation-menu/index.js";export*from"./components/number-field/index.js";export*from"./components/otp-field/index.js";export*from"./components/overlay/index.js";export*from"./components/page-layout/index.js";export*from"./components/pagination/index.js";export*from"./components/panes/index.js";export*from"./components/pie-chart/index.js";export*from"./components/pill/index.js";export*from"./components/popconfirm/index.js";export*from"./components/popover/index.js";export*from"./components/portal/index.js";export*from"./components/progress-box/index.js";export*from"./components/progress-circular/index.js";export*from"./components/progress-linear/index.js";export*from"./components/radio-group/index.js";export*from"./components/rating/index.js";export*from"./components/scatter-chart/index.js";export*from"./components/scroll-area/index.js";export*from"./components/scroll-zone/index.js";export*from"./components/segmented-button/index.js";export*from"./components/select/index.js";export*from"./components/shortcut/index.js";export*from"./components/show/index.js";export*from"./components/sidebar/index.js";export*from"./components/skeleton/index.js";export*from"./components/slider/index.js";export*from"./components/snackbar/index.js";export*from"./components/spoiler/index.js";export*from"./components/sparkline/index.js";export*from"./components/stack/index.js";export*from"./components/statistic/index.js";export*from"./components/stepper/index.js";export*from"./components/switch/index.js";export*from"./components/table/index.js";export*from"./components/tabs/index.js";export*from"./components/text-field/index.js";export*from"./components/text-link/index.js";export*from"./components/time-picker/index.js";export*from"./components/timeline/index.js";export*from"./components/timeline-chart/index.js";export*from"./components/toggle/index.js";export*from"./components/toggle-group/index.js";export*from"./components/toolbar/index.js";export*from"./components/tooltip/index.js";export*from"./components/tour/index.js";export*from"./components/transfer/index.js";export*from"./components/tree-select/index.js";export*from"./components/tree-view/index.js";export*from"./components/typography/index.js";export*from"./components/visually-hidden/index.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as r}from"../components/button/MPButton.js";import{MPIcon as l}from"../components/icon/MPIcon.js";import{MPIconButton as a}from"../components/icon-button/MPIconButton.js";import{ChevronDownIcon as s,ChevronLeftIcon as c,ChevronRightIcon as i}from"../constants/icons.js";import{MPStateLayer as u}from"./StateLayer.js";import{CONTROL_ICON as m,META_TEXT as d,PROSE_TEXT as h}from"./scale.js";import{VISUALLY_HIDDEN as p}from"./visually-hidden.js";import{addDays as f,addMonths as g,addYears as y,calendarWeeks as v,compareDay as w,dateFormatter as x,isDayOutside as b,isMonthBeforeYear as D,isSameDay as S,isSameMonth as M,isUnitOutside as N,isValidDate as P,makeDate as _,meridiemLabels as C,monthLabels as k,startOfDay as j,startOfMonth as z,today as A,weekdayLabels as E,withTime as T,YEAR_PAGE_SIZE as F,yearPageStart as Y}from"./date.js";const B={xs:"1.75rem",sm:"2rem",md:"2.5rem",lg:"2.75rem",xl:"3rem"},R={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"},H=/*@__PURE__*/["group relative flex cursor-pointer items-center justify-center overflow-hidden","box-border appearance-none font-[inherit] tabular-nums select-none","transition-[background-color,border-color,color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:z-10 focus-visible:outline-2","focus-visible:outline-offset-[-2px] focus-visible:outline-solid outline-none"].join(" "),$={day:0,month:1,year:2};function K({children:n,label:o,selected:r,inRange:l=!1,rangeEdge:a=null,current:s=!1,muted:c=!1,disabled:i=!1,focused:m=!1,className:d,onClick:h,onPointerEnter:p,onKeyDown:f}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":i||void 0,tabIndex:m?0:-1,"data-focus-target":m?"true":void 0,className:[H,"start"===a?"rounded-s-mp-full":"end"===a?"rounded-e-mp-full":"middle"===a?"rounded-none":"rounded-mp-full",i?"bg-transparent cursor-default text-mp-on-surface/38":r?"bg-(--_mp-accent) text-(--_mp-on-accent)":l?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":s?"bg-transparent border border-(--_mp-accent) text-(--_mp-accent)":c?"bg-transparent text-mp-on-surface-variant":"bg-transparent text-mp-on-surface",d??""].filter(Boolean).join(" "),onClick:()=>{i||h()},onPointerEnter:p,onKeyDown:f,children:[i?null:e(u,{}),n]})}function L({size:o,color:u,view:d,month:p,locale:f,labels:g,showPreviousButton:y,showNextButton:v,onStep:w,onViewChange:x}){const b=k(f,"long")[p.getMonth()],S=String(p.getFullYear()),M=D(f),N=R[o],P="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],_=(t,n)=>n?e(a,{size:N,color:u,label:P[-1===t?0:1],icon:e(l,{icon:-1===t?c:i,size:m[N],className:"rtl:rotate-180"}),onClick:()=>w(t)}):e("span",{"aria-hidden":"true",className:"size-(--_mp-cell)"}),C=t=>e(l,{icon:s,size:m[N],className:["transition-transform duration-(--mp-sys-motion-duration-short4)",t?"rotate-180":""].filter(Boolean).join(" ")}),j=e(r,{variant:"text",size:N,color:u,"aria-label":g.chooseMonth,"aria-expanded":"month"===d,endIcon:C("month"===d),onClick:()=>x("month"===d?"day":"month"),children:b},"month"),z=e(r,{variant:"text",size:N,color:u,className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,endIcon:C("year"===d),onClick:()=>x("year"===d?"day":"year"),children:S},"year"),A=Y(p.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[_(-1,y),e("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1",children:"year"===d?e("span",{className:`text-mp-on-surface flex h-(--_mp-cell) items-center tabular-nums ${h[o]}`,children:`${A}–${A+F-1}`}):"month"===d?z:t(n,M?{children:[j,z]}:{children:[z,j]})}),_(1,v)]})}export function Calendar({size:n,color:r,locale:l,weekStartsOn:a,month:s,onMonthChange:c,selected:i,rangeStart:u=null,rangeEnd:m=null,onSelect:d,onPreviewChange:h,minDate:p,maxDate:f,shouldDisableDate:v,showOutsideDays:w=!0,autoFocus:x=!1,showPreviousButton:D=!0,showNextButton:S=!0,precision:N="day",labels:C}){const[k,E]=o.useState(N),T=$[k]<$[N]?N:k,Y=o.useMemo(()=>i.filter(P),[i]),[R,H]=o.useState(()=>{const e=Y.find(e=>M(e,s));return e?j(e):M(A(),s)?A():z(s)}),K=o.useRef(x),U=o.useRef(null);o.useEffect(()=>{H(e=>M(e,s)?e:z(s))},[s]),o.useLayoutEffect(()=>{K.current&&(K.current=!1,U.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>b(e,p,f)||(v?.(e)??!1),[p,f,v]),G=e=>{K.current=!0,E(e)},W=e=>{K.current=!0,c(e)};return t("div",{ref:U,className:"mp-calendar flex flex-col gap-1",style:{"--_mp-cell":B[n]},onPointerLeave:()=>h?.(null),children:[e(L,{size:n,color:r,view:T,month:s,locale:l,labels:C,showPreviousButton:D,showNextButton:S,onStep:e=>{c("day"===T?g(s,e):y(s,"month"===T?e:e*F))},onViewChange:G}),e("div",{className:"h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*7)]",children:"day"===T?e(I,{size:n,locale:l,weekStartsOn:a,month:s,chosen:Y,rangeStart:u,rangeEnd:m,focusedDate:R,showOutsideDays:w,isDisabled:V,onSelect:e=>{H(e),d(e)},onPreviewChange:h,onMoveFocus:e=>{K.current=!0,H(e),M(e,s)||c(z(e))}}):"month"===T?e(O,{size:n,locale:l,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{const t=_(s.getFullYear(),e,1);"month"!==N?(c(t),G("day")):d(t)}}):e(q,{size:n,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{"year"!==N?(c(_(e,s.getMonth(),1)),G("month")):d(_(e,0,1))}})})]})}function U(e){return"rtl"===getComputedStyle(e).direction?-1:1}function I({size:n,locale:r,weekStartsOn:l,month:a,chosen:s,rangeStart:c,rangeEnd:i,focusedDate:u,showOutsideDays:m,isDisabled:p,onSelect:y,onPreviewChange:b,onMoveFocus:D}){const N=E(r,l,"narrow"),_=E(r,l,"long"),C=(j=i,P(k=c)&&P(j)?w(k,j)<=0?[k,j]:[j,k]:null);var k,j;const z=A(),T=o.useMemo(()=>{const e=x(r,{dateStyle:"full"});return v(a,l).map(t=>t.map(t=>({date:t,label:e.format(t)})))},[a,l,r]),F=o.useRef(null),Y=o.useRef(a);o.useLayoutEffect(()=>{const e=F.current,t=Y.current;if(Y.current=a,!e||M(t,a))return;const n=t.getTime()<a.getTime(),o="rtl"===getComputedStyle(e).direction;e.style.setProperty("--_mp-calendar-from",String(n===o?-1:1)),e.dataset.mpPaged="true",e.style.animationName="none",e.offsetWidth,e.style.animationName=""},[a]);return t("div",{role:"grid","aria-label":x(r,{year:"numeric",month:"long"}).format(a),className:"flex h-full flex-col",children:[e("div",{role:"rowgroup",children:e("div",{role:"row",className:"grid grid-cols-7",children:N.map((t,n)=>e("span",{role:"columnheader","aria-label":_[n],className:`text-mp-on-surface-variant flex h-(--_mp-cell) items-center justify-center select-none ${d}`,children:t},n))})}),e("div",{ref:F,role:"rowgroup",className:"mp-calendar__page flex flex-1 flex-col",children:T.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(({date:t,label:o})=>{const r=!M(t,a);if(r&&!m)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--_mp-cell)"},t.getTime());const c=s.some(e=>S(e,t)),i=null!==C&&w(t,C[0])>=0&&w(t,C[1])<=0,d=null!==C&&i&&S(t,C[0]),v=null!==C&&i&&S(t,C[1]);return e(K,{label:o,selected:c,inRange:i&&!c,rangeEdge:i?d&&v?"both":d?"start":v?"end":"middle":null,current:S(t,z)&&!c,muted:r,disabled:p(t),focused:S(t,u),className:`size-(--_mp-cell) ${h[n]}`,onClick:()=>y(t),onPointerEnter:()=>b?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-l+7)%7,o=U(e.currentTarget),r={ArrowLeft:()=>f(t,-o),ArrowRight:()=>f(t,o),ArrowUp:()=>f(t,-7),ArrowDown:()=>f(t,7),Home:()=>f(t,-n),End:()=>f(t,6-n),PageUp:()=>g(t,e.shiftKey?-12:-1),PageDown:()=>g(t,e.shiftKey?12:1)}[e.key];r&&(e.preventDefault(),D(r()))})(e,t),children:t.getDate()},t.getTime())})},o))})]})}function O({size:t,locale:n,month:r,chosen:l,minDate:a,maxDate:s,onMoveCursor:c,onPick:i}){const u=k(n,"short"),m=r.getFullYear(),d=new Date,p=o.useMemo(()=>{const e=x(n,{year:"numeric",month:"long"});return Array.from({length:12},(t,n)=>e.format(_(m,n,1)))},[n,m]),f=e=>{const t=U(e.currentTarget),n={ArrowLeft:-t,ArrowRight:t,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==n&&(e.preventDefault(),c(g(z(r),n)))};return e("div",{role:"grid","aria-label":String(m),className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(o=>{const c=3*n+o;return e(K,{label:p[c],selected:l.some(e=>e.getFullYear()===m&&e.getMonth()===c),current:d.getFullYear()===m&&d.getMonth()===c,disabled:N(_(m,c,1),"month",a,s),focused:c===r.getMonth(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>i(c),onKeyDown:f,children:u[c]},c)})},n))})}function q({size:t,month:n,chosen:o,minDate:r,maxDate:l,onMoveCursor:a,onPick:s}){const c=Y(n.getFullYear()),i=(new Date).getFullYear(),u=e=>{const t=U(e.currentTarget),o={ArrowLeft:-t,ArrowRight:t,ArrowUp:-4,ArrowDown:4,PageUp:-F,PageDown:F}[e.key];void 0!==o&&(e.preventDefault(),a(y(z(n),o)))};return e("div",{role:"grid","aria-label":`${c}–${c+F-1}`,className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(a=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(m=>{const d=c+4*a+m;return e(K,{label:String(d),selected:o.some(e=>e.getFullYear()===d),current:d===i,disabled:N(_(d,0,1),"year",r,l),focused:d===n.getFullYear(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>s(d),onKeyDown:u,children:d},d)})},a))})}function V(e,t){return Number.isFinite(e)?Math.min(t,Math.max(1,Math.round(e))):1}function G(e){const t=e.parentElement;if(!t)return;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.top-o.top-t.clientTop+t.scrollTop,l=r+n.height;r<t.scrollTop?t.scrollTop=r:l>t.scrollTop+t.clientHeight&&(t.scrollTop=l-t.clientHeight)}export function MPTimeGrid({size:n,locale:r,value:l,referenceDate:a,onChange:s,hour12:c,showSeconds:i,hourStep:m,minuteStep:d,secondStep:f,shouldDisableTime:g,autoFocus:y=!1,labels:v}){const w=l??a,b=o.useRef(null),[D,S]=o.useMemo(()=>C(r),[r]);o.useEffect(()=>{const e=b.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(G),y){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[y]);const M=o.useMemo(()=>{const e=c?12:24,t=V(m,e),n=Array.from({length:Math.ceil(e/t)},(e,n)=>n*t);return c?n.map(e=>0===e?12:e):n},[c,m]),N=o.useMemo(()=>{const e=V(d,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[d]),P=o.useMemo(()=>{const e=V(f,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[f]),_=e=>String(e).padStart(2,"0"),k=c?w.getHours()%12||12:w.getHours(),[j,z]=o.useState({}),A=(o,r,a,i,m)=>{const d=null===l?-1:a.findIndex(e=>i(e)),p=j[o]??(d>=0?d:0);return e("div",{role:"listbox","aria-label":r,className:["mp-time-grid__column flex flex-col gap-0.5 overflow-y-auto overscroll-contain","h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"].join(" "),onKeyDown:e=>{const t={ArrowDown:1,ArrowUp:-1,PageDown:5,PageUp:-5}[e.key],n=void 0!==t?(e=>{const t=[...e.children].indexOf(document.activeElement);return t>=0?t:p})(e.currentTarget)+t:"Home"===e.key?0:"End"===e.key?a.length-1:null;null!==n&&(e.preventDefault(),((e,t)=>{const n=Math.min(a.length-1,Math.max(0,e)),r=t.children[n];z(e=>({...e,[o]:n})),r instanceof HTMLElement&&(r.focus({preventScroll:!0}),G(r))})(n,e.currentTarget))},children:a.map((r,a)=>{const d=((e,t)=>T(w,"hour"===e?{hours:c?t%12+(w.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:w.getHours()%12+12*t}))(o,r),f=null!==l&&i(r),y=g?.(d,o)??!1;return t("button",{type:"button",role:"option","aria-selected":f,"aria-disabled":y||void 0,"data-chosen":f?"true":void 0,tabIndex:a===p?0:-1,className:[H,"rounded-mp-full h-(--_mp-cell) w-full shrink-0",h[n],y?"bg-transparent cursor-default text-mp-on-surface/38":f?"bg-(--_mp-accent) text-(--_mp-on-accent)":"bg-transparent text-mp-on-surface"].join(" "),onFocus:()=>z(e=>({...e,[o]:a})),onClick:()=>{y||s(d)},children:[y?null:e(u,{}),m(r)]},r)})},o)};return t("div",{ref:b,className:"mp-time-grid flex gap-1",style:{"--_mp-cell":B[n]},children:[A("hour",v.hour,M,e=>e===k,e=>c?String(e):_(e)),A("minute",v.minute,N,e=>e===w.getMinutes(),_),i?A("second",v.second,P,e=>e===w.getSeconds(),_):null,c?A("meridiem",v.meridiem,[0,1],e=>(w.getHours()>=12?1:0)===e,e=>0===e?D:S):null,e("span",{className:p,"aria-live":"polite",children:null===l?"":x(r,{hour:"numeric",minute:"2-digit",...i?{second:"2-digit"}:{}}).format(l)})]})}
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as r}from"../components/button/MPButton.js";import{MPIcon as l}from"../components/icon/MPIcon.js";import{MPIconButton as a}from"../components/icon-button/MPIconButton.js";import{ChevronDownIcon as s,ChevronLeftIcon as c,ChevronRightIcon as i}from"../constants/icons.js";import{MPStateLayer as u}from"./StateLayer.js";import{CONTROL_ICON as m,META_TEXT as d,PROSE_TEXT as h}from"./scale.js";import{VISUALLY_HIDDEN as p}from"./visually-hidden.js";import{addDays as f,addMonths as g,addYears as b,calendarWeeks as y,compareDay as v,dateFormatter as w,isDayOutside as x,isMonthBeforeYear as D,isSameDay as S,isSameMonth as M,isUnitOutside as N,isValidDate as P,makeDate as _,meridiemLabels as C,monthLabels as k,startOfDay as j,startOfMonth as z,today as A,weekdayLabels as E,withTime as T,YEAR_PAGE_SIZE as F,yearPageStart as Y}from"./date.js";const B={xs:"1.75rem",sm:"2rem",md:"2.5rem",lg:"2.75rem",xl:"3rem"},R={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"},H=/*@__PURE__*/["group relative flex cursor-pointer items-center justify-center overflow-hidden","box-border appearance-none p-0 font-[inherit] tabular-nums select-none","transition-[background-color,border-color,color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:z-10 focus-visible:outline-2","focus-visible:outline-offset-[-2px] focus-visible:outline-solid outline-none"].join(" "),$={day:0,month:1,year:2};function K({children:n,label:o,selected:r,inRange:l=!1,rangeEdge:a=null,current:s=!1,muted:c=!1,disabled:i=!1,focused:m=!1,className:d,onClick:h,onPointerEnter:p,onKeyDown:f}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":i||void 0,tabIndex:m?0:-1,"data-focus-target":m?"true":void 0,className:[H,"start"===a?"rounded-s-mp-full":"end"===a?"rounded-e-mp-full":"middle"===a?"rounded-none":"rounded-mp-full",i?"border-0 bg-transparent cursor-default text-mp-on-surface/38":r?"border-0 bg-(--_mp-accent) text-(--_mp-on-accent)":l?"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":s?"bg-transparent border border-(--_mp-accent) text-(--_mp-accent)":c?"border-0 bg-transparent text-mp-on-surface-variant":"border-0 bg-transparent text-mp-on-surface",d??""].filter(Boolean).join(" "),onClick:()=>{i||h()},onPointerEnter:p,onKeyDown:f,children:[i?null:e(u,{}),n]})}function L({size:o,color:u,view:d,month:p,locale:f,labels:g,showPreviousButton:b,showNextButton:y,onStep:v,onViewChange:w}){const x=k(f,"long")[p.getMonth()],S=String(p.getFullYear()),M=D(f),N=R[o],P="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],_=(t,n)=>n?e(a,{size:N,color:u,label:P[-1===t?0:1],icon:e(l,{icon:-1===t?c:i,size:m[N],className:"rtl:rotate-180"}),onClick:()=>v(t)}):e("span",{"aria-hidden":"true",className:"size-(--_mp-cell)"}),C=t=>e(l,{icon:s,size:m[N],className:["transition-transform duration-(--mp-sys-motion-duration-short4)",t?"rotate-180":""].filter(Boolean).join(" ")}),j=e(r,{variant:"text",size:N,color:u,"aria-label":g.chooseMonth,"aria-expanded":"month"===d,endIcon:C("month"===d),onClick:()=>w("month"===d?"day":"month"),children:x},"month"),z=e(r,{variant:"text",size:N,color:u,className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,endIcon:C("year"===d),onClick:()=>w("year"===d?"day":"year"),children:S},"year"),A=Y(p.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[_(-1,b),e("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1",children:"year"===d?e("span",{className:`text-mp-on-surface flex h-(--_mp-cell) items-center tabular-nums ${h[o]}`,children:`${A}–${A+F-1}`}):"month"===d?z:t(n,M?{children:[j,z]}:{children:[z,j]})}),_(1,y)]})}export function Calendar({size:n,color:r,locale:l,weekStartsOn:a,month:s,onMonthChange:c,selected:i,rangeStart:u=null,rangeEnd:m=null,onSelect:d,onPreviewChange:h,minDate:p,maxDate:f,shouldDisableDate:y,showOutsideDays:v=!0,autoFocus:w=!1,showPreviousButton:D=!0,showNextButton:S=!0,precision:N="day",labels:C}){const[k,E]=o.useState(N),T=$[k]<$[N]?N:k,Y=o.useMemo(()=>i.filter(P),[i]),[R,H]=o.useState(()=>{const e=Y.find(e=>M(e,s));return e?j(e):M(A(),s)?A():z(s)}),K=o.useRef(w),U=o.useRef(null);o.useEffect(()=>{H(e=>M(e,s)?e:z(s))},[s]),o.useLayoutEffect(()=>{K.current&&(K.current=!1,U.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>x(e,p,f)||(y?.(e)??!1),[p,f,y]),G=e=>{K.current=!0,E(e)},W=e=>{K.current=!0,c(e)};return t("div",{ref:U,className:"mp-calendar flex flex-col gap-1",style:{"--_mp-cell":B[n]},onPointerLeave:()=>h?.(null),children:[e(L,{size:n,color:r,view:T,month:s,locale:l,labels:C,showPreviousButton:D,showNextButton:S,onStep:e=>{c("day"===T?g(s,e):b(s,"month"===T?e:e*F))},onViewChange:G}),e("div",{className:"h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*7)]",children:"day"===T?e(I,{size:n,locale:l,weekStartsOn:a,month:s,chosen:Y,rangeStart:u,rangeEnd:m,focusedDate:R,showOutsideDays:v,isDisabled:V,onSelect:e=>{H(e),d(e)},onPreviewChange:h,onMoveFocus:e=>{K.current=!0,H(e),M(e,s)||c(z(e))}}):"month"===T?e(O,{size:n,locale:l,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{const t=_(s.getFullYear(),e,1);"month"!==N?(c(t),G("day")):d(t)}}):e(q,{size:n,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{"year"!==N?(c(_(e,s.getMonth(),1)),G("month")):d(_(e,0,1))}})})]})}function U(e){return"rtl"===getComputedStyle(e).direction?-1:1}function I({size:n,locale:r,weekStartsOn:l,month:a,chosen:s,rangeStart:c,rangeEnd:i,focusedDate:u,showOutsideDays:m,isDisabled:p,onSelect:b,onPreviewChange:x,onMoveFocus:D}){const N=E(r,l,"narrow"),_=E(r,l,"long"),C=(j=i,P(k=c)&&P(j)?v(k,j)<=0?[k,j]:[j,k]:null);var k,j;const z=A(),T=o.useMemo(()=>{const e=w(r,{dateStyle:"full"});return y(a,l).map(t=>t.map(t=>({date:t,label:e.format(t)})))},[a,l,r]),F=o.useRef(null),Y=o.useRef(a);o.useLayoutEffect(()=>{const e=F.current,t=Y.current;if(Y.current=a,!e||M(t,a))return;const n=t.getTime()<a.getTime(),o="rtl"===getComputedStyle(e).direction;e.style.setProperty("--_mp-calendar-from",String(n===o?-1:1)),e.dataset.mpPaged="true",e.style.animationName="none",e.offsetWidth,e.style.animationName=""},[a]);return t("div",{role:"grid","aria-label":w(r,{year:"numeric",month:"long"}).format(a),className:"flex h-full flex-col",children:[e("div",{role:"rowgroup",children:e("div",{role:"row",className:"grid grid-cols-7",children:N.map((t,n)=>e("span",{role:"columnheader","aria-label":_[n],className:`text-mp-on-surface-variant flex h-(--_mp-cell) items-center justify-center select-none ${d}`,children:t},n))})}),e("div",{ref:F,role:"rowgroup",className:"mp-calendar__page flex flex-1 flex-col",children:T.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(({date:t,label:o})=>{const r=!M(t,a);if(r&&!m)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--_mp-cell)"},t.getTime());const c=s.some(e=>S(e,t)),i=null!==C&&v(t,C[0])>=0&&v(t,C[1])<=0,d=null!==C&&i&&S(t,C[0]),y=null!==C&&i&&S(t,C[1]);return e(K,{label:o,selected:c,inRange:i&&!c,rangeEdge:i?d&&y?"both":d?"start":y?"end":"middle":null,current:S(t,z)&&!c,muted:r,disabled:p(t),focused:S(t,u),className:`size-(--_mp-cell) ${h[n]}`,onClick:()=>b(t),onPointerEnter:()=>x?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-l+7)%7,o=U(e.currentTarget),r={ArrowLeft:()=>f(t,-o),ArrowRight:()=>f(t,o),ArrowUp:()=>f(t,-7),ArrowDown:()=>f(t,7),Home:()=>f(t,-n),End:()=>f(t,6-n),PageUp:()=>g(t,e.shiftKey?-12:-1),PageDown:()=>g(t,e.shiftKey?12:1)}[e.key];r&&(e.preventDefault(),D(r()))})(e,t),children:t.getDate()},t.getTime())})},o))})]})}function O({size:t,locale:n,month:r,chosen:l,minDate:a,maxDate:s,onMoveCursor:c,onPick:i}){const u=k(n,"short"),m=r.getFullYear(),d=new Date,p=o.useMemo(()=>{const e=w(n,{year:"numeric",month:"long"});return Array.from({length:12},(t,n)=>e.format(_(m,n,1)))},[n,m]),f=e=>{const t=U(e.currentTarget),n={ArrowLeft:-t,ArrowRight:t,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==n&&(e.preventDefault(),c(g(z(r),n)))};return e("div",{role:"grid","aria-label":String(m),className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(o=>{const c=3*n+o;return e(K,{label:p[c],selected:l.some(e=>e.getFullYear()===m&&e.getMonth()===c),current:d.getFullYear()===m&&d.getMonth()===c,disabled:N(_(m,c,1),"month",a,s),focused:c===r.getMonth(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>i(c),onKeyDown:f,children:u[c]},c)})},n))})}function q({size:t,month:n,chosen:o,minDate:r,maxDate:l,onMoveCursor:a,onPick:s}){const c=Y(n.getFullYear()),i=(new Date).getFullYear(),u=e=>{const t=U(e.currentTarget),o={ArrowLeft:-t,ArrowRight:t,ArrowUp:-4,ArrowDown:4,PageUp:-F,PageDown:F}[e.key];void 0!==o&&(e.preventDefault(),a(b(z(n),o)))};return e("div",{role:"grid","aria-label":`${c}–${c+F-1}`,className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(a=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(m=>{const d=c+4*a+m;return e(K,{label:String(d),selected:o.some(e=>e.getFullYear()===d),current:d===i,disabled:N(_(d,0,1),"year",r,l),focused:d===n.getFullYear(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>s(d),onKeyDown:u,children:d},d)})},a))})}function V(e,t){return Number.isFinite(e)?Math.min(t,Math.max(1,Math.round(e))):1}function G(e,t="auto"){const n=e.parentElement;if(!n)return;const o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),l=o.top-r.top-n.clientTop+n.scrollTop,a=l+o.height;l<n.scrollTop?n.scrollTo({top:l,behavior:t}):a>n.scrollTop+n.clientHeight&&n.scrollTo({top:a-n.clientHeight,behavior:t})}export function MPTimeGrid({size:n,locale:r,value:l,referenceDate:a,onChange:s,hour12:c,showSeconds:i,hourStep:m,minuteStep:d,secondStep:f,shouldDisableTime:g,autoFocus:b=!1,labels:y}){const v=l??a,x=o.useRef(null),[D,S]=o.useMemo(()=>C(r),[r]);o.useEffect(()=>{const e=x.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(e=>G(e,"instant")),b){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[b]);const M=o.useMemo(()=>{const e=c?12:24,t=V(m,e),n=Array.from({length:Math.ceil(e/t)},(e,n)=>n*t);return c?n.map(e=>0===e?12:e):n},[c,m]),N=o.useMemo(()=>{const e=V(d,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[d]),P=o.useMemo(()=>{const e=V(f,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[f]),_=e=>String(e).padStart(2,"0"),k=c?v.getHours()%12||12:v.getHours(),[j,z]=o.useState({}),A=(o,r,a,i,m)=>{const d=null===l?-1:a.findIndex(e=>i(e)),p=j[o]??(d>=0?d:0);return e("div",{role:"listbox","aria-label":r,className:["mp-time-grid__column flex flex-col gap-0.5 overflow-y-auto overscroll-contain","motion-safe:scroll-smooth","h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"].join(" "),onKeyDown:e=>{const t={ArrowDown:1,ArrowUp:-1,PageDown:5,PageUp:-5}[e.key],n=void 0!==t?(e=>{const t=[...e.children].indexOf(document.activeElement);return t>=0?t:p})(e.currentTarget)+t:"Home"===e.key?0:"End"===e.key?a.length-1:null;null!==n&&(e.preventDefault(),((e,t)=>{const n=Math.min(a.length-1,Math.max(0,e)),r=t.children[n];z(e=>({...e,[o]:n})),r instanceof HTMLElement&&(r.focus({preventScroll:!0}),G(r))})(n,e.currentTarget))},children:a.map((r,a)=>{const d=((e,t)=>T(v,"hour"===e?{hours:c?t%12+(v.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:v.getHours()%12+12*t}))(o,r),f=null!==l&&i(r),b=g?.(d,o)??!1;return t("button",{type:"button",role:"option","aria-selected":f,"aria-disabled":b||void 0,"data-chosen":f?"true":void 0,tabIndex:a===p?0:-1,className:[H,"rounded-mp-full h-(--_mp-cell) w-full shrink-0 border-0",h[n],b?"bg-transparent cursor-default text-mp-on-surface/38":f?"bg-(--_mp-accent) text-(--_mp-on-accent)":"bg-transparent text-mp-on-surface"].join(" "),onFocus:()=>z(e=>({...e,[o]:a})),onClick:()=>{b||s(d)},children:[b?null:e(u,{}),m(r)]},r)})},o)};return t("div",{ref:x,className:"mp-time-grid flex gap-1",style:{"--_mp-cell":B[n]},children:[A("hour",y.hour,M,e=>e===k,e=>c?String(e):_(e)),A("minute",y.minute,N,e=>e===v.getMinutes(),_),i?A("second",y.second,P,e=>e===v.getSeconds(),_):null,c?A("meridiem",y.meridiem,[0,1],e=>(v.getHours()>=12?1:0)===e,e=>0===e?D:S):null,e("span",{className:p,"aria-live":"polite",children:null===l?"":w(r,{hour:"numeric",minute:"2-digit",...i?{second:"2-digit"}:{}}).format(l)})]})}
|
|
@@ -0,0 +1,199 @@
|
|
|
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
|
+
interface LegendProps {
|
|
78
|
+
/**
|
|
79
|
+
* What each entry is called. Names rather than series, because a pie's
|
|
80
|
+
* entries are its slices — the entity a legend identifies is not always a
|
|
81
|
+
* series, and a legend that insisted on one would be a legend a pie has to
|
|
82
|
+
* fake a series array for.
|
|
83
|
+
*/
|
|
84
|
+
names: readonly (string | undefined)[];
|
|
85
|
+
colors: readonly string[];
|
|
86
|
+
options: MPChartLegend;
|
|
87
|
+
visibility: Visibility;
|
|
88
|
+
size: MPSize;
|
|
89
|
+
values?: readonly (string | undefined)[];
|
|
90
|
+
swatch?: (index: number, color: string) => React.ReactNode;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The identity channel that does not depend on being able to see a colour.
|
|
94
|
+
*
|
|
95
|
+
* A swatch and a word, and the swatch is the only thing on the row wearing the
|
|
96
|
+
* series' colour — the name beside it stays in ordinary ink. That is the rule
|
|
97
|
+
* for every piece of text in a chart: a label written in the mark's colour is a
|
|
98
|
+
* label the reader has to decode before they can read it, and it fails outright
|
|
99
|
+
* in forced colours.
|
|
100
|
+
*
|
|
101
|
+
* Interactive by default, and each entry is a real `<button>` with
|
|
102
|
+
* `aria-pressed`. A legend that filters is a control, and a control that is a
|
|
103
|
+
* `<div>` with an `onClick` is one a keyboard cannot reach.
|
|
104
|
+
*/
|
|
105
|
+
export declare function ChartLegend({ names, colors, options, visibility, size, values, swatch }: LegendProps): React.JSX.Element;
|
|
106
|
+
interface PanelProps {
|
|
107
|
+
heading?: React.ReactNode;
|
|
108
|
+
items: readonly MPChartTooltipItem[];
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
flip: boolean;
|
|
112
|
+
size: MPSize;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What the pointer uncovers, as a panel.
|
|
116
|
+
*
|
|
117
|
+
* `pointer-events-none` is the load-bearing part: a panel that could be hovered
|
|
118
|
+
* would sit under the pointer, take the hover from the plot, and close itself —
|
|
119
|
+
* then reopen, then close, for as long as the reader held still.
|
|
120
|
+
*/
|
|
121
|
+
export declare function ChartTooltipPanel({ heading, items, x, y, flip, size }: PanelProps): React.JSX.Element;
|
|
122
|
+
/**
|
|
123
|
+
* The same reading, said out loud instead of drawn.
|
|
124
|
+
*
|
|
125
|
+
* It cannot be the panel above, and that is a constraint rather than a
|
|
126
|
+
* preference: the panel is drawn inside the element carrying `role="img"`, and
|
|
127
|
+
* `img` is a leaf role — everything under it is cut out of the accessibility
|
|
128
|
+
* tree, so a live region in there announces to nobody. This is a **sibling** of
|
|
129
|
+
* the picture, clipped rather than painted, and it is what makes the arrow keys
|
|
130
|
+
* mean something to a reader who is not looking at the plot.
|
|
131
|
+
*
|
|
132
|
+
* Empty when nothing is active, so leaving the chart clears what was said
|
|
133
|
+
* rather than leaving the last column standing in the region forever.
|
|
134
|
+
*/
|
|
135
|
+
export declare function ChartStatus({ heading, items }: {
|
|
136
|
+
heading?: React.ReactNode;
|
|
137
|
+
items: readonly MPChartTooltipItem[];
|
|
138
|
+
}): React.JSX.Element;
|
|
139
|
+
interface TableProps {
|
|
140
|
+
id: string;
|
|
141
|
+
caption: string;
|
|
142
|
+
corner: React.ReactNode;
|
|
143
|
+
categories: readonly MPChartCategory[];
|
|
144
|
+
/** One per column, beside the category's own. */
|
|
145
|
+
names: readonly (string | undefined)[];
|
|
146
|
+
values: readonly (readonly ChartValue[])[];
|
|
147
|
+
format: (value: number) => string;
|
|
148
|
+
locale: string | undefined;
|
|
149
|
+
empty: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The numbers behind the picture, as a grid.
|
|
153
|
+
*
|
|
154
|
+
* Clipped rather than drawn. Every chart here ships one and it is what
|
|
155
|
+
* `aria-describedby` points at, so a reader who cannot see the plot has the
|
|
156
|
+
* data itself rather than a summary of it — and a reader who can see the plot
|
|
157
|
+
* is not made to scroll past a table they did not ask for.
|
|
158
|
+
*
|
|
159
|
+
* Rendered rather than built on demand, because it is the description of a
|
|
160
|
+
* focusable element: an `aria-describedby` pointing at an id that does not
|
|
161
|
+
* exist yet is an `aria-describedby` pointing at nothing.
|
|
162
|
+
*/
|
|
163
|
+
export declare function ChartTable({ id, caption, corner, categories, names, values, format, locale, empty }: TableProps): React.JSX.Element;
|
|
164
|
+
export interface ChartShellProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'color' | 'title'> {
|
|
165
|
+
size: MPSize;
|
|
166
|
+
/** The element the drawing is measured in and focused on. */
|
|
167
|
+
plotRef: React.RefObject<HTMLDivElement | null>;
|
|
168
|
+
/** Its accessible name, already resolved — never an optional prop passed straight through. */
|
|
169
|
+
name: string;
|
|
170
|
+
/** The id of the table describing it, or nothing when there is nothing to describe. */
|
|
171
|
+
describedBy?: string;
|
|
172
|
+
/** Whether there is anything here to walk. A chart with no data is not a tab stop. */
|
|
173
|
+
interactive: boolean;
|
|
174
|
+
height?: number | string;
|
|
175
|
+
/** The pointer and keyboard handlers, which are the plot's own business. */
|
|
176
|
+
plotProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
177
|
+
/** The drawing: an `<svg>`, or the empty state. */
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
/** Floated over the drawing. */
|
|
180
|
+
tooltip?: React.ReactNode;
|
|
181
|
+
legend?: React.ReactNode;
|
|
182
|
+
legendSide?: MPSide;
|
|
183
|
+
status: {
|
|
184
|
+
heading?: React.ReactNode;
|
|
185
|
+
items: readonly MPChartTooltipItem[];
|
|
186
|
+
};
|
|
187
|
+
table?: React.ReactNode;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The arrangement: a plot, a legend on one of its four sides, a readout beside
|
|
191
|
+
* it and the table underneath.
|
|
192
|
+
*
|
|
193
|
+
* The readout is a **sibling** of the plot rather than a child, and that is a
|
|
194
|
+
* constraint rather than a layout preference — see `ChartStatus`. Putting the
|
|
195
|
+
* arrangement here is what keeps the two frames from disagreeing about it: the
|
|
196
|
+
* one place this is easy to get wrong is the one place it must not be.
|
|
197
|
+
*/
|
|
198
|
+
export declare function ChartShell({ size, plotRef, name, describedBy, interactive, height, plotProps, children, tooltip, legend, legendSide, status, table, className, ...rest }: ChartShellProps): React.JSX.Element;
|
|
199
|
+
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}}const o={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},c={start:"justify-start",center:"justify-center",end:"justify-end"};export function ChartLegend({names:n,colors:a,options:r,visibility:i,size:s,values:o,swatch:m}){const d=!1!==r.interactive,p="xs"===s||"sm"===s?"text-mp-label-small":"text-mp-label-medium";return e("ul",{className:["mp-chart__legend m-0 flex list-none flex-wrap items-center gap-x-4 gap-y-1 p-0",c[r.align??"center"],p].join(" "),children:n.map((n,r)=>{const s=i.visible[r],c=!s||null!==i.hovered&&i.hovered!==r,p=n??`${r+1}`,u=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:p}),o?.[r]?e("span",{className:"text-mp-on-surface tabular-nums",children:o[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","appearance-none border-0 bg-transparent p-0 text-inherit [font:inherit]","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2",c?"opacity-40":"",s?"":"line-through"].filter(Boolean).join(" "),children:u}):e("span",{className:"flex min-w-0 items-center gap-1.5 "+(c?"opacity-40":""),children:u})},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:"m-0 flex list-none flex-col gap-0.5 p-0",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:p}){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:p})}):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?p:m(a.value))},l)})]},n))})]})})}export function ChartShell({size:t,plotRef:n,name:a,describedBy:s,interactive:c,height:m,plotProps:d,children:p,tooltip:u,legend:h,legendSide:f="bottom",status:x,table:b,className:v,...g}){return l("div",{"data-mp-size":t,className:["mp-chart flex min-w-0 flex-col gap-3",v??""].filter(Boolean).join(" "),...g,children:[l("div",{className:`flex min-w-0 gap-3 ${o[f]}`,children:[l("div",{ref:n,role:"img",tabIndex:c?0:void 0,"aria-label":a,"aria-describedby":s,...d,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(m)??i[t]},children:[p,u]}),h]}),e(ChartStatus,{heading:x.heading,items:x.items}),b]})}
|
|
@@ -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 {};
|