material-plus-ui 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +10 -6
  2. package/dist/a2ui/catalog.d.ts +104 -0
  3. package/dist/a2ui/catalog.js +1 -0
  4. package/dist/a2ui/components/MPA2uiAudioPlayer.d.ts +1 -0
  5. package/dist/a2ui/components/MPA2uiAudioPlayer.js +2 -0
  6. package/dist/a2ui/components/MPA2uiButton.d.ts +1 -0
  7. package/dist/a2ui/components/MPA2uiButton.js +2 -0
  8. package/dist/a2ui/components/MPA2uiCard.d.ts +1 -0
  9. package/dist/a2ui/components/MPA2uiCard.js +2 -0
  10. package/dist/a2ui/components/MPA2uiCheckBox.d.ts +1 -0
  11. package/dist/a2ui/components/MPA2uiCheckBox.js +2 -0
  12. package/dist/a2ui/components/MPA2uiChoicePicker.d.ts +1 -0
  13. package/dist/a2ui/components/MPA2uiChoicePicker.js +2 -0
  14. package/dist/a2ui/components/MPA2uiColumn.d.ts +1 -0
  15. package/dist/a2ui/components/MPA2uiColumn.js +2 -0
  16. package/dist/a2ui/components/MPA2uiDateTimeInput.d.ts +1 -0
  17. package/dist/a2ui/components/MPA2uiDateTimeInput.js +2 -0
  18. package/dist/a2ui/components/MPA2uiDivider.d.ts +1 -0
  19. package/dist/a2ui/components/MPA2uiDivider.js +2 -0
  20. package/dist/a2ui/components/MPA2uiIcon.d.ts +1 -0
  21. package/dist/a2ui/components/MPA2uiIcon.js +2 -0
  22. package/dist/a2ui/components/MPA2uiImage.d.ts +1 -0
  23. package/dist/a2ui/components/MPA2uiImage.js +2 -0
  24. package/dist/a2ui/components/MPA2uiList.d.ts +1 -0
  25. package/dist/a2ui/components/MPA2uiList.js +2 -0
  26. package/dist/a2ui/components/MPA2uiModal.d.ts +1 -0
  27. package/dist/a2ui/components/MPA2uiModal.js +2 -0
  28. package/dist/a2ui/components/MPA2uiRow.d.ts +1 -0
  29. package/dist/a2ui/components/MPA2uiRow.js +2 -0
  30. package/dist/a2ui/components/MPA2uiSlider.d.ts +1 -0
  31. package/dist/a2ui/components/MPA2uiSlider.js +2 -0
  32. package/dist/a2ui/components/MPA2uiTabs.d.ts +1 -0
  33. package/dist/a2ui/components/MPA2uiTabs.js +2 -0
  34. package/dist/a2ui/components/MPA2uiText.d.ts +1 -0
  35. package/dist/a2ui/components/MPA2uiText.js +2 -0
  36. package/dist/a2ui/components/MPA2uiTextField.d.ts +1 -0
  37. package/dist/a2ui/components/MPA2uiTextField.js +2 -0
  38. package/dist/a2ui/components/MPA2uiVideo.d.ts +1 -0
  39. package/dist/a2ui/components/MPA2uiVideo.js +2 -0
  40. package/dist/a2ui/extended/MPA2uiBarChart.d.ts +1 -0
  41. package/dist/a2ui/extended/MPA2uiBarChart.js +2 -0
  42. package/dist/a2ui/extended/MPA2uiDataTable.d.ts +1 -0
  43. package/dist/a2ui/extended/MPA2uiDataTable.js +2 -0
  44. package/dist/a2ui/extended/MPA2uiLineChart.d.ts +1 -0
  45. package/dist/a2ui/extended/MPA2uiLineChart.js +2 -0
  46. package/dist/a2ui/extended/MPA2uiPieChart.d.ts +1 -0
  47. package/dist/a2ui/extended/MPA2uiPieChart.js +2 -0
  48. package/dist/a2ui/extended/MPA2uiStatistic.d.ts +1 -0
  49. package/dist/a2ui/extended/MPA2uiStatistic.js +2 -0
  50. package/dist/a2ui/extended/api.d.ts +1436 -0
  51. package/dist/a2ui/extended/api.js +1 -0
  52. package/dist/a2ui/extended/chart.d.ts +26 -0
  53. package/dist/a2ui/extended/chart.js +1 -0
  54. package/dist/a2ui/index.d.ts +103 -0
  55. package/dist/a2ui/index.js +1 -0
  56. package/dist/a2ui/internal/children.d.ts +28 -0
  57. package/dist/a2ui/internal/children.js +1 -0
  58. package/dist/a2ui/internal/common.d.ts +113 -0
  59. package/dist/a2ui/internal/common.js +1 -0
  60. package/dist/a2ui/internal/icons.d.ts +3 -0
  61. package/dist/a2ui/internal/icons.js +1 -0
  62. package/dist/components/accordion/MPAccordion.d.ts +13 -0
  63. package/dist/components/accordion/MPAccordion.js +1 -1
  64. package/dist/components/accordion/index.d.ts +1 -1
  65. package/dist/components/alert/MPAlert.d.ts +1 -1
  66. package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
  67. package/dist/components/animate-grow/MPAnimateGrow.d.ts +1 -1
  68. package/dist/components/animate-headline/MPAnimateHeadline.d.ts +8 -0
  69. package/dist/components/animate-headline/MPAnimateHeadline.js +1 -1
  70. package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
  71. package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
  72. package/dist/components/animate-scramble/MPAnimateScramble.d.ts +8 -0
  73. package/dist/components/animate-scramble/MPAnimateScramble.js +1 -1
  74. package/dist/components/animate-slide/MPAnimateSlide.d.ts +1 -1
  75. package/dist/components/animate-split/MPAnimateSplit.d.ts +8 -0
  76. package/dist/components/animate-split/MPAnimateSplit.js +1 -1
  77. package/dist/components/animate-typing/MPAnimateTyping.d.ts +10 -2
  78. package/dist/components/animate-typing/MPAnimateTyping.js +1 -1
  79. package/dist/components/animate-zoom/MPAnimateZoom.d.ts +2 -2
  80. package/dist/components/app-logo/MPAppLogo.d.ts +6 -1
  81. package/dist/components/area-chart/MPAreaChart.d.ts +18 -3
  82. package/dist/components/area-chart/MPAreaChart.js +1 -1
  83. package/dist/components/avatar/MPAvatar.d.ts +17 -1
  84. package/dist/components/avatar/MPAvatar.js +1 -1
  85. package/dist/components/bar-chart/MPBarChart.d.ts +15 -5
  86. package/dist/components/bar-chart/MPBarChart.js +1 -1
  87. package/dist/components/blockquote/MPBlockquote.d.ts +1 -1
  88. package/dist/components/box/MPBox.d.ts +1 -1
  89. package/dist/components/breadcrumb/MPBreadcrumb.d.ts +8 -0
  90. package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
  91. package/dist/components/carousel/MPCarousel.js +1 -1
  92. package/dist/components/checkbox/MPCheckbox.js +1 -1
  93. package/dist/components/chip/MPChip.d.ts +1 -1
  94. package/dist/components/code-block/MPCodeBlock.js +1 -1
  95. package/dist/components/combobox/MPCombobox.js +1 -1
  96. package/dist/components/command-palette/MPCommandPalette.js +1 -1
  97. package/dist/components/config/MPConfigProvider.d.ts +17 -1
  98. package/dist/components/config/MPConfigProvider.js +1 -1
  99. package/dist/components/confirm/MPConfirmProvider.js +1 -1
  100. package/dist/components/data-table/MPDataTable.d.ts +0 -34
  101. package/dist/components/data-table/MPDataTable.js +1 -1
  102. package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
  103. package/dist/components/drawer/MPDrawer.d.ts +13 -1
  104. package/dist/components/drawer/MPDrawer.js +1 -1
  105. package/dist/components/empty/MPEmpty.d.ts +1 -1
  106. package/dist/components/file-picker/MPFilePicker.js +1 -1
  107. package/dist/components/form/MPForm.d.ts +3 -0
  108. package/dist/components/form/MPForm.js +1 -1
  109. package/dist/components/gauge-chart/MPGaugeChart.js +1 -1
  110. package/dist/components/header/MPHeader.js +1 -1
  111. package/dist/components/heatmap-chart/MPHeatmapChart.d.ts +12 -3
  112. package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
  113. package/dist/components/image/MPImage.d.ts +5 -0
  114. package/dist/components/image/MPImage.js +1 -1
  115. package/dist/components/line-chart/MPLineChart.d.ts +20 -2
  116. package/dist/components/line-chart/MPLineChart.js +1 -1
  117. package/dist/components/locale/MPLocaleProvider.d.ts +15 -30
  118. package/dist/components/locale/MPLocaleProvider.js +1 -1
  119. package/dist/components/menu/MPMenu.d.ts +9 -1
  120. package/dist/components/menu/MPMenu.js +1 -1
  121. package/dist/components/meter/MPMeter.d.ts +5 -0
  122. package/dist/components/meter/MPMeter.js +1 -1
  123. package/dist/components/mockup/MPMockup.js +1 -1
  124. package/dist/components/navigation-menu/MPNavigationMenu.d.ts +27 -1
  125. package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
  126. package/dist/components/number-field/MPNumberField.d.ts +2 -1
  127. package/dist/components/number-field/MPNumberField.js +1 -1
  128. package/dist/components/otp-field/MPOtpField.js +1 -1
  129. package/dist/components/page-layout/MPPageLayout.js +1 -1
  130. package/dist/components/pagination/MPPagination.d.ts +8 -0
  131. package/dist/components/pagination/MPPagination.js +1 -1
  132. package/dist/components/panes/MPPanes.js +1 -1
  133. package/dist/components/pie-chart/MPPieChart.d.ts +23 -1
  134. package/dist/components/pie-chart/MPPieChart.js +1 -1
  135. package/dist/components/pill/MPPill.js +1 -1
  136. package/dist/components/progress-box/MPProgressBox.js +1 -1
  137. package/dist/components/progress-circular/MPProgressCircular.js +1 -1
  138. package/dist/components/progress-linear/MPProgressLinear.js +1 -1
  139. package/dist/components/radio-group/MPRadioGroup.js +1 -1
  140. package/dist/components/scatter-chart/MPScatterChart.d.ts +5 -1
  141. package/dist/components/scatter-chart/MPScatterChart.js +1 -1
  142. package/dist/components/sidebar/MPSidebar.d.ts +11 -0
  143. package/dist/components/sidebar/MPSidebar.js +1 -1
  144. package/dist/components/slider/MPSlider.d.ts +5 -0
  145. package/dist/components/slider/MPSlider.js +1 -1
  146. package/dist/components/snackbar/MPSnackbar.js +1 -1
  147. package/dist/components/sparkline/MPSparkline.d.ts +14 -1
  148. package/dist/components/sparkline/MPSparkline.js +1 -1
  149. package/dist/components/switch/MPSwitch.js +1 -1
  150. package/dist/components/tabs/MPTabs.js +1 -1
  151. package/dist/components/text-field/MPTextField.js +1 -1
  152. package/dist/components/timeline-chart/MPTimelineChart.d.ts +6 -2
  153. package/dist/components/timeline-chart/MPTimelineChart.js +1 -1
  154. package/dist/components/tour/MPTour.js +1 -1
  155. package/dist/components/transfer/MPTransfer.js +1 -1
  156. package/dist/components/tree-select/MPTreeSelect.js +1 -1
  157. package/dist/components/tree-view/MPTreeView.d.ts +8 -0
  158. package/dist/components/tree-view/MPTreeView.js +1 -1
  159. package/dist/components/typography/MPTypography.d.ts +1 -1
  160. package/dist/hooks/index.d.ts +4 -2
  161. package/dist/hooks/index.js +1 -1
  162. package/dist/hooks/mpColorSchemeScript.d.ts +46 -0
  163. package/dist/hooks/mpColorSchemeScript.js +1 -0
  164. package/dist/hooks/useMPColorScheme.d.ts +2 -47
  165. package/dist/hooks/useMPColorScheme.js +1 -1
  166. package/dist/hooks/useMPMediaQuery.js +1 -1
  167. package/dist/hooks/useMPOnScreen.js +1 -1
  168. package/dist/internal/Calendar.js +1 -1
  169. package/dist/internal/ChartChrome.d.ts +73 -14
  170. package/dist/internal/ChartChrome.js +1 -1
  171. package/dist/internal/ChartFrame.d.ts +24 -4
  172. package/dist/internal/ChartFrame.js +1 -1
  173. package/dist/internal/FieldOutline.d.ts +9 -1
  174. package/dist/internal/FieldOutline.js +1 -1
  175. package/dist/internal/RenderedLink.d.ts +20 -0
  176. package/dist/internal/RenderedLink.js +2 -0
  177. package/dist/internal/SupportingText.js +1 -1
  178. package/dist/internal/animate.d.ts +4 -0
  179. package/dist/internal/animate.js +1 -1
  180. package/dist/internal/box-size.d.ts +22 -0
  181. package/dist/internal/box-size.js +2 -0
  182. package/dist/internal/chart.d.ts +111 -13
  183. package/dist/internal/chart.js +1 -1
  184. package/dist/internal/color-scheme-keys.d.ts +13 -0
  185. package/dist/internal/color-scheme-keys.js +1 -0
  186. package/dist/internal/color-scheme.d.ts +11 -2
  187. package/dist/internal/color-scheme.js +1 -1
  188. package/dist/internal/config.d.ts +2 -0
  189. package/dist/internal/date.d.ts +2 -8
  190. package/dist/internal/date.js +1 -1
  191. package/dist/internal/highlight.js +1 -1
  192. package/dist/internal/i18n.d.ts +4 -53
  193. package/dist/internal/i18n.js +1 -1
  194. package/dist/internal/intersection.d.ts +50 -0
  195. package/dist/internal/intersection.js +2 -0
  196. package/dist/internal/intl.d.ts +22 -21
  197. package/dist/internal/intl.js +1 -1
  198. package/dist/internal/keys.d.ts +0 -9
  199. package/dist/internal/keys.js +1 -1
  200. package/dist/internal/layout-effect.d.ts +7 -0
  201. package/dist/internal/layout-effect.js +2 -0
  202. package/dist/internal/locale.d.ts +10 -2
  203. package/dist/internal/media.d.ts +1 -0
  204. package/dist/internal/media.js +1 -0
  205. package/dist/internal/messages/chart.d.ts +1 -1
  206. package/dist/internal/messages/chart.js +1 -1
  207. package/dist/internal/occurrence.d.ts +18 -0
  208. package/dist/internal/occurrence.js +1 -0
  209. package/dist/internal/page-layout.js +1 -1
  210. package/dist/internal/progress.d.ts +5 -0
  211. package/dist/internal/ref.d.ts +9 -0
  212. package/dist/internal/ref.js +1 -0
  213. package/dist/internal/remember.d.ts +36 -0
  214. package/dist/internal/remember.js +1 -0
  215. package/dist/internal/surface.d.ts +7 -1
  216. package/dist/internal/surface.js +1 -1
  217. package/dist/internal/text.d.ts +10 -4
  218. package/dist/internal/text.js +1 -1
  219. package/dist/internal/window-class.d.ts +8 -0
  220. package/dist/internal/window-class.js +1 -1
  221. package/dist/locales/ar.js +1 -1
  222. package/dist/locales/de.js +1 -1
  223. package/dist/locales/es.js +1 -1
  224. package/dist/locales/fr.js +1 -1
  225. package/dist/locales/hi.js +1 -1
  226. package/dist/locales/id.js +1 -1
  227. package/dist/locales/it.js +1 -1
  228. package/dist/locales/ja.js +1 -1
  229. package/dist/locales/ko.js +1 -1
  230. package/dist/locales/nl.js +1 -1
  231. package/dist/locales/pl.js +1 -1
  232. package/dist/locales/pt.js +1 -1
  233. package/dist/locales/ru.js +1 -1
  234. package/dist/locales/th.js +1 -1
  235. package/dist/locales/tr.js +1 -1
  236. package/dist/locales/vi.js +1 -1
  237. package/dist/locales/zh-hans.js +1 -1
  238. package/dist/locales/zh-hant.js +1 -1
  239. package/dist/styles/accordion.css +1 -1
  240. package/dist/styles/alert.css +1 -1
  241. package/dist/styles/animate-appear.css +1 -1
  242. package/dist/styles/animate-blink.css +1 -1
  243. package/dist/styles/animate-counter.css +1 -1
  244. package/dist/styles/animate-fade.css +1 -1
  245. package/dist/styles/animate-float.css +1 -1
  246. package/dist/styles/animate-grow.css +1 -1
  247. package/dist/styles/animate-headline.css +1 -1
  248. package/dist/styles/animate-lighting.css +1 -1
  249. package/dist/styles/animate-marquee.css +1 -1
  250. package/dist/styles/animate-reveal.css +1 -1
  251. package/dist/styles/animate-rotate.css +1 -1
  252. package/dist/styles/animate-scramble.css +1 -1
  253. package/dist/styles/animate-shake.css +1 -1
  254. package/dist/styles/animate-slide.css +1 -1
  255. package/dist/styles/animate-split.css +1 -1
  256. package/dist/styles/animate-typing.css +1 -1
  257. package/dist/styles/animate-zoom.css +1 -1
  258. package/dist/styles/area-chart.css +1 -1
  259. package/dist/styles/avatar.css +1 -1
  260. package/dist/styles/bar-chart.css +1 -1
  261. package/dist/styles/blockquote.css +1 -1
  262. package/dist/styles/box.css +1 -1
  263. package/dist/styles/breadcrumb.css +1 -1
  264. package/dist/styles/calendar.css +1 -1
  265. package/dist/styles/card.css +1 -1
  266. package/dist/styles/carousel.css +1 -1
  267. package/dist/styles/checkbox.css +1 -1
  268. package/dist/styles/chip.css +1 -1
  269. package/dist/styles/collapsible.css +1 -1
  270. package/dist/styles/color-picker.css +1 -1
  271. package/dist/styles/combobox.css +1 -1
  272. package/dist/styles/command-palette.css +1 -1
  273. package/dist/styles/confirm.css +1 -1
  274. package/dist/styles/data-table.css +1 -1
  275. package/dist/styles/date-picker.css +1 -1
  276. package/dist/styles/date-range-picker.css +1 -1
  277. package/dist/styles/date-time-picker.css +1 -1
  278. package/dist/styles/dialog.css +1 -1
  279. package/dist/styles/drawer.css +1 -1
  280. package/dist/styles/empty.css +1 -1
  281. package/dist/styles/floating-bottom-navigation.css +1 -1
  282. package/dist/styles/footer.css +1 -1
  283. package/dist/styles/gauge-chart.css +1 -1
  284. package/dist/styles/header.css +1 -1
  285. package/dist/styles/heatmap-chart.css +1 -1
  286. package/dist/styles/highlight.css +1 -1
  287. package/dist/styles/hover-card.css +1 -1
  288. package/dist/styles/image.css +1 -1
  289. package/dist/styles/line-chart.css +1 -1
  290. package/dist/styles/list.css +1 -1
  291. package/dist/styles/menu.css +1 -1
  292. package/dist/styles/menubar.css +1 -1
  293. package/dist/styles/meter.css +1 -1
  294. package/dist/styles/navigation-menu.css +1 -1
  295. package/dist/styles/number-field.css +1 -1
  296. package/dist/styles/otp-field.css +1 -1
  297. package/dist/styles/overlay.css +1 -1
  298. package/dist/styles/page-layout.css +1 -1
  299. package/dist/styles/pie-chart.css +1 -1
  300. package/dist/styles/pill.css +1 -1
  301. package/dist/styles/popconfirm.css +1 -1
  302. package/dist/styles/popover.css +1 -1
  303. package/dist/styles/progress-box.css +1 -1
  304. package/dist/styles/progress-circular.css +1 -1
  305. package/dist/styles/progress-linear.css +1 -1
  306. package/dist/styles/radio-group.css +1 -1
  307. package/dist/styles/scatter-chart.css +1 -1
  308. package/dist/styles/select.css +1 -1
  309. package/dist/styles/sidebar.css +1 -1
  310. package/dist/styles/slider.css +1 -1
  311. package/dist/styles/snackbar.css +1 -1
  312. package/dist/styles/sparkline.css +1 -1
  313. package/dist/styles/spoiler.css +1 -1
  314. package/dist/styles/stack.css +1 -1
  315. package/dist/styles/statistic.css +1 -1
  316. package/dist/styles/switch.css +1 -1
  317. package/dist/styles/table.css +1 -1
  318. package/dist/styles/tabs.css +1 -1
  319. package/dist/styles/text-field.css +1 -1
  320. package/dist/styles/time-picker.css +1 -1
  321. package/dist/styles/timeline-chart.css +1 -1
  322. package/dist/styles/tokens.css +1 -1
  323. package/dist/styles/toolbar.css +1 -1
  324. package/dist/styles/tour.css +1 -1
  325. package/dist/styles/transfer.css +1 -1
  326. package/dist/styles/tree-select.css +1 -1
  327. package/dist/styles/tree-view.css +1 -1
  328. package/dist/styles/typography.css +1 -1
  329. package/dist/styles.css +1 -1
  330. package/dist/tailwind.css +116 -4
  331. package/dist/types.d.ts +208 -1
  332. package/package.json +25 -4
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";const a=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:u,children:m}){const[d,f]=o.useState(null),p=c(s,l()),h=o.useRef(null),C=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...u,...e,acknowledge:r})}),[u]),P=o.useMemo(()=>({confirm:e=>C(e,!1),alert:e=>C(e,!0).then(()=>{})}),[C]),x=e=>{h.current?.(e),h.current=null,f(null)},g=o.useRef(null);d&&(g.current=d);const v=d??g.current,w=v?.acknowledge??!1;return n(a.Provider,{value:P,children:[m,e(t,{open:null!==d,onOpenChange:e=>{e||x(w)},icon:v?.icon,title:v?.title,description:v?.description,size:v?.size??"md",color:v?.color??"primary",dismissible:v?.dismissible??!0,actions:n(r,{children:[w?null:e(i,{variant:"text",onClick:()=>x(!1),children:v?.cancelLabel??p.cancel}),e(i,{variant:"text",color:v?.color??"primary",onClick:()=>x(!0),children:v?.confirmLabel??(w?p.ok:p.confirm)})]}),children:v?.children})]})}export function useMPConfirm(){const e=o.useContext(a);if(!e)throw new Error("useMPConfirm was called outside an <MPConfirmProvider>. Wrap the application in one — the provider is what holds the dialog every confirm() is drawn in.");return e}
2
+ import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{MPDialog as t}from"../dialog/MPDialog.js";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";const a=/*@__PURE__*/o.createContext(null);export function MPConfirmProvider({defaults:u,children:m}){const[d,f]=o.useState(null),p=c(s,l()),h=o.useRef(null),C=o.useRef(u);C.current=u;const P=o.useCallback((e,r)=>new Promise(n=>{h.current?.(!1),h.current=n,f({...C.current,...e,acknowledge:r})}),[]),x=o.useMemo(()=>({confirm:e=>P(e,!1),alert:e=>P(e,!0).then(()=>{})}),[P]),g=e=>{h.current?.(e),h.current=null,f(null)},v=o.useRef(null);d&&(v.current=d);const w=d??v.current,j=w?.acknowledge??!1;return n(a.Provider,{value:x,children:[m,e(t,{open:null!==d,onOpenChange:e=>{e||g(j)},icon:w?.icon,title:w?.title,description:w?.description,size:w?.size??"md",color:w?.color??"primary",dismissible:w?.dismissible??!0,actions:n(r,{children:[j?null:e(i,{variant:"text",onClick:()=>g(!1),children:w?.cancelLabel??p.cancel}),e(i,{variant:"text",color:w?.color??"primary",onClick:()=>g(!0),children:w?.confirmLabel??(j?p.ok:p.confirm)})]}),children:w?.children})]})}export function useMPConfirm(){const e=o.useContext(a);if(!e)throw new Error("useMPConfirm was called outside an <MPConfirmProvider>. Wrap the application in one — the provider is what holds the dialog every confirm() is drawn in.");return e}
@@ -277,38 +277,4 @@ export interface MPDataTableProps<Row> extends Omit<React.ComponentPropsWithoutR
277
277
  density?: MPDensity;
