material-plus-ui 1.9.0 → 1.10.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/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/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/code-block/MPCodeBlock.js +1 -1
- package/dist/components/combobox/MPCombobox.js +1 -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 +0 -34
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- 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/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/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/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 +8 -0
- 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.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +11 -0
- 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.js +1 -1
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.js +1 -1
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- 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 +9 -1
- package/dist/internal/FieldOutline.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/highlight.js +1 -1
- package/dist/internal/i18n.d.ts +0 -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/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/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/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/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/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 +116 -4
- 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 o from"react";import{MPIcon as n}from"../icon/MPIcon.js";import{CheckIcon as r,CodeIcon as i,CopyIcon as l}from"../../constants/icons.js";import{canonicalLanguage as a,highlightCode as s,plainLines as c}from"../../internal/highlight.js";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{MPIcon as n}from"../icon/MPIcon.js";import{CheckIcon as r,CodeIcon as i,CopyIcon as l}from"../../constants/icons.js";import{canonicalLanguage as a,highlightCode as s,plainLines as c}from"../../internal/highlight.js";import{watchIntersection as m}from"../../internal/intersection.js";import{cssLength as d}from"../../internal/length.js";import{useMPLocale as p,useMPMessages as u}from"../../internal/locale.js";import{CODE as f}from"../../internal/messages/code.js";import{META_TEXT as g,hasContent as x}from"../../internal/scale.js";import{VISUALLY_HIDDEN as h}from"../../internal/visually-hidden.js";import{useMPDensity as b,useMPSize as y}from"../../internal/config.js";export{registerMPLanguage}from"../../internal/highlight.js";const v={xs:"text-[0.6875rem]/[1.55]",sm:"text-[0.75rem]/[1.6]",md:"text-[0.8125rem]/[1.65]",lg:"text-[0.875rem]/[1.7]",xl:"text-[1rem]/[1.7]"},w={xs:8,sm:12,md:14,lg:16,xl:20},j={xs:8,sm:12,md:14,lg:16,xl:20},N={xs:4,sm:4,md:6,lg:8,xl:8};function k(e,t,o){return Math.max(o,e+2*t)}export const MPCodeBlock=/*@__PURE__*/o.forwardRef(function({code:M,language:_,theme:S="auto",size:T,density:$,highlight:L=!0,toolbar:z=!0,title:C,showLanguage:F=!0,copyable:R=!0,rawToggle:A=!1,markLines:E,lineNumbers:H=!1,startLine:I=1,prompt:K,wrap:B=!1,maxHeight:P,fontFamily:D,fontSize:O,lineHeight:q,locale:G,copyLabel:J,copiedLabel:Q,rawLabel:U,onCopy:V,className:W,style:X,...Y},Z){const ee=y(T),te=b($),oe=u(f,p(G)),ne=o.useMemo(()=>M.replace(/\r\n?/g,"\n").replace(/\s+$/,""),[M]),re=a(_),[ie,le]=o.useState(!1),[ae,se]=o.useState(null),[ce,me]=o.useState(null),[de,pe]=o.useState(!1),ue=L&&!ie&&null!==re;o.useEffect(()=>{if(!ue||!re)return void me(null);if(!de)return;let e=!1;return s(ne,re).then(t=>{e||o.startTransition(()=>me(t))},()=>{e||me(null)}),()=>{e=!0}},[ne,re,ue,de]);const fe=o.useMemo(()=>ue&&ce?ce:c(ne),[ue,ce,ne]),ge=o.useMemo(()=>function(e){const t=new Set;if(void 0===e)return t;for(const o of Array.isArray(e)?e:[e])if("number"!=typeof o)for(const e of o.split(",")){const o=/^\s*(\d+)\s*(?:-\s*(\d+)\s*)?$/.exec(e);if(!o)continue;const n=Number(o[1]),r=void 0===o[2]?n:Number(o[2]);for(let e=Math.min(n,r);e<=Math.max(n,r);e+=1)t.add(e)}else Number.isFinite(o)&&t.add(Math.trunc(o));return t}(E),[E]),xe=o.useRef(void 0);o.useEffect(()=>()=>clearTimeout(xe.current),[]);const he=o.useRef(null);o.useEffect(()=>{const e=he.current;if(!de){if(e&&"undefined"!=typeof IntersectionObserver)return m(e,e=>{e.isIntersecting&&pe(!0)},{rootMargin:"100% 0px"});pe(!0)}},[de]);const be=J??oe.copy,ye=Q??oe.copied,ve=U??oe.raw,we=/*@__PURE__*/["mp-code__button inline-flex shrink-0 cursor-pointer items-center gap-1 border-0","rounded-mp-xs bg-transparent px-1.5 py-1","text-(--mp-code-dim) hover:text-(--mp-code-fg) hover:bg-(--mp-code-hover)",g,"transition-[color,background-color] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none","outline-(--mp-code-fg) focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),je=x(C)?"string"==typeof C?C:void 0:re??oe.label,Ne=z&&(F||R||A||x(C));return t("div",{ref:Z,"data-mp-size":ee,"data-mp-code-theme":S,"data-mp-code-wrap":B?"true":void 0,className:["mp-code rounded-mp-md flex min-w-0 flex-col overflow-hidden","border-(--mp-code-rule) bg-(--mp-code-bg) text-(--mp-code-fg) border",W??""].filter(Boolean).join(" "),style:{"--mp-code-gutter":`${String(I+Math.max(fe.length-1,0)).length}ch`,"--mp-code-pad-x":`${k(j[ee],te,6)}px`,"--mp-code-pad-y":`${k(w[ee],te,4)}px`,"--mp-code-bar-pad-y":`${k(N[ee],te,2)}px`,...D?{fontFamily:D}:null,...void 0===O?null:{fontSize:d(O)},...void 0===q?null:{lineHeight:q},...X},...Y,children:[Ne?t("div",{className:["mp-code__bar border-(--mp-code-rule) flex min-w-0 items-center gap-1 border-b","px-[calc(var(--mp-code-pad-x)+2px)] py-(--mp-code-bar-pad-y)"].join(" "),children:[x(C)?e("span",{className:`mp-code__title min-w-0 truncate font-mono ${g}`,children:C}):null,F&&re?e("span",{className:["mp-code__language text-(--mp-code-dim) min-w-0 truncate font-mono","tracking-wide uppercase select-none",g].join(" "),children:re}):null,e("span",{className:"flex-1"}),A&&L?e("button",{type:"button","aria-pressed":ie,"aria-label":ve,title:ve,onClick:()=>le(e=>!e),className:[we,ie?"bg-(--mp-code-hover) text-(--mp-code-fg)":""].filter(Boolean).join(" "),children:e(n,{icon:i,size:"1.15em"})}):null,R?t("button",{type:"button",onClick:async()=>{const e=await async function(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.cssText="position:fixed;top:0;left:0;opacity:0;pointer-events:none",document.body.append(t),t.select();const o=document.execCommand("copy");return t.remove(),o}catch{return!1}}(ne);clearTimeout(xe.current),se(e),xe.current=setTimeout(()=>se(null),2e3),e&&V?.(ne)},className:we,children:[e(n,{icon:ae?r:l,size:"1.15em"}),e("span",{children:null===ae?be:ae?ye:oe.copyFailed})]}):null]}):null,e("div",{className:`mp-code__body flex min-h-0 flex-col ${v[ee]}`,children:e("div",{role:"region","aria-label":je,tabIndex:0,onKeyDown:e=>{if("a"!==e.key&&"A"!==e.key)return;if(!e.metaKey&&!e.ctrlKey||e.altKey)return;const t=he.current,o="undefined"==typeof window?null:window.getSelection();if(!t||!o)return;e.preventDefault();const n=document.createRange();n.selectNodeContents(t),o.removeAllRanges(),o.addRange(n)},className:["mp-code__scroller box-border min-h-0 overflow-auto py-(--mp-code-pad-y)","outline-(--mp-code-fg) focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),style:void 0===P?void 0:{maxHeight:d(P)},children:e("pre",{ref:he,className:["m-0 bg-transparent p-0 font-mono",B?"w-full":"w-max min-w-full"].join(" "),children:fe.map((t,n)=>{const r=I+n;return e("div",{className:"mp-code-line px-(--mp-code-pad-x)","data-line":H?r:void 0,"data-mark":ge.has(r)?"":void 0,"data-prompt":K&&t.length>0?K:void 0,children:e("code",{children:t.map((t,n)=>t.token?e("span",{className:t.token,children:t.text},n):e(o.Fragment,{children:t.text},n))})},n)})})})}),e("span",{"aria-live":"polite",className:h,children:null===ae?"":ae?ye:oe.copyFailed})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as n from"react";import{Combobox as o}from"@base-ui/react/combobox";import{Field as l}from"@base-ui/react/field";import{MPChip as t}from"../chip/MPChip.js";import{MPIcon as r}from"../icon/MPIcon.js";import{AddIcon as i,CheckIcon as s,ChevronDownIcon as m,CloseIcon as c}from"../../constants/icons.js";import{MPFieldLabel as p,MPFieldOutline as u,useFloatingLabel as d}from"../../internal/FieldOutline.js";import{fillMessage as h}from"../../internal/i18n.js";import{useMPLocale as f,useMPMessages as b}from"../../internal/locale.js";import{COMBOBOX as g}from"../../internal/messages/combobox.js";import{COMMON as x}from"../../internal/messages/common.js";import{MPStateLayer as v}from"../../internal/StateLayer.js";import{MPSupportingText as y}from"../../internal/SupportingText.js";import{CONTROL_ICON as j,PROSE_TEXT as C,hasContent as w}from"../../internal/scale.js";import{MARK_MOTION_KEPT as N}from"../../internal/mark.js";import{FADE as L,PORTAL_LAYER as M}from"../../internal/surface.js";import{useMPSize as k}from"../../internal/config.js";const S={xs:{padding:"ps-2 pe-1",height:"h-8"},sm:{padding:"ps-3 pe-1.5",height:"h-10"},md:{padding:"ps-4 pe-2",height:"h-14"},lg:{padding:"ps-4 pe-2",height:"h-16"},xl:{padding:"ps-5 pe-2.5",height:"h-18"}},
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as n from"react";import{Combobox as o}from"@base-ui/react/combobox";import{Field as l}from"@base-ui/react/field";import{MPChip as t}from"../chip/MPChip.js";import{MPIcon as r}from"../icon/MPIcon.js";import{AddIcon as i,CheckIcon as s,ChevronDownIcon as m,CloseIcon as c}from"../../constants/icons.js";import{MPFieldLabel as p,MPFieldOutline as u,useFloatingLabel as d}from"../../internal/FieldOutline.js";import{fillMessage as h}from"../../internal/i18n.js";import{useMPLocale as f,useMPMessages as b}from"../../internal/locale.js";import{COMBOBOX as g}from"../../internal/messages/combobox.js";import{COMMON as x}from"../../internal/messages/common.js";import{MPStateLayer as v}from"../../internal/StateLayer.js";import{MPSupportingText as y}from"../../internal/SupportingText.js";import{CONTROL_ICON as j,PROSE_TEXT as C,hasContent as w}from"../../internal/scale.js";import{MARK_MOTION_KEPT as N}from"../../internal/mark.js";import{FADE as L,PORTAL_LAYER as M}from"../../internal/surface.js";import{useMPSize as k}from"../../internal/config.js";import{occurrenceKeys as I}from"../../internal/occurrence.js";const S={xs:{padding:"ps-2 pe-1",height:"h-8"},sm:{padding:"ps-3 pe-1.5",height:"h-10"},md:{padding:"ps-4 pe-2",height:"h-14"},lg:{padding:"ps-4 pe-2",height:"h-16"},xl:{padding:"ps-5 pe-2.5",height:"h-18"}},z={xs:"min-h-8 py-1",sm:"min-h-10 py-1.5",md:"min-h-14 py-3",lg:"min-h-16 py-3",xl:"min-h-18 py-3"},V={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"};function O(e){return null==e?[]:Array.isArray(e)?e.slice():[e]}export function MPCombobox({items:P,multiple:_,value:q,defaultValue:F,onValueChange:T,onInputValueChange:$,onKeyDown:A,onKeyUp:D,onFocus:K,onBlur:R,onClick:B,onDoubleClick:E,onContextMenu:U,allowCustom:G=!0,customLabel:H,clearable:W=!1,emptyMessage:J,limit:Q,filter:X,chipVariant:Y,chipColor:Z,placeholder:ee,label:ae,floatingLabel:ne=!0,description:oe,errorMessage:le,startIcon:te,size:re,fullWidth:ie=!1,required:se=!1,disabled:me=!1,readOnly:ce=!1,name:pe,open:ue,defaultOpen:de,onOpenChange:he,clearLabel:fe,openLabel:be,locale:ge,removeLabel:xe,inputRef:ve,id:ye,classNames:je,className:Ce,style:we}){const Ne=k(re),Le=f(ge),Me=b(x,Le),ke=b(g,Le),Ie=w(le),Se=!0===_,ze=S[Ne],Ve=n.useId(),Oe=ye??Ve,Pe=n.useMemo(()=>P.map(e=>({value:e.value,label:e.label??String(e.value),content:e.content,disabled:e.disabled})),[P]),[_e,qe]=n.useState(()=>O(F)),Fe=void 0===q?_e:O(q),[Te,$e]=n.useState(""),{shrunk:Ae,focusProps:De}=d({floating:ne&&w(ae),filled:Fe.length>0||""!==Te,pinned:!!te}),Ke=n.useMemo(()=>new Map(Pe.map(e=>[e.value,e])),[Pe]),Re=n.useMemo(()=>{const e=new Set;for(const a of Pe)e.add(a.label.toLocaleLowerCase()),e.add(String(a.value).toLocaleLowerCase());return e},[Pe]),Be=n.useCallback(e=>Ke.get(e)??{value:e,label:String(e),custom:!0},[Ke]),Ee=Te.trim(),Ue=Ee.toLocaleLowerCase(),Ge=""===Ee||Re.has(Ue)||Fe.some(e=>String(e).toLocaleLowerCase()===Ue),He=!G||ce||me||Ge?null:Ee,We=n.useMemo(()=>null==X?X:(e,a)=>!0===e.custom||X(e,a),[X]),Je=n.useMemo(()=>null===He?Pe:[...Pe,{value:He,label:He,custom:!0}],[Pe,He]),Qe=n.useMemo(()=>I(Je,e=>`${e.custom?"custom:":""}${String(e.value)}`),[Je]),Xe=Se?Fe.map(Be):Fe.length>0?Be(Fe[0]):null;const Ye=/*@__PURE__*/["min-w-0 flex-1 self-stretch border-0 bg-transparent text-inherit [font:inherit] outline-none","placeholder:text-mp-on-surface-variant",me?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface caret-mp-primary"].join(" "),Ze=/*@__PURE__*/["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent p-0","text-mp-on-surface-variant","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none","disabled:text-mp-on-surface/38 disabled:cursor-default"].join(" "),ea=a=>e(o.Input,{ref:ve,id:Oe,placeholder:Ae?ee:void 0,onKeyDown:A,onKeyUp:D,onFocus:K,onBlur:R,onClick:B,onDoubleClick:E,onContextMenu:U,className:Se?`${Ye} min-w-16 ${a?"ms-1.5":""}`:Ye});return a(l.Root,{disabled:me,invalid:Ie,"data-mp-size":Ne,className:["mp-combobox group flex-col align-top",ie?"flex w-full":"inline-flex w-fit",Ce??""].filter(Boolean).join(" "),style:we,...De,children:[a(o.Root,{name:pe,items:Je,multiple:Se,value:Xe,onValueChange:e=>{!function(e){void 0===q&&qe(e),T?.(Se?e:e[0]??null)}((null===e?[]:Array.isArray(e)?e:[e]).map(e=>e.value))},onInputValueChange:e=>{$e(e),$?.(e)},open:ue,defaultOpen:de,onOpenChange:e=>he?.(e),autoHighlight:!0,itemToStringLabel:e=>e.label,itemToStringValue:e=>String(e.value),isItemEqualToValue:(e,a)=>e.value===a.value,limit:Q,filter:We,disabled:me,readOnly:ce,required:se,children:[a("div",{className:"relative w-full",children:[a(o.InputGroup,{className:["relative flex w-full items-center gap-2",ze.padding,Se?z[Ne]:ze.height,C[Ne],me?"cursor-default":"cursor-text"].join(" "),children:[te?e("span",{className:["flex shrink-0 items-center",me?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:te}):null,Se?e(o.Chips,{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:e(o.Value,{children:l=>{const i=I(l,e=>e.value);return a(n.Fragment,{children:[l.map((a,n)=>e(o.Chip,{render:e(t,{variant:Y??(Ie?"outlined":"tonal"),color:Z??(Ie?"error":"primary"),size:V[Ne],disabled:me,endIcon:ce||me?null:e(o.ChipRemove,{"aria-label":xe?xe(a.label):h(Me.removeNamed,{label:a.label}),className:"flex cursor-pointer appearance-none items-center border-0 bg-transparent p-0 text-inherit opacity-70 hover:opacity-100",children:e(r,{icon:c,size:16})})}),children:a.label},i.get(a)??n)),ea(l.length>0)]})}})}):ea(!1),W&&!ce?a(o.Clear,{"aria-label":fe??Me.clear,className:Ze,children:[e(v,{}),e(r,{icon:c,size:j[Ne]})]}):null,a(o.Trigger,{"aria-label":be??Me.open,className:Ze,children:[e(v,{}),e(o.Icon,{className:["relative flex items-center","transition-transform duration-(--mp-sys-motion-duration-short4)","data-popup-open:rotate-180"].join(" "),children:e(r,{icon:m,size:j[Ne]})})]})]}),e(u,{label:ae,required:se,notched:Ae}),w(ae)?e(p,{size:Ne,label:ae,required:se,htmlFor:Oe,shrunk:Ae}):null]}),e(o.Portal,{children:e(o.Positioner,{className:M,sideOffset:4,children:a(o.Popup,{className:["mp-combobox__popup rounded-mp-xs shadow-mp-2 bg-mp-surface-container p-2","text-mp-on-surface w-[var(--anchor-width)] outline-none","max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain",C[Ne],L].join(" "),children:[e(o.Empty,{className:"text-mp-on-surface-variant px-3 py-2 empty:hidden",children:J??ke.empty}),e(o.List,{children:(n,l)=>a(o.Item,{value:n,disabled:n.disabled,className:["mp-combobox__item group rounded-mp-xs relative flex cursor-pointer",je?.item??"","items-center gap-3 py-2 ps-2 pe-3 select-none outline-none","transition-[background-color,color]","duration-(--mp-sys-motion-duration-short4)","data-selected:bg-mp-secondary-container","data-selected:text-mp-on-secondary-container","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default"].join(" "),children:[e(v,{className:"group-data-highlighted:opacity-8 group-data-disabled:opacity-0"}),e("span",{className:"flex size-5 shrink-0 items-center justify-center",children:n.custom?e(r,{icon:i,size:18}):e(o.ItemIndicator,{keepMounted:!0,className:`mp-combobox__mark ${N}`,children:e(r,{icon:s,size:18})})}),e("span",{className:w(n.content)?"min-w-0 flex-1":"min-w-0 flex-1 truncate",children:n.custom?H?H(n.label):h(ke.add,{label:n.label}):n.content??n.label})]},Qe.get(n)??l)})]})})})]}),e(y,{description:oe,errorMessage:le,className:ze.padding})]})}
|
|
@@ -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{Autocomplete as n}from"@base-ui/react/autocomplete";import{Dialog as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Autocomplete as n}from"@base-ui/react/autocomplete";import{Dialog as r}from"@base-ui/react/dialog";import{MPShortcut as l}from"../shortcut/MPShortcut.js";import{accentSlots as o}from"../../internal/accent.js";import{cssLength as s}from"../../internal/length.js";import{matchesShortcut as i,useDetectedOS as m}from"../../internal/keys.js";import{useMPLocale as c,useMPMessages as p}from"../../internal/locale.js";import{COMMAND as d}from"../../internal/messages/command.js";import{MPStateLayer as u}from"../../internal/StateLayer.js";import{hasContent as f,META_TEXT as h,PROSE_TEXT as x}from"../../internal/scale.js";import{FADE as g,PORTAL_LAYER as v,SCRIM as y,SHEET_MOTION as w}from"../../internal/surface.js";import{useMPColor as b,useMPSize as j}from"../../internal/config.js";import{occurrenceKeys as N}from"../../internal/occurrence.js";const k={xs:"max-w-sm",sm:"max-w-md",md:"max-w-xl",lg:"max-w-2xl",xl:"max-w-3xl"},$={xs:"h-10",sm:"h-12",md:"h-14",lg:"h-16",xl:"h-18"},C={xs:"px-2",sm:"px-2.5",md:"px-3",lg:"px-4",xl:"px-5"},M={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"};function S(e){return[e.label,e.group??"",...e.keywords??[]].join("\n").toLowerCase()}export function MPCommandPalette({items:_,open:L,defaultOpen:P=!1,onOpenChange:E,onSelect:z,shortcut:B="Mod+K",width:O,maxHeight:V=320,size:F,color:H,locale:I,placeholder:R,emptyMessage:D,label:K,classNames:T,className:W,style:q}){const A=j(F),G=b(H),J=c(I),Q=p(d,J),U=m(),[X,Y]=a.useState(P),[Z,ee]=a.useState(""),te=L??X,ae=a.useCallback(e=>{e||ee(""),void 0===L&&Y(e),E?.(e)},[L,E]);a.useEffect(()=>{if(!1===B)return;const e=e=>{i(e,B,U)&&(e.preventDefault(),ae(!0))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[B,U,ae]);const ne=a.useMemo(()=>_.map(S),[_]),re=a.useMemo(()=>N(_,e=>e.value),[_]),le=a.useMemo(()=>{if(""===Z)return _;const e=Z.toLowerCase();return _.filter((t,a)=>ne[a].includes(e))},[_,ne,Z]),oe=s(O),se=s(V);return e(r.Root,{open:te,onOpenChange:ae,children:t(r.Portal,{children:[e(r.Backdrop,{className:[`${v} fixed inset-0`,g,y,T?.backdrop??""].filter(Boolean).join(" ")}),e(r.Viewport,{className:`${v} fixed inset-0 flex justify-center p-4 pt-[12vh]`,children:e(r.Popup,{"aria-label":K??Q.label,"data-mp-size":A,className:["mp-command-palette relative flex w-full flex-col self-start overflow-hidden","bg-mp-surface-container-high text-mp-on-surface shadow-mp-3 rounded-mp-xl","outline-none",x[A],void 0===oe?k[A]:"",`transition-[opacity,scale] ${w}`,"motion-safe:data-starting-style:scale-95 motion-safe:data-ending-style:scale-95",W??""].filter(Boolean).join(" "),style:{...o(G),...void 0===oe?null:{maxWidth:oe},...q},children:t(n.Root,{open:!0,mode:"list",items:le,filter:null,value:Z,onValueChange:e=>ee(e),itemToStringValue:e=>e.label,children:[e("div",{className:`border-mp-outline-variant flex shrink-0 items-center border-b ${C[A]}`,children:e(n.Input,{autoFocus:!0,placeholder:R??Q.search,className:["mp-command-palette__input min-w-0 flex-1 bg-transparent font-[inherit]",T?.input??"","text-inherit outline-none","placeholder:text-mp-on-surface-variant caret-(--_mp-accent)",$[A]].join(" ")})}),e(n.List,{className:"mp-command-palette__list min-h-0 flex-1 overflow-y-auto overscroll-contain p-1"+(T?.list?` ${T.list}`:""),style:{maxHeight:se},children:(r,o)=>t(a.Fragment,{children:[r.group&&r.group!==le[o-1]?.group?e("div",{role:"presentation",className:`text-mp-on-surface-variant pt-2 pb-1 font-medium ${C[A]} ${h}`,children:r.group}):null,t(n.Item,{index:o,value:r,disabled:r.disabled,onClick:()=>(e=>{e.disabled||(e.onSelect?.(),z?.(e),ae(!1))})(r),className:["mp-command-palette__row group rounded-mp-xs relative flex cursor-pointer",T?.row??"","items-center gap-3 select-none outline-none","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default",C[A],M[A]].join(" "),children:[e(u,{layer:"inset-0 rounded-[inherit] bg-current",className:"group-data-highlighted:opacity-8 group-data-disabled:opacity-0"}),f(r.icon)?e("span",{className:"relative flex h-[1lh] shrink-0 items-center",children:r.icon}):null,t("span",{className:"relative flex min-w-0 flex-1 flex-col",children:[e("span",{className:"truncate",children:r.label}),f(r.description)?e("span",{className:`text-mp-on-surface-variant truncate ${h}`,children:r.description}):null]}),r.shortcut?e(l,{size:"xs",keys:r.shortcut,className:"relative shrink-0"}):null]})]},re.get(r)??o)}),e(n.Empty,{className:`text-mp-on-surface-variant py-6 text-center ${C[A]} ${h}`,children:D??Q.empty})]})})})]})})}
|
|
@@ -86,6 +86,22 @@ export interface MPConfigProviderProps {
|
|
|
86
86
|
* gets the CSS half and not the other one.
|
|
87
87
|
*/
|
|
88
88
|
dir?: 'ltr' | 'rtl';
|
|
89
|
+
/**
|
|
90
|
+
* Keeps a line under every field for its description or its error, whether
|
|
91
|
+
* or not there is one yet.
|
|
92
|
+
*
|
|
93
|
+
* By default the line is opened when there is something to put in it, and
|
|
94
|
+
* that moves everything below the field down by a line. Right after the
|
|
95
|
+
* reader typed, that is fine — a page that moves in answer to the reader is
|
|
96
|
+
* not a page that jumped. An error that arrives later is not: a server's
|
|
97
|
+
* answer to a submit, a check that waited for the reader to stop typing, or
|
|
98
|
+
* `MPForm`'s `errors` filled in from a response all push the page down with
|
|
99
|
+
* nothing the reader did to explain it, which is the shift Cumulative Layout
|
|
100
|
+
* Shift counts. With this the line is there from the start, and a message
|
|
101
|
+
* fills it in place.
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
reserveSupportingText?: boolean;
|
|
89
105
|
children?: React.ReactNode;
|
|
90
106
|
}
|
|
91
107
|
/**
|
|
@@ -149,7 +165,7 @@ export interface MPConfigProviderProps {
|
|
|
149
165
|
* </MPConfigProvider>
|
|
150
166
|
* ```
|
|
151
167
|
*/
|
|
152
|
-
export declare function MPConfigProvider({ size, color, density, breakpoints, locale, dir, children }: MPConfigProviderProps): React.JSX.Element;
|
|
168
|
+
export declare function MPConfigProvider({ size, color, density, breakpoints, locale, dir, reserveSupportingText, children }: MPConfigProviderProps): React.JSX.Element;
|
|
153
169
|
/**
|
|
154
170
|
* The configuration in force at this point in the tree.
|
|
155
171
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import*as e from"react";import{DirectionProvider as i}from"@base-ui/react/direction-provider";import{MPConfigContext as o,useMPConfig as t}from"../../internal/config.js";import{MPLocaleContext as n,useMPLocale as s}from"../../internal/locale.js";import{WINDOW_CLASSES as p}from"../../internal/window-class.js";export function MPConfigProvider({size:a,color:c,density:d,breakpoints:l,locale:m,dir:v,reserveSupportingText:u,children:f}){const x=t(),b=s(),g=p.map(r=>l?.[r]??x.breakpoints?.[r]??"").join(","),j=e.useMemo(()=>({size:a??x.size,color:c??x.color,density:d??x.density,breakpoints:l||x.breakpoints?{...x.breakpoints,...l}:void 0,reserveSupportingText:u??x.reserveSupportingText}),[a,c,d,u,x.size,x.color,x.density,x.reserveSupportingText,g]),y=m??b,h=r(o.Provider,{value:j,children:r(n.Provider,{value:y,children:f})});return v?r(i,{direction:v,children:r("div",{dir:v,style:{display:"contents"},children:h})}):h}export{t as useMPConfig};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";const a=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:u,children:m}){const[d,f]=o.useState(null),p=c(s,l()),h=o.useRef(null),C=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...
|
|
2
|
+
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";const a=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:u,children:m}){const[d,f]=o.useState(null),p=c(s,l()),h=o.useRef(null),C=o.useRef(u);C.current=u;const P=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...C.current,...e,acknowledge:r})}),[]),x=o.useMemo(()=>({confirm:e=>P(e,!1),alert:e=>P(e,!0).then(()=>{})}),[P]),g=e=>{h.current?.(e),h.current=null,f(null)},v=o.useRef(null);d&&(v.current=d);const w=d??v.current,j=w?.acknowledge??!1;return n(a.Provider,{value:x,children:[m,e(t,{open:null!==d,onOpenChange:e=>{e||g(j)},icon:w?.icon,title:w?.title,description:w?.description,size:w?.size??"md",color:w?.color??"primary",dismissible:w?.dismissible??!0,actions:n(r,{children:[j?null:e(i,{variant:"text",onClick:()=>g(!1),children:w?.cancelLabel??p.cancel}),e(i,{variant:"text",color:w?.color??"primary",onClick:()=>g(!0),children:w?.confirmLabel??(j?p.ok:p.confirm)})]}),children:w?.children})]})}export function useMPConfirm(){const e=o.useContext(a);if(!e)throw new Error("useMPConfirm was called outside an <MPConfirmProvider>. Wrap the application in one — the provider is what holds the dialog every confirm() is drawn in.");return e}
|
|
@@ -277,38 +277,4 @@ export interface MPDataTableProps<Row> extends Omit<React.ComponentPropsWithoutR
|
|
|
277
277
|
density?: MPDensity;
|
|
278
278
|
classNames?: MPSlots<MPDataTableSlot>;
|
|
279
279
|
}
|
|
280
|
-
/**
|
|
281
|
-
* A grid of data with the four things a reader does to one: put it in order,
|
|
282
|
-
* cut it down, step through it and take some of it away.
|
|
283
|
-
*
|
|
284
|
-
* ```tsx
|
|
285
|
-
* <MPDataTable headers={columns} items={rows} sortable searchable paged />
|
|
286
|
-
* ```
|
|
287
|
-
*
|
|
288
|
-
* It is a separate component from [MPTable](table) rather than a mode of it.
|
|
289
|
-
* `MPTable` is the presentational half: it
|
|
290
|
-
* draws what it is given, in the order it is given, and a page that only shows a
|
|
291
|
-
* grid should not carry a comparator, a CSV writer and a page clamp to do it.
|
|
292
|
-
* What the two do share is the geometry — `internal/table.ts` holds the cells'
|
|
293
|
-
* room and the type they are set in — so a data table never sits a pixel off the
|
|
294
|
-
* plain table beside it.
|
|
295
|
-
*
|
|
296
|
-
* ## What it does to the rows, and in what order
|
|
297
|
-
*
|
|
298
|
-
* Search, then `filter`, then sort, then the page. The order is the only one
|
|
299
|
-
* that makes each step mean what it says: sorting before searching would order
|
|
300
|
-
* rows nobody is going to see, and paging before either would cut a page out of
|
|
301
|
-
* a list the reader has not asked for yet. `render`'s `index` counts along the
|
|
302
|
-
* sorted, searched order across every page, so it is a running row number rather
|
|
303
|
-
* than a position on the screen.
|
|
304
|
-
*
|
|
305
|
-
* ## Who holds the keyboard
|
|
306
|
-
*
|
|
307
|
-
* A row that answers a press has to answer a keyboard, and a table of two
|
|
308
|
-
* hundred rows that each did would be two hundred tab stops. So there is exactly
|
|
309
|
-
* one route into a row and `checkboxes` is what picks it: with ticks, the tick
|
|
310
|
-
* is the control and the row is not in the tab order; without them, the row is.
|
|
311
|
-
* `onRowClick` on its own always puts the row in the tab order, because then
|
|
312
|
-
* there is nothing else to press.
|
|
313
|
-
*/
|
|
314
280
|
export declare function MPDataTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, sortable, sortMode, sort: sortProp, defaultSort, onSortChange, searchable, search: searchProp, defaultSearch, onSearchChange, searchLabel, filter, toolbar, paged, page: pageProp, defaultPage, onPageChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, resizable, columnWidths: columnWidthsProp, defaultColumnWidths, onColumnWidthsChange, selectionMode, selected: selectedProp, defaultSelected, onSelectedChange, checkboxes, onRowClick, exportable, exportFileName, exportEscapeFormulas, onExport, striped, hoverable, stickyHeader, variant, elevation, size: sizeProp, color: colorProp, density: densityProp, className, style, classNames, ...props }: MPDataTableProps<Row>): React.JSX.Element;
|
|
@@ -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{MPButton as r}from"../button/MPButton.js";import{MPCheckbox as n}from"../checkbox/MPCheckbox.js";import{MPIcon as o}from"../icon/MPIcon.js";import{MPPagination as l}from"../pagination/MPPagination.js";import{MPSelect as s}from"../select/MPSelect.js";import{MPTextField as i}from"../text-field/MPTextField.js";import{ArrowDownIcon as c,ArrowUpIcon as d,SearchIcon as m}from"../../constants/icons.js";import{accentSlots as u}from"../../internal/accent.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as f,useMPDensity as h,useMPSize as y}from"../../internal/config.js";import{useMPLocale as g,useMPMessages as b}from"../../internal/locale.js";import{fillMessage as v}from"../../internal/i18n.js";import{DATA_TABLE as x}from"../../internal/messages/data-table.js";import{TABLE as k}from"../../internal/messages/table.js";import{TRANSFER as w}from"../../internal/messages/transfer.js";import{CONTROL_ICON as S,META_TEXT as N}from"../../internal/scale.js";import{VISUALLY_HIDDEN as j}from"../../internal/visually-hidden.js";import{CELL_TEXT as C,HEAD_TEXT as z,ROW as _,cellPadX as M,cellPadY as P,drawableCell as E}from"../../internal/table.js";import{DEFAULT_COLUMN_WIDTH as L,MIN_COLUMN_WIDTH as D,compareValues as $,downloadText as A,keysBetween as I,nextSort as K,pageBounds as W,searchHaystack as R,searchText as T,sortRows as B,toCsv as F}from"../../internal/data-table.js";function V(e,t){return e.value?e.value(t):t[e.key]}const H={xs:36,sm:40,md:48,lg:52,xl:60},X=/*@__PURE__*/["group/sort -m-1 flex w-full cursor-pointer items-center gap-1 rounded-mp-xs p-1","appearance-none border-0 bg-transparent text-inherit text-start [font:inherit]","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","hover:text-mp-on-surface","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),O=/*@__PURE__*/["mp-data-table__resize absolute inset-y-0 end-0 z-10 w-2 translate-x-1/2 rtl:-translate-x-1/2","cursor-col-resize touch-none select-none appearance-none border-0 bg-transparent p-0","after:absolute after:inset-y-1 after:start-1/2 after:w-px after:bg-transparent","after:transition-[background-color] after:duration-(--mp-sys-motion-duration-short4)","hover:after:bg-mp-primary data-dragging:after:bg-mp-primary","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-solid outline-none"].join(" ");export function MPDataTable({headers:q,items:G,getRowKey:J,caption:Q,empty:U,locale:Y,sortable:Z=!1,sortMode:ee="single",sort:te,defaultSort:ae,onSortChange:re,searchable:ne=!1,search:oe,defaultSearch:le,onSearchChange:se,searchLabel:ie,filter:ce,toolbar:de,paged:me=!1,page:ue,defaultPage:pe,onPageChange:fe,pageSize:he,defaultPageSize:ye,onPageSizeChange:ge,pageSizeOptions:be=[10,25,50,100],resizable:ve=!1,columnWidths:xe,defaultColumnWidths:ke,onColumnWidthsChange:we,selectionMode:Se="none",selected:Ne,defaultSelected:je,onSelectedChange:Ce,checkboxes:ze=!1,onRowClick:_e,exportable:Me=!1,exportFileName:Pe="table.csv",exportEscapeFormulas:Ee=!0,onExport:Le,striped:De=!1,hoverable:$e=!1,stickyHeader:Ae=!1,variant:Ie="outlined",elevation:Ke,size:We,color:Re,density:Te,className:Be,style:Fe,classNames:Ve,...He}){const Xe=y(We),Oe=f(Re),qe=h(Te),Ge=g(Y),Je=b(x,Ge),Qe=b(k,Ge),Ue=b(w,Ge),Ye=M(Xe,qe),Ze=P(Xe,qe),[et,tt]=a.useState(()=>[...ae??[]]),at=te??et,[rt,nt]=a.useState(le??""),ot=oe??rt,[lt,st]=a.useState(pe??1),it=ue??lt,[ct,dt]=a.useState(ye??25),mt=he??ct,[ut,pt]=a.useState(()=>({...ke})),ft=xe??ut,[ht,yt]=a.useState(()=>[...je??[]]),gt=Ne??ht,bt=a.useMemo(()=>new Set(gt.map(e=>String(e))),[gt]),vt=a.useRef(null),xt=a.useMemo(()=>G.map((e,t)=>{const a=J?J(e,t):t;return{row:e,identity:a,key:String(a),origin:t}}),[G,J]),kt=a.useMemo(()=>{const e=q.filter(e=>!1!==e.searchable);return xt.map(t=>R(e.map(e=>V(e,t.row))))},[xt,q]),wt=T(ot.trim()),St=a.useMemo(()=>{const e=""===wt?xt:xt.filter((e,t)=>kt[t].includes(wt));return ce?e.filter(e=>ce(e.row,e.origin)):e},[xt,kt,wt,ce]),Nt=a.useMemo(()=>new Intl.Collator(Ge,{numeric:!0,sensitivity:"base"}),[Ge]),jt=a.useMemo(()=>B(St,at,(e,t)=>{const a=q.find(t=>t.key===e);if(!a)return null;const r="desc"===t,n=a.compare;return n?(e,t)=>r?-n(e.row,t.row):n(e.row,t.row):(e,t)=>$(V(a,e.row),V(a,t.row),Nt,r)}),[St,at,q,Nt]),Ct=W(jt.length,it,mt),zt=me?jt.slice(Ct.start,Ct.end):jt,_t=e=>{void 0===ue&&st(e),fe?.(e)},Mt=e=>{void 0===xe&&pt(e),we?.(e)},Pt=e=>{const t=new Set(e),a=[],r=[];for(const e of xt)t.has(e.key)&&(r.push(e.identity),a.push(e.row));void 0===Ne&&yt(r),Ce?.(r,a)},Et="none"!==Se,Lt="multiple"===Se,Dt=ze&&Et,$t=(e,t,a)=>{if(_e?.(e.row,Ct.start+t),Et){if(!Lt)return Pt(bt.has(e.key)?[]:[e.key]),void(vt.current=e.key);if(a&&null!==vt.current){const t=I(zt.map(e=>e.key),vt.current,e.key);return void Pt([...new Set([...bt,...t])])}vt.current=e.key,Pt(bt.has(e.key)?[...bt].filter(t=>t!==e.key):[...bt,e.key])}},At=zt.map(e=>e.key),It=At.filter(e=>bt.has(e)).length,Kt=At.length>0&&It===At.length,Wt=e=>ft[e.key]??e.width??L,Rt=a.useRef(null);a.useEffect(()=>()=>{null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)},[]);const Tt=(e,t)=>{const a=Math.max(D,e.minWidth??D);Mt({...ft,[e.key]:Math.max(a,Wt(e)+t)})},Bt=e=>{const t={...ft};delete t[e.key],Mt(t)},Ft={padding:`${Ze} ${Ye}`},Vt={...Ft,backgroundColor:"var(--_mp-color-surface-container)"},Ht={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"},Xt=q.length+(Dt?1:0),Ot=Boolean(_e)||Et&&!Dt,qt=$e||Et||Boolean(_e),Gt=ne||Me||void 0!==de,Jt=me||Et,Qt=(...e)=>e.filter(Boolean).join(" ");return t("div",{"data-mp-size":Xe,"data-mp-variant":Ie,className:Qt("mp-data-table rounded-mp-md flex flex-col",p(Ie,Ke),Be),style:{...u(Oe),...Fe},...He,children:[Gt?t("div",{className:Qt("mp-data-table__toolbar flex flex-wrap items-center gap-2",Ve?.toolbar),style:{padding:`${Ze} ${Ye}`},children:[ne?e(i,{size:Xe,value:ot,onChange:e=>{void 0===oe&&nt(e),_t(1),se?.(e)},label:ie??Ue.search,startIcon:e(o,{icon:m,size:S[Xe]}),className:"mp-data-table__search min-w-0 flex-1"}):e("div",{className:"min-w-0 flex-1"}),de,Me?e(r,{size:Xe,variant:"text",color:Oe,onClick:()=>{const e=q.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),a=jt.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):V(e,t.row))),r=F([t,...a],{escapeFormulas:Ee});Le?Le(r):A(r,Pe,"text/csv;charset=utf-8")},startIcon:e(o,{icon:c,size:S[Xe]}),children:Je.download}):null]}):null,e("div",{className:"mp-data-table__scroll min-h-0 flex-1 overflow-auto",children:t("table",{className:Qt("text-mp-on-surface w-full text-start",C[Xe],Ve?.table),style:{borderCollapse:"collapse",...ve?{tableLayout:"fixed",minWidth:q.reduce((e,t)=>e+Wt(t),Dt?H[Xe]:0)}:void 0},children:[Q?e("caption",{className:`text-mp-on-surface-variant ${N}`,style:{...Ft,textAlign:"start"},children:Q}):null,t("colgroup",{children:[Dt?e("col",{style:{width:H[Xe]}}):null,q.map(t=>e("col",{style:ve||void 0!==ft[t.key]||void 0!==t.width?{width:Wt(t)}:void 0},t.key))]}),e("thead",{className:Ve?.head,children:t("tr",{children:[Dt?e("th",{scope:"col",className:Qt("whitespace-nowrap",Ae&&"sticky top-0 z-20"),style:Vt,children:e(n,{size:Xe,color:Oe,checked:Kt,indeterminate:It>0&&!Kt,onCheckedChange:()=>{Pt(Kt?[...bt].filter(e=>!At.includes(e)):[...new Set([...bt,...At])])},label:e("span",{className:j,children:Je.selectAll}),disabled:!Lt||0===At.length})}):null,q.map(a=>{const r=a.sortable??Z,n=(l=a.key,at.findIndex(e=>e.key===l));var l;const s=-1===n?void 0:at[n],i=a.resizable??ve,c=a.align??"start";return t("th",{scope:"col","aria-sort":r?void 0===s?"none":"asc"===s.direction?"ascending":"descending":void 0,className:Qt("text-mp-on-surface-variant relative whitespace-nowrap",z[Xe],Ae&&"sticky top-0 z-10"),style:{...Vt,textAlign:c},children:[r?t("button",{type:"button",className:Qt(X,"end"===c&&"justify-end","center"===c&&"justify-center"),onClick:e=>((e,t)=>{const a=K(at,e,t&&"multiple"===ee);void 0===te&&tt(a),re?.(a)})(a.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:a.label??a.key}),e(o,{icon:d,size:S[Xe]-6,className:Qt("shrink-0 transition-[rotate,opacity]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",void 0===s?"opacity-0 group-hover/sort:opacity-38":"text-mp-primary opacity-100","desc"===s?.direction&&"rotate-180")}),at.length>1&&-1!==n?e("span",{className:"text-mp-primary shrink-0 tabular-nums",children:n+1}):null]}):a.label??a.key,i?e("button",{type:"button","aria-label":Je.resize,className:O,onPointerDown:e=>((e,t)=>{const a=t.currentTarget;try{a.setPointerCapture(t.pointerId)}catch{}a.dataset.dragging="true";const r=document.body.style.userSelect;Rt.current=r,document.body.style.userSelect="none";const n=t.clientX,o=Wt(e),l="rtl"===getComputedStyle(a).direction?-1:1,s=Math.max(D,e.minWidth??D),i=t=>{Mt({...ft,[e.key]:Math.max(s,Math.round(o+(t.clientX-n)*l))})},c=()=>{a.removeEventListener("pointermove",i),a.removeEventListener("pointerup",c),a.removeEventListener("pointercancel",c),delete a.dataset.dragging,null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)};a.addEventListener("pointermove",i),a.addEventListener("pointerup",c),a.addEventListener("pointercancel",c)})(a,e),onDoubleClick:()=>Bt(a),onKeyDown:e=>{const t=e.shiftKey?32:8;"ArrowRight"===e.key?(e.preventDefault(),Tt(a,t)):"ArrowLeft"===e.key?(e.preventDefault(),Tt(a,-t)):"Home"===e.key&&(e.preventDefault(),Bt(a))}}):null]},a.key)})]})}),e("tbody",{children:0===zt.length?e("tr",{className:_,style:Ht,children:e("td",{colSpan:Xt,className:"text-mp-on-surface-variant",style:{padding:`2rem ${Ye}`,textAlign:"center"},children:U??Qe.empty})}):zt.map((a,r)=>{const o=bt.has(a.key);return t("tr",{"aria-selected":Et?o:void 0,className:Qt(_,Ve?.row,De&&(Ct.start+r)%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",o?"[--_mp-row:var(--_mp-color-secondary-container)]":"",qt&&!o?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",(Et||_e)&&"cursor-pointer",Ot&&["outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" ")),style:Ht,tabIndex:Ot?0:void 0,onClick:e=>$t(a,r,e.shiftKey),onKeyDown:Ot?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),$t(a,r,e.shiftKey))}:void 0,children:[Dt?e("td",{style:Ft,children:e(n,{size:Xe,color:Oe,checked:o,onCheckedChange:()=>$t(a,r,!1),label:e("span",{className:j,children:Je.selectRow})})}):null,q.map(t=>e("td",{className:Ve?.cell,style:{...Ft,textAlign:t.align??"start"},children:t.render?t.render(a.row,Ct.start+r):E(V(t,a.row))},t.key))]},a.key)})})]})}),Jt?t("div",{className:Qt("mp-data-table__footer border-mp-outline-variant flex flex-wrap items-center gap-3","text-mp-on-surface-variant border-t",N,Ve?.footer),style:{padding:`${Ze} ${Ye}`},children:[e("span",{className:"mp-data-table__count",children:v(Je.total,{total:String(jt.length)})}),bt.size>0?e("span",{className:"mp-data-table__selected text-mp-primary",children:v(Je.selected,{count:String(bt.size)})}):null,e("span",{className:"flex-1"}),me&&be.length>0?e(s,{size:"xs",label:Je.perPage,floatingLabel:!1,value:mt,onValueChange:e=>(e=>{void 0===he&&dt(e),_t(1),ge?.(e)})(Number(e)),items:be.map(e=>({value:e})),className:"mp-data-table__page-size",style:{minWidth:"9.5rem"}}):null,me?e(l,{size:"xs",color:Oe,count:Ct.pages,page:Ct.page,onPageChange:_t,locale:Ge}):null]}):null]})}
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{MPButton as n}from"../button/MPButton.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as o}from"../icon/MPIcon.js";import{MPPagination as l}from"../pagination/MPPagination.js";import{MPSelect as s}from"../select/MPSelect.js";import{MPTextField as i}from"../text-field/MPTextField.js";import{ArrowDownIcon as c,ArrowUpIcon as d,SearchIcon as m}from"../../constants/icons.js";import{accentSlots as u}from"../../internal/accent.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as f,useMPDensity as h,useMPSize as y}from"../../internal/config.js";import{useMPLocale as g,useMPMessages as b}from"../../internal/locale.js";import{fillMessage as v}from"../../internal/i18n.js";import{checkServerLocale as x,intlLocale as k}from"../../internal/intl.js";import{DATA_TABLE as w}from"../../internal/messages/data-table.js";import{TABLE as N}from"../../internal/messages/table.js";import{TRANSFER as S}from"../../internal/messages/transfer.js";import{CONTROL_ICON as C,META_TEXT as j}from"../../internal/scale.js";import{VISUALLY_HIDDEN as z}from"../../internal/visually-hidden.js";import{CELL_TEXT as _,HEAD_TEXT as M,ROW as P,cellPadX as L,cellPadY as E,drawableCell as $}from"../../internal/table.js";import{DEFAULT_COLUMN_WIDTH as A,MIN_COLUMN_WIDTH as D,compareValues as I,downloadText as K,keysBetween as R,nextSort as W,pageBounds as B,searchHaystack as F,searchText as T,sortRows as X,toCsv as V}from"../../internal/data-table.js";function H(e,t){return e.value?e.value(t):t[e.key]}const Y={xs:36,sm:40,md:48,lg:52,xl:60},q=/*@__PURE__*/["group/sort -m-1 flex w-full cursor-pointer items-center gap-1 rounded-mp-xs p-1","appearance-none border-0 bg-transparent text-inherit text-start [font:inherit]","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","hover:text-mp-on-surface","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),O=/*@__PURE__*/["mp-data-table__resize absolute inset-y-0 end-0 z-10 w-2 translate-x-1/2 rtl:-translate-x-1/2","cursor-col-resize touch-none select-none appearance-none border-0 bg-transparent p-0","after:absolute after:inset-y-1 after:start-1/2 after:w-px after:bg-transparent","after:transition-[background-color] after:duration-(--mp-sys-motion-duration-short4)","hover:after:bg-mp-primary data-dragging:after:bg-mp-primary","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-solid outline-none"].join(" "),G={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"};function J({entry:a,index:n,at:o,chosen:l,headers:s,striped:i,lit:c,pressable:d,selectable:m,tabStop:u,ticks:p,rowClassName:f,cellClassName:h,padX:y,padY:g,size:b,color:v,selectLabel:x,onPress:k}){const w={padding:`${g} ${y}`};return t("tr",{"aria-selected":m?l:void 0,className:[P,f,i&&o%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",l?"[--_mp-row:var(--_mp-color-secondary-container)]":"",c&&!l?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",d&&"cursor-pointer",u&&["outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" ")].filter(Boolean).join(" "),style:G,tabIndex:u?0:void 0,onClick:e=>k(a,n,e.shiftKey),onKeyDown:u?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),k(a,n,e.shiftKey))}:void 0,children:[p?e("td",{style:w,children:e(r,{size:b,color:v,checked:l,onCheckedChange:()=>k(a,n,!1),label:e("span",{className:z,children:x})})}):null,s.map(t=>e("td",{className:h,style:{...w,textAlign:t.align??"start"},children:t.render?t.render(a.row,o):$(H(t,a.row))},t.key))]})}const Q=/*@__PURE__*/a.memo(J);export function MPDataTable({headers:$,items:J,getRowKey:U,caption:Z,empty:ee,locale:te,sortable:ae=!1,sortMode:ne="single",sort:re,defaultSort:oe,onSortChange:le,searchable:se=!1,search:ie,defaultSearch:ce,onSearchChange:de,searchLabel:me,filter:ue,toolbar:pe,paged:fe=!1,page:he,defaultPage:ye,onPageChange:ge,pageSize:be,defaultPageSize:ve,onPageSizeChange:xe,pageSizeOptions:ke=[10,25,50,100],resizable:we=!1,columnWidths:Ne,defaultColumnWidths:Se,onColumnWidthsChange:Ce,selectionMode:je="none",selected:ze,defaultSelected:_e,onSelectedChange:Me,checkboxes:Pe=!1,onRowClick:Le,exportable:Ee=!1,exportFileName:$e="table.csv",exportEscapeFormulas:Ae=!0,onExport:De,striped:Ie=!1,hoverable:Ke=!1,stickyHeader:Re=!1,variant:We="outlined",elevation:Be,size:Fe,color:Te,density:Xe,className:Ve,style:He,classNames:Ye,...qe}){const Oe=y(Fe),Ge=f(Te),Je=h(Xe),Qe=g(te),Ue=b(w,Qe),Ze=b(N,Qe),et=b(S,Qe),tt=L(Oe,Je),at=E(Oe,Je),[nt,rt]=a.useState(()=>[...oe??[]]),ot=re??nt,[lt,st]=a.useState(ce??""),it=ie??lt,[ct,dt]=a.useState(ye??1),mt=he??ct,[ut,pt]=a.useState(ve??25),ft=be??ut,[ht,yt]=a.useState(()=>({...Se})),gt=Ne??ht,[bt,vt]=a.useState(()=>[..._e??[]]),xt=ze??bt,kt=a.useMemo(()=>new Set(xt.map(e=>String(e))),[xt]),wt=a.useRef(null),Nt=a.useMemo(()=>J.map((e,t)=>{const a=U?U(e,t):t;return{row:e,identity:a,key:String(a),origin:t}}),[J,U]),St=T(it.trim()),Ct=""!==St,jt=a.useMemo(()=>{if(!Ct)return null;const e=$.filter(e=>!1!==e.searchable);return Nt.map(t=>F(e.map(e=>H(e,t.row))))},[Nt,$,Ct]),zt=a.useMemo(()=>{const e=""!==St&&jt?Nt.filter((e,t)=>jt[t].includes(St)):Nt;return ue?e.filter(e=>ue(e.row,e.origin)):e},[Nt,jt,St,ue]),_t=a.useMemo(()=>(x(Qe),new Intl.Collator(k(Qe),{numeric:!0,sensitivity:"base"})),[Qe]),Mt=a.useMemo(()=>X(zt,ot,(e,t)=>{const a=$.find(t=>t.key===e);if(!a)return null;const n="desc"===t,r=a.compare;if(r)return(e,t)=>n?-r(e.row,t.row):r(e.row,t.row);const o=new Map,l=e=>(o.has(e)||o.set(e,H(a,e.row)),o.get(e));return(e,t)=>I(l(e),l(t),_t,n)}),[zt,ot,$,_t]),Pt=B(Mt.length,mt,ft),Lt=fe?Mt.slice(Pt.start,Pt.end):Mt,Et=e=>{void 0===he&&dt(e),ge?.(e)},$t=e=>{void 0===Ne&&yt(e),Ce?.(e)},At=e=>{const t=new Set(e),a=[],n=[];for(const e of Nt)t.has(e.key)&&(n.push(e.identity),a.push(e.row));void 0===ze&&vt(n),Me?.(n,a)},Dt="none"!==je,It="multiple"===je,Kt=Pe&&Dt,Rt=(e,t,a)=>{if(Le?.(e.row,Pt.start+t),Dt){if(!It)return At(kt.has(e.key)?[]:[e.key]),void(wt.current=e.key);if(a&&null!==wt.current){const t=R(Lt.map(e=>e.key),wt.current,e.key);return void At([...new Set([...kt,...t])])}wt.current=e.key,At(kt.has(e.key)?[...kt].filter(t=>t!==e.key):[...kt,e.key])}},Wt=a.useRef(Rt);Wt.current=Rt;const Bt=a.useCallback((e,t,a)=>Wt.current(e,t,a),[]),Ft=Lt.map(e=>e.key),Tt=Ft.filter(e=>kt.has(e)).length,Xt=Ft.length>0&&Tt===Ft.length,Vt=e=>gt[e.key]??e.width??A,Ht=a.useRef(null);a.useEffect(()=>()=>{null!==Ht.current&&(document.body.style.userSelect=Ht.current,Ht.current=null)},[]);const Yt=(e,t)=>{const a=Math.max(D,e.minWidth??D);$t({...gt,[e.key]:Math.max(a,Vt(e)+t)})},qt=e=>{const t={...gt};delete t[e.key],$t(t)},Ot={padding:`${at} ${tt}`},Gt={...Ot,backgroundColor:"var(--_mp-color-surface-container)"},Jt=G,Qt=$.length+(Kt?1:0),Ut=Boolean(Le)||Dt&&!Kt,Zt=Ke||Dt||Boolean(Le),ea=se||Ee||void 0!==pe,ta=fe||Dt,aa=(...e)=>e.filter(Boolean).join(" ");return t("div",{"data-mp-size":Oe,"data-mp-variant":We,className:aa("mp-data-table rounded-mp-md flex flex-col",p(We,Be),Ve),style:{...u(Ge),...He},...qe,children:[ea?t("div",{className:aa("mp-data-table__toolbar flex flex-wrap items-center gap-2",Ye?.toolbar),style:{padding:`${at} ${tt}`},children:[se?e(i,{size:Oe,value:it,onChange:e=>{void 0===ie&&st(e),Et(1),de?.(e)},label:me??et.search,startIcon:e(o,{icon:m,size:C[Oe]}),className:"mp-data-table__search min-w-0 flex-1"}):e("div",{className:"min-w-0 flex-1"}),pe,Ee?e(n,{size:Oe,variant:"text",color:Ge,onClick:()=>{const e=$.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),a=Mt.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):H(e,t.row))),n=V([t,...a],{escapeFormulas:Ae});De?De(n):K(n,$e,"text/csv;charset=utf-8")},startIcon:e(o,{icon:c,size:C[Oe]}),children:Ue.download}):null]}):null,e("div",{className:"mp-data-table__scroll min-h-0 flex-1 overflow-auto",children:t("table",{className:aa("text-mp-on-surface w-full text-start",_[Oe],Ye?.table),style:{borderCollapse:"collapse",...we?{tableLayout:"fixed",minWidth:$.reduce((e,t)=>e+Vt(t),Kt?Y[Oe]:0)}:void 0},children:[Z?e("caption",{className:`text-mp-on-surface-variant ${j}`,style:{...Ot,textAlign:"start"},children:Z}):null,t("colgroup",{children:[Kt?e("col",{style:{width:Y[Oe]}}):null,$.map(t=>e("col",{style:we||void 0!==gt[t.key]||void 0!==t.width?{width:Vt(t)}:void 0},t.key))]}),e("thead",{className:Ye?.head,children:t("tr",{children:[Kt?e("th",{scope:"col",className:aa("whitespace-nowrap",Re&&"sticky top-0 z-20"),style:Gt,children:e(r,{size:Oe,color:Ge,checked:Xt,indeterminate:Tt>0&&!Xt,onCheckedChange:()=>{const e=new Set(Ft);At(Xt?[...kt].filter(t=>!e.has(t)):[...new Set([...kt,...Ft])])},label:e("span",{className:z,children:Ue.selectAll}),disabled:!It||0===Ft.length})}):null,$.map(a=>{const n=a.sortable??ae,r=(l=a.key,ot.findIndex(e=>e.key===l));var l;const s=-1===r?void 0:ot[r],i=a.resizable??we,c=a.align??"start";return t("th",{scope:"col","aria-sort":n?void 0===s?"none":"asc"===s.direction?"ascending":"descending":void 0,className:aa("text-mp-on-surface-variant relative whitespace-nowrap",M[Oe],Re&&"sticky top-0 z-10"),style:{...Gt,textAlign:c},children:[n?t("button",{type:"button",className:aa(q,"end"===c&&"justify-end","center"===c&&"justify-center"),onClick:e=>((e,t)=>{const a=W(ot,e,t&&"multiple"===ne);void 0===re&&rt(a),le?.(a)})(a.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:a.label??a.key}),e(o,{icon:d,size:C[Oe]-6,className:aa("shrink-0 transition-[rotate,opacity]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",void 0===s?"opacity-0 group-hover/sort:opacity-38":"text-mp-primary opacity-100","desc"===s?.direction&&"rotate-180")}),ot.length>1&&-1!==r?e("span",{className:"text-mp-primary shrink-0 tabular-nums",children:r+1}):null]}):a.label??a.key,i?e("button",{type:"button","aria-label":Ue.resize,className:O,onPointerDown:e=>((e,t)=>{const a=t.currentTarget;try{a.setPointerCapture(t.pointerId)}catch{}a.dataset.dragging="true";const n=document.body.style.userSelect;Ht.current=n,document.body.style.userSelect="none";const r=t.clientX,o=Vt(e),l="rtl"===getComputedStyle(a).direction?-1:1,s=Math.max(D,e.minWidth??D);let i=null,c=0;const d=()=>{c=0,null!==i&&($t({...gt,[e.key]:i}),i=null)},m=e=>{i=Math.max(s,Math.round(o+(e.clientX-r)*l)),0===c&&(c=requestAnimationFrame(d))},u=()=>{cancelAnimationFrame(c),d(),a.removeEventListener("pointermove",m),a.removeEventListener("pointerup",u),a.removeEventListener("pointercancel",u),delete a.dataset.dragging,null!==Ht.current&&(document.body.style.userSelect=Ht.current,Ht.current=null)};a.addEventListener("pointermove",m),a.addEventListener("pointerup",u),a.addEventListener("pointercancel",u)})(a,e),onDoubleClick:()=>qt(a),onKeyDown:e=>{const t=e.shiftKey?32:8;"ArrowRight"===e.key?(e.preventDefault(),Yt(a,t)):"ArrowLeft"===e.key?(e.preventDefault(),Yt(a,-t)):"Home"===e.key&&(e.preventDefault(),qt(a))}}):null]},a.key)})]})}),e("tbody",{children:0===Lt.length?e("tr",{className:P,style:Jt,children:e("td",{colSpan:Qt,className:"text-mp-on-surface-variant",style:{padding:`2rem ${tt}`,textAlign:"center"},children:ee??Ze.empty})}):Lt.map((t,a)=>e(Q,{entry:t,index:a,at:Pt.start+a,chosen:kt.has(t.key),headers:$,striped:Ie,lit:Zt,pressable:Dt||Boolean(Le),selectable:Dt,tabStop:Ut,ticks:Kt,rowClassName:Ye?.row,cellClassName:Ye?.cell,padX:tt,padY:at,size:Oe,color:Ge,selectLabel:Ue.selectRow,onPress:Bt},t.key))})]})}),ta?t("div",{className:aa("mp-data-table__footer border-mp-outline-variant flex flex-wrap items-center gap-3","text-mp-on-surface-variant border-t",j,Ye?.footer),style:{padding:`${at} ${tt}`},children:[e("span",{className:"mp-data-table__count",children:v(Ue.total,{total:String(Mt.length)})}),kt.size>0?e("span",{className:"mp-data-table__selected text-mp-primary",children:v(Ue.selected,{count:String(kt.size)})}):null,e("span",{className:"flex-1"}),fe&&ke.length>0?e(s,{size:"xs",label:Ue.perPage,floatingLabel:!1,value:ft,onValueChange:e=>(e=>{void 0===be&&pt(e),Et(1),xe?.(e)})(Number(e)),items:ke.map(e=>({value:e})),className:"mp-data-table__page-size",style:{minWidth:"9.5rem"}}):null,fe?e(l,{size:"xs",color:Ge,count:Pt.pages,page:Pt.page,onPageChange:Et,locale:Qe}):null]}):null]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{Calendar as o}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{MPWidthSizer as h}from"../../internal/WidthSizer.js";import{CONTROL_ICON as v,META_TEXT as x}from"../../internal/scale.js";import{addMonths as g,compareDay as j,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as D,today as k,withPlaceholder as y}from"../../internal/date.js";import{useMPColor as O,useMPSize as P}from"../../internal/config.js";const z={start:null,end:null};export const MPDateRangePicker=/*@__PURE__*/n.forwardRef(function({value:M,defaultValue:B,onValueChange:I,open:R,defaultOpen:V,onOpenChange:E,defaultMonth:F,minDate:W,maxDate:$,shouldDisableDate:_,locale:q,weekStartsOn:A,format:G={dateStyle:"medium"},monthCount:H=2,startPlaceholder:J,endPlaceholder:K,presets:L,clearable:Q=!1,closeOnSelect:T=!0,labels:U,name:X,size:Y,color:Z,readOnly:ee=!1,disabled:le=!1,startIcon:ne,...ae},te){const re=P(Y),se=O(Z),oe=d(q),ie=p(f,oe,U),ce=A??N(oe),[ue,me]=n.useState(B??z),de=void 0!==M?M??z:ue,pe=w(de.start)?de.start:null,fe=w(de.end)?de.end:null,[he,ve]=n.useState(V??!1),xe=R??he,[ge,je]=n.useState(null),[be,we]=n.useState(null),[Ne,Se]=n.useState(()=>C(pe??F??k()));n.useEffect(()=>{xe?Se(C(pe??F??k())):(je(null),we(null))},[xe]);const Ce=e=>{e&&(ee||le)||(void 0===R&&ve(e),E?.(e))},De=e=>{void 0===M&&me(e),I?.(e)},ke=ge??pe,ye=null!==ge?be:fe,Oe=(l,n)=>w(l)?b(l,oe,G):e("span",{className:"text-mp-on-surface-variant",children:n??""}),Pe=g(Ne,1),ze=2===H,Me=m(oe,G),Be=null!==ge?ie.end:null===pe?ie.start:null,Ie={size:re,color:se,locale:oe,weekStartsOn:ce,selected:[pe,fe,ge],rangeStart:ke,rangeEnd:ye,onSelect:e=>{const l=S(e);if(null===ge)return je(l),we(l),void De({start:l,end:null});const[n,a]=j(l,ge)<0?[l,ge]:[ge,l];je(null),we(null),De({start:n,end:a}),T&&Ce(!1)},onPreviewChange:e=>{null!==ge&&we(e??ge)},minDate:W,maxDate:$,shouldDisableDate:_,showOutsideDays:!1,labels:ie};return e(u,{...ae,slug:"date-range-picker",size:re,color:se,readOnly:ee,disabled:le,triggerRef:te,startIcon:void 0===ne?e(t,{icon:s,size:v[re]}):ne,display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(pe,J)}),e(h,{samples:y(Me,J)})]}),e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center rtl:rotate-180",children:e(t,{icon:r,size:v[re]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(fe,K)}),e(h,{samples:y(Me,K)})]})]}),empty:null===pe&&null===fe,clearable:Q,onClear:()=>De(z),open:xe,onOpenChange:Ce,labels:ie,hiddenValues:X?[{name:X,value:pe?D(pe):""},{name:X,value:fe?D(fe):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[L&&L.length>0?e("div",{className:"border-mp-outline-variant flex max-h-[calc(var(--_mp-cell,2.5rem)*8)] flex-col overflow-y-auto border-e pe-1.5",children:L.map((l,n)=>e(a,{variant:"text",size:i[re],color:se,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;je(null),we(null),De(l),w(l.start)&&Se(C(l.start)),T&&Ce(!1)})(l),children:l.label},n))}):null,e(o,{...Ie,month:Ne,onMonthChange:Se,showNextButton:!ze,autoFocus:!0}),ze?e(o,{...Ie,month:Pe,onMonthChange:e=>Se(g(e,-1)),showPreviousButton:!1}):null]}),Q||null!==Be?l(c,{children:[null!==Be?e("span",{className:`text-mp-on-surface-variant me-auto ${x}`,children:Be}):null,Q?e(a,{variant:"text",size:i[re],color:se,onClick:()=>{je(null),we(null),De(z),Ce(!1)},children:ie.clear}):null]}):null]})})});
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{Calendar as o}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{MPWidthSizer as h}from"../../internal/WidthSizer.js";import{CONTROL_ICON as v,META_TEXT as x}from"../../internal/scale.js";import{addMonths as g,compareDay as j,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as D,today as k,withPlaceholder as y}from"../../internal/date.js";import{useMPColor as O,useMPSize as P}from"../../internal/config.js";const z={start:null,end:null};export const MPDateRangePicker=/*@__PURE__*/n.forwardRef(function({value:M,defaultValue:B,onValueChange:I,open:R,defaultOpen:V,onOpenChange:E,defaultMonth:F,minDate:W,maxDate:$,shouldDisableDate:_,locale:q,weekStartsOn:A,format:G={dateStyle:"medium"},monthCount:H=2,startPlaceholder:J,endPlaceholder:K,presets:L,clearable:Q=!1,closeOnSelect:T=!0,labels:U,name:X,size:Y,color:Z,readOnly:ee=!1,disabled:le=!1,startIcon:ne,...ae},te){const re=P(Y),se=O(Z),oe=d(q),ie=p(f,oe,U),ce=A??N(oe),[ue,me]=n.useState(B??z),de=void 0!==M?M??z:ue,pe=w(de.start)?de.start:null,fe=w(de.end)?de.end:null,[he,ve]=n.useState(V??!1),xe=R??he,[ge,je]=n.useState(null),[be,we]=n.useState(null),[Ne,Se]=n.useState(()=>C(pe??F??k()));n.useEffect(()=>{xe?Se(C(pe??F??k())):(je(null),we(null))},[xe]);const Ce=e=>{e&&(ee||le)||(void 0===R&&ve(e),E?.(e))},De=e=>{void 0===M&&me(e),I?.(e)},ke=ge??pe,ye=null!==ge?be:fe,Oe=(l,n)=>w(l)?b(l,oe,G):e("span",{className:"text-mp-on-surface-variant",children:n??""}),Pe=n.useMemo(()=>g(Ne,1),[Ne]),ze=2===H,Me=m(oe,G),Be=null!==ge?ie.end:null===pe?ie.start:null,Ie={size:re,color:se,locale:oe,weekStartsOn:ce,selected:[pe,fe,ge],rangeStart:ke,rangeEnd:ye,onSelect:e=>{const l=S(e);if(null===ge)return je(l),we(l),void De({start:l,end:null});const[n,a]=j(l,ge)<0?[l,ge]:[ge,l];je(null),we(null),De({start:n,end:a}),T&&Ce(!1)},onPreviewChange:e=>{null!==ge&&we(e??ge)},minDate:W,maxDate:$,shouldDisableDate:_,showOutsideDays:!1,labels:ie};return e(u,{...ae,slug:"date-range-picker",size:re,color:se,readOnly:ee,disabled:le,triggerRef:te,startIcon:void 0===ne?e(t,{icon:s,size:v[re]}):ne,display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(pe,J)}),e(h,{samples:y(Me,J)})]}),e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center rtl:rotate-180",children:e(t,{icon:r,size:v[re]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(fe,K)}),e(h,{samples:y(Me,K)})]})]}),empty:null===pe&&null===fe,clearable:Q,onClear:()=>De(z),open:xe,onOpenChange:Ce,labels:ie,hiddenValues:X?[{name:X,value:pe?D(pe):""},{name:X,value:fe?D(fe):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[L&&L.length>0?e("div",{className:"border-mp-outline-variant flex max-h-[calc(var(--_mp-cell,2.5rem)*8)] flex-col overflow-y-auto border-e pe-1.5",children:L.map((l,n)=>e(a,{variant:"text",size:i[re],color:se,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;je(null),we(null),De(l),w(l.start)&&Se(C(l.start)),T&&Ce(!1)})(l),children:l.label},n))}):null,e(o,{...Ie,month:Ne,onMonthChange:Se,showNextButton:!ze,autoFocus:!0}),ze?e(o,{...Ie,month:Pe,onMonthChange:e=>Se(g(e,-1)),showPreviousButton:!1}):null]}),Q||null!==Be?l(c,{children:[null!==Be?e("span",{className:`text-mp-on-surface-variant me-auto ${x}`,children:Be}):null,Q?e(a,{variant:"text",size:i[re],color:se,onClick:()=>{je(null),we(null),De(z),Ce(!1)},children:ie.clear}):null]}):null]})})});
|
|
@@ -113,6 +113,18 @@ export interface MPDrawerProps {
|
|
|
113
113
|
* @default true
|
|
114
114
|
*/
|
|
115
115
|
dismissible?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Keeps a closed `modal` drawer's contents in the document, hidden, instead
|
|
118
|
+
* of taking them out of it.
|
|
119
|
+
*
|
|
120
|
+
* For a drawer that is a site's navigation on a narrow screen: closed, its
|
|
121
|
+
* links are otherwise not on the page at all, which is the page a crawler
|
|
122
|
+
* renders at a phone's width. A modal drawer is drawn into a portal, which no
|
|
123
|
+
* server renders, so the links arrive with hydration either way — a server
|
|
124
|
+
* should still send them somewhere in the page itself.
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
keepMounted?: boolean;
|
|
116
128
|
/**
|
|
117
129
|
* How far the panel reaches in by default, and the type scale inside it.
|
|
118
130
|
* `md` is MD3's own 360dp navigation drawer.
|
|
@@ -190,4 +202,4 @@ export declare const MPDrawerClose: React.ForwardRefExoticComponent<Omit<import(
|
|
|
190
202
|
* `SLIDE` gives a reader who asked for less motion the old behaviour exactly:
|
|
191
203
|
* the fade, with nowhere to travel from.
|
|
192
204
|
*/
|
|
193
|
-
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size: sizeProp, classNames, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
205
|
+
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, keepMounted, size: sizeProp, classNames, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
@@ -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
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as o from"react";import{Dialog as a}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as i}from"../../constants/icons.js";import{useMPLocale as r,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 h,SHEET_PAD_X as x,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 N}from"../../internal/config.js";const $={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},k={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},C={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}`,M="border-mp-outline-variant border-t";export const MPDrawerClose=a.Close;export function MPDrawer({side:w="left",mode:D="modal",open:O,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,keepMounted:K=!1,size:Q,classNames:U,className:W,style:X,children:Y}){const Z=N(Q),_=r(E),ee=s(d,_),te="modal"===D,le="left"===w||"right"===w,oe=q??te,ae=A??ee.close,[ne,ie]=o.useState(L??!0),re=O??ne,se=x[Z],de=g[Z],me=V?`${se} ${de}`:se,fe=c(F)||c(I),ce=c(R),pe=void 0===G?null:{[le?"width":"height"]:f(G)},ue=["mp-drawer relative flex flex-col overflow-hidden box-border","[&[hidden]]:hidden","border-mp-outline-variant outline-none",te?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",u[Z],C[w],H?k[w]:"",te?`${B} ${P[w]}`:"",le?`h-full max-w-full ${void 0===G?$[Z]:""}`:"w-full "+(void 0===G?"max-h-[85%]":""),V?"":`${de} ${h[Z]}`,W??""].filter(Boolean).join(" "),he=te?a.Title:"h2",xe=te?a.Description:"p",ge=/*@__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(" "),be=t(l,{children:[fe||oe?t("div",{className:`flex shrink-0 items-start gap-3 ${me}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(F)?e(he,{className:`m-0 ${b[Z]}`,children:F}):null,c(I)?e(xe,{className:`text-mp-on-surface-variant m-0 ${p}`,children:I}):null]}),oe?te?t(a.Close,{"aria-label":ae,className:ge,children:[e(m,{}),e(n,{icon:i,size:20})]}):t("button",{type:"button","aria-label":ae,className:ge,onClick:()=>{void 0===O&&ie(!1),S?.(!1)},children:[e(m,{}),e(n,{icon:i,size:20})]}):null]}):null,c(Y)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",me,V&&(fe||oe)?M:"",V?"":"-my-1 py-1"].filter(Boolean).join(" "),children:Y}):null,ce?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",me,V?M:""].filter(Boolean).join(" "),children:R}):null]});return te?t(a.Root,{open:O,defaultOpen:L,disablePointerDismissal:!J,onOpenChange:(e,t)=>{J||e||"escape-key"!==t.reason?S?.(e):t.cancel()},children:[T?e(a.Trigger,{render:T}):null,t(a.Portal,{keepMounted:K,children:[e(a.Backdrop,{className:[`${j} fixed inset-0`,y,v,U?.backdrop??""].filter(Boolean).join(" ")}),e(a.Viewport,{className:`${j} fixed inset-0 flex [&[hidden]]:hidden ${z[w]}`,children:e(a.Popup,{"data-mp-size":Z,"data-mp-side":w,"data-mp-mode":D,className:ue,style:{...pe,...X},children:be})})]})]}):re?e("div",{"data-mp-size":Z,"data-mp-side":w,"data-mp-mode":D,className:ue,style:{...pe,...X},children:be}):null}
|
|
@@ -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 o}from"../../internal/i18n.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER 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 o}from"../../internal/i18n.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as u}from"../../internal/messages/file-picker.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{CONTROL_ICON as p,META_TEXT as f,PROSE_TEXT as d,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){return`${e.name}-${e.size}-${e.lastModified}`}const j=new Set;function y(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:N,multiple:k=!1,maxSize:w,maxFiles:z,value:C,defaultValue:B,onFilesChange:I,onReject:S,label:D,description:L,errorMessage:$,title:E,hint:F,icon:M,showList:T=!0,removeLabel:R,locale:W,size:_,fullWidth:P=!0,required:O=!1,disabled:q=!1,readOnly:A=!1,name:V,id:G,className:H,style:Y},J){const K=b(_),Q=l(W),U=s(c,Q),X=s(u,Q),Z=n.useRef(null);n.useImperativeHandle(J,()=>Z.current,[]);const[ee,re]=n.useState(()=>[...B??[]]),ne=C?[...C]:ee,te=n.useRef(0),[ae,ie]=n.useState(!1),oe=x($),le=q||A,se=n.useId(),ce=n.useId(),ue=n.useRef([]),me=n.useCallback(e=>{const r=Z.current;if(!r||"undefined"==typeof DataTransfer)return;const n=new DataTransfer;for(const r of e)n.items.add(r);r.files=n.files,ue.current=e},[]);n.useEffect(()=>{ue.current.length===ne.length&&ue.current.every((e,r)=>e===ne[r])||me(ne)}),n.useEffect(()=>{const e=Z.current;if(!e)return;const r=()=>me(ue.current);return e.addEventListener("cancel",r),()=>e.removeEventListener("cancel",r)},[me]);const pe=n.useCallback(e=>{C||re(e),I?.(e)},[I,C]),fe=n.useCallback(e=>{const r=[],n=[],t=k?z??Number.POSITIVE_INFINITY:1,a=k?ne.length:0;for(const i of e)N&&!y(i,N)?n.push({file:i,reason:"type"}):void 0!==w&&i.size>w?n.push({file:i,reason:"size"}):a+r.length>=t?n.push({file:i,reason:"count"}):r.push(i);return{kept:r,rejections:n}},[N,ne.length,z,w,k]),[de,he]=n.useState(j),xe=n.useCallback(e=>{const{kept:r,rejections:n}=fe(e);n.length>0&&S?.(n),r.length>0&&(he(new Set(r.map(g))),pe(k?[...ne,...r]:r))},[fe,pe,ne,k,S]);return r("div",{className:["mp-file-picker flex-col align-top",h[K],P?"flex w-full":"inline-flex",H??""].filter(Boolean).join(" "),style:Y,"data-mp-size":K,"data-disabled":q||void 0,"data-invalid":oe||void 0,children:[x(D)?r("span",{id:ce,className:[f,q?"text-mp-on-surface/38":oe?"text-mp-error":"text-mp-on-surface-variant"].join(" "),children:[D,O?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,r("div",{className:"relative flex w-full flex-col",onDragEnter:e=>{le||(e.preventDefault(),te.current+=1,ie(!0))},onDragOver:e=>{le||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{le||(te.current=Math.max(0,te.current-1),0===te.current&&ie(!1))},onDrop:e=>{le||(e.preventDefault(),te.current=0,ie(!1),xe(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:G,disabled:q,"aria-describedby":x(L)||oe?se:void 0,"aria-invalid":oe||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[K],d[K],q?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":[A?"cursor-default":"cursor-pointer",oe?"border-mp-error":"border-mp-outline-variant","text-mp-on-surface",ae?"border-mp-primary bg-mp-primary/8":""].filter(Boolean).join(" ")].filter(Boolean).join(" "),onClick:()=>{!le&&Z.current&&(Z.current.value="",Z.current.click())},children:[le?null:e(m,{layer:"inset-0 rounded-[inherit] bg-mp-primary"}),void 0===M?e(t,{icon:i,size:1.6*p[K],className:q?"":"text-mp-primary"}):x(M)?e("span",{className:q?"":"text-mp-primary",children:M}):null,e("span",{className:"font-medium",children:E??X.prompt}),x(F)?e("span",{className:[f,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:F}):null]}),e("input",{ref:Z,type:"file",name:V,accept:N,multiple:k,required:O&&0===ne.length,disabled:le,tabIndex:-1,"aria-labelledby":x(D)?ce:void 0,"aria-describedby":x(L)||oe?se:void 0,className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>xe(Array.from(e.target.files??[]))})]}),T&&ne.length>0?e("ul",{className:["mp-file-picker__list m-0 flex w-full list-none flex-col p-0",h[K]].join(" "),children:ne.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",d[K],q?"text-mp-on-surface/38":"text-mp-on-surface",de.has(g(n))?"mp-row-arrive":""].filter(Boolean).join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:[f,"shrink-0 tabular-nums",q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:formatFileSize(n.size)}),le?null:r("button",{type:"button","aria-label":R?R(n.name):o(U.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:()=>pe(ne.filter((e,r)=>r!==i)),children:[e(m,{}),e(t,{icon:a,size:18})]})]},`${g(n)}-${i}`))}):null,oe?e("span",{id:se,className:[f,"text-mp-error"].join(" "),children:$}):x(L)?e("span",{id:se,className:[f,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:L}):null]})});
|
|
@@ -33,6 +33,9 @@ export interface MPFormProps extends Omit<React.ComponentPropsWithoutRef<'form'>
|
|
|
33
33
|
/**
|
|
34
34
|
* Called on a valid submit, with the form's values. The native submit event is
|
|
35
35
|
* prevented, so nothing navigates.
|
|
36
|
+
*
|
|
37
|
+
* Leave it out and give the form an `action` — a URL, or a React server
|
|
38
|
+
* action — and a valid submit goes to the action instead.
|
|
36
39
|
*/
|
|
37
40
|
onSubmit?: (values: Record<string, unknown>) => void;
|
|
38
41
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
import{jsx as o}from"react/jsx-runtime";import*as r from"react";import{Form as i}from"@base-ui/react/form";import{useMPSize as e}from"../../internal/config.js";import{SHEET_GAP as t}from"../../internal/scale.js";export const MPForm=/*@__PURE__*/r.forwardRef(function({validationMode:r="onSubmit",errors:a,onSubmit:m,size:n,className:s,children:f,...c},l){const d=e(n);return o(i,{ref:l,validationMode:r,errors:a,onFormSubmit:m||void 0===c.action?o=>m?.(o):void 0,"data-mp-size":d,className:["mp-form flex flex-col",t[d],s??""].filter(Boolean).join(" "),...c,children:f})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Meter as l}from"@base-ui/react/meter";import{useBoxSize as r}from"../../internal/box-size.js";import{useMPColor as o,useMPSize as i}from"../../internal/config.js";import{useMPLocale as m}from"../../internal/locale.js";import{intlLocale as s}from"../../internal/intl.js";import{accentSlots as n}from"../../internal/accent.js";import{thresholdColor as c}from"../../internal/threshold.js";import{progressFraction as h}from"../../internal/progress.js";import{CHART_FONT_SIZE as p,PLOT_HEIGHT as f,arcPath as u,formatStatistic as d}from"../../internal/chart.js";import{cssLength as x}from"../../internal/length.js";import{META_TEXT as g}from"../../internal/scale.js";const v={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-display-small"};export function MPGaugeChart({value:j,min:b=0,max:_=100,sweep:M=240,label:y,thresholds:w,bands:N=!1,color:$,format:P,locale:z,height:I,size:B,className:R,style:k,...C}){const G=i(B),L=o($),V=m(z),W=a.useRef(null),q=r(W),A=h(j,b,_)??0,D=c(j,L,w),E=p[G],F=q.width,H="number"==typeof I?I:void 0===I?f[G]:q.height,J=Math.min(300,Math.max(30,M))*Math.PI/180,K=J/2,O=K>Math.PI/2?Math.cos(Math.PI-K):0,Q=F>0?Math.min(F/2,H/(1+O)):H/(1+O),S=Math.max(0,Q-2),T=.78*S,U=F/2,X=S+2,Y=-K,Z=K,tt=Y+A*J,et=a.useMemo(()=>{if(!N||!w||0===w.length)return[{from:0,to:1,color:L}];const t=[...w.map(t=>({at:h(t.from,b,_)??0,color:t.color})).filter(t=>t.at>0&&t.at<1).sort((t,e)=>t.at-e.at)],e=[];let a=0,l=L;for(const r of t)e.push({from:a,to:r.at,color:l}),a=r.at,l=r.color;return e.push({from:a,to:1,color:l}),e},[N,w,L,b,_]),at=d(j,V,P,!1);return e(l.Root,{value:j,min:b,max:_,format:P,locale:s(V),"data-mp-size":G,className:["mp-gauge-chart flex min-w-0 flex-col items-center",R??""].filter(Boolean).join(" "),style:{...n(D),...k},...C,children:[e("div",{ref:W,className:"mp-gauge-chart__dial relative w-full",style:{height:x(I)??f[G]},children:[F>0&&S>0?e("svg",{width:F,height:H,viewBox:`0 0 ${F} ${H}`,"aria-hidden":"true",className:"block overflow-visible",children:[et.map((e,a)=>t("path",{d:u(U,X,S,T,Y+e.from*J,Y+e.to*J),fill:N?`var(--_mp-color-${e.color})`:"var(--_mp-color-on-surface)",opacity:N?.22:.12},a)),t("path",{d:u(U,X,S,T,Y,tt),fill:"var(--_mp-accent)"}),t("path",{d:u(U,X,S,T,Y,Y+.004*J),fill:"var(--_mp-color-outline)"}),t("path",{d:u(U,X,S,T,Z-.004*J,Z),fill:"var(--_mp-color-outline)"})]}):null,e("div",{className:"pointer-events-none absolute inset-x-0 flex flex-col items-center",style:{top:X-.45*T},children:[t(l.Value,{className:`mp-gauge-chart__value text-mp-on-surface font-medium tabular-nums ${v[G]}`,children:t=>P?t:at}),y?t(l.Label,{className:`mp-gauge-chart__label text-mp-on-surface-variant ${g}`,style:{maxWidth:1.8*T},children:y}):null]})]}),O>0?t("span",{"aria-hidden":"true",style:{height:E/2}}):null]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as i from"react";import{useRender as n}from"@base-ui/react/use-render";import{barSurface as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as i from"react";import{useRender as n}from"@base-ui/react/use-render";import{barSurface as a,MPPageLayoutContext as r}from"../../internal/page-layout.js";import{hasContent as s}from"../../internal/scale.js";import{sheetPadX as m}from"../../internal/density.js";import{measureValue as l}from"../../internal/measure.js";import{useWindowMins as o}from"../../internal/window-class.js";import{responsiveSlots as d,withBaseline as p}from"../../internal/responsive.js";import{useMPDensity as c,useMPSize as f}from"../../internal/config.js";const x={xs:"min-h-12",sm:"min-h-14",md:"min-h-16",lg:"min-h-20",xl:"min-h-24"},u={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"},h={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-4",xl:"gap-5"},g={xs:"gap-3",sm:"gap-4",md:"gap-6",lg:"gap-8",xl:"gap-10"},j={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"},b={start:"shrink-0",center:"flex-1 basis-0",end:"shrink-0"},v={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__*/i.forwardRef(function({brand:y,actions:w,align:N="start",position:k="sticky",variant:_="tonal",elevation:z,size:B,density:C,maxWidth:$="none",padded:H=!0,label:M,render:P,className:R,children:W,...q},A){const D=f(B),E=c(C),F=o(),{register:G}=i.useContext(r),I=i.useCallback(e=>{G("header",e),"function"==typeof A?A(e):A&&(A.current=e)},[G,A]);return n({render:P??e("header",{}),ref:I,props:{"aria-label":M,"data-mp-size":D,"data-mp-variant":_,"data-mp-position":k,className:["mp-header text-mp-on-surface box-border w-full min-w-0",a(_,z),"outlined"===_?"border-mp-outline-variant border-b":"",j[k],R??""].filter(Boolean).join(" "),children:t("div",{className:["flex w-full items-center",x[D],g[D],H?m(D,E):"","none"===$?"":"mp-measure mx-auto"].filter(Boolean).join(" "),style:"none"===$?void 0:d("measure",p($,"none"),e=>l(e,F)),children:[s(y)?e("div",{className:["mp-header__brand flex min-w-0 items-center",b[N],h[D],u[D]].join(" "),children:y}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null,s(W)?e("div",{className:`mp-header__middle ${v[N]} ${h[D]}`,children:W}):null,s(w)?e("div",{className:["mp-header__actions flex min-w-0 items-center justify-end",b[N],h[D]].join(" "),children:w}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null]}),...q}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useBoxSize as n}from"../../internal/box-size.js";import{useMPLocale as a,useMPMessages as r}from"../../internal/locale.js";import{useMPSize as o}from"../../internal/config.js";import{CHART as i}from"../../internal/messages/chart.js";import{TABLE as m}from"../../internal/messages/table.js";import{ChartShell as s,ChartTable as c,ChartTooltipPanel as u}from"../../internal/ChartChrome.js";import{CHART_FONT_SIZE as h,MARK_GAP as d,PLOT_HEIGHT as f,RAMP_STEPS as p,bounds as x,formatCategory as v,formatStatistic as g,rampFill as y,rampInk as w,rampStep as b,textWidth as M,tickTurn as k,toValues as j,truncate as A,turnedBand as $,turnedRoom as N}from"../../internal/chart.js";export function MPHeatmapChart({series:B,categories:_,xAxis:z,yAxis:S,min:C,max:P,valueLabels:D=!1,height:L,format:R,locale:I,label:F,legend:W,tooltip:E,empty:H,size:K,className:U,style:X,...Y}){const q=o(K),G=a(I),J=r(i,G),O=r(m,G),Q=l.useRef(null),T=n(Q),V=l.useId(),[Z,ee]=l.useState(null),te=l.useMemo(()=>j(B),[B]),le=te.reduce((e,t)=>Math.max(e,t.length),0),ne=l.useCallback(e=>g(e,G,R,!0),[R,G]),ae=B.map((e,t)=>e.name??String(t+1)),re=Array.from({length:le},(e,t)=>z?.tickFormat?String(z.tickFormat(_?.[t]??t,t)):v(_?.[t]??t,G)),oe=te.flat().filter(e=>null!==e.value),ie=x(oe.map(e=>e.value)),me=C??ie?.min??0,se=P??ie?.max??0,ce=se-me||1,ue=h[q],he=T.width,de="number"==typeof L?L:void 0===L?f[q]:T.height,fe=ae.reduce((e,t)=>Math.max(e,M(t,ue)),0),pe=S?.hidden?0:S?.thickness??Math.min(140,fe+10),xe=Math.max(0,he-pe),ve=le>0?xe/le:0,ge=z?.hidden?0:k(z?.tickLabels??"auto",re,ue,ve),ye=Math.min(120,.5*de),we=re.map((e,t)=>A(e,ge>0?Math.min(N(ge,ye,ue),ge>=90?1/0:(pe+ve*(t+.5))/Math.cos(ge*Math.PI/180)):ve-2,ue)),be=we.reduce((e,t)=>Math.max(e,M(t,ue)),0),Me=z?.hidden?0:z?.thickness??(ge>0?8+$(ge,be,ue)+4:ue+12),ke=pe,je=0,Ae=Math.max(0,de-Me),$e=te.length>0?Ae/te.length:0,Ne=(e,t)=>{ee(l=>{const n=l??{row:0,column:0};return{row:Math.min(te.length-1,Math.max(0,n.row+(l?e:0))),column:Math.min(le-1,Math.max(0,n.column+(l?t:0)))}})},Be=Z?te[Z.row]?.[Z.column]??null:null,_e=Z&&Be&&null!==Be.value?[{seriesIndex:Z.row,name:ae[Z.row],color:y(b((Be.value-me)/ce)),value:Be.value,formatted:ne(Be.value),label:Be.label}]:[],ze=!1===E?{mode:"none"}:!0===E||void 0===E?{}:E,Se=!1!==W&&oe.length>0,Ce=0===le||0===te.length||0===oe.length,Pe=Array.from({length:le},(e,t)=>te.map(e=>e[t]??{value:null}));return e(s,{...Y,size:q,className:["mp-heatmap-chart",U??""].filter(Boolean).join(" "),style:X,plotRef:Q,name:F??J.label,describedBy:Ce?void 0:V,interactive:!Ce,height:L,legendSide:"bottom",plotProps:{onPointerMove:Ce||"none"===ze.mode?void 0:e=>{const t=((e,t)=>{const l=Q.current;if(!l||ve<=0||$e<=0)return null;const n=l.getBoundingClientRect(),a=Math.floor((e-n.left-ke)/ve),r=Math.floor((t-n.top-je)/$e);return a<0||a>=le||r<0||r>=te.length?null:{row:r,column:a}})(e.clientX,e.clientY);ee(e=>e&&t&&e.row===t.row&&e.column===t.column?e:t)},onPointerLeave:()=>ee(null),onKeyDown:Ce||"none"===ze.mode?void 0:e=>{if("ArrowRight"===e.key)Ne(0,1);else if("ArrowLeft"===e.key)Ne(0,-1);else if("ArrowDown"===e.key)Ne(1,0);else if("ArrowUp"===e.key)Ne(-1,0);else{if("Escape"!==e.key)return;ee(null)}e.preventDefault()},onBlur:()=>ee(null)},tooltip:Z&&_e.length>0&&"none"!==ze.mode?e(u,{heading:`${ae[Z.row]} · ${re[Z.column]}`,items:_e,x:ke+(Z.column+.5)*ve,y:je+(Z.row+.5)*$e,flip:Z.column>le/2,size:q}):null,legend:Se?t("div",{className:"mp-chart__legend flex items-center justify-center gap-2",children:[e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:ne(me)}),e("span",{className:"flex","aria-hidden":"true",children:Array.from({length:p},(t,l)=>e("span",{className:"block h-3 w-6 first:rounded-s-mp-xs last:rounded-e-mp-xs",style:{background:y(l)}},l))}),e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:ne(se)})]}):null,status:{heading:Z?`${ae[Z.row]} · ${re[Z.column]}`:void 0,items:_e},table:Ce?null:e(c,{id:V,caption:F??J.table,corner:S?.label??J.category,categories:ae,names:re,values:Pe,format:ne,locale:G,empty:O.empty}),children:Ce?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:H??O.empty}):he>0&&de>0?t("svg",{width:he,height:de,viewBox:`0 0 ${he} ${de}`,"aria-hidden":"true",className:"block overflow-visible",children:[e("g",{className:"mp-heatmap-chart__cells",children:te.map((l,n)=>Array.from({length:le},(a,r)=>{const o=l[r],i=Z?.row===n&&Z?.column===r,m=ke+r*ve,s=je+n*$e,c=Math.max(0,ve-d),u=Math.max(0,$e-d);if(!o||null===o.value)return e("rect",{x:m+d/2,y:s+d/2,width:c,height:u,fill:"none",stroke:"var(--_mp-color-outline-variant)",strokeWidth:1,strokeDasharray:"2 2",rx:2},r);const h=b((o.value-me)/ce);return t("g",{children:[e("rect",{x:m+d/2,y:s+d/2,width:c,height:u,fill:o.color??y(h),rx:2,stroke:i?"var(--_mp-color-on-surface)":"none",strokeWidth:i?2:0}),D&&c>M(ne(o.value),ue)+8&&u>ue+4?e("text",{x:m+ve/2,y:s+$e/2,textAnchor:"middle",dominantBaseline:"central",fill:w(h),fontSize:ue,children:ne(o.value)}):null]},r)}))}),S?.hidden?null:ae.map((t,l)=>e("text",{x:ke-8,y:je+(l+.5)*$e,textAnchor:"end",dominantBaseline:"central",fill:"var(--_mp-color-on-surface-variant)",fontSize:ue,children:A(t,pe-10,ue)},`r${l}`)),z?.hidden?null:we.map((t,l)=>{const n=ke+(l+.5)*ve,a=je+Ae;return e("text",{x:n,y:ge>0?a+8:a+ue+4,textAnchor:ge>0?"end":"middle",dominantBaseline:ge>0?"central":void 0,transform:ge>0?`rotate(${-ge} ${n} ${a+8})`:void 0,fill:"var(--_mp-color-on-surface-variant)",fontSize:ue,children:t},`c${l}`)})]}):null})}
|
|
@@ -180,6 +180,11 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
|
|
|
180
180
|
* Sets `loading="eager"` and a high fetch priority. A `loading` or
|
|
181
181
|
* `fetchPriority` of your own still wins. Give it to one picture per page: a
|
|
182
182
|
* high priority on every picture raises none of them above the others.
|
|
183
|
+
*
|
|
184
|
+
* The picture is also drawn as soon as it arrives rather than faded in once
|
|
185
|
+
* the page's JavaScript has heard it load, with the placeholder under it
|
|
186
|
+
* instead of over it — on a server-rendered page, a faded picture cannot
|
|
187
|
+
* appear before hydration.
|
|
183
188
|
* @default false
|
|
184
189
|
*/
|
|
185
190
|
priority?: boolean;
|