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.
Files changed (151) hide show
  1. package/dist/components/animate-appear/MPAnimateAppear.d.ts +56 -0
  2. package/dist/components/animate-appear/MPAnimateAppear.js +1 -0
  3. package/dist/components/animate-appear/index.d.ts +2 -0
  4. package/dist/components/animate-appear/index.js +1 -0
  5. package/dist/components/animate-blink/MPAnimateBlink.d.ts +41 -0
  6. package/dist/components/animate-blink/MPAnimateBlink.js +1 -0
  7. package/dist/components/animate-blink/index.d.ts +2 -0
  8. package/dist/components/animate-blink/index.js +1 -0
  9. package/dist/components/animate-fade/MPAnimateFade.d.ts +38 -0
  10. package/dist/components/animate-fade/MPAnimateFade.js +1 -0
  11. package/dist/components/animate-fade/index.d.ts +2 -0
  12. package/dist/components/animate-fade/index.js +1 -0
  13. package/dist/components/animate-grow/MPAnimateGrow.d.ts +52 -0
  14. package/dist/components/animate-grow/MPAnimateGrow.js +1 -0
  15. package/dist/components/animate-grow/index.d.ts +2 -0
  16. package/dist/components/animate-grow/index.js +1 -0
  17. package/dist/components/animate-headline/MPAnimateHeadline.d.ts +63 -0
  18. package/dist/components/animate-headline/MPAnimateHeadline.js +1 -0
  19. package/dist/components/animate-headline/index.d.ts +2 -0
  20. package/dist/components/animate-headline/index.js +1 -0
  21. package/dist/components/animate-lighting/MPAnimateLighting.d.ts +68 -0
  22. package/dist/components/animate-lighting/MPAnimateLighting.js +1 -0
  23. package/dist/components/animate-lighting/index.d.ts +2 -0
  24. package/dist/components/animate-lighting/index.js +1 -0
  25. package/dist/components/animate-marquee/MPAnimateMarquee.d.ts +66 -0
  26. package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -0
  27. package/dist/components/animate-marquee/index.d.ts +2 -0
  28. package/dist/components/animate-marquee/index.js +1 -0
  29. package/dist/components/animate-rotate/MPAnimateRotate.d.ts +56 -0
  30. package/dist/components/animate-rotate/MPAnimateRotate.js +1 -0
  31. package/dist/components/animate-rotate/index.d.ts +2 -0
  32. package/dist/components/animate-rotate/index.js +1 -0
  33. package/dist/components/animate-slide/MPAnimateSlide.d.ts +53 -0
  34. package/dist/components/animate-slide/MPAnimateSlide.js +1 -0
  35. package/dist/components/animate-slide/index.d.ts +2 -0
  36. package/dist/components/animate-slide/index.js +1 -0
  37. package/dist/components/animate-typing/MPAnimateTyping.d.ts +59 -0
  38. package/dist/components/animate-typing/MPAnimateTyping.js +1 -0
  39. package/dist/components/animate-typing/index.d.ts +2 -0
  40. package/dist/components/animate-typing/index.js +1 -0
  41. package/dist/components/animate-zoom/MPAnimateZoom.d.ts +44 -0
  42. package/dist/components/animate-zoom/MPAnimateZoom.js +1 -0
  43. package/dist/components/animate-zoom/index.d.ts +2 -0
  44. package/dist/components/animate-zoom/index.js +1 -0
  45. package/dist/components/avatar/MPAvatar.d.ts +9 -2
  46. package/dist/components/avatar/MPAvatar.js +1 -1
  47. package/dist/components/badge/MPBadge.js +1 -1
  48. package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +144 -0
  49. package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -0
  50. package/dist/components/bottom-navigation/index.d.ts +2 -0
  51. package/dist/components/bottom-navigation/index.js +1 -0
  52. package/dist/components/breadcrumb/MPBreadcrumb.d.ts +22 -0
  53. package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
  54. package/dist/components/button/MPButton.d.ts +7 -2
  55. package/dist/components/button/MPButton.js +1 -1
  56. package/dist/components/carousel/MPCarousel.js +1 -1
  57. package/dist/components/checkbox/MPCheckbox.d.ts +2 -2
  58. package/dist/components/checkbox/MPCheckbox.js +1 -1
  59. package/dist/components/chip/MPChip.d.ts +13 -3
  60. package/dist/components/chip/MPChip.js +1 -1
  61. package/dist/components/color-picker/MPColorPicker.d.ts +21 -3
  62. package/dist/components/color-picker/MPColorPicker.js +1 -1
  63. package/dist/components/combobox/MPCombobox.d.ts +38 -10
  64. package/dist/components/combobox/MPCombobox.js +1 -1
  65. package/dist/components/container/MPContainer.d.ts +75 -0
  66. package/dist/components/container/MPContainer.js +1 -0
  67. package/dist/components/container/index.d.ts +2 -0
  68. package/dist/components/container/index.js +1 -0
  69. package/dist/components/date-picker/MPDatePicker.d.ts +3 -0
  70. package/dist/components/date-picker/MPDatePicker.js +1 -1
  71. package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
  72. package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
  73. package/dist/components/dialog/MPDialog.d.ts +8 -3
  74. package/dist/components/dialog/MPDialog.js +1 -1
  75. package/dist/components/drawer/MPDrawer.d.ts +33 -9
  76. package/dist/components/drawer/MPDrawer.js +1 -1
  77. package/dist/components/empty/MPEmpty.d.ts +12 -2
  78. package/dist/components/empty/MPEmpty.js +1 -1
  79. package/dist/components/file-picker/MPFilePicker.d.ts +11 -1
  80. package/dist/components/file-picker/MPFilePicker.js +1 -1
  81. package/dist/components/floating-action-button/MPFloatingActionButton.d.ts +126 -0
  82. package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -0
  83. package/dist/components/floating-action-button/index.d.ts +2 -0
  84. package/dist/components/floating-action-button/index.js +1 -0
  85. package/dist/components/grid/MPGrid.d.ts +155 -0
  86. package/dist/components/grid/MPGrid.js +1 -0
  87. package/dist/components/grid/index.d.ts +2 -0
  88. package/dist/components/grid/index.js +1 -0
  89. package/dist/components/highlight/MPHighlight.js +1 -1
  90. package/dist/components/list/MPList.js +1 -1
  91. package/dist/components/menu/MPMenu.d.ts +10 -1
  92. package/dist/components/menu/MPMenu.js +1 -1
  93. package/dist/components/number-field/MPNumberField.d.ts +21 -3
  94. package/dist/components/number-field/MPNumberField.js +1 -1
  95. package/dist/components/pagination/MPPagination.d.ts +106 -0
  96. package/dist/components/pagination/MPPagination.js +1 -0
  97. package/dist/components/pagination/index.d.ts +2 -0
  98. package/dist/components/pagination/index.js +1 -0
  99. package/dist/components/panes/MPPanes.js +1 -1
  100. package/dist/components/pill/MPPill.js +1 -1
  101. package/dist/components/popover/MPPopover.d.ts +8 -3
  102. package/dist/components/popover/MPPopover.js +1 -1
  103. package/dist/components/radio-group/MPRadioGroup.js +1 -1
  104. package/dist/components/rating/MPRating.d.ts +135 -0
  105. package/dist/components/rating/MPRating.js +1 -0
  106. package/dist/components/rating/index.d.ts +2 -0
  107. package/dist/components/rating/index.js +1 -0
  108. package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
  109. package/dist/components/select/MPSelect.d.ts +23 -6
  110. package/dist/components/select/MPSelect.js +1 -1
  111. package/dist/components/skeleton/MPSkeleton.js +1 -1
  112. package/dist/components/slider/MPSlider.js +1 -1
  113. package/dist/components/snackbar/MPSnackbar.d.ts +8 -3
  114. package/dist/components/snackbar/MPSnackbar.js +1 -1
  115. package/dist/components/spoiler/MPSpoiler.js +1 -1
  116. package/dist/components/switch/MPSwitch.d.ts +2 -2
  117. package/dist/components/switch/MPSwitch.js +1 -1
  118. package/dist/components/table/MPTable.d.ts +14 -1
  119. package/dist/components/table/MPTable.js +1 -1
  120. package/dist/components/tabs/MPTabs.d.ts +145 -0
  121. package/dist/components/tabs/MPTabs.js +1 -0
  122. package/dist/components/tabs/index.d.ts +2 -0
  123. package/dist/components/tabs/index.js +1 -0
  124. package/dist/components/text-field/MPTextField.d.ts +37 -7
  125. package/dist/components/text-field/MPTextField.js +1 -1
  126. package/dist/components/text-link/MPTextLink.js +1 -1
  127. package/dist/components/time-picker/MPTimePicker.js +1 -1
  128. package/dist/components/timeline/MPTimeline.js +1 -1
  129. package/dist/constants/icons.d.ts +13 -0
  130. package/dist/constants/icons.js +1 -1
  131. package/dist/index.d.ts +18 -0
  132. package/dist/index.js +1 -1
  133. package/dist/internal/Calendar.js +1 -1
  134. package/dist/internal/FieldOutline.d.ts +75 -4
  135. package/dist/internal/FieldOutline.js +1 -1
  136. package/dist/internal/Picker.d.ts +52 -9
  137. package/dist/internal/Picker.js +1 -1
  138. package/dist/internal/animate.d.ts +179 -0
  139. package/dist/internal/animate.js +1 -0
  140. package/dist/internal/date.d.ts +2 -2
  141. package/dist/internal/date.js +1 -1
  142. package/dist/internal/i18n.d.ts +110 -0
  143. package/dist/internal/i18n.js +1 -1
  144. package/dist/internal/inert.d.ts +11 -0
  145. package/dist/internal/inert.js +1 -0
  146. package/dist/internal/surface.d.ts +42 -12
  147. package/dist/internal/surface.js +1 -1
  148. package/dist/styles.css +1 -1
  149. package/dist/tailwind.css +640 -4
  150. package/dist/types.d.ts +155 -0
  151. 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