278
278
  classNames?: MPSlots<MPDataTableSlot>;
279
279
  }
280
- /**
281
- * A grid of data with the four things a reader does to one: put it in order,
282
- * cut it down, step through it and take some of it away.
283
- *
284
- * ```tsx
285
- * <MPDataTable headers={columns} items={rows} sortable searchable paged />
286
- * ```
287
- *
288
- * It is a separate component from [MPTable](table) rather than a mode of it.
289
- * `MPTable` is the presentational half: it
290
- * draws what it is given, in the order it is given, and a page that only shows a
291
- * grid should not carry a comparator, a CSV writer and a page clamp to do it.
292
- * What the two do share is the geometry — `internal/table.ts` holds the cells'
293
- * room and the type they are set in — so a data table never sits a pixel off the
294
- * plain table beside it.
295
- *
296
- * ## What it does to the rows, and in what order
297
- *
298
- * Search, then `filter`, then sort, then the page. The order is the only one
299
- * that makes each step mean what it says: sorting before searching would order
300
- * rows nobody is going to see, and paging before either would cut a page out of
301
- * a list the reader has not asked for yet. `render`'s `index` counts along the
302
- * sorted, searched order across every page, so it is a running row number rather
303
- * than a position on the screen.
304
- *
305
- * ## Who holds the keyboard
306
- *
307
- * A row that answers a press has to answer a keyboard, and a table of two
308
- * hundred rows that each did would be two hundred tab stops. So there is exactly
309
- * one route into a row and `checkboxes` is what picks it: with ticks, the tick
310
- * is the control and the row is not in the tab order; without them, the row is.
311
- * `onRowClick` on its own always puts the row in the tab order, because then
312
- * there is nothing else to press.
313
- */
314
280
  export declare function MPDataTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, sortable, sortMode, sort: sortProp, defaultSort, onSortChange, searchable, search: searchProp, defaultSearch, onSearchChange, searchLabel, filter, toolbar, paged, page: pageProp, defaultPage, onPageChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, pageSizeOptions, resizable, columnWidths: columnWidthsProp, defaultColumnWidths, onColumnWidthsChange, selectionMode, selected: selectedProp, defaultSelected, onSelectedChange, checkboxes, onRowClick, exportable, exportFileName, exportEscapeFormulas, onExport, striped, hoverable, stickyHeader, variant, elevation, size: sizeProp, color: colorProp, density: densityProp, className, style, classNames, ...props }: MPDataTableProps<Row>): React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{MPButton as r}from"../button/MPButton.js";import{MPCheckbox as n}from"../checkbox/MPCheckbox.js";import{MPIcon as o}from"../icon/MPIcon.js";import{MPPagination as l}from"../pagination/MPPagination.js";import{MPSelect as s}from"../select/MPSelect.js";import{MPTextField as i}from"../text-field/MPTextField.js";import{ArrowDownIcon as c,ArrowUpIcon as d,SearchIcon as m}from"../../constants/icons.js";import{accentSlots as u}from"../../internal/accent.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as f,useMPDensity as h,useMPSize as y}from"../../internal/config.js";import{useMPLocale as g,useMPMessages as b}from"../../internal/locale.js";import{fillMessage as v}from"../../internal/i18n.js";import{DATA_TABLE as x}from"../../internal/messages/data-table.js";import{TABLE as k}from"../../internal/messages/table.js";import{TRANSFER as w}from"../../internal/messages/transfer.js";import{CONTROL_ICON as S,META_TEXT as N}from"../../internal/scale.js";import{VISUALLY_HIDDEN as j}from"../../internal/visually-hidden.js";import{CELL_TEXT as C,HEAD_TEXT as z,ROW as _,cellPadX as M,cellPadY as P,drawableCell as E}from"../../internal/table.js";import{DEFAULT_COLUMN_WIDTH as L,MIN_COLUMN_WIDTH as D,compareValues as $,downloadText as A,keysBetween as I,nextSort as K,pageBounds as W,searchHaystack as R,searchText as T,sortRows as B,toCsv as F}from"../../internal/data-table.js";function V(e,t){return e.value?e.value(t):t[e.key]}const H={xs:36,sm:40,md:48,lg:52,xl:60},X=/*@__PURE__*/["group/sort -m-1 flex w-full cursor-pointer items-center gap-1 rounded-mp-xs p-1","appearance-none border-0 bg-transparent text-inherit text-start [font:inherit]","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","hover:text-mp-on-surface","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),O=/*@__PURE__*/["mp-data-table__resize absolute inset-y-0 end-0 z-10 w-2 translate-x-1/2 rtl:-translate-x-1/2","cursor-col-resize touch-none select-none appearance-none border-0 bg-transparent p-0","after:absolute after:inset-y-1 after:start-1/2 after:w-px after:bg-transparent","after:transition-[background-color] after:duration-(--mp-sys-motion-duration-short4)","hover:after:bg-mp-primary data-dragging:after:bg-mp-primary","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-solid outline-none"].join(" ");export function MPDataTable({headers:q,items:G,getRowKey:J,caption:Q,empty:U,locale:Y,sortable:Z=!1,sortMode:ee="single",sort:te,defaultSort:ae,onSortChange:re,searchable:ne=!1,search:oe,defaultSearch:le,onSearchChange:se,searchLabel:ie,filter:ce,toolbar:de,paged:me=!1,page:ue,defaultPage:pe,onPageChange:fe,pageSize:he,defaultPageSize:ye,onPageSizeChange:ge,pageSizeOptions:be=[10,25,50,100],resizable:ve=!1,columnWidths:xe,defaultColumnWidths:ke,onColumnWidthsChange:we,selectionMode:Se="none",selected:Ne,defaultSelected:je,onSelectedChange:Ce,checkboxes:ze=!1,onRowClick:_e,exportable:Me=!1,exportFileName:Pe="table.csv",exportEscapeFormulas:Ee=!0,onExport:Le,striped:De=!1,hoverable:$e=!1,stickyHeader:Ae=!1,variant:Ie="outlined",elevation:Ke,size:We,color:Re,density:Te,className:Be,style:Fe,classNames:Ve,...He}){const Xe=y(We),Oe=f(Re),qe=h(Te),Ge=g(Y),Je=b(x,Ge),Qe=b(k,Ge),Ue=b(w,Ge),Ye=M(Xe,qe),Ze=P(Xe,qe),[et,tt]=a.useState(()=>[...ae??[]]),at=te??et,[rt,nt]=a.useState(le??""),ot=oe??rt,[lt,st]=a.useState(pe??1),it=ue??lt,[ct,dt]=a.useState(ye??25),mt=he??ct,[ut,pt]=a.useState(()=>({...ke})),ft=xe??ut,[ht,yt]=a.useState(()=>[...je??[]]),gt=Ne??ht,bt=a.useMemo(()=>new Set(gt.map(e=>String(e))),[gt]),vt=a.useRef(null),xt=a.useMemo(()=>G.map((e,t)=>{const a=J?J(e,t):t;return{row:e,identity:a,key:String(a),origin:t}}),[G,J]),kt=a.useMemo(()=>{const e=q.filter(e=>!1!==e.searchable);return xt.map(t=>R(e.map(e=>V(e,t.row))))},[xt,q]),wt=T(ot.trim()),St=a.useMemo(()=>{const e=""===wt?xt:xt.filter((e,t)=>kt[t].includes(wt));return ce?e.filter(e=>ce(e.row,e.origin)):e},[xt,kt,wt,ce]),Nt=a.useMemo(()=>new Intl.Collator(Ge,{numeric:!0,sensitivity:"base"}),[Ge]),jt=a.useMemo(()=>B(St,at,(e,t)=>{const a=q.find(t=>t.key===e);if(!a)return null;const r="desc"===t,n=a.compare;return n?(e,t)=>r?-n(e.row,t.row):n(e.row,t.row):(e,t)=>$(V(a,e.row),V(a,t.row),Nt,r)}),[St,at,q,Nt]),Ct=W(jt.length,it,mt),zt=me?jt.slice(Ct.start,Ct.end):jt,_t=e=>{void 0===ue&&st(e),fe?.(e)},Mt=e=>{void 0===xe&&pt(e),we?.(e)},Pt=e=>{const t=new Set(e),a=[],r=[];for(const e of xt)t.has(e.key)&&(r.push(e.identity),a.push(e.row));void 0===Ne&&yt(r),Ce?.(r,a)},Et="none"!==Se,Lt="multiple"===Se,Dt=ze&&Et,$t=(e,t,a)=>{if(_e?.(e.row,Ct.start+t),Et){if(!Lt)return Pt(bt.has(e.key)?[]:[e.key]),void(vt.current=e.key);if(a&&null!==vt.current){const t=I(zt.map(e=>e.key),vt.current,e.key);return void Pt([...new Set([...bt,...t])])}vt.current=e.key,Pt(bt.has(e.key)?[...bt].filter(t=>t!==e.key):[...bt,e.key])}},At=zt.map(e=>e.key),It=At.filter(e=>bt.has(e)).length,Kt=At.length>0&&It===At.length,Wt=e=>ft[e.key]??e.width??L,Rt=a.useRef(null);a.useEffect(()=>()=>{null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)},[]);const Tt=(e,t)=>{const a=Math.max(D,e.minWidth??D);Mt({...ft,[e.key]:Math.max(a,Wt(e)+t)})},Bt=e=>{const t={...ft};delete t[e.key],Mt(t)},Ft={padding:`${Ze} ${Ye}`},Vt={...Ft,backgroundColor:"var(--_mp-color-surface-container)"},Ht={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"},Xt=q.length+(Dt?1:0),Ot=Boolean(_e)||Et&&!Dt,qt=$e||Et||Boolean(_e),Gt=ne||Me||void 0!==de,Jt=me||Et,Qt=(...e)=>e.filter(Boolean).join(" ");return t("div",{"data-mp-size":Xe,"data-mp-variant":Ie,className:Qt("mp-data-table rounded-mp-md flex flex-col",p(Ie,Ke),Be),style:{...u(Oe),...Fe},...He,children:[Gt?t("div",{className:Qt("mp-data-table__toolbar flex flex-wrap items-center gap-2",Ve?.toolbar),style:{padding:`${Ze} ${Ye}`},children:[ne?e(i,{size:Xe,value:ot,onChange:e=>{void 0===oe&&nt(e),_t(1),se?.(e)},label:ie??Ue.search,startIcon:e(o,{icon:m,size:S[Xe]}),className:"mp-data-table__search min-w-0 flex-1"}):e("div",{className:"min-w-0 flex-1"}),de,Me?e(r,{size:Xe,variant:"text",color:Oe,onClick:()=>{const e=q.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),a=jt.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):V(e,t.row))),r=F([t,...a],{escapeFormulas:Ee});Le?Le(r):A(r,Pe,"text/csv;charset=utf-8")},startIcon:e(o,{icon:c,size:S[Xe]}),children:Je.download}):null]}):null,e("div",{className:"mp-data-table__scroll min-h-0 flex-1 overflow-auto",children:t("table",{className:Qt("text-mp-on-surface w-full text-start",C[Xe],Ve?.table),style:{borderCollapse:"collapse",...ve?{tableLayout:"fixed",minWidth:q.reduce((e,t)=>e+Wt(t),Dt?H[Xe]:0)}:void 0},children:[Q?e("caption",{className:`text-mp-on-surface-variant ${N}`,style:{...Ft,textAlign:"start"},children:Q}):null,t("colgroup",{children:[Dt?e("col",{style:{width:H[Xe]}}):null,q.map(t=>e("col",{style:ve||void 0!==ft[t.key]||void 0!==t.width?{width:Wt(t)}:void 0},t.key))]}),e("thead",{className:Ve?.head,children:t("tr",{children:[Dt?e("th",{scope:"col",className:Qt("whitespace-nowrap",Ae&&"sticky top-0 z-20"),style:Vt,children:e(n,{size:Xe,color:Oe,checked:Kt,indeterminate:It>0&&!Kt,onCheckedChange:()=>{Pt(Kt?[...bt].filter(e=>!At.includes(e)):[...new Set([...bt,...At])])},label:e("span",{className:j,children:Je.selectAll}),disabled:!Lt||0===At.length})}):null,q.map(a=>{const r=a.sortable??Z,n=(l=a.key,at.findIndex(e=>e.key===l));var l;const s=-1===n?void 0:at[n],i=a.resizable??ve,c=a.align??"start";return t("th",{scope:"col","aria-sort":r?void 0===s?"none":"asc"===s.direction?"ascending":"descending":void 0,className:Qt("text-mp-on-surface-variant relative whitespace-nowrap",z[Xe],Ae&&"sticky top-0 z-10"),style:{...Vt,textAlign:c},children:[r?t("button",{type:"button",className:Qt(X,"end"===c&&"justify-end","center"===c&&"justify-center"),onClick:e=>((e,t)=>{const a=K(at,e,t&&"multiple"===ee);void 0===te&&tt(a),re?.(a)})(a.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:a.label??a.key}),e(o,{icon:d,size:S[Xe]-6,className:Qt("shrink-0 transition-[rotate,opacity]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",void 0===s?"opacity-0 group-hover/sort:opacity-38":"text-mp-primary opacity-100","desc"===s?.direction&&"rotate-180")}),at.length>1&&-1!==n?e("span",{className:"text-mp-primary shrink-0 tabular-nums",children:n+1}):null]}):a.label??a.key,i?e("button",{type:"button","aria-label":Je.resize,className:O,onPointerDown:e=>((e,t)=>{const a=t.currentTarget;try{a.setPointerCapture(t.pointerId)}catch{}a.dataset.dragging="true";const r=document.body.style.userSelect;Rt.current=r,document.body.style.userSelect="none";const n=t.clientX,o=Wt(e),l="rtl"===getComputedStyle(a).direction?-1:1,s=Math.max(D,e.minWidth??D),i=t=>{Mt({...ft,[e.key]:Math.max(s,Math.round(o+(t.clientX-n)*l))})},c=()=>{a.removeEventListener("pointermove",i),a.removeEventListener("pointerup",c),a.removeEventListener("pointercancel",c),delete a.dataset.dragging,null!==Rt.current&&(document.body.style.userSelect=Rt.current,Rt.current=null)};a.addEventListener("pointermove",i),a.addEventListener("pointerup",c),a.addEventListener("pointercancel",c)})(a,e),onDoubleClick:()=>Bt(a),onKeyDown:e=>{const t=e.shiftKey?32:8;"ArrowRight"===e.key?(e.preventDefault(),Tt(a,t)):"ArrowLeft"===e.key?(e.preventDefault(),Tt(a,-t)):"Home"===e.key&&(e.preventDefault(),Bt(a))}}):null]},a.key)})]})}),e("tbody",{children:0===zt.length?e("tr",{className:_,style:Ht,children:e("td",{colSpan:Xt,className:"text-mp-on-surface-variant",style:{padding:`2rem ${Ye}`,textAlign:"center"},children:U??Qe.empty})}):zt.map((a,r)=>{const o=bt.has(a.key);return t("tr",{"aria-selected":Et?o:void 0,className:Qt(_,Ve?.row,De&&(Ct.start+r)%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",o?"[--_mp-row:var(--_mp-color-secondary-container)]":"",qt&&!o?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",(Et||_e)&&"cursor-pointer",Ot&&["outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" ")),style:Ht,tabIndex:Ot?0:void 0,onClick:e=>$t(a,r,e.shiftKey),onKeyDown:Ot?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),$t(a,r,e.shiftKey))}:void 0,children:[Dt?e("td",{style:Ft,children:e(n,{size:Xe,color:Oe,checked:o,onCheckedChange:()=>$t(a,r,!1),label:e("span",{className:j,children:Je.selectRow})})}):null,q.map(t=>e("td",{className:Ve?.cell,style:{...Ft,textAlign:t.align??"start"},children:t.render?t.render(a.row,Ct.start+r):E(V(t,a.row))},t.key))]},a.key)})})]})}),Jt?t("div",{className:Qt("mp-data-table__footer border-mp-outline-variant flex flex-wrap items-center gap-3","text-mp-on-surface-variant border-t",N,Ve?.footer),style:{padding:`${Ze} ${Ye}`},children:[e("span",{className:"mp-data-table__count",children:v(Je.total,{total:String(jt.length)})}),bt.size>0?e("span",{className:"mp-data-table__selected text-mp-primary",children:v(Je.selected,{count:String(bt.size)})}):null,e("span",{className:"flex-1"}),me&&be.length>0?e(s,{size:"xs",label:Je.perPage,floatingLabel:!1,value:mt,onValueChange:e=>(e=>{void 0===he&&dt(e),_t(1),ge?.(e)})(Number(e)),items:be.map(e=>({value:e})),className:"mp-data-table__page-size",style:{minWidth:"9.5rem"}}):null,me?e(l,{size:"xs",color:Oe,count:Ct.pages,page:Ct.page,onPageChange:_t,locale:Ge}):null]}):null]})}
