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
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{jsx as r}from"react/jsx-runtime";import{useRender as e}from"@base-ui/react/use-render";export function RenderedLink({render:n,props:o}){return e({render:n??r("a",{}),props:o})}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{Field as t}from"@base-ui/react/field";import{META_TEXT as a,hasContent as n}from"./scale.js";export function MPSupportingText({description:o,errorMessage:s,className:i}){const m=n(s)?"error":n(o)?"description":"none",c=r.useRef(null),p=r.useRef(m);r.useLayoutEffect(()=>{const e=c.current,r=p.current;p.current=m,e&&m!==r&&"none"!==m&&(e.dataset.mpReveal="none"===r?"open":"swap",e.style.animationName="none",e.offsetWidth,e.style.animationName="")},[m]);const l=["mp-supporting-text block min-h-0",a,"data-disabled:text-mp-on-surface/38",i??""].filter(Boolean).join(" ");return n(s)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Error,{match:!0,className:`${l} text-mp-error`,children:s})}):n(o)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Description,{className:`${l} text-mp-on-surface-variant m-0`,children:o})}):e(t.Error,{className:`${l} text-mp-error`})}
2
+ import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{Field as t}from"@base-ui/react/field";import{META_TEXT as s,hasContent as a}from"./scale.js";import{useMPConfig as n}from"./config.js";export function MPSupportingText({description:o,errorMessage:i,className:m}){const p=a(i)?"error":a(o)?"description":"none",c=r.useRef(null),l=r.useRef(p),u=!0===n().reserveSupportingText;r.useLayoutEffect(()=>{const e=c.current,r=l.current;l.current=p,e&&p!==r&&"none"!==p&&(e.dataset.mpReveal="none"!==r||u?"swap":"open",e.style.animationName="none",e.offsetWidth,e.style.animationName="")},[p,u]);const d=["mp-supporting-text block min-h-0",s,"data-disabled:text-mp-on-surface/38",m??""].filter(Boolean).join(" ");if(u){const r="block min-h-0 data-disabled:text-mp-on-surface/38";return e("div",{className:["mp-supporting-text__line block min-h-[1lh]",s,m??""].filter(Boolean).join(" "),children:a(i)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Error,{match:!0,className:`mp-supporting-text ${r} text-mp-error`,children:i})}):a(o)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Description,{className:`mp-supporting-text ${r} text-mp-on-surface-variant m-0`,children:o})}):e(t.Error,{className:`mp-supporting-text ${r} text-mp-error`})})}return a(i)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Error,{match:!0,className:`${d} text-mp-error`,children:i})}):a(o)?e("div",{ref:c,className:"mp-supporting-text__reveal",children:e(t.Description,{className:`${d} text-mp-on-surface-variant m-0`,children:o})}):e(t.Error,{className:`${d} text-mp-error`})}
@@ -107,6 +107,8 @@ export interface AnimationRun {
107
107
  state: 'running' | 'paused';
108
108
  /** Whether the animation has been let go at all. */
109
109
  started: boolean;
110
+ /** How many times it has been started, so a replay is something to depend on. */
111
+ run: number;
110
112
  /** Spread onto the element when `trigger` is `hover`; empty otherwise. */
111
113
  handlers: React.HTMLAttributes<HTMLElement>;
112
114
  }
@@ -164,6 +166,8 @@ export interface AnimateElement {
164
166
  props: React.HTMLAttributes<HTMLElement> & Record<string, unknown>;
165
167
  /** The children, wrapped when there is a `stagger` and untouched otherwise. */
166
168
  children: React.ReactNode;
169
+ /** How many times the animation has been started; changes on every replay. */
170
+ run: number;
167
171
  }
168
172
  /**
169
173
  * Everything an `MPAnimate*` root needs, in one call.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{ANIM_BASE as e,ANIMATION_CLASS as t,animationSlots as n,easingValue as r,isInfinite as a,lengthValue as s,repeatValue as o,revealClip as i,slideOffsets as c}from"./animate-core.js";export{e as ANIM_BASE,t as ANIMATION_CLASS,n as animationSlots,r as easingValue,a as isInfinite,s as lengthValue,o as repeatValue,i as revealClip,c as slideOffsets};import*as u from"react";export function staggerChildren(e,t,r,{stagger:a,durationStep:s=0,reverse:o=!1}){const i=u.Children.toArray(e);return i.map((e,c)=>{const d=o?i.length-1-c:c,f=n({...r,delay:r.delay+d*a,durationOffset:(r.durationOffset??0)+d*s});if(!u.isValidElement(e))return u.createElement("span",{key:c,className:t,style:f},e);const l=e.props;return u.cloneElement(e,{className:[t,l.className].filter(Boolean).join(" "),style:{...f,...l.style}})})}const d="(prefers-reduced-motion: reduce)";function f(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=window.matchMedia(d);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function l(){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(d).matches}function m(){return!1}export function usePrefersReducedMotion(){return u.useSyncExternalStore(f,l,m)}export function useAnimationRun({trigger:e,play:t,once:n,threshold:r,paused:a,infinite:s}){const o=u.useRef(null),[i,c]=u.useState("mount"===e),[d,f]=u.useState(0),l=u.useCallback(()=>{c(!0),f(e=>e+1)},[]);u.useLayoutEffect(()=>{const e=o.current;if(!e||0===d)return;const t=[e,...e.querySelectorAll(".mp-anim, .mp-marquee-track")];for(const e of t)e.style.animationName="none";e.offsetWidth;for(const e of t)e.style.animationName=""},[d]),u.useEffect(()=>{if("visible"!==e)return;const t=o.current;if(!t||"undefined"==typeof IntersectionObserver)return void c(!0);const a=new IntersectionObserver(([e])=>{e.isIntersecting?(l(),n&&a.disconnect()):n||c(!1)},{threshold:r});return a.observe(t),()=>a.disconnect()},[e,n,r,l]),u.useEffect(()=>{"manual"===e&&(t?l():c(!1))},[e,t,l]);const m=u.useCallback(()=>{s&&c(!1)},[s]),p="hover"===e?{onPointerEnter:l,onFocus:l,onPointerLeave:m,onBlur:m}:{};return{ref:u.useCallback(e=>{o.current=e},[]),state:i&&!a?"running":"paused",started:i,handlers:p}}export function useAnimateElement(r){const{trigger:a,play:s,once:o,threshold:i,paused:c,infinite:u,stagger:d=0,durationStep:f,reverse:l,effectClass:m,children:p,...h}=r,g=useAnimationRun({trigger:a,play:s,once:o,threshold:i,paused:c,infinite:u}),y=`${e} ${m??t[h.effect]}`,v=function(e,t,n){return"view"!==t?e:n?"paused":"running"}(g.state,h.timeline,c);return d>0?{ref:g.ref,className:"",style:{"--_mp-anim-state":v},props:{...g.handlers,"data-mp-animation":h.effect,"data-mp-state":v},children:staggerChildren(p,y,h,{stagger:d,durationStep:f,reverse:l})}:{ref:g.ref,className:y,style:{...n(h),"--_mp-anim-state":v},props:{...g.handlers,"data-mp-animation":h.effect,"data-mp-state":v},children:p}}
2
+ import{ANIM_BASE as e,ANIMATION_CLASS as t,animationSlots as n,easingValue as r,isInfinite as s,lengthValue as a,repeatValue as o,revealClip as i,slideOffsets as u}from"./animate-core.js";export{e as ANIM_BASE,t as ANIMATION_CLASS,n as animationSlots,r as easingValue,s as isInfinite,a as lengthValue,o as repeatValue,i as revealClip,u as slideOffsets};import*as c from"react";import{watchIntersection as f}from"./intersection.js";import{mediaList as l}from"./media.js";export function staggerChildren(e,t,r,{stagger:s,durationStep:a=0,reverse:o=!1}){const i=c.Children.toArray(e);return i.map((e,u)=>{const f=o?i.length-1-u:u,l=n({...r,delay:r.delay+f*s,durationOffset:(r.durationOffset??0)+f*a});if(!c.isValidElement(e))return c.createElement("span",{key:u,className:t,style:l},e);const d=e.props;return c.cloneElement(e,{className:[t,d.className].filter(Boolean).join(" "),style:{...l,...d.style}})})}const d="(prefers-reduced-motion: reduce)";function m(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=l(d);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)}function p(){return l(d)?.matches??!1}function h(){return!1}export function usePrefersReducedMotion(){return c.useSyncExternalStore(m,p,h)}export function useAnimationRun({trigger:e,play:t,once:n,threshold:r,paused:s,infinite:a}){const o=c.useRef(null),[i,u]=c.useState("mount"===e),[l,d]=c.useState(0),m=c.useRef("mount"===e),p=c.useCallback(()=>{u(!0),d(e=>e+1)},[]);c.useLayoutEffect(()=>{const e=o.current;if(!e||0===l)return;if(!m.current)return void(m.current=!0);const t=[e,...e.querySelectorAll(".mp-anim, .mp-marquee-track")];for(const e of t)e.style.animationName="none";e.offsetWidth;for(const e of t)e.style.animationName=""},[l]),c.useEffect(()=>{if("visible"!==e)return;const t=o.current;if(!t||"undefined"==typeof IntersectionObserver)return void u(!0);const s=f(t,e=>{e.isIntersecting?(p(),n&&s()):n||u(!1)},{threshold:r});return s},[e,n,r,p]),c.useEffect(()=>{"manual"===e&&(t?p():u(!1))},[e,t,p]);const h=c.useCallback(()=>{a&&u(!1)},[a]),g="hover"===e?{onPointerEnter:p,onFocus:p,onPointerLeave:h,onBlur:h}:{};return{ref:c.useCallback(e=>{o.current=e},[]),state:i&&!s?"running":"paused",started:i,run:l,handlers:g}}export function useAnimateElement(r){const{trigger:s,play:a,once:o,threshold:i,paused:u,infinite:c,stagger:f=0,durationStep:l,reverse:d,effectClass:m,children:p,...h}=r,g=useAnimationRun({trigger:s,play:a,once:o,threshold:i,paused:u,infinite:c}),y=`${e} ${m??t[h.effect]}`,v=function(e,t,n){return"view"!==t?e:n?"paused":"running"}(g.state,h.timeline,u);return f>0?{ref:g.ref,className:"",style:{"--_mp-anim-state":v},props:{...g.handlers,"data-mp-animation":h.effect,"data-mp-state":v},children:staggerChildren(p,y,h,{stagger:f,durationStep:l,reverse:d}),run:g.run}:{ref:g.ref,className:y,style:{...n(h),"--_mp-anim-state":v},props:{...g.handlers,"data-mp-animation":h.effect,"data-mp-state":v},children:p,run:g.run}}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The size a chart lays itself out against: its box's own layout size, read
3
+ * before the browser paints.
4
+ *
5
+ * `useMPElementSize` answers the question a caller asks of it — how big the box
6
+ * looks — and two things about that answer are wrong for a chart:
7
+ *
8
+ * - **It is read in an effect**, which runs after the browser has painted. A
9
+ * chart mounted in the browser drew one frame with no width, an empty box,
10
+ * and then its picture. Read in a layout effect the first paint already has
11
+ * the picture, and a server-rendered chart draws in the frame it hydrates in.
12
+ * - **It includes transforms.** A chart mounted inside a surface that enters
13
+ * from `scale(0.95)` — `MPDialog` does — measured the shrunken box, drew its
14
+ * paths to fit that, and was never told otherwise: a transform finishing is
15
+ * not a resize, so the observer stays silent and the plot stays five per cent
16
+ * narrower than the room it has. The layout size is the room.
17
+ *
18
+ * Rounded, and the rounding is what makes the bail-out meaningful.
19
+ */
20
+ import * as React from 'react';
21
+ import type { MPElementSize } from '../hooks/useMPElementSize.js';
22
+ export declare function useBoxSize(ref: React.RefObject<Element | null>): MPElementSize;
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import*as t from"react";import{useBrowserLayoutEffect as e}from"./layout-effect.js";const i={width:0,height:0};function n(t,e){const i=e?.borderBoxSize?.[0];if(i)return{width:Math.round(i.inlineSize),height:Math.round(i.blockSize)};if(t instanceof HTMLElement)return{width:t.offsetWidth,height:t.offsetHeight};const n=t.getBoundingClientRect();return{width:Math.round(n.width),height:Math.round(n.height)}}export function useBoxSize(r){const[o,h]=t.useState(i);return e(()=>{const t=r.current;if(!t)return;const e=t=>h(e=>e.width===t.width&&e.height===t.height?e:t);if(e(n(t)),"undefined"==typeof ResizeObserver)return;const i=new ResizeObserver(([i])=>e(n(t,i)));return i.observe(t),()=>i.disconnect()},[r]),o}
@@ -1,5 +1,5 @@
1
1
  import type * as React from 'react';
