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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useMPConfig, type MPConfigValue } from '../../internal/config.js';
|
|
3
|
-
import type { MPColor, MPSize } from '../../types.js';
|
|
3
|
+
import type { MPColor, MPDensity, MPSize, MPWindowClass } from '../../types.js';
|
|
4
4
|
export interface MPConfigProviderProps {
|
|
5
5
|
/**
|
|
6
6
|
* The size every control under this starts at.
|
|
@@ -18,6 +18,46 @@ export interface MPConfigProviderProps {
|
|
|
18
18
|
* line here rather than a prop on every button, chip, tab and slider.
|
|
19
19
|
*/
|
|
20
20
|
color?: MPColor;
|
|
21
|
+
/**
|
|
22
|
+
* How tightly every component that holds things is packed under this.
|
|
23
|
+
*
|
|
24
|
+
* `0` unless set — the size that was asked for, with nothing taken out. A
|
|
25
|
+
* product that runs dense sets it here, and only the containers read it: the
|
|
26
|
+
* lists, tables and cards tighten and the controls keep the height a finger
|
|
27
|
+
* needs. See `MPDensity`.
|
|
28
|
+
*/
|
|
29
|
+
density?: MPDensity;
|
|
30
|
+
/**
|
|
31
|
+
* Where the window size classes begin, in CSS pixels, for everything the
|
|
32
|
+
* library decides in **JavaScript** — `useMPWindowClass`, `MPSidebar`'s
|
|
33
|
+
* collapse, and the rungs `maxWidth` resolves to.
|
|
34
|
+
*
|
|
35
|
+
* Partial and merged over MD3's own, so `{ medium: 700 }` moves one boundary
|
|
36
|
+
* and leaves the other three. `compact` is always nought whatever it is given:
|
|
37
|
+
* a first class whose floor is above zero leaves a band of windows in no class
|
|
38
|
+
* at all.
|
|
39
|
+
*
|
|
40
|
+
* ## This does not move the stylesheet
|
|
41
|
+
*
|
|
42
|
+
* It cannot. A media query is resolved before any of this runs and cannot name
|
|
43
|
+
* a custom property, so `MPGrid`'s reflow, `MPShow`'s hiding and every other
|
|
44
|
+
* width-driven rule are decided by the CSS the build produced. This prop is
|
|
45
|
+
* how you tell the JavaScript side what you already did on the CSS side — it
|
|
46
|
+
* is not the source, and a page that sets it alone has moved half its layout.
|
|
47
|
+
*
|
|
48
|
+
* The CSS side is a project that runs its own Tailwind, redeclaring both
|
|
49
|
+
* halves of the boundary after importing the library:
|
|
50
|
+
*
|
|
51
|
+
* ```css
|
|
52
|
+
* @custom-variant mp-medium (@media (width >= 700px));
|
|
53
|
+
* @custom-variant mp-below-medium (@media (width < 700px));
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* A project on the compiled `material-plus-ui/styles.css` cannot move the
|
|
57
|
+
* stylesheet at all, and should not set this either. See
|
|
58
|
+
* [Breakpoints](../../design/breakpoints).
|
|
59
|
+
*/
|
|
60
|
+
breakpoints?: Partial<Record<MPWindowClass, number>>;
|
|
21
61
|
/**
|
|
22
62
|
* The language the components speak — the same value `MPLocaleProvider` takes,
|
|
23
63
|
* carried here so an application needs one provider rather than two.
|
|
@@ -52,8 +92,9 @@ export interface MPConfigProviderProps {
|
|
|
52
92
|
* The prop defaults for everything under it.
|
|
53
93
|
*
|
|
54
94
|
* Wrap the application. Every component in this library still takes `size` and
|
|
55
|
-
* `color` of its own
|
|
56
|
-
* design that runs at `size="sm"` is one
|
|
95
|
+
* `color` of its own — and every container takes `density` — and this is where
|
|
96
|
+
* those props get their default, so a design that runs at `size="sm"` is one
|
|
97
|
+
* decision rather than one per call site.
|
|
57
98
|
*
|
|
58
99
|
* ```tsx
|
|
59
100
|
* <MPConfigProvider size="sm" color="tertiary" locale="ko">
|
|
@@ -61,7 +102,7 @@ export interface MPConfigProviderProps {
|
|
|
61
102
|
* </MPConfigProvider>
|
|
62
103
|
* ```
|
|
63
104
|
*
|
|
64
|
-
* ## Why it carries these
|
|
105
|
+
* ## Why it carries these three and not a theme
|
|
65
106
|
*
|
|
66
107
|
* Everything a theme normally holds is already a CSS custom property here — the
|
|
67
108
|
* colour roles, the type scale, the corners, the motion durations. Those reach a
|
|
@@ -73,8 +114,9 @@ export interface MPConfigProviderProps {
|
|
|
73
114
|
* Tailwind class strings — `h-14`, `text-mp-body-large` — because Tailwind finds
|
|
74
115
|
* classes by scanning source text and an interpolated `h-${n}` generates no rule
|
|
75
116
|
* at all. A value that cannot be a custom property and has to reach every call
|
|
76
|
-
* site is exactly what context is for. `color`
|
|
77
|
-
* axes a whole product is usually set on together
|
|
117
|
+
* site is exactly what context is for. `color` and `density` join it because the
|
|
118
|
+
* three are the axes a whole product is usually set on together — and because
|
|
119
|
+
* `density` resolves to class strings for the same reason `size` does.
|
|
78
120
|
*
|
|
79
121
|
* ## Why `variant` is not here
|
|
80
122
|
*
|
|
@@ -107,7 +149,7 @@ export interface MPConfigProviderProps {
|
|
|
107
149
|
* </MPConfigProvider>
|
|
108
150
|
* ```
|
|
109
151
|
*/
|
|
110
|
-
export declare function MPConfigProvider({ size, color, locale, dir, children }: MPConfigProviderProps): React.JSX.Element;
|
|
152
|
+
export declare function MPConfigProvider({ size, color, density, breakpoints, locale, dir, children }: MPConfigProviderProps): React.JSX.Element;
|
|
111
153
|
/**
|
|
112
154
|
* The configuration in force at this point in the tree.
|
|
113
155
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import*as i from"react";import{DirectionProvider as o}from"@base-ui/react/direction-provider";import{MPConfigContext as e,useMPConfig as n}from"../../internal/config.js";import{MPLocaleContext as t,useMPLocale as s}from"../../internal/locale.js";import{WINDOW_CLASSES as a}from"../../internal/window-class.js";export function MPConfigProvider({size:c,color:d,density:l,breakpoints:p,locale:m,dir:f,children:v}){const u=n(),b=s(),j=a.map(r=>p?.[r]??u.breakpoints?.[r]??"").join(","),y=i.useMemo(()=>({size:c??u.size,color:d??u.color,density:l??u.density,breakpoints:p||u.breakpoints?{...u.breakpoints,...p}:void 0}),[c,d,l,u.size,u.color,u.density,j]),h=m??b,k=r(e.Provider,{value:y,children:r(t.Provider,{value:h,children:v})});return f?r(o,{direction:f,children:r("div",{dir:f,style:{display:"contents"},children:k})}):k}export{n as useMPConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as
|
|
2
|
+
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";const a=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:u,children:m}){const[d,f]=o.useState(null),p=c(s,l()),h=o.useRef(null),C=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...u,...e,acknowledge:r})}),[u]),P=o.useMemo(()=>({confirm:e=>C(e,!1),alert:e=>C(e,!0).then(()=>{})}),[C]),x=e=>{h.current?.(e),h.current=null,f(null)},g=o.useRef(null);d&&(g.current=d);const v=d??g.current,w=v?.acknowledge??!1;return n(a.Provider,{value:P,children:[m,e(t,{open:null!==d,onOpenChange:e=>{e||x(w)},icon:v?.icon,title:v?.title,description:v?.description,size:v?.size??"md",color:v?.color??"primary",dismissible:v?.dismissible??!0,actions:n(r,{children:[w?null:e(i,{variant:"text",onClick:()=>x(!1),children:v?.cancelLabel??p.cancel}),e(i,{variant:"text",color:v?.color??"primary",onClick:()=>x(!0),children:v?.confirmLabel??(w?p.ok:p.confirm)})]}),children:v?.children})]})}export function useMPConfirm(){const e=o.useContext(a);if(!e)throw new Error("useMPConfirm was called outside an <MPConfirmProvider>. Wrap the application in one — the provider is what holds the dialog every confirm() is drawn in.");return e}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
-
import type { MPSize } from '../../types.js';
|
|
3
|
+
import type { MPMeasure, MPResponsive, MPSize } from '../../types.js';
|
|
4
4
|
export interface MPContainerProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
5
5
|
/**
|
|
6
6
|
* How wide the content is allowed to get, on a ladder pinned to MD3's window
|
|
7
7
|
* size classes — `sm` 600dp, `md` 840dp, `lg` 1200dp, `xl` 1600dp, `xs` 480dp.
|
|
8
8
|
*
|
|
9
|
+
* Or a CSS length of your own: `maxWidth="60ch"` is the measure a paragraph
|
|
10
|
+
* actually wants, and no ladder of window widths can spell it.
|
|
11
|
+
*
|
|
12
|
+
* Responsive, like the grid's props: `maxWidth={{ compact: 'none', expanded: 'lg' }}`
|
|
13
|
+
* is edge to edge on a phone and held to 1200dp from 840 up. Each entry applies
|
|
14
|
+
* from its own window class upward.
|
|
15
|
+
*
|
|
9
16
|
* `none`, the default, is no limit: a container's job is the margin, and a
|
|
10
17
|
* measure is a second decision that a page should have to ask for.
|
|
11
18
|
* @default 'none'
|
|
12
19
|
*/
|
|
13
|
-
maxWidth?:
|
|
20
|
+
maxWidth?: MPResponsive<MPMeasure>;
|
|
14
21
|
/**
|
|
15
22
|
* The page margin. Turn it off to keep the centring and the measure without
|
|
16
23
|
* the gutter — a full-bleed hero, a section that pads itself.
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{SHEET_PAD_X as n}from"../../internal/scale.js";import{measureValue as o}from"../../internal/measure.js";import{useWindowMins as t}from"../../internal/window-class.js";import{responsiveSlots as a,withBaseline as s}from"../../internal/responsive.js";import{useMPSize as i}from"../../internal/config.js";export const MPContainer=/*@__PURE__*/e.forwardRef(function({maxWidth:e="none",padded:m=!0,size:l,centered:c=!0,render:p,className:d,style:f,children:u,...j},b){const w=i(l),x=t(),h="none"!==e;return r({render:p,ref:b,props:{"data-mp-size":w,className:["mp-container block w-full","box-border",h?"mp-measure":"",c?"mx-auto":"",m?n[w]:"",d??""].filter(Boolean).join(" "),style:h?{...a("measure",s(e,"none"),e=>o(e,x)),...f}:f,children:u,...j}})});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPDensity, MPOrientation, MPSize } from '../../types.js';
|
|
3
|
+
export interface MPDataListProps extends Omit<React.ComponentPropsWithoutRef<'dl'>, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* Where the label sits.
|
|
6
|
+
*
|
|
7
|
+
* - `horizontal` — beside the value, in a column of its own. The default, and
|
|
8
|
+
* the shape a details panel takes.
|
|
9
|
+
* - `vertical` — above it. For a narrow column, and for values long enough
|
|
10
|
+
* that a label beside them would leave most of the row empty.
|
|
11
|
+
* @default 'horizontal'
|
|
12
|
+
*/
|
|
13
|
+
orientation?: MPOrientation;
|
|
14
|
+
/**
|
|
15
|
+
* How wide the label column is when `horizontal`. A number is pixels, a
|
|
16
|
+
* string is any CSS length.
|
|
17
|
+
*
|
|
18
|
+
* Left out it is as wide as the widest label, which is what keeps every value
|
|
19
|
+
* in the list starting at the same place without anybody measuring anything.
|
|
20
|
+
*/
|
|
21
|
+
labelWidth?: number | string;
|
|
22
|
+
/** Draws a hairline between the rows. @default false */
|
|
23
|
+
dividers?: boolean;
|
|
24
|
+
/** @default 'md' */
|
|
25
|
+
size?: MPSize;
|
|
26
|
+
/**
|
|
27
|
+
* Tightens the gaps between rows and columns, and nothing else. The type
|
|
28
|
+
* scale does not move.
|
|
29
|
+
* @default 0
|
|
30
|
+
*/
|
|
31
|
+
density?: MPDensity;
|
|
32
|
+
/** The pairs. */
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
export interface MPDataListItemProps {
|
|
36
|
+
/** What the value is called. */
|
|
37
|
+
label: React.ReactNode;
|
|
38
|
+
/** The value. A node, so a chip, a link or a piece of code all fit. */
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One pair: what it is called, and what it is.
|
|
43
|
+
*
|
|
44
|
+
* A fragment rather than an element, so the `<dt>` and the `<dd>` land as direct
|
|
45
|
+
* children of the `<dl>` and the grid can line every label up against every
|
|
46
|
+
* other. It has no `size` or `density` of its own — those belong to the list,
|
|
47
|
+
* because a details panel with one row set tighter than its neighbours is not a
|
|
48
|
+
* thing anybody wants.
|
|
49
|
+
*/
|
|
50
|
+
export declare function MPDataListItem({ label, children }: MPDataListItemProps): React.JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* A list of things and what they are called — a details panel, the summary of a
|
|
53
|
+
* record, the metadata under a heading.
|
|
54
|
+
*
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <MPDataList>
|
|
57
|
+
* <MPDataListItem label="Status">Active</MPDataListItem>
|
|
58
|
+
* <MPDataListItem label="Owner">Priya Raman</MPDataListItem>
|
|
59
|
+
* </MPDataList>
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* ## Why not a two-column `MPTable`
|
|
63
|
+
*
|
|
64
|
+
* Because they are read differently, and the difference is the whole reason
|
|
65
|
+
* this is a component. A table is a grid of **rows**, all of the same shape,
|
|
66
|
+
* and a screen reader walks it as a grid — announcing column headers, offering
|
|
67
|
+
* cell-by-cell navigation, counting rows. This is a set of **pairs**, and each
|
|
68
|
+
* one is announced as "label, value", which is what a details panel actually
|
|
69
|
+
* is.
|
|
70
|
+
*
|
|
71
|
+
* So it is a real `<dl>` of real `<dt>`/`<dd>` pairs, and `MPDataListItem`
|
|
72
|
+
* renders a fragment rather than a wrapper: the two elements have to be direct
|
|
73
|
+
* children of the `<dl>` for the grid to line every label up against every
|
|
74
|
+
* other, and a `<div>` between them would take the grid with it.
|
|
75
|
+
*
|
|
76
|
+
* ## It draws no surface
|
|
77
|
+
*
|
|
78
|
+
* No sheet, no padding, no corner. Put it in an `MPCard` when one is wanted,
|
|
79
|
+
* which is what makes the same list work inside a card, inside a popover, and
|
|
80
|
+
* loose under a heading.
|
|
81
|
+
*/
|
|
82
|
+
export declare const MPDataList: React.ForwardRefExoticComponent<MPDataListProps & React.RefAttributes<HTMLDListElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{cssLength as i}from"../../internal/length.js";import{META_TEXT as n,PROSE_TEXT as r,hasContent as l}from"../../internal/scale.js";import{useMPDensity as o,useMPSize as s}from"../../internal/config.js";const m=/*@__PURE__*/a.createContext({size:"md",orientation:"horizontal"}),d={xs:12,sm:16,md:20,lg:24,xl:32},p={xs:8,sm:10,md:12,lg:14,xl:16};function c(t,e,a){return Math.max(a,t+4*e)}export function MPDataListItem({label:i,children:o}){const{size:s,orientation:d}=a.useContext(m),p="vertical"===d;return e(a.Fragment,{children:[t("dt",{className:["mp-data-list__label text-mp-on-surface-variant min-w-0",n,p?"mt-(--_mp-data-list-row) first:mt-0":""].filter(Boolean).join(" "),children:i}),t("dd",{className:`mp-data-list__value text-mp-on-surface m-0 min-w-0 ${r[s]}`,children:l(o)?o:null})]})}export const MPDataList=/*@__PURE__*/a.forwardRef(function({orientation:e="horizontal",labelWidth:n,dividers:r=!1,size:l,density:f,className:x,style:h,children:u,..._},j){const b=s(l),g=o(f),v="vertical"===e,w=a.useMemo(()=>({size:b,orientation:e}),[b,e]);return t(m.Provider,{value:w,children:t("dl",{ref:j,"data-mp-size":b,className:["mp-data-list m-0 min-w-0",v?"flex flex-col":["grid items-baseline","[grid-template-columns:var(--_mp-data-list-label)_minmax(0,1fr)]","gap-x-(--_mp-data-list-col) gap-y-(--_mp-data-list-row)"].join(" "),r?["border-mp-outline-variant","[&>dt:nth-of-type(n+2)]:border-t [&>dt:nth-of-type(n+2)]:pt-(--_mp-data-list-row)",v?"":"[&>dd:nth-of-type(n+2)]:border-t [&>dd:nth-of-type(n+2)]:pt-(--_mp-data-list-row)"].filter(Boolean).join(" "):"",x??""].filter(Boolean).join(" "),style:{"--_mp-data-list-label":i(n)??"max-content","--_mp-data-list-col":`${c(d[b],g,8)}px`,"--_mp-data-list-row":`${c(p[b],g,4)}px`,...h},..._,children:u})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPDataList,MPDataListItem}from"./MPDataList.js";
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPDataTableSort } from '../../internal/data-table.js';
|
|
3
|
+
import type { MPAlign, MPColor, MPDensity, MPElevation, MPSize, MPSlots, MPVariant } from '../../types.js';
|
|
4
|
+
export type { MPDataTableSort, MPSortDirection } from '../../internal/data-table.js';
|
|
5
|
+
/** How many rows may be chosen at once. */
|
|
6
|
+
export type MPDataTableSelectionMode = 'none' | 'single' | 'multiple';
|
|
7
|
+
/** The parts an `MPDataTable` draws that a `className` cannot reach. */
|
|
8
|
+
export type MPDataTableSlot = 'toolbar' | 'table' | 'head' | 'row' | 'cell' | 'footer';
|
|
9
|
+
/**
|
|
10
|
+
* A column: its heading, how wide it is, how to get a value out of a row and how
|
|
11
|
+
* to draw one.
|
|
12
|
+
*
|
|
13
|
+
* The split between `value` and `render` is the whole shape of this type. A
|
|
14
|
+
* `render` decides what a reader sees; a `value` decides what the sort and the
|
|
15
|
+
* search see. Most columns need neither — the cell is `row[key]`, and that is
|
|
16
|
+
* what is compared and matched. A column that draws an `MPChip` needs `render`,
|
|
17
|
+
* and it needs `value` as well the moment it is sortable, because a React
|
|
18
|
+
* element has no order.
|
|
19
|
+
*/
|
|
20
|
+
export interface MPDataTableColumn<Row> {
|
|
21
|
+
/**
|
|
22
|
+
* Identifies the column — to `sort`, to `columnWidths`, and unless `value` or
|
|
23
|
+
* `render` says otherwise, it names the property to read off each row.
|
|
24
|
+
*/
|
|
25
|
+
key: string;
|
|
26
|
+
/** The heading. Defaults to the `key`, which is usually not what you want. */
|
|
27
|
+
label?: React.ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* How wide, in pixels.
|
|
30
|
+
*
|
|
31
|
+
* Pixels rather than any CSS length, because a resize drag does arithmetic on
|
|
32
|
+
* this number. Columns that do not say are `160`, and see `resizable` for what
|
|
33
|
+
* turning it on does to the layout.
|
|
34
|
+
*/
|
|
35
|
+
width?: number;
|
|
36
|
+
/** How narrow a drag may make it. @default 48 */
|
|
37
|
+
minWidth?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Which edge the cells line up against. Numbers usually want `end` so their
|
|
40
|
+
* digits line up in a column.
|
|
41
|
+
* @default 'start'
|
|
42
|
+
*/
|
|
43
|
+
align?: MPAlign;
|
|
44
|
+
/** Whether this column can be sorted. Defaults to the table's `sortable`. */
|
|
45
|
+
sortable?: boolean;
|
|
46
|
+
/** Whether this column can be dragged wider. Defaults to the table's `resizable`. */
|
|
47
|
+
resizable?: boolean;
|
|
48
|
+
/** Whether the search looks in this column. @default true */
|
|
49
|
+
searchable?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The value behind the cell: what is sorted, and what the search is matched
|
|
52
|
+
* against. Defaults to `row[key]`.
|
|
53
|
+
*/
|
|
54
|
+
value?: (row: Row) => unknown;
|
|
55
|
+
/**
|
|
56
|
+
* Orders two rows by this column, for a value the default comparison cannot
|
|
57
|
+
* rank — a status that goes `draft`, `review`, `live` rather than
|
|
58
|
+
* alphabetically. Always written ascending; the table reverses it.
|
|
59
|
+
*/
|
|
60
|
+
compare?: (a: Row, b: Row) => number;
|
|
61
|
+
/**
|
|
62
|
+
* Draws the cell. `index` is the row's place in the sorted, searched order and
|
|
63
|
+
* is counted across every page, so `(row, index) => index + 1` is a running
|
|
64
|
+
* row number.
|
|
65
|
+
*/
|
|
66
|
+
render?: (row: Row, index: number) => React.ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* What a download writes for this cell.
|
|
69
|
+
*
|
|
70
|
+
* Defaults to `value`, and then to `row[key]`. It is separate from `render` on
|
|
71
|
+
* purpose: a cell that draws a chip, an avatar or a progress bar has no text
|
|
72
|
+
* to put in a file, and `render`'s return is a React element rather than
|
|
73
|
+
* something a spreadsheet can hold.
|
|
74
|
+
*/
|
|
75
|
+
exportValue?: (row: Row) => unknown;
|
|
76
|
+
/** Leaves this column out of a download. @default true */
|
|
77
|
+
exportable?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface MPDataTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children' | 'onSelect'> {
|
|
80
|
+
/** The columns, in the order they appear. */
|
|
81
|
+
headers: readonly MPDataTableColumn<Row>[];
|
|
82
|
+
/** The rows. */
|
|
83
|
+
items: readonly Row[];
|
|
84
|
+
/**
|
|
85
|
+
* A stable identity per row, and the value `selected` is a list of.
|
|
86
|
+
*
|
|
87
|
+
* Defaults to the row's index in `items`, which is enough for a table that
|
|
88
|
+
* only ever displays. The moment rows can be chosen, sorted or searched it is
|
|
89
|
+
* required in practice: an index identifies a position, and every one of those
|
|
90
|
+
* three changes which row is in it.
|
|
91
|
+
*/
|
|
92
|
+
getRowKey?: (row: Row, index: number) => React.Key;
|
|
93
|
+
/** Shown above the table, and read out as its accessible name. */
|
|
94
|
+
caption?: React.ReactNode;
|
|
95
|
+
/** What to show instead of rows when nothing is left. */
|
|
96
|
+
empty?: React.ReactNode;
|
|
97
|
+
/**
|
|
98
|
+
* Which language the table's own words are in — the ticks' names, the count
|
|
99
|
+
* under the rows, the download button.
|
|
100
|
+
*
|
|
101
|
+
* It is also what the default sort compares strings with. Pass it whenever the
|
|
102
|
+
* markup is rendered on a server: without it the comparison follows the
|
|
103
|
+
* runtime's own locale, and a server that disagrees with the browser about
|
|
104
|
+
* that produces two different row orders for the same table.
|
|
105
|
+
*/
|
|
106
|
+
locale?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Makes every column sortable. A column overrides it either way with its own
|
|
109
|
+
* `sortable`.
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
sortable?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether more than one column can be sorted at a time. With `multiple`, a
|
|
115
|
+
* Shift-press adds a column to the sort instead of replacing it, and each
|
|
116
|
+
* sorted heading carries its place in the order.
|
|
117
|
+
* @default 'single'
|
|
118
|
+
*/
|
|
119
|
+
sortMode?: 'single' | 'multiple';
|
|
120
|
+
/** The sort. Use with `onSortChange` for a controlled one. */
|
|
121
|
+
sort?: readonly MPDataTableSort[];
|
|
122
|
+
/** What it starts as, for an uncontrolled table. */
|
|
123
|
+
defaultSort?: readonly MPDataTableSort[];
|
|
124
|
+
onSortChange?: (sort: MPDataTableSort[]) => void;
|
|
125
|
+
/** Draws a field above the table that filters the rows. @default false */
|
|
126
|
+
searchable?: boolean;
|
|
127
|
+
/** The query. Use with `onSearchChange` for a controlled field. */
|
|
128
|
+
search?: string;
|
|
129
|
+
/** What it starts as, for an uncontrolled one. */
|
|
130
|
+
defaultSearch?: string;
|
|
131
|
+
onSearchChange?: (search: string) => void;
|
|
132
|
+
/**
|
|
133
|
+
* Overrides the word on the field, which is also its accessible name.
|
|
134
|
+
*
|
|
135
|
+
* It is a label rather than a placeholder because a placeholder is not a name:
|
|
136
|
+
* a field whose only word disappears the moment somebody types in it is a
|
|
137
|
+
* field a screen reader announces as nothing.
|
|
138
|
+
*/
|
|
139
|
+
searchLabel?: string;
|
|
140
|
+
/**
|
|
141
|
+
* A filter of your own, applied after the search. Return `false` to drop a
|
|
142
|
+
* row. `index` is the row's place in `items`.
|
|
143
|
+
*/
|
|
144
|
+
filter?: (row: Row, index: number) => boolean;
|
|
145
|
+
/** Content at the end of the bar the search field sits in. */
|
|
146
|
+
toolbar?: React.ReactNode;
|
|
147
|
+
/**
|
|
148
|
+
* Hands the rows out a page at a time, and puts the pages in the footer.
|
|
149
|
+
*
|
|
150
|
+
* Every row is rendered otherwise, and there is no windowing — the same
|
|
151
|
+
* ceiling `MPTable` states, and this is the answer to it. A few hundred rows
|
|
152
|
+
* is nothing, a few thousand is a visible pause, and past that a table wants
|
|
153
|
+
* either this or a narrower list.
|
|
154
|
+
* @default false
|
|
155
|
+
*/
|
|
156
|
+
paged?: boolean;
|
|
157
|
+
/** The current page, 1-based. Use with `onPageChange`. */
|
|
158
|
+
page?: number;
|
|
159
|
+
/** @default 1 */
|
|
160
|
+
defaultPage?: number;
|
|
161
|
+
onPageChange?: (page: number) => void;
|
|
162
|
+
/** How many rows a page holds. Use with `onPageSizeChange`. */
|
|
163
|
+
pageSize?: number;
|
|
164
|
+
/** @default 25 */
|
|
165
|
+
defaultPageSize?: number;
|
|
166
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
167
|
+
/**
|
|
168
|
+
* What the footer's page-size control offers. An empty list drops the control.
|
|
169
|
+
* @default [10, 25, 50, 100]
|
|
170
|
+
*/
|
|
171
|
+
pageSizeOptions?: readonly number[];
|
|
172
|
+
/**
|
|
173
|
+
* Lets a heading be dragged wider or narrower, and gives the handle between
|
|
174
|
+
* two columns to the keyboard as well.
|
|
175
|
+
*
|
|
176
|
+
* **It also changes how the columns are laid out, and it has to.** Without it
|
|
177
|
+
* the browser balances the columns against their contents, which is what makes
|
|
178
|
+
* a plain table read well; but a balanced column springs back from a drag,
|
|
179
|
+
* because a width in that layout is a hint rather than a measurement. Turning
|
|
180
|
+
* this on fixes the layout, so `width` becomes exact and a column that has not
|
|
181
|
+
* said how wide it is takes 160.
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
resizable?: boolean;
|
|
185
|
+
/** The widths, keyed by column. Use with `onColumnWidthsChange`. */
|
|
186
|
+
columnWidths?: Readonly<Record<string, number>>;
|
|
187
|
+
/** What they start as, for an uncontrolled table. */
|
|
188
|
+
defaultColumnWidths?: Readonly<Record<string, number>>;
|
|
189
|
+
onColumnWidthsChange?: (widths: Record<string, number>) => void;
|
|
190
|
+
/**
|
|
191
|
+
* How many rows may be chosen.
|
|
192
|
+
* @default 'none'
|
|
193
|
+
*/
|
|
194
|
+
selectionMode?: MPDataTableSelectionMode;
|
|
195
|
+
/** The chosen rows, as their keys. Use with `onSelectedChange`. */
|
|
196
|
+
selected?: readonly React.Key[];
|
|
197
|
+
/** Which start chosen, for an uncontrolled table. */
|
|
198
|
+
defaultSelected?: readonly React.Key[];
|
|
199
|
+
/**
|
|
200
|
+
* The keys, and the rows behind them — including rows the search has hidden
|
|
201
|
+
* and rows on other pages, which are still chosen and still have to be handed
|
|
202
|
+
* back.
|
|
203
|
+
*/
|
|
204
|
+
onSelectedChange?: (selected: React.Key[], rows: Row[]) => void;
|
|
205
|
+
/**
|
|
206
|
+
* Adds a column of ticks, and one in the heading that takes the whole page at
|
|
207
|
+
* once.
|
|
208
|
+
*
|
|
209
|
+
* It also decides which of the row and the tick is the keyboard's route into
|
|
210
|
+
* the row — see the note on the component.
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
checkboxes?: boolean;
|
|
214
|
+
/** Fires on every press of a row, before the selection changes. */
|
|
215
|
+
onRowClick?: (row: Row, index: number) => void;
|
|
216
|
+
/**
|
|
217
|
+
* Adds a button that writes the rows out as a CSV file.
|
|
218
|
+
*
|
|
219
|
+
* **Every row the reader is currently looking at, not the page they are on.**
|
|
220
|
+
* The search and the sort are applied and the paging is not, because a file of
|
|
221
|
+
* page three is not a file anybody asked for.
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
exportable?: boolean;
|
|
225
|
+
/** What the downloaded file is called. @default 'table.csv' */
|
|
226
|
+
exportFileName?: string;
|
|
227
|
+
/**
|
|
228
|
+
* Puts an apostrophe in front of a cell a spreadsheet would otherwise run as a
|
|
229
|
+
* formula — one beginning `=`, `+`, `-` or `@`.
|
|
230
|
+
*
|
|
231
|
+
* On by default. A data table shows rows other people filled in, and the file
|
|
232
|
+
* it writes is going to be opened in a spreadsheet: those two together are
|
|
233
|
+
* what turn a cell reading `=HYPERLINK("https://…"&A1)` into one click that
|
|
234
|
+
* posts the row beside it to somebody else's server. It is the reader's own
|
|
235
|
+
* spreadsheet that runs it, so the file is the only place to stop it.
|
|
236
|
+
*
|
|
237
|
+
* A number keeps its sign: `-5` and `+82 2 555 0100` are not formulas and are
|
|
238
|
+
* left alone.
|
|
239
|
+
*
|
|
240
|
+
* Turn it off for a file going to a parser rather than to a person — a
|
|
241
|
+
* database loader has no apostrophe rule and would take it as part of the
|
|
242
|
+
* value.
|
|
243
|
+
* @default true
|
|
244
|
+
*/
|
|
245
|
+
exportEscapeFormulas?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Takes the CSV instead of downloading it — to post it somewhere, to open it
|
|
248
|
+
* in a viewer of your own, or to put a sheet around it.
|
|
249
|
+
*/
|
|
250
|
+
onExport?: (csv: string) => void;
|
|
251
|
+
/** Tints every other row. @default false */
|
|
252
|
+
striped?: boolean;
|
|
253
|
+
/** Lights the row under the pointer. @default false */
|
|
254
|
+
hoverable?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Pins the heading while the body scrolls. Only does anything if something
|
|
257
|
+
* around the table actually constrains its height.
|
|
258
|
+
* @default false
|
|
259
|
+
*/
|
|
260
|
+
stickyHeader?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* How much surface the sheet around the table paints.
|
|
263
|
+
* @default 'outlined'
|
|
264
|
+
*/
|
|
265
|
+
variant?: MPVariant;
|
|
266
|
+
/** How far off the page the sheet is lifted, on MD3's own scale. */
|
|
267
|
+
elevation?: MPElevation;
|
|
268
|
+
/** @default 'md' */
|
|
269
|
+
size?: MPSize;
|
|
270
|
+
/**
|
|
271
|
+
* Which accent family the sort arrow, the ticks and a chosen row read. The
|
|
272
|
+
* cells themselves stay neutral.
|
|
273
|
+
* @default 'primary'
|
|
274
|
+
*/
|
|
275
|
+
color?: MPColor;
|
|
276
|
+
/** Takes room out of every cell without changing what it is set in. @default 0 */
|
|
277
|
+
density?: MPDensity;
|
|
278
|
+
classNames?: MPSlots<MPDataTableSlot>;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* A grid of data with the four things a reader does to one: put it in order,
|
|
282
|
+
* cut it down, step through it and take some of it away.
|
|
283
|
+
*
|
|
284
|
+
* ```tsx
|
|
285
|
+
* <MPDataTable headers={columns} items={rows} sortable searchable paged />
|
|
286
|
+
* ```
|
|
287
|
+
*
|
|
288
|
+
* It is a separate component from [MPTable](table) rather than a mode of it.
|
|
289
|
+
* `MPTable` is the presentational half: it
|
|
290
|
+
* draws what it is given, in the order it is given, and a page that only shows a
|
|
291
|
+
* grid should not carry a comparator, a CSV writer and a page clamp to do it.
|
|
292
|
+
* What the two do share is the geometry — `internal/table.ts` holds the cells'
|
|
293
|
+
* room and the type they are set in — so a data table never sits a pixel off the
|
|
294
|
+
* plain table beside it.
|
|
295
|
+
*
|
|
296
|
+
* ## What it does to the rows, and in what order
|
|
297
|
+
*
|
|
298
|
+
* Search, then `filter`, then sort, then the page. The order is the only one
|
|
299
|
+
* that makes each step mean what it says: sorting before searching would order
|
|
300
|
+
* rows nobody is going to see, and paging before either would cut a page out of
|
|
301
|
+
* a list the reader has not asked for yet. `render`'s `index` counts along the
|
|
302
|
+
* sorted, searched order across every page, so it is a running row number rather
|
|
303
|
+
* than a position on the screen.
|
|
304
|
+
*
|
|
305
|
+
* ## Who holds the keyboard
|
|
306
|
+
*
|
|
307
|
+
* A row that answers a press has to answer a keyboard, and a table of two
|
|
308
|
+
* hundred rows that each did would be two hundred tab stops. So there is exactly
|
|
309
|
+
* one route into a row and `checkboxes` is what picks it: with ticks, the tick
|
|
310
|
+
* is the control and the row is not in the tab order; without them, the row is.
|
|
311
|
+
* `onRowClick` on its own always puts the row in the tab order, because then
|
|
312
|
+
* there is nothing else to press.
|
|
313
|
+
*/
|
|
314
|
+
export declare function MPDataTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, sortable, sortMode, sort: sortProp, defaultSort, onSortChange, searchable, search: searchProp, defaultSearch, onSearchChange, searchLabel, filter, toolbar, paged, page: pageProp, defaultPage, onPageChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, resizable, columnWidths: columnWidthsProp, defaultColumnWidths, onColumnWidthsChange, selectionMode, selected: selectedProp, defaultSelected, onSelectedChange, checkboxes, onRowClick, exportable, exportFileName, exportEscapeFormulas, onExport, striped, hoverable, stickyHeader, variant, elevation, size: sizeProp, color: colorProp, density: densityProp, className, style, classNames, ...props }: MPDataTableProps<Row>): React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{MPButton as r}from"../button/MPButton.js";import{MPCheckbox as n}from"../checkbox/MPCheckbox.js";import{MPIcon as o}from"../icon/MPIcon.js";import{MPPagination as l}from"../pagination/MPPagination.js";import{MPSelect as s}from"../select/MPSelect.js";import{MPTextField as i}from"../text-field/MPTextField.js";import{ArrowDownIcon as c,ArrowUpIcon as d,SearchIcon as m}from"../../constants/icons.js";import{accentSlots as u}from"../../internal/accent.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as f,useMPDensity as h,useMPSize as y}from"../../internal/config.js";import{useMPLocale as g,useMPMessages as b}from"../../internal/locale.js";import{fillMessage as v}from"../../internal/i18n.js";import{DATA_TABLE as x}from"../../internal/messages/data-table.js";import{TABLE as k}from"../../internal/messages/table.js";import{TRANSFER as w}from"../../internal/messages/transfer.js";import{CONTROL_ICON as S,META_TEXT as N}from"../../internal/scale.js";import{VISUALLY_HIDDEN as j}from"../../internal/visually-hidden.js";import{CELL_TEXT as C,HEAD_TEXT as z,ROW as _,cellPadX as M,cellPadY as P,drawableCell as E}from"../../internal/table.js";import{DEFAULT_COLUMN_WIDTH as L,MIN_COLUMN_WIDTH as D,compareValues as $,downloadText as A,keysBetween as I,nextSort as K,pageBounds as W,searchHaystack as R,searchText as T,sortRows as B,toCsv as F}from"../../internal/data-table.js";function V(e,t){return e.value?e.value(t):t[e.key]}const H={xs:36,sm:40,md:48,lg:52,xl:60},X=/*@__PURE__*/["group/sort -m-1 flex w-full cursor-pointer items-center gap-1 rounded-mp-xs p-1","appearance-none border-0 bg-transparent text-inherit text-start [font:inherit]","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","hover:text-mp-on-surface","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),O=/*@__PURE__*/["mp-data-table__resize absolute inset-y-0 end-0 z-10 w-2 translate-x-1/2 rtl:-translate-x-1/2","cursor-col-resize touch-none select-none appearance-none border-0 bg-transparent p-0","after:absolute after:inset-y-1 after:start-1/2 after:w-px after:bg-transparent","after:transition-[background-color] after:duration-(--mp-sys-motion-duration-short4)","hover:after:bg-mp-primary data-dragging:after:bg-mp-primary","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-solid outline-none"].join(" ");export function MPDataTable({headers:q,items:G,getRowKey:J,caption:Q,empty:U,locale:Y,sortable:Z=!1,sortMode:ee="single",sort:te,defaultSort:ae,onSortChange:re,searchable:ne=!1,search:oe,defaultSearch:le,onSearchChange:se,searchLabel:ie,filter:ce,toolbar:de,paged:me=!1,page:ue,defaultPage:pe,onPageChange:fe,pageSize:he,defaultPageSize:ye,onPageSizeChange:ge,pageSizeOptions:be=[10,25,50,100],resizable:ve=!1,columnWidths:xe,defaultColumnWidths:ke,onColumnWidthsChange:we,selectionMode:Se="none",selected:Ne,defaultSelected:je,onSelectedChange:Ce,checkboxes:ze=!1,onRowClick:_e,exportable:Me=!1,exportFileName:Pe="table.csv",exportEscapeFormulas:Ee=!0,onExport:Le,striped:De=!1,hoverable:$e=!1,stickyHeader:Ae=!1,variant:Ie="outlined",elevation:Ke,size:We,color:Re,density:Te,className:Be,style:Fe,classNames:Ve,...He}){const Xe=y(We),Oe=f(Re),qe=h(Te),Ge=g(Y),Je=b(x,Ge),Qe=b(k,Ge),Ue=b(w,Ge),Ye=M(Xe,qe),Ze=P(Xe,qe),[et,tt]=a.useState(()=>[...ae??[]]),at=te??et,[rt,nt]=a.useState(le??""),ot=oe??rt,[lt,st]=a.useState(pe??1),it=ue??lt,[ct,dt]=a.useState(ye??25),mt=he??ct,[ut,pt]=a.useState(()=>({...ke})),ft=xe??ut,[ht,yt]=a.useState(()=>[...je??[]]),gt=Ne??ht,bt=a.useMemo(()=>new Set(gt.map(e=>String(e))),[gt]),vt=a.useRef(null),xt=a.useMemo(()=>G.map((e,t)=>{const a=J?J(e,t):t;return{row:e,identity:a,key:String(a),origin:t}}),[G,J]),kt=a.useMemo(()=>{const e=q.filter(e=>!1!==e.searchable);return xt.map(t=>R(e.map(e=>V(e,t.row))))},[xt,q]),wt=T(ot.trim()),St=a.useMemo(()=>{const e=""===wt?xt:xt.filter((e,t)=>kt[t].includes(wt));return ce?e.filter(e=>ce(e.row,e.origin)):e},[xt,kt,wt,ce]),Nt=a.useMemo(()=>new Intl.Collator(Ge,{numeric:!0,sensitivity:"base"}),[Ge]),jt=a.useMemo(()=>B(St,at,(e,t)=>{const a=q.find(t=>t.key===e);if(!a)return null;const r="desc"===t,n=a.compare;return n?(e,t)=>r?-n(e.row,t.row):n(e.row,t.row):(e,t)=>$(V(a,e.row),V(a,t.row),Nt,r)}),[St,at,q,Nt]),Ct=W(jt.length,it,mt),zt=me?jt.slice(Ct.start,Ct.end):jt,_t=e=>{void 0===ue&&st(e),fe?.(e)},Mt=e=>{void 0===xe&&pt(e),we?.(e)},Pt=e=>{const t=new Set(e),a=[],r=[];for(const e of xt)t.has(e.key)&&(r.push(e.identity),a.push(e.row));void 0===Ne&&yt(r),Ce?.(r,a)},Et="none"!==Se,Lt="multiple"===Se,Dt=ze&&Et,$t=(e,t,a)=>{if(_e?.(e.row,Ct.start+t),Et){if(!Lt)return Pt(bt.has(e.key)?[]:[e.key]),void(vt.current=e.key);if(a&&null!==vt.current){const t=I(zt.map(e=>e.key),vt.current,e.key);return void Pt([...new Set([...bt,...t])])}vt.current=e.key,Pt(bt.has(e.key)?[...bt].filter(t=>t!==e.key):[...bt,e.key])}},At=zt.map(e=>e.key),It=At.filter(e=>bt.has(e)).length,Kt=At.length>0&&It===At.length,Wt=e=>ft[e.key]??e.width??L,Rt=a.useRef(null);a.useEffect(()=>()=>{null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)},[]);const Tt=(e,t)=>{const a=Math.max(D,e.minWidth??D);Mt({...ft,[e.key]:Math.max(a,Wt(e)+t)})},Bt=e=>{const t={...ft};delete t[e.key],Mt(t)},Ft={padding:`${Ze} ${Ye}`},Vt={...Ft,backgroundColor:"var(--_mp-color-surface-container)"},Ht={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"},Xt=q.length+(Dt?1:0),Ot=Boolean(_e)||Et&&!Dt,qt=$e||Et||Boolean(_e),Gt=ne||Me||void 0!==de,Jt=me||Et,Qt=(...e)=>e.filter(Boolean).join(" ");return t("div",{"data-mp-size":Xe,"data-mp-variant":Ie,className:Qt("mp-data-table rounded-mp-md flex flex-col",p(Ie,Ke),Be),style:{...u(Oe),...Fe},...He,children:[Gt?t("div",{className:Qt("mp-data-table__toolbar flex flex-wrap items-center gap-2",Ve?.toolbar),style:{padding:`${Ze} ${Ye}`},children:[ne?e(i,{size:Xe,value:ot,onChange:e=>{void 0===oe&&nt(e),_t(1),se?.(e)},label:ie??Ue.search,startIcon:e(o,{icon:m,size:S[Xe]}),className:"mp-data-table__search min-w-0 flex-1"}):e("div",{className:"min-w-0 flex-1"}),de,Me?e(r,{size:Xe,variant:"text",color:Oe,onClick:()=>{const e=q.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),a=jt.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):V(e,t.row))),r=F([t,...a],{escapeFormulas:Ee});Le?Le(r):A(r,Pe,"text/csv;charset=utf-8")},startIcon:e(o,{icon:c,size:S[Xe]}),children:Je.download}):null]}):null,e("div",{className:"mp-data-table__scroll min-h-0 flex-1 overflow-auto",children:t("table",{className:Qt("text-mp-on-surface w-full text-start",C[Xe],Ve?.table),style:{borderCollapse:"collapse",...ve?{tableLayout:"fixed",minWidth:q.reduce((e,t)=>e+Wt(t),Dt?H[Xe]:0)}:void 0},children:[Q?e("caption",{className:`text-mp-on-surface-variant ${N}`,style:{...Ft,textAlign:"start"},children:Q}):null,t("colgroup",{children:[Dt?e("col",{style:{width:H[Xe]}}):null,q.map(t=>e("col",{style:ve||void 0!==ft[t.key]||void 0!==t.width?{width:Wt(t)}:void 0},t.key))]}),e("thead",{className:Ve?.head,children:t("tr",{children:[Dt?e("th",{scope:"col",className:Qt("whitespace-nowrap",Ae&&"sticky top-0 z-20"),style:Vt,children:e(n,{size:Xe,color:Oe,checked:Kt,indeterminate:It>0&&!Kt,onCheckedChange:()=>{Pt(Kt?[...bt].filter(e=>!At.includes(e)):[...new Set([...bt,...At])])},label:e("span",{className:j,children:Je.selectAll}),disabled:!Lt||0===At.length})}):null,q.map(a=>{const r=a.sortable??Z,n=(l=a.key,at.findIndex(e=>e.key===l));var l;const s=-1===n?void 0:at[n],i=a.resizable??ve,c=a.align??"start";return t("th",{scope:"col","aria-sort":r?void 0===s?"none":"asc"===s.direction?"ascending":"descending":void 0,className:Qt("text-mp-on-surface-variant relative whitespace-nowrap",z[Xe],Ae&&"sticky top-0 z-10"),style:{...Vt,textAlign:c},children:[r?t("button",{type:"button",className:Qt(X,"end"===c&&"justify-end","center"===c&&"justify-center"),onClick:e=>((e,t)=>{const a=K(at,e,t&&"multiple"===ee);void 0===te&&tt(a),re?.(a)})(a.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:a.label??a.key}),e(o,{icon:d,size:S[Xe]-6,className:Qt("shrink-0 transition-[rotate,opacity]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",void 0===s?"opacity-0 group-hover/sort:opacity-38":"text-mp-primary opacity-100","desc"===s?.direction&&"rotate-180")}),at.length>1&&-1!==n?e("span",{className:"text-mp-primary shrink-0 tabular-nums",children:n+1}):null]}):a.label??a.key,i?e("button",{type:"button","aria-label":Je.resize,className:O,onPointerDown:e=>((e,t)=>{const a=t.currentTarget;try{a.setPointerCapture(t.pointerId)}catch{}a.dataset.dragging="true";const r=document.body.style.userSelect;Rt.current=r,document.body.style.userSelect="none";const n=t.clientX,o=Wt(e),l="rtl"===getComputedStyle(a).direction?-1:1,s=Math.max(D,e.minWidth??D),i=t=>{Mt({...ft,[e.key]:Math.max(s,Math.round(o+(t.clientX-n)*l))})},c=()=>{a.removeEventListener("pointermove",i),a.removeEventListener("pointerup",c),a.removeEventListener("pointercancel",c),delete a.dataset.dragging,null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)};a.addEventListener("pointermove",i),a.addEventListener("pointerup",c),a.addEventListener("pointercancel",c)})(a,e),onDoubleClick:()=>Bt(a),onKeyDown:e=>{const t=e.shiftKey?32:8;"ArrowRight"===e.key?(e.preventDefault(),Tt(a,t)):"ArrowLeft"===e.key?(e.preventDefault(),Tt(a,-t)):"Home"===e.key&&(e.preventDefault(),Bt(a))}}):null]},a.key)})]})}),e("tbody",{children:0===zt.length?e("tr",{className:_,style:Ht,children:e("td",{colSpan:Xt,className:"text-mp-on-surface-variant",style:{padding:`2rem ${Ye}`,textAlign:"center"},children:U??Qe.empty})}):zt.map((a,r)=>{const o=bt.has(a.key);return t("tr",{"aria-selected":Et?o:void 0,className:Qt(_,Ve?.row,De&&(Ct.start+r)%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",o?"[--_mp-row:var(--_mp-color-secondary-container)]":"",qt&&!o?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",(Et||_e)&&"cursor-pointer",Ot&&["outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" ")),style:Ht,tabIndex:Ot?0:void 0,onClick:e=>$t(a,r,e.shiftKey),onKeyDown:Ot?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),$t(a,r,e.shiftKey))}:void 0,children:[Dt?e("td",{style:Ft,children:e(n,{size:Xe,color:Oe,checked:o,onCheckedChange:()=>$t(a,r,!1),label:e("span",{className:j,children:Je.selectRow})})}):null,q.map(t=>e("td",{className:Ve?.cell,style:{...Ft,textAlign:t.align??"start"},children:t.render?t.render(a.row,Ct.start+r):E(V(t,a.row))},t.key))]},a.key)})})]})}),Jt?t("div",{className:Qt("mp-data-table__footer border-mp-outline-variant flex flex-wrap items-center gap-3","text-mp-on-surface-variant border-t",N,Ve?.footer),style:{padding:`${Ze} ${Ye}`},children:[e("span",{className:"mp-data-table__count",children:v(Je.total,{total:String(jt.length)})}),bt.size>0?e("span",{className:"mp-data-table__selected text-mp-primary",children:v(Je.selected,{count:String(bt.size)})}):null,e("span",{className:"flex-1"}),me&&be.length>0?e(s,{size:"xs",label:Je.perPage,floatingLabel:!1,value:mt,onValueChange:e=>(e=>{void 0===he&&dt(e),_t(1),ge?.(e)})(Number(e)),items:be.map(e=>({value:e})),className:"mp-data-table__page-size",style:{minWidth:"9.5rem"}}):null,me?e(l,{size:"xs",color:Oe,count:Ct.pages,page:Ct.page,onPageChange:_t,locale:Ge}):null]}):null]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPDataTable}from"./MPDataTable.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as o from"react";import{MPButton as t}from"../button/MPButton.js";import{MPIcon as n}from"../icon/MPIcon.js";import{CalendarIcon as l}from"../../constants/icons.js";import{Calendar as r}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as s,MPPickerShell as c,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as u}from"../../internal/locale.js";import{PICKER as p}from"../../internal/messages/picker.js";import{CONTROL_ICON as f}from"../../internal/scale.js";import{formatDate as h,isUnitOutside as y,
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as o from"react";import{MPButton as t}from"../button/MPButton.js";import{MPIcon as n}from"../icon/MPIcon.js";import{CalendarIcon as l}from"../../constants/icons.js";import{Calendar as r}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as s,MPPickerShell as c,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as u}from"../../internal/locale.js";import{PICKER as p}from"../../internal/messages/picker.js";import{CONTROL_ICON as f}from"../../internal/scale.js";import{formatDate as h,isUnitOutside as y,TO_ISO as j,isValidDate as b,localeWeekStart as g,mergeDateAndTime as v,startOfMonth as x,startOfUnit as D,today as k,withPlaceholder as C}from"../../internal/date.js";import{useMPColor as O,useMPSize as S}from"../../internal/config.js";const z={day:{dateStyle:"medium"},month:{year:"numeric",month:"long"},year:{year:"numeric"}};export const MPDatePicker=/*@__PURE__*/o.forwardRef(function({value:M,defaultValue:P,onValueChange:w,open:I,defaultOpen:V,onOpenChange:B,precision:R="day",defaultMonth:E,minDate:F,maxDate:N,shouldDisableDate:T,locale:Y,weekStartsOn:q,format:A,placeholder:G,clearable:H=!1,showTodayButton:J=!0,closeOnSelect:K=!0,labels:L,name:Q,size:U,color:W,readOnly:X=!1,disabled:Z=!1,startIcon:$,..._},ee){const ae=S(U),oe=O(W),te=d(Y),ne=u(p,te,L),le=q??g(te),re=A??z[R],[ie,se]=o.useState(P??null),ce=void 0!==M?M:ie,[me,de]=o.useState(V??!1),ue=I??me,[pe,fe]=o.useState(()=>x(b(ce)?ce:E??k()));o.useEffect(()=>{ue&&fe(x(b(ce)?ce:E??k()))},[ue]);const he=e=>{e&&(X||Z)||(void 0===I&&de(e),B?.(e))},ye=e=>{void 0===M&&se(e),w?.(e)},je=e=>{const a=D(e,R),o=b(ce)?v(a,ce):a;ye(o),fe(x(o)),K&&he(!1)},be=k(),ge=y(be,R,F,N)||"day"===R&&(T?.(be)??!1),ve="year"===R?ne.thisYear:"month"===R?ne.thisMonth:ne.today,xe=J||H,De=C(m(te,re),G);return e(c,{..._,slug:"date-picker",size:ae,color:oe,readOnly:X,disabled:Z,triggerRef:ee,startIcon:void 0===$?e(n,{icon:l,size:f[ae]}):$,display:b(ce)?h(ce,te,re):G??"",samples:De,empty:!b(ce),clearable:H,onClear:()=>ye(null),open:ue,onOpenChange:he,labels:ne,hiddenValues:Q?[{name:Q,value:b(ce)?j[R](ce):""}]:void 0,children:a("div",{className:"flex flex-col "+(xe?"gap-1.5":""),children:[e(r,{size:ae,color:oe,locale:te,weekStartsOn:le,month:pe,onMonthChange:fe,selected:[ce],onSelect:je,minDate:F,maxDate:N,shouldDisableDate:T,precision:R,labels:ne,autoFocus:!0}),xe?a(s,{children:[H?e(t,{variant:"text",size:i[ae],color:oe,onClick:()=>{ye(null),he(!1)},children:ne.clear}):null,J?e(t,{variant:"text",size:i[ae],color:oe,disabled:ge,onClick:()=>je(be),children:ve}):null]}):null]})})});
|