material-plus-ui 1.0.0 → 1.2.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/dist/components/animate-appear/MPAnimateAppear.d.ts +56 -0
- package/dist/components/animate-appear/MPAnimateAppear.js +1 -0
- package/dist/components/animate-appear/index.d.ts +2 -0
- package/dist/components/animate-appear/index.js +1 -0
- package/dist/components/animate-blink/MPAnimateBlink.d.ts +41 -0
- package/dist/components/animate-blink/MPAnimateBlink.js +1 -0
- package/dist/components/animate-blink/index.d.ts +2 -0
- package/dist/components/animate-blink/index.js +1 -0
- package/dist/components/animate-fade/MPAnimateFade.d.ts +38 -0
- package/dist/components/animate-fade/MPAnimateFade.js +1 -0
- package/dist/components/animate-fade/index.d.ts +2 -0
- package/dist/components/animate-fade/index.js +1 -0
- package/dist/components/animate-grow/MPAnimateGrow.d.ts +52 -0
- package/dist/components/animate-grow/MPAnimateGrow.js +1 -0
- package/dist/components/animate-grow/index.d.ts +2 -0
- package/dist/components/animate-grow/index.js +1 -0
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +63 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -0
- package/dist/components/animate-headline/index.d.ts +2 -0
- package/dist/components/animate-headline/index.js +1 -0
- package/dist/components/animate-lighting/MPAnimateLighting.d.ts +68 -0
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -0
- package/dist/components/animate-lighting/index.d.ts +2 -0
- package/dist/components/animate-lighting/index.js +1 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.d.ts +66 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -0
- package/dist/components/animate-marquee/index.d.ts +2 -0
- package/dist/components/animate-marquee/index.js +1 -0
- package/dist/components/animate-rotate/MPAnimateRotate.d.ts +56 -0
- package/dist/components/animate-rotate/MPAnimateRotate.js +1 -0
- package/dist/components/animate-rotate/index.d.ts +2 -0
- package/dist/components/animate-rotate/index.js +1 -0
- package/dist/components/animate-slide/MPAnimateSlide.d.ts +53 -0
- package/dist/components/animate-slide/MPAnimateSlide.js +1 -0
- package/dist/components/animate-slide/index.d.ts +2 -0
- package/dist/components/animate-slide/index.js +1 -0
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +59 -0
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -0
- package/dist/components/animate-typing/index.d.ts +2 -0
- package/dist/components/animate-typing/index.js +1 -0
- package/dist/components/animate-zoom/MPAnimateZoom.d.ts +44 -0
- package/dist/components/animate-zoom/MPAnimateZoom.js +1 -0
- package/dist/components/animate-zoom/index.d.ts +2 -0
- package/dist/components/animate-zoom/index.js +1 -0
- package/dist/components/avatar/MPAvatar.d.ts +9 -2
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/badge/MPBadge.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +144 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -0
- package/dist/components/bottom-navigation/index.d.ts +2 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +22 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.d.ts +7 -2
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.d.ts +2 -2
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +13 -3
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/color-picker/MPColorPicker.d.ts +21 -3
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +38 -10
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/container/MPContainer.d.ts +75 -0
- package/dist/components/container/MPContainer.js +1 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/container/index.js +1 -0
- package/dist/components/date-picker/MPDatePicker.d.ts +3 -0
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +8 -3
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +33 -9
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/empty/MPEmpty.d.ts +12 -2
- package/dist/components/empty/MPEmpty.js +1 -1
- package/dist/components/file-picker/MPFilePicker.d.ts +11 -1
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.d.ts +126 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -0
- package/dist/components/floating-action-button/index.d.ts +2 -0
- package/dist/components/floating-action-button/index.js +1 -0
- package/dist/components/grid/MPGrid.d.ts +155 -0
- package/dist/components/grid/MPGrid.js +1 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/highlight/MPHighlight.js +1 -1
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +10 -1
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +21 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/pagination/MPPagination.d.ts +106 -0
- package/dist/components/pagination/MPPagination.js +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popover/MPPopover.d.ts +8 -3
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.d.ts +135 -0
- package/dist/components/rating/MPRating.js +1 -0
- package/dist/components/rating/index.d.ts +2 -0
- package/dist/components/rating/index.js +1 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +23 -6
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +8 -3
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/spoiler/MPSpoiler.js +1 -1
- package/dist/components/switch/MPSwitch.d.ts +2 -2
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +14 -1
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/tabs/MPTabs.d.ts +145 -0
- package/dist/components/tabs/MPTabs.js +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/text-field/MPTextField.d.ts +37 -7
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/constants/icons.d.ts +13 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/FieldOutline.d.ts +75 -4
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/Picker.d.ts +52 -9
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/animate.d.ts +179 -0
- package/dist/internal/animate.js +1 -0
- package/dist/internal/date.d.ts +2 -2
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +110 -0
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/inert.d.ts +11 -0
- package/dist/internal/inert.js +1 -0
- package/dist/internal/surface.d.ts +42 -12
- package/dist/internal/surface.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +640 -4
- package/dist/types.d.ts +155 -0
- package/package.json +10 -10
|
@@ -50,8 +50,26 @@ export interface MPColorPickerProps extends MPStyleProps {
|
|
|
50
50
|
* @default true
|
|
51
51
|
*/
|
|
52
52
|
editable?: boolean;
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Label for the picker, drawn in the outline's notch — or above the panel when
|
|
55
|
+
* `inline`, which has no notch to draw it in. While nothing is chosen and the
|
|
56
|
+
* trigger is unfocused it rests on the trigger's own line instead. See
|
|
57
|
+
* `floatingLabel`.
|
|
58
|
+
*/
|
|
54
59
|
label?: React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the label rests on the trigger's line while there is nothing to make
|
|
62
|
+
* room for, and rises into the notch on focus or on the first colour.
|
|
63
|
+
*
|
|
64
|
+
* The swatch comes down with it. The swatch is the value drawn rather than an
|
|
65
|
+
* affordance — with no colour in the picker it is an empty ring — so it is the
|
|
66
|
+
* one leading mark in the library that gives its place up to a resting label
|
|
67
|
+
* rather than holding the label out of it.
|
|
68
|
+
*
|
|
69
|
+
* Ignored when `inline`, which has no trigger for a label to rest on.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
floatingLabel?: boolean;
|
|
55
73
|
/** The line under the control. Replaced by `errorMessage` when there is one. */
|
|
56
74
|
description?: React.ReactNode;
|
|
57
75
|
/**
|
|
@@ -77,8 +95,8 @@ export interface MPColorPickerProps extends MPStyleProps {
|
|
|
77
95
|
/** Overrides for the accessible names, one at a time. */
|
|
78
96
|
labels?: Partial<MPColorPickerLabels>;
|
|
79
97
|
/**
|
|
80
|
-
* The id put on the trigger and pointed at by the label.
|
|
81
|
-
*
|
|
98
|
+
* The id put on the trigger and pointed at by the label. Generated when it is
|
|
99
|
+
* left out.
|
|
82
100
|
*/
|
|
83
101
|
id?: string;
|
|
84
102
|
className?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Field as n}from"@base-ui/react/field";import{Popover as
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Field as n}from"@base-ui/react/field";import{Popover as t}from"@base-ui/react/popover";import{MPIcon as l}from"../icon/MPIcon";import{CheckIcon as o,CloseIcon as i}from"../../constants/icons";import{MPFieldLabel as s,MPFieldOutline as u,useFloatingLabel as c}from"../../internal/FieldOutline";import{MPStateLayer as d}from"../../internal/StateLayer";import{MPSupportingText as p}from"../../internal/SupportingText";import{CONTROL_ICON as h,META_TEXT as m,PROSE_TEXT as f,STACK_GAP as g,hasContent as v}from"../../internal/scale";import{FADE as b,PORTAL_LAYER as x}from"../../internal/surface";import{CHECKER_BACKGROUND as y,DEFAULT_SWATCHES as w,clamp as N,cssColor as k,formatColor as C,parseColor as j,readableInk as _}from"../../internal/color";const z={area:"Saturation and brightness",hue:"Hue",alpha:"Opacity",value:"Colour value",swatches:"Swatches",clear:"Clear",empty:"No colour"},P={xs:"w-40",sm:"w-44",md:"w-52",lg:"w-60",xl:"w-72"},$={xs:"h-24",sm:"h-28",md:"h-32",lg:"h-40",xl:"h-48"},M={xs:"h-2.5",sm:"h-3",md:"h-3.5",lg:"h-4",xl:"h-5"},T={xs:"gap-2",sm:"gap-2.5",md:"gap-3",lg:"gap-3.5",xl:"gap-4"},I={xs:12,sm:14,md:16,lg:18,xl:20},O={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}},S="border-mp-outline-variant relative overflow-hidden border",A=["pointer-events-none absolute rounded-full border-2 border-white","[box-shadow:0_0_0_1px_rgb(0_0_0/0.35),0_1px_3px_rgb(0_0_0/0.4)]"].join(" ");function B(e,a,r){return{x:0===e.width?0:N((a-e.left)/e.width,0,1),y:0===e.height?0:N((r-e.top)/e.height,0,1)}}function D(e){const a=e.shiftKey?10:1;switch(e.key){case"ArrowLeft":return{x:-a,y:0};case"ArrowRight":return{x:a,y:0};case"ArrowUp":return{x:0,y:a};case"ArrowDown":return{x:0,y:-a};default:return null}}function L({hsv:n,alphaValue:t,onChange:i,text:s,onTextChange:u,withAlpha:c,swatches:d,editable:p,size:h,inert:f,labels:g}){const v=I[h],b=-v/2,x=k({h:n.h,s:100,v:100}),w=k(n),z=r.useRef(null),O=e=>({onPointerDown:a=>{if(f)return;const r=a.currentTarget.getBoundingClientRect();z.current=r,a.currentTarget.setPointerCapture(a.pointerId),e(B(r,a.clientX,a.clientY))},onPointerMove:a=>{const r=z.current;!f&&r&&a.currentTarget.hasPointerCapture(a.pointerId)&&e(B(r,a.clientX,a.clientY))},onPointerUp:()=>{z.current=null},onPointerCancel:()=>{z.current=null}}),L=(e,a,r,n)=>({role:"slider",tabIndex:f?-1:0,"aria-label":e,"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.round(a),"aria-orientation":"horizontal","aria-disabled":f||void 0,onKeyDown:e=>{const a=D(e);!f&&a&&0!==a.x&&(e.preventDefault(),n(a.x))}}),R=["outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),q=r.useMemo(()=>d?d.map(e=>{const a=j(e);return{swatch:e,parsed:a,hex:null===a?null:C(a.hsv,a.alpha,"hex")}}):[],[d]),V=C(n,t,"hex");return a("div",{className:`mp-color-picker__panel flex flex-col ${P[h]} ${T[h]}`,children:[e("div",{...O(({x:e,y:a})=>i({hsv:{h:n.h,s:100*e,v:100*(1-a)},alpha:t})),role:"slider",tabIndex:f?-1:0,"aria-label":g.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(n.s),"aria-valuetext":`${Math.round(n.s)}%, ${Math.round(n.v)}%`,"aria-disabled":f||void 0,onKeyDown:e=>{const a=D(e);!f&&a&&(e.preventDefault(),i({hsv:{h:n.h,s:N(n.s+a.x,0,100),v:N(n.v+a.y,0,100)},alpha:t}))},className:[S,"rounded-mp-sm",$[h],R,f?"cursor-default":"cursor-crosshair touch-none"].join(" "),style:{backgroundColor:x,backgroundImage:"linear-gradient(to top, #000000, rgb(0 0 0 / 0)), linear-gradient(to right, #ffffff, rgb(255 255 255 / 0))"},children:e("span",{className:A,style:{width:v,height:v,left:`${n.s}%`,top:100-n.v+"%",marginLeft:b,marginTop:b,backgroundColor:w}})}),e("div",{...O(({x:e})=>i({hsv:{...n,h:360*e},alpha:t})),...L(g.hue,n.h,360,e=>i({hsv:{...n,h:(n.h+2*e+360)%360},alpha:t})),className:[S,"rounded-mp-full",M[h],R,f?"cursor-default":"cursor-pointer touch-none"].join(" "),style:{backgroundImage:"linear-gradient(to right, #ff0000 0%, #ffff00 16.66%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.66%, #ff00ff 83.33%, #ff0000 100%)"},children:e("span",{className:A,style:{width:v,height:v,left:n.h/360*100+"%",top:"50%",marginLeft:b,marginTop:b,backgroundColor:x}})}),c?a("div",{...O(({x:e})=>i({hsv:n,alpha:e})),...L(g.alpha,100*t,100,e=>i({hsv:n,alpha:N(t+e/100,0,1)})),className:[S,"rounded-mp-full",M[h],R,f?"cursor-default":"cursor-pointer touch-none"].join(" "),style:y,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${k(n,0)}, ${w})`}}),e("span",{className:A,style:{width:v,height:v,left:100*t+"%",top:"50%",marginLeft:b,marginTop:b,backgroundColor:k(n,t)}})]}):null,p?a("div",{className:`flex items-center ${T[h]}`,children:[e("span",{"aria-hidden":"true",className:"border-mp-outline-variant shrink-0 rounded-full border",style:{width:v+8,height:v+8,...y},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:k(n,t)}})}),e("input",{type:"text",value:s,readOnly:f,spellCheck:!1,autoComplete:"off","aria-label":g.value,onChange:e=>u(e.target.value),className:["rounded-mp-xs border-mp-outline text-mp-on-surface min-w-0 flex-1 border","bg-transparent px-2 py-1 font-mono lowercase",m,"focus-visible:border-mp-primary outline-none"].join(" ")})]}):null,q.length>0?e("div",{role:"group","aria-label":g.swatches,className:"grid grid-cols-8 gap-1",children:q.map(({swatch:a,parsed:r,hex:n},t)=>{const s=null!==r&&n===V;return e("button",{type:"button",disabled:f,"aria-label":a,"aria-pressed":s,onClick:()=>{r&&i({hsv:r.hsv,alpha:r.alpha})},className:["border-mp-outline-variant flex aspect-square items-center justify-center","rounded-full border","transition-[box-shadow] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",R,f?"cursor-default":"hover:shadow-mp-1 cursor-pointer"].join(" "),style:{backgroundColor:a},children:e("span",{"aria-hidden":"true",className:["transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",s?"opacity-100":"opacity-0"].join(" "),style:r?{color:_(r.hsv)}:void 0,children:e(l,{icon:o,size:12})})},`${t}:${a}`)})}):null]})}const R={h:202,s:100,v:61};export const MPColorPicker=r.forwardRef(function({value:o,defaultValue:N="#00639b",onValueChange:_,format:P="hex",alpha:$=!1,swatches:M=w,inline:T=!1,editable:I=!0,label:S,floatingLabel:A=!0,description:B,errorMessage:D,required:q=!1,disabled:V=!1,readOnly:K=!1,clearable:F=!1,name:U,open:X,defaultOpen:Y=!1,onOpenChange:E,labels:H,size:W="md",fullWidth:G=!1,id:J,className:Q,style:Z},ee){const ae=r.useMemo(()=>({...z,...H}),[H]),re=v(D),ne=O[W],te=r.useId(),le=J??te,[oe,ie]=r.useState(N),se=o??oe,[ue,ce]=r.useState(Y),de=X??ue,[pe,he]=r.useState(()=>j(se)??{hsv:R,alpha:1}),[me,fe]=r.useState(()=>se),ge=C(pe.hsv,$?pe.alpha:1,P),ve=""===se;r.useEffect(()=>{const e=j(se);e?C(e.hsv,$?e.alpha:1,P)!==ge&&(fe(se),he(e)):fe(se)},[se,ge,$,P]);const be=V||K,xe=F&&!be&&!ve,{shrunk:ye,focusProps:we}=c({floating:A&&v(S),filled:!ve,pinned:de}),Ne=(e,a)=>{he(e);const r=C(e.hsv,$?e.alpha:1,P);fe(a??r),void 0===o&&ie(r),_?.(r)},ke=e(L,{hsv:pe.hsv,alphaValue:pe.alpha,onChange:Ne,text:me,onTextChange:e=>{fe(e);const a=j(e);a&&Ne(a,e)},withAlpha:$,swatches:M,editable:I,size:W,inert:be,labels:ae}),Ce=e("span",{"aria-hidden":"true",className:"border-mp-outline-variant block size-5 shrink-0 rounded-full border",style:y,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:ve?"transparent":k(pe.hsv,$?pe.alpha:1)}})}),je=U?e("input",{type:"hidden",name:U,value:ve?"":ge}):null;return T?a("div",{ref:ee,"data-mp-size":W,className:["mp-color-picker flex flex-col",g[W],Q??""].filter(Boolean).join(" "),style:Z,children:[v(S)?a("span",{className:[m,V?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[S,q?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,ke,v(D)?e("span",{className:`${m} text-mp-error`,children:D}):v(B)?e("span",{className:`${m} text-mp-on-surface-variant`,children:B}):null,je]}):a(n.Root,{ref:ee,disabled:V,invalid:re,"data-mp-size":W,className:["mp-color-picker group flex-col align-top",G?"flex w-full":"inline-flex w-fit",Q??""].filter(Boolean).join(" "),style:Z,...we,children:[a(t.Root,{open:de,onOpenChange:e=>{void 0===X&&ce(e),E?.(e)},children:[a("div",{className:"relative w-full",children:[a(t.Trigger,{id:le,disabled:V,nativeButton:!0,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",ne.padding,xe?"pe-10":"",ne.height,f[W],V?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(K?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[ve&&!ye?null:Ce,e("span",{className:["min-w-0 flex-1 truncate text-start",ve?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:ve?ye?ae.empty:null:ge})]}),xe?a("button",{type:"button","aria-label":ae.clear,onClick:()=>{void 0===o&&ie(""),fe(""),_?.("")},className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(d,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(l,{icon:i,size:h[W]})]}):null,e(u,{label:S,required:q,notched:ye}),v(S)?e(s,{size:W,label:S,required:q,htmlFor:le,shrunk:ye}):null]}),e(t.Portal,{children:e(t.Positioner,{className:x,sideOffset:4,align:"start",children:e(t.Popup,{className:["mp-color-picker__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container","text-mp-on-surface p-3 outline-none",f[W],b].join(" "),children:ke})})})]}),e(p,{description:B,errorMessage:D,className:ne.padding}),je]})});
|
|
@@ -69,14 +69,28 @@ export interface MPComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
69
69
|
emptyMessage?: React.ReactNode;
|
|
70
70
|
/** The most rows the list will show at once. `-1` is all of them. @default -1 */
|
|
71
71
|
limit?: number;
|
|
72
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* Shown in the input while nothing is typed. With a floating label it is held
|
|
74
|
+
* back until the label has risen out of its way.
|
|
75
|
+
*/
|
|
73
76
|
placeholder?: string;
|
|
74
77
|
/**
|
|
75
|
-
* Label in the outline's notch
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
+
* Label for the combobox, drawn in the outline's notch and — while nothing is
|
|
79
|
+
* chosen or typed, the control is unfocused and there is no `startIcon` —
|
|
80
|
+
* resting on the input's own line. See `floatingLabel`.
|
|
78
81
|
*/
|
|
79
82
|
label?: React.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Whether the label rests on the input's line while there is nothing to make
|
|
85
|
+
* room for, and rises into the notch on focus, on the first character or on
|
|
86
|
+
* the first chip.
|
|
87
|
+
*
|
|
88
|
+
* `false` pins it in the notch, which is the one thing a floating label costs:
|
|
89
|
+
* a combobox with a label and one without no longer sit at the same height in
|
|
90
|
+
* a form until both are answered. A `startIcon` holds the label up regardless.
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
floatingLabel?: boolean;
|
|
80
94
|
/** The line under the control. Replaced by `errorMessage` when there is one. */
|
|
81
95
|
description?: React.ReactNode;
|
|
82
96
|
/**
|
|
@@ -99,8 +113,16 @@ export interface MPComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
99
113
|
/** Whether the popup starts open. */
|
|
100
114
|
defaultOpen?: boolean;
|
|
101
115
|
onOpenChange?: (open: boolean) => void;
|
|
102
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Accessible name of the clear button. Defaults to the word for "clear" in
|
|
118
|
+
* `locale`.
|
|
119
|
+
*/
|
|
103
120
|
clearLabel?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Which language the two adornments' default names are written in. Falls back
|
|
123
|
+
* to the nearest `MPLocaleProvider`, then to English.
|
|
124
|
+
*/
|
|
125
|
+
locale?: string;
|
|
104
126
|
/**
|
|
105
127
|
* Accessible name of the chevron that opens the list, **for a combobox with no
|
|
106
128
|
* `label`**.
|
|
@@ -110,16 +132,22 @@ export interface MPComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
110
132
|
* a button called "Fruit" beside a field called "Fruit" is the button that
|
|
111
133
|
* opens that field. This is the fallback for the unlabelled case, where the
|
|
112
134
|
* chevron would otherwise be a button with a glyph in it and no name at all.
|
|
113
|
-
*
|
|
135
|
+
*
|
|
136
|
+
* Defaults to the word for "open" in `locale`.
|
|
114
137
|
*/
|
|
115
138
|
openLabel?: string;
|
|
116
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Accessible name of a chip's remove button. Receives the chip's label.
|
|
141
|
+
*
|
|
142
|
+
* Left out, the chip is still named — "Remove Seoul" in `locale`'s own word
|
|
143
|
+
* order — rather than being one of five buttons all called "Remove".
|
|
144
|
+
*/
|
|
117
145
|
removeLabel?: (label: string) => string;
|
|
118
146
|
/** A ref to the text input the reader types into. */
|
|
119
147
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
120
148
|
/**
|
|
121
|
-
* The id put on the input and pointed at by the label.
|
|
122
|
-
*
|
|
149
|
+
* The id put on the input and pointed at by the label. Generated when it is
|
|
150
|
+
* left out.
|
|
123
151
|
*/
|
|
124
152
|
id?: string;
|
|
125
153
|
className?: string;
|
|
@@ -143,5 +171,5 @@ export interface MPComboboxProps<Multiple extends boolean | undefined = false> e
|
|
|
143
171
|
* navigation across both the list and the chips, and the hidden input that makes
|
|
144
172
|
* the whole thing submit with a form.
|
|
145
173
|
*/
|
|
146
|
-
export declare function MPCombobox<Multiple extends boolean | undefined = false>({ items, multiple, value, defaultValue, onValueChange, onInputValueChange, allowCustom, customLabel, clearable, emptyMessage, limit, placeholder, label, description, errorMessage, startIcon, size, fullWidth, required, disabled, readOnly, name, open, defaultOpen, onOpenChange, clearLabel, openLabel, removeLabel, inputRef, id, className, style }: MPComboboxProps<Multiple>): React.JSX.Element;
|
|
174
|
+
export declare function MPCombobox<Multiple extends boolean | undefined = false>({ items, multiple, value, defaultValue, onValueChange, onInputValueChange, allowCustom, customLabel, clearable, emptyMessage, limit, placeholder, label, floatingLabel, description, errorMessage, startIcon, size, fullWidth, required, disabled, readOnly, name, open, defaultOpen, onOpenChange, clearLabel, openLabel, locale: localeProp, removeLabel, inputRef, id, className, style }: MPComboboxProps<Multiple>): React.JSX.Element;
|
|
147
175
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{Combobox as i}from"@base-ui/react/combobox";import{Field as n}from"@base-ui/react/field";import{MPChip as t}from"../chip/MPChip";import{MPIcon as
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{Combobox as i}from"@base-ui/react/combobox";import{Field as n}from"@base-ui/react/field";import{MPChip as t}from"../chip/MPChip";import{MPIcon as o}from"../icon/MPIcon";import{AddIcon as r,CheckIcon as s,ChevronDownIcon as m,CloseIcon as c}from"../../constants/icons";import{MPFieldLabel as d,MPFieldOutline as u,useFloatingLabel as p}from"../../internal/FieldOutline";import{fillMessage as h}from"../../internal/i18n";import{useMPLocale as f,useMPMessages as g}from"../../internal/locale";import{MPStateLayer as b}from"../../internal/StateLayer";import{MPSupportingText as x}from"../../internal/SupportingText";import{CONTROL_ICON as v,PROSE_TEXT as y,hasContent as N}from"../../internal/scale";import{FADE as w,PORTAL_LAYER as C}from"../../internal/surface";const L={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"}},j={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"},I={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"};function S(e){return null==e?[]:Array.isArray(e)?e.slice():[e]}export function MPCombobox({items:z,multiple:M,value:O,defaultValue:V,onValueChange:k,onInputValueChange:P,allowCustom:q=!0,customLabel:A,clearable:T=!1,emptyMessage:$="No matches",limit:R,placeholder:_,label:F,floatingLabel:E=!0,description:B,errorMessage:G,startIcon:H,size:W="md",fullWidth:D=!1,required:J=!1,disabled:K=!1,readOnly:Q=!1,name:U,open:X,defaultOpen:Y,onOpenChange:Z,clearLabel:ee,openLabel:ae,locale:le,removeLabel:ie,inputRef:ne,id:te,className:oe,style:re}){const se=f(le),me=g("common",se),ce=N(G),de=!0===M,ue=L[W],pe=l.useId(),he=te??pe,fe=l.useMemo(()=>z.map(e=>({value:e.value,label:e.label??String(e.value),disabled:e.disabled})),[z]),[ge,be]=l.useState(()=>S(V)),xe=void 0===O?ge:S(O),[ve,ye]=l.useState(""),{shrunk:Ne,focusProps:we}=p({floating:E&&N(F),filled:xe.length>0||""!==ve,pinned:!!H}),Ce=l.useCallback(e=>fe.find(a=>a.value===e)??{value:e,label:String(e),custom:!0},[fe]),Le=ve.trim(),je=Le.toLocaleLowerCase(),Ie=""===Le||fe.some(e=>e.label.toLocaleLowerCase()===je||String(e.value).toLocaleLowerCase()===je)||xe.some(e=>String(e).toLocaleLowerCase()===je),Se=!q||Q||K||Ie?null:Le,ze=l.useMemo(()=>null===Se?fe:[...fe,{value:Se,label:Se,custom:!0}],[fe,Se]),Me=de?xe.map(Ce):xe.length>0?Ce(xe[0]):null;const Oe=["min-w-0 flex-1 self-stretch bg-transparent font-[inherit] text-inherit outline-none","placeholder:text-mp-on-surface-variant",K?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface caret-mp-primary"].join(" "),Ve=["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer items-center justify-center","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(" "),ke=a=>e(i.Input,{ref:ne,id:he,placeholder:Ne?_:void 0,className:de?`${Oe} min-w-16 ${a?"ms-1.5":""}`:Oe});return a(n.Root,{disabled:K,invalid:ce,"data-mp-size":W,className:["mp-combobox group flex-col align-top",D?"flex w-full":"inline-flex w-fit",oe??""].filter(Boolean).join(" "),style:re,...we,children:[a(i.Root,{name:U,items:ze,multiple:de,value:Me,onValueChange:e=>{!function(e){void 0===O&&be(e),k?.(de?e:e[0]??null)}((null===e?[]:Array.isArray(e)?e:[e]).map(e=>e.value))},onInputValueChange:e=>{ye(e),P?.(e)},open:X,defaultOpen:Y,onOpenChange:e=>Z?.(e),autoHighlight:!0,itemToStringLabel:e=>e.label,itemToStringValue:e=>String(e.value),isItemEqualToValue:(e,a)=>e.value===a.value,limit:R,disabled:K,readOnly:Q,required:J,children:[a("div",{className:"relative w-full",children:[a(i.InputGroup,{className:["relative flex w-full items-center gap-2",ue.padding,de?j[W]:ue.height,y[W],K?"cursor-default":"cursor-text"].join(" "),children:[H?e("span",{className:["flex shrink-0 items-center",K?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:H}):null,de?e(i.Chips,{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:e(i.Value,{children:n=>a(l.Fragment,{children:[n.map(a=>e(i.Chip,{render:e(t,{variant:ce?"outlined":"tonal",color:ce?"error":"primary",size:I[W],disabled:K,endIcon:Q||K?null:e(i.ChipRemove,{"aria-label":ie?ie(a.label):h(me.removeNamed,{label:a.label}),className:"flex cursor-pointer items-center opacity-70 hover:opacity-100",children:e(o,{icon:c,size:16})})}),children:a.label},String(a.value))),ke(n.length>0)]})})}):ke(!1),T&&!Q?a(i.Clear,{"aria-label":ee??me.clear,className:Ve,children:[e(b,{}),e(o,{icon:c,size:v[W]})]}):null,a(i.Trigger,{"aria-label":ae??me.open,className:Ve,children:[e(b,{}),e(i.Icon,{className:["relative flex items-center","transition-transform duration-(--mp-sys-motion-duration-short4)","data-popup-open:rotate-180"].join(" "),children:e(o,{icon:m,size:v[W]})})]})]}),e(u,{label:F,required:J,notched:Ne}),N(F)?e(d,{size:W,label:F,required:J,htmlFor:he,shrunk:Ne}):null]}),e(i.Portal,{children:e(i.Positioner,{className:C,sideOffset:4,children:a(i.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",y[W],w].join(" "),children:[e(i.Empty,{className:"text-mp-on-surface-variant px-3 py-2 empty:hidden",children:$}),e(i.List,{children:l=>a(i.Item,{value:l,disabled:l.disabled,className:["mp-combobox__item group rounded-mp-xs relative flex cursor-pointer","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(b,{className:"group-data-highlighted:opacity-8 group-data-disabled:opacity-0"}),e("span",{className:"flex size-5 shrink-0 items-center justify-center",children:l.custom?e(o,{icon:r,size:18}):e(i.ItemIndicator,{children:e(o,{icon:s,size:18})})}),e("span",{className:"min-w-0 flex-1 truncate",children:l.custom?A?A(l.label):`Add “${l.label}”`:l.label})]},`${l.custom?"custom:":""}${String(l.value)}`)})]})})})]}),e(x,{description:B,errorMessage:G,className:ue.padding})]})}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { MPSize } from '../../types';
|
|
4
|
+
export interface MPContainerProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* How wide the content is allowed to get, on a ladder pinned to MD3's window
|
|
7
|
+
* size classes — `sm` 600dp, `md` 840dp, `lg` 1200dp, `xl` 1600dp, `xs` 480dp.
|
|
8
|
+
*
|
|
9
|
+
* `none`, the default, is no limit: a container's job is the margin, and a
|
|
10
|
+
* measure is a second decision that a page should have to ask for.
|
|
11
|
+
* @default 'none'
|
|
12
|
+
*/
|
|
13
|
+
maxWidth?: MPSize | 'none';
|
|
14
|
+
/**
|
|
15
|
+
* The page margin. Turn it off to keep the centring and the measure without
|
|
16
|
+
* the gutter — a full-bleed hero, a section that pads itself.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
padded?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The margin's rung. `md` is 16dp, which is MD3's own compact margin; the
|
|
22
|
+
* specification widens it to 24dp from a medium window up, which here is
|
|
23
|
+
* `size="lg"`.
|
|
24
|
+
*
|
|
25
|
+
* As on [MPBox](./box) this is the size of the *sheet* — it never touches a
|
|
26
|
+
* height or the type scale — and it is independent of `maxWidth`, which is how
|
|
27
|
+
* wide the content gets rather than how far it sits from the edge.
|
|
28
|
+
* @default 'md'
|
|
29
|
+
*/
|
|
30
|
+
size?: MPSize;
|
|
31
|
+
/**
|
|
32
|
+
* Centres the content once `maxWidth` is narrower than the page. No effect
|
|
33
|
+
* while `maxWidth` is `none`, because there is nothing left over to centre in.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
centered?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Renders something other than a `<div>`: `render={<main />}`,
|
|
39
|
+
* `render={<section />}`. Base UI's own escape hatch.
|
|
40
|
+
*/
|
|
41
|
+
render?: useRender.RenderProp;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The page margin, and optionally a measure.
|
|
46
|
+
*
|
|
47
|
+
* Material describes a layout as content held off the edge of the window by a
|
|
48
|
+
* margin — 16dp in a compact window, 24dp from medium up — and this is that
|
|
49
|
+
* margin, said once, at the top of a page rather than on each of the things
|
|
50
|
+
* inside it.
|
|
51
|
+
*
|
|
52
|
+
* Nothing to do with the grid. A container holds an [MPGrid](./grid) as happily
|
|
53
|
+
* as it holds a single paragraph, and a grid needs no container around it: the
|
|
54
|
+
* two are separate because the questions are separate — how far the content sits
|
|
55
|
+
* from the edge of the window, and how the content divides itself up.
|
|
56
|
+
*
|
|
57
|
+
* ## Why it draws no surface
|
|
58
|
+
*
|
|
59
|
+
* No `variant`, no `color`, no shadow, for the same reason a grid draws none:
|
|
60
|
+
* the outermost element on a page is the one thing that must not decide what the
|
|
61
|
+
* page looks like. A container that painted `surface-container` would put a
|
|
62
|
+
* second background behind an application that already has one, and every sheet
|
|
63
|
+
* inside it would then be a sheet on a sheet.
|
|
64
|
+
*
|
|
65
|
+
* When the page genuinely is a card on a background, that is an
|
|
66
|
+
* [MPBox](./box) or an [MPCard](./card) *inside* the container.
|
|
67
|
+
*
|
|
68
|
+
* ## Why the measure is off by default
|
|
69
|
+
*
|
|
70
|
+
* Because the two decisions arrive at different times. Nearly every page wants
|
|
71
|
+
* the margin, and a good number of them — a dashboard, a table, an editor —
|
|
72
|
+
* deliberately want the full width. A container that capped the width on its own
|
|
73
|
+
* would be a component whose most common use is undoing something it did.
|
|
74
|
+
*/
|
|
75
|
+
export declare const MPContainer: React.ForwardRefExoticComponent<MPContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";import{useRender as r}from"@base-ui/react/use-render";import{SHEET_PAD_X as m}from"../../internal/scale";const a={xs:"max-w-[30rem]",sm:"max-w-[37.5rem]",md:"max-w-[52.5rem]",lg:"max-w-[75rem]",xl:"max-w-[100rem]"};export const MPContainer=e.forwardRef(function({maxWidth:e="none",padded:n=!0,size:o="md",centered:t=!0,render:d,className:i,children:s,...c},l){return r({render:d,ref:l,props:{"data-mp-size":o,className:["mp-container block w-full","box-border","none"===e?"":a[e],t?"mx-auto":"",n?m[o]:"",i??""].filter(Boolean).join(" "),children:s,...c}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPContainer}from"./MPContainer";
|
|
@@ -39,6 +39,9 @@ export interface MPDatePickerProps extends MPPickerShellProps {
|
|
|
39
39
|
/**
|
|
40
40
|
* How the trigger writes the chosen date. Passed straight to `Intl`, so
|
|
41
41
|
* `{ dateStyle: 'full' }` and `{ year: '2-digit', month: 'narrow' }` both work.
|
|
42
|
+
*
|
|
43
|
+
* An object written inline is fine: what the picker keeps between renders is
|
|
44
|
+
* keyed on what the format *says*, not on the object that says it.
|
|
42
45
|
* @default { dateStyle: 'medium' }
|
|
43
46
|
*/
|
|
44
47
|
format?: Intl.DateTimeFormatOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{MPButton as o}from"../button/MPButton";import{MPIcon as t}from"../icon/MPIcon";import{CalendarIcon as n}from"../../constants/icons";import{MPCalendar as r}from"../../internal/Calendar";import{FOOTER_SIZE as i,MPPickerFooter as s,MPPickerShell as c}from"../../internal/Picker";import{useMPLocale as m,useMPMessages as
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as l from"react";import{MPButton as o}from"../button/MPButton";import{MPIcon as t}from"../icon/MPIcon";import{CalendarIcon as n}from"../../constants/icons";import{MPCalendar as r}from"../../internal/Calendar";import{FOOTER_SIZE as i,MPPickerFooter as s,MPPickerShell as c,useDisplaySamples as d}from"../../internal/Picker";import{useMPLocale as m,useMPMessages as u}from"../../internal/locale";import{CONTROL_ICON as p}from"../../internal/scale";import{formatDate as f,isDayOutside as h,isValidDate as b,localeWeekStart as v,mergeDateAndTime as x,startOfDay as D,startOfMonth as g,toISODate as k,today as y,withPlaceholder as C}from"../../internal/date";export const MPDatePicker=l.forwardRef(function({value:O,defaultValue:S,onValueChange:z,open:M,defaultOpen:P,onOpenChange:w,defaultMonth:j,minDate:I,maxDate:V,shouldDisableDate:B,locale:R,weekStartsOn:E,format:F={dateStyle:"medium"},placeholder:N,clearable:T=!1,showTodayButton:q=!0,closeOnSelect:A=!0,labels:G,name:H,size:J="md",color:K="primary",readOnly:L=!1,disabled:Q=!1,startIcon:U,...W},X){const Y=m(R),Z=u("picker",Y,G),$=E??v(Y),[_,ee]=l.useState(S??null),ae=void 0!==O?O:_,[le,oe]=l.useState(P??!1),te=M??le,[ne,re]=l.useState(()=>g(b(ae)?ae:j??y()));l.useEffect(()=>{te&&re(g(b(ae)?ae:j??y()))},[te]);const ie=e=>{e&&(L||Q)||(void 0===M&&oe(e),w?.(e))},se=e=>{void 0===O&&ee(e),z?.(e)},ce=e=>{const a=b(ae)?x(e,ae):D(e);se(a),re(g(a)),A&&ie(!1)},de=y(),me=h(de,I,V)||(B?.(de)??!1),ue=q||T,pe=C(d(Y,F),N);return e(c,{...W,slug:"date-picker",size:J,color:K,readOnly:L,disabled:Q,triggerRef:X,startIcon:void 0===U?e(t,{icon:n,size:p[J]}):U,display:b(ae)?f(ae,Y,F):N??"",samples:pe,empty:!b(ae),clearable:T,onClear:()=>se(null),open:te,onOpenChange:ie,labels:Z,hiddenValues:H?[{name:H,value:b(ae)?k(ae):""}]:void 0,children:a("div",{className:"flex flex-col "+(ue?"gap-1.5":""),children:[e(r,{size:J,color:K,locale:Y,weekStartsOn:$,month:ne,onMonthChange:re,selected:[ae],onSelect:ce,minDate:I,maxDate:V,shouldDisableDate:B,labels:Z,autoFocus:!0}),ue?a(s,{children:[T?e(o,{variant:"text",size:i[J],color:K,onClick:()=>{se(null),ie(!1)},children:Z.clear}):null,q?e(o,{variant:"text",size:i[J],color:K,disabled:me,onClick:()=>ce(de),children:Z.today}):null]}):null]})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton";import{MPIcon as t}from"../icon/MPIcon";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons";import{MPCalendar as o}from"../../internal/Calendar";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u}from"../../internal/Picker";import{useMPLocale as
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton";import{MPIcon as t}from"../icon/MPIcon";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons";import{MPCalendar as o}from"../../internal/Calendar";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale";import{MPWidthSizer as h}from"../../internal/WidthSizer";import{CONTROL_ICON as f,META_TEXT as v}from"../../internal/scale";import{addMonths as x,compareDay as g,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as y,today as D,withPlaceholder as k}from"../../internal/date";const O={start:null,end:null};export const MPDateRangePicker=n.forwardRef(function({value:P,defaultValue:z,onValueChange:M,open:j,defaultOpen:B,onOpenChange:I,defaultMonth:R,minDate:V,maxDate:E,shouldDisableDate:F,locale:W,weekStartsOn:$,format:_={dateStyle:"medium"},monthCount:q=2,startPlaceholder:A,endPlaceholder:G,presets:H,clearable:J=!1,closeOnSelect:K=!0,labels:L,name:Q,size:T="md",color:U="primary",readOnly:X=!1,disabled:Y=!1,startIcon:Z,...ee},le){const ne=d(W),ae=p("picker",ne,L),te=$??N(ne),[re,se]=n.useState(z??O),oe=void 0!==P?P??O:re,ie=w(oe.start)?oe.start:null,ce=w(oe.end)?oe.end:null,[ue,me]=n.useState(B??!1),de=j??ue,[pe,he]=n.useState(null),[fe,ve]=n.useState(null),[xe,ge]=n.useState(()=>C(ie??R??D()));n.useEffect(()=>{de?ge(C(ie??R??D())):(he(null),ve(null))},[de]);const be=e=>{e&&(X||Y)||(void 0===j&&me(e),I?.(e))},we=e=>{void 0===P&&se(e),M?.(e)},Ne=pe??ie,Se=null!==pe?fe:ce,Ce=(l,n)=>w(l)?b(l,ne,_):e("span",{className:"text-mp-on-surface-variant",children:n??""}),ye=x(xe,1),De=2===q,ke=m(ne,_),Oe=null!==pe?ae.end:null===ie?ae.start:null,Pe={size:T,color:U,locale:ne,weekStartsOn:te,selected:[ie,ce,pe],rangeStart:Ne,rangeEnd:Se,onSelect:e=>{const l=S(e);if(null===pe)return he(l),ve(l),void we({start:l,end:null});const[n,a]=g(l,pe)<0?[l,pe]:[pe,l];he(null),ve(null),we({start:n,end:a}),K&&be(!1)},onPreviewChange:e=>{null!==pe&&ve(e??pe)},minDate:V,maxDate:E,shouldDisableDate:F,showOutsideDays:!1,labels:ae};return e(u,{...ee,slug:"date-range-picker",size:T,color:U,readOnly:X,disabled:Y,triggerRef:le,startIcon:void 0===Z?e(t,{icon:s,size:f[T]}):Z,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:Ce(ie,A)}),e(h,{samples:k(ke,A)})]}),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:f[T]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Ce(ce,G)}),e(h,{samples:k(ke,G)})]})]}),empty:null===ie&&null===ce,clearable:J,onClear:()=>we(O),open:de,onOpenChange:be,labels:ae,hiddenValues:Q?[{name:Q,value:ie?y(ie):""},{name:Q,value:ce?y(ce):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[H&&H.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:H.map((l,n)=>e(a,{variant:"text",size:i[T],color:U,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;he(null),ve(null),we(l),w(l.start)&&ge(C(l.start)),K&&be(!1)})(l),children:l.label},n))}):null,e(o,{...Pe,month:xe,onMonthChange:ge,showNextButton:!De,autoFocus:!0}),De?e(o,{...Pe,month:ye,onMonthChange:e=>ge(x(e,-1)),showPreviousButton:!1}):null]}),J||null!==Oe?l(c,{children:[null!==Oe?e("span",{className:`text-mp-on-surface-variant me-auto ${v}`,children:Oe}):null,J?e(a,{variant:"text",size:i[T],color:U,onClick:()=>{he(null),ve(null),we(O),be(!1)},children:ae.clear}):null]}):null]})})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{MPButton as l}from"../button/MPButton";import{MPIcon as a}from"../icon/MPIcon";import{CalendarIcon as n}from"../../constants/icons";import{MPCalendar as r,MPTimeGrid as i}from"../../internal/Calendar";import{FOOTER_SIZE as s,MPPickerDivider as c,MPPickerFooter as
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{MPButton as l}from"../button/MPButton";import{MPIcon as a}from"../icon/MPIcon";import{CalendarIcon as n}from"../../constants/icons";import{MPCalendar as r,MPTimeGrid as i}from"../../internal/Calendar";import{FOOTER_SIZE as s,MPPickerDivider as c,MPPickerFooter as d,MPPickerShell as m,useDisplaySamples as u}from"../../internal/Picker";import{useMPLocale as h,useMPMessages as p}from"../../internal/locale";import{CONTROL_ICON as f}from"../../internal/scale";import{formatDate as S,isDayOutside as b,isHour12 as g,isValidDate as v,localeWeekStart as D,mergeDateAndTime as x,startOfDay as C,startOfMonth as k,timeUnitSpan as w,toISODateTime as z,today as O,withPlaceholder as y,withTime as T}from"../../internal/date";export const MPDateTimePicker=t.forwardRef(function({value:M,defaultValue:P,onValueChange:j,open:I,defaultOpen:N,onOpenChange:V,defaultMonth:B,minDate:R,maxDate:E,shouldDisableDate:F,shouldDisableTime:q,locale:A,weekStartsOn:G,format:H,hour12:J,showSeconds:K=!1,hourStep:L=1,minuteStep:Q=1,secondStep:U=1,placeholder:W,clearable:X=!1,showNowButton:Y=!0,closeOnSelect:Z=!1,labels:$,name:_,size:ee="md",color:oe="primary",readOnly:te=!1,disabled:le=!1,startIcon:ae,...ne},re){const ie=h(A),se=p("picker",ie,$),ce=G??D(ie),de=J??g(ie),[me,ue]=t.useState(P??null),he=void 0!==M?M:me,[pe,fe]=t.useState(N??!1),Se=I??pe,[be,ge]=t.useState(()=>k(v(he)?he:B??O()));t.useEffect(()=>{Se&&ge(k(v(he)?he:B??O()))},[Se]);const ve=e=>{e&&(te||le)||(void 0===I&&fe(e),V?.(e))},De=e=>{void 0===M&&ue(e),j?.(e)},xe=t.useCallback((e,o)=>{const[t,l]=w(o,e),a=C(e).getTime();return!!(v(R)&&a+1e3*l<R.getTime())||(!!(v(E)&&a+1e3*t>E.getTime())||(q?.(e,o)??!1))},[R,E,q]),Ce=H??{dateStyle:"medium",timeStyle:"short",hour12:de},ke=new Date,we=T(ke,{seconds:K?ke.getSeconds():0}),ze=b(we,R,E)||(F?.(we)??!1)||xe(we,"second"),Oe=y(u(ie,Ce),W);return e(m,{...ne,slug:"date-time-picker",size:ee,color:oe,readOnly:te,disabled:le,triggerRef:re,startIcon:void 0===ae?e(a,{icon:n,size:f[ee]}):ae,display:v(he)?S(he,ie,Ce):W??"",samples:Oe,empty:!v(he),clearable:X,onClear:()=>De(null),open:Se,onOpenChange:ve,labels:se,hiddenValues:_?[{name:_,value:v(he)?z(he,K):""}]:void 0,children:o("div",{className:"flex flex-col gap-1.5",children:[o("div",{className:"flex items-stretch gap-2",children:[e(r,{size:ee,color:oe,locale:ie,weekStartsOn:ce,month:be,onMonthChange:ge,selected:[he],onSelect:e=>{const o=v(he)?x(e,he):C(e);De(o),ge(k(o)),Z&&ve(!1)},minDate:R,maxDate:E,shouldDisableDate:F,labels:se,autoFocus:!0}),e(c,{}),e(i,{size:ee,locale:ie,value:v(he)?he:null,referenceDate:v(he)?he:O(),onChange:De,hour12:de,showSeconds:K,hourStep:L,minuteStep:Q,secondStep:U,shouldDisableTime:xe,labels:se})]}),o(d,{children:[X?e(l,{variant:"text",size:s[ee],color:oe,onClick:()=>{De(null),ve(!1)},children:se.clear}):null,Y?e(l,{variant:"text",size:s[ee],color:oe,disabled:ze,onClick:()=>{De(we),ge(k(we))},children:se.now}):null,e(l,{variant:"filled",size:s[ee],color:oe,onClick:()=>ve(!1),children:se.done})]})]})})});
|
|
@@ -54,10 +54,15 @@ export interface MPDialogProps {
|
|
|
54
54
|
*/
|
|
55
55
|
showClose?: boolean;
|
|
56
56
|
/**
|
|
57
|
-
* Accessible name of the × button.
|
|
58
|
-
*
|
|
57
|
+
* Accessible name of the × button. Defaults to the word for "close" in
|
|
58
|
+
* `locale`.
|
|
59
59
|
*/
|
|
60
60
|
closeLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Which language the × button's default name is written in. Falls back to the
|
|
63
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
64
|
+
*/
|
|
65
|
+
locale?: string;
|
|
61
66
|
/**
|
|
62
67
|
* A hard cap on the sheet's width, overriding the one `size` implies. Numbers
|
|
63
68
|
* are pixels. For the dialog whose *content* decides its width — a wide table,
|
|
@@ -142,4 +147,4 @@ export declare const MPDialogClose: React.ForwardRefExoticComponent<Omit<import(
|
|
|
142
147
|
* is no `variant`: a dialog that could be told to sit flat on the page would be a
|
|
143
148
|
* dialog that could be told to stop being a dialog.
|
|
144
149
|
*/
|
|
145
|
-
export declare function MPDialog({ open, defaultOpen, onOpenChange, trigger, icon, title, description, actions, dividers, showClose, closeLabel, width, fullWidth, fullScreen, modal, dismissible, size, color, className, style, children }: MPDialogProps): React.JSX.Element;
|
|
150
|
+
export declare function MPDialog({ open, defaultOpen, onOpenChange, trigger, icon, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, width, fullWidth, fullScreen, modal, dismissible, size, color, className, style, children }: MPDialogProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as t}from"@base-ui/react/dialog";import{MPIcon as i}from"../icon/MPIcon";import{CloseIcon as n}from"../../constants/icons";import{accentSlots as o}from"../../internal/accent";import{useMPLocale as s,useMPMessages as a}from"../../internal/locale";import{MPStateLayer as r}from"../../internal/StateLayer";import{SHEET_GAP as m,hasContent as c}from"../../internal/scale";import{FADE as p,PORTAL_LAYER as d,SCRIM as x,SHEET_MOTION as f}from"../../internal/surface";const u={xs:"max-w-[320px]",sm:"max-w-[400px]",md:"max-w-[560px]",lg:"max-w-[720px]",xl:"max-w-[960px]"},h=`transition-[opacity,scale] ${f}`,g=["motion-safe:data-starting-style:scale-95","motion-safe:data-ending-style:scale-95"].join(" "),y={xs:"p-3",sm:"p-4",md:"p-6",lg:"p-7",xl:"p-8"},v={xs:"px-3",sm:"px-4",md:"px-6",lg:"px-7",xl:"px-8"},b={xs:"py-3",sm:"py-4",md:"py-6",lg:"py-7",xl:"py-8"},w={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-headline-large"},j={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-large",xl:"text-mp-body-large"},N={xs:20,sm:22,md:24,lg:28,xl:32};export const MPDialogClose=t.Close;export function MPDialog({open:f,defaultOpen:$,onOpenChange:k,trigger:C,icon:P,title:B,description:z,actions:D,dividers:O=!1,showClose:M,closeLabel:L,locale:S,width:T,fullWidth:W=!0,fullScreen:I=!1,modal:R=!0,dismissible:V=!0,size:_="md",color:q="secondary",className:A,style:E,children:F}){const G=s(S),H=a("common",G),J=M??I,K=c(P),Q=c(B)||c(z)||K,U=c(D),X=O?y[_]:v[_],Y="border-mp-outline-variant border-t";return l(t.Root,{open:f,defaultOpen:$,modal:R,disablePointerDismissal:!V,onOpenChange:(e,l)=>{V||e||"escape-key"!==l.reason?k?.(e):l.cancel()},children:[C?e(t.Trigger,{render:C}):null,l(t.Portal,{children:[e(t.Backdrop,{className:`${d} fixed inset-0 ${p} ${x}`}),e(t.Viewport,{className:[d,"fixed inset-0 flex justify-center",I?"items-stretch":"items-center p-4"].join(" "),children:l(t.Popup,{"data-mp-size":_,className:["mp-dialog relative flex w-full flex-col overflow-hidden","bg-mp-surface-container-high text-mp-on-surface shadow-mp-3 outline-none",I?"h-full max-w-none rounded-none":`rounded-mp-xl max-h-full ${void 0===T?u[_]:""}`,I||W?"":"w-auto",O?"":`${b[_]} ${m[_]}`,h,I?"":g,A??""].filter(Boolean).join(" "),style:{...o(q),...void 0===T||I?null:{maxWidth:"number"==typeof T?`${T}px`:T},...E},children:[Q||J?l("div",{className:["flex shrink-0 items-start gap-3",X,K&&!J?"flex-col items-center text-center":""].filter(Boolean).join(" "),children:[K?e("span",{className:"flex shrink-0 items-center justify-center text-(--_mp-accent)",children:P}):null,l("div",{className:`flex min-w-0 flex-1 flex-col ${m[_]}`,children:[c(B)?e(t.Title,{className:`m-0 ${w[_]}`,children:B}):null,c(z)?e(t.Description,{className:`text-mp-on-surface-variant m-0 ${j[_]}`,children:z}):null]}),J?l(t.Close,{"aria-label":L??H.close,className:["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(r,{}),e(i,{icon:n,size:N[_]})]}):null]}):null,c(F)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",j[_],X,O&&(Q||J)?Y:""].filter(Boolean).join(" "),children:F}):null,U?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",X,O?Y:""].filter(Boolean).join(" "),children:D}):null]})})]})]})}
|
|
@@ -80,10 +80,15 @@ export interface MPDrawerProps {
|
|
|
80
80
|
*/
|
|
81
81
|
showClose?: boolean;
|
|
82
82
|
/**
|
|
83
|
-
* Accessible name of the × button.
|
|
84
|
-
*
|
|
83
|
+
* Accessible name of the × button. Defaults to the word for "close" in
|
|
84
|
+
* `locale`.
|
|
85
85
|
*/
|
|
86
86
|
closeLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Which language the × button's default name is written in. Falls back to the
|
|
89
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
90
|
+
*/
|
|
91
|
+
locale?: string;
|
|
87
92
|
/**
|
|
88
93
|
* How far the panel reaches in from its edge: a **width** for `left` and
|
|
89
94
|
* `right`, a **height** for `top` and `bottom`. Numbers are pixels.
|
|
@@ -151,13 +156,32 @@ export declare const MPDrawerClose: React.ForwardRefExoticComponent<Omit<import(
|
|
|
151
156
|
* scroll lock, the `aria-labelledby` / `aria-describedby` wiring, restoring
|
|
152
157
|
* focus to the trigger, and the inert page behind.
|
|
153
158
|
*
|
|
154
|
-
* ## The surface, and why
|
|
159
|
+
* ## The surface, and why this one does slide
|
|
155
160
|
*
|
|
156
161
|
* `surface-container-low` at elevation 1 for the modal panel and `surface` flat
|
|
157
|
-
* for the standard one — MD3's own two answers.
|
|
158
|
-
*
|
|
159
|
-
* panel
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
+
* for the standard one — MD3's own two answers.
|
|
163
|
+
*
|
|
164
|
+
* A modal panel comes in from the edge it is attached to. That is the one place
|
|
165
|
+
* this library parts company with the rule `internal/surface.ts` states for
|
|
166
|
+
* every other floating surface — that a box full of text should not travel,
|
|
167
|
+
* because a sentence dragged across the screen is a sentence the reader is
|
|
168
|
+
* already trying to read.
|
|
169
|
+
*
|
|
170
|
+
* The rule holds where it was written. A menu opens next to the row the pointer
|
|
171
|
+
* is on; a dialog lands in the middle of the page, over the paragraph the
|
|
172
|
+
* reader was in the middle of. Both arrive *where the reader is looking*, and
|
|
173
|
+
* both are read the instant they appear.
|
|
174
|
+
*
|
|
175
|
+
* A drawer is neither. It arrives at an edge, which is the one part of the
|
|
176
|
+
* window nobody is reading, and it arrives because somebody pressed a
|
|
177
|
+
* hamburger and is waiting for it. Nothing is being dragged past anything.
|
|
178
|
+
* What a fade costs instead is the only thing the panel had left to say while
|
|
179
|
+
* it was arriving: a fade has no direction, so a left drawer and a right one
|
|
180
|
+
* are the same event until they have both finished. The shape says which edge
|
|
181
|
+
* afterwards — square against the window, cut on the free side. The travel is
|
|
182
|
+
* what says it *during*.
|
|
183
|
+
*
|
|
184
|
+
* `SLIDE` gives a reader who asked for less motion the old behaviour exactly:
|
|
185
|
+
* the fade, with nowhere to travel from.
|
|
162
186
|
*/
|
|
163
|
-
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, extent, rounded, dismissible, size, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
187
|
+
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon";import{CloseIcon as r}from"../../constants/icons";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale";import{MPStateLayer as d}from"../../internal/StateLayer";import{hasContent as m,META_TEXT as c,PROSE_TEXT as f,SHEET_GAP as u,SHEET_PAD_X as p,SHEET_PAD_Y as x,SHEET_TITLE as h}from"../../internal/scale";import{FADE as b,PORTAL_LAYER as g,SCRIM as y,SHEET_MOTION as v}from"../../internal/surface";const w={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},$={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},j={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},N={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},C={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"},k=`transition-[opacity,translate] ${v}`,z="border-mp-outline-variant border-t";export const MPDrawerClose=o.Close;export function MPDrawer({side:v="left",mode:P="modal",open:B,defaultOpen:D,onOpenChange:O,trigger:M,title:L,description:S,actions:T,dividers:F=!1,showClose:I,closeLabel:R,locale:V,extent:q,rounded:A=!0,dismissible:E=!0,size:G="md",className:H,style:J,children:K}){const Q=i(V),U=s("common",Q),W="modal"===P,X="left"===v||"right"===v,Y=I??W,Z=R??U.close,[_,ee]=a.useState(D??!0),te=B??_,le=p[G],ae=x[G],oe=F?`${le} ${ae}`:le,ne=m(L)||m(S),re=m(T),ie=void 0===q?null:{[X?"width":"height"]:"number"==typeof q?`${q}px`:q},se=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",W?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",f[G],j[v],A?$[v]:"",W?`${k} ${C[v]}`:"",X?`h-full max-w-full ${void 0===q?w[G]:""}`:"w-full "+(void 0===q?"max-h-[85%]":""),F?"":`${ae} ${u[G]}`,H??""].filter(Boolean).join(" "),de=W?o.Title:"h2",me=W?o.Description:"p",ce=["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(" "),fe=t(l,{children:[ne||Y?t("div",{className:`flex shrink-0 items-start gap-3 ${oe}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[m(L)?e(de,{className:`m-0 ${h[G]}`,children:L}):null,m(S)?e(me,{className:`text-mp-on-surface-variant m-0 ${c}`,children:S}):null]}),Y?W?t(o.Close,{"aria-label":Z,className:ce,children:[e(d,{}),e(n,{icon:r,size:20})]}):t("button",{type:"button","aria-label":Z,className:ce,onClick:()=>{void 0===B&&ee(!1),O?.(!1)},children:[e(d,{}),e(n,{icon:r,size:20})]}):null]}):null,m(K)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",oe,F&&(ne||Y)?z:"",F?"":"-my-1 py-1"].filter(Boolean).join(" "),children:K}):null,re?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",oe,F?z:""].filter(Boolean).join(" "),children:T}):null]});return W?t(o.Root,{open:B,defaultOpen:D,disablePointerDismissal:!E,onOpenChange:(e,t)=>{E||e||"escape-key"!==t.reason?O?.(e):t.cancel()},children:[M?e(o.Trigger,{render:M}):null,t(o.Portal,{children:[e(o.Backdrop,{className:`${g} fixed inset-0 ${b} ${y}`}),e(o.Viewport,{className:`${g} fixed inset-0 flex ${N[v]}`,children:e(o.Popup,{"data-mp-size":G,"data-mp-side":v,"data-mp-mode":P,className:se,style:{...ie,...J},children:fe})})]})]}):te?e("div",{"data-mp-size":G,"data-mp-side":v,"data-mp-mode":P,className:se,style:{...ie,...J},children:fe}):null}
|
|
@@ -3,10 +3,20 @@ import { useRender } from '@base-ui/react/use-render';
|
|
|
3
3
|
import type { MPSize, MPVariant } from '../../types';
|
|
4
4
|
export interface MPEmptyProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title'> {
|
|
5
5
|
/**
|
|
6
|
-
* The headline. Defaults to
|
|
7
|
-
* glyph and a sentence with no heading over
|
|
6
|
+
* The headline. Defaults to the words for "nothing here" in `locale`; pass
|
|
7
|
+
* `false` for a state that is a glyph and a sentence with no heading over
|
|
8
|
+
* them.
|
|
8
9
|
*/
|
|
9
10
|
title?: React.ReactNode | false;
|
|
11
|
+
/**
|
|
12
|
+
* Which language that default headline is written in. Falls back to the
|
|
13
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
14
|
+
*
|
|
15
|
+
* It matters more here than anywhere else in the library: this is the one
|
|
16
|
+
* invented string that is **drawn** rather than only read out, so a page in
|
|
17
|
+
* Korean with an empty list used to say "Nothing here" in the middle of it.
|
|
18
|
+
*/
|
|
19
|
+
locale?: string;
|
|
10
20
|
/**
|
|
11
21
|
* The glyph above the headline. Defaults to the empty tray; pass `false` to
|
|
12
22
|
* drop it, or a node — an illustration, a brand mark, an icon from any set —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as a}from"@base-ui/react/use-render";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale";import{hasContent as i,PROSE_TEXT as o,SHEET_GAP as m,SHEET_PAD_X as c,SHEET_TITLE as d}from"../../internal/scale";import{CONTAINER_SURFACE as p}from"../../internal/surface";const x={xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},f={xs:"text-[1.5rem]",sm:"text-[1.75rem]",md:"text-[2.25rem]",lg:"text-[2.75rem]",xl:"text-[3.25rem]"};function u(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-[1em]",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const MPEmpty=n.forwardRef(function({variant:n="text",size:h="md",title:v,icon:y,action:j,locale:N,render:k,className:g,style:w,children:z,...$},L){const B=l(N),C=s("empty",B),M=void 0===v?C.title:v,W=void 0===y?e(u,{}):y,b=i(M),E=["mp-empty flex w-full flex-col items-center justify-center text-center",c[h],x[h],"text"===n?"":"rounded-mp-md",m[h],p[n],"text-mp-on-surface",g??""].filter(Boolean).join(" ");return a({render:k,ref:L,props:{role:"status","data-mp-size":h,"data-mp-variant":n,className:E,style:w,children:t(r,{children:[i(W)?e("span",{className:`text-mp-on-surface-variant flex items-center ${f[h]} [&>svg]:size-[1em]`,children:W}):null,b||i(z)?t("div",{className:`flex max-w-prose flex-col items-center ${m[h]}`,children:[b?e("div",{className:d[h],children:M}):null,i(z)?e("div",{className:`${o[h]} ${b?"text-mp-on-surface-variant":""}`,children:z}):null]}):null,i(j)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:j}):null]}),...$}})});
|