material-plus-ui 1.4.0 → 1.6.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/.fix.py +92 -0
- package/README.md +1 -1
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.js +1 -1
- package/dist/components/badge/MPBadge.js +1 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +17 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.d.ts +49 -3
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.d.ts +160 -0
- package/dist/components/calendar/MPCalendar.js +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/MPCard.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/checkbox/MPCheckbox.d.ts +6 -0
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +21 -6
- package/dist/components/chip/MPChip.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 +52 -3
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +1 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +124 -0
- package/dist/components/config/MPConfigProvider.js +2 -0
- package/dist/components/config/index.d.ts +2 -0
- package/dist/components/config/index.js +1 -0
- package/dist/components/confirm/MPConfirmProvider.d.ts +143 -0
- package/dist/components/confirm/MPConfirmProvider.js +2 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-picker/MPDatePicker.d.ts +53 -2
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +16 -3
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/empty/MPEmpty.js +1 -1
- package/dist/components/file-picker/MPFilePicker.d.ts +6 -0
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.js +1 -1
- package/dist/components/grid/MPGrid.d.ts +23 -1
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/image/MPImage.d.ts +112 -0
- package/dist/components/image/MPImage.js +2 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/list/MPList.d.ts +28 -0
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +25 -4
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.d.ts +8 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +8 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +9 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +1 -1
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +92 -0
- package/dist/components/popconfirm/MPPopconfirm.js +2 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +1 -1
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.d.ts +12 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.d.ts +7 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +9 -2
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +33 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +20 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/spoiler/MPSpoiler.js +1 -1
- package/dist/components/stepper/MPStepper.d.ts +153 -0
- package/dist/components/stepper/MPStepper.js +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/index.js +1 -0
- package/dist/components/switch/MPSwitch.d.ts +6 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +1 -1
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +46 -14
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline/MPTimeline.d.ts +10 -2
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/typography/MPTypography.d.ts +7 -0
- package/dist/components/typography/MPTypography.js +1 -2
- package/dist/components/visually-hidden/MPVisuallyHidden.d.ts +60 -0
- package/dist/components/visually-hidden/MPVisuallyHidden.js +2 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/constants/glyphs.d.ts +2 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +1 -0
- package/dist/constants/icons.js +1 -1
- package/dist/hooks/index.d.ts +23 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +135 -0
- package/dist/hooks/useMPColorScheme.js +1 -0
- package/dist/hooks/useMPReducedMotion.d.ts +32 -0
- package/dist/hooks/useMPReducedMotion.js +1 -0
- package/dist/hooks/useMPShortcut.d.ts +105 -0
- package/dist/hooks/useMPShortcut.js +2 -0
- package/dist/hooks/useMPWindowClass.d.ts +48 -0
- package/dist/hooks/useMPWindowClass.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +19 -4
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/Picker.d.ts +15 -3
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/color-scheme.d.ts +28 -0
- package/dist/internal/color-scheme.js +2 -0
- package/dist/internal/config.d.ts +43 -0
- package/dist/internal/config.js +2 -0
- package/dist/internal/date.d.ts +50 -3
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +26 -1
- package/dist/internal/messages/confirm.d.ts +3 -0
- package/dist/internal/messages/confirm.js +1 -0
- package/dist/internal/messages/picker.js +1 -1
- package/dist/internal/progress.d.ts +14 -0
- package/dist/internal/step.d.ts +71 -0
- package/dist/internal/step.js +1 -0
- package/dist/internal/window-class.d.ts +21 -0
- package/dist/internal/window-class.js +2 -0
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/animate-lighting.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/calendar.css +2 -0
- package/dist/styles/chip.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/config.css +2 -0
- package/dist/styles/confirm.css +2 -0
- package/dist/styles/grid.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/image.css +2 -0
- package/dist/styles/list.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/popconfirm.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/rating.css +1 -1
- package/dist/styles/shortcut.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/stepper.css +2 -0
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/visually-hidden.css +2 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +91 -5
- package/dist/types.d.ts +64 -0
- package/package.json +6 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as r}from"../../constants/icons.js";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as x,SHEET_PAD_X as h,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as r}from"../../constants/icons.js";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as x,SHEET_PAD_X as h,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as j,SCRIM as v,SHEET_MOTION as w}from"../../internal/surface.js";import{useMPSize as $}from"../../internal/config.js";const N={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},C={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},k={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},z={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},P={left:"motion-safe:data-starting-style:-translate-x-full motion-safe:data-ending-style:-translate-x-full",right:"motion-safe:data-starting-style:translate-x-full motion-safe:data-ending-style:translate-x-full",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"},B=`transition-[opacity,translate] ${w}`,D="border-mp-outline-variant border-t";export const MPDrawerClose=o.Close;export function MPDrawer({side:w="left",mode:O="modal",open:M,defaultOpen:L,onOpenChange:S,trigger:T,title:F,description:I,actions:R,dividers:V=!1,showClose:q,closeLabel:A,locale:E,extent:G,rounded:H=!0,dismissible:J=!0,size:K,className:Q,style:U,children:W}){const X=$(K),Y=i(E),Z=s(d,Y),_="modal"===O,ee="left"===w||"right"===w,te=q??_,le=A??Z.close,[ae,oe]=a.useState(L??!0),ne=M??ae,re=h[X],ie=g[X],se=V?`${re} ${ie}`:re,de=c(F)||c(I),me=c(R),fe=void 0===G?null:{[ee?"width":"height"]:f(G)},ce=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",_?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",u[X],k[w],H?C[w]:"",_?`${B} ${P[w]}`:"",ee?`h-full max-w-full ${void 0===G?N[X]:""}`:"w-full "+(void 0===G?"max-h-[85%]":""),V?"":`${ie} ${x[X]}`,Q??""].filter(Boolean).join(" "),pe=_?o.Title:"h2",ue=_?o.Description:"p",xe=/*@__PURE__*/["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),he=t(l,{children:[de||te?t("div",{className:`flex shrink-0 items-start gap-3 ${se}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(F)?e(pe,{className:`m-0 ${b[X]}`,children:F}):null,c(I)?e(ue,{className:`text-mp-on-surface-variant m-0 ${p}`,children:I}):null]}),te?_?t(o.Close,{"aria-label":le,className:xe,children:[e(m,{}),e(n,{icon:r,size:20})]}):t("button",{type:"button","aria-label":le,className:xe,onClick:()=>{void 0===M&&oe(!1),S?.(!1)},children:[e(m,{}),e(n,{icon:r,size:20})]}):null]}):null,c(W)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",se,V&&(de||te)?D:"",V?"":"-my-1 py-1"].filter(Boolean).join(" "),children:W}):null,me?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",se,V?D:""].filter(Boolean).join(" "),children:R}):null]});return _?t(o.Root,{open:M,defaultOpen:L,disablePointerDismissal:!J,onOpenChange:(e,t)=>{J||e||"escape-key"!==t.reason?S?.(e):t.cancel()},children:[T?e(o.Trigger,{render:T}):null,t(o.Portal,{children:[e(o.Backdrop,{className:`${j} fixed inset-0 ${y} ${v}`}),e(o.Viewport,{className:`${j} fixed inset-0 flex ${z[w]}`,children:e(o.Popup,{"data-mp-size":X,"data-mp-side":w,"data-mp-mode":O,className:ce,style:{...fe,...U},children:he})})]})]}):ne?e("div",{"data-mp-size":X,"data-mp-side":w,"data-mp-mode":O,className:ce,style:{...fe,...U},children:he}):null}
|
|
@@ -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
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as s}from"@base-ui/react/use-render";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{EMPTY as i}from"../../internal/messages/empty.js";import{hasContent as o,PROSE_TEXT as m,SHEET_GAP as c,SHEET_PAD_X as d,SHEET_TITLE as p}from"../../internal/scale.js";import{CONTAINER_SURFACE as f}from"../../internal/surface.js";import{useMPSize as x}from"../../internal/config.js";const u={xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},h={xs:"text-[1.5rem]",sm:"text-[1.75rem]",md:"text-[2.25rem]",lg:"text-[2.75rem]",xl:"text-[3.25rem]"};function v(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-[1em]",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const MPEmpty=/*@__PURE__*/n.forwardRef(function({variant:n="text",size:j,title:y,icon:g,action:N,locale:k,render:w,className:z,style:$,children:L,...B},C){const M=x(j),W=a(k),b=l(i,W),E=void 0===y?b.title:y,F=void 0===g?e(v,{}):g,P=o(E),R=["mp-empty flex w-full flex-col items-center justify-center text-center",d[M],u[M],"text"===n?"":"rounded-mp-md",c[M],f[n],"text-mp-on-surface",z??""].filter(Boolean).join(" ");return s({render:w,ref:C,props:{role:"status","data-mp-size":M,"data-mp-variant":n,className:R,style:$,children:t(r,{children:[o(F)?e("span",{className:`text-mp-on-surface-variant flex items-center ${h[M]} [&>svg]:size-[1em]`,children:F}):null,P||o(L)?t("div",{className:`flex max-w-prose flex-col items-center ${c[M]}`,children:[P?e("div",{className:p[M],children:E}):null,o(L)?e("div",{className:`${m[M]} ${P?"text-mp-on-surface-variant":""}`,children:L}):null]}):null,o(N)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:N}):null]}),...B}})});
|
|
@@ -83,6 +83,12 @@ export interface MPFilePickerProps extends MPStyleProps {
|
|
|
83
83
|
name?: string;
|
|
84
84
|
/** The id put on the browse button. */
|
|
85
85
|
id?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Added to the picker's outermost element — the box around the label, the drop
|
|
88
|
+
* zone and the list of files that have been chosen.
|
|
89
|
+
*/
|
|
90
|
+
className?: string;
|
|
91
|
+
style?: React.CSSProperties;
|
|
86
92
|
}
|
|
87
93
|
/**
|
|
88
94
|
* A box you drop files on, or click to open the file dialog.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as l}from"../../internal/i18n.js";import{useMPLocale as o,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as m}from"../../internal/messages/file-picker.js";import{MPStateLayer as p}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as d,PROSE_TEXT as f,STACK_GAP as h,hasContent as x}from"../../internal/scale.js";import{useMPSize as b}from"../../internal/config.js";const v={xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"};export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function g(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(e.slice(0,-1)):t===e)}export const MPFilePicker=/*@__PURE__*/n.forwardRef(function({accept:j,multiple:y=!1,maxSize:N,maxFiles:k,value:z,defaultValue:w,onFilesChange:C,onReject:I,label:B,description:D,errorMessage:F,title:L,hint:M,icon:S,showList:$=!0,removeLabel:T,locale:W,size:_,fullWidth:P=!0,required:R=!1,disabled:E=!1,readOnly:O=!1,name:q,id:A,className:V,style:G},H){const Y=b(_),J=o(W),K=s(c,J),Q=s(m,J),U=n.useRef(null);n.useImperativeHandle(H,()=>U.current,[]);const[X,Z]=n.useState(()=>[...w??[]]),ee=z?[...z]:X,re=n.useRef(0),[ne,te]=n.useState(!1),ae=x(F),ie=E||O,le=n.useId(),oe=n.useId(),se=n.useCallback(e=>{z||Z(e),C?.(e)},[C,z]),ce=n.useCallback(e=>{const r=[],n=[],t=y?k??Number.POSITIVE_INFINITY:1,a=y?ee.length:0;for(const i of e)j&&!g(i,j)?n.push({file:i,reason:"type"}):void 0!==N&&i.size>N?n.push({file:i,reason:"size"}):a+r.length>=t?n.push({file:i,reason:"count"}):r.push(i);return{kept:r,rejections:n}},[j,ee.length,k,N,y]),me=n.useCallback(e=>{const{kept:r,rejections:n}=ce(e);n.length>0&&I?.(n),r.length>0&&se(y?[...ee,...r]:r)},[ce,se,ee,y,I]);return r("div",{className:["mp-file-picker flex-col align-top",h[Y],P?"flex w-full":"inline-flex",V??""].filter(Boolean).join(" "),style:G,"data-mp-size":Y,"data-disabled":E||void 0,"data-invalid":ae||void 0,children:[x(B)?r("span",{id:oe,className:[d,E?"text-mp-on-surface/38":ae?"text-mp-error":"text-mp-on-surface-variant"].join(" "),children:[B,R?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,r("div",{className:"relative flex w-full flex-col",onDragEnter:e=>{ie||(e.preventDefault(),re.current+=1,te(!0))},onDragOver:e=>{ie||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{ie||(re.current=Math.max(0,re.current-1),0===re.current&&te(!1))},onDrop:e=>{ie||(e.preventDefault(),re.current=0,te(!1),me(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:A,disabled:E,"aria-describedby":x(D)||ae?le:void 0,"aria-invalid":ae||void 0,className:["mp-file-picker__zone group relative flex w-full flex-col items-center","justify-center gap-2 text-center","rounded-mp-md box-border border-2 border-dashed","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color,background-color] duration-(--mp-sys-motion-duration-short4)",v[Y],f[Y],E?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":[O?"cursor-default":"cursor-pointer",ae?"border-mp-error":"border-mp-outline-variant","text-mp-on-surface",ne?"border-mp-primary bg-mp-primary/8":""].filter(Boolean).join(" ")].filter(Boolean).join(" "),onClick:()=>{!ie&&U.current&&(U.current.value="",U.current.click())},children:[ie?null:e(p,{layer:"inset-0 rounded-[inherit] bg-mp-primary"}),void 0===S?e(t,{icon:i,size:1.6*u[Y],className:E?"":"text-mp-primary"}):x(S)?e("span",{className:E?"":"text-mp-primary",children:S}):null,e("span",{className:"font-medium",children:L??Q.prompt}),x(M)?e("span",{className:[d,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null]}),e("input",{ref:U,type:"file",name:q,accept:j,multiple:y,required:R&&0===ee.length,disabled:ie,tabIndex:-1,"aria-labelledby":x(B)?oe:void 0,"aria-describedby":x(D)||ae?le:void 0,className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>me(Array.from(e.target.files??[]))})]}),$&&ee.length>0?e("ul",{className:["mp-file-picker__list m-0 flex w-full list-none flex-col p-0",h[Y]].join(" "),children:ee.map((n,i)=>r("li",{className:["rounded-mp-xs bg-mp-surface-container-low flex w-full items-center gap-3","px-3 py-2",f[Y],E?"text-mp-on-surface/38":"text-mp-on-surface"].join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:[d,"shrink-0 tabular-nums",E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:formatFileSize(n.size)}),ie?null:r("button",{type:"button","aria-label":T?T(n.name):l(K.removeNamed,{label:n.name}),className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","cursor-pointer appearance-none items-center justify-center rounded-full","bg-transparent p-0 font-[inherit] outline-none"].join(" "),onClick:()=>se(ee.filter((e,r)=>r!==i)),children:[e(p,{}),e(t,{icon:a,size:18})]})]},`${n.name}-${n.size}-${n.lastModified}-${i}`))}):null,ae?e("span",{id:le,className:[d,"text-mp-error"].join(" "),children:F}):x(D)?e("span",{id:le,className:[d,E?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:D}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as n from"react";import{Button as o}from"@base-ui/react/button";import{accentSlots as a}from"../../internal/accent.js";import{cssLength as i}from"../../internal/length.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{hasContent as r}from"../../internal/scale.js";import{useMPColor as m,useMPSize as l}from"../../internal/config.js";const p={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"bg-mp-surface-container-high text-(--_mp-accent)"},d={xs:"h-10",sm:"h-12",md:"h-14",lg:"h-18",xl:"h-24"},f={xs:"min-w-10 gap-0 px-0",sm:"min-w-12 gap-0 px-0",md:"min-w-14 gap-0 px-0",lg:"min-w-18 gap-0 px-0",xl:"min-w-24 gap-0 px-0"},c={xs:"rounded-mp-md",sm:"rounded-mp-lg",md:"rounded-mp-lg",lg:"rounded-mp-xl",xl:"rounded-mp-xl"},x={xs:24,sm:24,md:24,lg:30,xl:36},u={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"},g={xs:"min-w-16 gap-1.5 px-3",sm:"min-w-18 gap-2 px-4",md:"min-w-20 gap-2 px-4",lg:"min-w-24 gap-2.5 px-5",xl:"min-w-28 gap-3 px-6"},b={absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},h={"top-start":"top-(--_mp-fab-offset) start-(--_mp-fab-offset)","top-end":"top-(--_mp-fab-offset) end-(--_mp-fab-offset)","bottom-start":"bottom-(--_mp-fab-offset) start-(--_mp-fab-offset)","bottom-end":"bottom-(--_mp-fab-offset) end-(--_mp-fab-offset)"};export const MPFloatingActionButton=/*@__PURE__*/n.forwardRef(function({icon:n,label:w,extended:_=!1,variant:y="tonal",color:j,size:v,position:k="fixed",corner:z="bottom-end",offset:N=16,disabled:B=!1,type:$="button",className:A,style:F,...L},M){const P=m(j),R=l(v);return e(o,{ref:M,type:$,disabled:B,"aria-label":w,"data-mp-size":R,"data-mp-variant":y,className:["mp-fab group inline-flex shrink-0 items-center justify-center","box-border overflow-hidden align-middle whitespace-nowrap select-none","cursor-pointer appearance-none font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-[background-color,box-shadow,color,min-width,padding,gap]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",c[R],d[R],u[R],_?g[R]:f[R],B?"bg-mp-on-surface/12 text-mp-on-surface/38 cursor-default shadow-none":`${p[y]} shadow-mp-3`,"static"===k?"relative":`${b[k]} ${h[z]}`,A??""].filter(Boolean).join(" "),style:{...a(P),"--_mp-fab-offset":i(N),...F},...L,children:[B?null:t(s,{}),r(n)?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:x[R],height:x[R]},children:n}):null,t("span",{className:["relative grid transition-[grid-template-columns]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",_?"grid-cols-[1fr]":"grid-cols-[0fr]"].join(" "),children:t("span",{className:"min-w-0 truncate",children:w})})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{useRender as o}from"@base-ui/react/use-render";import{BAR_SURFACE as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{MEASURE as i,SHEET_PAD_X as n,SHEET_PAD_Y as s}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as t from"react";import{useRender as o}from"@base-ui/react/use-render";import{BAR_SURFACE as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{MEASURE as i,SHEET_PAD_X as n,SHEET_PAD_Y as s}from"../../internal/scale.js";import{useMPSize as l}from"../../internal/config.js";const m={static:"",absolute:"absolute inset-x-0 bottom-0 z-30",sticky:"sticky bottom-0 z-30",fixed:"fixed inset-x-0 bottom-0 z-40"};export const MPFooter=/*@__PURE__*/t.forwardRef(function({position:f="static",variant:c="outlined",size:d,maxWidth:p="none",padded:u=!0,label:b,render:x,className:j,children:z,...h},v){const w=l(d),{register:y}=t.useContext(a),g=t.useCallback(e=>{y("footer",e),"function"==typeof v?v(e):v&&(v.current=e)},[y,v]);return o({render:x??e("footer",{}),ref:g,props:{"aria-label":b,"data-mp-size":w,"data-mp-variant":c,className:["mp-footer text-mp-on-surface box-border w-full min-w-0",r[c],"outlined"===c?"border-mp-outline-variant border-t":"",m[f],j??""].filter(Boolean).join(" "),children:e("div",{className:["mp-footer__inner w-full",u?`${n[w]} ${s[w]}`:"","none"===p?"":`${i[p]} mx-auto`].filter(Boolean).join(" "),children:z}),...h}})});
|
|
@@ -14,6 +14,20 @@ export type MPGridJustify = 'start' | 'center' | 'end' | 'space-between' | 'spac
|
|
|
14
14
|
export type MPGridAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
15
15
|
/** The same, for one item overriding the row it is in. */
|
|
16
16
|
export type MPGridAlignSelf = MPGridAlign | 'auto';
|
|
17
|
+
/**
|
|
18
|
+
* How wide one item is: a number of the grid's columns, or `'grow'`.
|
|
19
|
+
*
|
|
20
|
+
* `'grow'` is the one value that is not a measurement. It is "whatever the row
|
|
21
|
+
* has left after everybody else has taken theirs", which is the width a
|
|
22
|
+
* thumbnail's neighbour wants and the one thing a twelve-column arithmetic
|
|
23
|
+
* cannot express — the remainder is only known once the other items in *that*
|
|
24
|
+
* row have been laid out, and no `span` a caller writes down knows what else is
|
|
25
|
+
* in the row.
|
|
26
|
+
*
|
|
27
|
+
* Two growing items in a row split the remainder equally rather than by their
|
|
28
|
+
* contents, which is the useful half of what makes it predictable.
|
|
29
|
+
*/
|
|
30
|
+
export type MPGridSpan = number | 'grow';
|
|
17
31
|
export interface MPGridProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
18
32
|
/**
|
|
19
33
|
* How many columns a row is divided into. Every `span` and every `offset`
|
|
@@ -74,9 +88,17 @@ export interface MPGridItemProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
74
88
|
* own window class up, so two of them usually describe a whole layout.
|
|
75
89
|
*
|
|
76
90
|
* A span wider than the row is clamped to the row rather than overflowing.
|
|
91
|
+
*
|
|
92
|
+
* `span="grow"` is the exception to all of the above: it takes the width the
|
|
93
|
+
* row has left rather than a share of it, which is the layout a thumbnail
|
|
94
|
+
* beside a body of text wants — `<MPGridItem span={3}>` for the picture and
|
|
95
|
+
* `<MPGridItem span="grow">` for the words, with no arithmetic to keep in step
|
|
96
|
+
* when the picture's column count changes. It is responsive like any other
|
|
97
|
+
* value: `span={{ compact: 12, medium: 'grow' }}` stacks on a phone and fills
|
|
98
|
+
* the rest of the row from 600dp.
|
|
77
99
|
* @default the grid's full width
|
|
78
100
|
*/
|
|
79
|
-
span?: MPResponsive<
|
|
101
|
+
span?: MPResponsive<MPGridSpan>;
|
|
80
102
|
/**
|
|
81
103
|
* Columns left empty *before* the item — space pushed in ahead of it, not an
|
|
82
104
|
* absolute position in the row. First in a twelve-column row, `offset={4}` with
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";
|
|
2
|
+
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";import{WINDOW_CLASSES as n}from"../../internal/window-class.js";function r(e){return null==e?{}:"object"==typeof e?e:{compact:e}}function o(e,t,o){const s=r(t),a={};for(const t of n){const n=s[t];void 0!==n&&(a[`--_mp-${e}-${t}`]=o(n))}return a}function s(e,t){return null==e?t:"object"==typeof e?{compact:t,...e}:e}function a(e){return String(Math.max(1,Math.round(e)))}function c(e){return String(Math.max(1,Math.round(e)))}function i(e){const t=r(e),o=Object.values(t).some(e=>"grow"===e),s={};for(const e of n){const n=t[e];void 0!==n&&("grow"!==n&&(s[`--_mp-span-${e}`]=c(n)),o&&(s[`--_mp-grow-${e}`]="grow"===n?"1":"0"))}return s}function f(e){return String(Math.max(0,Math.round(e)))}function l(e){const t=.25*Math.max(0,e);return`${Number(t.toFixed(5))}rem`}const u={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between","space-around":"justify-around","space-evenly":"justify-evenly"},p={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch",baseline:"items-baseline"},m={start:"content-start",center:"content-center",end:"content-end","space-between":"content-between","space-around":"content-around","space-evenly":"content-evenly",stretch:"content-stretch"},d={auto:"self-auto",start:"self-start",center:"self-center",end:"self-end",stretch:"self-stretch",baseline:"self-baseline"};export const MPGrid=/*@__PURE__*/e.forwardRef(function({columns:e,spacing:n,rowSpacing:r,columnSpacing:c,justifyContent:i,alignItems:f,alignContent:d,wrap:g=!0,render:y,className:h,style:w,children:b,...j},x){return t({render:y,ref:x,props:{className:["mp-grid flex",g?"flex-wrap":"flex-nowrap","gap-x-(--_mp-gap-x) gap-y-(--_mp-gap-y)",i?u[i]:"",f?p[f]:"",d?m[d]:"",h??""].filter(Boolean).join(" "),style:{...o("cols",s(e,12),a),...o("gap-x",s(c??n,4),l),...o("gap-y",s(r??n,4),l),...w},children:b,...j}})});export const MPGridItem=/*@__PURE__*/e.forwardRef(function({span:e,offset:n,alignSelf:r,render:s,className:a,style:c,children:l,...u},p){return t({render:s,ref:p,props:{className:["mp-grid-item",r?d[r]:"",a??""].filter(Boolean).join(" "),style:{...i(e),...o("offset",n,f),...c},children:l,...u}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{useRender as i}from"@base-ui/react/use-render";import{BAR_SURFACE as n,MPPageLayoutContext as r}from"../../internal/page-layout.js";import{hasContent as s,MEASURE as l,SHEET_PAD_X as m}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{useRender as i}from"@base-ui/react/use-render";import{BAR_SURFACE as n,MPPageLayoutContext as r}from"../../internal/page-layout.js";import{hasContent as s,MEASURE as l,SHEET_PAD_X as m}from"../../internal/scale.js";import{useMPSize as d}from"../../internal/config.js";const o={xs:"min-h-12",sm:"min-h-14",md:"min-h-16",lg:"min-h-20",xl:"min-h-24"},c={xs:"text-mp-title-small",sm:"text-mp-title-medium",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},p={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-4",xl:"gap-5"},x={xs:"gap-3",sm:"gap-4",md:"gap-6",lg:"gap-8",xl:"gap-10"},f={static:"",absolute:"absolute inset-x-0 top-0 z-30",sticky:"sticky top-0 z-30",fixed:"fixed inset-x-0 top-0 z-40"},u={start:"shrink-0",center:"flex-1 basis-0",end:"shrink-0"},h={start:"flex min-w-0 flex-1 items-center justify-start",center:"flex min-w-0 shrink items-center justify-center",end:"flex min-w-0 flex-1 items-center justify-end"};export const MPHeader=/*@__PURE__*/a.forwardRef(function({brand:g,actions:b,align:j="start",position:v="sticky",variant:w="tonal",size:y,maxWidth:N="none",padded:k=!0,label:_,render:z,className:$,children:B,...C},H){const M=d(y),{register:P}=a.useContext(r),R=a.useCallback(e=>{P("header",e),"function"==typeof H?H(e):H&&(H.current=e)},[P,H]);return i({render:z??e("header",{}),ref:R,props:{"aria-label":_,"data-mp-size":M,"data-mp-variant":w,className:["mp-header text-mp-on-surface box-border w-full min-w-0",n[w],"outlined"===w?"border-mp-outline-variant border-b":"",f[v],$??""].filter(Boolean).join(" "),children:t("div",{className:["flex w-full items-center",o[M],x[M],k?m[M]:"","none"===N?"":`${l[N]} mx-auto`].filter(Boolean).join(" "),children:[s(g)?e("div",{className:["mp-header__brand flex min-w-0 items-center",u[j],p[M],c[M]].join(" "),children:g}):"center"===j?e("div",{"aria-hidden":"true",className:u[j]}):null,s(B)?e("div",{className:`mp-header__middle ${h[j]} ${p[M]}`,children:B}):null,s(b)?e("div",{className:["mp-header__actions flex min-w-0 items-center justify-end",u[j],p[M]].join(" "),children:b}):"center"===j?e("div",{"aria-hidden":"true",className:u[j]}):null]}),...C}})});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPSize } from '../../types.js';
|
|
3
|
+
/** How the picture is fitted into the box it was given. CSS's own four. */
|
|
4
|
+
export type MPImageFit = 'cover' | 'contain' | 'fill' | 'none';
|
|
5
|
+
/** What the picture is doing right now. */
|
|
6
|
+
export type MPImageState = 'loading' | 'loaded' | 'error';
|
|
7
|
+
export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>, 'onError'> {
|
|
8
|
+
/** Where the picture is. */
|
|
9
|
+
src?: string;
|
|
10
|
+
/**
|
|
11
|
+
* What the picture says, for a reader who cannot see it.
|
|
12
|
+
*
|
|
13
|
+
* Required, and the one prop here that is — for the reason `MPIconButton`'s
|
|
14
|
+
* `label` is required: a picture with no text alternative is the single most
|
|
15
|
+
* common accessibility defect a component library can help with, and the help
|
|
16
|
+
* is refusing to compile without one. Pass `alt=""` for a picture that is
|
|
17
|
+
* decoration, which is a claim rather than an omission.
|
|
18
|
+
*/
|
|
19
|
+
alt: string;
|
|
20
|
+
/**
|
|
21
|
+
* The proportion the box holds, written the way CSS writes it — a number
|
|
22
|
+
* (`1.5`) or a ratio (`'16 / 9'`).
|
|
23
|
+
*
|
|
24
|
+
* Left out, the box is whatever the picture turns out to be, and the page
|
|
25
|
+
* **reflows** when it arrives. Giving a ratio is what reserves the room.
|
|
26
|
+
*/
|
|
27
|
+
ratio?: number | string;
|
|
28
|
+
/**
|
|
29
|
+
* How the picture is fitted into that box.
|
|
30
|
+
* @default 'cover'
|
|
31
|
+
*/
|
|
32
|
+
fit?: MPImageFit;
|
|
33
|
+
/**
|
|
34
|
+
* Drawn while the picture is on its way.
|
|
35
|
+
*
|
|
36
|
+
* A shimmer by default, on the surface the box sits on. `false` draws nothing,
|
|
37
|
+
* which is what a picture inside something that already has its own loading
|
|
38
|
+
* treatment wants.
|
|
39
|
+
*/
|
|
40
|
+
placeholder?: React.ReactNode | false;
|
|
41
|
+
/**
|
|
42
|
+
* Drawn instead of the picture when it does not arrive.
|
|
43
|
+
*
|
|
44
|
+
* A broken-picture glyph on a neutral surface by default. This is the prop
|
|
45
|
+
* that makes the component worth having: a bare `<img>` whose `src` 404s draws
|
|
46
|
+
* the browser's own broken-image mark, which is different in every browser and
|
|
47
|
+
* belongs to none of them.
|
|
48
|
+
*/
|
|
49
|
+
fallback?: React.ReactNode;
|
|
50
|
+
/**
|
|
51
|
+
* Opens the picture over a scrim when it is pressed.
|
|
52
|
+
*
|
|
53
|
+
* The box becomes a button, so it is reachable by keyboard and says what it
|
|
54
|
+
* does. Off by default: most pictures on a page are not worth opening, and one
|
|
55
|
+
* that silently became pressable would be a control nobody declared.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
preview?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* What the preview loads, when that is not `src` — the full-resolution file
|
|
61
|
+
* behind a thumbnail.
|
|
62
|
+
* @default src
|
|
63
|
+
*/
|
|
64
|
+
previewSrc?: string;
|
|
65
|
+
/** The label on the button `preview` turns the box into. */
|
|
66
|
+
previewLabel?: string;
|
|
67
|
+
/** Called when the state changes, for a caller that wants to know. */
|
|
68
|
+
onStateChange?: (state: MPImageState) => void;
|
|
69
|
+
/** The corner and type scale of the placeholder and the fallback. @default 'md' */
|
|
70
|
+
size?: MPSize;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A picture that says what it is doing.
|
|
74
|
+
*
|
|
75
|
+
* ```tsx
|
|
76
|
+
* <MPImage src={photo} alt="The east face at dawn" ratio="16 / 9" preview />
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* A bare `<img>` has three states and shows two of them badly. While it is on
|
|
80
|
+
* its way there is a hole the size of nothing, and the page jumps when it lands;
|
|
81
|
+
* when it fails there is the browser's own broken-image mark, which is different
|
|
82
|
+
* in every browser and belongs to none of them. This draws a placeholder for the
|
|
83
|
+
* first and a fallback for the second, and `ratio` reserves the room so that
|
|
84
|
+
* neither one moves the page.
|
|
85
|
+
*
|
|
86
|
+
* ## The cached case is the one that breaks
|
|
87
|
+
*
|
|
88
|
+
* An image already in the cache fires `load` **before** React attaches the
|
|
89
|
+
* handler, so a component that only listened would sit on its placeholder
|
|
90
|
+
* forever — and the picture behind it would be fully drawn the whole time. The
|
|
91
|
+
* `complete` flag is checked on mount for exactly that, which is why this is a
|
|
92
|
+
* component rather than three lines of `useState` at a call site.
|
|
93
|
+
*
|
|
94
|
+
* ## `alt` is required
|
|
95
|
+
*
|
|
96
|
+
* For the reason `MPIconButton`'s `label` is: a picture with no text alternative
|
|
97
|
+
* is the most common accessibility defect a library can actually help with, and
|
|
98
|
+
* the help is refusing to compile. `alt=""` is the way to say *decoration*,
|
|
99
|
+
* which is a claim somebody made rather than a prop somebody forgot.
|
|
100
|
+
*
|
|
101
|
+
* ## What it is not
|
|
102
|
+
*
|
|
103
|
+
* Not a gallery. `preview` opens **this** picture and nothing else — a lightbox
|
|
104
|
+
* that walked between images would need to know which images, in what order, and
|
|
105
|
+
* that is a component holding a collection rather than a picture.
|
|
106
|
+
*
|
|
107
|
+
* Not a `next/image`. There is no `srcset` generation, no loader and no format
|
|
108
|
+
* negotiation: those belong to whatever is serving the file, and a library that
|
|
109
|
+
* guessed at them would be guessing about somebody else's CDN. `srcSet` and
|
|
110
|
+
* `sizes` pass straight through to the `<img>`.
|
|
111
|
+
*/
|
|
112
|
+
export declare const MPImage: React.ForwardRefExoticComponent<MPImageProps & React.RefAttributes<HTMLImageElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,Fragment as a,jsxs as o}from"react/jsx-runtime";import*as r from"react";import{Dialog as t}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{BrokenImageIcon as i}from"../../constants/icons.js";import{useMPLocale as s,useMPMessages as l}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FADE as m,PORTAL_LAYER as d,SCRIM as f}from"../../internal/surface.js";import{useMPSize as u}from"../../internal/config.js";const p={cover:"object-cover",contain:"object-contain",fill:"object-fill",none:"object-none"};export const MPImage=/*@__PURE__*/r.forwardRef(function({src:j,alt:b,ratio:g,fit:h="cover",placeholder:v,fallback:x,preview:y=!1,previewSrc:N,previewLabel:z,onStateChange:w,size:k,className:P,style:R,onLoad:S,...L},B){const C=u(k),E=s(),I=l(c,E),[M,$]=r.useState(j?"loading":"error"),F=r.useRef(null),T=r.useCallback(e=>{$(a=>(a!==e&&w?.(e),e))},[w]),[W,q]=r.useState(j);j!==W&&(q(j),$(j?"loading":"error")),r.useEffect(()=>{const e=F.current;e&&j&&e.complete&&T(e.naturalWidth>0?"loaded":"error")},[j,T]);const A="loaded"===M,D=e("div",{className:["bg-mp-surface-container text-mp-on-surface-variant","flex size-full items-center justify-center"].join(" "),children:e(n,{icon:i,size:24})}),G=e("div",{className:["bg-mp-surface-container-high size-full","motion-safe:animate-pulse motion-reduce:animate-none"].join(" ")}),H=o(a,{children:[e("img",{...L,ref:e=>{F.current=e,"function"==typeof B?B(e):B&&(B.current=e)},src:j,alt:b,className:["size-full",p[h],A?"opacity-100":"opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)"].join(" "),onLoad:e=>{T("loaded"),S?.(e)},onError:()=>T("error")}),"loading"===M&&!1!==v?e("span",{"aria-hidden":"true",className:"absolute inset-0",children:v??G}):null,"error"===M?e("span",{className:"absolute inset-0",children:x??D}):null]}),J=["mp-image relative block overflow-hidden",P??""].filter(Boolean).join(" "),K={aspectRatio:g,...R};return y?o(t.Root,{children:[e(t.Trigger,{"data-mp-size":C,"data-mp-state":M,disabled:"error"===M,"aria-label":(z??b)||I.open,className:[J,"outline-mp-secondary cursor-zoom-in appearance-none border-0 bg-transparent p-0","focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-default","outline-none"].join(" "),style:K,children:H}),o(t.Portal,{children:[e(t.Backdrop,{className:`${f} ${m} fixed inset-0 z-40`}),e(t.Popup,{className:[d,m,"fixed inset-0 flex items-center justify-center p-6"].join(" "),children:e("img",{src:N??j,alt:b,className:"max-h-full max-w-full object-contain"})})]})]}):e("span",{"data-mp-size":C,"data-mp-state":M,className:J,style:K,children:H})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPImage}from"./MPImage.js";
|
|
@@ -62,6 +62,31 @@ export interface MPListItemProps extends Omit<React.ComponentPropsWithoutRef<'li
|
|
|
62
62
|
action?: React.ReactNode;
|
|
63
63
|
/** Renders the row as a link. Mutually exclusive with `onClick` in practice. */
|
|
64
64
|
href?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Where that link opens. `rel` follows on its own for `_blank` — see `rel`.
|
|
67
|
+
*/
|
|
68
|
+
target?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Overrides the `rel` a `_blank` row would otherwise get, which is
|
|
71
|
+
* `noopener noreferrer`. Writing one **replaces** it rather than adding to it,
|
|
72
|
+
* so a row that also needs `nofollow` spells all three out.
|
|
73
|
+
*/
|
|
74
|
+
rel?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Renders the row's pressable element as something else — a router's `Link`,
|
|
77
|
+
* most of the time. `href`, `target` and the row's classes still go through,
|
|
78
|
+
* so `render={<NextLink />}` needs the URL written once, on the `MPListItem`.
|
|
79
|
+
*
|
|
80
|
+
* **This is the one `render` in the library that is not the outermost
|
|
81
|
+
* element.** A row's shell is an `<li>` because it is inside a `<ul>`, and
|
|
82
|
+
* swapping that for anything else makes the list stop being a list; what a
|
|
83
|
+
* caller actually wants to replace is the `<a>` *inside* it, which is the
|
|
84
|
+
* thing App Router has to own for a client-side navigation and a prefetch to
|
|
85
|
+
* happen at all. So that is what this replaces. Without `href` or `onClick`
|
|
86
|
+
* the row is not pressable and there is nothing here to render — this is
|
|
87
|
+
* ignored rather than wrapping inert content in a link.
|
|
88
|
+
*/
|
|
89
|
+
render?: useRender.RenderProp;
|
|
65
90
|
/** Marks the row as the chosen one — the open page, the current filter. */
|
|
66
91
|
selected?: boolean;
|
|
67
92
|
/** Unavailable. Drops the accent family, as everywhere else in the library. */
|
|
@@ -92,5 +117,8 @@ export declare const MPList: React.ForwardRefExoticComponent<MPListProps & React
|
|
|
92
117
|
* control. This is the same shape `MPChip` uses, for the same two reasons: a
|
|
93
118
|
* `<span>` carrying a click handler is invisible to a keyboard, and a `<button>`
|
|
94
119
|
* inside a `<button>` is markup Chrome silently un-nests.
|
|
120
|
+
*
|
|
121
|
+
* That inner element is what `render` replaces — a router's `Link`, so a row in
|
|
122
|
+
* a navigation list is a client-side navigation rather than a full page load.
|
|
95
123
|
*/
|
|
96
124
|
export declare const MPListItem: React.ForwardRefExoticComponent<MPListItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r,Fragment as n}from"react/jsx-runtime";import*as t from"react";import{useRender as i}from"@base-ui/react/use-render";import{accentSlots as o}from"../../internal/accent.js";import{CONTROL_GAP as
|
|
2
|
+
import{jsx as e,jsxs as r,Fragment as n}from"react/jsx-runtime";import*as t from"react";import{useRender as i}from"@base-ui/react/use-render";import{accentSlots as o}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{CONTROL_GAP as s,hasContent as a,PROSE_TEXT as d,SHEET_PAD_X as m}from"../../internal/scale.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{CONTAINER_SURFACE as p}from"../../internal/surface.js";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const x=/*@__PURE__*/t.createContext({size:"md",color:"primary",dividers:!1}),h={xs:"py-1.5",sm:"py-2.5",md:"py-4",lg:"py-5",xl:"py-6"},v={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-medium"},b={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"};export const MPList=/*@__PURE__*/t.forwardRef(function({variant:r="outlined",size:n,color:l,dividers:s=!1,render:a,className:d,style:m,children:c,...h},v){const b=f(n),y=u(l),j=t.useMemo(()=>({size:b,color:y,dividers:s}),[b,y,s]),N=["mp-list rounded-mp-md flex flex-col",p[r],"text-mp-on-surface",s?"overflow-hidden [&>li+li]:border-mp-outline-variant [&>li+li]:border-t":"p-1",d??""].filter(Boolean).join(" "),g=i({render:a??e("ul",{}),ref:v,props:{role:"list","data-mp-size":b,"data-mp-variant":r,className:N,style:{...o(y),...m},children:c,...h}});return e(x.Provider,{value:j,children:g})});function y({render:r,props:n}){return i({render:r??(n.href?e("a",{}):e("button",{})),props:n})}export const MPListItem=/*@__PURE__*/t.forwardRef(function({startIcon:i,endIcon:o,description:p,action:u,href:f,target:j,rel:N,render:g,selected:k=!1,disabled:_=!1,className:w,children:z,onClick:B,...C},I){const{size:L,dividers:M}=t.useContext(x),P=Boolean(B||f)&&!_,R=m[L],F=["group relative flex min-w-0 flex-1 items-center overflow-hidden text-start","font-[inherit] no-underline",R,h[L],s[L],d[L],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",M?"":b[L],_?"text-mp-on-surface/38 cursor-default":k?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":"",P?["cursor-pointer appearance-none border-0",k?"":"bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].filter(Boolean).join(" "):""].filter(Boolean).join(" "),S=r(n,{children:[P?e(c,{}):null,a(i)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:i}):null,r("span",{className:"mp-list-item__text flex min-w-0 flex-1 flex-col",children:[a(z)?e("span",{className:"mp-list-item__label truncate",children:z}):null,a(p)?e("span",{className:["mp-list-item__description truncate",v[L],k?"opacity-80":"text-mp-on-surface-variant"].join(" "),children:p}):null]}),a(o)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:o}):null]});return r("li",{ref:I,"data-selected":k||void 0,className:["flex w-full items-center",w??""].filter(Boolean).join(" "),...C,children:[P&&f?e(y,{render:g,props:{href:f,target:j,rel:l(j,N),className:F,"aria-current":k?"page":void 0,onClick:B,children:S}}):P?e(y,{render:g,props:{type:g?void 0:"button",className:F,"aria-current":!!k||void 0,onClick:B,children:S}}):e("div",{className:F,"aria-disabled":_||void 0,children:S}),a(u)?e("div",{className:`flex shrink-0 items-center ${R}`,children:u}):null]})});
|
|
@@ -30,6 +30,25 @@ export interface MPMenuProps extends MPMenuSurfaceProps {
|
|
|
30
30
|
* menu opened from elsewhere needs no trigger of its own.
|
|
31
31
|
*/
|
|
32
32
|
trigger?: React.ReactElement;
|
|
33
|
+
/**
|
|
34
|
+
* Whether that trigger renders a real `<button>`.
|
|
35
|
+
*
|
|
36
|
+
* It nearly always does — an [MPButton](./button), an
|
|
37
|
+
* [MPIconButton](./icon-button), an [MPChip](./chip) with an `onClick` — and
|
|
38
|
+
* this can be left alone. Set it `false` for a trigger that is deliberately
|
|
39
|
+
* something else: an avatar, a card, a row of text. Base UI then supplies the
|
|
40
|
+
* `role`, the tab stop and the Enter/Space handling a `<button>` would have
|
|
41
|
+
* brought with it, so the trigger is still a button to a screen reader and to
|
|
42
|
+
* a keyboard.
|
|
43
|
+
*
|
|
44
|
+
* The reason it is a prop rather than something inferred: what a trigger
|
|
45
|
+
* renders is only known once it has rendered, and by then the wiring has
|
|
46
|
+
* already been decided. Base UI says so in the console when the two disagree,
|
|
47
|
+
* in either direction — a `false` here on something that *is* a `<button>` is
|
|
48
|
+
* as wrong as the reverse.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
nativeButton?: boolean;
|
|
33
52
|
/** Whether the menu is open. Use with `onOpenChange` for a controlled menu. */
|
|
34
53
|
open?: boolean;
|
|
35
54
|
/** Whether it starts open, for an uncontrolled one. */
|
|
@@ -133,6 +152,7 @@ export interface MPMenuGroupProps {
|
|
|
133
152
|
label?: React.ReactNode;
|
|
134
153
|
children?: React.ReactNode;
|
|
135
154
|
className?: string;
|
|
155
|
+
style?: React.CSSProperties;
|
|
136
156
|
}
|
|
137
157
|
export interface MPMenuCheckboxItemProps extends Omit<MPMenuItemProps, 'href' | 'target' | 'startIcon' | 'onClick'> {
|
|
138
158
|
checked?: boolean;
|
|
@@ -153,6 +173,7 @@ export interface MPMenuRadioGroupProps {
|
|
|
153
173
|
disabled?: boolean;
|
|
154
174
|
children?: React.ReactNode;
|
|
155
175
|
className?: string;
|
|
176
|
+
style?: React.CSSProperties;
|
|
156
177
|
}
|
|
157
178
|
export interface MPMenuRadioItemProps extends Omit<MPMenuItemProps, 'href' | 'target' | 'startIcon' | 'onClick'> {
|
|
158
179
|
/** What this row sets the group to. */
|
|
@@ -173,7 +194,7 @@ export declare function MPMenuItem({ onClick, href, target, rel, startIcon, endI
|
|
|
173
194
|
/** A row that ticks. The tick lands in the column a `startIcon` would. */
|
|
174
195
|
export declare function MPMenuCheckboxItem({ checked, defaultChecked, onCheckedChange, endIcon, shortcut, description, color, closeOnClick, disabled, label, children, className, style }: MPMenuCheckboxItemProps): React.JSX.Element;
|
|
175
196
|
/** One choice out of a set. Wraps the rows that make up the set. */
|
|
176
|
-
export declare function MPMenuRadioGroup({ value, defaultValue, onValueChange, disabled, children, className }: MPMenuRadioGroupProps): React.JSX.Element;
|
|
197
|
+
export declare function MPMenuRadioGroup({ value, defaultValue, onValueChange, disabled, children, className, style }: MPMenuRadioGroupProps): React.JSX.Element;
|
|
177
198
|
/**
|
|
178
199
|
* A row inside an `MPMenuRadioGroup`.
|
|
179
200
|
*
|
|
@@ -183,7 +204,7 @@ export declare function MPMenuRadioGroup({ value, defaultValue, onValueChange, d
|
|
|
183
204
|
*/
|
|
184
205
|
export declare function MPMenuRadioItem({ value, endIcon, shortcut, description, color, closeOnClick, disabled, label, children, className, style }: MPMenuRadioItemProps): React.JSX.Element;
|
|
185
206
|
/** A named run of rows. The label is a heading, not a row — it cannot be picked. */
|
|
186
|
-
export declare function MPMenuGroup({ label, children, className }: MPMenuGroupProps): React.JSX.Element;
|
|
207
|
+
export declare function MPMenuGroup({ label, children, className, style }: MPMenuGroupProps): React.JSX.Element;
|
|
187
208
|
/** The hairline between two runs of rows. `outline-variant`, as MD3 draws it. */
|
|
188
209
|
export declare function MPMenuSeparator({ className, ...props }: MPMenuSeparatorProps): React.JSX.Element;
|
|
189
210
|
/**
|
|
@@ -217,7 +238,7 @@ export declare function MPMenuSubmenu({ label, startIcon, disabled, side, sideOf
|
|
|
217
238
|
* type with a variant for every shape a row can take, which is a component tree
|
|
218
239
|
* spelled as a discriminated union.
|
|
219
240
|
*/
|
|
220
|
-
export declare function MPMenu({ size, color, trigger, open, defaultOpen, onOpenChange, side, align, sideOffset, modal, openOnHover, loopFocus, disabled, className, style, children }: MPMenuProps): React.JSX.Element;
|
|
241
|
+
export declare function MPMenu({ size: sizeProp, color: colorProp, trigger, open, defaultOpen, onOpenChange, side, align, sideOffset, modal, openOnHover, loopFocus, nativeButton, disabled, className, style, children }: MPMenuProps): React.JSX.Element;
|
|
221
242
|
/**
|
|
222
243
|
* The same menu, opened by a right-click or a long press instead of by a button.
|
|
223
244
|
*
|
|
@@ -228,5 +249,5 @@ export declare function MPMenu({ size, color, trigger, open, defaultOpen, onOpen
|
|
|
228
249
|
* against an anchor, and the long press is what makes it reachable on a touch
|
|
229
250
|
* screen at all.
|
|
230
251
|
*/
|
|
231
|
-
export declare function MPContextMenu({ size, color, content, children, open, defaultOpen, onOpenChange, loopFocus, disabled, className, style }: MPContextMenuProps): React.JSX.Element;
|
|
252
|
+
export declare function MPContextMenu({ size: sizeProp, color: colorProp, content, children, open, defaultOpen, onOpenChange, loopFocus, disabled, className, style }: MPContextMenuProps): React.JSX.Element;
|
|
232
253
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{Menu as a}from"@base-ui/react/menu";import{ContextMenu as l}from"@base-ui/react/context-menu";import{MPIcon as r}from"../icon/MPIcon.js";import{CheckIcon as s,ChevronRightIcon as o}from"../../constants/icons.js";import{linkRel as i}from"../../internal/link.js";import{MPMenuContext as c}from"../../internal/menu.js";import{accentSlots as d}from"../../internal/accent.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as p,hasContent as h}from"../../internal/scale.js";import{FADE as f,PORTAL_LAYER as x}from"../../internal/surface.js";const
|
|
2
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as t from"react";import{Menu as a}from"@base-ui/react/menu";import{ContextMenu as l}from"@base-ui/react/context-menu";import{MPIcon as r}from"../icon/MPIcon.js";import{CheckIcon as s,ChevronRightIcon as o}from"../../constants/icons.js";import{linkRel as i}from"../../internal/link.js";import{MPMenuContext as c}from"../../internal/menu.js";import{accentSlots as d}from"../../internal/accent.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as p,hasContent as h}from"../../internal/scale.js";import{FADE as f,PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPColor as b,useMPSize as g}from"../../internal/config.js";const v=/*@__PURE__*/["mp-menu__popup rounded-mp-xs shadow-mp-2 bg-mp-surface-container text-mp-on-surface","max-h-[min(24rem,var(--available-height))] min-w-[112px] max-w-[280px]","overflow-y-auto overscroll-contain py-2 outline-none",f].join(" "),N={xs:"min-h-8",sm:"min-h-10",md:"min-h-12",lg:"min-h-14",xl:"min-h-16"},y={xs:"px-2",sm:"px-2.5",md:"px-3",lg:"px-4",xl:"px-5"},C={xs:"gap-2",sm:"gap-2.5",md:"gap-3",lg:"gap-3",xl:"gap-4"},k={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"};function j(e,n,t){return["group relative flex w-full cursor-pointer items-center select-none",n?"text-(--_mp-accent)":"text-mp-on-surface",N[e],y[e],C[e],k[e],"data-disabled:text-mp-on-surface/38 data-disabled:cursor-default","outline-none",t??""].filter(Boolean).join(" ")}function M(){return e(m,{layer:"inset-0 bg-current",className:"group-data-highlighted:opacity-8 group-data-popup-open:opacity-8 group-data-disabled:opacity-0"})}const O="relative flex shrink-0 items-center justify-center";function P({children:t,description:a}){return h(a)?n("span",{className:"relative flex min-w-0 flex-1 flex-col py-1.5 text-start",children:[e("span",{className:"truncate",children:t}),e("span",{className:`text-mp-on-surface-variant truncate ${p}`,children:a})]}):e("span",{className:"relative min-w-0 flex-1 truncate text-start",children:t})}function I({shortcut:n}){return h(n)?e("span",{className:`text-mp-on-surface-variant relative ms-2 shrink-0 ${p}`,children:n}):null}export function MPMenuItem({onClick:l,href:r,target:s,rel:o,startIcon:d,endIcon:m,shortcut:u,description:p,color:f,closeOnClick:x=!0,disabled:b=!1,label:g,children:v,className:N,style:y}){const{size:C}=t.useContext(c),k=n(t.Fragment,{children:[e(M,{}),h(d)?e("span",{className:`${O} text-mp-on-surface-variant`,children:d}):null,e(P,{description:p,children:v}),h(m)?e("span",{className:`${O} text-mp-on-surface-variant`,children:m}):null,e(I,{shortcut:u})]}),$=f?{"--_mp-accent":`var(--_mp-color-${f})`}:void 0,z=$||y?{...$,...y}:void 0;return void 0===r||b?e(a.Item,{disabled:b,label:g,closeOnClick:x,onClick:l,className:j(C,Boolean(f),N),style:z,children:k}):e(a.LinkItem,{href:r,target:s,rel:i(s,o),label:g,closeOnClick:x,onClick:l,className:j(C,Boolean(f),N),style:z,children:k})}export function MPMenuCheckboxItem({checked:l,defaultChecked:o,onCheckedChange:i,endIcon:d,shortcut:m,description:p,color:f,closeOnClick:x=!1,disabled:b=!1,label:g,children:v,className:N,style:y}){const{size:C}=t.useContext(c),k=f?{"--_mp-accent":`var(--_mp-color-${f})`}:void 0;return n(a.CheckboxItem,{checked:l,defaultChecked:o,onCheckedChange:e=>i?.(e),disabled:b,label:g,closeOnClick:x,className:j(C,Boolean(f),N),style:k||y?{...k,...y}:void 0,children:[e(M,{}),e("span",{className:`${O} text-(--_mp-accent)`,style:{width:u[C]},children:e(a.CheckboxItemIndicator,{className:"flex items-center justify-center",children:e(r,{icon:s,size:u[C]})})}),e(P,{description:p,children:v}),h(d)?e("span",{className:`${O} text-mp-on-surface-variant`,children:d}):null,e(I,{shortcut:m})]})}export function MPMenuRadioGroup({value:n,defaultValue:t,onValueChange:l,disabled:r=!1,children:s,className:o,style:i}){return e(a.RadioGroup,{value:n,defaultValue:t,onValueChange:e=>l?.(e),disabled:r,className:o,style:i,children:s})}export function MPMenuRadioItem({value:l,endIcon:r,shortcut:s,description:o,color:i,closeOnClick:d=!1,disabled:m=!1,label:p,children:f,className:x,style:b}){const{size:g}=t.useContext(c),v=i?{"--_mp-accent":`var(--_mp-color-${i})`}:void 0;return n(a.RadioItem,{value:l,disabled:m,label:p,closeOnClick:d,className:j(g,Boolean(i),x),style:v||b?{...v,...b}:void 0,children:[e(M,{}),e("span",{className:`${O} text-(--_mp-accent)`,style:{width:u[g]},children:e(a.RadioItemIndicator,{className:"flex items-center justify-center",children:e("span",{className:"block size-2.5 rounded-full bg-current"})})}),e(P,{description:o,children:f}),h(r)?e("span",{className:`${O} text-mp-on-surface-variant`,children:r}):null,e(I,{shortcut:s})]})}export function MPMenuGroup({label:l,children:r,className:s,style:o}){const{size:i}=t.useContext(c);return n(a.Group,{className:s,style:o,children:[h(l)?e(a.GroupLabel,{className:`text-mp-on-surface-variant pt-2 pb-1 ${y[i]} ${p}`,children:l}):null,r]})}export function MPMenuSeparator({className:n,...t}){return e(a.Separator,{className:["bg-mp-outline-variant my-2 h-px",n??""].filter(Boolean).join(" "),...t})}export function MPMenuSubmenu({label:l,startIcon:s,disabled:i=!1,side:m="right",sideOffset:p=0,children:f,className:b,style:g}){const{size:N,color:y}=t.useContext(c);return n(a.SubmenuRoot,{children:[n(a.SubmenuTrigger,{disabled:i,className:j(N,!1),children:[e(M,{}),h(s)?e("span",{className:`${O} text-mp-on-surface-variant`,children:s}):null,e("span",{className:"relative min-w-0 flex-1 truncate text-start",children:l}),e("span",{className:`${O} text-mp-on-surface-variant rtl:rotate-180`,children:e(r,{icon:o,size:u[N]})})]}),e(a.Portal,{children:e(a.Positioner,{className:x,side:m,sideOffset:p,align:"start",children:e(a.Popup,{className:[v,b??""].filter(Boolean).join(" "),style:{...d(y),...g},children:f})})})]})}export function MPMenu({size:l,color:r,trigger:s,open:o,defaultOpen:i,onOpenChange:m,side:u="bottom",align:p="start",sideOffset:h=4,modal:f,openOnHover:N=!1,loopFocus:y=!0,nativeButton:C=!0,disabled:k=!1,className:j,style:M,children:O}){const P=g(l),I=b(r),$=t.useMemo(()=>({size:P,color:I}),[P,I]);return e(c.Provider,{value:$,children:n(a.Root,{open:o,defaultOpen:i,onOpenChange:e=>m?.(e),modal:f,loopFocus:y,disabled:k,children:[s?e(a.Trigger,{render:s,openOnHover:N,nativeButton:C,disabled:k}):null,e(a.Portal,{children:e(a.Positioner,{className:x,side:u,align:p,sideOffset:h,children:e(a.Popup,{"data-mp-size":P,className:[v,j??""].filter(Boolean).join(" "),style:{...d(I),...M},children:O})})})]})})}export function MPContextMenu({size:a,color:r,content:s,children:o,open:i,defaultOpen:m,onOpenChange:u,loopFocus:p=!0,disabled:h=!1,className:f,style:N}){const y=g(a),C=b(r),k=t.useMemo(()=>({size:y,color:C}),[y,C]);return e(c.Provider,{value:k,children:n(l.Root,{open:i,defaultOpen:m,onOpenChange:e=>u?.(e),loopFocus:p,disabled:h,children:[e(l.Trigger,{children:o}),e(l.Portal,{children:e(l.Positioner,{className:x,children:e(l.Popup,{"data-mp-size":y,className:[v,f??""].filter(Boolean).join(" "),style:{...d(C),...N},children:s})})})]})})}
|
|
@@ -42,6 +42,13 @@ export interface MPMenubarMenuProps {
|
|
|
42
42
|
disabled?: boolean;
|
|
43
43
|
/** The rows, written exactly as they are inside an [MPMenu](./menu). */
|
|
44
44
|
children?: React.ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Added to the word on the bar — the button that opens the menu — rather than
|
|
47
|
+
* to the menu it opens. That one takes its own `className` on
|
|
48
|
+
* [MPMenu](./menu).
|
|
49
|
+
*/
|
|
50
|
+
className?: string;
|
|
51
|
+
style?: React.CSSProperties;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* One menu on the bar: the word, and the rows behind it.
|
|
@@ -51,7 +58,7 @@ export interface MPMenubarMenuProps {
|
|
|
51
58
|
* inside are the same [MPMenuItem](./menu), `MPMenuSeparator`, `MPMenuGroup` and
|
|
52
59
|
* `MPMenuSubmenu` an [MPMenu](./menu) takes, because it *is* the same menu.
|
|
53
60
|
*/
|
|
54
|
-
export declare function MPMenubarMenu({ label, startIcon, disabled, children }: MPMenubarMenuProps): React.JSX.Element;
|
|
61
|
+
export declare function MPMenubarMenu({ label, startIcon, disabled, children, className, style }: MPMenubarMenuProps): React.JSX.Element;
|
|
55
62
|
/**
|
|
56
63
|
* The strip of words at the top of an application — File, Edit, View — each of
|
|
57
64
|
* which opens a menu.
|
|
@@ -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{Menubar as r}from"@base-ui/react/menubar";import{MPMenu as n}from"../menu/MPMenu.js";import{accentSlots as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Menubar as r}from"@base-ui/react/menubar";import{MPMenu as n}from"../menu/MPMenu.js";import{accentSlots as s}from"../../internal/accent.js";import{MPMenuContext as i}from"../../internal/menu.js";import{MPStateLayer as l}from"../../internal/StateLayer.js";import{CONTROL_GAP as a,hasContent as m}from"../../internal/scale.js";import{useMPColor as c,useMPSize as p}from"../../internal/config.js";const u={xs:"h-6",sm:"h-7",md:"h-8",lg:"h-10",xl:"h-12"},d={xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-4"},f={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"};export function MPMenubarMenu({label:r,startIcon:s,disabled:c=!1,children:p,className:x,style:b}){const{size:h,color:j}=o.useContext(i);return e(n,{size:h,color:j,disabled:c,openOnHover:!0,sideOffset:4,trigger:t("button",{type:"button",disabled:c,className:["mp-menubar__menu group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-xs cursor-pointer items-center justify-center bg-transparent","appearance-none font-[inherit] whitespace-nowrap select-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","disabled:text-mp-on-surface/38 disabled:cursor-default","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",u[h],d[h],f[h],a[h],x??""].filter(Boolean).join(" "),style:b,children:[c?null:e(l,{className:"group-data-popup-open:opacity-8"}),m(s)?e("span",{className:"relative flex",children:s}):null,e("span",{className:"relative",children:r})]}),children:p})}export const MPMenubar=/*@__PURE__*/o.forwardRef(function({orientation:t="horizontal",modal:n=!0,loopFocus:l=!0,disabled:m=!1,size:u,color:d,className:f,style:x,children:b,...h},j){const g=p(u),v=c(d),y=o.useMemo(()=>({size:g,color:v}),[g,v]);return e(i.Provider,{value:y,children:e(r,{ref:j,orientation:t,modal:n,loopFocus:l,disabled:m,"data-mp-size":g,"data-mp-orientation":t,className:["mp-menubar flex items-center","vertical"===t?"flex-col items-stretch":"flex-row",a[g],f??""].filter(Boolean).join(" "),style:{...s(v),...x},...h,children:b})})});
|