2
- import type { MPChartCategory, MPChartCurve, MPChartDatum, MPChartSeries, MPSize } from '../types.js';
2
+ import type { MPChartCategory, MPChartCurve, MPChartDatum, MPChartSeries, MPChartTickLabels, MPChartValueLabels, MPSize } from '../types.js';
3
3
  /**
4
4
  * The arithmetic and the vocabulary the charts share.
5
5
  *
@@ -49,6 +49,16 @@ export declare const COMPACT_FROM = 10000;
49
49
  * component that compacted it anyway would be arguing.
50
50
  */
51
51
  export declare function formatStatistic(value: number, locale: string | undefined, format: Intl.NumberFormatOptions | undefined, compact: boolean): string;
52
+ /**
53
+ * A share of a whole, as a percentage.
54
+ *
55
+ * Whole percentages, because a percent stack is read as a composition rather
56
+ * than measured: "about a third" is the answer it is being asked for, and
57
+ * `33.4%` on an axis is three characters spent on a digit nobody uses. A share
58
+ * under a percent is written as the `<1%` it rounds to rather than as the `0%`
59
+ * it is not — a slice that is there has to read as there.
60
+ */
61
+ export declare function formatShare(share: number, locale: string | undefined): string;
52
62
  /** Which way a figure has moved, and whether that is the good direction. */
