material-plus-ui 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/a2ui/extended/api.d.ts +4 -4
- package/dist/components/accordion/MPAccordion.d.ts +13 -0
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +8 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/animate-scramble/MPAnimateScramble.d.ts +8 -0
- package/dist/components/animate-scramble/MPAnimateScramble.js +1 -1
- package/dist/components/animate-split/MPAnimateSplit.d.ts +8 -0
- package/dist/components/animate-split/MPAnimateSplit.js +1 -1
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +10 -2
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -1
- package/dist/components/app-logo/MPAppLogo.d.ts +6 -1
- package/dist/components/area-chart/MPAreaChart.js +1 -1
- package/dist/components/avatar/MPAvatar.d.ts +16 -0
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/badge/MPBadge.d.ts +7 -6
- package/dist/components/bar-chart/MPBarChart.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +8 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.d.ts +5 -3
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +1 -1
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/code-block/MPCodeBlock.js +1 -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 +3 -2
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +3 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +17 -1
- package/dist/components/config/MPConfigProvider.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/data-table/MPDataTable.d.ts +3 -36
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +3 -2
- package/dist/components/drawer/MPDrawer.d.ts +13 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.d.ts +3 -1
- package/dist/components/floating-bottom-navigation/MPFloatingBottomNavigation.d.ts +10 -1
- package/dist/components/floating-bottom-navigation/MPFloatingBottomNavigation.js +1 -1
- package/dist/components/form/MPForm.d.ts +3 -0
- package/dist/components/form/MPForm.js +1 -1
- package/dist/components/gauge-chart/MPGaugeChart.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
- package/dist/components/hover-card/MPHoverCard.d.ts +8 -7
- package/dist/components/icon-button/MPIconButton.js +1 -1
- package/dist/components/image/MPImage.d.ts +5 -0
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/line-chart/MPLineChart.js +1 -1
- package/dist/components/list/MPList.d.ts +3 -2
- package/dist/components/locale/MPLocaleProvider.d.ts +15 -30
- package/dist/components/locale/MPLocaleProvider.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +9 -1
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/meter/MPMeter.d.ts +5 -0
- package/dist/components/meter/MPMeter.js +1 -1
- package/dist/components/mockup/MPMockup.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +27 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +2 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/page-layout/MPPageLayout.js +1 -1
- package/dist/components/pagination/MPPagination.d.ts +12 -4
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pie-chart/MPPieChart.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.d.ts +4 -3
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +15 -2
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +5 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +8 -6
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/stepper/MPStepper.d.ts +9 -7
- package/dist/components/stepper/MPStepper.js +1 -1
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +7 -3
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +9 -0
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.js +1 -1
- package/dist/components/toolbar/MPToolbar.d.ts +3 -3
- package/dist/components/tooltip/MPTooltip.d.ts +6 -0
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/tree-select/MPTreeSelect.d.ts +12 -2
- package/dist/components/tree-select/MPTreeSelect.js +1 -1
- package/dist/components/tree-view/MPTreeView.d.ts +8 -0
- package/dist/components/tree-view/MPTreeView.js +1 -1
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/mpColorSchemeScript.d.ts +46 -0
- package/dist/hooks/mpColorSchemeScript.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +2 -47
- package/dist/hooks/useMPColorScheme.js +1 -1
- package/dist/hooks/useMPMediaQuery.js +1 -1
- package/dist/hooks/useMPOnScreen.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +11 -2
- package/dist/internal/ChartChrome.js +1 -1
- package/dist/internal/ChartFrame.js +1 -1
- package/dist/internal/FieldOutline.d.ts +20 -2
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/FieldValue.d.ts +35 -0
- package/dist/internal/FieldValue.js +2 -0
- package/dist/internal/Picker.d.ts +24 -5
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/RenderedLink.d.ts +20 -0
- package/dist/internal/RenderedLink.js +2 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +4 -0
- package/dist/internal/animate.js +1 -1
- package/dist/internal/box-size.d.ts +22 -0
- package/dist/internal/box-size.js +2 -0
- package/dist/internal/chart.d.ts +21 -11
- package/dist/internal/chart.js +1 -1
- package/dist/internal/color-scheme-keys.d.ts +13 -0
- package/dist/internal/color-scheme-keys.js +1 -0
- package/dist/internal/color-scheme.d.ts +11 -2
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/config.d.ts +2 -0
- package/dist/internal/date.d.ts +2 -8
- package/dist/internal/date.js +1 -1
- package/dist/internal/fold.d.ts +45 -0
- package/dist/internal/fold.js +2 -0
- package/dist/internal/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +6 -53
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/intersection.d.ts +50 -0
- package/dist/internal/intersection.js +2 -0
- package/dist/internal/intl.d.ts +22 -21
- package/dist/internal/intl.js +1 -1
- package/dist/internal/keys.d.ts +0 -9
- package/dist/internal/keys.js +1 -1
- package/dist/internal/layout-effect.d.ts +7 -0
- package/dist/internal/layout-effect.js +2 -0
- package/dist/internal/locale.d.ts +10 -2
- package/dist/internal/media.d.ts +1 -0
- package/dist/internal/media.js +1 -0
- package/dist/internal/messages/common.js +1 -1
- package/dist/internal/occurrence.d.ts +18 -0
- package/dist/internal/occurrence.js +1 -0
- package/dist/internal/page-layout.js +1 -1
- package/dist/internal/progress.d.ts +5 -0
- package/dist/internal/ref.d.ts +9 -0
- package/dist/internal/ref.js +1 -0
- package/dist/internal/remember.d.ts +36 -0
- package/dist/internal/remember.js +1 -0
- package/dist/internal/surface.d.ts +7 -1
- package/dist/internal/surface.js +1 -1
- package/dist/internal/table.d.ts +4 -4
- package/dist/internal/text.d.ts +10 -4
- package/dist/internal/text.js +1 -1
- package/dist/internal/window-class.d.ts +8 -0
- 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/animate-appear.css +1 -1
- package/dist/styles/animate-blink.css +1 -1
- package/dist/styles/animate-counter.css +1 -1
- package/dist/styles/animate-fade.css +1 -1
- package/dist/styles/animate-float.css +1 -1
- 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 +1 -1
- package/dist/styles/animate-rotate.css +1 -1
- package/dist/styles/animate-scramble.css +1 -1
- package/dist/styles/animate-shake.css +1 -1
- package/dist/styles/animate-slide.css +1 -1
- package/dist/styles/animate-split.css +1 -1
- package/dist/styles/animate-typing.css +1 -1
- package/dist/styles/animate-zoom.css +1 -1
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.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/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- 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/confirm.css +1 -1
- package/dist/styles/data-table.css +1 -1
- 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/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/floating-bottom-navigation.css +1 -1
- package/dist/styles/footer.css +1 -1
- package/dist/styles/gauge-chart.css +1 -1
- package/dist/styles/header.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/hover-card.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/meter.css +1 -1
- 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/pill.css +1 -1
- package/dist/styles/popconfirm.css +1 -1
- package/dist/styles/popover.css +1 -1
- 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/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/stack.css +1 -1
- 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/time-picker.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tour.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/tree-select.css +1 -1
- package/dist/styles/tree-view.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +178 -29
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{Toggle as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{Toggle as a}from"@base-ui/react/toggle";import{ToggleGroup as o}from"@base-ui/react/toggle-group";import{MPIcon as n}from"../icon/MPIcon.js";import{CheckIcon as s}from"../../constants/icons.js";import{MPStateLayer as l}from"../../internal/StateLayer.js";import{useMPSize as i}from"../../internal/config.js";const m={xs:"h-8",sm:"h-9",md:"h-10",lg:"h-12",xl:"h-14"},d={xs:"text-mp-label-large",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"},p={xs:"px-3",sm:"px-3.5",md:"px-4",lg:"px-5",xl:"px-6"},c={xs:"gap-1.5",sm:"gap-1.5",md:"gap-2",lg:"gap-2",xl:"gap-2"},u={xs:16,sm:18,md:18,lg:20,xl:20};export const MPSegmentedButton=/*@__PURE__*/r.forwardRef(function({items:r,value:f,defaultValue:x,onValueChange:b,multiple:g=!1,showCheck:h=!0,size:y,fullWidth:j=!1,disabled:v=!1,"aria-label":w,className:N,style:B},V){const k=i(y);return e(o,{ref:V,"aria-label":w,value:f,defaultValue:x,onValueChange:e=>b?.(e),multiple:g,disabled:v,"data-mp-size":k,className:["mp-segmented-button rounded-mp-full box-border items-center align-middle","overflow-hidden border",v?"border-mp-on-surface/12":"border-mp-outline",j?"flex w-full":"inline-flex w-fit",m[k],N??""].filter(Boolean).join(" "),style:B,children:r.map((r,o)=>{const i=v||r.disabled;return t(a,{value:r.value,disabled:r.disabled,className:["mp-segmented-button__segment group relative flex h-full items-center","box-border justify-center bg-transparent font-[inherit] whitespace-nowrap","select-none","appearance-none overflow-hidden outline-none","transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",d[k],c[k],p[k],0===o?"border-0":"border-y-0 border-e-0 border-s",i?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":["border-mp-outline cursor-pointer","text-mp-on-surface","data-pressed:bg-mp-secondary-container","data-pressed:text-mp-on-secondary-container"].join(" "),j?"flex-1":""].filter(Boolean).join(" "),children:[i?null:e(l,{}),h||r.icon?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:u[k],height:u[k]},children:[h?e("span",{className:["absolute inset-0 flex items-center justify-center opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard group-data-pressed:opacity-100"].join(" "),children:e(n,{icon:s,size:u[k]})}):null,r.icon?e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",h?"group-data-pressed:opacity-0":""].filter(Boolean).join(" "),children:r.icon}):null]}):null,e("span",{className:"truncate",children:r.label})]},`${o}:${r.value}`)})})});
|
|
@@ -55,6 +55,17 @@ export interface MPSidebarProps extends Omit<React.ComponentPropsWithoutRef<'asi
|
|
|
55
55
|
* to bring it back would be a sidebar the reader has lost.
|
|
56
56
|
*/
|
|
57
57
|
collapseBelow?: MPPageCollapse;
|
|
58
|
+
/**
|
|
59
|
+
* Keeps the sidebar's contents in the document while it is a closed drawer,
|
|
60
|
+
* hidden, rather than taking them out.
|
|
61
|
+
*
|
|
62
|
+
* Collapsed, a sidebar is a modal drawer, and a closed one is not on the page
|
|
63
|
+
* at all — so below `collapseBelow` its links vanished from the page a
|
|
64
|
+
* crawler renders at a phone's width. Turn it on for a sidebar that is the
|
|
65
|
+
* site's navigation. See `MPDrawer`'s own `keepMounted`.
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
keepMounted?: boolean;
|
|
58
69
|
/**
|
|
59
70
|
* Whether the drawer is open. Only meaningful once the sidebar has collapsed;
|
|
60
71
|
* a column is not opened, it is there.
|
|
@@ -90,8 +101,10 @@ export interface MPSidebarProps extends Omit<React.ComponentPropsWithoutRef<'asi
|
|
|
90
101
|
*/
|
|
91
102
|
title?: React.ReactNode;
|
|
92
103
|
/**
|
|
93
|
-
* How much surface the column paints, on the
|
|
94
|
-
*
|
|
104
|
+
* How much surface the column paints, on the ladder `MPHeader` and `MPFooter`
|
|
105
|
+
* use: the container one, except that `elevated` lifts to a level-2 shadow and
|
|
106
|
+
* `outlined` keeps the page's surface. A sidebar is never dyed, because what
|
|
107
|
+
* sits on it arrives with colours of its own.
|
|
95
108
|
*
|
|
96
109
|
* `outlined` is the default: the page's own surface, with a hairline down the
|
|
97
110
|
* edge that faces the content. That is the column *in the layout*. Once it has
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{MPDrawer as n}from"../drawer/MPDrawer.js";import{pixelsIn as o}from"../../internal/length.js";import{useMPLocale as i,useMPMessages as a}from"../../internal/locale.js";import{LAYOUT as s}from"../../internal/messages/layout.js";import{barSurface as l,drawerSide as d,EXPANDED_ONLY as u,MPPageLayoutContext as c,MPSidebarSideContext as m,useMPCollapsed as p}from"../../internal/page-layout.js";import{sheetPadX as f,sheetPadY as v}from"../../internal/density.js";import{useMPDensity as b,useMPSize as y}from"../../internal/config.js";const h={xs:"15rem",sm:"18rem",md:"22.5rem",lg:"26rem",xl:"30rem"};function g(e,t){return null==e?t:"number"==typeof e?e:o(e,"undefined"==typeof window?void 0:window.innerWidth)??t}export const MPSidebar=/*@__PURE__*/r.forwardRef(function({side:o,width:w,minWidth:x=160,maxWidth:j=480,resizable:_=!1,onResize:
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{MPDrawer as n}from"../drawer/MPDrawer.js";import{pixelsIn as o}from"../../internal/length.js";import{useMPLocale as i,useMPMessages as a}from"../../internal/locale.js";import{LAYOUT as s}from"../../internal/messages/layout.js";import{barSurface as l,drawerSide as d,EXPANDED_ONLY as u,MPPageLayoutContext as c,MPSidebarSideContext as m,useMPCollapsed as p}from"../../internal/page-layout.js";import{sheetPadX as f,sheetPadY as v}from"../../internal/density.js";import{useMPDensity as b,useMPSize as y}from"../../internal/config.js";const h={xs:"15rem",sm:"18rem",md:"22.5rem",lg:"26rem",xl:"30rem"};function g(e,t){return null==e?t:"number"==typeof e?e:o(e,"undefined"==typeof window?void 0:window.innerWidth)??t}export const MPSidebar=/*@__PURE__*/r.forwardRef(function({side:o,width:w,minWidth:x=160,maxWidth:j=480,resizable:_=!1,onResize:k,onResizeEnd:R,collapseBelow:C,keepMounted:M=!1,open:z,defaultOpen:P=!1,onOpenChange:E,sticky:L=!0,title:B,variant:S="outlined",elevation:N,size:A,density:D,padded:O=!0,label:$,locale:I,className:W,style:T,children:X,...K},V){const q=y(A),F=b(D),G=r.useContext(c),H=r.useContext(m),J=o??H??"start",Q=i(I??G.locale),U=a(s,Q),Y=C??(G.present?G.collapseBelow:"none"),Z=p(Y),[ee,te]=r.useState(P),re=void 0!==z,ne=re?z:G.present?G.open[J]:ee,oe=e=>{re||(G.present?G.setOpen(J,e):te(e)),E?.(e)},ie=void 0===w?h[q]:"number"==typeof w?`${w}px`:w,ae=r.useRef(null),se=r.useRef(ie),le=r.useRef(null),de=r.useId();se.current!==ie&&(se.current=ie,ae.current=null);const ue=ae.current??ie,ce=r.useRef(null),me=r.useCallback(e=>{ce.current=e,"function"==typeof V?V(e):V&&(V.current=e)},[V]),pe=r.useRef(null);r.useEffect(()=>()=>pe.current?.(),[]);const fe=e=>{const t=ce.current;if(!t)return e;const r=Math.min(g(j,480),Math.max(g(x,160),Math.round(e)));return ae.current=`${r}px`,t.style.setProperty("--_mp-sidebar-width",ae.current),le.current?.setAttribute("aria-valuenow",String(r)),r};return Z?e(n,{side:d(J),mode:"modal",open:ne,onOpenChange:oe,title:B??$??U.sidebar,keepMounted:M,size:q,locale:Q,extent:void 0===w?void 0:ue,className:W,style:T,children:X}):t("aside",{ref:me,"aria-label":$??U.sidebar,"data-mp-size":q,"data-mp-variant":S,"data-mp-side":J,className:["mp-sidebar text-mp-on-surface relative box-border flex min-w-0 shrink-0 flex-col","w-(--_mp-sidebar-width)",l(S,N),"outlined"===S?"border-mp-outline-variant "+("start"===J?"border-e":"border-s"):"","content"===G.scroll?"h-full":L?["self-start sticky [top:var(--_mp-layout-header,0px)]","[height:calc(100dvh_-_var(--_mp-layout-header,0px)_-_var(--_mp-layout-footer,0px))]"].join(" "):"",u[Y],W??""].filter(Boolean).join(" "),style:{"--_mp-sidebar-width":ue,...T},...K,children:[e("div",{id:de,className:["mp-sidebar__body min-h-0 flex-1 overflow-y-auto overscroll-contain",O?`${f(q,F)} ${v(q,F)}`:""].filter(Boolean).join(" "),children:X}),_?e("div",{ref:le,role:"separator","aria-orientation":"vertical","aria-label":U.resizeSidebar,"aria-valuemin":Math.round(g(x,160)),"aria-valuemax":Math.round(g(j,480)),"aria-valuenow":Math.round(g(ue,g(h[q],360))),"aria-controls":de,tabIndex:0,className:["mp-sidebar__handle absolute inset-y-0 z-1 w-2 cursor-col-resize bg-transparent","start"===J?"-me-1 end-0":"-ms-1 start-0","hover:bg-mp-outline-variant data-dragging:bg-mp-outline-variant","transition-colors duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-0","focus-visible:outline-solid outline-none"].join(" "),onPointerDown:e=>{const t=ce.current;if(!t||0!==e.button)return;const r=e.currentTarget;r.setPointerCapture(e.pointerId),r.dataset.dragging="true";const n=document.body.style.getPropertyValue("-webkit-user-select");document.body.style.setProperty("-webkit-user-select","none");const o=e.clientX,i=t.getBoundingClientRect().width,a="rtl"===getComputedStyle(t).direction,s="start"===J===a?-1:1;let l=i;const d=e=>{l=fe(i+(e.clientX-o)*s),k?.(l)},u=()=>{pe.current=null,r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",c),r.removeEventListener("pointercancel",c),delete r.dataset.dragging,n?document.body.style.setProperty("-webkit-user-select",n):document.body.style.removeProperty("-webkit-user-select")},c=()=>{u(),R?.(l)};pe.current=u,r.addEventListener("pointermove",d),r.addEventListener("pointerup",c),r.addEventListener("pointercancel",c)},onKeyDown:e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();const t="rtl"===getComputedStyle(e.currentTarget).direction,r="start"===J===t?-1:1;(e=>{const t=ce.current;if(!t)return;const r=fe(t.getBoundingClientRect().width+e);k?.(r),R?.(r)})(("ArrowRight"===e.key?16:-16)*r)}}):null]})});
|
|
@@ -59,6 +59,11 @@ export interface MPSliderProps {
|
|
|
59
59
|
showValue?: boolean;
|
|
60
60
|
/** How the readout is written. Passed to `Intl.NumberFormat`. */
|
|
61
61
|
format?: Intl.NumberFormatOptions;
|
|
62
|
+
/**
|
|
63
|
+
* The locale the readout and the announced value are written in. Defaults to
|
|
64
|
+
* the nearest `MPLocaleProvider`, then to the runtime's own.
|
|
65
|
+
*/
|
|
66
|
+
locale?: string;
|
|
62
67
|
/**
|
|
63
68
|
* Which way the slider runs. A vertical slider has no length of its own, so
|
|
64
69
|
* give it a height — the default is a starting point, not a rule.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Slider as r}from"@base-ui/react/slider";import{accentSlots as s}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as l,hasContent as i}from"../../internal/scale.js";import{useMPColor as o,useMPSize as m}from"../../internal/config.js";const
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Slider as r}from"@base-ui/react/slider";import{accentSlots as s}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as l,hasContent as i}from"../../internal/scale.js";import{useMPColor as o,useMPSize as m}from"../../internal/config.js";import{useMPLocale as c}from"../../internal/locale.js";import{checkServerLocale as u,intlLocale as p}from"../../internal/intl.js";const d={xs:{thickness:"h-0.5",cross:"w-0.5",handle:"size-3.5",strip:"h-8",stripCross:"w-8"},sm:{thickness:"h-[3px]",cross:"w-[3px]",handle:"size-4",strip:"h-9",stripCross:"w-9"},md:{thickness:"h-1",cross:"w-1",handle:"size-5",strip:"h-10",stripCross:"w-10"},lg:{thickness:"h-1.5",cross:"w-1.5",handle:"size-6",strip:"h-11",stripCross:"w-11"},xl:{thickness:"h-2",cross:"w-2",handle:"size-7",strip:"h-12",stripCross:"w-12"}},f=/*@__PURE__*/["duration-(--mp-sys-motion-duration-short2) ease-mp-standard","motion-reduce:transition-none"].join(" "),h={xs:"size-[2px]",sm:"size-[2px]",md:"size-[3px]",lg:"size-1",xl:"size-1.5"},g={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=/*@__PURE__*/t.forwardRef(function({value:b,defaultValue:x,onValueChange:v,onValueCommitted:j,min:w=0,max:y=100,step:z=1,marks:N,label:_,description:k,showValue:C=!1,format:V,locale:A,orientation:M="horizontal",size:S,color:$,disabled:I=!1,name:B,"aria-label":L,className:R,style:T},F){const P=m(S),X=o($),Y=c(A),q="vertical"===M;u(Y);const D=d[P],E=t.useId(),G=b??x,H=Array.isArray(G)?G.length:1,J=t.useMemo(()=>{if(!N||y<=w)return[];if(!0!==N)return N.filter(e=>e.value>=w&&e.value<=y);const e=Math.floor((y-w)/z);return!Number.isFinite(e)||e<1||e>50?[]:Array.from({length:e+1},(e,a)=>({value:w+a*z}))},[N,w,y,z]),[K,O]=t.useState(x),Q=b??K,U=t.useMemo(()=>{const e=Array.isArray(Q)?Q:void 0===Q?[]:[Q];return 0===e.length?null:1===e.length?{from:w,to:e[0]}:{from:Math.min(...e),to:Math.max(...e)}},[Q,w]),W=e=>(e-w)/(y-w)*100+"%";return a(r.Root,{ref:F,value:b,defaultValue:x,onValueChange:e=>{void 0===b&&O(e),v?.(e)},onValueCommitted:e=>j?.(e),min:w,max:y,step:z,disabled:I,orientation:M,format:V,locale:p(Y),name:B,"data-mp-size":P,className:["mp-slider flex",q?"w-fit flex-col items-center gap-2":"w-full flex-col gap-1",I?"cursor-default":"",R??""].filter(Boolean).join(" "),style:{...s(X),...T},children:[i(_)||C?a("div",{className:["flex w-full items-baseline gap-2",l].join(" "),children:[i(_)?e(r.Label,{className:I?"text-mp-on-surface/38":"text-mp-on-surface-variant",children:_}):null,C?e(r.Value,{className:["ms-auto tabular-nums",I?"text-mp-on-surface/38":"text-mp-on-surface"].join(" ")}):null]}):null,e(r.Control,{className:["mp-slider__control group/rail flex touch-none items-center justify-center select-none",q?`${D.stripCross} h-40 flex-col`:`w-full ${D.strip}`,I?"":"cursor-pointer"].filter(Boolean).join(" "),children:a(r.Track,{className:["mp-slider__track rounded-mp-full relative",q?`${D.cross} h-full`:`${D.thickness} w-full`,I?"bg-mp-on-surface/12":"bg-mp-surface-container-highest"].join(" "),children:[e(r.Indicator,{className:["rounded-mp-full","[transition-property:inset-inline-start,width,bottom,height]",f,"group-data-dragging/rail:transition-none",I?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")}),J.map(a=>{const t=null!==U&&a.value>=U.from&&a.value<=U.to;return e("span",{"aria-hidden":"true",className:["mp-slider__tick pointer-events-none absolute rounded-full",h[P],I?"bg-mp-on-surface/38":t?"bg-(--_mp-on-accent)":"bg-mp-on-surface-variant"].join(" "),style:q?{bottom:W(a.value),insetInlineStart:"50%",transform:"translate(-50%, 50%)"}:{insetInlineStart:W(a.value),top:"50%",transform:"translate(-50%, -50%)"}},`tick:${a.value}`)}),Array.from({length:H},(a,t)=>e(r.Thumb,{index:t,"aria-label":i(_)?void 0:L,"aria-describedby":i(k)?E:void 0,className:["mp-slider__handle group rounded-mp-full relative outline-none","[transition-property:inset-inline-start,bottom]",f,"data-dragging:transition-none",D.handle,I?"bg-mp-on-surface/38 cursor-default":"bg-(--_mp-accent) cursor-grab active:cursor-grabbing"].join(" "),children:I?null:e(n,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",g[P],"bg-(--_mp-accent)"].join(" "),className:"group-data-dragging:opacity-16"})},t))]})}),J.some(e=>i(e.label))?e("div",{"aria-hidden":"true",className:["mp-slider__marks relative",l,q?"h-full":"w-full",I?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),style:q?void 0:{height:"1lh"},children:J.map(a=>i(a.label)?e("span",{className:"absolute whitespace-nowrap",style:q?{bottom:W(a.value),transform:"translateY(50%)"}:{insetInlineStart:W(a.value),transform:"translateX(-50%)"},children:a.label},`label:${a.value}`):null)}):null,i(k)?e("div",{id:E,className:[l,I?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:k}):null]})});
|
|
@@ -28,10 +28,11 @@ export interface MPSnackbarData {
|
|
|
28
28
|
* page whose bottom corner is a toolbar. Not for a preference: an application
|
|
29
29
|
* whose snackbars all appear in the same wrong place should move the provider.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* region added to the document at the same instant as the message inside it
|
|
34
|
-
*
|
|
31
|
+
* The six stacks share one `aria-live` region, which is on the page from the
|
|
32
|
+
* first render whether or not anything is in it, and that is not a detail: a
|
|
33
|
+
* region added to the document at the same instant as the message inside it
|
|
34
|
+
* is one a screen reader has nothing to compare against and does not read. A
|
|
35
|
+
* corner's stack is drawn inside it once that corner has a message.
|
|
35
36
|
*/
|
|
36
37
|
position?: MPSnackbarPosition;
|
|
37
38
|
/**
|
|
@@ -113,8 +114,9 @@ export interface MPSnackbarProviderProps {
|
|
|
113
114
|
*/
|
|
114
115
|
limit?: number;
|
|
115
116
|
/**
|
|
116
|
-
* How wide a snackbar may get. Numbers are pixels. MD3's own
|
|
117
|
-
*
|
|
117
|
+
* How wide a snackbar may get. Numbers are pixels. The default is MD3's own
|
|
118
|
+
* maximum, 600dp. There is no minimum on the plate; the message keeps at least
|
|
119
|
+
* 280px of the line, or the whole line on a window narrower than that.
|
|
118
120
|
* @default 600
|
|
119
121
|
*/
|
|
120
122
|
width?: number | string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{MPIcon as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as i}from"../../constants/icons.js";import{accentSlots as a}from"../../internal/accent.js";import{useMPLocale as r,useMPMessages as l}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as p}from"../../internal/length.js";import{PORTAL_LAYER as d}from"../../internal/surface.js";import{useMPSize as u}from"../../internal/config.js";const f={"top-start":"top-0 items-start","top-center":"top-0 items-center","top-end":"top-0 items-end","bottom-start":"bottom-0 flex-col-reverse items-start","bottom-center":"bottom-0 flex-col-reverse items-center","bottom-end":"bottom-0 flex-col-reverse items-end"},b=/*@__PURE__*/["transition-[opacity,translate] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),x={top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},h={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},y={xs:"min-h-9 gap-1.5 py-1.5 ps-3 pe-1.5",sm:"min-h-10 gap-2 py-2 ps-3.5 pe-2",md:"min-h-12 gap-2 py-2.5 ps-4 pe-2",lg:"min-h-14 gap-3 py-3 ps-5 pe-2.5",xl:"min-h-16 gap-3 py-3.5 pe-3 ps-6"},g={xs:16,sm:18,md:20,lg:22,xl:24};function v(t){const{color:e,icon:o,position:s,className:n,message:i,actionLabel:a,onAction:r,...l}=t;return{...l,title:i,data:{color:e,icon:o,position:s,className:n},actionProps:void 0===a?void 0:{children:a,onClick:r}}}export function useMPSnackbar(){const t=s.useToastManager();return o.useMemo(()=>({add:e=>t.add(v(e)),close:e=>t.close(e),update:(e,o)=>t.update(e,v(o)),promise:(e,o)=>t.promise(e,{loading:v(o.loading),success:t=>v("function"==typeof o.success?o.success(t):o.success),error:t=>v("function"==typeof o.error?o.error(t):o.error)}),snackbars:t.toasts}),[t])}function j({toast:o,color:r,size:l,showClose:c,closeLabel:p,swipeDirection:d,edge:u}){const f=o.data?.color??r,v=o.data?.icon,j={"--_mp-plate":f?`var(--_mp-color-${f}-container)`:"var(--_mp-color-inverse-surface)","--_mp-on-plate":f?`var(--_mp-color-on-${f}-container)`:"var(--_mp-color-inverse-on-surface)","--_mp-plate-action":f?`var(--_mp-color-${f})`:"var(--_mp-color-inverse-primary)",...f?a(f):null};return e(s.Root,{toast:o,swipeDirection:d,"data-mp-size":l,className:["mp-snackbar rounded-mp-xs shadow-mp-3 pointer-events-auto flex w-full items-center","bg-(--_mp-plate) text-(--_mp-on-plate) outline-none",y[l],h[l],b,x[u],"data-limited:hidden",o.data?.className??""].filter(Boolean).join(" "),style:j,children:[v?t("span",{className:"flex shrink-0 items-center",children:v}):null,t(s.Title,{render:t("span",{}),className:"min-w-0 flex-1 py-0.5 ps-1 [min-inline-size:min(280px,100%)]"}),t(s.Action,{className:["text-mp-label-large flex shrink-0 cursor-pointer items-center","rounded-mp-full h-8 px-3 text-(--_mp-plate-action)","transition-colors duration-(--mp-sys-motion-duration-short4)","hover:bg-(--_mp-plate-action)/8 focus-visible:bg-(--_mp-plate-action)/10","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ")}),c?e(s.Close,{"aria-label":p,className:["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer","items-center justify-center text-(--_mp-on-plate)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[t(m,{}),t(n,{icon:i,size:g[l]})]}):null]})}const _=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"];function w({fallback:e,width:o,...n}){const{toasts:i}=s.useToastManager();return t(s.Portal,{children:t(s.Viewport,{className:`${d} pointer-events-none fixed inset-0`,children:_.map(s=>{const a=i.filter(t=>(t.data?.position??e)===s);if(0===a.length)return null;const r=s.startsWith("top")?"top":"bottom",l=["top"===r?"up":"down","left","right"];return t("div",{"data-mp-position":s,className:["mp-snackbar__stack pointer-events-none absolute inset-x-0 flex flex-col gap-2 p-4",f[s]].join(" "),children:a.map(e=>t("div",{className:"w-full",style:{maxWidth:p(o)},children:t(j,{toast:e,swipeDirection:l,edge:r,...n})},e.id))},s)})})})}export function MPSnackbarProvider({color:o,position:n="bottom-start",timeout:i=5e3,limit:a=3,width:m=600,size:p,showClose:d=!0,closeLabel:f,locale:b,children:x}){const h=u(p),y=r(b),g=l(c,y);return e(s.Provider,{timeout:i,limit:a,children:[x,t(w,{fallback:n,width:m,color:o,size:h,showClose:d,closeLabel:f??g.close})]})}
|
|
@@ -18,10 +18,12 @@ export interface MPStepperProps extends Omit<React.ComponentPropsWithoutRef<'div
|
|
|
18
18
|
/**
|
|
19
19
|
* Called with the step that was pressed.
|
|
20
20
|
*
|
|
21
|
-
* **Leaving it out is what makes the steps
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* with its own Next and
|
|
21
|
+
* **Leaving it out of a controlled stepper is what makes the steps
|
|
22
|
+
* unpressable.** A stepper given `active` and no handler is a progress
|
|
23
|
+
* indicator — it says where the reader is and offers no way to move, which is
|
|
24
|
+
* the right shape for a sequence the application drives with its own Next and
|
|
25
|
+
* Back buttons. An uncontrolled stepper moves itself when a step is pressed,
|
|
26
|
+
* handler or not.
|
|
25
27
|
*/
|
|
26
28
|
onActiveChange?: (active: number) => void;
|
|
27
29
|
/**
|
|
@@ -123,9 +125,9 @@ export interface MPStepProps extends Omit<React.ComponentPropsWithoutRef<'li'>,
|
|
|
123
125
|
* | The content | is all on screen | is one panel |
|
|
124
126
|
* | Default orientation | `vertical` | `horizontal` |
|
|
125
127
|
*
|
|
126
|
-
* A stepper with no `onActiveChange` is the overlap: unpressable, one
|
|
127
|
-
* a progress indicator for a sequence the application's own Next and
|
|
128
|
-
* buttons drive.
|
|
128
|
+
* A controlled stepper with no `onActiveChange` is the overlap: unpressable, one
|
|
129
|
+
* panel, and a progress indicator for a sequence the application's own Next and
|
|
130
|
+
* Back buttons drive.
|
|
129
131
|
*
|
|
130
132
|
* ## It ships no Next and Back
|
|
131
133
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as l}from"../icon/MPIcon.js";import{CheckIcon as o,ErrorIcon as a}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{hasContent as s,META_TEXT as c,SHEET_TITLE as p}from"../../internal/scale.js";import{BORDER_STYLE as m,BULLET as d,BULLET_GAP as u,BULLET_SIZE as f,CONNECTOR_COLOR as h,ITEM_GAP as v,ITEM_GAP_X as x,STEP_MOTION as b,TITLE_COLOR as _}from"../../internal/step.js";import{useMPColor as j,useMPSize as N}from"../../internal/config.js";function g(e,t){return`${e}-label-${t}`}function w(e){return`${e}-panel`}const y=/*@__PURE__*/n.createContext(null),z=/*@__PURE__*/n.createContext(0);export const MPStepper=/*@__PURE__*/n.forwardRef(function({active:r,defaultActive:l=0,onActiveChange:o,linear:a=!0,orientation:c="horizontal",size:p,color:m,className:d,style:u,children:h,...v},x){const b=N(p),_=j(m),[g,w]=n.useState(l),C=r??g,[P
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as l}from"../icon/MPIcon.js";import{CheckIcon as o,ErrorIcon as a}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{hasContent as s,META_TEXT as c,SHEET_TITLE as p}from"../../internal/scale.js";import{BORDER_STYLE as m,BULLET as d,BULLET_GAP as u,BULLET_SIZE as f,CONNECTOR_COLOR as h,ITEM_GAP as v,ITEM_GAP_X as x,STEP_MOTION as b,TITLE_COLOR as _}from"../../internal/step.js";import{useMPColor as j,useMPSize as N}from"../../internal/config.js";function g(e,t){return`${e}-label-${t}`}function w(e){return`${e}-panel`}const y=/*@__PURE__*/n.createContext(null),z=/*@__PURE__*/n.createContext(0);export const MPStepper=/*@__PURE__*/n.forwardRef(function({active:r,defaultActive:l=0,onActiveChange:o,linear:a=!0,orientation:c="horizontal",size:p,color:m,className:d,style:u,children:h,...v},x){const b=N(p),_=j(m),[g,w]=n.useState(l),C=r??g,[P,$]=n.useState(C);C>P&&$(C);const S=n.Children.toArray(h).filter(n.isValidElement),k=S.length,M=n.useId(),A=s(S[C]?.props.children),I=n.useCallback(e=>{void 0===r&&w(e),o?.(e)},[r,o]),R=n.useMemo(()=>({size:b,color:_,orientation:c,active:C,onSelect:o||void 0===r?I:null,linear:a,count:k,furthest:P,idBase:M,hasPanel:A}),[b,_,c,C,o,r,I,a,k,P,M,A]),E="horizontal"===c;return e(y.Provider,{value:R,children:t("div",{...v,ref:x,"data-mp-size":b,className:["mp-stepper flex flex-col",d??""].filter(Boolean).join(" "),style:{...i(_),...u},children:[e("ol",{className:["mp-stepper__rail m-0 flex list-none p-0",E?"flex-row items-start":"flex-col"].join(" "),style:{"--_mp-bullet":f[b]},children:S.map((t,r)=>e(z.Provider,{value:r,children:t},r))}),e(B,{steps:S,active:C,idBase:M})]})})});function B({steps:t,active:r,idBase:n}){const l=t[r],o=l?.props.children;if(!s(o))return null;const a=s(l?.props.label);return e("div",{id:w(n),role:"group","aria-labelledby":a?g(n,r):void 0,className:"mp-stepper__panel mt-4",children:o})}export const MPStep=/*@__PURE__*/n.forwardRef(function({label:f,description:j,bullet:N,error:B=!1,optional:C,disabled:P=!1,connector:$="solid",color:S,className:k,style:M,children:A,...I},R){const E=n.useContext(y),F=n.useContext(z),V=E?.size??"md",q=E?.orientation??"horizontal",D=E?.active??0,G=E?.count??1,H=E?.furthest??0,J=E?.linear??!0,K=F<D?"complete":F===D?"current":"upcoming",L=S??(B?"error":E?.color??"primary"),O="horizontal"===q,Q=F===G-1,T="none"!==$&&!Q,U=!P&&(!J||F<=H),W=null!=E?.onSelect,X=W&&U,Y=N??("complete"!==K||B?B?e(l,{icon:a}):F+1:e(l,{icon:o})),Z=e("span",{"aria-hidden":"true",className:["mp-stepper__bullet rounded-mp-full relative z-10 flex shrink-0","items-center justify-center","size-(--_mp-bullet) text-[calc(var(--_mp-bullet)*0.5)] leading-none font-medium","tabular-nums [&>svg]:size-[0.6em]",d[K],"transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard"].join(" "),children:Y}),ee=T?e("span",{"aria-hidden":"true",className:["mp-stepper__connector pointer-events-none absolute",O?"start-(--_mp-bullet) top-[calc(var(--_mp-bullet)/2_-_1px)] end-0 border-t-2":"top-(--_mp-bullet) start-[calc(var(--_mp-bullet)/2_-_1px)] bottom-0 border-s-2",m[$],h[K],b].filter(Boolean).join(" ")}):null,te=t("span",{className:"flex min-w-0 flex-col gap-0.5 text-start "+(O?"mt-2":""),children:[s(f)?e("span",{id:E?g(E.idBase,F):void 0,className:["mp-stepper__label",p[V],B?"text-mp-error":_[K],b].join(" "),children:f}):null,s(C)?e("span",{className:`text-mp-on-surface-variant ${c}`,children:C}):null,s(j)?e("span",{className:`text-mp-on-surface-variant ${c}`,children:j}):null]}),re=t(r,{children:[ee,t("span",{className:`flex min-w-0 ${O?"flex-col items-start":"flex-row"} ${O?"":u[V]}`,children:[Z,te]})]});return e("li",{...I,ref:R,"aria-current":"current"===K?"step":void 0,className:["mp-stepper__step relative min-w-0",O?`flex-1 ${Q?"":x[V]}`:Q?"":v[V],k??""].filter(Boolean).join(" "),style:{...S||B?i(L):null,...M},children:W?e("button",{type:"button","aria-controls":E?.hasPanel?w(E.idBase):void 0,"aria-expanded":E?.hasPanel?"current"===K:void 0,"aria-disabled":!U||void 0,className:["group relative flex w-full min-w-0 appearance-none border-0 bg-transparent p-0 text-start",X?"cursor-pointer":"cursor-default","outline-mp-secondary rounded-mp-xs focus-visible:outline-2 focus-visible:outline-offset-2","outline-none"].join(" "),onClick:X?()=>E?.onSelect?.(F):void 0,children:re}):e("span",{className:"relative flex w-full min-w-0",children:re})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const g={xs:{track:"h-5 w-8",thumb:"start-[5px] size-2.5 data-checked:start-[15px] data-checked:size-3.5",halo:"size-8",glyph:8},sm:{track:"h-6 w-10",thumb:"start-1.5 size-3 data-checked:start-[19px] data-checked:size-[18px]",halo:"size-9",glyph:10},md:{track:"h-8 w-13",thumb:"start-2 size-4 data-checked:start-6 data-checked:size-6",halo:"size-10",glyph:14},lg:{track:"h-9 w-15",thumb:"start-[9px] size-[18px] data-checked:start-7 data-checked:size-7",halo:"size-11",glyph:16},xl:{track:"h-10 w-17",thumb:"start-2.5 size-5 data-checked:start-[33px] data-checked:size-[30px]",halo:"size-12",glyph:18}};export const MPSwitch=/*@__PURE__*/r.forwardRef(function({checked:k,defaultChecked:b,onCheckedChange:x,label:y,description:j,errorMessage:z,icons:w=!1,labelPlacement:N="end",size:_,color:C,required:M=!1,disabled:v=!1,readOnly:P=!1,name:R,id:S,fullWidth:W=!1,className:q,style:B},
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const g={xs:{track:"h-5 w-8",thumb:"start-[5px] size-2.5 data-checked:start-[15px] data-checked:size-3.5",halo:"size-8",glyph:8},sm:{track:"h-6 w-10",thumb:"start-1.5 size-3 data-checked:start-[19px] data-checked:size-[18px]",halo:"size-9",glyph:10},md:{track:"h-8 w-13",thumb:"start-2 size-4 data-checked:start-6 data-checked:size-6",halo:"size-10",glyph:14},lg:{track:"h-9 w-15",thumb:"start-[9px] size-[18px] data-checked:start-7 data-checked:size-7",halo:"size-11",glyph:16},xl:{track:"h-10 w-17",thumb:"start-2.5 size-5 data-checked:start-[33px] data-checked:size-[30px]",halo:"size-12",glyph:18}};export const MPSwitch=/*@__PURE__*/r.forwardRef(function({checked:k,defaultChecked:b,onCheckedChange:x,label:y,description:j,errorMessage:z,icons:w=!1,labelPlacement:N="end",size:_,color:C,required:M=!1,disabled:v=!1,readOnly:P=!1,name:R,id:S,fullWidth:W=!1,className:q,style:B},I){const L=f(_),O=u(C),T=p(z),F=T?"error":O,A=g[L],D=r.useId(),E=S??D,G=e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(n.Root,{ref:I,id:E,name:R,checked:k,defaultChecked:b,required:M,disabled:v,readOnly:P,onCheckedChange:e=>x?.(e),className:["mp-switch__track group relative box-border inline-flex shrink-0 p-0","rounded-mp-full appearance-none font-[inherit] outline-none","transition-[background-color,box-shadow]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",A.track,v?["bg-mp-surface-container-highest inset-ring-2 inset-ring-mp-on-surface/12","cursor-default","data-checked:bg-mp-on-surface/12 data-checked:inset-ring-0"].join(" "):[P?"cursor-default":"cursor-pointer","bg-mp-surface-container-highest inset-ring-2",T?"inset-ring-mp-error":"inset-ring-mp-outline","data-checked:inset-ring-0 data-checked:bg-(--_mp-accent)"].join(" ")].join(" "),children:a(n.Thumb,{className:["mp-switch__thumb absolute top-1/2 flex -translate-y-1/2 items-center justify-center","rounded-full","transition-[inset-inline-start,width,height,background-color]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",A.thumb,v?"bg-mp-on-surface/38 data-checked:bg-mp-surface-container-highest":[T?"bg-mp-error":"bg-mp-outline","data-checked:bg-(--_mp-on-accent)"].join(" ")].join(" "),children:[v?null:e(d,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",A.halo,"bg-mp-on-surface group-data-checked:bg-(--_mp-accent)"].join(" ")}),w?a(t,{children:[e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard opacity-0 group-data-checked:opacity-100",v?"text-mp-surface-container-highest":"text-(--_mp-accent)"].join(" "),children:e(s,{icon:o,size:A.glyph,strokeWidth:3})}),e("span",{className:["absolute inset-0 flex items-center justify-center","text-mp-surface-container-highest","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard group-data-checked:opacity-0"].join(" "),children:e(s,{icon:c,size:A.glyph,strokeWidth:3})})]}):null]})})}),H=p(y)||p(j)||T?a("span",{className:["flex min-w-0 flex-col gap-0.5","start"===N?"flex-1":""].filter(Boolean).join(" "),children:[p(y)?a(i.Label,{className:["leading-[1.4]",v?"text-mp-on-surface/38 cursor-default":P?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:[y,M?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(h,{description:j,errorMessage:z})]}):null;return e(i.Root,{className:["mp-switch align-top",W?"flex w-full":"inline-flex",q??""].filter(Boolean).join(" "),disabled:v,invalid:T,"data-mp-size":L,style:{...l(F),...B},children:e("div",{className:["flex w-full items-start gap-3",m[L]].join(" "),children:a(t,"start"===N?{children:[H,G]}:{children:[G,H]})})})});
|
|
@@ -128,9 +128,13 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
128
128
|
*/
|
|
129
129
|
size?: MPSize;
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
131
|
+
* Has no visible effect, and is kept only so code that passes it still
|
|
132
|
+
* compiles.
|
|
133
|
+
*
|
|
134
|
+
* It promised the accent family a hovered row would read, and the rows were
|
|
135
|
+
* never tinted: a stripe and a hover are neutral surfaces one step apart, on
|
|
136
|
+
* purpose, because a table that tints its rows colours its data.
|
|
137
|
+
* @deprecated No effect. It is due to be removed in the next major version.
|
|
134
138
|
*/
|
|
135
139
|
color?: MPColor;
|
|
136
140
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Tabs as a}from"@base-ui/react/tabs";import{accentSlots as r}from"../../internal/accent.js";import{MPStateLayer as i}from"../../internal/StateLayer.js";import{CONTROL_GAP as o,hasContent as l,SHEET_GAP as s}from"../../internal/scale.js";import{useMPColor as c,useMPSize as u}from"../../internal/config.js";const d=/*@__PURE__*/n.createContext({variant:"primary",size:"md",iconPosition:"top",fullWidth:!1}),m={xs:"h-8",sm:"h-10",md:"h-12",lg:"h-14",xl:"h-16"},f={xs:"h-11",sm:"h-13",md:"h-16",lg:"h-18",xl:"h-20"},p={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-title-small",lg:"text-mp-title-small",xl:"text-mp-title-medium"},h={xs:"px-3",sm:"px-3.5",md:"px-4",lg:"px-5",xl:"px-6"},b={xs:12,sm:14,md:16,lg:20,xl:24},v={xs:18,sm:20,md:24,lg:24,xl:28};function x(e,t,a,r=""){n.Children.toArray(e).forEach(e=>{if(!n.isValidElement(e))return void(l(e)&&t.push(e));if(e.type===n.Fragment)return void x(e.props.children,t,a,`${r}${String(e.key)}/`);const i=r?n.cloneElement(e,{key:`${r}${String(e.key)}`}):e;e.type===MPTabPanel?a.push(i):t.push(i)})}export const MPTabs=/*@__PURE__*/n.forwardRef(function({variant:i="primary",color:o,size:l,value:m,defaultValue:f,onValueChange:p,iconPosition:h,activateOnFocus:v=!1,loopFocus:y=!0,divider:w=!0,fullWidth:g=!1,className:_,style:j,children:P,"aria-label":k,...M},N){const R=c(o),z=u(l),C=h??("primary"===i?"top":"start"),F=n.useMemo(()=>({variant:i,size:z,iconPosition:C,fullWidth:g}),[i,z,C,g]),$=n.useRef(null),[O,S]=n.useState(null),W=n.useCallback(()=>{const e=$.current;if(!e)return;const t=e.scrollWidth-e.clientWidth,n=Math.abs(e.scrollLeft),a=t-n,r="rtl"===getComputedStyle(e).direction,i=(r?a:n)>1,o=(r?n:a)>1;S(i&&o?"both":i?"left":o?"right":null)},[]);n.useEffect(()=>{const e=$.current;if(W(),!e)return;const t="undefined"==typeof ResizeObserver?null:new ResizeObserver(W),n=()=>{if(t){t.disconnect(),t.observe(e);for(const n of e.children)t.observe(n)}};n();const a="undefined"==typeof MutationObserver?null:new MutationObserver(()=>{n(),W()});return a?.observe(e,{childList:!0}),()=>{t?.disconnect(),a?.disconnect()}},[W]);const E=n.useRef(0);n.useEffect(()=>()=>cancelAnimationFrame(E.current),[]);const T=[],V=[];return x(P,T,V),e(d.Provider,{value:F,children:t(a.Root,{ref:N,value:m,defaultValue:f,onValueChange:e=>p?.(e),"data-mp-size":z,"data-mp-variant":i,className:["mp-tabs flex min-w-0 flex-col",s[z],_??""].filter(Boolean).join(" "),style:{...r(R),"--_mp-tab-inset":`${b[z]}px`,...j},...M,children:[t(a.List,{ref:$,"aria-label":k,activateOnFocus:v,loopFocus:y,"data-mp-overflow":O??void 0,onScroll:()=>{0===E.current&&(E.current=requestAnimationFrame(()=>{E.current=0,W()}))},className:["mp-tabs__list relative flex shrink-0",w?"border-mp-outline-variant border-b":"",g?"w-full":"","overflow-x-auto overflow-y-hidden","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden"].filter(Boolean).join(" "),children:[T,e(a.Indicator,{className:["mp-tabs__indicator pointer-events-none absolute bottom-0","bg-(--_mp-accent)","primary"===i?["h-0.75 rounded-t-full","left-[calc(var(--active-tab-left)_+_var(--_mp-tab-inset))]","w-[calc(var(--active-tab-width)_-_2_*_var(--_mp-tab-inset))]"].join(" "):"left-(--active-tab-left) h-0.5 w-(--active-tab-width)","[transition-property:left,width]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard"].join(" ")})]}),V]})})});export const MPTab=/*@__PURE__*/n.forwardRef(function({value:r,icon:s,disabled:c=!1,className:u,children:b,...x},y){const{variant:w,size:g,iconPosition:_,fullWidth:j}=n.useContext(d),P="top"===_&&l(s);return t(a.Tab,{ref:y,value:r,disabled:c,className:["mp-tabs__tab group relative flex shrink-0 items-center justify-center","box-border appearance-none border-0 bg-transparent font-[inherit] whitespace-nowrap select-none","overflow-hidden outline-none","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",P?`flex-col gap-1 ${f[g]}`:`flex-row ${m[g]}`,P?"":o[g],p[g],h[g],c?"text-mp-on-surface/38 cursor-default":["text-mp-on-surface-variant cursor-pointer","primary"===w?"data-active:text-(--_mp-accent)":"data-active:text-mp-on-surface"].join(" "),"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid",j?"flex-1":"",u??""].filter(Boolean).join(" "),...x,children:[c?null:e(i,{}),l(s)?e("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:v[g],height:v[g]},children:s}):null,l(b)?e("span",{className:"relative truncate",children:b}):null]})});export const MPTabPanel=/*@__PURE__*/n.forwardRef(function({value:t,keepMounted:n=!1,className:r,children:i,...o},l){return e(a.Panel,{ref:l,value:t,keepMounted:n,className:["mp-tabs__panel text-mp-on-surface min-w-0 flex-1","rounded-mp-xs outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-opacity duration-(--mp-sys-motion-duration-short4) ease-mp-standard","data-starting-style:opacity-0",r??""].filter(Boolean).join(" "),...o,children:i})});
|
|
@@ -43,6 +43,15 @@ export interface MPTextFieldProps extends MPStyleProps, MPControlEventProps<HTML
|
|
|
43
43
|
* where a placeholder would be. See `floatingLabel`.
|
|
44
44
|
*/
|
|
45
45
|
label?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The accessible name, for a field with no visible `label` — a filter box
|
|
48
|
+
* whose purpose the panel around it already shows.
|
|
49
|
+
*
|
|
50
|
+
* A prop of its own because the field passes nothing on that it does not
|
|
51
|
+
* name, and a hyphenated attribute is one TypeScript never checks: written on
|
|
52
|
+
* the component, it used to be accepted without a word and dropped.
|
|
53
|
+
*/
|
|
54
|
+
'aria-label'?: string;
|
|
46
55
|
/**
|
|
47
56
|
* Whether the label rests on the field's line while there is nothing to make
|
|
48
57
|
* room for, and rises into the notch on focus or on the first character.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Field as n}from"@base-ui/react/field";import{MPIcon as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Field as n}from"@base-ui/react/field";import{MPIcon as a}from"../icon/MPIcon.js";import{MPFieldLabel as r,MPFieldOutline as i,useFloatingLabel as l}from"../../internal/FieldOutline.js";import{MPSupportingText as s}from"../../internal/SupportingText.js";import{VisibilityIcon as d,VisibilityOffIcon as p}from"../../constants/icons.js";import{useMPLocale as u,useMPMessages as c}from"../../internal/locale.js";import{TEXT_FIELD as m}from"../../internal/messages/text-field.js";import{useMPSize as f}from"../../internal/config.js";const x={xs:{padding:"px-2",control:"py-1.5",text:"text-mp-body-medium",icon:16},sm:{padding:"px-3",control:"py-2.5",text:"text-mp-body-medium",icon:18},md:{padding:"px-4",control:"py-4",text:"text-mp-body-large",icon:20},lg:{padding:"px-4",control:"py-5",text:"text-mp-body-large",icon:22},xl:{padding:"px-5",control:"py-6",text:"text-mp-body-large",icon:24}};export const MPTextField=/*@__PURE__*/o.forwardRef(function({value:b,name:g,type:y="text",placeholder:h,autoComplete:v,label:w,"aria-label":C,floatingLabel:j=!0,onChange:k,onFormReset:M,onSubmit:z,onKeyDown:D,onKeyUp:N,onFocus:E,onBlur:F,onClick:P,onDoubleClick:S,onContextMenu:B,errorMessage:K="",required:q=!1,fullWidth:L=!1,readOnly:R=!1,autoFocus:U=!1,size:I,disabled:O=!1,disableEnterKey:T=!1,rows:$,maxLength:_,startIcon:W,resizable:A=!1,id:G,locale:H,passwordLabels:J,className:Q,style:V},X){const Y=f(I),Z=u(H),ee=c(m,Z,J),te=o.useRef(null),[oe,ne]=o.useState(!1),[ae,re]=o.useState(!1),[ie,le]=o.useState(b),se=o.useId(),de=G??se,pe=!!$,ue=K.length>0,ce=x[Y],me=ae?ie:b,{shrunk:fe,focusProps:xe}=l({floating:j&&!!w,filled:me.length>0,pinned:!!W}),be=o.useCallback(e=>{te.current=e,"function"==typeof X?X(e):X&&(X.current=e)},[X]),ge=e=>{e.preventDefault()};return o.useEffect(()=>{ae||le(b)},[b,ae]),o.useEffect(()=>{U&&!window.matchMedia("(max-width: 599.95px)").matches&&te.current?.focus()},[]),t(n.Root,{className:["mp-text-field group relative",L?"w-full":"inline-block","align-top",Q??""].filter(Boolean).join(" "),style:V,disabled:O,invalid:ue,"data-mp-size":Y,...xe,children:[t("div",{className:["relative flex w-full items-center gap-2",ce.padding,pe?"py-2":""].filter(Boolean).join(" "),children:[e(i,{label:w,required:q,notched:fe}),W?e("span",{className:"text-mp-on-surface-variant group-data-disabled:text-mp-on-surface/38 flex shrink-0 items-center",children:W}):null,e(n.Control,{render:pe?e("textarea",{rows:$}):e("input",{}),id:de,name:g,"aria-label":C,type:pe?void 0:oe?"text":y,required:q,readOnly:R,disabled:O,autoComplete:v,placeholder:fe?h:void 0,maxLength:_,value:me,ref:be,className:[`${ce.text} text-mp-on-surface w-full min-w-0 flex-1`,"font-[family-name:var(--mp-sys-typescale-body-large-font)]","appearance-none border-0 bg-transparent px-0 outline-none","caret-mp-primary",ce.control,pe?"py-0":"",pe&&A?"resize-y":"resize-none","search"===y?"[&::-webkit-search-cancel-button]:hidden":"","group-data-disabled:text-mp-on-surface/38","placeholder:text-mp-on-surface-variant group-data-disabled:placeholder:text-mp-on-surface/38"].filter(Boolean).join(" "),onChange:e=>{M?.();const t=e.target.value;ae&&le(t),k?.(t)},onCompositionStart:()=>{re(!0),le(b)},onCompositionUpdate:e=>{le(e.target.value)},onCompositionEnd:e=>{re(!1);const t=e.target.value;M?.(),k?.(t),le(t)},onKeyUp:N,onFocus:E,onBlur:F,onClick:P,onDoubleClick:S,onContextMenu:B,onKeyDown:e=>{if(D?.(e),!e.defaultPrevented&&"Enter"===e.key){if(function(e){const t=e.nativeEvent;return t.isComposing||229===t.keyCode}(e))return;z?.(),(T||z&&!pe)&&e.preventDefault()}}}),"password"!==y||pe?null:e("button",{type:"button","aria-label":oe?ee.hidePassword:ee.showPassword,onClick:()=>ne(e=>!e),onMouseDown:ge,onMouseUp:ge,disabled:O,className:["text-mp-on-surface-variant -me-1 flex shrink-0 items-center justify-center","cursor-pointer appearance-none border-0 bg-transparent p-1 font-[inherit]","rounded-full","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none","hover:text-mp-on-surface focus-visible:text-mp-primary","disabled:text-mp-on-surface/38 disabled:cursor-default"].join(" "),children:e(a,{icon:oe?d:p,size:ce.icon})}),w?e(r,{size:Y,label:w,required:q,shrunk:fe,multiline:pe}):null]}),e(s,{errorMessage:K,className:`mp-text-field__support mt-1 ${ce.padding}`})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as n from"react";import{MPButton as l}from"../button/MPButton.js";import{MPIcon as r}from"../icon/MPIcon.js";import{ClockIcon as t}from"../../constants/icons.js";import{MPTimeGrid as
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as n from"react";import{MPButton as l}from"../button/MPButton.js";import{MPIcon as r}from"../icon/MPIcon.js";import{ClockIcon as t}from"../../constants/icons.js";import{MPTimeGrid as a}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 u,useMPMessages as d}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,isHour12 as g,isValidDate as j,secondsOfDay as S,timeUnitSpan as b,toISOTime as v,withPlaceholder as C,withTime as x}from"../../internal/date.js";import{useMPColor as k,useMPSize as w}from"../../internal/config.js";export const MPTimePicker=/*@__PURE__*/n.forwardRef(function({value:z,defaultValue:D,onValueChange:O,open:P,defaultOpen:T,onOpenChange:y,referenceDate:M,minTime:V,maxTime:I,shouldDisableTime:B,hour12:N,showSeconds:R=!1,hourStep:F=1,minuteStep:H=1,secondStep:q=1,locale:A,format:E,placeholder:G,clearable:J=!1,showNowButton:K=!0,closeOnSelect:L=!1,labels:Q,name:U,size:W,color:X,readOnly:Y=!1,disabled:Z=!1,startIcon:$,..._},ee){const oe=w(W),ne=k(X),le=u(A),re=d(p,le,Q),te=N??g(le),[ae,ie]=n.useState(D??null),se=void 0!==z?z:ae,[ce,me]=n.useState(T??!1),ue=P??ce,[de]=n.useState(()=>M??new Date),pe=e=>{e&&(Y||Z)||(void 0===P&&me(e),y?.(e))},fe=e=>{void 0===z&&ie(e),O?.(e)},he=n.useCallback((e,o)=>{const[n,l]=b(o,e);return!!(j(V)&&l<S(V))||(!!(j(I)&&n>S(I))||(B?.(e,o)??!1))},[V,I,B]),ge=E??{hour:"numeric",minute:"2-digit",hour12:te,...R?{second:"2-digit"}:{}},je=new Date,Se=x(M??de,{hours:je.getHours(),minutes:je.getMinutes(),seconds:R?je.getSeconds():0}),be=K||J||!L,ve=C(m(le,ge),G),Ce=j(se)?v(se,R):"";return e(c,{..._,slug:"time-picker",size:oe,color:ne,name:U,locale:le,readOnly:Y,disabled:Z,triggerRef:ee,startIcon:void 0===$?e(r,{icon:t,size:f[oe]}):$,display:j(se)?h(se,le,ge):G??"",samples:ve,empty:!j(se),clearable:J,onClear:()=>fe(null),open:ue,onOpenChange:pe,labels:re,formValue:Ce,hiddenValues:U?[{name:U,value:Ce}]:void 0,children:o("div",{className:"flex flex-col "+(be?"gap-1.5":""),children:[e(a,{size:oe,locale:le,value:j(se)?se:null,referenceDate:M??de,onChange:e=>{fe(e),L&&pe(!1)},hour12:te,showSeconds:R,hourStep:F,minuteStep:H,secondStep:q,shouldDisableTime:he,labels:re,autoFocus:!0}),be?o(s,{children:[J?e(l,{variant:"text",size:i[oe],color:ne,onClick:()=>{fe(null),pe(!1)},children:re.clear}):null,K?e(l,{variant:"text",size:i[oe],color:ne,disabled:he(Se,"second"),onClick:()=>{fe(Se),pe(!1)},children:re.now}):null,L?null:e(l,{variant:"filled",size:i[oe],color:ne,onClick:()=>pe(!1),children:re.done})]}):null]})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as a,jsxs as e}from"react/jsx-runtime";import*as t from"react";import{CartesianFrame as r}from"../../internal/ChartFrame.js";import{ChartTable as n}from"../../internal/ChartChrome.js";import{useMPLocale as o,useMPMessages as l}from"../../internal/locale.js";import{CHART as s}from"../../internal/messages/chart.js";import{TABLE as i}from"../../internal/messages/table.js";import{formatTimeTick as m,timeScale as p}from"../../internal/time-scale.js";import{BAR_RADIUS as c,CHART_FONT_SIZE as u,MARK_GAP as f,barPath as x,
|
|
2
|
+
import{jsx as a,jsxs as e}from"react/jsx-runtime";import*as t from"react";import{CartesianFrame as r}from"../../internal/ChartFrame.js";import{ChartTable as n}from"../../internal/ChartChrome.js";import{useMPLocale as o,useMPMessages as l}from"../../internal/locale.js";import{CHART as s}from"../../internal/messages/chart.js";import{TABLE as i}from"../../internal/messages/table.js";import{formatTimeTick as m,timeScale as p}from"../../internal/time-scale.js";import{BAR_RADIUS as c,CHART_FONT_SIZE as u,MARK_GAP as f,barPath as x,bounds as d,seriesColor as b,textWidth as h,toNumber as g}from"../../internal/chart.js";function y(a,e,t){return null!=a&&!1!==a&&""!==a&&("string"!=typeof a&&"number"!=typeof a||e>=h(String(a),t)+16)}export function MPTimelineChart({series:h,yAxis:j,xAxis:M,spanLabels:k=!0,...v}){const $=o(v.locale),C=l(s,$),P=l(i,$),S=t.useMemo(()=>h.map(a=>a.data.map(a=>{const e=g(a.start),t=g(a.end);return null===e||null===t?null:{from:Math.min(e,t),to:Math.max(e,t),span:a}}).filter(a=>null!==a)),[h]),A=S.flat(),_=d(A.map(a=>a.from)),z=d(A.map(a=>a.to)),F=_&&z?{min:_.min,max:z.max}:null,N=p(F,{min:M?.min,max:M?.max,tickCount:M?.tickCount}),T=t.useCallback(a=>m(a,N.unit,$),[N.unit,$]),B=t.useMemo(()=>[{data:h.map(()=>0)}],[h]),I=h.map((a,e)=>a.name??String(e+1)),L=h.map((a,e)=>b(e,a.color));return a(r,{...v,series:B,categories:I,horizontal:!0,inset:!1,bandRatio:.62,scale:N,includeZero:!1,legend:!1,xAxis:j,yAxis:{...M,tickFormat:M?.tickFormat??(a=>T(Number(a)))},marks:({plot:a,band:e,valuePx:t,categoryPx:r})=>S.flatMap((n,o)=>n.map((n,l)=>{const s=t(n.from),i=t(n.to),m=a.top+r(o);return{series:o,index:l,x:(s+i)/2,y:m,r:e.band/2,rx:Math.max(1,Math.abs(i-s)/2),ry:e.band/2}})),markTooltip:a=>{const e=S[a.series]?.[a.index];return e?{heading:void 0===e.span.label||null===e.span.label?I[a.series]:`${I[a.series]} · ${String(e.span.label)}`,items:[{seriesIndex:a.series,color:e.span.color?b(0,e.span.color):L[a.series],value:e.to-e.from,formatted:`${T(e.from)} – ${T(e.to)}`}]}:null},table:e=>a(n,{id:e,caption:v.label??C.table,corner:j?.label??C.category,categories:I,names:[C.table],values:[S.map(a=>({value:a.length,label:a.map(a=>`${T(a.from)} – ${T(a.to)}`).join("; ")}))],format:a=>String(a),locale:$,empty:P.empty}),children:({plot:t,band:r,valuePx:n,categoryPx:o,activeMark:l,size:s})=>{const i=u[s]-1;return a("g",{className:"mp-timeline-chart__spans",children:S.map((s,m)=>s.map((s,p)=>{const u=n(s.from),d=n(s.to),h=Math.max(2,r.band-f),g=t.top+o(m)-h/2,j=Math.max(1,d-u),M=l?.series===m&&l?.index===p,v=s.span.color?b(0,s.span.color):L[m];return e("g",{children:[a("path",{d:x(u,g,j,h,c,"both"),fill:v,opacity:M?1:.85,stroke:M?"var(--_mp-color-on-surface)":"none",strokeWidth:M?1.5:0}),k&&y(s.span.label,j,i)?a("text",{x:u+8,y:t.top+o(m),dominantBaseline:"central",fill:"var(--_mp-color-surface)",fontSize:i,children:s.span.label}):null]},`${m}-${p}`)}))})}})}
|
|
@@ -99,8 +99,8 @@ export interface MPToolbarProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
99
99
|
*
|
|
100
100
|
* ## What it is not
|
|
101
101
|
*
|
|
102
|
-
* Not `MPHeader`, which is `MPPageLayout`'s
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* Not `MPHeader`, which is `MPPageLayout`'s header slot: the layout measures it
|
|
103
|
+
* and keeps the page clear of it. This is a bar you can put anywhere, including
|
|
104
|
+
* inside a card.
|
|
105
105
|
*/
|
|
106
106
|
export declare const MPToolbar: React.ForwardRefExoticComponent<MPToolbarProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -55,6 +55,12 @@ export interface MPTooltipProps {
|
|
|
55
55
|
*/
|
|
56
56
|
disabled?: boolean;
|
|
57
57
|
/**
|
|
58
|
+
* The plate's padding and type. `sm` and `md` both draw MD3's plain tooltip,
|
|
59
|
+
* 24dp tall with a `body-small` label, and differ only in the arrow.
|
|
60
|
+
*
|
|
61
|
+
* `sm` is this component's own answer, so it does not take the size
|
|
62
|
+
* `MPConfigProvider` sets for the rest of the application: a tooltip at a
|
|
63
|
+
* control's height is a slab. Set it here when a tooltip has to be larger.
|
|
58
64
|
* @default 'sm'
|
|
59
65
|
*/
|
|
60
66
|
size?: MPSize;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as o}from"@base-ui/react/popover";import{MPButton as i}from"../button/MPButton.js";import{MPIcon as r}from"../icon/MPIcon.js";import{CloseIcon as s}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{useMPColor as a,useMPSize as c}from"../../internal/config.js";import{fillMessage as m}from"../../internal/i18n.js";import{useMPLocale as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Popover as o}from"@base-ui/react/popover";import{MPButton as i}from"../button/MPButton.js";import{MPIcon as r}from"../icon/MPIcon.js";import{CloseIcon as s}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{useMPColor as a,useMPSize as c}from"../../internal/config.js";import{fillMessage as m}from"../../internal/i18n.js";import{useMPLocale as p,useMPMessages as u}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{TOUR as f}from"../../internal/messages/tour.js";import{CONTROL_ICON as h,META_TEXT as g,PROSE_TEXT as x,SHEET_GAP as v,SHEET_PAD as j,SHEET_TITLE as w,hasContent as b}from"../../internal/scale.js";import{MPStateLayer as y}from"../../internal/StateLayer.js";import{FADE as N,PORTAL_LAYER as S}from"../../internal/surface.js";import{VISUALLY_HIDDEN as k}from"../../internal/visually-hidden.js";const $={xs:"max-w-56",sm:"max-w-64",md:"max-w-80",lg:"max-w-96",xl:"max-w-md"},_={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};function B({spot:t,className:n,holeRef:o}){return e("div",null===t?{"aria-hidden":"true",className:["mp-tour__scrim bg-mp-scrim/32 pointer-events-none fixed inset-0 z-40",n??""].filter(Boolean).join(" ")}:{ref:o,"aria-hidden":"true",className:["mp-tour__scrim rounded-mp-xs pointer-events-none fixed z-40","shadow-[0_0_0_9999px_color-mix(in_oklab,var(--_mp-color-scrim)_32%,transparent)]","transition-[top,left,width,height] duration-(--mp-sys-motion-duration-medium1)","ease-mp-standard motion-reduce:transition-none",n??""].filter(Boolean).join(" "),style:{top:t.top,left:t.left,width:t.width,height:t.height}})}export function MPTour({steps:z,open:C,defaultOpen:R=!1,onOpenChange:M,step:P,defaultStep:O=0,onStepChange:q,onFinish:E,scrim:F=!0,skippable:I=!0,dismissible:T=!0,scrollIntoView:A=!0,locale:D,labels:H,size:L,color:V,className:W,style:G,classNames:J}){const K=c(L),Q=a(V),U=p(D),X=u(f,U,H),Y=u(d,U),[Z,ee]=n.useState(R),[te,ne]=n.useState(O),oe=C??Z,ie=Math.min(P??te,Math.max(0,z.length-1)),re=z[ie],[se,le]=n.useState(null),ae=n.useRef(null),[ce,me]=n.useState(""),pe=n.useRef(ie);n.useEffect(()=>{if(!oe)return pe.current=ie,void me("");if(pe.current===ie)return;pe.current=ie;const e=m(X.position,{index:String(ie+1),total:String(z.length)}),t=z[ie]?.title;me("string"==typeof t&&""!==t?`${e}. ${t}`:e)},[oe,ie,z,X.position]);const ue=e=>{void 0===C&&ee(e),M?.(e)},de=e=>{void 0===P&&ne(e),q?.(e)},fe=re?.target,he=re?.padding??6;if(n.useEffect(()=>{if(!oe||!fe)return;const e=document.querySelector(fe);if(!(e instanceof HTMLElement))return;A&&e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"});let t=0,n="",o=!1;const i=()=>{const r=e.getBoundingClientRect(),s=`${r.top} ${r.left} ${r.width} ${r.height}`;if(s!==n){n=s;const e={top:r.top-he,left:r.left-he,width:r.width+2*he,height:r.height+2*he},t=ae.current;o&&t?(t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`):(o=!0,le({selector:fe,spot:e}))}t=requestAnimationFrame(i)};return i(),()=>cancelAnimationFrame(t)},[oe,fe,he,A]),0===z.length)return null;const ge=oe&&fe&&se?.selector===fe?se.spot:null,xe=0===ie,ve=ie===z.length-1,je=_[K],we=b(re?.title)||b(re?.content);return t(o.Root,{open:oe,onOpenChange:(e,t)=>{e?ue(!0):"outside-press"===t.reason||"focus-out"===t.reason||"escape-key"===t.reason&&!T?t.cancel():ue(!1)},children:[oe&&F?e(B,{spot:ge,className:J?.scrim,holeRef:ae}):null,e(o.Portal,{children:e(o.Positioner,{className:S,side:re?.side??"bottom",align:re?.align??"center",sideOffset:fe?10:0,collisionPadding:12,anchor:()=>fe?document.querySelector(fe):{getBoundingClientRect:()=>new DOMRect(window.innerWidth/2,window.innerHeight/2,0,0)},children:t(o.Popup,{"data-mp-size":K,className:["mp-tour rounded-mp-md relative box-border flex flex-col outline-none","bg-mp-surface-container text-mp-on-surface shadow-mp-3",j[K],v[K],x[K],$[K],N,W??""].filter(Boolean).join(" "),style:{...l(Q),...G},children:[we?t("div",{className:"flex items-start gap-3",children:[t("div",{className:"flex min-w-0 flex-1 flex-col gap-1",children:[b(re?.title)?e(o.Title,{className:["text-mp-on-surface m-0 font-medium",w[K],J?.title??""].filter(Boolean).join(" "),children:re?.title}):null,b(re?.content)?e(o.Description,{className:["text-mp-on-surface-variant m-0 min-w-0",J?.content??""].filter(Boolean).join(" "),children:re?.content}):null]}),T?t("button",{type:"button","aria-label":Y.close,onClick:()=>ue(!1),className:["group/close rounded-mp-full text-mp-on-surface-variant relative -me-1 -mt-1","flex size-8 shrink-0 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none",J?.close??""].filter(Boolean).join(" "),children:[e(y,{className:"group-hover/close:opacity-8 group-focus-visible/close:opacity-10"}),e(r,{icon:s,size:h[K]})]}):null]}):null,e("span",{className:k,"aria-live":"polite",children:ce}),t("div",{className:["flex items-center gap-2",J?.footer??""].filter(Boolean).join(" "),children:[e("span",{className:`text-mp-on-surface-variant shrink-0 tabular-nums ${g}`,children:m(X.position,{index:String(ie+1),total:String(z.length)})}),t("div",{className:"ms-auto flex items-center gap-1",children:[I&&!ve?e(i,{size:je,variant:"text",color:"secondary",onClick:()=>ue(!1),children:X.skip}):null,xe?null:e(i,{size:je,variant:"outlined",color:Q,onClick:()=>de(ie-1),children:X.previous}),e(i,{size:je,color:Q,onClick:()=>ve?(E?.(),void ue(!1)):de(ie+1),children:ve?X.done:X.next})]})]})]})})})]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{MPBox as l}from"../box/MPBox.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as s}from"../icon/MPIcon.js";import{MPIconButton as i}from"../icon-button/MPIconButton.js";import{MPTextField as n}from"../text-field/MPTextField.js";import{ArrowRightIcon as o}from"../../constants/icons.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{cssLength as d}from"../../internal/length.js";import{TRANSFER as u}from"../../internal/messages/transfer.js";import{fillMessage as h}from"../../internal/i18n.js";import{VISUALLY_HIDDEN as f}from"../../internal/visually-hidden.js";import{useMPColor as p,useMPSize as v}from"../../internal/config.js";import{hasContent as g,META_TEXT as b,SHEET_PAD_X as x}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{MPBox as l}from"../box/MPBox.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as s}from"../icon/MPIcon.js";import{MPIconButton as i}from"../icon-button/MPIconButton.js";import{MPTextField as n}from"../text-field/MPTextField.js";import{ArrowRightIcon as o}from"../../constants/icons.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{cssLength as d}from"../../internal/length.js";import{TRANSFER as u}from"../../internal/messages/transfer.js";import{fillMessage as h}from"../../internal/i18n.js";import{VISUALLY_HIDDEN as f}from"../../internal/visually-hidden.js";import{useMPColor as p,useMPSize as v}from"../../internal/config.js";import{hasContent as g,META_TEXT as b,SHEET_PAD_X as x}from"../../internal/scale.js";import{occurrenceKeys as w}from"../../internal/occurrence.js";const j={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},k={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"},S=new Set;function y({title:s,rows:i,total:o,ticked:c,arrived:m,onTick:d,onTickAll:u,search:h,onSearch:f,searchable:p,disabled:v,height:g,messages:S,variant:y,size:N,color:T}){const z=i.filter(e=>!e.disabled),C=t.useMemo(()=>w(i,e=>e.value),[i]),M=z.filter(e=>c.has(e.value)),_=z.length>0&&M.length===z.length,$=M.length>0&&!_,P=x[N],B=t.useId();return a(l,{variant:y,size:N,padded:!1,className:"mp-transfer__panel flex min-w-0 flex-col overflow-hidden",children:[a("div",{className:["mp-transfer__heading border-mp-outline-variant flex items-center gap-2 border-b",P,j[N]].join(" "),children:[e("div",{className:"min-w-0 flex-1",children:e(r,{size:N,color:T,checked:_,indeterminate:$,disabled:v||0===z.length,label:e("span",{id:B,className:"block truncate font-medium",children:s}),onCheckedChange:e=>u(e)})}),a("span",{className:`text-mp-on-surface-variant shrink-0 tabular-nums ${b}`,children:[M.length,"/",o]})]}),p?e("div",{className:`${P} ${j[N]}`,children:e(n,{size:N,fullWidth:!0,disabled:v,placeholder:S.search,"aria-label":S.search,value:h,onChange:f})}):null,e("div",{role:"group","aria-labelledby":B,className:`mp-transfer__list flex flex-col overflow-y-auto overscroll-contain ${P} ${j[N]}`,style:{height:g},children:0===i.length?e("span",{className:`text-mp-on-surface-variant ${b} ${k[N]}`,children:S.empty}):i.map(a=>e("div",{className:[k[N],m.has(a.value)?"mp-row-arrive":""].filter(Boolean).join(" "),children:e(r,{size:N,color:T,label:a.label,checked:c.has(a.value),disabled:v||a.disabled,onCheckedChange:e=>d(a.value,e)})},C.get(a)))})]})}function N(e,a){if(""===a)return e;const t=a.toLowerCase();return e.filter(e=>"string"!=typeof e.label||e.label.toLowerCase().includes(t))}export const MPTransfer=/*@__PURE__*/t.forwardRef(function({items:l,value:r,defaultValue:n,onValueChange:b,sourceLabel:x,targetLabel:w,searchable:j=!1,height:k=220,disabled:T=!1,variant:z="outlined",size:C,color:M,locale:_,labels:$,className:P,...B},L){const A=v(C),I=p(M),V=c(_),E=m(u,V,$),[F,R]=t.useState(n??[]),W=r??F,[q,D]=t.useState(()=>new Set),[G,H]=t.useState(()=>({values:new Set,toTarget:!0})),[J,K]=t.useState(""),[O,Q]=t.useState(""),[U,X]=t.useState(null),Y=t.useMemo(()=>new Set(W),[W]),Z=l.filter(e=>!Y.has(e.value)),ee=l.filter(e=>Y.has(e.value));t.useEffect(()=>{const e=new Set(l.map(e=>e.value));D(a=>{const t=[...a].filter(a=>e.has(a));return t.length===a.size?a:new Set(t)})},[l]);const ae=(e,a)=>{D(t=>{const l=new Set(t);return a?l.add(e):l.delete(e),l})},te=(e,a)=>{D(t=>{const l=new Set(t);for(const t of e)t.disabled||(a?l.add(t.value):l.delete(t.value));return l})},le=(e,a)=>{const t=e.filter(e=>!e.disabled&&q.has(e.value));if(0===t.length)return;const s=new Set(t.map(e=>e.value)),i=a?l.filter(e=>Y.has(e.value)||s.has(e.value)).map(e=>e.value):W.filter(e=>!s.has(e));D(e=>new Set([...e].filter(e=>!s.has(e)))),H({values:s,toTarget:a}),X(e=>{return{tick:(e?.tick??0)+1,text:h(E.moved,{count:String(t.length),list:(l=a?w:x,r=a?E.target:E.source,"string"==typeof l&&""!==l?l:r)})};var l,r}),(e=>{void 0===r&&R(e),b?.(e)})(i)},re=N(Z,J),se=N(ee,O),ie=re.some(e=>!e.disabled&&q.has(e.value)),ne=se.some(e=>!e.disabled&&q.has(e.value)),oe=d(k),ce={ticked:q,disabled:T,height:oe,messages:E,variant:z,size:A,color:I,searchable:j};return a("div",{ref:L,"data-mp-size":A,className:["mp-transfer grid w-full items-center gap-3","[grid-template-columns:minmax(0,1fr)]","mp-medium:[grid-template-columns:minmax(0,1fr)_auto_minmax(0,1fr)]",P??""].filter(Boolean).join(" "),...B,children:[e(y,{...ce,title:g(x)?x:E.source,rows:re,total:Z.length,arrived:G.toTarget?S:G.values,onTick:ae,onTickAll:e=>te(re,e),search:J,onSearch:K}),a("div",{className:"flex flex-row justify-center gap-2 mp-medium:flex-col",children:[e(i,{size:A,color:I,variant:"text"===z?"text":"outlined",label:E.toTarget,disabled:T||!ie,onClick:()=>le(re,!0),icon:e(s,{icon:o,className:"rotate-90 mp-medium:rotate-0"})}),e(i,{size:A,color:I,variant:"text"===z?"text":"outlined",label:E.toSource,disabled:T||!ne,onClick:()=>le(se,!1),icon:e(s,{icon:o,className:"-rotate-90 mp-medium:rotate-180"})})]}),e("span",{className:f,"aria-live":"polite","aria-atomic":"true",children:U?e("span",{children:U.text},U.tick):null}),e(y,{...ce,title:g(w)?w:E.target,rows:se,total:ee.length,arrived:G.toTarget?G.values:S,onTick:ae,onTickAll:e=>te(se,e),search:O,onSearch:Q})]})});
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { type MPTreeViewValue } from '../tree-view/MPTreeView.js';
|
|
3
3
|
import { type MPPickerShellProps } from '../../internal/Picker.js';
|
|
4
4
|
import type { MPPickerLabels } from '../../internal/Calendar.js';
|
|
5
|
-
import type { MPSlots } from '../../types.js';
|
|
5
|
+
import type { MPColor, MPSlots } from '../../types.js';
|
|
6
6
|
/** One node of the tree the reader is choosing from. */
|
|
7
7
|
export interface MPTreeSelectItem {
|
|
8
8
|
/** What is stored when this node is chosen. Unique across the whole tree. */
|
|
@@ -24,7 +24,17 @@ export interface MPTreeSelectItem {
|
|
|
24
24
|
}
|
|
25
25
|
/** The parts an `MPTreeSelect` draws that a `className` cannot reach. */
|
|
26
26
|
export type MPTreeSelectSlot = 'popup' | 'tree' | 'item' | 'empty';
|
|
27
|
-
export interface MPTreeSelectProps extends MPPickerShellProps {
|
|
27
|
+
export interface MPTreeSelectProps extends Omit<MPPickerShellProps, 'color'> {
|
|
28
|
+
/**
|
|
29
|
+
* Has no visible effect, and is kept only so code that passes it still
|
|
30
|
+
* compiles.
|
|
31
|
+
*
|
|
32
|
+
* The pickers share this prop for a calendar's chosen day and a range's band,
|
|
33
|
+
* and a tree has neither. A chosen row is `secondary-container`, as an
|
|
34
|
+
* `MPSelect`'s chosen option is.
|
|
35
|
+
* @deprecated No effect. It is due to be removed in the next major version.
|
|
36
|
+
*/
|
|
37
|
+
color?: MPColor;
|
|
28
38
|
/** The tree, as nested items. */
|
|
29
39
|
items?: MPTreeSelectItem[];
|
|
30
40
|
/** The chosen value, or values when `multiple`. */
|