- /** Label in the outline's notch, or above the panel when `inline`. */
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. Derived from `name`
81
- * when omitted, and generated when there is no name either.
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 l}from"@base-ui/react/popover";import{MPIcon as t}from"../icon/MPIcon";import{CheckIcon as o,CloseIcon as i}from"../../constants/icons";import{MPFieldLabel as s,MPFieldOutline as u}from"../../internal/FieldOutline";import{MPStateLayer as c}from"../../internal/StateLayer";import{MPSupportingText as d}from"../../internal/SupportingText";import{CONTROL_ICON as p,META_TEXT as h,PROSE_TEXT as f,STACK_GAP as m,hasContent as g}from"../../internal/scale";import{FADE as v,PORTAL_LAYER as b}from"../../internal/surface";import{CHECKER_BACKGROUND as x,DEFAULT_SWATCHES as y,clamp as w,cssColor as N,formatColor as k,parseColor as C,readableInk as j}from"../../internal/color";const _={area:"Saturation and brightness",hue:"Hue",alpha:"Opacity",value:"Colour value",swatches:"Swatches",clear:"Clear",empty:"No colour"},z={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"},P={xs:"gap-2",sm:"gap-2.5",md:"gap-3",lg:"gap-3.5",xl:"gap-4"},T={xs:12,sm:14,md:16,lg:18,xl:20},I={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"}},O="border-mp-outline-variant relative overflow-hidden border",S=["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 A(e){const a=e.currentTarget.getBoundingClientRect();return{x:0===a.width?0:w((e.clientX-a.left)/a.width,0,1),y:0===a.height?0:w((e.clientY-a.top)/a.height,0,1)}}function B(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 D({hsv:r,alphaValue:n,onChange:l,text:i,onTextChange:s,withAlpha:u,swatches:c,editable:d,size:p,inert:f,labels:m}){const g=T[p],v=-g/2,b=N({h:r.h,s:100,v:100}),y=N(r),_=e=>({onPointerDown:a=>{f||(a.currentTarget.setPointerCapture(a.pointerId),e(a))},onPointerMove:a=>{!f&&a.currentTarget.hasPointerCapture(a.pointerId)&&e(a)}}),I=(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=B(e);!f&&a&&0!==a.x&&(e.preventDefault(),n(a.x))}}),D=["outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ");return a("div",{className:`mp-color-picker__panel flex flex-col ${z[p]} ${P[p]}`,children:[e("div",{..._(e=>{const{x:a,y:t}=A(e);l({hsv:{h:r.h,s:100*a,v:100*(1-t)},alpha:n})}),role:"slider",tabIndex:f?-1:0,"aria-label":m.area,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r.s),"aria-valuetext":`${Math.round(r.s)}%, ${Math.round(r.v)}%`,"aria-disabled":f||void 0,onKeyDown:e=>{const a=B(e);!f&&a&&(e.preventDefault(),l({hsv:{h:r.h,s:w(r.s+a.x,0,100),v:w(r.v+a.y,0,100)},alpha:n}))},className:[O,"rounded-mp-sm",$[p],D,f?"cursor-default":"cursor-crosshair touch-none"].join(" "),style:{backgroundColor:b,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:S,style:{width:g,height:g,left:`${r.s}%`,top:100-r.v+"%",marginLeft:v,marginTop:v,backgroundColor:y}})}),e("div",{..._(e=>l({hsv:{...r,h:360*A(e).x},alpha:n})),...I(m.hue,r.h,360,e=>l({hsv:{...r,h:(r.h+2*e+360)%360},alpha:n})),className:[O,"rounded-mp-full",M[p],D,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:S,style:{width:g,height:g,left:r.h/360*100+"%",top:"50%",marginLeft:v,marginTop:v,backgroundColor:b}})}),u?a("div",{..._(e=>l({hsv:r,alpha:A(e).x})),...I(m.alpha,100*n,100,e=>l({hsv:r,alpha:w(n+e/100,0,1)})),className:[O,"rounded-mp-full",M[p],D,f?"cursor-default":"cursor-pointer touch-none"].join(" "),style:x,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundImage:`linear-gradient(to right, ${N(r,0)}, ${y})`}}),e("span",{className:S,style:{width:g,height:g,left:100*n+"%",top:"50%",marginLeft:v,marginTop:v,backgroundColor:N(r,n)}})]}):null,d?a("div",{className:`flex items-center ${P[p]}`,children:[e("span",{"aria-hidden":"true",className:"border-mp-outline-variant shrink-0 rounded-full border",style:{width:g+8,height:g+8,...x},children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:N(r,n)}})}),e("input",{type:"text",value:i,readOnly:f,spellCheck:!1,autoComplete:"off","aria-label":m.value,onChange:e=>s(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",h,"focus-visible:border-mp-primary outline-none"].join(" ")})]}):null,c&&c.length>0?e("div",{role:"group","aria-label":m.swatches,className:"grid grid-cols-8 gap-1",children:c.map(a=>{const i=C(a),s=null!==i&&k(i.hsv,i.alpha,"hex")===k(r,n,"hex");return e("button",{type:"button",disabled:f,"aria-label":a,"aria-pressed":s,onClick:()=>{i&&l(i)},className:["border-mp-outline-variant flex aspect-square items-center justify-center","rounded-full border",D,f?"cursor-default":"hover:shadow-mp-1 cursor-pointer"].join(" "),style:{backgroundColor:a},children:s&&i?e("span",{style:{color:j(i.hsv)},children:e(t,{icon:o,size:12})}):null},a)})}):null]})}const L={h:202,s:100,v:61};export const MPColorPicker=r.forwardRef(function({value:o,defaultValue:w="#00639b",onValueChange:j,format:z="hex",alpha:$=!1,swatches:M=y,inline:P=!1,editable:T=!0,label:O,description:S,errorMessage:A,required:B=!1,disabled:R=!1,readOnly:q=!1,clearable:V=!1,name:K,open:F,defaultOpen:E=!1,onOpenChange:H,labels:U,size:W="md",fullWidth:X=!1,id:Y,className:G,style:J},Q){const Z=r.useMemo(()=>({..._,...U}),[U]),ee=g(A),ae=I[W],re=r.useId(),ne=Y??`mp-color-picker-${K??re}`,[le,te]=r.useState(w),oe=o??le,[ie,se]=r.useState(E),ue=F??ie,[ce,de]=r.useState(()=>C(oe)??{hsv:L,alpha:1}),[pe,he]=r.useState(()=>oe),fe=k(ce.hsv,$?ce.alpha:1,z),me=""===oe;r.useEffect(()=>{const e=C(oe);e?k(e.hsv,$?e.alpha:1,z)!==fe&&(he(oe),de(e)):he(oe)},[oe,fe,$,z]);const ge=R||q,ve=V&&!ge&&!me,be=(e,a)=>{de(e);const r=k(e.hsv,$?e.alpha:1,z);he(a??r),void 0===o&&te(r),j?.(r)},xe=e(D,{hsv:ce.hsv,alphaValue:ce.alpha,onChange:be,text:pe,onTextChange:e=>{he(e);const a=C(e);a&&be(a,e)},withAlpha:$,swatches:M,editable:T,size:W,inert:ge,labels:Z}),ye=e("span",{"aria-hidden":"true",className:"border-mp-outline-variant block size-5 shrink-0 rounded-full border",style:x,children:e("span",{className:"block size-full rounded-full",style:{backgroundColor:me?"transparent":N(ce.hsv,$?ce.alpha:1)}})}),we=K?e("input",{type:"hidden",name:K,value:me?"":fe}):null;return P?a("div",{ref:Q,"data-mp-size":W,className:["mp-color-picker flex flex-col",m[W],G??""].filter(Boolean).join(" "),style:J,children:[g(O)?a("span",{className:[h,R?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[O,B?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,xe,g(A)?e("span",{className:`${h} text-mp-error`,children:A}):g(S)?e("span",{className:`${h} text-mp-on-surface-variant`,children:S}):null,we]}):a(n.Root,{ref:Q,disabled:R,invalid:ee,"data-mp-size":W,className:["mp-color-picker group flex-col align-top",X?"flex w-full":"inline-flex w-fit",G??""].filter(Boolean).join(" "),style:J,children:[a(l.Root,{open:ue,onOpenChange:e=>{void 0===F&&se(e),H?.(e)},children:[a("div",{className:"relative w-full",children:[a(l.Trigger,{id:ne,disabled:R,nativeButton:!0,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",ae.padding,ve?"pe-10":"",ae.height,f[W],R?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(q?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[ye,e("span",{className:["min-w-0 flex-1 truncate text-start",me?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:me?Z.empty:fe})]}),ve?a("button",{type:"button","aria-label":Z.clear,onClick:()=>{void 0===o&&te(""),he(""),j?.("")},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(c,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(t,{icon:i,size:p[W]})]}):null,e(u,{label:O,required:B}),g(O)?e(s,{size:W,label:O,required:B,htmlFor:ne}):null]}),e(l.Portal,{children:e(l.Positioner,{className:b,sideOffset:4,align:"start",children:e(l.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],v].join(" "),children:xe})})})]}),e(d,{description:S,errorMessage:A,className:ae.padding}),we]})});
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
- /** Shown in the input while nothing is typed. */
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. Always drawn there rather than floating over
76
- * the placeholder, so a combobox and a text field sit at the same height in a
77
- * form.
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
- /** Accessible name of the clear button. @default 'Clear' */
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
- * @default 'Open'
135
+ *
136
+ * Defaults to the word for "open" in `locale`.
114
137
  */
115
138
  openLabel?: string;
116
- /** Accessible name of a chip's remove button. Receives the chip's label. */
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. Derived from `name` when
122
- * omitted, and generated when there is no name either.
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 r}from"../icon/MPIcon";import{AddIcon as o,CheckIcon as s,ChevronDownIcon as m,CloseIcon as c}from"../../constants/icons";import{MPFieldLabel as u,MPFieldOutline as p}from"../../internal/FieldOutline";import{MPStateLayer as d}from"../../internal/StateLayer";import{MPSupportingText as h}from"../../internal/SupportingText";import{CONTROL_ICON as f,PROSE_TEXT as b,hasContent as g}from"../../internal/scale";import{FADE as x,PORTAL_LAYER as v}from"../../internal/surface";const y={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"}},C={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"},N={xs:"xs",sm:"xs",md:"sm",lg:"md",xl:"md"};function w(e){return null==e?[]:Array.isArray(e)?e.slice():[e]}export function MPCombobox({items:L,multiple:j,value:I,defaultValue:S,onValueChange:z,onInputValueChange:O,allowCustom:M=!0,customLabel:V,clearable:$=!1,emptyMessage:P="No matches",limit:q,placeholder:A,label:R,description:T,errorMessage:k,startIcon:_,size:F="md",fullWidth:E=!1,required:B=!1,disabled:G=!1,readOnly:H=!1,name:W,open:D,defaultOpen:J,onOpenChange:K,clearLabel:Q="Clear",openLabel:U="Open",removeLabel:X=e=>`Remove ${e}`,inputRef:Y,id:Z,className:ee,style:ae}){const le=g(k),ie=!0===j,ne=y[F],te=l.useId(),re=Z??`mp-combobox-${W??te}`,oe=l.useMemo(()=>L.map(e=>({value:e.value,label:e.label??String(e.value),disabled:e.disabled})),[L]),[se,me]=l.useState(()=>w(S)),ce=void 0===I?se:w(I),[ue,pe]=l.useState(""),de=l.useCallback(e=>oe.find(a=>a.value===e)??{value:e,label:String(e),custom:!0},[oe]),he=ue.trim(),fe=he.toLocaleLowerCase(),be=""===he||oe.some(e=>e.label.toLocaleLowerCase()===fe||String(e.value).toLocaleLowerCase()===fe)||ce.some(e=>String(e).toLocaleLowerCase()===fe),ge=!M||H||G||be?null:he,xe=l.useMemo(()=>null===ge?oe:[...oe,{value:ge,label:ge,custom:!0}],[oe,ge]),ve=ie?ce.map(de):ce.length>0?de(ce[0]):null;const ye=["min-w-0 flex-1 self-stretch bg-transparent font-[inherit] text-inherit outline-none","placeholder:text-mp-on-surface-variant",G?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface caret-mp-primary"].join(" "),Ce=["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(" "),Ne=a=>e(i.Input,{ref:Y,id:re,placeholder:A,className:ie?`${ye} min-w-16 ${a?"ms-1.5":""}`:ye});return a(n.Root,{disabled:G,invalid:le,"data-mp-size":F,className:["mp-combobox group flex-col align-top",E?"flex w-full":"inline-flex w-fit",ee??""].filter(Boolean).join(" "),style:ae,children:[a(i.Root,{name:W,items:xe,multiple:ie,value:ve,onValueChange:e=>{!function(e){void 0===I&&me(e),z?.(ie?e:e[0]??null)}((null===e?[]:Array.isArray(e)?e:[e]).map(e=>e.value))},onInputValueChange:e=>{pe(e),O?.(e)},open:D,defaultOpen:J,onOpenChange:e=>K?.(e),autoHighlight:!0,itemToStringLabel:e=>e.label,itemToStringValue:e=>String(e.value),isItemEqualToValue:(e,a)=>e.value===a.value,limit:q,disabled:G,readOnly:H,required:B,children:[a("div",{className:"relative w-full",children:[a(i.InputGroup,{className:["relative flex w-full items-center gap-2",ne.padding,ie?C[F]:ne.height,b[F],G?"cursor-default":"cursor-text"].join(" "),children:[_?e("span",{className:["flex shrink-0 items-center",G?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:_}):null,ie?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:le?"outlined":"tonal",color:le?"error":"primary",size:N[F],disabled:G,endIcon:H||G?null:e(i.ChipRemove,{"aria-label":X(a.label),className:"flex cursor-pointer items-center opacity-70 hover:opacity-100",children:e(r,{icon:c,size:16})})}),children:a.label},String(a.value))),Ne(n.length>0)]})})}):Ne(!1),$&&!H?a(i.Clear,{"aria-label":Q,className:Ce,children:[e(d,{}),e(r,{icon:c,size:f[F]})]}):null,a(i.Trigger,{"aria-label":U,className:Ce,children:[e(d,{}),e(i.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:f[F]})})]})]}),e(p,{label:R,required:B}),g(R)?e(u,{size:F,label:R,required:B,htmlFor:re}):null]}),e(i.Portal,{children:e(i.Positioner,{className:v,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",b[F],x].join(" "),children:[e(i.Empty,{className:"text-mp-on-surface-variant px-3 py-2 empty:hidden",children:P}),e(i.List,{children:l=>a(i.Item,{value:l,disabled:l.disabled,className:["mp-combobox__item rounded-mp-xs relative flex cursor-pointer items-center","gap-3 py-2 ps-2 pe-3 select-none outline-none","data-highlighted:bg-mp-on-surface/8","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("span",{className:"flex size-5 shrink-0 items-center justify-center",children:l.custom?e(r,{icon:o,size:18}):e(i.ItemIndicator,{children:e(r,{icon:s,size:18})})}),e("span",{className:"min-w-0 flex-1 truncate",children:l.custom?V?V(l.label):`Add “${l.label}”`:l.label})]},`${l.custom?"custom:":""}${String(l.value)}`)})]})})})]}),e(h,{description:T,errorMessage:k,className:ne.padding})]})}
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,2 @@
1
+ export { MPContainer } from './MPContainer';
2
+ export type { MPContainerProps } from './MPContainer';
@@ -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 d}from"../../internal/locale";import{CONTROL_ICON as u}from"../../internal/scale";import{displaySamples as p,formatDate as f,isDayOutside as h,isValidDate as b,localeWeekStart as x,mergeDateAndTime as v,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=d("picker",Y,G),$=E??x(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)?v(e,ae):D(e);se(a),re(g(a)),A&&ie(!1)},me=y(),de=h(me,I,V)||(B?.(me)??!1),ue=q||T,pe=l.useMemo(()=>C(p(Y,F),N),[Y,F,N]);return e(c,{...W,slug:"date-picker",size:J,color:K,readOnly:L,disabled:Q,name:H,triggerRef:X,startIcon:U??e(t,{icon:n,size:u[J]}),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:de,onClick:()=>ce(me),children:Z.today}):null]}):null]})})});
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 m,useMPMessages as d}from"../../internal/locale";import{MPWidthSizer as p}from"../../internal/WidthSizer";import{CONTROL_ICON as h,META_TEXT as f}from"../../internal/scale";import{addMonths as v,compareDay as x,displaySamples 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=m(W),ae=d("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=v(xe,1),De=2===q,ke=n.useMemo(()=>g(ne,_),[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]=x(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,name:Q,triggerRef:le,startIcon:Z??e(t,{icon:s,size:h[T]}),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(p,{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:h[T]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Ce(ce,G)}),e(p,{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(v(e,-1)),showPreviousButton:!1}):null]}),J||null!==Oe?l(c,{children:[null!==Oe?e("span",{className:`text-mp-on-surface-variant me-auto ${f}`,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
+ 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 m,MPPickerShell as d}from"../../internal/Picker";import{useMPLocale as u,useMPMessages as h}from"../../internal/locale";import{CONTROL_ICON as p}from"../../internal/scale";import{displaySamples as f,formatDate as S,isDayOutside as b,isHour12 as g,isValidDate as D,localeWeekStart as v,mergeDateAndTime as x,startOfDay as C,startOfMonth as k,timeUnitSpan as w,toISODateTime as z,today as O,withPlaceholder as y,withTime as M}from"../../internal/date";export const MPDateTimePicker=t.forwardRef(function({value:T,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=u(A),se=h("picker",ie,$),ce=G??v(ie),me=J??g(ie),[de,ue]=t.useState(P??null),he=void 0!==T?T:de,[pe,fe]=t.useState(N??!1),Se=I??pe,[be,ge]=t.useState(()=>k(D(he)?he:B??O()));t.useEffect(()=>{Se&&ge(k(D(he)?he:B??O()))},[Se]);const De=e=>{e&&(te||le)||(void 0===I&&fe(e),V?.(e))},ve=e=>{void 0===T&&ue(e),j?.(e)},xe=t.useCallback((e,o)=>{const[t,l]=w(o,e),a=C(e).getTime();return!!(D(R)&&a+1e3*l<R.getTime())||(!!(D(E)&&a+1e3*t>E.getTime())||(q?.(e,o)??!1))},[R,E,q]),Ce=H??{dateStyle:"medium",timeStyle:"short",hour12:me},ke=new Date,we=M(ke,{seconds:K?ke.getSeconds():0}),ze=b(we,R,E)||(F?.(we)??!1)||xe(we,"second"),Oe=t.useMemo(()=>y(f(ie,Ce),W),[ie,Ce,W]);return e(d,{...ne,slug:"date-time-picker",size:ee,color:oe,readOnly:te,disabled:le,name:_,triggerRef:re,startIcon:ae??e(a,{icon:n,size:p[ee]}),display:D(he)?S(he,ie,Ce):W??"",samples:Oe,empty:!D(he),clearable:X,onClear:()=>ve(null),open:Se,onOpenChange:De,labels:se,hiddenValues:_?[{name:_,value:D(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=D(he)?x(e,he):C(e);ve(o),ge(k(o)),Z&&De(!1)},minDate:R,maxDate:E,shouldDisableDate:F,labels:se,autoFocus:!0}),e(c,{}),e(i,{size:ee,locale:ie,value:D(he)?he:null,referenceDate:D(he)?he:O(),onChange:ve,hour12:me,showSeconds:K,hourStep:L,minuteStep:Q,secondStep:U,shouldDisableTime:xe,labels:se})]}),o(m,{children:[X?e(l,{variant:"text",size:s[ee],color:oe,onClick:()=>{ve(null),De(!1)},children:se.clear}):null,Y?e(l,{variant:"text",size:s[ee],color:oe,disabled:ze,onClick:()=>{ve(we),ge(k(we))},children:se.now}):null,e(l,{variant:"filled",size:s[ee],color:oe,onClick:()=>De(!1),children:se.done})]})]})})});
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
- * @default 'Close'
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 i}from"@base-ui/react/dialog";import{MPIcon as t}from"../icon/MPIcon";import{CloseIcon as n}from"../../constants/icons";import{accentSlots as o}from"../../internal/accent";import{MPStateLayer as s}from"../../internal/StateLayer";import{SHEET_GAP as r,hasContent as a}from"../../internal/scale";import{FADE as m,PORTAL_LAYER as c,SCRIM as p}from"../../internal/surface";const d={xs:"max-w-[320px]",sm:"max-w-[400px]",md:"max-w-[560px]",lg:"max-w-[720px]",xl:"max-w-[960px]"},x={xs:"p-3",sm:"p-4",md:"p-6",lg:"p-7",xl:"p-8"},f={xs:"px-3",sm:"px-4",md:"px-6",lg:"px-7",xl:"px-8"},u={xs:"py-3",sm:"py-4",md:"py-6",lg:"py-7",xl:"py-8"},h={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"},g={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"},y={xs:20,sm:22,md:24,lg:28,xl:32};export const MPDialogClose=i.Close;export function MPDialog({open:v,defaultOpen:b,onOpenChange:w,trigger:j,icon:N,title:$,description:C,actions:k,dividers:P=!1,showClose:B,closeLabel:z="Close",width:D,fullWidth:O=!0,fullScreen:M=!1,modal:L=!0,dismissible:S=!0,size:T="md",color:W="secondary",className:I,style:R,children:V}){const _=B??M,q=a(N),A=a($)||a(C)||q,E=a(k),F=P?x[T]:f[T],G="border-mp-outline-variant border-t";return l(i.Root,{open:v,defaultOpen:b,modal:L,disablePointerDismissal:!S,onOpenChange:(e,l)=>{S||e||"escape-key"!==l.reason?w?.(e):l.cancel()},children:[j?e(i.Trigger,{render:j}):null,l(i.Portal,{children:[e(i.Backdrop,{className:`${c} fixed inset-0 ${m} ${p}`}),e(i.Viewport,{className:[c,"fixed inset-0 flex justify-center",M?"items-stretch":"items-center p-4"].join(" "),children:l(i.Popup,{"data-mp-size":T,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",M?"h-full max-w-none rounded-none":`rounded-mp-xl max-h-full ${void 0===D?d[T]:""}`,M||O?"":"w-auto",P?"":`${u[T]} ${r[T]}`,m,I??""].filter(Boolean).join(" "),style:{...o(W),...void 0===D||M?null:{maxWidth:"number"==typeof D?`${D}px`:D},...R},children:[A||_?l("div",{className:["flex shrink-0 items-start gap-3",F,q&&!_?"flex-col items-center text-center":""].filter(Boolean).join(" "),children:[q?e("span",{className:"flex shrink-0 items-center justify-center text-(--_mp-accent)",children:N}):null,l("div",{className:`flex min-w-0 flex-1 flex-col ${r[T]}`,children:[a($)?e(i.Title,{className:`m-0 ${h[T]}`,children:$}):null,a(C)?e(i.Description,{className:`text-mp-on-surface-variant m-0 ${g[T]}`,children:C}):null]}),_?l(i.Close,{"aria-label":z,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(s,{}),e(t,{icon:n,size:y[T]})]}):null]}):null,a(V)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",g[T],F,P&&(A||_)?G:""].filter(Boolean).join(" "),children:V}):null,E?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",F,P?G:""].filter(Boolean).join(" "),children:k}):null]})})]})]})}
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
- * @default 'Close'
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 it does not slide
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. The transition is opacity only,
158
- * exactly as on the dialog: a drawer is nothing but text and controls, and a
159
- * panel that slid would drag its own sentences across the screen for the length
160
- * of the animation. What says the panel came from an edge is that it is
161
- * *attached* to one: square against the window, cut on the free side.
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 l,Fragment as o}from"react/jsx-runtime";import{Dialog as r}from"@base-ui/react/dialog";import{MPIcon as i}from"../icon/MPIcon";import{CloseIcon as t}from"../../constants/icons";import{MPStateLayer as n}from"../../internal/StateLayer";import{hasContent as a,META_TEXT as s,PROSE_TEXT as d,SHEET_GAP as m,SHEET_PAD_X as c,SHEET_PAD_Y as f,SHEET_TITLE as p}from"../../internal/scale";import{FADE as u,PORTAL_LAYER as h,SCRIM as x}from"../../internal/surface";const b={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},g={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},v={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},w={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},y="border-mp-outline-variant border-t";export const MPDrawerClose=r.Close;export function MPDrawer({side:$="left",mode:j="modal",open:N,defaultOpen:C,onOpenChange:k,trigger:z,title:P,description:B,actions:D,dividers:O=!1,showClose:M,closeLabel:L="Close",extent:T,rounded:F=!0,dismissible:I=!0,size:R="md",className:S,style:V,children:q}){const A="modal"===j,E="left"===$||"right"===$,G=M??A,H=c[R],J=f[R],K=O?`${H} ${J}`:H,Q=a(P)||a(B),U=a(D),W=void 0===T?null:{[E?"width":"height"]:"number"==typeof T?`${T}px`:T},X=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",A?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",d[R],v[$],F?g[$]:"",A?u:"",E?`h-full max-w-full ${void 0===T?b[R]:""}`:"w-full "+(void 0===T?"max-h-[85%]":""),O?"":`${J} ${m[R]}`,S??""].filter(Boolean).join(" "),Y=A?r.Title:"h2",Z=A?r.Description:"p",_=["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(" "),ee=l(o,{children:[Q||G?l("div",{className:`flex shrink-0 items-start gap-3 ${K}`,children:[l("div",{className:"flex min-w-0 flex-1 flex-col",children:[a(P)?e(Y,{className:`m-0 ${p[R]}`,children:P}):null,a(B)?e(Z,{className:`text-mp-on-surface-variant m-0 ${s}`,children:B}):null]}),G?A?l(r.Close,{"aria-label":L,className:_,children:[e(n,{}),e(i,{icon:t,size:20})]}):l("button",{type:"button","aria-label":L,className:_,onClick:()=>k?.(!1),children:[e(n,{}),e(i,{icon:t,size:20})]}):null]}):null,a(q)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",K,O&&(Q||G)?y:"",O?"":"-my-1 py-1"].filter(Boolean).join(" "),children:q}):null,U?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",K,O?y:""].filter(Boolean).join(" "),children:D}):null]});return A?l(r.Root,{open:N,defaultOpen:C,disablePointerDismissal:!I,onOpenChange:(e,l)=>{I||e||"escape-key"!==l.reason?k?.(e):l.cancel()},children:[z?e(r.Trigger,{render:z}):null,l(r.Portal,{children:[e(r.Backdrop,{className:`${h} fixed inset-0 ${u} ${x}`}),e(r.Viewport,{className:`${h} fixed inset-0 flex ${w[$]}`,children:e(r.Popup,{"data-mp-size":R,"data-mp-side":$,"data-mp-mode":j,className:X,style:{...W,...V},children:ee})})]})]}):N??C??1?e("div",{"data-mp-size":R,"data-mp-side":$,"data-mp-mode":j,className:X,style:{...W,...V},children:ee}):null}
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 `Nothing here`; pass `false` for a state that is a
7
- * glyph and a sentence with no heading over them.
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 s}from"@base-ui/react/use-render";import{hasContent as a,PROSE_TEXT as l,SHEET_GAP as i,SHEET_PAD_X as o,SHEET_TITLE as m}from"../../internal/scale";import{CONTAINER_SURFACE as c}from"../../internal/surface";const d={xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},p={xs:"text-[1.5rem]",sm:"text-[1.75rem]",md:"text-[2.25rem]",lg:"text-[2.75rem]",xl:"text-[3.25rem]"};function x(){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:u="md",title:f,icon:h,action:v,render:y,className:N,style:j,children:g,...k},w){const z=void 0===f?"Nothing here":f,$=void 0===h?e(x,{}):h,L=a(z),B=["mp-empty flex w-full flex-col items-center justify-center text-center",o[u],d[u],"text"===n?"":"rounded-mp-md",i[u],c[n],"text-mp-on-surface",N??""].filter(Boolean).join(" ");return s({render:y,ref:w,props:{role:"status","data-mp-size":u,"data-mp-variant":n,className:B,style:j,children:t(r,{children:[a($)?e("span",{className:`text-mp-on-surface-variant flex items-center ${p[u]} [&>svg]:size-[1em]`,children:$}):null,L||a(g)?t("div",{className:`flex max-w-prose flex-col items-center ${i[u]}`,children:[L?e("div",{className:m[u],children:z}):null,a(g)?e("div",{className:`${l[u]} ${L?"text-mp-on-surface-variant":""}`,children:g}):null]}):null,a(v)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:v}):null]}),...k}})});
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]}),...$}})});