53
63
  export interface MPStatisticDelta {
54
64
  /** The change, in the value's own units. */
@@ -89,6 +99,24 @@ export type PlotPoint = {
89
99
  * invented, because it looks exactly like data.
90
100
  */
91
101
  export declare function linePath(points: readonly PlotPoint[], curve: MPChartCurve): string;
102
+ /**
103
+ * The straight runs that cross a series' gaps, and nothing else.
104
+ *
105
+ * Drawn **beside** `linePath` rather than instead of it, and drawn dashed. A
106
+ * caller who has asked for the gaps to be joined has said a missing reading
107
+ * should not break the line; they have not said the chart may report a value
108
+ * nobody measured. A dashed straight run between the two real points says both
109
+ * things at once — here is the shape you asked for, and this part of it is a
110
+ * guess.
111
+ *
112
+ * Straight whatever the curve is, for the same reason: a smoothed bridge claims
113
+ * to know how the value moved while it was not being watched.
114
+ */
115
+ export declare function bridgePath(points: readonly PlotPoint[]): string;
116
+ /** The dash the bridges are drawn in, as a multiple of the stroke's width. */
117
+ export declare const BRIDGE_DASH = 3;
118
+ /** Every point a series has, with the gaps dropped rather than kept as holes. */
119
+ export declare function withoutGaps(points: readonly PlotPoint[]): PlotPoint[];
92
120
  /**
93
121
  * The ribbon between two runs of points.
94
122
  *
@@ -143,6 +171,26 @@ export declare function extentOf(values: readonly (number | null)[], min?: numbe
143
171
  min: number;
144
172
  max: number;
145
173
  };
174
+ /**
175
+ * An extent opened out to hold the places a caller has marked.
176
+ *
177
+ * A target line above everything measured is the case this exists for: cropped
178
+ * out of the scale it is a line the reader cannot see, which is the one thing a
179
+ * target must never be. A band counts both of its ends.
180
+ *
181
+ * `null` in and nothing marked is still `null` — a chart with no data and one
182
+ * reference is a chart of a line, and there is no picture to draw.
183
+ */
184
+ export declare function withReferences(extent: {
185
+ min: number;
186
+ max: number;
187
+ } | null, references: readonly {
188
+ value: number | Date;
189
+ to?: number | Date;
190
+ }[] | undefined): {
191
+ min: number;
192
+ max: number;
193
+ } | null;
146
194
  /**
147
195
  * The lowest and highest a set of series reaches.
148
196
  *
@@ -209,18 +257,16 @@ export interface BandScale {
209
257
  }
210
258
  export declare function bandScale(count: number, length: number, ratio: number): BandScale;
211
259
  /**
212
- * Roughly how wide a string renders at a given font size.
213
- *
214
- * An estimate on purpose. The exact answer is a canvas measurement per label
215
- * per render, on a path that runs again on every resize — and what the number
216
- * is used for is deciding how much room to reserve, where a few pixels of
217
- * generosity cost nothing and a reflow costs a frame.
260
+ * The lowest and highest of a list, in one pass and without spreading it.
218
261
  *
219
- * 0.6em is about the advance of a digit in the sans-serifs a UI runs in.
220
- * Anything CJK is close to a full em, so the wider characters are counted as
221
- * one: a Korean axis reserving 60% of the room it needs is an axis that
222
- * overlaps itself.
262
+ * `Math.min(...values)` passes every value as an argument, and an engine runs
263
+ * out of argument room somewhere past a hundred thousand — the chart then throws
264
+ * a `RangeError` instead of drawing. `null` for an empty list.
223
265
  */
266
+ export declare function bounds(values: Iterable<number>): {
267
+ min: number;
268
+ max: number;
269
+ } | null;
224
270
  export declare function textWidth(text: string, fontSize: number): number;
225
271
  /**
226
272
  * A label cut to the room it has.
@@ -236,8 +282,10 @@ export declare function truncate(text: string, maxWidth: number, fontSize: numbe
236
282
  /**
237
283
  * How many labels an axis can show before they collide — every nth.
238
284
  *
239
- * Every nth rather than rotating them. A rotated axis is unreadable at a
240
- * glance, and it takes a band of the plot to be unreadable in.
285
+ * Dropping labels is the last resort rather than the first. An axis that has
286
+ * turned its labels fits far more of them, so `turnedStep` below is what this
287
+ * is handed once a turn has been decided on, and the stride only starts
288
+ * throwing names away when even the turned ones would overlap.
241
289
  */
242
290
  export declare function tickStride(count: number, available: number, labelWidth: number): number;
243
291
  /**
@@ -261,6 +309,44 @@ export declare function showsTick(index: number, count: number, stride: number,
261
309
  * halves can meet.
262
310
  */
263
311
  export declare function fitsLast(count: number, stride: number, step: number, labelWidth: number): boolean;
312
+ /** How much clear page two flat labels want between them. */
313
+ export declare const LABEL_AIR = 12;
314
+ /**
315
+ * How far a label lies off the horizontal, in degrees.
316
+ *
317
+ * `auto` measures rather than guesses. Flat labels are what a reader takes in
318
+ * fastest, so they are kept while the widest one still fits its slot; past that
319
+ * the choice is between turning them and cutting them, and a name cut to
320
+ * "Onbo…" has lost the thing it was there to say. 45° is tried first because it
321
+ * is the shallower turn and the easier read, and the upright one is taken only
322
+ * where even a turned label's line box would not fit between two ticks.
323
+ *
324
+ * Short labels are left alone whatever the crowding, because an axis of "Jan",
325
+ * "Feb", "Mar" is crowded by how many of them there are rather than by how long
326
+ * any one is — see `TURN_FROM`.
327
+ */
328
+ export declare function tickTurn(mode: MPChartTickLabels | undefined, texts: readonly string[], fontSize: number, slot: number): number;
329
+ /**
330
+ * How much room one turned label needs **along** its axis.
331
+ *
332
+ * A flat label collides with its neighbour across its own width; a turned one
333
+ * collides across its line box instead, opened out by the angle. That is the
334
+ * whole reason turning helps at all — the line box does not grow with the
335
+ * label, so a twenty-character name and a four-character one need the same
336
+ * distance between ticks.
337
+ */
338
+ export declare function turnedStep(angle: number, fontSize: number): number;
339
+ /**
340
+ * How deep a band of turned labels is, for the widest of them.
341
+ *
342
+ * The depth is the label's own width projected onto the axis' normal, plus the
343
+ * half line box that hangs to the side of the anchor. Capped by the caller
344
+ * rather than here: how much of a plot may be given to its labels is a question
345
+ * about the box, and this function has never seen one.
346
+ */
347
+ export declare function turnedBand(angle: number, widest: number, fontSize: number): number;
348
+ /** The widest a label may print at before a band of `depth` would overflow. */
349
+ export declare function turnedRoom(angle: number, depth: number, fontSize: number): number;
264
350
  /** One datum, unpacked into the parts the frame reads. */
265
351
  export interface ChartValue {
266
352
  value: number | null;
@@ -300,6 +386,18 @@ export declare function categoryCount(series: readonly MPChartSeries[]): number;
300
386
  * a numbered axis is a great deal better than a blank one.
301
387
  */
302
388
  export declare function categoryAt(index: number, categories: readonly MPChartCategory[] | undefined, values: readonly (readonly ChartValue[])[]): MPChartCategory;
389
+ /**
390
+ * Which points of one series `valueLabels` writes a number beside, as a test
391
+ * on a point's index.
392
+ *
393
+ * Worked out once per series. Asked of each point in turn, the extremes meant
394
+ * filtering and spreading the whole series again for every point — quadratic in
395
+ * its length, on every render a hover makes.
396
+ *
397
+ * `last` is the index `last` names. Left out, it is the last point that has a
398
+ * value, which is what a line means by it; a bar chart names its last slot.
399
+ */
400
+ export declare function valueLabelTest(series: readonly ChartValue[], mode: MPChartValueLabels, last?: number): (index: number) => boolean;
303
401
  /**
304
402
  * A category as the axis writes it.
305
403
  *
@@ -1 +1 @@
1
- import{dateTimeFormatter as t,numberFormatter as n}from"./intl.js";export const CHART_SLOTS=8;const o=new Set(["primary","secondary","tertiary","error"]);export function seriesColor(t,n){return n?o.has(n)?`var(--_mp-color-${n})`:n:`var(--_mp-chart-${t%8+1})`}export const COMPACT_FROM=1e4;const r={notation:"compact",maximumFractionDigits:1},e={month:"short",day:"numeric"};export function formatStatistic(t,o,e,a){return Number.isFinite(t)?e?n(o,e).format(t):a&&Math.abs(t)>=1e4?n(o,r).format(t):n(o).format(t):""}export function deltaOf(t,n,o){const r=t-n,e=r>0?1:r<0?-1:0;return{absolute:r,percent:0===n?null:r/Math.abs(n)*100,direction:e,good:0!==e&&1===e==("up"===o)}}function a(t,n){if(0===t.length)return"";if(1===t.length)return`M${t[0].x} ${t[0].y}h0`;const o=`M${t[0].x} ${t[0].y}`;if("smooth"===n)return o+function(t){const n=t.length,o=[];for(let r=0;r<n-1;r+=1){const n=t[r+1].x-t[r].x;o.push(0===n?0:(t[r+1].y-t[r].y)/n)}const r=[o[0]??0];for(let t=1;t<n-1;t+=1){const n=o[t-1],e=o[t];r.push(n*e<=0?0:2*n*e/(n+e))}r.push(o[n-2]??0);const e=[];for(let o=0;o<n-1;o+=1){const n=(t[o+1].x-t[o].x)/3;e.push(`C${t[o].x+n} ${t[o].y+r[o]*n} ${t[o+1].x-n} ${t[o+1].y-r[o+1]*n} ${t[o+1].x} ${t[o+1].y}`)}return e.join("")}(t);const r=[];for(let o=1;o<t.length;o+=1)if("step"===n){const n=(t[o-1].x+t[o].x)/2;r.push(`H${n}V${t[o].y}H${t[o].x}`)}else r.push(`L${t[o].x} ${t[o].y}`);return o+r.join("")}export function linePath(t,n){return function(t){const n=[];let o=[];for(const r of t)null===r?(o.length>0&&n.push(o),o=[]):o.push(r);return o.length>0&&n.push(o),n}(t).map(t=>a(t,n)).join("")}export function bandPath(t,n,o){const r=[];let e=[],i=[];const u=()=>{e.length>0&&r.push(`${a(e,o)}${a([...i].reverse(),o).replace(/^M/,"L")}Z`),e=[],i=[]};return t.forEach((t,o)=>{const r=n[o];null!==t&&null!=r?(e.push(t),i.push(r)):u()}),u(),r.join("")}export function areaPath(t,n,o){return bandPath(t,t.map(t=>null===t?null:{x:t.x,y:n}),o)}export function barPath(t,n,o,r,e,a){const i=Math.abs(o),u=Math.abs(r);if(0===i||0===u)return"";const l=Math.max(0,Math.min(e,i/2,u/2)),c="both"===a,s={tl:c||"top"===a||"left"===a?l:0,tr:c||"top"===a||"right"===a?l:0,br:c||"bottom"===a||"right"===a?l:0,bl:c||"bottom"===a||"left"===a?l:0},x=(t,n,o)=>t>0?`a${t} ${t} 0 0 1 ${n} ${o}`:"";return`M${t+s.tl} ${n}h`+(i-s.tl-s.tr)+x(s.tr,s.tr,s.tr)+"v"+(u-s.tr-s.br)+x(s.br,-s.br,s.br)+"h"+-(i-s.bl-s.br)+x(s.bl,-s.bl,-s.bl)+"v"+-(u-s.tl-s.bl)+x(s.tl,s.tl,-s.tl)+"Z"}export function extentOf(t,n,o){const r=t.filter(t=>null!==t&&Number.isFinite(t)),e=n??(r.length>0?Math.min(...r):0),a=o??(r.length>0?Math.max(...r):0);return e===a?{min:e-.5,max:a+.5}:{min:e,max:a}}export function seriesExtent(t,n){let o=1/0,r=-1/0,e=!1;if(n){const n=t.reduce((t,n)=>Math.max(t,n.length),0);for(let a=0;a<n;a+=1){let n=0,i=0;for(const o of t){const t=o[a]?.value;null!=t&&(e=!0,t>=0?n+=t:i+=t)}o=Math.min(o,i),r=Math.max(r,n)}}else for(const n of t)for(const{value:t}of n)null!==t&&(e=!0,o=Math.min(o,t),r=Math.max(r,t));return e?{min:o,max:r}:null}function i(t){const n=10**Math.floor(Math.log10(t)),o=t/n;return o<=1?n:o<=2?2*n:o<=5?5*n:10*n}export function valueScale(t,n={}){const{tickCount:o=5,includeZero:r=!0}=n;let e=n.min??t?.min??0,a=n.max??t?.max??1;if(r&&void 0===n.min&&(e=Math.min(e,0)),r&&void 0===n.max&&(a=Math.max(a,0)),a===e){const t=Math.abs(a)>0?.5*Math.abs(a):1;e-=t,a+=t}const u=void 0!==n.min&&void 0!==n.max?function(t,n){const o=10**Math.floor(Math.log10(t/Math.max(1,n)));let r=i(t/Math.max(1,n)),e=1/0;for(const a of[.1,1,10])for(const i of[1,2,2.5,5]){const u=i*a*o,l=t/u,c=Math.round(l);if(c<1||Math.abs(l-c)>1e-9)continue;const s=Math.abs(c-n);s<e&&(e=s,r=u)}return r}(a-e,o):i((a-e)/Math.max(1,o)),l=void 0!==n.min?e:Math.floor(e/u)*u,c=void 0!==n.max?a:Math.ceil(a/u)*u,s=c-l||1,x=[];for(let t=l;t<=c+1e-9*u;t+=u)x.push(Number(t.toFixed(12)));return{min:l,max:c,ticks:x,fraction:t=>(t-l)/s}}export function bandScale(t,n,o){const r=t>0?n/t:n;return{step:r,band:r*o,centre:t=>r*(t+.5)}}export function textWidth(t,n){let o=0;for(const n of t)o+=/[ᄀ-ᇿ⺀-꓏가-퟿豈-﫿︰-﹏]/.test(n)?1:.6;return o*n}export function truncate(t,n,o){if(n<=0||textWidth(t,o)<=n)return t;const r=n-textWidth("…",o);let e="",a=0;for(const n of t){const t=a+textWidth(n,o);if(t>r)break;a=t,e+=n}return e.length>0?`${e.trimEnd()}…`:"…"}export function tickStride(t,n,o){return t<=1||n<=0?1:Math.max(1,Math.ceil(t/Math.max(1,Math.floor(n/Math.max(1,o)))))}export function showsTick(t,n,o,r){return t%o===0||r&&t===n-1}export function fitsLast(t,n,o,r){const e=(t-1)%n;return e>0&&e*o>=r+8}export function toValue(t){return null==t?{value:null}:"number"==typeof t?{value:Number.isFinite(t)?t:null}:"object"==typeof t&&"y"in t?{value:null!==t.y&&Number.isFinite(t.y)?t.y:null,x:t.x,z:t.z,color:t.color?seriesColor(0,t.color):void 0,label:t.label}:{value:null}}export function toValues(t){return t.map(t=>t.data.map(toValue))}export function toNumber(t){return t instanceof Date?Number.isFinite(t.getTime())?t.getTime():null:"number"==typeof t&&Number.isFinite(t)?t:null}export function categoryCount(t){return t.reduce((t,n)=>Math.max(t,n.data.length),0)}export function categoryAt(t,n,o){if(n&&t<n.length)return n[t];for(const n of o){const o=n[t]?.x;if(void 0!==o)return o}return t}export function formatCategory(o,r){return o instanceof Date?t(r,e).format(o):"number"==typeof o?n(r).format(o):o}export const PLOT_HEIGHT={xs:120,sm:160,md:220,lg:280,xl:360};export const CHART_FONT_SIZE={xs:10,sm:11,md:12,lg:13,xl:14};export const LINE_WIDTH={xs:1.5,sm:1.75,md:2,lg:2.5,xl:3};export const MARKER_RADIUS={xs:3,sm:3.5,md:4,lg:4.5,xl:5};export const MARK_GAP=2;export const BAR_RADIUS=4;export const BAR_MAX_THICKNESS={xs:24,sm:32,md:40,lg:48,xl:56};export const BAR_BAND_RATIO=.72;export function polarPoint(t,n,o,r){return{x:t+o*Math.sin(r),y:n-o*Math.cos(r)}}export function arcPath(t,n,o,r,e,a){const i=a-e;if(Math.abs(i)<1e-9||o<=0)return"";const u=Math.abs(i)>=2*Math.PI-1e-9,l=u?e+2*Math.PI*Math.sign(i||1):a,c=e+(l-e)/2,s=Math.abs(l-e)>Math.PI?1:0,x=l>e?1:0,h=x?0:1,$=polarPoint(t,n,o,e),f=polarPoint(t,n,o,c),m=polarPoint(t,n,o,l),p=u?`A${o} ${o} 0 0 ${x} ${f.x} ${f.y}A${o} ${o} 0 0 ${x} ${m.x} ${m.y}`:`A${o} ${o} 0 ${s} ${x} ${m.x} ${m.y}`;if(r<=0)return u?`M${$.x} ${$.y}${p}Z`:`M${t} ${n}L${$.x} ${$.y}${p}Z`;const M=polarPoint(t,n,r,l),b=polarPoint(t,n,r,c),d=polarPoint(t,n,r,e),y=u?`A${r} ${r} 0 0 ${h} ${b.x} ${b.y}A${r} ${r} 0 0 ${h} ${d.x} ${d.y}`:`A${r} ${r} 0 ${s} ${h} ${d.x} ${d.y}`;return`M${$.x} ${$.y}${p}L${M.x} ${M.y}${y}Z`}export function categoryExtent(t,n){let o=1/0,r=-1/0,e=!1;return t.forEach(t=>{t.forEach((t,a)=>{if(null===t.value)return;const i=toNumber(t.x??n?.[a]??a);null!==i&&(e=!0,o=Math.min(o,i),r=Math.max(r,i))})}),e?{min:o,max:r}:null}export const MARK_SHAPES=["circle","square","triangle","diamond","cross"];const u={circle:1,square:.886,triangle:1.35,diamond:1.25,cross:1.1};export function markPath(t,n,o,r){const e=r*u[t];switch(t){case"square":return`M${n-e} ${o-e}h${2*e}v${2*e}h${2*-e}Z`;case"triangle":return`M${n} ${o-e}L${n+.866*e} ${o+.5*e}L${n-.866*e} ${o+.5*e}Z`;case"diamond":return`M${n} ${o-e}L${n+e} ${o}L${n} ${o+e}L${n-e} ${o}Z`;case"cross":return`M${n-e} ${o-e}L${n+e} ${o+e}M${n+e} ${o-e}L${n-e} ${o+e}`;default:return`M${n-e} ${o}a${e} ${e} 0 1 0 ${2*e} 0a${e} ${e} 0 1 0 ${2*-e} 0Z`}}export function pointX(t,n,o){return toNumber(t.x??o?.[n]??n)}export function bubbleRadius(t,n,o,r){return n<=0||t<=0?r:r+(o-r)*Math.sqrt(Math.min(1,t/n))}export const RAMP_STEPS=5;export function rampStep(t){return Number.isFinite(t)?Math.min(4,Math.max(0,Math.floor(5*t))):0}export function rampFill(t){return`var(--_mp-chart-scale-${Math.min(5,Math.max(1,t+1))})`}export function rampInk(t){return t>=3?"var(--_mp-color-surface)":"var(--_mp-color-on-surface)"}
1
+ import{dateTimeFormatter as t,numberFormatter as n}from"./intl.js";export const CHART_SLOTS=8;const r=new Set(["primary","secondary","tertiary","error"]);export function seriesColor(t,n){return n?r.has(n)?`var(--_mp-color-${n})`:n:`var(--_mp-chart-${t%8+1})`}export const COMPACT_FROM=1e4;const o={notation:"compact",maximumFractionDigits:1},e={month:"short",day:"numeric"},a={style:"percent",maximumFractionDigits:0};export function formatStatistic(t,r,e,a){return Number.isFinite(t)?e?n(r,e).format(t):a&&Math.abs(t)>=1e4?n(r,o).format(t):n(r).format(t):""}export function formatShare(t,r){return Number.isFinite(t)?t>0&&t<.005?`<${n(r,a).format(.01)}`:n(r,a).format(t):""}export function deltaOf(t,n,r){const o=t-n,e=o>0?1:o<0?-1:0;return{absolute:o,percent:0===n?null:o/Math.abs(n)*100,direction:e,good:0!==e&&1===e==("up"===r)}}function u(t,n){if(0===t.length)return"";if(1===t.length)return`M${t[0].x} ${t[0].y}h0`;const r=`M${t[0].x} ${t[0].y}`;if("smooth"===n)return r+function(t){const n=t.length,r=[];for(let o=0;o<n-1;o+=1){const n=t[o+1].x-t[o].x;r.push(0===n?0:(t[o+1].y-t[o].y)/n)}const o=[r[0]??0];for(let t=1;t<n-1;t+=1){const n=r[t-1],e=r[t];o.push(n*e<=0?0:2*n*e/(n+e))}o.push(r[n-2]??0);const e=[];for(let r=0;r<n-1;r+=1){const n=(t[r+1].x-t[r].x)/3;e.push(`C${t[r].x+n} ${t[r].y+o[r]*n} ${t[r+1].x-n} ${t[r+1].y-o[r+1]*n} ${t[r+1].x} ${t[r+1].y}`)}return e.join("")}(t);const o=[];for(let r=1;r<t.length;r+=1)if("step"===n){const n=(t[r-1].x+t[r].x)/2;o.push(`H${n}V${t[r].y}H${t[r].x}`)}else o.push(`L${t[r].x} ${t[r].y}`);return r+o.join("")}export function linePath(t,n){return function(t){const n=[];let r=[];for(const o of t)null===o?(r.length>0&&n.push(r),r=[]):r.push(o);return r.length>0&&n.push(r),n}(t).map(t=>u(t,n)).join("")}export function bridgePath(t){const n=[];let r=null,o=!1;for(const e of t)null!==e?(null!==r&&o&&n.push(`M${r.x} ${r.y}L${e.x} ${e.y}`),r=e,o=!1):o=null!==r;return n.join("")}export const BRIDGE_DASH=3;export function withoutGaps(t){return t.filter(t=>null!==t)}export function bandPath(t,n,r){const o=[];let e=[],a=[];const i=()=>{e.length>0&&o.push(`${u(e,r)}${u([...a].reverse(),r).replace(/^M/,"L")}Z`),e=[],a=[]};return t.forEach((t,r)=>{const o=n[r];null!==t&&null!=o?(e.push(t),a.push(o)):i()}),i(),o.join("")}export function areaPath(t,n,r){return bandPath(t,t.map(t=>null===t?null:{x:t.x,y:n}),r)}export function barPath(t,n,r,o,e,a){const u=Math.abs(r),i=Math.abs(o);if(0===u||0===i)return"";const l=Math.max(0,Math.min(e,u/2,i/2)),c="both"===a,s={tl:c||"top"===a||"left"===a?l:0,tr:c||"top"===a||"right"===a?l:0,br:c||"bottom"===a||"right"===a?l:0,bl:c||"bottom"===a||"left"===a?l:0},x=(t,n,r)=>t>0?`a${t} ${t} 0 0 1 ${n} ${r}`:"";return`M${t+s.tl} ${n}h`+(u-s.tl-s.tr)+x(s.tr,s.tr,s.tr)+"v"+(i-s.tr-s.br)+x(s.br,-s.br,s.br)+"h"+-(u-s.bl-s.br)+x(s.bl,-s.bl,-s.bl)+"v"+-(i-s.tl-s.bl)+x(s.tl,s.tl,-s.tl)+"Z"}export function extentOf(t,n,r){const o=bounds(t.filter(t=>null!==t&&Number.isFinite(t))),e=n??o?.min??0,a=r??o?.max??0;return e===a?{min:e-.5,max:a+.5}:{min:e,max:a}}export function withReferences(t,n){const r=(n??[]).flatMap(t=>[toNumber(t.value),void 0===t.to?null:toNumber(t.to)]).filter(t=>null!==t);return 0===r.length||null===t?t:{min:Math.min(t.min,...r),max:Math.max(t.max,...r)}}export function seriesExtent(t,n){let r=1/0,o=-1/0,e=!1;if(n){const n=t.reduce((t,n)=>Math.max(t,n.length),0);for(let a=0;a<n;a+=1){let n=0,u=0;for(const r of t){const t=r[a]?.value;null!=t&&(e=!0,t>=0?n+=t:u+=t)}r=Math.min(r,u),o=Math.max(o,n)}}else for(const n of t)for(const{value:t}of n)null!==t&&(e=!0,r=Math.min(r,t),o=Math.max(o,t));return e?{min:r,max:o}:null}function i(t){const n=10**Math.floor(Math.log10(t)),r=t/n;return r<=1?n:r<=2?2*n:r<=5?5*n:10*n}export function valueScale(t,n={}){const{tickCount:r=5,includeZero:o=!0}=n;let e=n.min??t?.min??0,a=n.max??t?.max??1;if(o&&void 0===n.min&&(e=Math.min(e,0)),o&&void 0===n.max&&(a=Math.max(a,0)),a===e){const t=Math.abs(a)>0?.5*Math.abs(a):1;e-=t,a+=t}const u=void 0!==n.min&&void 0!==n.max?function(t,n){const r=10**Math.floor(Math.log10(t/Math.max(1,n)));let o=i(t/Math.max(1,n)),e=1/0;for(const a of[.1,1,10])for(const u of[1,2,2.5,5]){const i=u*a*r,l=t/i,c=Math.round(l);if(c<1||Math.abs(l-c)>1e-9)continue;const s=Math.abs(c-n);s<e&&(e=s,o=i)}return o}(a-e,r):i((a-e)/Math.max(1,r)),l=void 0!==n.min?e:Math.floor(e/u)*u,c=void 0!==n.max?a:Math.ceil(a/u)*u,s=c-l||1,x=[];for(let t=l;t<=c+1e-9*u;t+=u)x.push(Number(t.toFixed(12)));return{min:l,max:c,ticks:x,fraction:t=>(t-l)/s}}export function bandScale(t,n,r){const o=t>0?n/t:n;return{step:o,band:o*r,centre:t=>o*(t+.5)}}const l=/[\u1100-\u11FF\u2E80-\uA4CF\uAC00-\uD7FF\uF900-\uFAFF\uFE30-\uFE4F]/;export function bounds(t){let n=1/0,r=-1/0;for(const o of t)o<n&&(n=o),o>r&&(r=o);return n<=r?{min:n,max:r}:null}export function textWidth(t,n){let r=0;for(const n of t)r+=l.test(n)?1:.6;return r*n}export function truncate(t,n,r){if(n<=0||textWidth(t,r)<=n)return t;const o=n-textWidth("…",r);let e="",a=0;for(const n of t){const t=a+textWidth(n,r);if(t>o)break;a=t,e+=n}return e.length>0?`${e.trimEnd()}…`:"…"}export function tickStride(t,n,r){return t<=1||n<=0?1:Math.max(1,Math.ceil(t/Math.max(1,Math.floor(n/Math.max(1,r)))))}export function showsTick(t,n,r,o){return t%r===0||o&&t===n-1}export function fitsLast(t,n,r,o){const e=(t-1)%n;return e>0&&e*r>=o+8}export const LABEL_AIR=12;const c=1.35;export function tickTurn(t,n,r,o){if("rotate"===t)return 45;if("vertical"===t)return 90;if("truncate"===t||void 0===t)return 0;const e=n.reduce((t,n)=>Math.max(t,textWidth(n,r)),0);return e+12<=o||e<3*r?0:o>=turnedStep(45,r)?45:90}export function turnedStep(t,n){const r=t*Math.PI/180;return n*c/Math.max(.2,Math.sin(r))}export function turnedBand(t,n,r){const o=t*Math.PI/180;return n*Math.sin(o)+r*c*Math.cos(o)/2}export function turnedRoom(t,n,r){const o=t*Math.PI/180;return(n-r*c*Math.cos(o)/2)/Math.max(.2,Math.sin(o))}export function toValue(t){return null==t?{value:null}:"number"==typeof t?{value:Number.isFinite(t)?t:null}:"object"==typeof t&&"y"in t?{value:null!==t.y&&Number.isFinite(t.y)?t.y:null,x:t.x,z:t.z,color:t.color?seriesColor(0,t.color):void 0,label:t.label}:{value:null}}export function toValues(t){return t.map(t=>t.data.map(toValue))}export function toNumber(t){return t instanceof Date?Number.isFinite(t.getTime())?t.getTime():null:"number"==typeof t&&Number.isFinite(t)?t:null}export function categoryCount(t){return t.reduce((t,n)=>Math.max(t,n.data.length),0)}export function categoryAt(t,n,r){if(n&&t<n.length)return n[t];for(const n of r){const r=n[t]?.x;if(void 0!==r)return r}return t}export function valueLabelTest(t,n,r){if("all"===n)return()=>!0;if("last"===n){let n=r??-1;if(void 0===r)for(let r=t.length-1;r>=0;r--)if(null!==t[r].value){n=r;break}return t=>t===n}if("extremes"!==n)return()=>!1;let o=1/0,e=-1/0;for(const n of t)null!==n.value&&(o=Math.min(o,n.value),e=Math.max(e,n.value));return n=>t[n]?.value===o||t[n]?.value===e}export function formatCategory(r,o){return r instanceof Date?t(o,e).format(r):"number"==typeof r?n(o).format(r):r}export const PLOT_HEIGHT={xs:120,sm:160,md:220,lg:280,xl:360};export const CHART_FONT_SIZE={xs:10,sm:11,md:12,lg:13,xl:14};export const LINE_WIDTH={xs:1.5,sm:1.75,md:2,lg:2.5,xl:3};export const MARKER_RADIUS={xs:3,sm:3.5,md:4,lg:4.5,xl:5};export const MARK_GAP=2;export const BAR_RADIUS=4;export const BAR_MAX_THICKNESS={xs:24,sm:32,md:40,lg:48,xl:56};export const BAR_BAND_RATIO=.72;export function polarPoint(t,n,r,o){return{x:t+r*Math.sin(o),y:n-r*Math.cos(o)}}export function arcPath(t,n,r,o,e,a){const u=a-e;if(Math.abs(u)<1e-9||r<=0)return"";const i=Math.abs(u)>=2*Math.PI-1e-9,l=i?e+2*Math.PI*Math.sign(u||1):a,c=e+(l-e)/2,s=Math.abs(l-e)>Math.PI?1:0,x=l>e?1:0,f=x?0:1,m=polarPoint(t,n,r,e),h=polarPoint(t,n,r,c),$=polarPoint(t,n,r,l),p=i?`A${r} ${r} 0 0 ${x} ${h.x} ${h.y}A${r} ${r} 0 0 ${x} ${$.x} ${$.y}`:`A${r} ${r} 0 ${s} ${x} ${$.x} ${$.y}`;if(o<=0)return i?`M${m.x} ${m.y}${p}Z`:`M${t} ${n}L${m.x} ${m.y}${p}Z`;const M=polarPoint(t,n,o,l),b=polarPoint(t,n,o,c),d=polarPoint(t,n,o,e),y=i?`A${o} ${o} 0 0 ${f} ${b.x} ${b.y}A${o} ${o} 0 0 ${f} ${d.x} ${d.y}`:`A${o} ${o} 0 ${s} ${f} ${d.x} ${d.y}`;return`M${m.x} ${m.y}${p}L${M.x} ${M.y}${y}Z`}export function categoryExtent(t,n){let r=1/0,o=-1/0,e=!1;return t.forEach(t=>{t.forEach((t,a)=>{if(null===t.value)return;const u=toNumber(t.x??n?.[a]??a);null!==u&&(e=!0,r=Math.min(r,u),o=Math.max(o,u))})}),e?{min:r,max:o}:null}export const MARK_SHAPES=["circle","square","triangle","diamond","cross"];const s={circle:1,square:.886,triangle:1.35,diamond:1.25,cross:1.1};export function markPath(t,n,r,o){const e=o*s[t];switch(t){case"square":return`M${n-e} ${r-e}h${2*e}v${2*e}h${2*-e}Z`;case"triangle":return`M${n} ${r-e}L${n+.866*e} ${r+.5*e}L${n-.866*e} ${r+.5*e}Z`;case"diamond":return`M${n} ${r-e}L${n+e} ${r}L${n} ${r+e}L${n-e} ${r}Z`;case"cross":return`M${n-e} ${r-e}L${n+e} ${r+e}M${n+e} ${r-e}L${n-e} ${r+e}`;default:return`M${n-e} ${r}a${e} ${e} 0 1 0 ${2*e} 0a${e} ${e} 0 1 0 ${2*-e} 0Z`}}export function pointX(t,n,r){return toNumber(t.x??r?.[n]??n)}export function bubbleRadius(t,n,r,o){return n<=0||t<=0?o:o+(r-o)*Math.sqrt(Math.min(1,t/n))}export const RAMP_STEPS=5;export function rampStep(t){return Number.isFinite(t)?Math.min(4,Math.max(0,Math.floor(5*t))):0}export function rampFill(t){return`var(--_mp-chart-scale-${Math.min(5,Math.max(1,t+1))})`}export function rampInk(t){return t>=3?"var(--_mp-color-surface)":"var(--_mp-color-on-surface)"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The two names the scheme switch and its `<head>` script agree on.
3
+ *
4
+ * Kept apart from `internal/color-scheme.ts`, which is a store and imports
5
+ * React, so that `mpColorSchemeScript` can import them without importing React
6
+ * too. A module that imports React is marked `"use client"` by the build, and a
7
+ * function exported from one cannot be called from a server component — which
8
+ * is the one place the script is meant to be written.
9
+ */
10
+ /** The attribute on the document element that forces a scheme. */
11
+ export declare const SCHEME_ATTRIBUTE = "data-mp-scheme";
12
+ /** Where a page's choice is remembered, unless told otherwise. */
13
+ export declare const DEFAULT_STORAGE_KEY = "mp-color-scheme";
@@ -0,0 +1 @@
1
+ export const SCHEME_ATTRIBUTE="data-mp-scheme";export const DEFAULT_STORAGE_KEY="mp-color-scheme";
@@ -1,9 +1,18 @@
1
+ import { DEFAULT_STORAGE_KEY, SCHEME_ATTRIBUTE } from './color-scheme-keys.js';
1
2
  /** What a page can be set to. `'system'` is the absence of a choice. */
2
3
  export type MPColorScheme = 'light' | 'dark' | 'system';
3
4
  /** What is actually painted, once `'system'` has been resolved. */
4
5
  export type MPResolvedColorScheme = 'light' | 'dark';
5
- export declare const SCHEME_ATTRIBUTE = "data-mp-scheme";
6
- export declare const DEFAULT_STORAGE_KEY = "mp-color-scheme";
6
+ export { DEFAULT_STORAGE_KEY, SCHEME_ATTRIBUTE };
7
+ /**
8
+ * Puts the choice on the document element, or takes it off.
9
+ *
10
+ * `'system'` **removes** the attribute rather than writing it, which is the
11
+ * whole of how the media query gets its say back: the dark block is reached
12
+ * either by `prefers-color-scheme` on a root that is not forced light, or by the
13
+ * attribute. An attribute spelling out `system` would match neither.
14
+ */
15
+ export declare function applyScheme(scheme: MPColorScheme): void;
7
16
  export declare function setScheme(storageKey: string, scheme: MPColorScheme): void;
8
17
  export declare function useChosenScheme(storageKey: string): MPColorScheme;
9
18
  /**
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import*as e from"react";export const SCHEME_ATTRIBUTE="data-mp-scheme";export const DEFAULT_STORAGE_KEY="mp-color-scheme";const t="(prefers-color-scheme: dark)";function n(e){return"light"===e||"dark"===e||"system"===e}let o;const r=new Set;function c(){for(const e of r)e()}export function setScheme(e,t){o=t,function(e,t){try{"system"===t?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}(e,t),function(e){if("undefined"==typeof document)return;const t=document.documentElement;"system"===e?t.removeAttribute("data-mp-scheme"):t.setAttribute("data-mp-scheme",e)}(t),c()}function s(e){return r.add(e),()=>{r.delete(e)}}function u(e){return o??=function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("data-mp-scheme");return n(e)&&"system"!==e?e:void 0}()??function(e){try{if("undefined"==typeof localStorage)return"system";const t=localStorage.getItem(e);return n(t)?t:"system"}catch{return"system"}}(e),o}export function useChosenScheme(t){const n=e.useCallback(()=>u(t),[t]);return e.useSyncExternalStore(s,n,()=>"system")}function m(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const n=window.matchMedia(t);return n.addEventListener("change",e),()=>n.removeEventListener("change",e)}function i(){return"undefined"!=typeof window&&window.matchMedia?.(t).matches?"dark":"light"}export function useSystemScheme(){return e.useSyncExternalStore(m,i,()=>"light")}export function resetScheme(){o=void 0,c()}
2
+ import*as e from"react";import{DEFAULT_STORAGE_KEY as t,SCHEME_ATTRIBUTE as n}from"./color-scheme-keys.js";import{mediaList as o}from"./media.js";export{t as DEFAULT_STORAGE_KEY,n as SCHEME_ATTRIBUTE};const r="(prefers-color-scheme: dark)";function c(e){return"light"===e||"dark"===e||"system"===e}let u;const s=new Set;function m(){for(const e of s)e()}export function applyScheme(e){if("undefined"==typeof document)return;const t=document.documentElement;"system"===e?t.removeAttribute(n):t.setAttribute(n,e)}export function setScheme(e,t){u=t,function(e,t){try{"system"===t?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}(e,t),applyScheme(t),m()}function i(e){return s.add(e),()=>{s.delete(e)}}function f(e){return u??=function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute(n);return c(e)&&"system"!==e?e:void 0}()??function(e){try{if("undefined"==typeof localStorage)return"system";const t=localStorage.getItem(e);return c(t)?t:"system"}catch{return"system"}}(e),u}export function useChosenScheme(t){const n=e.useCallback(()=>f(t),[t]);return e.useSyncExternalStore(i,n,()=>"system")}function a(e){if("undefined"==typeof window||!window.matchMedia)return()=>{};const t=o(r);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)}function d(){return o(r)?.matches?"dark":"light"}export function useSystemScheme(){return e.useSyncExternalStore(a,d,()=>"light")}export function resetScheme(){u=void 0,m()}
@@ -41,6 +41,8 @@ export interface MPConfigValue {
41
41
  * and cannot be.
42
42
  */
43
43
  breakpoints?: Partial<Record<MPWindowClass, number>>;
44
+ /** Whether a field keeps a line under itself for a message it has not got yet. */
45
+ reserveSupportingText?: boolean;
44
46
  }
45
47
  export declare const MPConfigContext: React.Context<MPConfigValue>;
46
48
  /** The configuration in force at this point in the tree. */
@@ -214,14 +214,8 @@ export declare function weekdayLabels(locale: string | undefined, weekStartsOn:
214
214
  /** The twelve month names, January first, in the locale's own words. */
215
215
  export declare function monthLabels(locale: string | undefined, month?: 'short' | 'long'): readonly string[];
216
216
  /**
217
- * Does this locale write the month before the year?
218
- *
219
- * The calendar's header is two separate buttons — one that opens the month grid
220
- * and one that opens the year grid — so it cannot just print what `Intl` gives
221
- * it. Asking `formatToParts` which part came first is how the two buttons end up
222
- * in the order the reader expects: `July 2026` in English, `2026년 7월` in
223
- * Korean. Getting this wrong is subtle and reads as broken to exactly the people
224
- * it is wrong for.
217
+ * Cached on the locale for the reason `isHour12` is: a calendar's header asks
218
+ * on every render, and `formatToParts` builds a fresh array of parts each time.
225
219
  */
226
220
  export declare function isMonthBeforeYear(locale: string | undefined): boolean;
227
221
  export declare function isHour12(locale: string | undefined): boolean;
@@ -1 +1 @@
1
- import{dateTimeFormatter as t,remember as e}from"./intl.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,r){const n=new Date(0);return n.setFullYear(t,e,r),n.setHours(0,0,0,0),n}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function startOfUnit(t,e){return"year"===e?function(t){return makeDate(t.getFullYear(),0,1)}(t):"month"===e?startOfMonth(t):startOfDay(t)}export function today(){return startOfDay(new Date)}export function addDays(t,e){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}export function addMonths(t,e){const r=new Date(t.getTime()),n=makeDate(t.getFullYear(),t.getMonth()+e,1);var o,a;return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),(o=n.getFullYear(),a=n.getMonth(),makeDate(o,a+1,0).getDate()))),r}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function isDayOutside(t,e,r){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(r)&&compareDay(t,r)>0}export function isUnitOutside(t,e,r,n){return"day"===e?isDayOutside(t,r,n):!!(isValidDate(r)&&compareDay(function(t,e){return"year"===e?makeDate(t.getFullYear(),11,31):"month"===e?makeDate(t.getFullYear(),t.getMonth()+1,0):startOfDay(t)}(t,e),r)<0)||isValidDate(n)&&compareDay(startOfUnit(t,e),n)>0}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const r=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(r/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(r/60);return[t,t+59]}if("second"===t)return[r,r];const n=e.getHours()<12?0:43200;return[n,n+43200-1]}export function withTime(t,e){const r=new Date(t.getTime());return r.setHours(e.hours??r.getHours(),e.minutes??r.getMinutes(),e.seconds??r.getSeconds(),0),r}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const r=startOfMonth(t),n=(r.getDay()-e+7)%7,o=addDays(r,-n);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,r)=>addDays(o,7*e+r)))}export function yearPageStart(t){return t-(t%12+12)%12}export function dateFormatter(e,r){return t(e,r)}export function formatDate(t,e,r){return isValidDate(t)?dateFormatter(e,r).format(t):""}const r=Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(t,e){const n=dateFormatter(t,e);return[...new Set(r.map(t=>n.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISOYear(t){return String(t.getFullYear()).padStart(4,"0")}export function toISOMonth(t){return`${toISOYear(t)}-${String(t.getMonth()+1).padStart(2,"0")}`}export function toISODate(t){return`${toISOMonth(t)}-${String(t.getDate()).padStart(2,"0")}`}export const TO_ISO={day:toISODate,month:toISOMonth,year:toISOYear};export function toISOTime(t,e=!1){const r=t=>String(t).padStart(2,"0"),n=`${r(t.getHours())}:${r(t.getMinutes())}`;return e?`${n}:${r(t.getSeconds())}`:n}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const n=makeDate(2021,7,1),o=new Map;export function weekdayLabels(t,r,a="narrow"){const i=`w ${t??""} ${r} ${a}`,u=o.get(i);if(u)return u;const s=dateFormatter(t,{weekday:a});return e(o,i,Array.from({length:7},(t,e)=>s.format(addDays(n,(r+e)%7))))}export function monthLabels(t,r="short"){const n=`m ${t??""} ${r}`,a=o.get(n);if(a)return a;const i=dateFormatter(t,{month:r});return e(o,n,Array.from({length:12},(t,e)=>i.format(makeDate(2021,e,1))))}export function isMonthBeforeYear(t){const e=dateFormatter(t,{year:"numeric",month:"long"}).formatToParts(n);return e.findIndex(t=>"month"===t.type)<e.findIndex(t=>"year"===t.type)}const a=new Map;export function isHour12(t){const r=t??"",n=a.get(r);if(void 0!==n)return n;const o=dateFormatter(t,{hour:"numeric"}).resolvedOptions(),i=o.hourCycle?"h11"===o.hourCycle||"h12"===o.hourCycle:!0===o.hour12;return e(a,r,i)}export function meridiemLabels(t){const e=dateFormatter(t,{hour:"numeric",hour12:!0}),r=t=>{const r=e.formatToParts(withTime(n,{hours:t})).find(t=>"dayPeriod"===t.type);return r?.value??(t<12?"AM":"PM")};return[r(9),r(21)]}const i=new Map;export function localeWeekStart(t){const r=t??"",n=i.get(r);return void 0!==n?n:e(i,r,function(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,r=new Intl.Locale(e),n="function"==typeof r.getWeekInfo?r.getWeekInfo():r.weekInfo;if("number"==typeof n?.firstDay)return n.firstDay%7}catch{}return 0}(t))}
1
+ import{checkServerLocale as t,dateTimeFormatter as e,remember as r}from"./intl.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,r){const n=new Date(0);return n.setFullYear(t,e,r),n.setHours(0,0,0,0),n}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function startOfUnit(t,e){return"year"===e?function(t){return makeDate(t.getFullYear(),0,1)}(t):"month"===e?startOfMonth(t):startOfDay(t)}export function today(){return startOfDay(new Date)}export function addDays(t,e){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}export function addMonths(t,e){const r=new Date(t.getTime()),n=makeDate(t.getFullYear(),t.getMonth()+e,1);var o,a;return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),(o=n.getFullYear(),a=n.getMonth(),makeDate(o,a+1,0).getDate()))),r}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function isDayOutside(t,e,r){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(r)&&compareDay(t,r)>0}export function isUnitOutside(t,e,r,n){return"day"===e?isDayOutside(t,r,n):!!(isValidDate(r)&&compareDay(function(t,e){return"year"===e?makeDate(t.getFullYear(),11,31):"month"===e?makeDate(t.getFullYear(),t.getMonth()+1,0):startOfDay(t)}(t,e),r)<0)||isValidDate(n)&&compareDay(startOfUnit(t,e),n)>0}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const r=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(r/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(r/60);return[t,t+59]}if("second"===t)return[r,r];const n=e.getHours()<12?0:43200;return[n,n+43200-1]}export function withTime(t,e){const r=new Date(t.getTime());return r.setHours(e.hours??r.getHours(),e.minutes??r.getMinutes(),e.seconds??r.getSeconds(),0),r}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const r=startOfMonth(t),n=(r.getDay()-e+7)%7,o=addDays(r,-n);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,r)=>addDays(o,7*e+r)))}export function yearPageStart(t){return t-(t%12+12)%12}export function dateFormatter(t,r){return e(t,r)}export function formatDate(t,e,r){return isValidDate(t)?dateFormatter(e,r).format(t):""}const n=Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(t,e){const r=dateFormatter(t,e);return[...new Set(n.map(t=>r.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISOYear(t){return String(t.getFullYear()).padStart(4,"0")}export function toISOMonth(t){return`${toISOYear(t)}-${String(t.getMonth()+1).padStart(2,"0")}`}export function toISODate(t){return`${toISOMonth(t)}-${String(t.getDate()).padStart(2,"0")}`}export const TO_ISO={day:toISODate,month:toISOMonth,year:toISOYear};export function toISOTime(t,e=!1){const r=t=>String(t).padStart(2,"0"),n=`${r(t.getHours())}:${r(t.getMinutes())}`;return e?`${n}:${r(t.getSeconds())}`:n}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const o=makeDate(2021,7,1),a=new Map;export function weekdayLabels(t,e,n="narrow"){const i=`w ${t??""} ${e} ${n}`,u=a.get(i);if(u)return u;const s=dateFormatter(t,{weekday:n});return r(a,i,Array.from({length:7},(t,r)=>s.format(addDays(o,(e+r)%7))))}export function monthLabels(t,e="short"){const n=`m ${t??""} ${e}`,o=a.get(n);if(o)return o;const i=dateFormatter(t,{month:e});return r(a,n,Array.from({length:12},(t,e)=>i.format(makeDate(2021,e,1))))}const i=new Map;export function isMonthBeforeYear(t){const e=t??"",n=i.get(e);if(void 0!==n)return n;const a=dateFormatter(t,{year:"numeric",month:"long"}).formatToParts(o);return r(i,e,a.findIndex(t=>"month"===t.type)<a.findIndex(t=>"year"===t.type))}const u=new Map;export function isHour12(t){const e=t??"",n=u.get(e);if(void 0!==n)return n;const o=dateFormatter(t,{hour:"numeric"}).resolvedOptions(),a=o.hourCycle?"h11"===o.hourCycle||"h12"===o.hourCycle:!0===o.hour12;return r(u,e,a)}export function meridiemLabels(t){const e=dateFormatter(t,{hour:"numeric",hour12:!0}),r=t=>{const r=e.formatToParts(withTime(o,{hours:t})).find(t=>"dayPeriod"===t.type);return r?.value??(t<12?"AM":"PM")};return[r(9),r(21)]}const s=new Map;export function localeWeekStart(e){const n=e??"",o=s.get(n);return void 0!==o?o:r(s,n,function(e){t(e);try{const t=e??(new Intl.DateTimeFormat).resolvedOptions().locale,r=new Intl.Locale(t),n="function"==typeof r.getWeekInfo?r.getWeekInfo():r.weekInfo;if("number"==typeof n?.firstDay)return n.firstDay%7}catch{}return 0}(e))}
@@ -1 +1 @@
1
- const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",golang:"go",gql:"graphql",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;let g=null;const s=new Map;export function registerMPLanguage(i,t){const g=i.toLowerCase();l.set(g,t),s.delete(g)}export function canonicalLanguage(i){if(!i)return null;const l=i.trim().toLowerCase();return l?t[l]??l:null}export async function highlightCode(t,a){let e=s.get(a);e||(e=async function(t){const s=l.get(t),a=s?void 0:i[t];if(!s&&!a)return null;g??=import("highlight.js/lib/core").then(i=>i.default);const e=await g;return s?e.registerLanguage(t,s):e.getLanguage(t)||e.registerLanguage(t,(await a()).default),t}(a).catch(i=>{throw s.delete(a),i}),s.set(a,e));const h=await e;if(!h||!g)return null;return tokenize((await g).highlight(t,{language:h,ignoreIllegals:!0}).value)}const a={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"};export function tokenize(i){const t=[[]],l=[],g=/<span class="([^"]*)">|<\/span>/g;let s=0;const e=i=>{if(!i)return;const g=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>a[i]).split("\n").forEach((i,l)=>{l>0&&t.push([]),i&&t[t.length-1].push(g?{text:i,token:g}:{text:i})})};for(const t of i.matchAll(g))e(i.slice(s,t.index)),s=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return e(i.slice(s)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
1
+ const i={bash:()=>import("highlight.js/lib/languages/bash"),c:()=>import("highlight.js/lib/languages/c"),cpp:()=>import("highlight.js/lib/languages/cpp"),csharp:()=>import("highlight.js/lib/languages/csharp"),css:()=>import("highlight.js/lib/languages/css"),diff:()=>import("highlight.js/lib/languages/diff"),dockerfile:()=>import("highlight.js/lib/languages/dockerfile"),go:()=>import("highlight.js/lib/languages/go"),graphql:()=>import("highlight.js/lib/languages/graphql"),ini:()=>import("highlight.js/lib/languages/ini"),java:()=>import("highlight.js/lib/languages/java"),javascript:()=>import("highlight.js/lib/languages/javascript"),json:()=>import("highlight.js/lib/languages/json"),kotlin:()=>import("highlight.js/lib/languages/kotlin"),less:()=>import("highlight.js/lib/languages/less"),lua:()=>import("highlight.js/lib/languages/lua"),makefile:()=>import("highlight.js/lib/languages/makefile"),markdown:()=>import("highlight.js/lib/languages/markdown"),objectivec:()=>import("highlight.js/lib/languages/objectivec"),perl:()=>import("highlight.js/lib/languages/perl"),php:()=>import("highlight.js/lib/languages/php"),plaintext:()=>import("highlight.js/lib/languages/plaintext"),powershell:()=>import("highlight.js/lib/languages/powershell"),python:()=>import("highlight.js/lib/languages/python"),r:()=>import("highlight.js/lib/languages/r"),ruby:()=>import("highlight.js/lib/languages/ruby"),rust:()=>import("highlight.js/lib/languages/rust"),scss:()=>import("highlight.js/lib/languages/scss"),shell:()=>import("highlight.js/lib/languages/shell"),sql:()=>import("highlight.js/lib/languages/sql"),swift:()=>import("highlight.js/lib/languages/swift"),typescript:()=>import("highlight.js/lib/languages/typescript"),xml:()=>import("highlight.js/lib/languages/xml"),yaml:()=>import("highlight.js/lib/languages/yaml")},t={"c++":"cpp",cc:"cpp",cjs:"javascript",console:"bash",cs:"csharp",cts:"typescript",docker:"dockerfile",golang:"go",gql:"graphql",h:"cpp",hpp:"cpp",htm:"xml",html:"xml",js:"javascript",jsx:"javascript",kt:"kotlin",kts:"kotlin",md:"markdown",mdx:"markdown",mjs:"javascript",mm:"objectivec",mts:"typescript",mysql:"sql",node:"javascript",none:"plaintext",objc:"objectivec",plain:"plaintext",posh:"powershell",ps1:"powershell",psql:"sql",py:"python",rb:"ruby",rs:"rust",sh:"bash",svelte:"xml",svg:"xml",text:"plaintext",toml:"ini",ts:"typescript",tsx:"typescript",txt:"plaintext",vue:"xml",yml:"yaml",zsh:"bash"},l=new Map;let s=null;const g=new Map;export function registerMPLanguage(i,t){const s=i.toLowerCase();l.set(s,t),g.delete(s)}export function canonicalLanguage(i){if(!i)return null;const l=i.trim().toLowerCase();return l?t[l]??l:null}export async function highlightCode(t,e){let a=g.get(e);a||(a=async function(t){const g=l.get(t),e=g?void 0:i[t];if(!g&&!e)return null;s??=import("highlight.js/lib/core").then(i=>i.default);const a=await s;return g?a.registerLanguage(t,g):a.getLanguage(t)||a.registerLanguage(t,(await e()).default),t}(e).catch(i=>{throw g.delete(e),i}),g.set(e,a));const h=await a;if(!h||!s)return null;const n=await s;return await function(){const i=globalThis.scheduler;return i?.yield?i.yield():new Promise(i=>setTimeout(i,0))}(),tokenize(n.highlight(t,{language:h,ignoreIllegals:!0}).value)}const e={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#x27;":"'"};export function tokenize(i){const t=[[]],l=[],s=/<span class="([^"]*)">|<\/span>/g;let g=0;const a=i=>{if(!i)return;const s=l[l.length-1];i.replace(/&(?:amp|lt|gt|quot|#x27);/g,i=>e[i]).split("\n").forEach((i,l)=>{l>0&&t.push([]),i&&t[t.length-1].push(s?{text:i,token:s}:{text:i})})};for(const t of i.matchAll(s))a(i.slice(g,t.index)),g=t.index+t[0].length,void 0===t[1]?l.pop():l.push(t[1]);return a(i.slice(g)),t}export function plainLines(i){return i.split("\n").map(i=>i?[{text:i}]:[])}
@@ -1,56 +1,3 @@
1
- /**
2
- * The words the library says on its own behalf.
3
- *
4
- * Almost nothing in Material Plus writes text a reader sees — a button says
5
- * whatever it was handed, a dialog's title is the caller's. The exceptions are
6
- * the strings a component has to invent because there is nowhere else for them
7
- * to come from: the name on a calendar's back arrow, the word on the button that
8
- * empties a picker, the label a screen reader hears for a column of minutes.
9
- *
10
- * Those are collected here rather than defaulted inside each component, because
11
- * they are a *set*. A product in Korean does not want four pickers each
12
- * defaulting to English and each needing eighteen override props; and the next
13
- * component that needs a word should get it from the same place rather than
14
- * starting a second table beside this one.
15
- *
16
- * What is *not* in here is anything `Intl` already knows. Month names, weekday
17
- * names, AM/PM and number formats come from the platform, which speaks more
18
- * languages than this file ever will — see `internal/date.ts`. This is only for
19
- * the words the platform has no opinion about.
20
- *
21
- * Every component that reads this takes a `locale` and an override prop for the
22
- * strings themselves, so an unsupported language is never a dead end: `locale`
23
- * gets you a translation, `MPLocaleProvider` gets you one for the whole
24
- * application at once, and the prop gets you one for anything else.
25
- *
26
- * ## Where the words themselves are
27
- *
28
- * Not here. This file is the shape of the table, the registry a translation
29
- * arrives through, and the merge — no strings.
30
- *
31
- * The eighteen translations live under `src/locales/`, and nothing in the
32
- * library imports them. They used to be here, and being here is what made them
33
- * cost something: a component that says one word — `MPButton` says *Loading* —
34
- * held a static import chain down to a table of every string in every language,
35
- * and a bundler cannot drop data that something imports. Twenty kilobytes, on
36
- * every consumer, for a word. So the table arrives from the outside instead:
37
- * `registerMPMessages` below is how, `material-plus-ui/locales` is where from,
38
- * and the only thing that changed for a reader is that the application now names
39
- * the languages it speaks. Once it has, `locale="ko"` resolves through exactly
40
- * the path it always did.
41
- *
42
- * English left too, for the same reason one step smaller. It is thirteen modules
43
- * under `internal/messages/`, one per namespace, because a bundler that can drop
44
- * a module it can also drop an export — and cannot drop a property. Held as one
45
- * object, English was 1.75 kB that every component carried whole: `MPButton`
46
- * shipped the calendar's eighteen strings to say *Loading*. `resolveNamespace`
47
- * is handed the namespace it should merge, so a component pays for the words it
48
- * speaks and no others.
49
- *
50
- * The public surface is `registerMPMessages`, `MPLocaleProvider` and the
51
- * per-component `labels` props; `resolveNamespace` and `fillMessage` stay
52
- * internal.
53
- */
54
1
  /**
55
2
  * One namespace per component, rather than one flat list of keys.
56
3
  *
@@ -302,6 +249,10 @@ export interface MPMessages {
302
249
  table: string;
303
250
  /** The heading over that table's first column. */
304
251
  category: string;
252
+ /** The row a hover panel adds for what a stacked column adds up to. */
253
+ total: string;
254
+ /** The control that undoes a range the reader dragged out of the axis. */
255
+ showAll: string;
305
256
  };
306
257
  sparkline: {
307
258
  summary: string;
@@ -1 +1 @@
1
- const e=new Map;export function registerMPMessages(...s){for(const t of s){e.set(t.locale.toLowerCase(),t.messages);for(const s of t.aliases??[])e.set(s.toLowerCase(),t.messages)}t.clear()}const t=new Map;export function resolveNamespace(s,n){const o=n?.trim()??"",r=`${s.name}\0${o}`,a=t.get(r);if(a)return a;const c=function(e){const t=e.toLowerCase().split(/[-_]/).filter(Boolean),s=t[0];if(!s)return[];const n=t.slice(1),o=n.find(e=>/^[a-z]{4}$/.test(e)),r=n.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[o?`${s}-${o}`:"",r?`${s}-${r}`:"",s].filter(Boolean)}(o).map(t=>e.get(t)).find(Boolean),i=c?.[s.name],f=i?{...s.en,...i}:s.en;return t.set(r,f),f}export function fillMessage(e,t){return e.replace(/\{(\w+)\}/g,(e,s)=>t[s]??e)}
1
+ import{remember as e}from"./remember.js";const t=new Map;export function registerMPMessages(...e){for(const o of e){t.set(o.locale.toLowerCase(),o.messages);for(const e of o.aliases??[])t.set(e.toLowerCase(),o.messages)}o.clear()}const o=new Map;export function resolveNamespace(s,n){const r=n?.trim()??"",a=`${s.name}\0${r}`,i=o.get(a);if(i)return i;const c=function(e){const t=e.toLowerCase().split(/[-_]/).filter(Boolean),o=t[0];if(!o)return[];const s=t.slice(1),n=s.find(e=>/^[a-z]{4}$/.test(e)),r=s.find(e=>/^([a-z]{2}|\d{3})$/.test(e));return[n?`${o}-${n}`:"",r?`${o}-${r}`:"",o].filter(Boolean)}(r).map(e=>t.get(e)).find(Boolean),f=c?.[s.name],l=f?{...s.en,...f}:s.en;return e(o,a,l)}export function fillMessage(e,t){return e.replace(/\{(\w+)\}/g,(e,o)=>t[o]??e)}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * One `IntersectionObserver` per set of options, shared by everything here that
3
+ * asks whether it is on screen.
4
+ *
5
+ * An observer is not free. Each one is checked by the browser on every frame
6
+ * the page scrolls, and every `MPAnimate*` with `trigger="visible"`, every
7
+ * `useMPOnScreen` and every indeterminate progress indicator used to bring its
8
+ * own — so a landing page of forty fading cards was forty observers asking the
9
+ * same question at the same threshold. One observer watching forty elements
10
+ * answers it once per frame, and delivers exactly the entries the forty would
11
+ * have: observing an element always queues a first entry for that element,
12
+ * shared observer or not.
13
+ *
14
+ * The one case sharing changes is a second question about an element that is
15
+ * already observed. Observing it again queues nothing, so the latest entry for
16
+ * each element is kept and handed to a listener that joins after the first one
17
+ * was delivered.
18
+ *
19
+ * Keyed on what changes the answer, the threshold and the root margin, so two
20
+ * callers that asked different questions still get different observers.
21
+ */
22
+ import * as React from 'react';
23
+ type Listener = (entry: IntersectionObserverEntry) => void;
24
+ export interface IntersectionOptions {
25
+ threshold?: number;
26
+ rootMargin?: string;
27
+ }
28
+ /**
29
+ * Calls `listener` with every intersection entry for `element`, starting with
30
+ * the first one the browser reports. Returns the function that stops it.
31
+ *
32
+ * Callers check for `IntersectionObserver` themselves first, because each has
33
+ * its own answer for a browser without one.
34
+ */
35
+ export declare function watchIntersection(element: Element, listener: Listener, { threshold, rootMargin }?: IntersectionOptions): () => void;
36
+ /**
37
+ * Holds an endless CSS animation while its element is off screen.
38
+ *
39
+ * A loop nobody can see is still a loop the browser runs: a style pass every
40
+ * frame for the glow's custom property, and a layout pass for the linear
41
+ * indicator's bars, which move by `inset`. Marking the element lets the
42
+ * stylesheet set `animation-play-state: paused` on whatever part of it moves,
43
+ * and taking the mark off lets it carry on from where it stopped — which, for
44
+ * a loop, is indistinguishable from never having stopped.
45
+ *
46
+ * Written as an attribute straight onto the element rather than as state, so
47
+ * scrolling past one is not a render.
48
+ */
49
+ export declare function useOffscreenPause(enabled: boolean): React.RefObject<Element | null>;
50
+ export {};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import*as e from"react";const t=new Map;export function watchIntersection(e,r,{threshold:n=0,rootMargin:s="0px"}={}){const o=`${n} ${s}`;let c=t.get(o);if(!c){const e=new Map,r=new Map;c={observer:new IntersectionObserver(t=>{for(const n of t){r.set(n.target,n);for(const t of e.get(n.target)??[])t(n)}},{threshold:n,rootMargin:s}),listeners:e,latest:r},t.set(o,c)}const{observer:i,listeners:f,latest:a}=c;let u=f.get(e),l=!1;if(u){const t=a.get(e);t&&queueMicrotask(()=>{l||r(t)})}else u=new Set,f.set(e,u),i.observe(e);return u.add(r),()=>{l||(l=!0,u.delete(r),u.size>0||(f.delete(e),a.delete(e),i.unobserve(e),0===f.size&&(i.disconnect(),t.delete(o))))}}const r="data-mp-offscreen";export function useOffscreenPause(t){const n=e.useRef(null);return e.useEffect(()=>{const e=n.current;if(!e||!t||"undefined"==typeof IntersectionObserver)return;const s=watchIntersection(e,t=>{e.toggleAttribute(r,!t.isIntersecting)});return()=>{s(),e.removeAttribute(r)}},[t]),n}