2
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{MPButton as n}from"../button/MPButton.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as o}from"../icon/MPIcon.js";import{MPPagination as l}from"../pagination/MPPagination.js";import{MPSelect as s}from"../select/MPSelect.js";import{MPTextField as i}from"../text-field/MPTextField.js";import{ArrowDownIcon as c,ArrowUpIcon as d,SearchIcon as m}from"../../constants/icons.js";import{accentSlots as u}from"../../internal/accent.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as f,useMPDensity as h,useMPSize as y}from"../../internal/config.js";import{useMPLocale as g,useMPMessages as b}from"../../internal/locale.js";import{fillMessage as v}from"../../internal/i18n.js";import{checkServerLocale as x,intlLocale as k}from"../../internal/intl.js";import{DATA_TABLE as w}from"../../internal/messages/data-table.js";import{TABLE as N}from"../../internal/messages/table.js";import{TRANSFER as S}from"../../internal/messages/transfer.js";import{CONTROL_ICON as C,META_TEXT as j}from"../../internal/scale.js";import{VISUALLY_HIDDEN as z}from"../../internal/visually-hidden.js";import{CELL_TEXT as _,HEAD_TEXT as M,ROW as P,cellPadX as L,cellPadY as E,drawableCell as $}from"../../internal/table.js";import{DEFAULT_COLUMN_WIDTH as A,MIN_COLUMN_WIDTH as D,compareValues as I,downloadText as K,keysBetween as R,nextSort as W,pageBounds as B,searchHaystack as F,searchText as T,sortRows as X,toCsv as V}from"../../internal/data-table.js";function H(e,t){return e.value?e.value(t):t[e.key]}const Y={xs:36,sm:40,md:48,lg:52,xl:60},q=/*@__PURE__*/["group/sort -m-1 flex w-full cursor-pointer items-center gap-1 rounded-mp-xs p-1","appearance-none border-0 bg-transparent text-inherit text-start [font:inherit]","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","hover:text-mp-on-surface","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),O=/*@__PURE__*/["mp-data-table__resize absolute inset-y-0 end-0 z-10 w-2 translate-x-1/2 rtl:-translate-x-1/2","cursor-col-resize touch-none select-none appearance-none border-0 bg-transparent p-0","after:absolute after:inset-y-1 after:start-1/2 after:w-px after:bg-transparent","after:transition-[background-color] after:duration-(--mp-sys-motion-duration-short4)","hover:after:bg-mp-primary data-dragging:after:bg-mp-primary","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-solid outline-none"].join(" "),G={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"};function J({entry:a,index:n,at:o,chosen:l,headers:s,striped:i,lit:c,pressable:d,selectable:m,tabStop:u,ticks:p,rowClassName:f,cellClassName:h,padX:y,padY:g,size:b,color:v,selectLabel:x,onPress:k}){const w={padding:`${g} ${y}`};return t("tr",{"aria-selected":m?l:void 0,className:[P,f,i&&o%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",l?"[--_mp-row:var(--_mp-color-secondary-container)]":"",c&&!l?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",d&&"cursor-pointer",u&&["outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" ")].filter(Boolean).join(" "),style:G,tabIndex:u?0:void 0,onClick:e=>k(a,n,e.shiftKey),onKeyDown:u?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),k(a,n,e.shiftKey))}:void 0,children:[p?e("td",{style:w,children:e(r,{size:b,color:v,checked:l,onCheckedChange:()=>k(a,n,!1),label:e("span",{className:z,children:x})})}):null,s.map(t=>e("td",{className:h,style:{...w,textAlign:t.align??"start"},children:t.render?t.render(a.row,o):$(H(t,a.row))},t.key))]})}const Q=/*@__PURE__*/a.memo(J);export function MPDataTable({headers:$,items:J,getRowKey:U,caption:Z,empty:ee,locale:te,sortable:ae=!1,sortMode:ne="single",sort:re,defaultSort:oe,onSortChange:le,searchable:se=!1,search:ie,defaultSearch:ce,onSearchChange:de,searchLabel:me,filter:ue,toolbar:pe,paged:fe=!1,page:he,defaultPage:ye,onPageChange:ge,pageSize:be,defaultPageSize:ve,onPageSizeChange:xe,pageSizeOptions:ke=[10,25,50,100],resizable:we=!1,columnWidths:Ne,defaultColumnWidths:Se,onColumnWidthsChange:Ce,selectionMode:je="none",selected:ze,defaultSelected:_e,onSelectedChange:Me,checkboxes:Pe=!1,onRowClick:Le,exportable:Ee=!1,exportFileName:$e="table.csv",exportEscapeFormulas:Ae=!0,onExport:De,striped:Ie=!1,hoverable:Ke=!1,stickyHeader:Re=!1,variant:We="outlined",elevation:Be,size:Fe,color:Te,density:Xe,className:Ve,style:He,classNames:Ye,...qe}){const Oe=y(Fe),Ge=f(Te),Je=h(Xe),Qe=g(te),Ue=b(w,Qe),Ze=b(N,Qe),et=b(S,Qe),tt=L(Oe,Je),at=E(Oe,Je),[nt,rt]=a.useState(()=>[...oe??[]]),ot=re??nt,[lt,st]=a.useState(ce??""),it=ie??lt,[ct,dt]=a.useState(ye??1),mt=he??ct,[ut,pt]=a.useState(ve??25),ft=be??ut,[ht,yt]=a.useState(()=>({...Se})),gt=Ne??ht,[bt,vt]=a.useState(()=>[..._e??[]]),xt=ze??bt,kt=a.useMemo(()=>new Set(xt.map(e=>String(e))),[xt]),wt=a.useRef(null),Nt=a.useMemo(()=>J.map((e,t)=>{const a=U?U(e,t):t;return{row:e,identity:a,key:String(a),origin:t}}),[J,U]),St=T(it.trim()),Ct=""!==St,jt=a.useMemo(()=>{if(!Ct)return null;const e=$.filter(e=>!1!==e.searchable);return Nt.map(t=>F(e.map(e=>H(e,t.row))))},[Nt,$,Ct]),zt=a.useMemo(()=>{const e=""!==St&&jt?Nt.filter((e,t)=>jt[t].includes(St)):Nt;return ue?e.filter(e=>ue(e.row,e.origin)):e},[Nt,jt,St,ue]),_t=a.useMemo(()=>(x(Qe),new Intl.Collator(k(Qe),{numeric:!0,sensitivity:"base"})),[Qe]),Mt=a.useMemo(()=>X(zt,ot,(e,t)=>{const a=$.find(t=>t.key===e);if(!a)return null;const n="desc"===t,r=a.compare;if(r)return(e,t)=>n?-r(e.row,t.row):r(e.row,t.row);const o=new Map,l=e=>(o.has(e)||o.set(e,H(a,e.row)),o.get(e));return(e,t)=>I(l(e),l(t),_t,n)}),[zt,ot,$,_t]),Pt=B(Mt.length,mt,ft),Lt=fe?Mt.slice(Pt.start,Pt.end):Mt,Et=e=>{void 0===he&&dt(e),ge?.(e)},$t=e=>{void 0===Ne&&yt(e),Ce?.(e)},At=e=>{const t=new Set(e),a=[],n=[];for(const e of Nt)t.has(e.key)&&(n.push(e.identity),a.push(e.row));void 0===ze&&vt(n),Me?.(n,a)},Dt="none"!==je,It="multiple"===je,Kt=Pe&&Dt,Rt=(e,t,a)=>{if(Le?.(e.row,Pt.start+t),Dt){if(!It)return At(kt.has(e.key)?[]:[e.key]),void(wt.current=e.key);if(a&&null!==wt.current){const t=R(Lt.map(e=>e.key),wt.current,e.key);return void At([...new Set([...kt,...t])])}wt.current=e.key,At(kt.has(e.key)?[...kt].filter(t=>t!==e.key):[...kt,e.key])}},Wt=a.useRef(Rt);Wt.current=Rt;const Bt=a.useCallback((e,t,a)=>Wt.current(e,t,a),[]),Ft=Lt.map(e=>e.key),Tt=Ft.filter(e=>kt.has(e)).length,Xt=Ft.length>0&&Tt===Ft.length,Vt=e=>gt[e.key]??e.width??A,Ht=a.useRef(null);a.useEffect(()=>()=>{null!==Ht.current&&(document.body.style.userSelect=Ht.current,Ht.current=null)},[]);const Yt=(e,t)=>{const a=Math.max(D,e.minWidth??D);$t({...gt,[e.key]:Math.max(a,Vt(e)+t)})},qt=e=>{const t={...gt};delete t[e.key],$t(t)},Ot={padding:`${at} ${tt}`},Gt={...Ot,backgroundColor:"var(--_mp-color-surface-container)"},Jt=G,Qt=$.length+(Kt?1:0),Ut=Boolean(Le)||Dt&&!Kt,Zt=Ke||Dt||Boolean(Le),ea=se||Ee||void 0!==pe,ta=fe||Dt,aa=(...e)=>e.filter(Boolean).join(" ");return t("div",{"data-mp-size":Oe,"data-mp-variant":We,className:aa("mp-data-table rounded-mp-md flex flex-col",p(We,Be),Ve),style:{...u(Ge),...He},...qe,children:[ea?t("div",{className:aa("mp-data-table__toolbar flex flex-wrap items-center gap-2",Ye?.toolbar),style:{padding:`${at} ${tt}`},children:[se?e(i,{size:Oe,value:it,onChange:e=>{void 0===ie&&st(e),Et(1),de?.(e)},label:me??et.search,startIcon:e(o,{icon:m,size:C[Oe]}),className:"mp-data-table__search min-w-0 flex-1"}):e("div",{className:"min-w-0 flex-1"}),pe,Ee?e(n,{size:Oe,variant:"text",color:Ge,onClick:()=>{const e=$.filter(e=>!1!==e.exportable),t=e.map(e=>"string"==typeof e.label?e.label:e.key),a=Mt.map(t=>e.map(e=>e.exportValue?e.exportValue(t.row):H(e,t.row))),n=V([t,...a],{escapeFormulas:Ae});De?De(n):K(n,$e,"text/csv;charset=utf-8")},startIcon:e(o,{icon:c,size:C[Oe]}),children:Ue.download}):null]}):null,e("div",{className:"mp-data-table__scroll min-h-0 flex-1 overflow-auto",children:t("table",{className:aa("text-mp-on-surface w-full text-start",_[Oe],Ye?.table),style:{borderCollapse:"collapse",...we?{tableLayout:"fixed",minWidth:$.reduce((e,t)=>e+Vt(t),Kt?Y[Oe]:0)}:void 0},children:[Z?e("caption",{className:`text-mp-on-surface-variant ${j}`,style:{...Ot,textAlign:"start"},children:Z}):null,t("colgroup",{children:[Kt?e("col",{style:{width:Y[Oe]}}):null,$.map(t=>e("col",{style:we||void 0!==gt[t.key]||void 0!==t.width?{width:Vt(t)}:void 0},t.key))]}),e("thead",{className:Ye?.head,children:t("tr",{children:[Kt?e("th",{scope:"col",className:aa("whitespace-nowrap",Re&&"sticky top-0 z-20"),style:Gt,children:e(r,{size:Oe,color:Ge,checked:Xt,indeterminate:Tt>0&&!Xt,onCheckedChange:()=>{const e=new Set(Ft);At(Xt?[...kt].filter(t=>!e.has(t)):[...new Set([...kt,...Ft])])},label:e("span",{className:z,children:Ue.selectAll}),disabled:!It||0===Ft.length})}):null,$.map(a=>{const n=a.sortable??ae,r=(l=a.key,ot.findIndex(e=>e.key===l));var l;const s=-1===r?void 0:ot[r],i=a.resizable??we,c=a.align??"start";return t("th",{scope:"col","aria-sort":n?void 0===s?"none":"asc"===s.direction?"ascending":"descending":void 0,className:aa("text-mp-on-surface-variant relative whitespace-nowrap",M[Oe],Re&&"sticky top-0 z-10"),style:{...Gt,textAlign:c},children:[n?t("button",{type:"button",className:aa(q,"end"===c&&"justify-end","center"===c&&"justify-center"),onClick:e=>((e,t)=>{const a=W(ot,e,t&&"multiple"===ne);void 0===re&&rt(a),le?.(a)})(a.key,e.shiftKey),children:[e("span",{className:"min-w-0 truncate",children:a.label??a.key}),e(o,{icon:d,size:C[Oe]-6,className:aa("shrink-0 transition-[rotate,opacity]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",void 0===s?"opacity-0 group-hover/sort:opacity-38":"text-mp-primary opacity-100","desc"===s?.direction&&"rotate-180")}),ot.length>1&&-1!==r?e("span",{className:"text-mp-primary shrink-0 tabular-nums",children:r+1}):null]}):a.label??a.key,i?e("button",{type:"button","aria-label":Ue.resize,className:O,onPointerDown:e=>((e,t)=>{const a=t.currentTarget;try{a.setPointerCapture(t.pointerId)}catch{}a.dataset.dragging="true";const n=document.body.style.userSelect;Ht.current=n,document.body.style.userSelect="none";const r=t.clientX,o=Vt(e),l="rtl"===getComputedStyle(a).direction?-1:1,s=Math.max(D,e.minWidth??D);let i=null,c=0;const d=()=>{c=0,null!==i&&($t({...gt,[e.key]:i}),i=null)},m=e=>{i=Math.max(s,Math.round(o+(e.clientX-r)*l)),0===c&&(c=requestAnimationFrame(d))},u=()=>{cancelAnimationFrame(c),d(),a.removeEventListener("pointermove",m),a.removeEventListener("pointerup",u),a.removeEventListener("pointercancel",u),delete a.dataset.dragging,null!==Ht.current&&(document.body.style.userSelect=Ht.current,Ht.current=null)};a.addEventListener("pointermove",m),a.addEventListener("pointerup",u),a.addEventListener("pointercancel",u)})(a,e),onDoubleClick:()=>qt(a),onKeyDown:e=>{const t=e.shiftKey?32:8;"ArrowRight"===e.key?(e.preventDefault(),Yt(a,t)):"ArrowLeft"===e.key?(e.preventDefault(),Yt(a,-t)):"Home"===e.key&&(e.preventDefault(),qt(a))}}):null]},a.key)})]})}),e("tbody",{children:0===Lt.length?e("tr",{className:P,style:Jt,children:e("td",{colSpan:Qt,className:"text-mp-on-surface-variant",style:{padding:`2rem ${tt}`,textAlign:"center"},children:ee??Ze.empty})}):Lt.map((t,a)=>e(Q,{entry:t,index:a,at:Pt.start+a,chosen:kt.has(t.key),headers:$,striped:Ie,lit:Zt,pressable:Dt||Boolean(Le),selectable:Dt,tabStop:Ut,ticks:Kt,rowClassName:Ye?.row,cellClassName:Ye?.cell,padX:tt,padY:at,size:Oe,color:Ge,selectLabel:Ue.selectRow,onPress:Bt},t.key))})]})}),ta?t("div",{className:aa("mp-data-table__footer border-mp-outline-variant flex flex-wrap items-center gap-3","text-mp-on-surface-variant border-t",j,Ye?.footer),style:{padding:`${at} ${tt}`},children:[e("span",{className:"mp-data-table__count",children:v(Ue.total,{total:String(Mt.length)})}),kt.size>0?e("span",{className:"mp-data-table__selected text-mp-primary",children:v(Ue.selected,{count:String(kt.size)})}):null,e("span",{className:"flex-1"}),fe&&ke.length>0?e(s,{size:"xs",label:Ue.perPage,floatingLabel:!1,value:ft,onValueChange:e=>(e=>{void 0===be&&pt(e),Et(1),xe?.(e)})(Number(e)),items:ke.map(e=>({value:e})),className:"mp-data-table__page-size",style:{minWidth:"9.5rem"}}):null,fe?e(l,{size:"xs",color:Ge,count:Pt.pages,page:Pt.page,onPageChange:Et,locale:Qe}):null]}):null]})}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{Calendar as o}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{MPWidthSizer as h}from"../../internal/WidthSizer.js";import{CONTROL_ICON as v,META_TEXT as x}from"../../internal/scale.js";import{addMonths as g,compareDay as j,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as D,today as k,withPlaceholder as y}from"../../internal/date.js";import{useMPColor as O,useMPSize as P}from"../../internal/config.js";const z={start:null,end:null};export const MPDateRangePicker=/*@__PURE__*/n.forwardRef(function({value:M,defaultValue:B,onValueChange:I,open:R,defaultOpen:V,onOpenChange:E,defaultMonth:F,minDate:W,maxDate:$,shouldDisableDate:_,locale:q,weekStartsOn:A,format:G={dateStyle:"medium"},monthCount:H=2,startPlaceholder:J,endPlaceholder:K,presets:L,clearable:Q=!1,closeOnSelect:T=!0,labels:U,name:X,size:Y,color:Z,readOnly:ee=!1,disabled:le=!1,startIcon:ne,...ae},te){const re=P(Y),se=O(Z),oe=d(q),ie=p(f,oe,U),ce=A??N(oe),[ue,me]=n.useState(B??z),de=void 0!==M?M??z:ue,pe=w(de.start)?de.start:null,fe=w(de.end)?de.end:null,[he,ve]=n.useState(V??!1),xe=R??he,[ge,je]=n.useState(null),[be,we]=n.useState(null),[Ne,Se]=n.useState(()=>C(pe??F??k()));n.useEffect(()=>{xe?Se(C(pe??F??k())):(je(null),we(null))},[xe]);const Ce=e=>{e&&(ee||le)||(void 0===R&&ve(e),E?.(e))},De=e=>{void 0===M&&me(e),I?.(e)},ke=ge??pe,ye=null!==ge?be:fe,Oe=(l,n)=>w(l)?b(l,oe,G):e("span",{className:"text-mp-on-surface-variant",children:n??""}),Pe=g(Ne,1),ze=2===H,Me=m(oe,G),Be=null!==ge?ie.end:null===pe?ie.start:null,Ie={size:re,color:se,locale:oe,weekStartsOn:ce,selected:[pe,fe,ge],rangeStart:ke,rangeEnd:ye,onSelect:e=>{const l=S(e);if(null===ge)return je(l),we(l),void De({start:l,end:null});const[n,a]=j(l,ge)<0?[l,ge]:[ge,l];je(null),we(null),De({start:n,end:a}),T&&Ce(!1)},onPreviewChange:e=>{null!==ge&&we(e??ge)},minDate:W,maxDate:$,shouldDisableDate:_,showOutsideDays:!1,labels:ie};return e(u,{...ae,slug:"date-range-picker",size:re,color:se,readOnly:ee,disabled:le,triggerRef:te,startIcon:void 0===ne?e(t,{icon:s,size:v[re]}):ne,display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(pe,J)}),e(h,{samples:y(Me,J)})]}),e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center rtl:rotate-180",children:e(t,{icon:r,size:v[re]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(fe,K)}),e(h,{samples:y(Me,K)})]})]}),empty:null===pe&&null===fe,clearable:Q,onClear:()=>De(z),open:xe,onOpenChange:Ce,labels:ie,hiddenValues:X?[{name:X,value:pe?D(pe):""},{name:X,value:fe?D(fe):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[L&&L.length>0?e("div",{className:"border-mp-outline-variant flex max-h-[calc(var(--_mp-cell,2.5rem)*8)] flex-col overflow-y-auto border-e pe-1.5",children:L.map((l,n)=>e(a,{variant:"text",size:i[re],color:se,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;je(null),we(null),De(l),w(l.start)&&Se(C(l.start)),T&&Ce(!1)})(l),children:l.label},n))}):null,e(o,{...Ie,month:Ne,onMonthChange:Se,showNextButton:!ze,autoFocus:!0}),ze?e(o,{...Ie,month:Pe,onMonthChange:e=>Se(g(e,-1)),showPreviousButton:!1}):null]}),Q||null!==Be?l(c,{children:[null!==Be?e("span",{className:`text-mp-on-surface-variant me-auto ${x}`,children:Be}):null,Q?e(a,{variant:"text",size:i[re],color:se,onClick:()=>{je(null),we(null),De(z),Ce(!1)},children:ie.clear}):null]}):null]})})});
2
+ import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as n from"react";import{MPButton as a}from"../button/MPButton.js";import{MPIcon as t}from"../icon/MPIcon.js";import{ArrowRightIcon as r,CalendarIcon as s}from"../../constants/icons.js";import{Calendar as o}from"../../internal/Calendar.js";import{FOOTER_SIZE as i,MPPickerFooter as c,MPPickerShell as u,useDisplaySamples as m}from"../../internal/Picker.js";import{useMPLocale as d,useMPMessages as p}from"../../internal/locale.js";import{PICKER as f}from"../../internal/messages/picker.js";import{MPWidthSizer as h}from"../../internal/WidthSizer.js";import{CONTROL_ICON as v,META_TEXT as x}from"../../internal/scale.js";import{addMonths as g,compareDay as j,formatDate as b,isValidDate as w,localeWeekStart as N,startOfDay as S,startOfMonth as C,toISODate as D,today as k,withPlaceholder as y}from"../../internal/date.js";import{useMPColor as O,useMPSize as P}from"../../internal/config.js";const z={start:null,end:null};export const MPDateRangePicker=/*@__PURE__*/n.forwardRef(function({value:M,defaultValue:B,onValueChange:I,open:R,defaultOpen:V,onOpenChange:E,defaultMonth:F,minDate:W,maxDate:$,shouldDisableDate:_,locale:q,weekStartsOn:A,format:G={dateStyle:"medium"},monthCount:H=2,startPlaceholder:J,endPlaceholder:K,presets:L,clearable:Q=!1,closeOnSelect:T=!0,labels:U,name:X,size:Y,color:Z,readOnly:ee=!1,disabled:le=!1,startIcon:ne,...ae},te){const re=P(Y),se=O(Z),oe=d(q),ie=p(f,oe,U),ce=A??N(oe),[ue,me]=n.useState(B??z),de=void 0!==M?M??z:ue,pe=w(de.start)?de.start:null,fe=w(de.end)?de.end:null,[he,ve]=n.useState(V??!1),xe=R??he,[ge,je]=n.useState(null),[be,we]=n.useState(null),[Ne,Se]=n.useState(()=>C(pe??F??k()));n.useEffect(()=>{xe?Se(C(pe??F??k())):(je(null),we(null))},[xe]);const Ce=e=>{e&&(ee||le)||(void 0===R&&ve(e),E?.(e))},De=e=>{void 0===M&&me(e),I?.(e)},ke=ge??pe,ye=null!==ge?be:fe,Oe=(l,n)=>w(l)?b(l,oe,G):e("span",{className:"text-mp-on-surface-variant",children:n??""}),Pe=n.useMemo(()=>g(Ne,1),[Ne]),ze=2===H,Me=m(oe,G),Be=null!==ge?ie.end:null===pe?ie.start:null,Ie={size:re,color:se,locale:oe,weekStartsOn:ce,selected:[pe,fe,ge],rangeStart:ke,rangeEnd:ye,onSelect:e=>{const l=S(e);if(null===ge)return je(l),we(l),void De({start:l,end:null});const[n,a]=j(l,ge)<0?[l,ge]:[ge,l];je(null),we(null),De({start:n,end:a}),T&&Ce(!1)},onPreviewChange:e=>{null!==ge&&we(e??ge)},minDate:W,maxDate:$,shouldDisableDate:_,showOutsideDays:!1,labels:ie};return e(u,{...ae,slug:"date-range-picker",size:re,color:se,readOnly:ee,disabled:le,triggerRef:te,startIcon:void 0===ne?e(t,{icon:s,size:v[re]}):ne,display:l("span",{className:"flex min-w-0 items-center gap-1.5",children:[l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(pe,J)}),e(h,{samples:y(Me,J)})]}),e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center rtl:rotate-180",children:e(t,{icon:r,size:v[re]})}),l("span",{className:"flex min-w-0 flex-col",children:[e("span",{className:"truncate",children:Oe(fe,K)}),e(h,{samples:y(Me,K)})]})]}),empty:null===pe&&null===fe,clearable:Q,onClear:()=>De(z),open:xe,onOpenChange:Ce,labels:ie,hiddenValues:X?[{name:X,value:pe?D(pe):""},{name:X,value:fe?D(fe):""}]:void 0,children:l("div",{className:"flex flex-col gap-1.5",children:[l("div",{className:"flex items-stretch gap-2",children:[L&&L.length>0?e("div",{className:"border-mp-outline-variant flex max-h-[calc(var(--_mp-cell,2.5rem)*8)] flex-col overflow-y-auto border-e pe-1.5",children:L.map((l,n)=>e(a,{variant:"text",size:i[re],color:se,className:"justify-start whitespace-nowrap",onClick:()=>(e=>{const l="function"==typeof e.value?e.value():e.value;je(null),we(null),De(l),w(l.start)&&Se(C(l.start)),T&&Ce(!1)})(l),children:l.label},n))}):null,e(o,{...Ie,month:Ne,onMonthChange:Se,showNextButton:!ze,autoFocus:!0}),ze?e(o,{...Ie,month:Pe,onMonthChange:e=>Se(g(e,-1)),showPreviousButton:!1}):null]}),Q||null!==Be?l(c,{children:[null!==Be?e("span",{className:`text-mp-on-surface-variant me-auto ${x}`,children:Be}):null,Q?e(a,{variant:"text",size:i[re],color:se,onClick:()=>{je(null),we(null),De(z),Ce(!1)},children:ie.clear}):null]}):null]})})});
@@ -113,6 +113,18 @@ export interface MPDrawerProps {
113
113
  * @default true
114
114
  */
115
115
  dismissible?: boolean;
116
+ /**
117
+ * Keeps a closed `modal` drawer's contents in the document, hidden, instead
118
+ * of taking them out of it.
119
+ *
120
+ * For a drawer that is a site's navigation on a narrow screen: closed, its
121
+ * links are otherwise not on the page at all, which is the page a crawler
122
+ * renders at a phone's width. A modal drawer is drawn into a portal, which no
123
+ * server renders, so the links arrive with hydration either way — a server
124
+ * should still send them somewhere in the page itself.
125
+ * @default false
126
+ */
127
+ keepMounted?: boolean;
116
128
  /**
117
129
  * How far the panel reaches in by default, and the type scale inside it.
118
130
  * `md` is MD3's own 360dp navigation drawer.
@@ -190,4 +202,4 @@ export declare const MPDrawerClose: React.ForwardRefExoticComponent<Omit<import(
190
202
  * `SLIDE` gives a reader who asked for less motion the old behaviour exactly:
191
203
  * the fade, with nowhere to travel from.
192
204
  */
193
- export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size: sizeProp, classNames, className, style, children }: MPDrawerProps): React.JSX.Element | null;
205
+ export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, keepMounted, size: sizeProp, classNames, className, style, children }: MPDrawerProps): React.JSX.Element | null;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as a from"react";import{Dialog as o}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as r}from"../../constants/icons.js";import{useMPLocale as i,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as x,SHEET_PAD_X as h,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as j,SCRIM as v,SHEET_MOTION as w}from"../../internal/surface.js";import{useMPSize as N}from"../../internal/config.js";const $={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},k={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},C={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},z={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},P={left:"motion-safe:data-starting-style:-translate-x-full motion-safe:data-ending-style:-translate-x-full",right:"motion-safe:data-starting-style:translate-x-full motion-safe:data-ending-style:translate-x-full",top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},B=`transition-[opacity,translate] ${w}`,D="border-mp-outline-variant border-t";export const MPDrawerClose=o.Close;export function MPDrawer({side:w="left",mode:O="modal",open:M,defaultOpen:L,onOpenChange:S,trigger:T,title:F,description:I,actions:R,dividers:V=!1,showClose:q,closeLabel:A,locale:E,extent:G,rounded:H=!0,dismissible:J=!0,size:K,classNames:Q,className:U,style:W,children:X}){const Y=N(K),Z=i(E),_=s(d,Z),ee="modal"===O,te="left"===w||"right"===w,le=q??ee,ae=A??_.close,[oe,ne]=a.useState(L??!0),re=M??oe,ie=h[Y],se=g[Y],de=V?`${ie} ${se}`:ie,me=c(F)||c(I),fe=c(R),ce=void 0===G?null:{[te?"width":"height"]:f(G)},pe=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",ee?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",u[Y],C[w],H?k[w]:"",ee?`${B} ${P[w]}`:"",te?`h-full max-w-full ${void 0===G?$[Y]:""}`:"w-full "+(void 0===G?"max-h-[85%]":""),V?"":`${se} ${x[Y]}`,U??""].filter(Boolean).join(" "),ue=ee?o.Title:"h2",xe=ee?o.Description:"p",he=/*@__PURE__*/["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),ge=t(l,{children:[me||le?t("div",{className:`flex shrink-0 items-start gap-3 ${de}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(F)?e(ue,{className:`m-0 ${b[Y]}`,children:F}):null,c(I)?e(xe,{className:`text-mp-on-surface-variant m-0 ${p}`,children:I}):null]}),le?ee?t(o.Close,{"aria-label":ae,className:he,children:[e(m,{}),e(n,{icon:r,size:20})]}):t("button",{type:"button","aria-label":ae,className:he,onClick:()=>{void 0===M&&ne(!1),S?.(!1)},children:[e(m,{}),e(n,{icon:r,size:20})]}):null]}):null,c(X)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",de,V&&(me||le)?D:"",V?"":"-my-1 py-1"].filter(Boolean).join(" "),children:X}):null,fe?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",de,V?D:""].filter(Boolean).join(" "),children:R}):null]});return ee?t(o.Root,{open:M,defaultOpen:L,disablePointerDismissal:!J,onOpenChange:(e,t)=>{J||e||"escape-key"!==t.reason?S?.(e):t.cancel()},children:[T?e(o.Trigger,{render:T}):null,t(o.Portal,{children:[e(o.Backdrop,{className:[`${j} fixed inset-0`,y,v,Q?.backdrop??""].filter(Boolean).join(" ")}),e(o.Viewport,{className:`${j} fixed inset-0 flex ${z[w]}`,children:e(o.Popup,{"data-mp-size":Y,"data-mp-side":w,"data-mp-mode":O,className:pe,style:{...ce,...W},children:ge})})]})]}):re?e("div",{"data-mp-size":Y,"data-mp-side":w,"data-mp-mode":O,className:pe,style:{...ce,...W},children:ge}):null}
2
+ import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as o from"react";import{Dialog as a}from"@base-ui/react/dialog";import{MPIcon as n}from"../icon/MPIcon.js";import{CloseIcon as i}from"../../constants/icons.js";import{useMPLocale as r,useMPMessages as s}from"../../internal/locale.js";import{COMMON as d}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{cssLength as f}from"../../internal/length.js";import{hasContent as c,META_TEXT as p,PROSE_TEXT as u,SHEET_GAP as h,SHEET_PAD_X as x,SHEET_PAD_Y as g,SHEET_TITLE as b}from"../../internal/scale.js";import{FADE as y,PORTAL_LAYER as j,SCRIM as v,SHEET_MOTION as w}from"../../internal/surface.js";import{useMPSize as N}from"../../internal/config.js";const $={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},k={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},C={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},z={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},P={left:"motion-safe:data-starting-style:-translate-x-full motion-safe:data-ending-style:-translate-x-full",right:"motion-safe:data-starting-style:translate-x-full motion-safe:data-ending-style:translate-x-full",top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},B=`transition-[opacity,translate] ${w}`,M="border-mp-outline-variant border-t";export const MPDrawerClose=a.Close;export function MPDrawer({side:w="left",mode:D="modal",open:O,defaultOpen:L,onOpenChange:S,trigger:T,title:F,description:I,actions:R,dividers:V=!1,showClose:q,closeLabel:A,locale:E,extent:G,rounded:H=!0,dismissible:J=!0,keepMounted:K=!1,size:Q,classNames:U,className:W,style:X,children:Y}){const Z=N(Q),_=r(E),ee=s(d,_),te="modal"===D,le="left"===w||"right"===w,oe=q??te,ae=A??ee.close,[ne,ie]=o.useState(L??!0),re=O??ne,se=x[Z],de=g[Z],me=V?`${se} ${de}`:se,fe=c(F)||c(I),ce=c(R),pe=void 0===G?null:{[le?"width":"height"]:f(G)},ue=["mp-drawer relative flex flex-col overflow-hidden box-border","[&[hidden]]:hidden","border-mp-outline-variant outline-none",te?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",u[Z],C[w],H?k[w]:"",te?`${B} ${P[w]}`:"",le?`h-full max-w-full ${void 0===G?$[Z]:""}`:"w-full "+(void 0===G?"max-h-[85%]":""),V?"":`${de} ${h[Z]}`,W??""].filter(Boolean).join(" "),he=te?a.Title:"h2",xe=te?a.Description:"p",ge=/*@__PURE__*/["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),be=t(l,{children:[fe||oe?t("div",{className:`flex shrink-0 items-start gap-3 ${me}`,children:[t("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(F)?e(he,{className:`m-0 ${b[Z]}`,children:F}):null,c(I)?e(xe,{className:`text-mp-on-surface-variant m-0 ${p}`,children:I}):null]}),oe?te?t(a.Close,{"aria-label":ae,className:ge,children:[e(m,{}),e(n,{icon:i,size:20})]}):t("button",{type:"button","aria-label":ae,className:ge,onClick:()=>{void 0===O&&ie(!1),S?.(!1)},children:[e(m,{}),e(n,{icon:i,size:20})]}):null]}):null,c(Y)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",me,V&&(fe||oe)?M:"",V?"":"-my-1 py-1"].filter(Boolean).join(" "),children:Y}):null,ce?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",me,V?M:""].filter(Boolean).join(" "),children:R}):null]});return te?t(a.Root,{open:O,defaultOpen:L,disablePointerDismissal:!J,onOpenChange:(e,t)=>{J||e||"escape-key"!==t.reason?S?.(e):t.cancel()},children:[T?e(a.Trigger,{render:T}):null,t(a.Portal,{keepMounted:K,children:[e(a.Backdrop,{className:[`${j} fixed inset-0`,y,v,U?.backdrop??""].filter(Boolean).join(" ")}),e(a.Viewport,{className:`${j} fixed inset-0 flex [&[hidden]]:hidden ${z[w]}`,children:e(a.Popup,{"data-mp-size":Z,"data-mp-side":w,"data-mp-mode":D,className:ue,style:{...pe,...X},children:be})})]})]}):re?e("div",{"data-mp-size":Z,"data-mp-side":w,"data-mp-mode":D,className:ue,style:{...pe,...X},children:be}):null}
@@ -52,7 +52,7 @@ export interface MPEmptyProps extends Omit<React.ComponentPropsWithoutRef<'div'>
52
52
  * `transition="fade"` is the whole of what most callers want; the object form
53
53
  * takes a duration, an edge to come from, or a scale to start at. Anything
54
54
  * that has to run again — on scroll, on hover, under your own control — is an
55
- * [MPAnimateFade](../motion/animate-fade) and its siblings.
55
+ * [MPAnimateFade](../transitions/animate-fade) and its siblings.
56
56
  */
57
57
  transition?: MPTransition;
58
58
  }
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as o}from"../../internal/i18n.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as m}from"../../internal/messages/file-picker.js";import{MPStateLayer as p}from"../../internal/StateLayer.js";import{CONTROL_ICON as u,META_TEXT as d,PROSE_TEXT as f,STACK_GAP as h,hasContent as x}from"../../internal/scale.js";import{useMPSize as b}from"../../internal/config.js";const v={xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"};export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function g(e){return`${e.name}-${e.size}-${e.lastModified}`}const j=new Set;function y(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(e.slice(0,-1)):t===e)}export const MPFilePicker=/*@__PURE__*/n.forwardRef(function({accept:N,multiple:k=!1,maxSize:w,maxFiles:z,value:B,defaultValue:C,onFilesChange:I,onReject:S,label:$,description:D,errorMessage:F,title:L,hint:M,icon:T,showList:W=!0,removeLabel:_,locale:P,size:R,fullWidth:E=!0,required:O=!1,disabled:q=!1,readOnly:A=!1,name:V,id:G,className:H,style:Y},J){const K=b(R),Q=l(P),U=s(c,Q),X=s(m,Q),Z=n.useRef(null);n.useImperativeHandle(J,()=>Z.current,[]);const[ee,re]=n.useState(()=>[...C??[]]),ne=B?[...B]:ee,te=n.useRef(0),[ae,ie]=n.useState(!1),oe=x(F),le=q||A,se=n.useId(),ce=n.useId(),me=n.useCallback(e=>{B||re(e),I?.(e)},[I,B]),pe=n.useCallback(e=>{const r=[],n=[],t=k?z??Number.POSITIVE_INFINITY:1,a=k?ne.length:0;for(const i of e)N&&!y(i,N)?n.push({file:i,reason:"type"}):void 0!==w&&i.size>w?n.push({file:i,reason:"size"}):a+r.length>=t?n.push({file:i,reason:"count"}):r.push(i);return{kept:r,rejections:n}},[N,ne.length,z,w,k]),[ue,de]=n.useState(j),fe=n.useCallback(e=>{const{kept:r,rejections:n}=pe(e);n.length>0&&S?.(n),r.length>0&&(de(new Set(r.map(g))),me(k?[...ne,...r]:r))},[pe,me,ne,k,S]);return r("div",{className:["mp-file-picker flex-col align-top",h[K],E?"flex w-full":"inline-flex",H??""].filter(Boolean).join(" "),style:Y,"data-mp-size":K,"data-disabled":q||void 0,"data-invalid":oe||void 0,children:[x($)?r("span",{id:ce,className:[d,q?"text-mp-on-surface/38":oe?"text-mp-error":"text-mp-on-surface-variant"].join(" "),children:[$,O?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,r("div",{className:"relative flex w-full flex-col",onDragEnter:e=>{le||(e.preventDefault(),te.current+=1,ie(!0))},onDragOver:e=>{le||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{le||(te.current=Math.max(0,te.current-1),0===te.current&&ie(!1))},onDrop:e=>{le||(e.preventDefault(),te.current=0,ie(!1),fe(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:G,disabled:q,"aria-describedby":x(D)||oe?se:void 0,"aria-invalid":oe||void 0,className:["mp-file-picker__zone group relative flex w-full flex-col items-center","justify-center gap-2 text-center","rounded-mp-md box-border border-2 border-dashed","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color,background-color] duration-(--mp-sys-motion-duration-short4)",v[K],f[K],q?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":[A?"cursor-default":"cursor-pointer",oe?"border-mp-error":"border-mp-outline-variant","text-mp-on-surface",ae?"border-mp-primary bg-mp-primary/8":""].filter(Boolean).join(" ")].filter(Boolean).join(" "),onClick:()=>{!le&&Z.current&&(Z.current.value="",Z.current.click())},children:[le?null:e(p,{layer:"inset-0 rounded-[inherit] bg-mp-primary"}),void 0===T?e(t,{icon:i,size:1.6*u[K],className:q?"":"text-mp-primary"}):x(T)?e("span",{className:q?"":"text-mp-primary",children:T}):null,e("span",{className:"font-medium",children:L??X.prompt}),x(M)?e("span",{className:[d,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null]}),e("input",{ref:Z,type:"file",name:V,accept:N,multiple:k,required:O&&0===ne.length,disabled:le,tabIndex:-1,"aria-labelledby":x($)?ce:void 0,"aria-describedby":x(D)||oe?se:void 0,className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>fe(Array.from(e.target.files??[]))})]}),W&&ne.length>0?e("ul",{className:["mp-file-picker__list m-0 flex w-full list-none flex-col p-0",h[K]].join(" "),children:ne.map((n,i)=>r("li",{className:["rounded-mp-xs bg-mp-surface-container-low flex w-full items-center gap-3","px-3 py-2",f[K],q?"text-mp-on-surface/38":"text-mp-on-surface",ue.has(g(n))?"mp-row-arrive":""].filter(Boolean).join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:[d,"shrink-0 tabular-nums",q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:formatFileSize(n.size)}),le?null:r("button",{type:"button","aria-label":_?_(n.name):o(U.removeNamed,{label:n.name}),className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","cursor-pointer appearance-none items-center justify-center rounded-full","bg-transparent p-0 font-[inherit] outline-none"].join(" "),onClick:()=>me(ne.filter((e,r)=>r!==i)),children:[e(p,{}),e(t,{icon:a,size:18})]})]},`${g(n)}-${i}`))}):null,oe?e("span",{id:se,className:[d,"text-mp-error"].join(" "),children:F}):x(D)?e("span",{id:se,className:[d,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:D}):null]})});
2
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as n from"react";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as a,UploadIcon as i}from"../../constants/icons.js";import{fillMessage as o}from"../../internal/i18n.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FILE_PICKER as u}from"../../internal/messages/file-picker.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{CONTROL_ICON as p,META_TEXT as f,PROSE_TEXT as d,STACK_GAP as h,hasContent as x}from"../../internal/scale.js";import{useMPSize as b}from"../../internal/config.js";const v={xs:"p-4",sm:"p-5",md:"p-6",lg:"p-8",xl:"p-10"};export function formatFileSize(e){if(e<1e3)return`${e} B`;const r=["kB","MB","GB","TB"];let n=e/1e3,t=0;for(;n>=1e3&&t<r.length-1;)n/=1e3,t+=1;return`${n<10?n.toFixed(1):Math.round(n)} ${r[t]}`}function g(e){return`${e.name}-${e.size}-${e.lastModified}`}const j=new Set;function y(e,r){const n=e.name.toLowerCase(),t=e.type.toLowerCase();return r.split(",").map(e=>e.trim().toLowerCase()).filter(Boolean).some(e=>e.startsWith(".")?n.endsWith(e):e.endsWith("/*")?t.startsWith(e.slice(0,-1)):t===e)}export const MPFilePicker=/*@__PURE__*/n.forwardRef(function({accept:N,multiple:k=!1,maxSize:w,maxFiles:z,value:C,defaultValue:B,onFilesChange:I,onReject:S,label:D,description:L,errorMessage:$,title:E,hint:F,icon:M,showList:T=!0,removeLabel:R,locale:W,size:_,fullWidth:P=!0,required:O=!1,disabled:q=!1,readOnly:A=!1,name:V,id:G,className:H,style:Y},J){const K=b(_),Q=l(W),U=s(c,Q),X=s(u,Q),Z=n.useRef(null);n.useImperativeHandle(J,()=>Z.current,[]);const[ee,re]=n.useState(()=>[...B??[]]),ne=C?[...C]:ee,te=n.useRef(0),[ae,ie]=n.useState(!1),oe=x($),le=q||A,se=n.useId(),ce=n.useId(),ue=n.useRef([]),me=n.useCallback(e=>{const r=Z.current;if(!r||"undefined"==typeof DataTransfer)return;const n=new DataTransfer;for(const r of e)n.items.add(r);r.files=n.files,ue.current=e},[]);n.useEffect(()=>{ue.current.length===ne.length&&ue.current.every((e,r)=>e===ne[r])||me(ne)}),n.useEffect(()=>{const e=Z.current;if(!e)return;const r=()=>me(ue.current);return e.addEventListener("cancel",r),()=>e.removeEventListener("cancel",r)},[me]);const pe=n.useCallback(e=>{C||re(e),I?.(e)},[I,C]),fe=n.useCallback(e=>{const r=[],n=[],t=k?z??Number.POSITIVE_INFINITY:1,a=k?ne.length:0;for(const i of e)N&&!y(i,N)?n.push({file:i,reason:"type"}):void 0!==w&&i.size>w?n.push({file:i,reason:"size"}):a+r.length>=t?n.push({file:i,reason:"count"}):r.push(i);return{kept:r,rejections:n}},[N,ne.length,z,w,k]),[de,he]=n.useState(j),xe=n.useCallback(e=>{const{kept:r,rejections:n}=fe(e);n.length>0&&S?.(n),r.length>0&&(he(new Set(r.map(g))),pe(k?[...ne,...r]:r))},[fe,pe,ne,k,S]);return r("div",{className:["mp-file-picker flex-col align-top",h[K],P?"flex w-full":"inline-flex",H??""].filter(Boolean).join(" "),style:Y,"data-mp-size":K,"data-disabled":q||void 0,"data-invalid":oe||void 0,children:[x(D)?r("span",{id:ce,className:[f,q?"text-mp-on-surface/38":oe?"text-mp-error":"text-mp-on-surface-variant"].join(" "),children:[D,O?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,r("div",{className:"relative flex w-full flex-col",onDragEnter:e=>{le||(e.preventDefault(),te.current+=1,ie(!0))},onDragOver:e=>{le||(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDragLeave:()=>{le||(te.current=Math.max(0,te.current-1),0===te.current&&ie(!1))},onDrop:e=>{le||(e.preventDefault(),te.current=0,ie(!1),xe(Array.from(e.dataTransfer.files)))},children:[r("button",{type:"button",id:G,disabled:q,"aria-describedby":x(L)||oe?se:void 0,"aria-invalid":oe||void 0,className:["mp-file-picker__zone group relative flex w-full flex-col items-center","justify-center gap-2 text-center","rounded-mp-md box-border border-2 border-dashed","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color,background-color] duration-(--mp-sys-motion-duration-short4)",v[K],d[K],q?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":[A?"cursor-default":"cursor-pointer",oe?"border-mp-error":"border-mp-outline-variant","text-mp-on-surface",ae?"border-mp-primary bg-mp-primary/8":""].filter(Boolean).join(" ")].filter(Boolean).join(" "),onClick:()=>{!le&&Z.current&&(Z.current.value="",Z.current.click())},children:[le?null:e(m,{layer:"inset-0 rounded-[inherit] bg-mp-primary"}),void 0===M?e(t,{icon:i,size:1.6*p[K],className:q?"":"text-mp-primary"}):x(M)?e("span",{className:q?"":"text-mp-primary",children:M}):null,e("span",{className:"font-medium",children:E??X.prompt}),x(F)?e("span",{className:[f,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:F}):null]}),e("input",{ref:Z,type:"file",name:V,accept:N,multiple:k,required:O&&0===ne.length,disabled:le,tabIndex:-1,"aria-labelledby":x(D)?ce:void 0,"aria-describedby":x(L)||oe?se:void 0,className:"absolute size-px overflow-hidden opacity-0 [clip-path:inset(50%)]",onChange:e=>xe(Array.from(e.target.files??[]))})]}),T&&ne.length>0?e("ul",{className:["mp-file-picker__list m-0 flex w-full list-none flex-col p-0",h[K]].join(" "),children:ne.map((n,i)=>r("li",{className:["rounded-mp-xs bg-mp-surface-container-low flex w-full items-center gap-3","px-3 py-2",d[K],q?"text-mp-on-surface/38":"text-mp-on-surface",de.has(g(n))?"mp-row-arrive":""].filter(Boolean).join(" "),children:[e("span",{className:"min-w-0 flex-1 truncate",children:n.name}),e("span",{className:[f,"shrink-0 tabular-nums",q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:formatFileSize(n.size)}),le?null:r("button",{type:"button","aria-label":R?R(n.name):o(U.removeNamed,{label:n.name}),className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","cursor-pointer appearance-none items-center justify-center rounded-full","bg-transparent p-0 font-[inherit] outline-none"].join(" "),onClick:()=>pe(ne.filter((e,r)=>r!==i)),children:[e(m,{}),e(t,{icon:a,size:18})]})]},`${g(n)}-${i}`))}):null,oe?e("span",{id:se,className:[f,"text-mp-error"].join(" "),children:$}):x(L)?e("span",{id:se,className:[f,q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:L}):null]})});
@@ -33,6 +33,9 @@ export interface MPFormProps extends Omit<React.ComponentPropsWithoutRef<'form'>
33
33
  /**
34
34
  * Called on a valid submit, with the form's values. The native submit event is
35
35
  * prevented, so nothing navigates.
36
+ *
37
+ * Leave it out and give the form an `action` — a URL, or a React server
38
+ * action — and a valid submit goes to the action instead.
36
39
  */
37
40
  onSubmit?: (values: Record<string, unknown>) => void;
38
41
  /**
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r}from"react/jsx-runtime";import*as o from"react";import{Form as e}from"@base-ui/react/form";import{useMPSize as i}from"../../internal/config.js";import{SHEET_GAP as t}from"../../internal/scale.js";export const MPForm=/*@__PURE__*/o.forwardRef(function({validationMode:o="onSubmit",errors:m,onSubmit:a,size:n,className:s,children:f,...l},c){const d=i(n);return r(e,{ref:c,validationMode:o,errors:m,onFormSubmit:r=>a?.(r),"data-mp-size":d,className:["mp-form flex flex-col",t[d],s??""].filter(Boolean).join(" "),...l,children:f})});
2
+ import{jsx as o}from"react/jsx-runtime";import*as r from"react";import{Form as i}from"@base-ui/react/form";import{useMPSize as e}from"../../internal/config.js";import{SHEET_GAP as t}from"../../internal/scale.js";export const MPForm=/*@__PURE__*/r.forwardRef(function({validationMode:r="onSubmit",errors:a,onSubmit:m,size:n,className:s,children:f,...c},l){const d=e(n);return o(i,{ref:l,validationMode:r,errors:a,onFormSubmit:m||void 0===c.action?o=>m?.(o):void 0,"data-mp-size":d,className:["mp-form flex flex-col",t[d],s??""].filter(Boolean).join(" "),...c,children:f})});
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Meter as l}from"@base-ui/react/meter";import{useMPElementSize as r}from"../../hooks/useMPElementSize.js";import{useMPColor as o,useMPSize as m}from"../../internal/config.js";import{useMPLocale as i}from"../../internal/locale.js";import{accentSlots as s}from"../../internal/accent.js";import{thresholdColor as n}from"../../internal/threshold.js";import{progressFraction as c}from"../../internal/progress.js";import{CHART_FONT_SIZE as h,PLOT_HEIGHT as p,arcPath as f,formatStatistic as u}from"../../internal/chart.js";import{cssLength as d}from"../../internal/length.js";import{META_TEXT as x}from"../../internal/scale.js";const g={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-display-small"};export function MPGaugeChart({value:v,min:j=0,max:M=100,sweep:_=240,label:b,thresholds:y,bands:w=!1,color:N,format:P,locale:$,height:z,size:I,className:k,style:B,...R}){const C=m(I),E=o(N),G=i($),L=a.useRef(null),S=r(L),V=c(v,j,M)??0,W=n(v,E,y),q=h[C],A=S.width,D="number"==typeof z?z:void 0===z?p[C]:S.height,F=Math.min(300,Math.max(30,_))*Math.PI/180,H=F/2,J=H>Math.PI/2?Math.cos(Math.PI-H):0,K=Math.min(A/2,D/(1+J)),O=Math.max(0,K-2),Q=.78*O,T=A/2,U=O+2,X=-H,Y=H,Z=X+V*F,ee=a.useMemo(()=>{if(!w||!y||0===y.length)return[{from:0,to:1,color:E}];const e=[...y.map(e=>({at:c(e.from,j,M)??0,color:e.color})).filter(e=>e.at>0&&e.at<1).sort((e,t)=>e.at-t.at)],t=[];let a=0,l=E;for(const r of e)t.push({from:a,to:r.at,color:l}),a=r.at,l=r.color;return t.push({from:a,to:1,color:l}),t},[w,y,E,j,M]),te=u(v,G,P,!1);return t(l.Root,{value:v,min:j,max:M,format:P,"data-mp-size":C,className:["mp-gauge-chart flex min-w-0 flex-col items-center",k??""].filter(Boolean).join(" "),style:{...s(W),...B},...R,children:[t("div",{ref:L,className:"mp-gauge-chart__dial relative w-full",style:{height:d(z)??p[C]},children:[A>0&&O>0?t("svg",{width:A,height:D,viewBox:`0 0 ${A} ${D}`,"aria-hidden":"true",className:"block overflow-visible",children:[ee.map((t,a)=>e("path",{d:f(T,U,O,Q,X+t.from*F,X+t.to*F),fill:w?`var(--_mp-color-${t.color})`:"var(--_mp-color-on-surface)",opacity:w?.22:.12},a)),e("path",{d:f(T,U,O,Q,X,Z),fill:"var(--_mp-accent)"}),e("path",{d:f(T,U,O,Q,X,X+.004*F),fill:"var(--_mp-color-outline)"}),e("path",{d:f(T,U,O,Q,Y-.004*F,Y),fill:"var(--_mp-color-outline)"})]}):null,t("div",{className:"pointer-events-none absolute inset-x-0 flex flex-col items-center",style:{top:U-.45*Q},children:[e(l.Value,{className:`mp-gauge-chart__value text-mp-on-surface font-medium tabular-nums ${g[C]}`,children:e=>P?e:te}),b?e(l.Label,{className:`mp-gauge-chart__label text-mp-on-surface-variant ${x}`,style:{maxWidth:1.8*Q},children:b}):null]})]}),J>0?e("span",{"aria-hidden":"true",style:{height:q/2}}):null]})}
2
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Meter as l}from"@base-ui/react/meter";import{useBoxSize as r}from"../../internal/box-size.js";import{useMPColor as o,useMPSize as i}from"../../internal/config.js";import{useMPLocale as m}from"../../internal/locale.js";import{intlLocale as s}from"../../internal/intl.js";import{accentSlots as n}from"../../internal/accent.js";import{thresholdColor as c}from"../../internal/threshold.js";import{progressFraction as h}from"../../internal/progress.js";import{CHART_FONT_SIZE as p,PLOT_HEIGHT as f,arcPath as u,formatStatistic as d}from"../../internal/chart.js";import{cssLength as x}from"../../internal/length.js";import{META_TEXT as g}from"../../internal/scale.js";const v={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-display-small"};export function MPGaugeChart({value:j,min:b=0,max:_=100,sweep:M=240,label:y,thresholds:w,bands:N=!1,color:$,format:P,locale:z,height:I,size:B,className:R,style:k,...C}){const G=i(B),L=o($),V=m(z),W=a.useRef(null),q=r(W),A=h(j,b,_)??0,D=c(j,L,w),E=p[G],F=q.width,H="number"==typeof I?I:void 0===I?f[G]:q.height,J=Math.min(300,Math.max(30,M))*Math.PI/180,K=J/2,O=K>Math.PI/2?Math.cos(Math.PI-K):0,Q=F>0?Math.min(F/2,H/(1+O)):H/(1+O),S=Math.max(0,Q-2),T=.78*S,U=F/2,X=S+2,Y=-K,Z=K,tt=Y+A*J,et=a.useMemo(()=>{if(!N||!w||0===w.length)return[{from:0,to:1,color:L}];const t=[...w.map(t=>({at:h(t.from,b,_)??0,color:t.color})).filter(t=>t.at>0&&t.at<1).sort((t,e)=>t.at-e.at)],e=[];let a=0,l=L;for(const r of t)e.push({from:a,to:r.at,color:l}),a=r.at,l=r.color;return e.push({from:a,to:1,color:l}),e},[N,w,L,b,_]),at=d(j,V,P,!1);return e(l.Root,{value:j,min:b,max:_,format:P,locale:s(V),"data-mp-size":G,className:["mp-gauge-chart flex min-w-0 flex-col items-center",R??""].filter(Boolean).join(" "),style:{...n(D),...k},...C,children:[e("div",{ref:W,className:"mp-gauge-chart__dial relative w-full",style:{height:x(I)??f[G]},children:[F>0&&S>0?e("svg",{width:F,height:H,viewBox:`0 0 ${F} ${H}`,"aria-hidden":"true",className:"block overflow-visible",children:[et.map((e,a)=>t("path",{d:u(U,X,S,T,Y+e.from*J,Y+e.to*J),fill:N?`var(--_mp-color-${e.color})`:"var(--_mp-color-on-surface)",opacity:N?.22:.12},a)),t("path",{d:u(U,X,S,T,Y,tt),fill:"var(--_mp-accent)"}),t("path",{d:u(U,X,S,T,Y,Y+.004*J),fill:"var(--_mp-color-outline)"}),t("path",{d:u(U,X,S,T,Z-.004*J,Z),fill:"var(--_mp-color-outline)"})]}):null,e("div",{className:"pointer-events-none absolute inset-x-0 flex flex-col items-center",style:{top:X-.45*T},children:[t(l.Value,{className:`mp-gauge-chart__value text-mp-on-surface font-medium tabular-nums ${v[G]}`,children:t=>P?t:at}),y?t(l.Label,{className:`mp-gauge-chart__label text-mp-on-surface-variant ${g}`,style:{maxWidth:1.8*T},children:y}):null]})]}),O>0?t("span",{"aria-hidden":"true",style:{height:E/2}}):null]})}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as i from"react";import{useRender as n}from"@base-ui/react/use-render";import{barSurface as r,MPPageLayoutContext as a}from"../../internal/page-layout.js";import{hasContent as s}from"../../internal/scale.js";import{sheetPadX as l}from"../../internal/density.js";import{measureValue as m}from"../../internal/measure.js";import{useWindowMins as o}from"../../internal/window-class.js";import{responsiveSlots as d,withBaseline as c}from"../../internal/responsive.js";import{useMPDensity as p,useMPSize as f}from"../../internal/config.js";const x={xs:"min-h-12",sm:"min-h-14",md:"min-h-16",lg:"min-h-20",xl:"min-h-24"},u={xs:"text-mp-title-small",sm:"text-mp-title-medium",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},h={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-4",xl:"gap-5"},g={xs:"gap-3",sm:"gap-4",md:"gap-6",lg:"gap-8",xl:"gap-10"},j={static:"",absolute:"absolute inset-x-0 top-0 z-30",sticky:"sticky top-0 z-30",fixed:"fixed inset-x-0 top-0 z-40"},b={start:"shrink-0",center:"flex-1 basis-0",end:"shrink-0"},v={start:"flex min-w-0 flex-1 items-center justify-start",center:"flex min-w-0 shrink items-center justify-center",end:"flex min-w-0 flex-1 items-center justify-end"};export const MPHeader=/*@__PURE__*/i.forwardRef(function({brand:y,actions:w,align:N="start",position:k="sticky",variant:_="tonal",elevation:z,size:B,density:C,maxWidth:$="none",padded:H=!0,label:M,render:P,className:R,children:W,...q},A){const D=f(B),E=p(C),F=o(),{register:G}=i.useContext(a),I=i.useCallback(e=>{G("header",e),"function"==typeof A?A(e):A&&(A.current=e)},[G,A]);return n({render:P??e("header",{}),ref:I,props:{"aria-label":M,"data-mp-size":D,"data-mp-variant":_,className:["mp-header text-mp-on-surface box-border w-full min-w-0",r(_,z),"outlined"===_?"border-mp-outline-variant border-b":"",j[k],R??""].filter(Boolean).join(" "),children:t("div",{className:["flex w-full items-center",x[D],g[D],H?l(D,E):"","none"===$?"":"mp-measure mx-auto"].filter(Boolean).join(" "),style:"none"===$?void 0:d("measure",c($,"none"),e=>m(e,F)),children:[s(y)?e("div",{className:["mp-header__brand flex min-w-0 items-center",b[N],h[D],u[D]].join(" "),children:y}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null,s(W)?e("div",{className:`mp-header__middle ${v[N]} ${h[D]}`,children:W}):null,s(w)?e("div",{className:["mp-header__actions flex min-w-0 items-center justify-end",b[N],h[D]].join(" "),children:w}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null]}),...q}})});
2
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as i from"react";import{useRender as n}from"@base-ui/react/use-render";import{barSurface as a,MPPageLayoutContext as r}from"../../internal/page-layout.js";import{hasContent as s}from"../../internal/scale.js";import{sheetPadX as m}from"../../internal/density.js";import{measureValue as l}from"../../internal/measure.js";import{useWindowMins as o}from"../../internal/window-class.js";import{responsiveSlots as d,withBaseline as p}from"../../internal/responsive.js";import{useMPDensity as c,useMPSize as f}from"../../internal/config.js";const x={xs:"min-h-12",sm:"min-h-14",md:"min-h-16",lg:"min-h-20",xl:"min-h-24"},u={xs:"text-mp-title-small",sm:"text-mp-title-medium",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},h={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-4",xl:"gap-5"},g={xs:"gap-3",sm:"gap-4",md:"gap-6",lg:"gap-8",xl:"gap-10"},j={static:"",absolute:"absolute inset-x-0 top-0 z-30",sticky:"sticky top-0 z-30",fixed:"fixed inset-x-0 top-0 z-40"},b={start:"shrink-0",center:"flex-1 basis-0",end:"shrink-0"},v={start:"flex min-w-0 flex-1 items-center justify-start",center:"flex min-w-0 shrink items-center justify-center",end:"flex min-w-0 flex-1 items-center justify-end"};export const MPHeader=/*@__PURE__*/i.forwardRef(function({brand:y,actions:w,align:N="start",position:k="sticky",variant:_="tonal",elevation:z,size:B,density:C,maxWidth:$="none",padded:H=!0,label:M,render:P,className:R,children:W,...q},A){const D=f(B),E=c(C),F=o(),{register:G}=i.useContext(r),I=i.useCallback(e=>{G("header",e),"function"==typeof A?A(e):A&&(A.current=e)},[G,A]);return n({render:P??e("header",{}),ref:I,props:{"aria-label":M,"data-mp-size":D,"data-mp-variant":_,"data-mp-position":k,className:["mp-header text-mp-on-surface box-border w-full min-w-0",a(_,z),"outlined"===_?"border-mp-outline-variant border-b":"",j[k],R??""].filter(Boolean).join(" "),children:t("div",{className:["flex w-full items-center",x[D],g[D],H?m(D,E):"","none"===$?"":"mp-measure mx-auto"].filter(Boolean).join(" "),style:"none"===$?void 0:d("measure",p($,"none"),e=>l(e,F)),children:[s(y)?e("div",{className:["mp-header__brand flex min-w-0 items-center",b[N],h[D],u[D]].join(" "),children:y}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null,s(W)?e("div",{className:`mp-header__middle ${v[N]} ${h[D]}`,children:W}):null,s(w)?e("div",{className:["mp-header__actions flex min-w-0 items-center justify-end",b[N],h[D]].join(" "),children:w}):"center"===N?e("div",{"aria-hidden":"true",className:b[N]}):null]}),...q}})});
@@ -1,7 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { type ChartBaseProps } from '../../internal/ChartChrome.js';
3
3
  import type { MPChartAxis, MPChartCategory, MPChartSeries } from '../../types.js';
4
- export interface MPHeatmapChartProps extends ChartBaseProps {
4
+ /**
5
+ * No `labelColor`: every piece of text this chart writes sits **on** a ramp
6
+ * step, where the question is what reads against the fill underneath. There are
7
+ * no series here for an ink to name, either.
8
+ */
9
+ export interface MPHeatmapChartProps extends Omit<ChartBaseProps, 'labelColor'> {
5
10
  /**
6
11
  * The rows. Each series is one row and its `data` are that row's cells, in
7
12
  * the order `categories` names the columns.
@@ -9,9 +14,13 @@ export interface MPHeatmapChartProps extends ChartBaseProps {
9
14
  series: readonly MPChartSeries[];
10
15
  /** The column headings. */
11
16
  categories?: readonly MPChartCategory[];
12
- /** The column axis. Only `label`, `hidden` and `tickFormat` mean anything here. */
17
+ /**
18
+ * The column axis. Only `label`, `hidden`, `thickness`, `tickFormat` and
19
+ * `tickLabels` mean anything here — there is no scale to pin and no grid to
20
+ * cast when both axes are categorical.
21
+ */
13
22
  xAxis?: MPChartAxis;
14
- /** The row axis, same three. */
23
+ /** The row axis, minus `tickLabels`: a row already has a line of its own. */
15
24
  yAxis?: MPChartAxis;
16
25
  /**
17
26
  * Where the colour scale starts and ends. Taken from the data otherwise.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as t from"react";import{useMPElementSize as n}from"../../hooks/useMPElementSize.js";import{useMPLocale as a,useMPMessages as r}from"../../internal/locale.js";import{useMPSize as o}from"../../internal/config.js";import{CHART as i}from"../../internal/messages/chart.js";import{TABLE as m}from"../../internal/messages/table.js";import{ChartShell as s,ChartTable as c,ChartTooltipPanel as h}from"../../internal/ChartChrome.js";import{CHART_FONT_SIZE as u,MARK_GAP as d,PLOT_HEIGHT as f,RAMP_STEPS as p,formatCategory as x,formatStatistic as g,rampFill as v,rampInk as y,rampStep as w,textWidth as b,toValues as k,truncate as M}from"../../internal/chart.js";export function MPHeatmapChart({series:j,categories:A,xAxis:N,yAxis:S,min:$,max:_,valueLabels:z=!1,height:B,format:C,locale:P,label:D,legend:R,tooltip:L,empty:E,size:F,className:I,style:W,...H}){const K=o(F),U=a(P),X=r(i,U),Y=r(m,U),q=t.useRef(null),G=n(q),J=t.useId(),[O,Q]=t.useState(null),T=t.useMemo(()=>k(j),[j]),V=T.reduce((e,l)=>Math.max(e,l.length),0),Z=t.useCallback(e=>g(e,U,C,!0),[C,U]),ee=j.map((e,l)=>e.name??String(l+1)),le=Array.from({length:V},(e,l)=>N?.tickFormat?String(N.tickFormat(A?.[l]??l,l)):x(A?.[l]??l,U)),te=T.flat().filter(e=>null!==e.value),ne=$??(te.length>0?Math.min(...te.map(e=>e.value)):0),ae=_??(te.length>0?Math.max(...te.map(e=>e.value)):0),re=ae-ne||1,oe=u[K],ie=G.width,me="number"==typeof B?B:void 0===B?f[K]:G.height,se=ee.reduce((e,l)=>Math.max(e,b(l,oe)),0),ce=S?.hidden?0:S?.thickness??Math.min(140,se+10),he=N?.hidden?0:N?.thickness??oe+12,ue=ce,de=0,fe=Math.max(0,ie-ce),pe=Math.max(0,me-he),xe=V>0?fe/V:0,ge=T.length>0?pe/T.length:0,ve=(e,l)=>{Q(t=>{const n=t??{row:0,column:0};return{row:Math.min(T.length-1,Math.max(0,n.row+(t?e:0))),column:Math.min(V-1,Math.max(0,n.column+(t?l:0)))}})},ye=O?T[O.row]?.[O.column]??null:null,we=O&&ye&&null!==ye.value?[{seriesIndex:O.row,name:ee[O.row],color:v(w((ye.value-ne)/re)),value:ye.value,formatted:Z(ye.value),label:ye.label}]:[],be=!1===L?{mode:"none"}:!0===L||void 0===L?{}:L,ke=!1!==R&&te.length>0,Me=0===V||0===T.length||0===te.length,je=Array.from({length:V},(e,l)=>T.map(e=>e[l]??{value:null}));return e(s,{...H,size:K,className:["mp-heatmap-chart",I??""].filter(Boolean).join(" "),style:W,plotRef:q,name:D??X.label,describedBy:Me?void 0:J,interactive:!Me,height:B,legendSide:"bottom",plotProps:{onPointerMove:Me||"none"===be.mode?void 0:e=>Q(((e,l)=>{const t=q.current;if(!t||xe<=0||ge<=0)return null;const n=t.getBoundingClientRect(),a=Math.floor((e-n.left-ue)/xe),r=Math.floor((l-n.top-de)/ge);return a<0||a>=V||r<0||r>=T.length?null:{row:r,column:a}})(e.clientX,e.clientY)),onPointerLeave:()=>Q(null),onKeyDown:Me||"none"===be.mode?void 0:e=>{if("ArrowRight"===e.key)ve(0,1);else if("ArrowLeft"===e.key)ve(0,-1);else if("ArrowDown"===e.key)ve(1,0);else if("ArrowUp"===e.key)ve(-1,0);else{if("Escape"!==e.key)return;Q(null)}e.preventDefault()},onBlur:()=>Q(null)},tooltip:O&&we.length>0&&"none"!==be.mode?e(h,{heading:`${ee[O.row]} · ${le[O.column]}`,items:we,x:ue+(O.column+.5)*xe,y:de+(O.row+.5)*ge,flip:O.column>V/2,size:K}):null,legend:ke?l("div",{className:"mp-chart__legend flex items-center justify-center gap-2",children:[e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:Z(ne)}),e("span",{className:"flex","aria-hidden":"true",children:Array.from({length:p},(l,t)=>e("span",{className:"block h-3 w-6 first:rounded-s-mp-xs last:rounded-e-mp-xs",style:{background:v(t)}},t))}),e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:Z(ae)})]}):null,status:{heading:O?`${ee[O.row]} · ${le[O.column]}`:void 0,items:we},table:Me?null:e(c,{id:J,caption:D??X.table,corner:S?.label??X.category,categories:ee,names:le,values:je,format:Z,locale:U,empty:Y.empty}),children:Me?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:E??Y.empty}):ie>0&&me>0?l("svg",{width:ie,height:me,viewBox:`0 0 ${ie} ${me}`,"aria-hidden":"true",className:"block overflow-visible",children:[e("g",{className:"mp-heatmap-chart__cells",children:T.map((t,n)=>Array.from({length:V},(a,r)=>{const o=t[r],i=O?.row===n&&O?.column===r,m=ue+r*xe,s=de+n*ge,c=Math.max(0,xe-d),h=Math.max(0,ge-d);if(!o||null===o.value)return e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:"none",stroke:"var(--_mp-color-outline-variant)",strokeWidth:1,strokeDasharray:"2 2",rx:2},r);const u=w((o.value-ne)/re);return l("g",{children:[e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:o.color??v(u),rx:2,stroke:i?"var(--_mp-color-on-surface)":"none",strokeWidth:i?2:0}),z&&c>b(Z(o.value),oe)+8&&h>oe+4?e("text",{x:m+xe/2,y:s+ge/2,textAnchor:"middle",dominantBaseline:"central",fill:y(u),fontSize:oe,children:Z(o.value)}):null]},r)}))}),S?.hidden?null:ee.map((l,t)=>e("text",{x:ue-8,y:de+(t+.5)*ge,textAnchor:"end",dominantBaseline:"central",fill:"var(--_mp-color-on-surface-variant)",fontSize:oe,children:M(l,ce-10,oe)},`r${t}`)),N?.hidden?null:le.map((l,t)=>e("text",{x:ue+(t+.5)*xe,y:de+pe+oe+4,textAnchor:"middle",fill:"var(--_mp-color-on-surface-variant)",fontSize:oe,children:M(l,xe-2,oe)},`c${t}`))]}):null})}
2
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useBoxSize as n}from"../../internal/box-size.js";import{useMPLocale as a,useMPMessages as r}from"../../internal/locale.js";import{useMPSize as o}from"../../internal/config.js";import{CHART as i}from"../../internal/messages/chart.js";import{TABLE as m}from"../../internal/messages/table.js";import{ChartShell as s,ChartTable as c,ChartTooltipPanel as u}from"../../internal/ChartChrome.js";import{CHART_FONT_SIZE as h,MARK_GAP as d,PLOT_HEIGHT as f,RAMP_STEPS as p,bounds as x,formatCategory as v,formatStatistic as g,rampFill as y,rampInk as w,rampStep as b,textWidth as M,tickTurn as k,toValues as j,truncate as A,turnedBand as $,turnedRoom as N}from"../../internal/chart.js";export function MPHeatmapChart({series:B,categories:_,xAxis:z,yAxis:S,min:C,max:P,valueLabels:D=!1,height:L,format:R,locale:I,label:F,legend:W,tooltip:E,empty:H,size:K,className:U,style:X,...Y}){const q=o(K),G=a(I),J=r(i,G),O=r(m,G),Q=l.useRef(null),T=n(Q),V=l.useId(),[Z,ee]=l.useState(null),te=l.useMemo(()=>j(B),[B]),le=te.reduce((e,t)=>Math.max(e,t.length),0),ne=l.useCallback(e=>g(e,G,R,!0),[R,G]),ae=B.map((e,t)=>e.name??String(t+1)),re=Array.from({length:le},(e,t)=>z?.tickFormat?String(z.tickFormat(_?.[t]??t,t)):v(_?.[t]??t,G)),oe=te.flat().filter(e=>null!==e.value),ie=x(oe.map(e=>e.value)),me=C??ie?.min??0,se=P??ie?.max??0,ce=se-me||1,ue=h[q],he=T.width,de="number"==typeof L?L:void 0===L?f[q]:T.height,fe=ae.reduce((e,t)=>Math.max(e,M(t,ue)),0),pe=S?.hidden?0:S?.thickness??Math.min(140,fe+10),xe=Math.max(0,he-pe),ve=le>0?xe/le:0,ge=z?.hidden?0:k(z?.tickLabels??"auto",re,ue,ve),ye=Math.min(120,.5*de),we=re.map((e,t)=>A(e,ge>0?Math.min(N(ge,ye,ue),ge>=90?1/0:(pe+ve*(t+.5))/Math.cos(ge*Math.PI/180)):ve-2,ue)),be=we.reduce((e,t)=>Math.max(e,M(t,ue)),0),Me=z?.hidden?0:z?.thickness??(ge>0?8+$(ge,be,ue)+4:ue+12),ke=pe,je=0,Ae=Math.max(0,de-Me),$e=te.length>0?Ae/te.length:0,Ne=(e,t)=>{ee(l=>{const n=l??{row:0,column:0};return{row:Math.min(te.length-1,Math.max(0,n.row+(l?e:0))),column:Math.min(le-1,Math.max(0,n.column+(l?t:0)))}})},Be=Z?te[Z.row]?.[Z.column]??null:null,_e=Z&&Be&&null!==Be.value?[{seriesIndex:Z.row,name:ae[Z.row],color:y(b((Be.value-me)/ce)),value:Be.value,formatted:ne(Be.value),label:Be.label}]:[],ze=!1===E?{mode:"none"}:!0===E||void 0===E?{}:E,Se=!1!==W&&oe.length>0,Ce=0===le||0===te.length||0===oe.length,Pe=Array.from({length:le},(e,t)=>te.map(e=>e[t]??{value:null}));return e(s,{...Y,size:q,className:["mp-heatmap-chart",U??""].filter(Boolean).join(" "),style:X,plotRef:Q,name:F??J.label,describedBy:Ce?void 0:V,interactive:!Ce,height:L,legendSide:"bottom",plotProps:{onPointerMove:Ce||"none"===ze.mode?void 0:e=>{const t=((e,t)=>{const l=Q.current;if(!l||ve<=0||$e<=0)return null;const n=l.getBoundingClientRect(),a=Math.floor((e-n.left-ke)/ve),r=Math.floor((t-n.top-je)/$e);return a<0||a>=le||r<0||r>=te.length?null:{row:r,column:a}})(e.clientX,e.clientY);ee(e=>e&&t&&e.row===t.row&&e.column===t.column?e:t)},onPointerLeave:()=>ee(null),onKeyDown:Ce||"none"===ze.mode?void 0:e=>{if("ArrowRight"===e.key)Ne(0,1);else if("ArrowLeft"===e.key)Ne(0,-1);else if("ArrowDown"===e.key)Ne(1,0);else if("ArrowUp"===e.key)Ne(-1,0);else{if("Escape"!==e.key)return;ee(null)}e.preventDefault()},onBlur:()=>ee(null)},tooltip:Z&&_e.length>0&&"none"!==ze.mode?e(u,{heading:`${ae[Z.row]} · ${re[Z.column]}`,items:_e,x:ke+(Z.column+.5)*ve,y:je+(Z.row+.5)*$e,flip:Z.column>le/2,size:q}):null,legend:Se?t("div",{className:"mp-chart__legend flex items-center justify-center gap-2",children:[e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:ne(me)}),e("span",{className:"flex","aria-hidden":"true",children:Array.from({length:p},(t,l)=>e("span",{className:"block h-3 w-6 first:rounded-s-mp-xs last:rounded-e-mp-xs",style:{background:y(l)}},l))}),e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:ne(se)})]}):null,status:{heading:Z?`${ae[Z.row]} · ${re[Z.column]}`:void 0,items:_e},table:Ce?null:e(c,{id:V,caption:F??J.table,corner:S?.label??J.category,categories:ae,names:re,values:Pe,format:ne,locale:G,empty:O.empty}),children:Ce?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:H??O.empty}):he>0&&de>0?t("svg",{width:he,height:de,viewBox:`0 0 ${he} ${de}`,"aria-hidden":"true",className:"block overflow-visible",children:[e("g",{className:"mp-heatmap-chart__cells",children:te.map((l,n)=>Array.from({length:le},(a,r)=>{const o=l[r],i=Z?.row===n&&Z?.column===r,m=ke+r*ve,s=je+n*$e,c=Math.max(0,ve-d),u=Math.max(0,$e-d);if(!o||null===o.value)return e("rect",{x:m+d/2,y:s+d/2,width:c,height:u,fill:"none",stroke:"var(--_mp-color-outline-variant)",strokeWidth:1,strokeDasharray:"2 2",rx:2},r);const h=b((o.value-me)/ce);return t("g",{children:[e("rect",{x:m+d/2,y:s+d/2,width:c,height:u,fill:o.color??y(h),rx:2,stroke:i?"var(--_mp-color-on-surface)":"none",strokeWidth:i?2:0}),D&&c>M(ne(o.value),ue)+8&&u>ue+4?e("text",{x:m+ve/2,y:s+$e/2,textAnchor:"middle",dominantBaseline:"central",fill:w(h),fontSize:ue,children:ne(o.value)}):null]},r)}))}),S?.hidden?null:ae.map((t,l)=>e("text",{x:ke-8,y:je+(l+.5)*$e,textAnchor:"end",dominantBaseline:"central",fill:"var(--_mp-color-on-surface-variant)",fontSize:ue,children:A(t,pe-10,ue)},`r${l}`)),z?.hidden?null:we.map((t,l)=>{const n=ke+(l+.5)*ve,a=je+Ae;return e("text",{x:n,y:ge>0?a+8:a+ue+4,textAnchor:ge>0?"end":"middle",dominantBaseline:ge>0?"central":void 0,transform:ge>0?`rotate(${-ge} ${n} ${a+8})`:void 0,fill:"var(--_mp-color-on-surface-variant)",fontSize:ue,children:t},`c${l}`)})]}):null})}
@@ -180,6 +180,11 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
180
180
  * Sets `loading="eager"` and a high fetch priority. A `loading` or
181
181
  * `fetchPriority` of your own still wins. Give it to one picture per page: a
182
182
  * high priority on every picture raises none of them above the others.
183
+ *
184
+ * The picture is also drawn as soon as it arrives rather than faded in once
185
+ * the page's JavaScript has heard it load, with the placeholder under it
186
+ * instead of over it — on a server-rendered page, a faded picture cannot
187
+ * appear before hydration.
183
188
  * @default false
184
189
  */
185
190
  priority?: boolean;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,Fragment as t,jsxs as i}from"react/jsx-runtime";import*as o from"react";import{Dialog as n}from"@base-ui/react/dialog";import{MPIcon as r}from"../icon/MPIcon.js";import{BrokenImageIcon as a}from"../../constants/icons.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FADE as d,PORTAL_LAYER as u,SCRIM as h}from"../../internal/surface.js";import{useMPSize as m}from"../../internal/config.js";const f={cover:"object-cover",contain:"object-contain",fill:"object-fill",none:"object-none","scale-down":"object-scale-down"},p={position:"absolute",top:"50%",left:"50%",width:"100cqh",height:"100cqw",maxWidth:"none",translate:"-50% -50%"},g=Number.parseInt(o.version,10),b=!Number.isFinite(g)||0===g||g>=19?"fetchPriority":"fetchpriority",v={loading:"eager",[b]:"high"};function y(e,t){const i=2*e+"px";return t?{...p,width:`calc(100cqh + ${i})`,height:`calc(100cqw + ${i})`}:{position:"absolute",top:-e,left:-e,width:`calc(100% + ${i})`,height:`calc(100% + ${i})`,maxWidth:"none"}}const w=new Map([["left",[0,0]],["right",[0,1]],["top",[1,0]],["bottom",[1,1]]]);function j(e,t,i){const o=e.trim().split(/\s+/),n=[.5,.5],r=[!1,!1];if(o.length>2)return e;for(const[t,i]of o.entries()){if("center"===i)continue;const o=w.get(i),a=/^(-?\d*\.?\d+)%$/.exec(i),l=o?o[0]:t,s=o?o[1]:a?Number(a[1])/100:void 0;if(void 0===s||r[l])return e;n[l]=s,r[l]=!0}let[a,l]=n;"horizontal"!==i&&"both"!==i||(a=1-a),"vertical"!==i&&"both"!==i||(l=1-l);for(let e=0;e<t/90;e++)[a,l]=[l,1-a];const s=e=>Math.round(1e4*e)/100+"%";return`${s(a)} ${s(l)}`}function $(e){return"number"==typeof e?Number.isFinite(e)?e:void 0:void 0!==e&&/^\d+$/.test(e.trim())?Number(e):void 0}function x(e){const t=$(e);return void 0===t?String(e):`${t}px`}function N(e,t,i){const o=e??t,n=e??(i?t:void 0);if(!o)return{aspectRatio:"1",width:"min(100%, 100cqh)",containerType:"size"};const r=o.height,a=o.width;return{aspectRatio:`${r} / ${a}`,width:`min(100%, ${n?`${n.height}px, `:""}calc(100cqh * ${r} / ${a}))`,containerType:"size"}}function z(e){return e.naturalWidth>0&&e.naturalHeight>0?{width:e.naturalWidth,height:e.naturalHeight}:void 0}export const MPImage=/*@__PURE__*/o.forwardRef(function({src:g,alt:w,ratio:R,fit:k="cover",placeholder:L,fallback:P,preview:S=!1,previewSrc:T,previewLabel:W,onStateChange:q,rotate:M,flip:F="none",position:B="center",letterbox:E="none",priority:O=!1,size:U,className:I,style:C,width:H,height:V,onLoad:A,...D},G){const J=m(U),K=l(),Q=s(c,K),X="object"==typeof(Y=L)&&null!==Y&&!o.isValidElement(Y)&&"src"in Y?L:void 0;var Y;const Z=function(e){const[t,i]=o.useState();return o.useEffect(()=>{if(void 0===e||"string"==typeof e)return;const t=URL.createObjectURL(e);return i({blob:e,url:t}),()=>URL.revokeObjectURL(t)},[e]),void 0===e||"string"==typeof e?e:t?.blob===e?t.url:void 0}(X?.src),[_,ee]=o.useState({state:g?"loading":"error"}),[te,ie]=o.useState(),oe=o.useRef(null),{state:ne,natural:re}=_,ae=o.useCallback((e,t)=>{const i="loaded"===e&&t?z(t):void 0;ee(t=>t.state===e&&t.natural?.width===i?.width&&t.natural?.height===i?.height?t:(t.state!==e&&q?.(e),{state:e,natural:i}))},[q]),[le,se]=o.useState(g);g!==le&&(se(g),ee({state:g?"loading":"error"})),o.useEffect(()=>{const e=oe.current;e&&g&&e.complete&&ae(e.naturalWidth>0?"loaded":"error",e)},[g,ae]);const ce=function(e){return void 0!==e&&Number.isFinite(e)?(Math.round(e/90)%4+4)%4*90:0}(M),de=90===ce||270===ce,ue=function(e,t){const i="horizontal"===t||"both"===t,o="vertical"===t||"both"===t,[n,r]=90===e||270===e?[o,i]:[i,o];return{...e?{rotate:`${e}deg`}:null,...n||r?{scale:`${n?-1:1} ${r?-1:1}`}:null}}(ce,F),he="center"===B?{}:{objectPosition:j(B,ce,F)},me=void 0!==H&&void 0!==V,fe=void 0===H||me?void 0:x(H),pe=void 0===V||me?void 0:x(V),ge=me?$(H):void 0,be=me?$(V):void 0,ve=(ge&&be?{width:ge,height:be}:void 0)??re,ye=de&&void 0===R&&ve&&void 0===pe?`${ve.height} / ${ve.width}`:R,we="loaded"===ne,je=e("div",{className:["bg-mp-surface-container text-mp-on-surface-variant","flex size-full items-center justify-center"].join(" "),children:e(r,{icon:a,size:24})}),$e=e("div",{className:["bg-mp-surface-container-high size-full","motion-safe:animate-pulse motion-reduce:animate-none"].join(" ")}),xe=/*@__PURE__*/[we?"opacity-100":"opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)"].join(" "),Ne=D.loading??(O?"eager":void 0),ze=D.fetchPriority??(O?"high":void 0),Re="blur"===E&&("contain"===k||"none"===k||"scale-down"===k),ke="none"!==E&&"blur"!==E?E:void 0,Le=Boolean(Z)&&"error"!==ne,Pe=!0===X?.blur?20:"number"==typeof X?.blur&&Number.isFinite(X.blur)?Math.max(0,X.blur):0,Se=i(t,{children:[Re?e("img",{...ze?{[b]:ze}:null,src:g,srcSet:D.srcSet,sizes:D.sizes,loading:Ne,decoding:D.decoding,crossOrigin:D.crossOrigin,referrerPolicy:D.referrerPolicy,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none object-cover ${xe}`,style:{...ue,...he,filter:"blur(24px)",...y(48,de)}}):null,Le?e("img",{src:Z,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none ${f[k]}`,style:{...ue,...he,...Pe?{filter:`blur(${Pe}px)`}:null,...y(2*Pe,de),...we?{opacity:0,transition:"opacity 0ms linear var(--mp-sys-motion-duration-short4)"}:null}}):null,e("img",{...O?v:null,...D,ref:e=>{oe.current=e,"function"==typeof G?G(e):G&&(G.current=e)},src:g,alt:w,width:me?H:void 0,height:me?V:void 0,className:`block size-full ${f[k]} ${xe}`,style:{...ue,...he,...Re||Le?{position:"relative"}:null,...de?p:null},onLoad:e=>{ae("loaded",e.currentTarget),A?.(e)},onError:()=>ae("error")}),"loading"!==ne||!1===L||X?null:e("span",{"aria-hidden":"true",className:"absolute inset-0",children:L??$e}),"error"===ne?e("span",{className:"absolute inset-0",children:P??je}):null]}),Te=["mp-image relative block overflow-hidden",I??""].filter(Boolean).join(" "),We={aspectRatio:ye,...void 0!==fe?{width:fe,maxWidth:"100%"}:null,...void 0!==pe?{height:pe}:null,...void 0!==pe&&void 0!==R?{width:"auto",maxWidth:"100%"}:null,...de?{containerType:"size"}:null,...void 0!==ke?{background:ke}:null,...C},qe=T??g,Me=te?.src===qe?te:void 0,Fe=e=>{const t=z(e.currentTarget);!t||t.width===Me?.width&&t.height===Me?.height||ie({...t,src:qe})};return S?i(n.Root,{children:[e(n.Trigger,{"data-mp-size":J,"data-mp-state":ne,disabled:"error"===ne,"aria-label":(W??w)||Q.open,className:[Te,"w-full","outline-mp-secondary cursor-zoom-in appearance-none border-0 bg-transparent p-0","focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-default","outline-none"].filter(Boolean).join(" "),style:We,children:Se}),i(n.Portal,{children:[e(n.Backdrop,{className:`${h} ${d} fixed inset-0 z-40`}),e(n.Popup,{className:[u,d,"fixed inset-0 flex items-center justify-center p-6"].join(" "),style:de?{containerType:"size"}:void 0,children:de?e("span",{className:"relative block shrink-0",style:N(Me,ve,void 0===T),children:e("img",{src:qe,alt:w,className:"object-contain",style:{...ue,...p},onLoad:Fe})}):e("img",{src:qe,alt:w,className:"max-h-full max-w-full object-contain",style:ue,onLoad:Fe})})]})]}):e("span",{"data-mp-size":J,"data-mp-state":ne,className:Te,style:We,children:Se})});
2
+ import{jsx as e,Fragment as t,jsxs as i}from"react/jsx-runtime";import*as o from"react";import{Dialog as n}from"@base-ui/react/dialog";import{MPIcon as r}from"../icon/MPIcon.js";import{BrokenImageIcon as a}from"../../constants/icons.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FADE as d,PORTAL_LAYER as u,SCRIM as h}from"../../internal/surface.js";import{useMPSize as m}from"../../internal/config.js";const f={cover:"object-cover",contain:"object-contain",fill:"object-fill",none:"object-none","scale-down":"object-scale-down"},p={position:"absolute",top:"50%",left:"50%",width:"100cqh",height:"100cqw",maxWidth:"none",translate:"-50% -50%"},g=Number.parseInt(o.version,10),b=!Number.isFinite(g)||0===g||g>=19?"fetchPriority":"fetchpriority",v={loading:"eager",[b]:"high"};function y(e,t){const i=2*e+"px";return t?{...p,width:`calc(100cqh + ${i})`,height:`calc(100cqw + ${i})`}:{position:"absolute",top:-e,left:-e,width:`calc(100% + ${i})`,height:`calc(100% + ${i})`,maxWidth:"none"}}const w=new Map([["left",[0,0]],["right",[0,1]],["top",[1,0]],["bottom",[1,1]]]);function j(e,t,i){const o=e.trim().split(/\s+/),n=[.5,.5],r=[!1,!1];if(o.length>2)return e;for(const[t,i]of o.entries()){if("center"===i)continue;const o=w.get(i),a=/^(-?\d*\.?\d+)%$/.exec(i),l=o?o[0]:t,s=o?o[1]:a?Number(a[1])/100:void 0;if(void 0===s||r[l])return e;n[l]=s,r[l]=!0}let[a,l]=n;"horizontal"!==i&&"both"!==i||(a=1-a),"vertical"!==i&&"both"!==i||(l=1-l);for(let e=0;e<t/90;e++)[a,l]=[l,1-a];const s=e=>Math.round(1e4*e)/100+"%";return`${s(a)} ${s(l)}`}function $(e){return"number"==typeof e?Number.isFinite(e)?e:void 0:void 0!==e&&/^\d+$/.test(e.trim())?Number(e):void 0}function x(e){const t=$(e);return void 0===t?String(e):`${t}px`}function N(e,t,i){const o=e??t,n=e??(i?t:void 0);if(!o)return{aspectRatio:"1",width:"min(100%, 100cqh)",containerType:"size"};const r=o.height,a=o.width;return{aspectRatio:`${r} / ${a}`,width:`min(100%, ${n?`${n.height}px, `:""}calc(100cqh * ${r} / ${a}))`,containerType:"size"}}function z(e){return e.naturalWidth>0&&e.naturalHeight>0?{width:e.naturalWidth,height:e.naturalHeight}:void 0}export const MPImage=/*@__PURE__*/o.forwardRef(function({src:g,alt:w,ratio:R,fit:k="cover",placeholder:L,fallback:P,preview:S=!1,previewSrc:T,previewLabel:W,onStateChange:q,rotate:M,flip:F="none",position:B="center",letterbox:E="none",priority:O=!1,size:U,className:I,style:C,width:H,height:V,onLoad:A,...D},G){const J=m(U),K=l(),Q=s(c,K),X="object"==typeof(Y=L)&&null!==Y&&!o.isValidElement(Y)&&"src"in Y?L:void 0;var Y;const Z=function(e){const[t,i]=o.useState();return o.useEffect(()=>{if(void 0===e||"string"==typeof e)return;const t=URL.createObjectURL(e);return i({blob:e,url:t}),()=>URL.revokeObjectURL(t)},[e]),void 0===e||"string"==typeof e?e:t?.blob===e?t.url:void 0}(X?.src),[_,ee]=o.useState({state:g?"loading":"error"}),[te,ie]=o.useState(),oe=o.useRef(null),{state:ne,natural:re}=_,ae=o.useCallback((e,t)=>{const i="loaded"===e&&t?z(t):void 0;ee(t=>t.state===e&&t.natural?.width===i?.width&&t.natural?.height===i?.height?t:(t.state!==e&&q?.(e),{state:e,natural:i}))},[q]),[le,se]=o.useState(g);g!==le&&(se(g),ee({state:g?"loading":"error"})),o.useEffect(()=>{const e=oe.current;e&&g&&e.complete&&ae(e.naturalWidth>0?"loaded":"error",e)},[g,ae]);const ce=function(e){return void 0!==e&&Number.isFinite(e)?(Math.round(e/90)%4+4)%4*90:0}(M),de=90===ce||270===ce,ue=function(e,t){const i="horizontal"===t||"both"===t,o="vertical"===t||"both"===t,[n,r]=90===e||270===e?[o,i]:[i,o];return{...e?{rotate:`${e}deg`}:null,...n||r?{scale:`${n?-1:1} ${r?-1:1}`}:null}}(ce,F),he="center"===B?{}:{objectPosition:j(B,ce,F)},me=void 0!==H&&void 0!==V,fe=void 0===H||me?void 0:x(H),pe=void 0===V||me?void 0:x(V),ge=me?$(H):void 0,be=me?$(V):void 0,ve=(ge&&be?{width:ge,height:be}:void 0)??re,ye=de&&void 0===R&&ve&&void 0===pe?`${ve.height} / ${ve.width}`:R,we="loaded"===ne,je=e("div",{className:["bg-mp-surface-container text-mp-on-surface-variant","flex size-full items-center justify-center"].join(" "),children:e(r,{icon:a,size:24})}),$e=e("div",{className:["bg-mp-surface-container-high size-full","motion-safe:animate-pulse motion-reduce:animate-none"].join(" ")}),xe=O?"":[we?"opacity-100":"opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)"].join(" "),Ne=D.loading??(O?"eager":void 0),ze=D.fetchPriority??(O?"high":void 0),Re="blur"===E&&("contain"===k||"none"===k||"scale-down"===k),ke="none"!==E&&"blur"!==E?E:void 0,Le=Boolean(Z)&&"error"!==ne,Pe=!0===X?.blur?20:"number"==typeof X?.blur&&Number.isFinite(X.blur)?Math.max(0,X.blur):0,Se="loading"!==ne||!1===L||X?null:e("span",{"aria-hidden":"true",className:"absolute inset-0",children:L??$e}),Te=i(t,{children:[O?Se:null,Re?e("img",{...ze?{[b]:ze}:null,src:g,srcSet:D.srcSet,sizes:D.sizes,loading:Ne,decoding:D.decoding,crossOrigin:D.crossOrigin,referrerPolicy:D.referrerPolicy,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none object-cover ${xe}`,style:{...ue,...he,filter:"blur(24px)",...y(48,de)}}):null,Le?e("img",{src:Z,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none ${f[k]}`,style:{...ue,...he,...Pe?{filter:`blur(${Pe}px)`}:null,...y(2*Pe,de),...we?{opacity:0,transition:"opacity 0ms linear var(--mp-sys-motion-duration-short4)"}:null}}):null,e("img",{...O?v:null,...D,ref:e=>{oe.current=e,"function"==typeof G?G(e):G&&(G.current=e)},src:g,alt:w,width:me?H:void 0,height:me?V:void 0,className:`block size-full ${f[k]} ${xe}`,style:{...ue,...he,...Re||Le||O?{position:"relative"}:null,...de?p:null},onLoad:e=>{ae("loaded",e.currentTarget),A?.(e)},onError:()=>ae("error")}),O?null:Se,"error"===ne?e("span",{className:"absolute inset-0",children:P??je}):null]}),We=["mp-image relative block overflow-hidden",I??""].filter(Boolean).join(" "),qe={aspectRatio:ye,...void 0!==fe?{width:fe,maxWidth:"100%"}:null,...void 0!==pe?{height:pe}:null,...void 0!==pe&&void 0!==R?{width:"auto",maxWidth:"100%"}:null,...de?{containerType:"size"}:null,...void 0!==ke?{background:ke}:null,...C},Me=T??g,Fe=te?.src===Me?te:void 0,Be=e=>{const t=z(e.currentTarget);!t||t.width===Fe?.width&&t.height===Fe?.height||ie({...t,src:Me})};return S?i(n.Root,{children:[e(n.Trigger,{"data-mp-size":J,"data-mp-state":ne,disabled:"error"===ne,"aria-label":(W??w)||Q.open,className:[We,"w-full","outline-mp-secondary cursor-zoom-in appearance-none border-0 bg-transparent p-0","focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-default","outline-none"].filter(Boolean).join(" "),style:qe,children:Te}),i(n.Portal,{children:[e(n.Backdrop,{className:`${h} ${d} fixed inset-0 z-40`}),e(n.Popup,{className:[u,d,"fixed inset-0 flex items-center justify-center p-6"].join(" "),style:de?{containerType:"size"}:void 0,children:de?e("span",{className:"relative block shrink-0",style:N(Fe,ve,void 0===T),children:e("img",{src:Me,alt:w,className:"object-contain",style:{...ue,...p},onLoad:Be})}):e("img",{src:Me,alt:w,className:"max-h-full max-w-full object-contain",style:ue,onLoad:Be})})]})]}):e("span",{"data-mp-size":J,"data-mp-state":ne,className:We,style:qe,children:Te})});
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { type CartesianChartProps } from '../../internal/ChartFrame.js';
3
- import type { MPChartCurve, MPChartValueLabels } from '../../types.js';
3
+ import type { MPChartCurve, MPChartGaps, MPChartValueLabels } from '../../types.js';
4
4
  export interface MPLineChartProps extends CartesianChartProps {
5
5
  /**
6
6
  * How the line gets from one point to the next.
@@ -16,6 +16,16 @@ export interface MPLineChartProps extends CartesianChartProps {
16
16
  * @default 'auto'
17
17
  */
18
18
  markers?: boolean | 'auto';
19
+ /**
20
+ * What the line does where a series has no value.
21
+ *
22
+ * `break` stops and restarts, `connect` joins the two sides with a dashed
23
+ * run, and `zero` draws the missing reading at zero and widens the axis to
24
+ * hold it. The hover panel and the table still report a gap as a gap in all
25
+ * three.
26
+ * @default 'break'
27
+ */
28
+ gaps?: MPChartGaps;
19
29
  /**
20
30
  * Which values are written onto the line itself.
21
31
  * @default 'none'
@@ -55,6 +65,14 @@ export interface MPLineChartProps extends CartesianChartProps {
55
65
  * nobody has, and it is the one kind of invented data a reader never questions
56
66
  * — it looks exactly like the rest of the line.
57
67
  *
68
+ * `gaps` is there for the two cases where the default is the wrong reading.
69
+ * `connect` joins the two sides and draws the joining run **dashed**, so the
70
+ * line carries on and the picture still says which part of it was measured.
71
+ * `zero` draws the missing reading at zero and widens the axis to hold it,
72
+ * which is right where a gap means "none of it happened" and wrong where it
73
+ * means "nobody was counting". The table behind the chart reports a gap as a
74
+ * gap whichever is chosen.
75
+ *
58
76
  * ## The hover layer is not optional
59
77
  *
60
78
  * A chart in a browser is a thing a reader interrogates, so the crosshair and
@@ -63,4 +81,4 @@ export interface MPLineChartProps extends CartesianChartProps {
63
81
  * gridline is answering it badly. The arrow keys walk the same columns, and a
64
82
  * clipped live region says each one out loud.
65
83
  */
66
- export declare function MPLineChart({ curve, markers, valueLabels, ...frame }: MPLineChartProps): React.JSX.Element;
84
+ export declare function MPLineChart({ curve, markers, gaps, valueLabels, ...frame }: MPLineChartProps): React.JSX.Element;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{CartesianFrame as l}from"../../internal/ChartFrame.js";import{LINE_WIDTH as t,MARKER_RADIUS as n,linePath as a}from"../../internal/chart.js";export function MPLineChart({curve:o="linear",markers:i="auto",valueLabels:u="none",...s}){return e(l,{...s,inset:!0,includeZero:!1,headroom:"none"===u?0:14,children:({plot:l,values:s,visible:c,colors:m,point:h,size:d,hovered:f,activeIndex:p,format:x})=>{const v=t[d],k=n[d],j=s.reduce((e,r)=>Math.max(e,r.length),0),y=j>1?l.width/(j-1):l.width,g="auto"===i?y>=6*k:i;return e("g",{className:"mp-line-chart__marks",children:s.map((t,n)=>{if(!c[n])return null;const i=t.map((e,r)=>null===e.value?null:h(r,e.value)),s=m[n];return r("g",{opacity:null!==f&&f!==n?.25:1,children:[e("path",{d:a(i,o),fill:"none",stroke:s,strokeWidth:v,strokeLinecap:"round",strokeLinejoin:"round"}),i.map((r,l)=>{if(!r)return null;const t=p===l;return g||t?e("circle",{cx:r.x,cy:r.y,r:t?k+1:k,fill:s,stroke:"var(--_mp-color-surface)",strokeWidth:2},l):null}),"none"===u?null:t.map((r,n)=>{const a=i[n];if(!a||null===r.value)return null;const o=t.filter(e=>null!==e.value),s=o.map(e=>e.value);if(!("all"===u||"last"===u&&r===o[o.length-1]||"extremes"===u&&(r.value===Math.min(...s)||r.value===Math.max(...s))))return null;const c=a.x>l.left+l.width-24?"end":a.x<l.left+24?"start":"middle";return e("text",{x:a.x,y:a.y-k-5,textAnchor:c,fill:"var(--_mp-color-on-surface)",fontSize:"xs"===d||"sm"===d?10:11,children:r.label??x(r.value)},n)})]},n)})})}})}
2
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{CartesianFrame as n}from"../../internal/ChartFrame.js";import{BRIDGE_DASH as t,LINE_WIDTH as l,MARKER_RADIUS as o,bridgePath as a,linePath as i,valueLabelTest as s}from"../../internal/chart.js";export function MPLineChart({curve:u="linear",markers:c="auto",gaps:d="break",valueLabels:h="none",...m}){return e(n,{...m,inset:!0,includeZero:"zero"===d,headroom:"none"===h?0:14,children:({plot:n,values:m,visible:p,colors:f,labelInk:x,point:k,size:v,hovered:j,activeIndex:y,format:b})=>{const L=l[v],g=o[v],z=m.reduce((e,r)=>Math.max(e,r.length),0),w=z>1?n.width/(z-1):n.width,W="auto"===c?w>=6*g:c;return e("g",{className:"mp-line-chart__marks",children:m.map((l,o)=>{if(!p[o])return null;const c=l.map((e,r)=>null===e.value?"zero"===d?k(r,0):null:k(r,e.value)),m=f[o],z=null!==j&&j!==o,w=s(l,h);return r("g",{opacity:z?.25:1,children:[e("path",{d:i(c,u),fill:"none",stroke:m,strokeWidth:L,strokeLinecap:"round",strokeLinejoin:"round"}),"connect"===d?e("path",{d:a(c),fill:"none",stroke:m,strokeWidth:L,strokeDasharray:`${L*t} ${L*t}`,strokeLinecap:"round"}):null,c.map((r,n)=>{if(!r)return null;const t=y===n;return W||t?e("circle",{cx:r.x,cy:r.y,r:t?g+1:g,fill:m,stroke:"var(--_mp-color-surface)",strokeWidth:2},n):null}),"none"===h?null:l.map((r,t)=>{const l=c[t];if(!l||null===r.value)return null;if(!w(t))return null;const a=l.x>n.left+n.width-24?"end":l.x<n.left+24?"start":"middle";return e("text",{x:l.x,y:l.y-g-5,textAnchor:a,fill:x(o),fontSize:"xs"===v||"sm"===v?10:11,children:r.label??b(r.value)},t)})]},o)})})}})}
@@ -19,38 +19,23 @@ export interface MPLocaleProviderProps {
19
19
  * over it does.
20
20
  */
21
21
  locale?: string;
22
+ /**
23
+ * The tag dates and numbers are written in on the server, and while the page
24
+ * hydrates, when `locale` is left `undefined`. Once the page has hydrated, the
25
+ * reader's own default takes over.
26
+ *
27
+ * For a server-rendered page that wants to follow the reader's browser but
28
+ * cannot tell their language on the server. Without it the server writes in
29
+ * its own machine's locale, the browser's first render writes in the reader's,
30
+ * and React discards the server's markup over the difference. With it the two
31
+ * agree, and the formatted values are rewritten once after hydration instead.
32
+ *
33
+ * Ignored when `locale` is set, which already agrees on both sides.
34
+ */
35
+ serverLocale?: string;
22
36
  children?: React.ReactNode;
23
37
  }
24
- /**
25
- * The language the components speak, set once for everything under it.
26
- *
27
- * Wrap the application. Every component in this library that writes a word or
28
- * formats a date takes a `locale` prop of its own, and this is where that prop
29
- * gets its default — so a form of four pickers is one decision rather than four.
30
- *
31
- * ```tsx
32
- * <MPLocaleProvider locale="ko">
33
- * <App />
34
- * </MPLocaleProvider>
35
- * ```
36
- *
37
- * ## Why it is not a whole theme object
38
- *
39
- * Everything else a provider might carry here is already a CSS custom property:
40
- * the colour roles, the type scale, the corners, the motion durations. Those
41
- * reach a component through the cascade, which means a section of a page can
42
- * differ from the rest of it without a second provider and without a re-render.
43
- * A locale cannot travel that way — it decides which *string* is rendered, not
44
- * how one is painted — so it is the one thing left that needs context, and this
45
- * provider carries that and nothing else.
46
- *
47
- * ## Nesting
48
- *
49
- * Providers nest, and the nearest one wins. A page in Korean with one section
50
- * showing a Japanese listing's dates is two providers, and the inner one does
51
- * not have to restate anything: there is only the one value.
52
- */
53
- export declare function MPLocaleProvider({ locale, children }: MPLocaleProviderProps): React.JSX.Element;
38
+ export declare function MPLocaleProvider({ locale, serverLocale, children }: MPLocaleProviderProps): React.JSX.Element;
54
39
  /**
55
40
  * The locale in force at this point in the tree.
56
41
  *
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r}from"react/jsx-runtime";import{MPLocaleContext as e,useMPLocale as o}from"../../internal/locale.js";export function MPLocaleProvider({locale:o,children:i}){return r(e.Provider,{value:o,children:i})}export{o as useMPLocale};
2
+ import{jsx as r}from"react/jsx-runtime";import*as e from"react";import{MPLocaleContext as o,useMPLocale as t}from"../../internal/locale.js";const c=()=>()=>{},n=()=>{};export function MPLocaleProvider({locale:t,serverLocale:a,children:l}){const i=e.useSyncExternalStore(c,n,()=>a);return r(o.Provider,{value:t??i,children:l})}export{t as useMPLocale};