material-plus-ui 1.7.0 → 1.9.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 (263) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +28 -18
  3. package/dist/a2ui/catalog.d.ts +104 -0
  4. package/dist/a2ui/catalog.js +1 -0
  5. package/dist/a2ui/components/MPA2uiAudioPlayer.d.ts +1 -0
  6. package/dist/a2ui/components/MPA2uiAudioPlayer.js +2 -0
  7. package/dist/a2ui/components/MPA2uiButton.d.ts +1 -0
  8. package/dist/a2ui/components/MPA2uiButton.js +2 -0
  9. package/dist/a2ui/components/MPA2uiCard.d.ts +1 -0
  10. package/dist/a2ui/components/MPA2uiCard.js +2 -0
  11. package/dist/a2ui/components/MPA2uiCheckBox.d.ts +1 -0
  12. package/dist/a2ui/components/MPA2uiCheckBox.js +2 -0
  13. package/dist/a2ui/components/MPA2uiChoicePicker.d.ts +1 -0
  14. package/dist/a2ui/components/MPA2uiChoicePicker.js +2 -0
  15. package/dist/a2ui/components/MPA2uiColumn.d.ts +1 -0
  16. package/dist/a2ui/components/MPA2uiColumn.js +2 -0
  17. package/dist/a2ui/components/MPA2uiDateTimeInput.d.ts +1 -0
  18. package/dist/a2ui/components/MPA2uiDateTimeInput.js +2 -0
  19. package/dist/a2ui/components/MPA2uiDivider.d.ts +1 -0
  20. package/dist/a2ui/components/MPA2uiDivider.js +2 -0
  21. package/dist/a2ui/components/MPA2uiIcon.d.ts +1 -0
  22. package/dist/a2ui/components/MPA2uiIcon.js +2 -0
  23. package/dist/a2ui/components/MPA2uiImage.d.ts +1 -0
  24. package/dist/a2ui/components/MPA2uiImage.js +2 -0
  25. package/dist/a2ui/components/MPA2uiList.d.ts +1 -0
  26. package/dist/a2ui/components/MPA2uiList.js +2 -0
  27. package/dist/a2ui/components/MPA2uiModal.d.ts +1 -0
  28. package/dist/a2ui/components/MPA2uiModal.js +2 -0
  29. package/dist/a2ui/components/MPA2uiRow.d.ts +1 -0
  30. package/dist/a2ui/components/MPA2uiRow.js +2 -0
  31. package/dist/a2ui/components/MPA2uiSlider.d.ts +1 -0
  32. package/dist/a2ui/components/MPA2uiSlider.js +2 -0
  33. package/dist/a2ui/components/MPA2uiTabs.d.ts +1 -0
  34. package/dist/a2ui/components/MPA2uiTabs.js +2 -0
  35. package/dist/a2ui/components/MPA2uiText.d.ts +1 -0
  36. package/dist/a2ui/components/MPA2uiText.js +2 -0
  37. package/dist/a2ui/components/MPA2uiTextField.d.ts +1 -0
  38. package/dist/a2ui/components/MPA2uiTextField.js +2 -0
  39. package/dist/a2ui/components/MPA2uiVideo.d.ts +1 -0
  40. package/dist/a2ui/components/MPA2uiVideo.js +2 -0
  41. package/dist/a2ui/extended/MPA2uiBarChart.d.ts +1 -0
  42. package/dist/a2ui/extended/MPA2uiBarChart.js +2 -0
  43. package/dist/a2ui/extended/MPA2uiDataTable.d.ts +1 -0
  44. package/dist/a2ui/extended/MPA2uiDataTable.js +2 -0
  45. package/dist/a2ui/extended/MPA2uiLineChart.d.ts +1 -0
  46. package/dist/a2ui/extended/MPA2uiLineChart.js +2 -0
  47. package/dist/a2ui/extended/MPA2uiPieChart.d.ts +1 -0
  48. package/dist/a2ui/extended/MPA2uiPieChart.js +2 -0
  49. package/dist/a2ui/extended/MPA2uiStatistic.d.ts +1 -0
  50. package/dist/a2ui/extended/MPA2uiStatistic.js +2 -0
  51. package/dist/a2ui/extended/api.d.ts +1436 -0
  52. package/dist/a2ui/extended/api.js +1 -0
  53. package/dist/a2ui/extended/chart.d.ts +26 -0
  54. package/dist/a2ui/extended/chart.js +1 -0
  55. package/dist/a2ui/index.d.ts +103 -0
  56. package/dist/a2ui/index.js +1 -0
  57. package/dist/a2ui/internal/children.d.ts +28 -0
  58. package/dist/a2ui/internal/children.js +1 -0
  59. package/dist/a2ui/internal/common.d.ts +113 -0
  60. package/dist/a2ui/internal/common.js +1 -0
  61. package/dist/a2ui/internal/icons.d.ts +3 -0
  62. package/dist/a2ui/internal/icons.js +1 -0
  63. package/dist/components/alert/MPAlert.d.ts +2 -2
  64. package/dist/components/alert/MPAlert.js +1 -1
  65. package/dist/components/anchor/MPAnchor.js +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-slide/MPAnimateSlide.d.ts +1 -1
  69. package/dist/components/animate-zoom/MPAnimateZoom.d.ts +2 -2
  70. package/dist/components/app-logo/MPAppLogo.d.ts +16 -1
  71. package/dist/components/app-logo/MPAppLogo.js +1 -1
  72. package/dist/components/area-chart/MPAreaChart.d.ts +18 -3
  73. package/dist/components/area-chart/MPAreaChart.js +1 -1
  74. package/dist/components/aspect-ratio/MPAspectRatio.d.ts +1 -1
  75. package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
  76. package/dist/components/avatar/MPAvatar.d.ts +1 -1
  77. package/dist/components/bar-chart/MPBarChart.d.ts +15 -5
  78. package/dist/components/bar-chart/MPBarChart.js +1 -1
  79. package/dist/components/blockquote/MPBlockquote.d.ts +9 -1
  80. package/dist/components/blockquote/MPBlockquote.js +1 -1
  81. package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
  82. package/dist/components/box/MPBox.d.ts +1 -1
  83. package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
  84. package/dist/components/button/MPButton.js +1 -1
  85. package/dist/components/calendar/MPCalendar.js +1 -1
  86. package/dist/components/carousel/MPCarousel.js +1 -1
  87. package/dist/components/checkbox/MPCheckbox.js +1 -1
  88. package/dist/components/chip/MPChip.d.ts +2 -2
  89. package/dist/components/chip/MPChip.js +1 -1
  90. package/dist/components/color-picker/MPColorPicker.js +1 -1
  91. package/dist/components/combobox/MPCombobox.js +1 -1
  92. package/dist/components/confirm/MPConfirmProvider.js +1 -1
  93. package/dist/components/data-table/MPDataTable.d.ts +20 -1
  94. package/dist/components/data-table/MPDataTable.js +1 -1
  95. package/dist/components/date-picker/MPDatePicker.js +1 -1
  96. package/dist/components/empty/MPEmpty.d.ts +1 -1
  97. package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
  98. package/dist/components/grid/MPGrid.d.ts +25 -8
  99. package/dist/components/grid/MPGrid.js +1 -1
  100. package/dist/components/heatmap-chart/MPHeatmapChart.d.ts +12 -3
  101. package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
  102. package/dist/components/hover-card/MPHoverCard.d.ts +1 -0
  103. package/dist/components/hover-card/MPHoverCard.js +1 -1
  104. package/dist/components/icon/MPIcon.js +1 -1
  105. package/dist/components/image/MPImage.d.ts +112 -4
  106. package/dist/components/image/MPImage.js +1 -1
  107. package/dist/components/image/index.d.ts +1 -1
  108. package/dist/components/line-chart/MPLineChart.d.ts +20 -2
  109. package/dist/components/line-chart/MPLineChart.js +1 -1
  110. package/dist/components/list/MPList.js +1 -1
  111. package/dist/components/menu/MPMenu.d.ts +1 -1
  112. package/dist/components/menubar/MPMenubar.js +1 -1
  113. package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
  114. package/dist/components/number-field/MPNumberField.js +1 -1
  115. package/dist/components/pie-chart/MPPieChart.d.ts +23 -1
  116. package/dist/components/pie-chart/MPPieChart.js +1 -1
  117. package/dist/components/pill/MPPill.js +1 -1
  118. package/dist/components/popconfirm/MPPopconfirm.d.ts +2 -2
  119. package/dist/components/popover/MPPopover.d.ts +1 -0
  120. package/dist/components/popover/MPPopover.js +1 -1
  121. package/dist/components/portal/MPPortal.d.ts +1 -1
  122. package/dist/components/radio-group/MPRadioGroup.js +1 -1
  123. package/dist/components/rating/MPRating.js +1 -1
  124. package/dist/components/scatter-chart/MPScatterChart.d.ts +5 -1
  125. package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
  126. package/dist/components/select/MPSelect.js +1 -1
  127. package/dist/components/sparkline/MPSparkline.d.ts +14 -1
  128. package/dist/components/sparkline/MPSparkline.js +1 -1
  129. package/dist/components/statistic/MPStatistic.js +1 -1
  130. package/dist/components/stepper/MPStepper.js +1 -1
  131. package/dist/components/table/MPTable.d.ts +1 -1
  132. package/dist/components/tabs/MPTabs.js +1 -1
  133. package/dist/components/timeline/MPTimeline.js +1 -1
  134. package/dist/components/timeline-chart/MPTimelineChart.d.ts +6 -2
  135. package/dist/components/toggle/MPToggle.js +1 -1
  136. package/dist/components/tooltip/MPTooltip.js +1 -1
  137. package/dist/components/tour/MPTour.js +1 -1
  138. package/dist/components/transfer/MPTransfer.js +1 -1
  139. package/dist/components/typography/MPTypography.d.ts +1 -1
  140. package/dist/constants/glyphs.d.ts +32 -32
  141. package/dist/constants/icons.d.ts +32 -32
  142. package/dist/internal/Calendar.js +1 -1
  143. package/dist/internal/ChartChrome.d.ts +63 -19
  144. package/dist/internal/ChartChrome.js +1 -1
  145. package/dist/internal/ChartFrame.d.ts +24 -4
  146. package/dist/internal/ChartFrame.js +1 -1
  147. package/dist/internal/FieldOutline.js +1 -1
  148. package/dist/internal/Picker.js +1 -1
  149. package/dist/internal/PopupArrow.d.ts +60 -0
  150. package/dist/internal/PopupArrow.js +2 -0
  151. package/dist/internal/SupportingText.js +1 -1
  152. package/dist/internal/chart.d.ts +91 -13
  153. package/dist/internal/chart.js +1 -1
  154. package/dist/internal/color-scheme.d.ts +0 -9
  155. package/dist/internal/color-scheme.js +1 -1
  156. package/dist/internal/data-table.d.ts +35 -2
  157. package/dist/internal/data-table.js +1 -1
  158. package/dist/internal/date.d.ts +22 -18
  159. package/dist/internal/date.js +1 -1
  160. package/dist/internal/i18n.d.ts +14 -0
  161. package/dist/internal/intl.d.ts +64 -0
  162. package/dist/internal/intl.js +1 -0
  163. package/dist/internal/messages/chart.d.ts +1 -1
  164. package/dist/internal/messages/chart.js +1 -1
  165. package/dist/internal/messages/transfer.d.ts +1 -1
  166. package/dist/internal/messages/transfer.js +1 -1
  167. package/dist/internal/text.js +1 -1
  168. package/dist/internal/time-scale.js +1 -1
  169. package/dist/locales/ar.js +1 -1
  170. package/dist/locales/de.js +1 -1
  171. package/dist/locales/es.js +1 -1
  172. package/dist/locales/fr.js +1 -1
  173. package/dist/locales/hi.js +1 -1
  174. package/dist/locales/id.js +1 -1
  175. package/dist/locales/it.js +1 -1
  176. package/dist/locales/ja.js +1 -1
  177. package/dist/locales/ko.js +1 -1
  178. package/dist/locales/nl.js +1 -1
  179. package/dist/locales/pl.js +1 -1
  180. package/dist/locales/pt.js +1 -1
  181. package/dist/locales/ru.js +1 -1
  182. package/dist/locales/th.js +1 -1
  183. package/dist/locales/tr.js +1 -1
  184. package/dist/locales/vi.js +1 -1
  185. package/dist/locales/zh-hans.js +1 -1
  186. package/dist/locales/zh-hant.js +1 -1
  187. package/dist/styles/accordion.css +1 -1
  188. package/dist/styles/alert.css +1 -1
  189. package/dist/styles/app-logo.css +1 -1
  190. package/dist/styles/area-chart.css +1 -1
  191. package/dist/styles/aspect-ratio.css +1 -1
  192. package/dist/styles/bar-chart.css +1 -1
  193. package/dist/styles/blockquote.css +1 -1
  194. package/dist/styles/bottom-navigation.css +1 -1
  195. package/dist/styles/breadcrumb.css +1 -1
  196. package/dist/styles/button.css +1 -1
  197. package/dist/styles/calendar.css +1 -1
  198. package/dist/styles/carousel.css +1 -1
  199. package/dist/styles/chat-bubble.css +1 -1
  200. package/dist/styles/checkbox.css +1 -1
  201. package/dist/styles/chip.css +1 -1
  202. package/dist/styles/code-block.css +1 -1
  203. package/dist/styles/collapsible.css +1 -1
  204. package/dist/styles/color-picker.css +1 -1
  205. package/dist/styles/combobox.css +1 -1
  206. package/dist/styles/confirm.css +1 -1
  207. package/dist/styles/data-table.css +1 -1
  208. package/dist/styles/date-picker.css +1 -1
  209. package/dist/styles/date-range-picker.css +1 -1
  210. package/dist/styles/date-time-picker.css +1 -1
  211. package/dist/styles/dialog.css +1 -1
  212. package/dist/styles/drawer.css +1 -1
  213. package/dist/styles/file-picker.css +1 -1
  214. package/dist/styles/flex.css +1 -1
  215. package/dist/styles/floating-action-button.css +1 -1
  216. package/dist/styles/gauge-chart.css +1 -1
  217. package/dist/styles/grid.css +1 -1
  218. package/dist/styles/heatmap-chart.css +1 -1
  219. package/dist/styles/icon-button.css +1 -1
  220. package/dist/styles/icon.css +1 -1
  221. package/dist/styles/image.css +1 -1
  222. package/dist/styles/line-chart.css +1 -1
  223. package/dist/styles/list.css +1 -1
  224. package/dist/styles/menu.css +1 -1
  225. package/dist/styles/menubar.css +1 -1
  226. package/dist/styles/navigation-menu.css +1 -1
  227. package/dist/styles/number-field.css +1 -1
  228. package/dist/styles/otp-field.css +1 -1
  229. package/dist/styles/pagination.css +1 -1
  230. package/dist/styles/pie-chart.css +1 -1
  231. package/dist/styles/pill.css +1 -1
  232. package/dist/styles/popconfirm.css +1 -1
  233. package/dist/styles/popover.css +1 -1
  234. package/dist/styles/radio-group.css +1 -1
  235. package/dist/styles/rating.css +1 -1
  236. package/dist/styles/scatter-chart.css +1 -1
  237. package/dist/styles/scroll-zone.css +1 -1
  238. package/dist/styles/segmented-button.css +1 -1
  239. package/dist/styles/select.css +1 -1
  240. package/dist/styles/sidebar.css +1 -1
  241. package/dist/styles/snackbar.css +1 -1
  242. package/dist/styles/sparkline.css +1 -1
  243. package/dist/styles/spoiler.css +1 -1
  244. package/dist/styles/statistic.css +1 -1
  245. package/dist/styles/stepper.css +1 -1
  246. package/dist/styles/switch.css +1 -1
  247. package/dist/styles/tabs.css +1 -1
  248. package/dist/styles/text-field.css +1 -1
  249. package/dist/styles/text-link.css +1 -1
  250. package/dist/styles/time-picker.css +1 -1
  251. package/dist/styles/timeline-chart.css +1 -1
  252. package/dist/styles/timeline.css +1 -1
  253. package/dist/styles/toggle.css +1 -1
  254. package/dist/styles/tokens.css +1 -1
  255. package/dist/styles/tour.css +1 -1
  256. package/dist/styles/transfer.css +1 -1
  257. package/dist/styles/tree-select.css +1 -1
  258. package/dist/styles/tree-view.css +1 -1
  259. package/dist/styles.css +1 -1
  260. package/dist/tailwind.css +1253 -55
  261. package/dist/types.d.ts +210 -3
  262. package/package.json +47 -26
  263. package/.fix.py +0 -92
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useMPElementSize as i}from"../hooks/useMPElementSize.js";import{useMPLocale as a,useMPMessages as n}from"./locale.js";import{useMPSize as o}from"./config.js";import{CHART as r}from"./messages/chart.js";import{TABLE as s}from"./messages/table.js";import{ChartLegend as h,ChartShell as c,ChartTable as d,ChartTooltipPanel as u,useVisibility as m}from"./ChartChrome.js";import{CHART_FONT_SIZE as x,MARKER_RADIUS as f,PLOT_HEIGHT as p,bandScale as g,categoryAt as y,categoryCount as v,categoryExtent as k,fitsLast as b,formatCategory as M,formatStatistic as w,seriesColor as z,seriesExtent as S,showsTick as P,textWidth as A,tickStride as C,toValues as j,truncate as B,valueScale as $}from"./chart.js";const R=[],W="var(--_mp-color-outline-variant)",F="var(--_mp-color-outline)",N="var(--_mp-color-on-surface-variant)";function T({plot:l,scale:i,horizontal:a,categoryPx:n,categoryScale:o,categoryValuePx:r,valuePx:s,tickTexts:h,categoryTexts:c,valueAxis:d,categoryAxis:u,fontSize:m,zeroPx:x}){const f=!1!==d?.grid&&!d?.hidden,p=!u?.hidden&&(u?.grid??null!==o),g=e=>o?r(o.ticks[e]):(a?l.top:l.left)+n(e),y=C(c.length,a?l.height:l.width,a?1.8*m:Math.max(...c.map(e=>A(e,m)),1)+12),v=C(i.ticks.length,a?l.width:l.height,a?Math.max(...h.map(e=>A(e,m)),1)+16:2*m),k=c.length>1?Math.abs(g(1)-g(0)):l.width,M=i.ticks.length>1?Math.abs(s(i.ticks[1])-s(i.ticks[0])):l.height,w=b(c.length,y,k,a?1.8*m:A(c[c.length-1]??"",m)),z=b(i.ticks.length,v,M,a?A(h[h.length-1]??"",m):1.6*m);return t("g",{className:"mp-chart__axes",children:[i.ticks.map((n,o)=>{const r=s(n),c=Math.abs(n)<1e-9&&i.min<0,u=!d?.hidden&&P(o,i.ticks.length,v,z);return t("g",{children:[f?e("line",a?{x1:r,x2:r,y1:l.top,y2:l.top+l.height,stroke:c?F:W,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:r,y2:r,stroke:c?F:W,strokeWidth:1}):null,u?e("text",{x:a?r:l.left-8,y:a?l.top+l.height+m+6:r,textAnchor:a?"middle":"end",dominantBaseline:a?"auto":"central",fill:N,fontSize:m,children:h[o]}):null]},`v${o}`)}),c.map((i,n)=>{const o=g(n),r=!u?.hidden&&P(n,c.length,y,w);return t("g",{children:[p?e("line",a?{x1:l.left,x2:l.left+l.width,y1:o,y2:o,stroke:W,strokeWidth:1}:{x1:o,x2:o,y1:l.top,y2:l.top+l.height,stroke:W,strokeWidth:1}):null,r?e("text",{x:a?l.left-8:o,y:a?o:l.top+l.height+m+6,textAnchor:a?"end":"middle",dominantBaseline:a?"central":"auto",fill:N,fontSize:m,children:i}):null]},`c${n}`)}),e("line",a?{x1:x,x2:x,y1:l.top,y2:l.top+l.height,stroke:F,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:x,y2:x,stroke:F,strokeWidth:1}),d?.label&&!d.hidden?e("text",{x:a?l.left+l.width/2:m,y:a?l.top+l.height+2*m+12:l.top+l.height/2,textAnchor:"middle",dominantBaseline:a?"auto":"central",fill:N,fontSize:m,transform:a?void 0:`rotate(-90 ${m} ${l.top+l.height/2})`,children:d.label}):null,u?.label&&!u.hidden?e("text",{x:a?m:l.left+l.width/2,y:a?l.top+l.height/2:l.top+l.height+2*m+12,textAnchor:"middle",dominantBaseline:a?"central":"auto",fill:N,fontSize:m,transform:a?`rotate(-90 ${m} ${l.top+l.height/2})`:void 0,children:u.label}):null]})}export function CartesianFrame({series:b,categories:P,xAxis:C,yAxis:W,horizontal:N=!1,stacked:_=!1,includeZero:E=!0,bandRatio:I=1,inset:V=!1,headroom:D=0,markInset:X=0,xScale:Y="band",marks:Z,markRadius:L=24,swatch:H,scale:K,table:U,markTooltip:q,height:G,format:J,locale:O,label:Q,legend:ee,tooltip:te,empty:le,size:ie,className:ae,style:ne,children:oe,...re}){const se=o(ie),he=a(O),ce=n(r,he),de=n(s,he),ue=l.useRef(null),me=i(ue),xe=me.width,fe=l.useId(),pe=m(b),[ge,ye]=l.useState(null),[ve,ke]=l.useState(null),[be,Me]=l.useState(null),we=l.useCallback(e=>w(e,he,J,!0),[J,he]),ze=l.useMemo(()=>j(b),[b]),Se=l.useMemo(()=>b.map((e,t)=>z(t,e.color)),[b]),Pe=l.useMemo(()=>b.map(e=>e.name),[b]),Ae=v(b),Ce=l.useMemo(()=>Array.from({length:Ae},(e,t)=>y(t,P,ze)),[Ae,P,ze]),je=ze.filter((e,t)=>pe.visible[t]),Be=S(je,_),$e=x[se],Re=W,We=C,Fe=K??$(Be,{min:Re?.min,max:Re?.max,tickCount:Re?.tickCount,includeZero:E}),Ne="value"===Y?k(je,P):null,Te="value"===Y?$(Ne,{min:We?.min,max:We?.max,tickCount:We?.tickCount,includeZero:!1}):null,_e=Fe.ticks.map((e,t)=>Re?.tickFormat?String(Re.tickFormat(e,t)):we(e)),Ee=Te?Te.ticks.map((e,t)=>We?.tickFormat?String(We.tickFormat(e,t)):w(e,he,void 0,!0)):Ce.map((e,t)=>We?.tickFormat?String(We.tickFormat(e,t)):M(e,he)),Ie=_e.reduce((e,t)=>Math.max(e,A(t,$e)),0),Ve=$e+6,De=Re?.hidden?0:Ie+10+(Re?.label?Ve:0),Xe=(xe-(N?0:De)-16)/Math.max(1,Ae),Ye=Te?Ee:N||Xe-6>=2.4*$e?Ee.map(e=>B(e,N?150:Xe-6,$e)):Ee,Ze=Ye.reduce((e,t)=>Math.max(e,A(t,$e)),0),Le=N?We?.hidden?0:Ze+10+(We?.label?Ve:0):De,He=N?Re?.hidden?0:$e+12+(Re?.label?Ve:0):We?.hidden?0:$e+12+(We?.label?Ve:0),Ke=(N?We:Re)?.thickness??Le,Ue=(N?Re:We)?.thickness??He,qe=(N?12+D:Math.max(8,Ze/2))+X,Ge=f[se]+4+(N?0:D)+X,Je="number"==typeof G?G:void 0===G?p[se]:me.height,Oe={left:Ke+X,top:Ge,width:Math.max(0,xe-Ke-X-qe),height:Math.max(0,Je-Ge-Ue-X)},Qe=N?Oe.height:Oe.width,et=g(V?Math.max(1,Ae-1):Ae,Qe,I),tt=l.useCallback(e=>V?Ae<=1?Qe/2:Qe*e/(Ae-1):et.centre(e),[V,Ae,Qe,et]),lt=l.useCallback(e=>N?Oe.left+Fe.fraction(e)*Oe.width:Oe.top+(1-Fe.fraction(e))*Oe.height,[N,Oe.left,Oe.top,Oe.width,Oe.height,Fe]),it=l.useCallback(e=>N?Oe.top+(1-(Te?.fraction(e)??0))*Oe.height:Oe.left+(Te?.fraction(e)??0)*Oe.width,[N,Oe.left,Oe.top,Oe.width,Oe.height,Te]),at=l.useCallback((e,t)=>N?{x:lt(t),y:Oe.top+tt(e)}:{x:Oe.left+tt(e),y:lt(t)},[N,lt,tt,Oe.left,Oe.top]),nt=lt(Math.min(Math.max(0,Fe.min),Fe.max)),ot={plot:Oe,values:ze,visible:pe.visible,colors:Se,scale:Fe,band:et,horizontal:N,valuePx:lt,categoryPx:tt,point:at,categoryScale:Te,categoryValuePx:it,zeroPx:nt,categories:Ce,format:we,size:se},rt=Z?Z(ot):R,st=!1===te?{mode:"none"}:!0===te||void 0===te?{}:te,ht=st.mode??(Z?"item":"index"),ct=null===ve?null:rt[ve]??null,dt=Z?ct?ct.index:null:ge,ut=Z?rt.length:Ae,mt=()=>{ye(null),ke(null),Me(null)},xt=e=>{const t=null===e?null:Math.min(ut-1,Math.max(0,e));Z?ke(t):ye(t)},ft=e=>{Me(null);xt(((Z?ve:ge)??(e>0?-1:ut))+e)},pt=null===dt?[]:b.flatMap((e,t)=>{if(!pe.visible[t]||ct&&ct.series!==t)return[];const l=ze[t]?.[dt];return l&&null!==l.value?[{seriesIndex:t,name:e.name,color:l.color??Se[t],value:l.value,formatted:we(l.value),label:l.label}]:[]}),gt=ct&&q?q(ct):null,yt=gt?gt.items:"item"===ht&&pt.length>1&&null!==be?[pt.reduce((e,t)=>Math.abs(lt(t.value??0)-be)<Math.abs(lt(e.value??0)-be)?t:e)]:pt,vt=gt?gt.heading:ct?M(ze[ct.series]?.[ct.index]?.x??P?.[ct.index]??ct.index,he):null===dt?void 0:M(Ce[dt]??dt,he),kt=ct?ct.x:N?lt(yt[0]?.value??0):Oe.left+tt(dt??0),bt=ct?ct.y:N?Oe.top+tt(dt??0):Oe.top+Oe.height/2,Mt=ct?(ct.x-Oe.left)/Math.max(1,Oe.width)>.6:(N?Fe.fraction(yt[0]?.value??0):tt(dt??0)/Math.max(1,Qe))>.6,wt=!1===ee?{interactive:!1}:!0===ee||void 0===ee?{}:ee,zt=!0===ee||!1!==ee&&b.length>1,St=wt.side??"bottom",Pt={...ot,hovered:pe.hovered,activeIndex:dt,marks:rt,activeMark:ct},At=0===Ae||null===Be||"value"===Y&&null===Ne;return e(c,{...re,size:se,className:ae,style:ne,plotRef:ue,name:Q??ce.label,describedBy:At?void 0:fe,interactive:!At,height:G,legendSide:St,plotProps:{onPointerMove:At||"none"===ht?void 0:e=>{Z?ke(((e,t)=>{const l=ue.current;if(!l||0===rt.length)return null;const i=l.getBoundingClientRect(),a=e-i.left,n=t-i.top;let o=null,r=1/0,s=1/0;return rt.forEach((e,t)=>{const l=Math.hypot(e.x-a,e.y-n),i=void 0===e.rx?Math.max(0,l-e.r):Math.hypot(Math.max(0,Math.abs(e.x-a)-e.rx),Math.max(0,Math.abs(e.y-n)-(e.ry??e.rx)));i<=L&&(i<r||i===r&&l<s)&&(r=i,s=l,o=t)}),o})(e.clientX,e.clientY)):ye(((e,t)=>{const l=ue.current;if(!l||0===Ae)return null;const i=l.getBoundingClientRect(),a=N?t-i.top-Oe.top:e-i.left-Oe.left;if(a<-et.step||a>Qe+et.step)return null;const n=V?Ae<=1?0:Math.round(a/Qe*(Ae-1)):Math.floor(a/et.step);return Math.min(Ae-1,Math.max(0,n))})(e.clientX,e.clientY)),"item"===ht&&Me(((e,t)=>{const l=ue.current;if(!l)return null;const i=l.getBoundingClientRect();return N?e-i.left:t-i.top})(e.clientX,e.clientY))},onPointerLeave:mt,onKeyDown:At||"none"===ht?void 0:e=>{const t=N?"ArrowDown":"ArrowRight",l=N?"ArrowUp":"ArrowLeft";if(e.key===t)ft(1);else if(e.key===l)ft(-1);else if("Home"===e.key)xt(0);else if("End"===e.key)xt(ut-1);else{if("Escape"!==e.key)return;mt()}e.preventDefault()},onBlur:mt},tooltip:null!==dt&&yt.length>0&&"none"!==ht?st.render?e("div",{"aria-hidden":"true",className:"pointer-events-none absolute z-10",style:{left:kt,top:bt,transform:`translate(${Mt?"calc(-100% - 12px)":"12px"}, -50%)`},children:st.render({index:dt,category:Ce[dt]??dt,items:yt})}):e(u,{heading:vt,items:yt,x:kt,y:bt,flip:Mt,size:se}):null,legend:zt?e(h,{names:Pe,colors:Se,options:wt,visibility:pe,size:se,swatch:H,values:wt.showValue&&null!==dt?b.map((e,t)=>{const l=ze[t]?.[dt]?.value;return null==l?void 0:we(l)}):void 0}):null,status:{heading:vt,items:yt},table:At?null:U?.(fe)??e(d,{id:fe,caption:Q??ce.table,corner:We?.label??ce.category,categories:Ce,names:Pe,values:ze,format:we,locale:he,empty:de.empty}),children:At?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:le??de.empty}):xe>0&&Je>0?t("svg",{width:xe,height:Je,viewBox:`0 0 ${xe} ${Je}`,"aria-hidden":"true",className:"block overflow-visible",children:[e(T,{plot:Oe,scale:Fe,horizontal:N,categoryPx:tt,categoryScale:Te,categoryValuePx:it,valuePx:lt,tickTexts:_e,categoryTexts:Ye,valueAxis:Re,categoryAxis:We,fontSize:$e,zeroPx:nt}),null===dt||Z||"index"!==ht||!1===st.crosshair?null:(()=>{const t=tt(dt);return e("line",N?{x1:Oe.left,x2:Oe.left+Oe.width,y1:Oe.top+t,y2:Oe.top+t,stroke:F,strokeWidth:1}:{x1:Oe.left+t,x2:Oe.left+t,y1:Oe.top,y2:Oe.top+Oe.height,stroke:F,strokeWidth:1})})(),oe(Pt)]}):null})}
2
+ import{jsx as t,jsxs as e,Fragment as l}from"react/jsx-runtime";import*as n from"react";import{useMPElementSize as a}from"../hooks/useMPElementSize.js";import{useMPLocale as i,useMPMessages as o}from"./locale.js";import{useMPSize as r}from"./config.js";import{CHART as s}from"./messages/chart.js";import{TABLE as h}from"./messages/table.js";import{ChartLegend as c,ChartShell as u,ChartTable as d,ChartTooltipPanel as m,useVisibility as p}from"./ChartChrome.js";import{VISUALLY_HIDDEN as f}from"./visually-hidden.js";import{CHART_FONT_SIZE as x,MARKER_RADIUS as g,PLOT_HEIGHT as v,bandScale as y,categoryAt as b,categoryCount as k,categoryExtent as M,fitsLast as w,formatCategory as z,formatShare as S,formatStatistic as P,seriesColor as C,seriesExtent as A,showsTick as $,textWidth as _,tickStride as B,tickTurn as j,toNumber as R,toValues as N,truncate as W,turnedBand as I,turnedRoom as F,turnedStep as T,valueScale as D,withReferences as L}from"./chart.js";const X=[];function Y({text:e,along:l,top:n,turn:a,fontSize:i}){return t("text",a<=0?{x:l,y:n+i+6,textAnchor:"middle",fill:Z,fontSize:i,children:e}:{x:l,y:n+8,textAnchor:"end",dominantBaseline:"central",transform:`rotate(${-a} ${l} ${n+8})`,fill:Z,fontSize:i,children:e})}const E="var(--_mp-color-outline-variant)",V="var(--_mp-color-outline)",Z="var(--_mp-color-on-surface-variant)";function U({plot:l,scale:n,horizontal:a,categoryPx:i,categoryScale:o,categoryValuePx:r,valuePx:s,tickTexts:h,categoryTexts:c,valueAxis:u,categoryAxis:d,fontSize:m,zeroPx:p,turn:f,tickBand:x}){const g=!1!==u?.grid&&!u?.hidden,v=!d?.hidden&&(d?.grid??null!==o),y=t=>o?r(o.ticks[t]):(a?l.top:l.left)+i(t),b=(t,e)=>f>0?T(f,m):Math.max(...t.map(t=>_(t,m)),1)+e,k=B(c.length,a?l.height:l.width,a?1.8*m:b(c,12)),M=B(n.ticks.length,a?l.width:l.height,a?b(h,16):2*m),z=c.length>1?Math.abs(y(1)-y(0)):l.width,S=n.ticks.length>1?Math.abs(s(n.ticks[1])-s(n.ticks[0])):l.height,P=w(c.length,k,z,a?1.8*m:f>0?T(f,m):_(c[c.length-1]??"",m)),C=w(n.ticks.length,M,S,a?f>0?T(f,m):_(h[h.length-1]??"",m):1.6*m);return e("g",{className:"mp-chart__axes",children:[n.ticks.map((i,o)=>{const r=s(i),c=Math.abs(i)<1e-9&&n.min<0,d=!u?.hidden&&$(o,n.ticks.length,M,C);return e("g",{children:[g?t("line",a?{x1:r,x2:r,y1:l.top,y2:l.top+l.height,stroke:c?V:E,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:r,y2:r,stroke:c?V:E,strokeWidth:1}):null,d?a?t(Y,{text:h[o],along:r,top:l.top+l.height,turn:f,fontSize:m}):t("text",{x:l.left-8,y:r,textAnchor:"end",dominantBaseline:"central",fill:Z,fontSize:m,children:h[o]}):null]},`v${o}`)}),c.map((n,i)=>{const o=y(i),r=!d?.hidden&&$(i,c.length,k,P);return e("g",{children:[v?t("line",a?{x1:l.left,x2:l.left+l.width,y1:o,y2:o,stroke:E,strokeWidth:1}:{x1:o,x2:o,y1:l.top,y2:l.top+l.height,stroke:E,strokeWidth:1}):null,r?a?t("text",{x:l.left-8,y:o,textAnchor:"end",dominantBaseline:"central",fill:Z,fontSize:m,children:n}):t(Y,{text:n,along:o,top:l.top+l.height,turn:f,fontSize:m}):null]},`c${i}`)}),t("line",a?{x1:p,x2:p,y1:l.top,y2:l.top+l.height,stroke:V,strokeWidth:1}:{x1:l.left,x2:l.left+l.width,y1:p,y2:p,stroke:V,strokeWidth:1}),u?.label&&!u.hidden?t("text",{x:a?l.left+l.width/2:m,y:a?l.top+l.height+x+m:l.top+l.height/2,textAnchor:"middle",dominantBaseline:a?"auto":"central",fill:Z,fontSize:m,transform:a?void 0:`rotate(-90 ${m} ${l.top+l.height/2})`,children:u.label}):null,d?.label&&!d.hidden?t("text",{x:a?m:l.left+l.width/2,y:a?l.top+l.height/2:l.top+l.height+x+m,textAnchor:"middle",dominantBaseline:a?"central":"auto",fill:Z,fontSize:m,transform:a?`rotate(-90 ${m} ${l.top+l.height/2})`:void 0,children:d.label}):null]})}function H(t,e){try{e?t.currentTarget.setPointerCapture(t.pointerId):t.currentTarget.releasePointerCapture(t.pointerId)}catch{}}function K(t,e,l){return(t??[]).map(t=>({...t,at:R(t.value),end:void 0===t.to?null:R(t.to)})).filter(t=>null!==t.at).map(t=>({at:e(t.at),to:null===t.end?null:e(t.end),upright:l,label:t.label,color:t.color?C(0,t.color):"var(--_mp-color-outline)",dashed:!1!==t.dashed}))}function O({marks:l,plot:n,pass:a,fontSize:i}){return 0===l.length?null:t("g",{className:`mp-chart__references mp-chart__references--${a}`,"aria-hidden":"true",children:l.map((l,o)=>{if("band"===a)return null===l.to?null:t("rect",{...(r=l.at,s=l.to,l.upright?{x:Math.min(r,s),y:n.top,width:Math.abs(s-r),height:n.height}:{x:n.left,y:Math.min(r,s),width:n.width,height:Math.abs(s-r)}),fill:l.color,opacity:.12},o);var r,s;const h=null===l.to?[l.at]:[l.at,l.to];return e("g",{children:[h.map(e=>t("line",{x1:l.upright?e:n.left,x2:l.upright?e:n.left+n.width,y1:l.upright?n.top:e,y2:l.upright?n.top+n.height:e,stroke:l.color,strokeWidth:1,strokeDasharray:l.dashed?"4 3":void 0},e)),void 0===l.label||null===l.label||""===l.label?null:t("text",{x:l.upright?l.at+4:n.left+n.width,y:l.upright?n.top+i:l.at-4,textAnchor:l.upright?"start":"end",fill:l.color,fontSize:i,children:l.label})]},o)})})}export function CartesianFrame({series:w,categories:$,xAxis:B,yAxis:R,horizontal:T=!1,zoom:Y,stacked:E=!1,includeZero:q=!0,bandRatio:G=1,inset:J=!1,headroom:Q=0,markInset:tt=0,xScale:et="band",marks:lt,markRadius:nt=24,swatch:at,scale:it,table:ot,markTooltip:rt,height:st,format:ht,locale:ct,label:ut,legend:dt,tooltip:mt,empty:pt,labelColor:ft="ink",size:xt,className:gt,style:vt,children:yt,...bt}){const kt=r(xt),Mt=i(ct),wt=o(s,Mt),zt=o(h,Mt),St=n.useRef(null),Pt=a(St),Ct=Pt.width,At=n.useId(),$t=n.useId(),_t=p(w),[Bt,jt]=n.useState(null),[Rt,Nt]=n.useState(null),[Wt,It]=n.useState(null),[Ft,Tt]=n.useState(null),Dt=n.useRef(null),Lt=t=>{Dt.current=t,Tt(t)},Xt=n.useCallback(t=>P(t,Mt,ht,!0),[ht,Mt]),Yt=n.useMemo(()=>N(w),[w]),Et=n.useMemo(()=>w.map((t,e)=>C(e,t.color)),[w]),Vt=n.useMemo(()=>w.map(t=>t.name),[w]),Zt=k(w),Ut=n.useMemo(()=>Array.from({length:Zt},(t,e)=>b(e,$,Yt)),[Zt,$,Yt]),Ht=!0!==Y&&!1!==Y&&Y?Y:{},Kt=void 0!==Y&&!1!==Y&&"band"===et,[Ot,qt]=n.useState(()=>Ht.defaultRange??null),Gt=(void 0!==Ht.range?Ht.range:Ot)??null,Jt=Kt&&null!==Gt&&0!==Zt?[Math.max(0,Math.min(Zt-1,Math.min(Gt[0],Gt[1]))),Math.max(0,Math.min(Zt-1,Math.max(Gt[0],Gt[1])))]:null,Qt=Jt?Jt[0]:0,te=Jt?Jt[1]-Jt[0]+1:Zt,ee=Jt?Yt.map(t=>t.slice(Qt,Qt+te)):Yt,le=Jt?Ut.slice(Qt,Qt+te):Ut,ne=t=>{void 0===Ht.range&&qt(t),Ht.onRangeChange?.(t)},ae=ee.filter((t,e)=>_t.visible[e]),ie="percent"===E,oe=ie?{min:0,max:1}:A(ae,Boolean(E)),re=x[kt],se=R,he=B,ce=it??D(ie?oe:L(oe,se?.references),{min:ie?0:se?.min,max:ie?1:se?.max,tickCount:se?.tickCount??(ie?4:void 0),includeZero:q}),ue="value"===et?M(ae,$):null,de="value"===et?D(L(ue,he?.references),{min:he?.min,max:he?.max,tickCount:he?.tickCount,includeZero:!1}):null,me=ce.ticks.map((t,e)=>se?.tickFormat?String(se.tickFormat(t,e)):ie?S(t,Mt):Xt(t)),pe=de?de.ticks.map((t,e)=>he?.tickFormat?String(he.tickFormat(t,e)):P(t,Mt,void 0,!0)):le.map((t,e)=>he?.tickFormat?String(he.tickFormat(t,e)):z(t,Mt)),fe=me.reduce((t,e)=>Math.max(t,_(e,re)),0),xe=re+6,ge=se?.hidden?0:fe+10+(se?.label?xe:0),ve="number"==typeof st?st:void 0===st?v[kt]:Pt.height,ye=(Ct-(T?0:ge)-16)/Math.max(1,te),be=T?se:he,ke=T?me:pe,Me=T?he?.hidden?0:pe.reduce((t,e)=>Math.max(t,Math.min(150,_(e,re))),0)+10+(he?.label?xe:0):ge,we=ke.reduce((t,e)=>Math.max(t,_(e,re)),0),ze=T?12+Q:Math.max(8,we/2),Se=(Ct-Me-ze-2*tt)/Math.max(1,ke.length),Pe=T||null!==de,Ce=be?.hidden?0:j(be?.tickLabels??(Pe?"truncate":"auto"),ke,re,Se),Ae=Math.min(120,.5*ve),$e=Ce>0&&!T?pe.map((t,e)=>W(t,(t=>Math.min(F(Ce,Ae,re),Ce>=90?1/0:(Me+Se*(t+(J?0:.5)))/Math.cos(Ce*Math.PI/180)))(e),re)):de?pe:T||ye-6>=2.4*re?pe.map(t=>W(t,T?150:ye-6,re)):pe,_e=$e.reduce((t,e)=>Math.max(t,_(e,re)),0),Be=be?.hidden?0:Ce>0?8+Math.min(Ae,I(Ce,T?fe:_e,re))+4:re+12,je=T?he?.hidden?0:_e+10+(he?.label?xe:0):ge,Re=Be+(be?.hidden||!be?.label?0:xe),Ne=(T?he:se)?.thickness??je,We=be?.thickness??Re,Ie=(T||Ce>0?12+(T?Q:0):Math.max(8,_e/2))+tt,Fe=g[kt]+4+(T?0:Q)+tt,Te={left:Ne+tt,top:Fe,width:Math.max(0,Ct-Ne-tt-Ie),height:Math.max(0,ve-Fe-We-tt)},De=T?Te.height:Te.width,Le=y(J?Math.max(1,te-1):te,De,G),Xe=n.useCallback(t=>J?te<=1?De/2:De*t/(te-1):Le.centre(t),[J,te,De,Le]),Ye=n.useCallback(t=>T?Te.left+ce.fraction(t)*Te.width:Te.top+(1-ce.fraction(t))*Te.height,[T,Te.left,Te.top,Te.width,Te.height,ce]),Ee=n.useCallback(t=>T?Te.top+(1-(de?.fraction(t)??0))*Te.height:Te.left+(de?.fraction(t)??0)*Te.width,[T,Te.left,Te.top,Te.width,Te.height,de]),Ve=n.useCallback((t,e)=>T?{x:Ye(e),y:Te.top+Xe(t)}:{x:Te.left+Xe(t),y:Ye(e)},[T,Ye,Xe,Te.left,Te.top]),Ze=Ye(Math.min(Math.max(0,ce.min),ce.max)),Ue=[...K(se?.references,Ye,T),...de?K(he?.references,Ee,!T):[]],He=t=>t instanceof Date?z(t,Mt):Xt(t),Ke=[...se?.references??[],...de?he?.references??[]:[]].filter(t=>void 0!==t.label&&null!==t.label&&""!==t.label),Oe={plot:Te,values:ee,visible:_t.visible,colors:Et,labelInk:t=>"series"===ft?Et[t]??Z:"var(--_mp-color-on-surface)",scale:ce,band:Le,horizontal:T,valuePx:Ye,categoryPx:Xe,point:Ve,categoryScale:de,categoryValuePx:Ee,zeroPx:Ze,categories:le,format:Xt,share:t=>S(t,Mt),size:kt},qe=lt?lt(Oe):X,Ge=!1===mt?{mode:"none"}:!0===mt||void 0===mt?{}:mt,Je=Ge.mode??(lt?"item":"index"),Qe=(t,e)=>{const l=St.current;if(!l||0===te)return null;const n=l.getBoundingClientRect(),a=T?e-n.top-Te.top:t-n.left-Te.left;if(a<-Le.step||a>De+Le.step)return null;const i=J?te<=1?0:Math.round(a/De*(te-1)):Math.floor(a/Le.step);return Math.min(te-1,Math.max(0,i))},tl=null===Rt?null:qe[Rt]??null,el=lt?tl?tl.index:null:Bt,ll=lt?qe.length:te,nl=()=>{jt(null),Nt(null),It(null)},al=t=>{const e=Dt.current;if(null===e)return;H(t,!1);const l=Math.min(e.start,e.to),n=Math.max(e.start,e.to);Lt(null),n-l+1>=Math.max(2,Ht.min??2)&&ne([Qt+l,Qt+n])},il=t=>{const e=null===t?null:Math.min(ll-1,Math.max(0,t));lt?Nt(e):jt(e)},ol=t=>{It(null);il(((lt?Rt:Bt)??(t>0?-1:ll))+t)},rl=null!==el&&ie?ee.reduce((t,e,l)=>{const n=_t.visible[l]?e[el]?.value:null;return t+(null!=n&&n>0?n:0)},0):0,sl=null===el?[]:w.flatMap((t,e)=>{if(!_t.visible[e]||tl&&tl.series!==e)return[];const l=ee[e]?.[el];return l&&null!==l.value?[{seriesIndex:e,name:t.name,color:l.color??Et[e],value:l.value,formatted:ie&&rl>0&&l.value>0?`${Xt(l.value)} · ${S(l.value/rl,Mt)}`:Xt(l.value),label:l.label}]:[]}),hl=tl&&rt?rt(tl):null,cl=hl?hl.items:"item"===Je&&sl.length>1&&null!==Wt?[sl.reduce((t,e)=>Math.abs(Ye(e.value??0)-Wt)<Math.abs(Ye(t.value??0)-Wt)?e:t)]:sl,ul="value"===Ge.sort?[...cl].sort((t,e)=>(e.value??-1/0)-(t.value??-1/0)):cl,dl=!(Ge.total??!0===E)||hl||cl.length<2?void 0:Xt(cl.reduce((t,e)=>t+(e.value??0),0)),ml=hl?hl.heading:tl?z(ee[tl.series]?.[tl.index]?.x??$?.[tl.index]??tl.index,Mt):null===el?void 0:z(le[el]??el,Mt),pl=tl?tl.x:T?Ye(cl[0]?.value??0):Te.left+Xe(el??0),fl=tl?tl.y:T?Te.top+Xe(el??0):Te.top+Te.height/2,xl=tl?(tl.x-Te.left)/Math.max(1,Te.width)>.6:(T?ce.fraction(cl[0]?.value??0):Xe(el??0)/Math.max(1,De))>.6,gl=!1===dt?{interactive:!1}:!0===dt||void 0===dt?{}:dt,vl=!0===dt||!1!==dt&&w.length>1,yl=gl.side??"bottom",bl={...Oe,hovered:_t.hovered,activeIndex:el,marks:qe,activeMark:tl},kl=0===te||null===oe||"value"===et&&null===ue;return t(u,{...bt,size:kt,className:gt,style:vt,plotRef:St,name:ut??wt.label,describedBy:kl?void 0:Ke.length>0?`${At} ${$t}`:At,interactive:!kl,height:st,legendSide:yl,plotProps:{onPointerDown:Kt&&!kl?t=>{const e=Qe(t.clientX,t.clientY);null!==e&&(H(t,!0),nl(),Lt({start:e,to:e}))}:void 0,onPointerMove:kl?void 0:t=>{null===Dt.current?"none"!==Je&&(lt?Nt(((t,e)=>{const l=St.current;if(!l||0===qe.length)return null;const n=l.getBoundingClientRect(),a=t-n.left,i=e-n.top;let o=null,r=1/0,s=1/0;return qe.forEach((t,e)=>{const l=Math.hypot(t.x-a,t.y-i),n=void 0===t.rx?Math.max(0,l-t.r):Math.hypot(Math.max(0,Math.abs(t.x-a)-t.rx),Math.max(0,Math.abs(t.y-i)-(t.ry??t.rx)));n<=nt&&(n<r||n===r&&l<s)&&(r=n,s=l,o=e)}),o})(t.clientX,t.clientY)):jt(Qe(t.clientX,t.clientY)),"item"===Je&&It(((t,e)=>{const l=St.current;if(!l)return null;const n=l.getBoundingClientRect();return T?t-n.left:e-n.top})(t.clientX,t.clientY))):Lt({...Dt.current,to:Qe(t.clientX,t.clientY)??Dt.current.to})},onPointerUp:Kt&&!kl?al:void 0,onPointerCancel:Kt&&!kl?()=>Lt(null):void 0,onPointerLeave:t=>{Kt&&!kl&&al(t),nl()},onKeyDown:kl||"none"===Je&&!Kt?void 0:t=>{const e=T?"ArrowDown":"ArrowRight",l=T?"ArrowUp":"ArrowLeft";if(t.key===e)ol(1);else if(t.key===l)ol(-1);else if("Home"===t.key)il(0);else if("End"===t.key)il(ll-1);else{if("Escape"!==t.key)return;null===el&&null!==Jt?ne(null):nl()}t.preventDefault()},onBlur:nl},overlay:null===Jt||kl?null:t("button",{type:"button",onClick:()=>ne(null),className:["mp-chart__reset absolute end-0 top-0 z-10 cursor-pointer","text-mp-primary text-mp-label-medium rounded-mp-xs px-2 py-1","appearance-none border-0 bg-transparent [font:inherit]","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2"].join(" "),children:wt.showAll}),tooltip:null!==el&&cl.length>0&&"none"!==Je&&null===Ft?Ge.render?t("div",{"aria-hidden":"true",className:"pointer-events-none absolute z-10",style:{left:pl,top:fl,transform:`translate(${xl?"calc(-100% - 12px)":"12px"}, -50%)`},children:Ge.render({index:el,category:le[el]??el,items:ul,total:dl})}):t(m,{heading:ml,items:ul,total:dl,totalLabel:wt.total,x:pl,y:fl,flip:xl,size:kt}):null,legend:vl?t(c,{names:Vt,colors:Et,options:gl,visibility:_t,size:kt,swatch:at,colorNames:"series"===ft,values:gl.showValue&&null!==el?w.map((t,e)=>{const l=ee[e]?.[el]?.value;return null==l?void 0:Xt(l)}):void 0}):null,status:{heading:ml,items:ul,total:dl,totalLabel:wt.total},table:kl?null:e(l,{children:[ot?.(At)??t(d,{id:At,caption:ut??wt.table,corner:he?.label??wt.category,categories:le,names:Vt,values:ee,format:Xt,locale:Mt,empty:zt.empty}),0===Ke.length?null:t("ul",{id:$t,className:f,children:Ke.map((t,l)=>e("li",{children:[t.label,":"," ",void 0===t.to?He(t.value):`${He(t.value)}–${He(t.to)}`]},l))})]}),children:kl?t("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:pt??zt.empty}):Ct>0&&ve>0?e("svg",{width:Ct,height:ve,viewBox:`0 0 ${Ct} ${ve}`,"aria-hidden":"true",className:"block overflow-visible",children:[t(U,{plot:Te,scale:ce,horizontal:T,categoryPx:Xe,categoryScale:de,categoryValuePx:Ee,valuePx:Ye,tickTexts:me,categoryTexts:$e,valueAxis:se,categoryAxis:he,fontSize:re,zeroPx:Ze,turn:Ce,tickBand:Be}),t(O,{marks:Ue,plot:Te,pass:"band",fontSize:re}),null===el||lt||"index"!==Je||!1===Ge.crosshair?null:(()=>{const e=Xe(el);return t("line",T?{x1:Te.left,x2:Te.left+Te.width,y1:Te.top+e,y2:Te.top+e,stroke:V,strokeWidth:1}:{x1:Te.left+e,x2:Te.left+e,y1:Te.top,y2:Te.top+Te.height,stroke:V,strokeWidth:1})})(),yt(bl),t(O,{marks:Ue,plot:Te,pass:"line",fontSize:re}),null===Ft?null:(()=>{const e=[Ft.start,Ft.to].map(t=>(T?Te.top:Te.left)+Xe(t)).sort((t,e)=>t-e),l=Math.max(Le.step,1),n=e[0]-l/2,a=e[1]-e[0]+l;return t("rect",{x:T?Te.left:n,y:T?n:Te.top,width:T?Te.width:a,height:T?a:Te.height,fill:"var(--_mp-color-primary)",fillOpacity:.12,stroke:"var(--_mp-color-primary)",strokeWidth:1})})()]}):null})}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r,Fragment as t,jsxs as o}from"react/jsx-runtime";import*as e from"react";import{Field as a}from"@base-ui/react/field";import{PROSE_TEXT as n}from"./scale.js";const i={xs:"start-1",sm:"start-2",md:"start-3",lg:"start-3",xl:"start-4"},s={xs:"top-[18px]",sm:"top-[18px]",md:"top-5",lg:"top-5",xl:"top-5"};function d(e,a){return o(t,{children:[e,a?r("span",{"aria-hidden":"true",children:" *"}):null]})}export function MPFieldOutline({label:t,required:o=!1,notched:e=!0}){return r("fieldset",{"aria-hidden":"true",className:["pointer-events-none absolute inset-0 -top-[5px] m-0 min-w-0 px-2 pt-0","rounded-mp-xs border border-mp-outline","transition-[border-color] duration-(--mp-sys-motion-duration-short4)","group-hover:border-mp-on-surface","group-focus-within:border-2 group-focus-within:border-mp-primary","group-data-focused:border-2 group-data-focused:border-mp-primary","group-data-invalid:border-mp-error","group-data-disabled:border-mp-on-surface/12"].join(" "),children:t?r("legend",{className:["text-mp-body-small invisible float-none block h-[11px] w-auto overflow-hidden p-0","leading-none","ease-mp-standard transition-[max-width,padding]","duration-(--mp-sys-motion-duration-short4)",e?"max-w-full px-1":"max-w-0 px-0"].join(" "),children:d(t,o)}):null})}export function MPFieldLabel({size:t,label:o,required:e=!1,htmlFor:p,shrunk:l=!0,multiline:u=!1}){return r(a.Label,{htmlFor:p,"data-mp-shrunk":l?"":void 0,className:["text-mp-on-surface-variant","ease-mp-standard transition-[color,top,font-size,max-width]","duration-(--mp-sys-motion-duration-short4)","pointer-events-none absolute -translate-y-1/2 px-1 leading-none",i[t],l?"text-mp-body-small top-0 max-w-none":[n[t],"max-w-[calc(100%-2rem)] truncate",u?s[t]:"top-1/2"].join(" "),"group-focus-within:text-mp-primary","group-data-focused:text-mp-primary","group-data-invalid:text-mp-error","group-data-disabled:text-mp-on-surface/38"].join(" "),children:d(o,e)})}export function useFloatingLabel({floating:r,filled:t,pinned:o=!1}){const[a,n]=e.useState(!1);return{shrunk:!r||t||a||o,focusProps:{onFocusCapture:()=>n(!0),onBlurCapture:r=>{r.currentTarget.contains(r.relatedTarget)||n(!1)}}}}
2
+ import{jsx as r,Fragment as t,jsxs as e}from"react/jsx-runtime";import*as o from"react";import{Field as a}from"@base-ui/react/field";import{PROSE_TEXT as n}from"./scale.js";const i={xs:"start-1",sm:"start-2",md:"start-3",lg:"start-3",xl:"start-4"},s={xs:"top-[18px]",sm:"top-[18px]",md:"top-5",lg:"top-5",xl:"top-5"};function d(o,a){return e(t,{children:[o,a?r("span",{"aria-hidden":"true",children:" *"}):null]})}export function MPFieldOutline({label:t,required:e=!1,notched:o=!0}){return r("fieldset",{"aria-hidden":"true",className:["pointer-events-none absolute inset-0 m-0 min-w-0 px-2 pt-0",t?"-top-[5px]":"","text-start","rounded-mp-xs border border-mp-outline","transition-[border-color] duration-(--mp-sys-motion-duration-short4)","group-hover:border-mp-on-surface","group-focus-within:border-2 group-focus-within:border-mp-primary","group-data-focused:border-2 group-data-focused:border-mp-primary","group-data-invalid:border-mp-error","group-data-disabled:border-mp-on-surface/12"].filter(Boolean).join(" "),children:t?r("legend",{className:["text-mp-body-small invisible float-none block h-[11px] w-auto overflow-hidden p-0","leading-none","ease-mp-standard transition-[max-width,padding]","duration-(--mp-sys-motion-duration-short4)",o?"max-w-full px-1":"max-w-0 px-0"].join(" "),children:d(t,e)}):null})}export function MPFieldLabel({size:t,label:e,required:o=!1,htmlFor:p,shrunk:l=!0,multiline:u=!1}){return r(a.Label,{htmlFor:p,"data-mp-shrunk":l?"":void 0,className:["text-mp-on-surface-variant","ease-mp-standard transition-[color,top,font-size,max-width]","duration-(--mp-sys-motion-duration-short4)","pointer-events-none absolute -translate-y-1/2 px-1 leading-none",i[t],l?"text-mp-body-small top-0 max-w-none":[n[t],"max-w-[calc(100%-2rem)] truncate",u?s[t]:"top-1/2"].join(" "),"group-focus-within:text-mp-primary","group-data-focused:text-mp-primary","group-data-invalid:text-mp-error","group-data-disabled:text-mp-on-surface/38"].join(" "),children:d(e,o)})}export function useFloatingLabel({floating:r,filled:t,pinned:e=!1}){const[a,n]=o.useState(!1);return{shrunk:!r||t||a||e,focusProps:{onFocusCapture:()=>n(!0),onBlurCapture:r=>{r.currentTarget.contains(r.relatedTarget)||n(!1)}}}}
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Field as r}from"@base-ui/react/field";import{Popover as i}from"@base-ui/react/popover";import{MPIcon as t}from"../components/icon/MPIcon.js";import{CloseIcon as l}from"../constants/icons.js";import{accentSlots as s}from"./accent.js";import{MPFieldLabel as a,MPFieldOutline as p,useFloatingLabel as c}from"./FieldOutline.js";import{MPStateLayer as u}from"./StateLayer.js";import{MPSupportingText as m}from"./SupportingText.js";import{MPWidthSizer as d}from"./WidthSizer.js";import{displaySamples as f}from"./date.js";import{CONTROL_ICON as h,hasContent as x,PROSE_TEXT as g}from"./scale.js";import{FADE as b,PORTAL_LAYER as y}from"./surface.js";export function useDisplaySamples(e,n){const r=`${e??""} ${JSON.stringify(n)}`;return o.useMemo(()=>f(e,n),[r])}const j={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}};export const POPUP_PAD={xs:"p-1.5",sm:"p-2",md:"p-2.5",lg:"p-3",xl:"p-3.5"};export function MPPickerShell({slug:f,size:v="md",color:P="primary",fullWidth:N=!1,label:k,floatingLabel:w=!0,description:C,errorMessage:O,startIcon:M,required:D=!1,disabled:F=!1,readOnly:S=!1,id:z,className:B,style:_,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,display:A,samples:E,empty:L,clearable:W=!1,onClear:J,open:V,onOpenChange:Z,labels:G,hiddenValues:H,children:Q,triggerRef:X}){const Y=x(O),ee=j[v],ne=o.useId(),oe=z??ne,re=W&&!L&&!(F||S),{shrunk:ie,focusProps:te}=c({floating:w&&x(k),filled:!L,pinned:V||x(M)});return n(r.Root,{disabled:F,invalid:Y,"data-mp-size":v,className:[`mp-${f} group flex-col align-top`,N?"flex w-full":"inline-flex w-fit",B??""].filter(Boolean).join(" "),style:{...s(P),..._},...te,children:[n(i.Root,{open:V,onOpenChange:Z,children:[n("div",{className:"relative w-full",children:[n(i.Trigger,{id:oe,ref:X,disabled:F,nativeButton:!0,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",ee.padding,re?"pe-10":"",ee.height,g[v],F?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(S?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[M?e("span",{className:["flex shrink-0 items-center",F?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null,n("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:["w-full truncate text-start",L&&!F?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:L&&!ie?null:A}),e(d,{samples:E??[]})]})]}),re?n("button",{type:"button","aria-label":G.clear,onClick:J,className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(u,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(t,{icon:l,size:h[v]})]}):null,e(p,{label:k,required:D,notched:ie}),x(k)?e(a,{size:v,label:k,required:D,htmlFor:oe,shrunk:ie}):null]}),e(i.Portal,{children:e(i.Positioner,{className:y,sideOffset:4,align:"start",children:e(i.Popup,{initialFocus:!1,style:s(P),className:[`mp-${f}__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container`,"text-mp-on-surface outline-none",POPUP_PAD[v],g[v],b].join(" "),children:Q})})})]}),e(m,{description:C,errorMessage:O,className:ee.padding}),H?.map((n,o)=>e("input",{type:"hidden",name:n.name,value:n.value},o))]})}export function MPPickerFooter({children:n}){return e("div",{className:"border-mp-outline-variant flex items-center justify-end gap-1 border-t pt-1.5",children:n})}export function MPPickerDivider(){return e("div",{"aria-hidden":"true",className:"bg-mp-outline-variant w-px self-stretch"})}export const FOOTER_SIZE={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};
2
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as o from"react";import{Field as r}from"@base-ui/react/field";import{Popover as i}from"@base-ui/react/popover";import{MPIcon as t}from"../components/icon/MPIcon.js";import{CloseIcon as l}from"../constants/icons.js";import{accentSlots as s}from"./accent.js";import{MPFieldLabel as a,MPFieldOutline as p,useFloatingLabel as c}from"./FieldOutline.js";import{MPStateLayer as u}from"./StateLayer.js";import{MPSupportingText as m}from"./SupportingText.js";import{MPWidthSizer as d}from"./WidthSizer.js";import{displaySamples as f}from"./date.js";import{CONTROL_ICON as h,hasContent as x,PROSE_TEXT as g}from"./scale.js";import{FADE as b,PORTAL_LAYER as y}from"./surface.js";export function useDisplaySamples(e,n){const r=`${e??""} ${JSON.stringify(n)}`;return o.useMemo(()=>f(e,n),[r])}const j={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}};export const POPUP_PAD={xs:"p-1.5",sm:"p-2",md:"p-2.5",lg:"p-3",xl:"p-3.5"};export function MPPickerShell({slug:f,size:v="md",color:P="primary",fullWidth:N=!1,label:k,floatingLabel:w=!0,description:C,errorMessage:O,startIcon:M,required:D=!1,disabled:F=!1,readOnly:S=!1,id:z,className:B,style:_,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,display:A,samples:E,empty:L,clearable:W=!1,onClear:J,open:V,onOpenChange:Z,labels:G,hiddenValues:H,children:Q,triggerRef:X}){const Y=x(O),ee=j[v],ne=o.useId(),oe=z??ne,re=W&&!L&&!(F||S),{shrunk:ie,focusProps:te}=c({floating:w&&x(k),filled:!L,pinned:V||x(M)});return n(r.Root,{disabled:F,invalid:Y,"data-mp-size":v,className:[`mp-${f} group flex-col align-top`,N?"flex w-full":"inline-flex w-fit",B??""].filter(Boolean).join(" "),style:{...s(P),..._},...te,children:[n(i.Root,{open:V,onOpenChange:Z,children:[n("div",{className:"relative w-full",children:[n(i.Trigger,{id:oe,ref:X,disabled:F,nativeButton:!0,onKeyDown:I,onKeyUp:K,onFocus:R,onBlur:U,onClick:$,onDoubleClick:q,onContextMenu:T,className:["relative flex w-full items-center gap-2 select-none","appearance-none border-0 bg-transparent font-[inherit] outline-none",ee.padding,re?"pe-10":"",ee.height,g[v],F?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(S?"cursor-default":"cursor-pointer")].filter(Boolean).join(" "),children:[M?e("span",{className:["flex shrink-0 items-center",F?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:M}):null,n("span",{className:"flex min-w-0 flex-1 flex-col",children:[e("span",{className:["w-full truncate text-start",L&&!F?"text-mp-on-surface-variant":""].filter(Boolean).join(" "),children:L&&!ie?null:A}),e(d,{samples:E??[]})]})]}),re?n("button",{type:"button","aria-label":G.clear,onClick:J,className:["group/clear rounded-mp-full text-mp-on-surface-variant absolute inset-y-0","end-1 my-auto flex size-8 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent p-0 font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "),children:[e(u,{className:"group-hover/clear:opacity-8 group-focus-visible/clear:opacity-10"}),e(t,{icon:l,size:h[v]})]}):null,e(p,{label:k,required:D,notched:ie}),x(k)?e(a,{size:v,label:k,required:D,htmlFor:oe,shrunk:ie}):null]}),e(i.Portal,{children:e(i.Positioner,{className:y,sideOffset:4,align:"start",children:e(i.Popup,{initialFocus:!1,style:s(P),className:[`mp-${f}__popup rounded-mp-md shadow-mp-2 bg-mp-surface-container`,"text-mp-on-surface outline-none",POPUP_PAD[v],g[v],b].join(" "),children:Q})})})]}),e(m,{description:C,errorMessage:O,className:ee.padding}),H?.map((n,o)=>e("input",{type:"hidden",name:n.name,value:n.value},o))]})}export function MPPickerFooter({children:n}){return e("div",{className:"border-mp-outline-variant flex items-center justify-end gap-1 border-t pt-1.5",children:n})}export function MPPickerDivider(){return e("div",{"aria-hidden":"true",className:"bg-mp-outline-variant w-px self-stretch"})}export const FOOTER_SIZE={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"};
@@ -0,0 +1,60 @@
1
+ /**
2
+ * The wedge that points a floating sheet back at what opened it.
3
+ *
4
+ * Three components draw one — `MPTooltip`, `MPPopover` and `MPHoverCard` — and
5
+ * all three drew it themselves: the same four turn classes, the same viewBox,
6
+ * the same path, the same `aria-hidden`. Only the fill ever differed, and only
7
+ * because a tooltip is drawn on its own ink rather than on a container tone.
8
+ *
9
+ * Three copies of one shape is three chances for one of them to be edited alone,
10
+ * and the failure would be quiet — a wedge one pixel out of line with the sheet
11
+ * above it is not something anybody reports.
12
+ *
13
+ * The positioning stays with the caller. Each of the three has its own `Arrow`
14
+ * part from Base UI, which is what measures the collision and reports the side,
15
+ * and none of them can be swapped for another. So this takes the **className**
16
+ * that goes on that part and the drawing that goes inside it, and the caller
17
+ * spells the two lines that say which part it is.
18
+ *
19
+ * Nothing here is exported from `src/index.ts`. It is the library talking to
20
+ * itself, in the sense `internal/` always means.
21
+ */
22
+ import * as React from 'react';
23
+ /**
24
+ * Which way the wedge is turned, by the side Base UI says it landed on.
25
+ *
26
+ * Drawn pointing down once and rotated to match, which is a rotation of a glyph
27
+ * — the one allowance the rule against moving a surface makes. The one-pixel
28
+ * overlap on each side is what closes the hairline a fractional position would
29
+ * otherwise leave between the wedge and the sheet it belongs to.
30
+ */
31
+ export declare const POPUP_ARROW_TURN: string;
32
+ /**
33
+ * The drawing itself, twice as wide as it is tall.
34
+ *
35
+ * `aria-hidden`, because the wedge says nothing a reader has not already been
36
+ * told: the sheet it hangs off is announced by the thing that opened it, and an
37
+ * arrow announced separately would be a second object in the tree that is really
38
+ * a corner of the first.
39
+ *
40
+ * @param size the wedge's width in pixels. It is half that tall.
41
+ * @param fill the surface the sheet is drawn on, as a custom property.
42
+ */
43
+ export declare function PopupArrow({ size, fill }: {
44
+ size: number;
45
+ fill: string;
46
+ }): React.JSX.Element;
47
+ /**
48
+ * How wide the wedge is at each rung.
49
+ *
50
+ * `MPPopover` and `MPHoverCard` share this one; `MPTooltip` keeps its own, two
51
+ * pixels narrower throughout, because a tooltip is a strip of text rather than a
52
+ * sheet and a wedge sized for a card reads as a spike coming off it.
53
+ */
54
+ export declare const POPUP_ARROW_SIZE: {
55
+ readonly xs: 8;
56
+ readonly sm: 9;
57
+ readonly md: 10;
58
+ readonly lg: 11;
59
+ readonly xl: 12;
60
+ };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{jsx as t}from"react/jsx-runtime";export const POPUP_ARROW_TURN=/*@__PURE__*/["data-[side=top]:bottom-[-1px]","data-[side=bottom]:top-[-1px] data-[side=bottom]:rotate-180","data-[side=left]:right-[-1px] data-[side=left]:-rotate-90","data-[side=right]:left-[-1px] data-[side=right]:rotate-90"].join(" ");export function PopupArrow({size:e,fill:a}){return t("svg",{width:e,height:e/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:t("path",{d:"M0 0h10L5 5z",fill:a})})}export const POPUP_ARROW_SIZE={xs:8,sm:9,md:10,lg:11,xl:12};
@@ -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 c=n(s)?"error":n(o)?"description":"none",m=r.useRef(null),p=r.useRef(c);r.useLayoutEffect(()=>{const e=m.current,r=p.current;p.current=c,e&&c!==r&&"none"!==c&&(e.dataset.mpReveal="none"===r?"open":"swap",e.style.animationName="none",e.offsetWidth,e.style.animationName="")},[c]);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:m,className:"mp-supporting-text__reveal",children:e(t.Error,{match:!0,className:`${l} text-mp-error`,children:s})}):n(o)?e("div",{ref:m,className:"mp-supporting-text__reveal",children:e(t.Description,{className:`${l} text-mp-on-surface-variant`,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 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`})}
@@ -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, MPSize } from '../types.js';
3
3
  /**
4
4
  * The arithmetic and the vocabulary the charts share.
5
5
  *
@@ -18,16 +18,6 @@ import type { MPChartCategory, MPChartCurve, MPChartDatum, MPChartSeries, MPSize
18
18
  * second chart.
19
19
  */
20
20
  export declare const CHART_SLOTS = 8;
21
- /**
22
- * How many series may be told apart when **any two marks can touch** — a
23
- * scatter, a bubble chart, a heatmap.
24
- *
25
- * Three. The eight slots are separable pair-by-pair only that far, and no
26
- * ordering of eight does better; it is a property of the colour space rather
27
- * than of this palette. The stylesheet's note on `--_mp-chart-1` has the
28
- * measurements.
29
- */
30
- export declare const CHART_TOUCHING_SLOTS = 3;
31
21
  /**
32
22
  * What colour a mark is, in the fixed order the palette is handed out in.
33
23
  *
@@ -59,6 +49,16 @@ export declare const COMPACT_FROM = 10000;
59
49
  * component that compacted it anyway would be arguing.
60
50
  */
61
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;
62
62
  /** Which way a figure has moved, and whether that is the good direction. */
63
63
  export interface MPStatisticDelta {
64
64
  /** The change, in the value's own units. */
@@ -99,6 +99,24 @@ export type PlotPoint = {
99
99
  * invented, because it looks exactly like data.
100
100
  */
101
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[];
102
120
  /**
103
121
  * The ribbon between two runs of points.
104
122
  *
@@ -153,6 +171,26 @@ export declare function extentOf(values: readonly (number | null)[], min?: numbe
153
171
  min: number;
154
172
  max: number;
155
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;
156
194
  /**
157
195
  * The lowest and highest a set of series reaches.
158
196
  *
@@ -246,8 +284,10 @@ export declare function truncate(text: string, maxWidth: number, fontSize: numbe
246
284
  /**
247
285
  * How many labels an axis can show before they collide — every nth.
248
286
  *
249
- * Every nth rather than rotating them. A rotated axis is unreadable at a
250
- * glance, and it takes a band of the plot to be unreadable in.
287
+ * Dropping labels is the last resort rather than the first. An axis that has
288
+ * turned its labels fits far more of them, so `turnedStep` below is what this
289
+ * is handed once a turn has been decided on, and the stride only starts
290
+ * throwing names away when even the turned ones would overlap.
251
291
  */
252
292
  export declare function tickStride(count: number, available: number, labelWidth: number): number;
253
293
  /**
@@ -271,6 +311,44 @@ export declare function showsTick(index: number, count: number, stride: number,
271
311
  * halves can meet.
272
312
  */
273
313
  export declare function fitsLast(count: number, stride: number, step: number, labelWidth: number): boolean;
314
+ /** How much clear page two flat labels want between them. */
315
+ export declare const LABEL_AIR = 12;
316
+ /**
317
+ * How far a label lies off the horizontal, in degrees.
318
+ *
319
+ * `auto` measures rather than guesses. Flat labels are what a reader takes in
320
+ * fastest, so they are kept while the widest one still fits its slot; past that
321
+ * the choice is between turning them and cutting them, and a name cut to
322
+ * "Onbo…" has lost the thing it was there to say. 45° is tried first because it
323
+ * is the shallower turn and the easier read, and the upright one is taken only
324
+ * where even a turned label's line box would not fit between two ticks.
325
+ *
326
+ * Short labels are left alone whatever the crowding, because an axis of "Jan",
327
+ * "Feb", "Mar" is crowded by how many of them there are rather than by how long
328
+ * any one is — see `TURN_FROM`.
329
+ */
330
+ export declare function tickTurn(mode: MPChartTickLabels | undefined, texts: readonly string[], fontSize: number, slot: number): number;
331
+ /**
332
+ * How much room one turned label needs **along** its axis.
333
+ *
334
+ * A flat label collides with its neighbour across its own width; a turned one
335
+ * collides across its line box instead, opened out by the angle. That is the
336
+ * whole reason turning helps at all — the line box does not grow with the
337
+ * label, so a twenty-character name and a four-character one need the same
338
+ * distance between ticks.
339
+ */
340
+ export declare function turnedStep(angle: number, fontSize: number): number;
341
+ /**
342
+ * How deep a band of turned labels is, for the widest of them.
343
+ *
344
+ * The depth is the label's own width projected onto the axis' normal, plus the
345
+ * half line box that hangs to the side of the anchor. Capped by the caller
346
+ * rather than here: how much of a plot may be given to its labels is a question
347
+ * about the box, and this function has never seen one.
348
+ */
349
+ export declare function turnedBand(angle: number, widest: number, fontSize: number): number;
350
+ /** The widest a label may print at before a band of `depth` would overflow. */
351
+ export declare function turnedRoom(angle: number, depth: number, fontSize: number): number;
274
352
  /** One datum, unpacked into the parts the frame reads. */
275
353
  export interface ChartValue {
276
354
  value: number | null;
@@ -1 +1 @@
1
- export const CHART_SLOTS=8;export const CHART_TOUCHING_SLOTS=3;const t=new Set(["primary","secondary","tertiary","error"]);export function seriesColor(n,o){return o?t.has(o)?`var(--_mp-color-${o})`:o:`var(--_mp-chart-${n%8+1})`}export const COMPACT_FROM=1e4;export function formatStatistic(t,n,o,r){return Number.isFinite(t)?o?new Intl.NumberFormat(n,o).format(t):r&&Math.abs(t)>=1e4?new Intl.NumberFormat(n,{notation:"compact",maximumFractionDigits:1}).format(t):new Intl.NumberFormat(n).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 n(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,o){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=>n(t,o)).join("")}export function bandPath(t,o,r){const e=[];let a=[],u=[];const i=()=>{a.length>0&&e.push(`${n(a,r)}${n([...u].reverse(),r).replace(/^M/,"L")}Z`),a=[],u=[]};return t.forEach((t,n)=>{const r=o[n];null!==t&&null!=r?(a.push(t),u.push(r)):i()}),i(),e.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 u=Math.abs(o),i=Math.abs(r);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,o)=>t>0?`a${t} ${t} 0 0 1 ${n} ${o}`:"";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,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,u=0;for(const o of t){const t=o[a]?.value;null!=t&&(e=!0,t>=0?n+=t:u+=t)}o=Math.min(o,u),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 o(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:r=5,includeZero:e=!0}=n;let a=n.min??t?.min??0,u=n.max??t?.max??1;if(e&&void 0===n.min&&(a=Math.min(a,0)),e&&void 0===n.max&&(u=Math.max(u,0)),u===a){const t=Math.abs(u)>0?.5*Math.abs(u):1;a-=t,u+=t}const i=void 0!==n.min&&void 0!==n.max?function(t,n){const r=10**Math.floor(Math.log10(t/Math.max(1,n)));let e=o(t/Math.max(1,n)),a=1/0;for(const o of[.1,1,10])for(const u of[1,2,2.5,5]){const i=u*o*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<a&&(a=s,e=i)}return e}(u-a,r):o((u-a)/Math.max(1,r)),l=void 0!==n.min?a:Math.floor(a/i)*i,c=void 0!==n.max?u:Math.ceil(u/i)*i,s=c-l||1,x=[];for(let t=l;t<=c+1e-9*i;t+=i)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(t,n){return t instanceof Date?new Intl.DateTimeFormat(n,{month:"short",day:"numeric"}).format(t):"number"==typeof t?new Intl.NumberFormat(n).format(t):t}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 u=a-e;if(Math.abs(u)<1e-9||o<=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,m=x?0:1,h=polarPoint(t,n,o,e),$=polarPoint(t,n,o,c),f=polarPoint(t,n,o,l),p=i?`A${o} ${o} 0 0 ${x} ${$.x} ${$.y}A${o} ${o} 0 0 ${x} ${f.x} ${f.y}`:`A${o} ${o} 0 ${s} ${x} ${f.x} ${f.y}`;if(r<=0)return i?`M${h.x} ${h.y}${p}Z`:`M${t} ${n}L${h.x} ${h.y}${p}Z`;const M=polarPoint(t,n,r,l),b=polarPoint(t,n,r,c),d=polarPoint(t,n,r,e),y=i?`A${r} ${r} 0 0 ${m} ${b.x} ${b.y}A${r} ${r} 0 0 ${m} ${d.x} ${d.y}`:`A${r} ${r} 0 ${s} ${m} ${d.x} ${d.y}`;return`M${h.x} ${h.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 u=toNumber(t.x??n?.[a]??a);null!==u&&(e=!0,o=Math.min(o,u),r=Math.max(r,u))})}),e?{min:o,max:r}:null}export const MARK_SHAPES=["circle","square","triangle","diamond","cross"];const r={circle:1,square:.886,triangle:1.35,diamond:1.25,cross:1.1};export function markPath(t,n,o,e){const a=e*r[t];switch(t){case"square":return`M${n-a} ${o-a}h${2*a}v${2*a}h${2*-a}Z`;case"triangle":return`M${n} ${o-a}L${n+.866*a} ${o+.5*a}L${n-.866*a} ${o+.5*a}Z`;case"diamond":return`M${n} ${o-a}L${n+a} ${o}L${n} ${o+a}L${n-a} ${o}Z`;case"cross":return`M${n-a} ${o-a}L${n+a} ${o+a}M${n+a} ${o-a}L${n-a} ${o+a}`;default:return`M${n-a} ${o}a${a} ${a} 0 1 0 ${2*a} 0a${a} ${a} 0 1 0 ${2*-a} 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 c=Math.max(0,Math.min(e,u/2,i/2)),l="both"===a,s={tl:l||"top"===a||"left"===a?c:0,tr:l||"top"===a||"right"===a?c:0,br:l||"bottom"===a||"right"===a?c:0,bl:l||"bottom"===a||"left"===a?c: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=t.filter(t=>null!==t&&Number.isFinite(t)),e=n??(o.length>0?Math.min(...o):0),a=r??(o.length>0?Math.max(...o):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,c=t/i,l=Math.round(c);if(l<1||Math.abs(c-l)>1e-9)continue;const s=Math.abs(l-n);s<e&&(e=s,o=i)}return o}(a-e,r):i((a-e)/Math.max(1,r)),c=void 0!==n.min?e:Math.floor(e/u)*u,l=void 0!==n.max?a:Math.ceil(a/u)*u,s=l-c||1,x=[];for(let t=c;t<=l+1e-9*u;t+=u)x.push(Number(t.toFixed(12)));return{min:c,max:l,ticks:x,fraction:t=>(t-c)/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)}}export function textWidth(t,n){let r=0;for(const n of t)r+=/[ᄀ-ᇿ⺀-꓏가-퟿豈-﫿︰-﹏]/.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 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,c=i?e+2*Math.PI*Math.sign(u||1):a,l=e+(c-e)/2,s=Math.abs(c-e)>Math.PI?1:0,x=c>e?1:0,h=x?0:1,f=polarPoint(t,n,r,e),m=polarPoint(t,n,r,l),$=polarPoint(t,n,r,c),p=i?`A${r} ${r} 0 0 ${x} ${m.x} ${m.y}A${r} ${r} 0 0 ${x} ${$.x} ${$.y}`:`A${r} ${r} 0 ${s} ${x} ${$.x} ${$.y}`;if(o<=0)return i?`M${f.x} ${f.y}${p}Z`:`M${t} ${n}L${f.x} ${f.y}${p}Z`;const M=polarPoint(t,n,o,c),b=polarPoint(t,n,o,l),d=polarPoint(t,n,o,e),y=i?`A${o} ${o} 0 0 ${h} ${b.x} ${b.y}A${o} ${o} 0 0 ${h} ${d.x} ${d.y}`:`A${o} ${o} 0 ${s} ${h} ${d.x} ${d.y}`;return`M${f.x} ${f.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 l={circle:1,square:.886,triangle:1.35,diamond:1.25,cross:1.1};export function markPath(t,n,r,o){const e=o*l[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)"}
@@ -4,15 +4,6 @@ export type MPColorScheme = 'light' | 'dark' | 'system';
4
4
  export type MPResolvedColorScheme = 'light' | 'dark';
5
5
  export declare const SCHEME_ATTRIBUTE = "data-mp-scheme";
6
6
  export declare const DEFAULT_STORAGE_KEY = "mp-color-scheme";
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;
16
7
  export declare function setScheme(storageKey: string, scheme: MPColorScheme): void;
17
8
  export declare function useChosenScheme(storageKey: string): MPColorScheme;
18
9
  /**
@@ -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 applyScheme(e){if("undefined"==typeof document)return;const t=document.documentElement;"system"===e?t.removeAttribute("data-mp-scheme"):t.setAttribute("data-mp-scheme",e)}export function setScheme(e,t){o=t,function(e,t){try{"system"===t?localStorage.removeItem(e):localStorage.setItem(e,t)}catch{}}(e,t),applyScheme(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";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()}
@@ -120,7 +120,8 @@ export declare function searchText(value: unknown): string;
120
120
  /** Every string a row can be found by, folded once and joined into one haystack. */
121
121
  export declare function searchHaystack(values: readonly unknown[]): string;
122
122
  /**
123
- * One field, quoted only when it has to be.
123
+ * One field, quoted only when it has to be, and defused when a spreadsheet would
124
+ * otherwise run it.
124
125
  *
125
126
  * The escaping is the whole job here and getting it wrong is silent: a comma
126
127
  * inside a cell shifts every column after it by one, and nobody notices until a
@@ -128,10 +129,28 @@ export declare function searchHaystack(values: readonly unknown[]): string;
128
129
  * are in these six lines — a field is quoted if it holds the separator, a quote
129
130
  * or a line break, and a quote inside a quoted field is written twice.
130
131
  *
132
+ * ## Why a leading apostrophe
133
+ *
134
+ * RFC 4180 has nothing to say about the second problem, which is that a
135
+ * spreadsheet does not read a CSV as data. A cell that begins `=` or `@` or `+`
136
+ * is a **formula**, and `=HYPERLINK("https://…"&A1)` in a table of things other
137
+ * people typed is one click from posting a colleague's row to somebody else's
138
+ * server. It is the reader's own spreadsheet that runs it, so nothing this
139
+ * library does at render time can reach it — the file is where it has to be
140
+ * stopped.
141
+ *
142
+ * An apostrophe in front is the answer Excel, Sheets and LibreOffice all
143
+ * understand: it is their own marker for "the rest of this is text", and all
144
+ * three strip it on the way in. It is not free. A plain CSV parser — `pandas`,
145
+ * a `csv` module, a database loader — has no such rule and will see the
146
+ * apostrophe as part of the value, which is why `escapeFormulas` exists: a file
147
+ * going to a machine rather than to a person is a file nobody is going to open
148
+ * in a spreadsheet, and it should go out byte for byte.
149
+ *
131
150
  * `null` and `undefined` are empty rather than the words "null" and "undefined",
132
151
  * which is what `String()` would put in the cell.
133
152
  */
134
- export declare function csvField(value: unknown, separator: string): string;
153
+ export declare function csvField(value: unknown, separator: string, escapeFormulas?: boolean): string;
135
154
  export interface MPCsvOptions {
136
155
  /** What goes between fields. `;` for the locales whose spreadsheets expect it. */
137
156
  separator?: string;
@@ -143,6 +162,20 @@ export interface MPCsvOptions {
143
162
  * mojibake. Every other reader ignores the mark.
144
163
  */
145
164
  bom?: boolean;
165
+ /**
166
+ * Puts an apostrophe in front of a cell a spreadsheet would otherwise run as a
167
+ * formula.
168
+ *
169
+ * On by default, because the rows in a table are usually things other people
170
+ * typed and the file is usually going to be opened in a spreadsheet — which is
171
+ * the pair that makes a cell beginning `=` an attack rather than a curiosity.
172
+ * A number keeps its sign either way; `csvField` has the whole argument.
173
+ *
174
+ * Turn it off for a file going to a parser rather than to a person, where the
175
+ * apostrophe would arrive as part of the value.
176
+ * @default true
177
+ */
178
+ escapeFormulas?: boolean;
146
179
  }
147
180
  /** Rows of already-stringable values, as one CSV document. */
148
181
  export declare function toCsv(rows: readonly (readonly unknown[])[], options?: MPCsvOptions): string;
@@ -1 +1 @@
1
- export function compareValues(e,t,n,o=!1){const r=null==e||""===e,i=null==t||""===t;if(r||i)return r&&i?0:r?1:-1;const a=o?-1:1;return"number"==typeof e&&"number"==typeof t?Number.isNaN(e)||Number.isNaN(t)?Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:-1:a*(e-t):"boolean"==typeof e&&"boolean"==typeof t?a*(Number(e)-Number(t)):e instanceof Date&&t instanceof Date?a*(e.getTime()-t.getTime()):a*n.compare(String(e),String(t))}export function sortRows(e,t,n){const o=[];for(const e of t){const t=n(e.key,e.direction);t&&o.push(t)}return 0===o.length?e:[...e].sort((e,t)=>{for(const n of o){const o=n(e,t);if(0!==o)return o}return 0})}export function nextSort(e,t,n){const o=e.find(e=>e.key===t),r=void 0===o?"asc":"asc"===o.direction?"desc":null;return n?null===r?e.filter(e=>e.key!==t):void 0===o?[...e,{key:t,direction:r}]:e.map(e=>e.key===t?{key:t,direction:r}:e):null===r?[]:[{key:t,direction:r}]}export function pageBounds(e,t,n){const o=Math.max(1,Math.floor(n)),r=Math.max(1,Math.ceil(e/o)),i=Math.min(Math.max(Math.floor(t),1),r),a=(i-1)*o;return{pages:r,page:i,start:a,end:Math.min(a+o,e)}}export function keysBetween(e,t,n){const o=e.indexOf(t),r=e.indexOf(n);return-1===o||-1===r?[]:e.slice(Math.min(o,r),Math.max(o,r)+1)}export function searchText(e){return null==e||"object"==typeof e?"":String(e).toLocaleLowerCase()}export function searchHaystack(e){return e.map(searchText).join("\0")}export function csvField(e,t){if(null==e)return"";const n=e instanceof Date?e.toISOString():"object"==typeof e?JSON.stringify(e):String(e);return/["\r\n]/.test(n)||n.includes(t)?`"${n.replaceAll('"','""')}"`:n}export function toCsv(e,t={}){const{separator:n=",",bom:o=!0}=t,r=e.map(e=>e.map(e=>csvField(e,n)).join(n)).join("\r\n");return o?`\ufeff${r}`:r}export function downloadText(e,t,n){const o=URL.createObjectURL(new Blob([e],{type:n})),r=document.createElement("a");r.href=o,r.download=t,r.rel="noopener",r.style.display="none",document.body.append(r),r.click(),r.remove(),requestAnimationFrame(()=>URL.revokeObjectURL(o))}export const DEFAULT_COLUMN_WIDTH=160;export const MIN_COLUMN_WIDTH=48;
1
+ export function compareValues(e,t,n,o=!1){const r=null==e||""===e,i=null==t||""===t;if(r||i)return r&&i?0:r?1:-1;const a=o?-1:1;return"number"==typeof e&&"number"==typeof t?Number.isNaN(e)||Number.isNaN(t)?Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:-1:a*(e-t):"boolean"==typeof e&&"boolean"==typeof t?a*(Number(e)-Number(t)):e instanceof Date&&t instanceof Date?a*(e.getTime()-t.getTime()):a*n.compare(String(e),String(t))}export function sortRows(e,t,n){const o=[];for(const e of t){const t=n(e.key,e.direction);t&&o.push(t)}return 0===o.length?e:[...e].sort((e,t)=>{for(const n of o){const o=n(e,t);if(0!==o)return o}return 0})}export function nextSort(e,t,n){const o=e.find(e=>e.key===t),r=void 0===o?"asc":"asc"===o.direction?"desc":null;return n?null===r?e.filter(e=>e.key!==t):void 0===o?[...e,{key:t,direction:r}]:e.map(e=>e.key===t?{key:t,direction:r}:e):null===r?[]:[{key:t,direction:r}]}export function pageBounds(e,t,n){const o=Math.max(1,Math.floor(n)),r=Math.max(1,Math.ceil(e/o)),i=Math.min(Math.max(Math.floor(t),1),r),a=(i-1)*o;return{pages:r,page:i,start:a,end:Math.min(a+o,e)}}export function keysBetween(e,t,n){const o=e.indexOf(t),r=e.indexOf(n);return-1===o||-1===r?[]:e.slice(Math.min(o,r),Math.max(o,r)+1)}export function searchText(e){return null==e||"object"==typeof e?"":String(e).toLocaleLowerCase()}export function searchHaystack(e){return e.map(searchText).join("\0")}const e=/^[=+\-@\t\r]/,t=/^[+-]?[\d.,\u00a0\u202f ]*\d[\d.,\u00a0\u202f ]*$/;export function csvField(n,o,r=!0){if(null==n)return"";const i=n instanceof Date?n.toISOString():"object"==typeof n?JSON.stringify(n):String(n),a=r&&function(n){return!!e.test(n)&&!t.test(n)&&!Number.isFinite(Number(n))}(i)?`'${i}`:i;return/["\r\n]/.test(a)||a.includes(o)?`"${a.replaceAll('"','""')}"`:a}export function toCsv(e,t={}){const{separator:n=",",bom:o=!0,escapeFormulas:r=!0}=t,i=e.map(e=>e.map(e=>csvField(e,n,r)).join(n)).join("\r\n");return o?`\ufeff${i}`:i}export function downloadText(e,t,n){const o=URL.createObjectURL(new Blob([e],{type:n})),r=document.createElement("a");r.href=o,r.download=t,r.rel="noopener",r.style.display="none",document.body.append(r),r.click(),r.remove(),requestAnimationFrame(()=>URL.revokeObjectURL(o))}export const DEFAULT_COLUMN_WIDTH=160;export const MIN_COLUMN_WIDTH=48;
@@ -54,10 +54,6 @@ export declare function isValidDate(value: unknown): value is Date;
54
54
  export declare function startOfDay(date: Date): Date;
55
55
  /** The first day of the month this date is in, at midnight. */
56
56
  export declare function startOfMonth(date: Date): Date;
57
- /** The first day of the year this date is in, at midnight. */
58
- export declare function startOfYear(date: Date): Date;
59
- /** How many days a month has, leap years included. */
60
- export declare function daysInMonth(year: number, month: number): number;
61
57
  /**
62
58
  * The first instant of the day, month or year a date falls in.
63
59
  *
@@ -68,8 +64,6 @@ export declare function daysInMonth(year: number, month: number): number;
68
64
  * another.
69
65
  */
70
66
  export declare function startOfUnit(date: Date, unit: MPCalendarView): Date;
71
- /** The last day of that same unit, at midnight — the other end of its span. */
72
- export declare function endOfUnit(date: Date, unit: MPCalendarView): Date;
73
67
  /** Today, at midnight. The one place the pickers read the clock for a *date*. */
74
68
  export declare function today(): Date;
75
69
  export declare function addDays(date: Date, amount: number): Date;
@@ -146,7 +140,14 @@ export declare function mergeDateAndTime(date: Date, time: Date): Date;
146
140
  export declare function calendarWeeks(month: Date, weekStartsOn: MPWeekday): Date[][];
147
141
  /** The first year on the page a given year falls on. 2026 → 2016 at 12 a page. */
148
142
  export declare function yearPageStart(year: number): number;
149
- /** A memoised `Intl.DateTimeFormat`. `undefined` locale means the runtime's own. */
143
+ /**
144
+ * A memoised `Intl.DateTimeFormat`. `undefined` locale means the runtime's own.
145
+ *
146
+ * The cache itself lives in `internal/intl.ts`, along with the bound it keeps
147
+ * and the two other `Intl` constructors the library asks for. This name stays
148
+ * because it is what the pickers call and because it says which formatter is
149
+ * meant, but it is now the shared cache underneath rather than a second one.
150
+ */
150
151
  export declare function dateFormatter(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
151
152
  /** Formats a date, tolerating the `null` a cleared picker holds. */
152
153
  export declare function formatDate(date: Date | null | undefined, locale: string | undefined, options: Intl.DateTimeFormatOptions): string;
@@ -185,6 +186,20 @@ export declare function withPlaceholder(samples: string[], placeholder: unknown)
185
186
  export declare function toISOYear(date: Date): string;
186
187
  export declare function toISOMonth(date: Date): string;
187
188
  export declare function toISODate(date: Date): string;
189
+ /**
190
+ * The spelling a given precision submits, as a table to look up.
191
+ *
192
+ * `MPCalendar` and `MPDatePicker` each kept this, identically, and each said in
193
+ * its own comment that the two had to agree — which is the argument for there
194
+ * being one of it. A calendar and a picker that submitted the same day two
195
+ * different ways would be two answers to one question.
196
+ *
197
+ * `YYYY-MM-DD` and `YYYY-MM` are what `<input type="date">` and
198
+ * `<input type="month">` submit. A year on its own has no input type behind it
199
+ * and is simply `YYYY` — the same string with the parts nobody chose taken off,
200
+ * rather than a day the server would have to know to ignore.
201
+ */
202
+ export declare const TO_ISO: Record<MPDatePrecision, (date: Date) => string>;
188
203
  export declare function toISOTime(date: Date, withSeconds?: boolean): string;
189
204
  export declare function toISODateTime(date: Date, withSeconds?: boolean): string;
190
205
  /**
@@ -209,18 +224,7 @@ export declare function monthLabels(locale: string | undefined, month?: 'short'
209
224
  * it is wrong for.
210
225
  */
211
226
  export declare function isMonthBeforeYear(locale: string | undefined): boolean;
212
- /** Does this locale put a clock on a 12-hour dial? */
213
227
  export declare function isHour12(locale: string | undefined): boolean;
214
228
  /** What this locale calls AM and PM. */
215
229
  export declare function meridiemLabels(locale: string | undefined): [string, string];
216
- /**
217
- * Which day the week starts on here — Sunday in the US and Korea, Monday across
218
- * most of Europe, Saturday in much of the Middle East.
219
- *
220
- * `Intl.Locale`'s week info is the right source and is also the least evenly
221
- * implemented corner of `Intl`: it is a getter in some engines, a method in
222
- * others, and absent in the rest. All three are handled, and the fallback is
223
- * Sunday rather than a throw — a calendar that renders starting on the wrong day
224
- * is a small annoyance, and a calendar that renders nothing is not.
225
- */
226
230
  export declare function localeWeekStart(locale: string | undefined): MPWeekday;
@@ -1 +1 @@
1
- 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 startOfYear(t){return makeDate(t.getFullYear(),0,1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function startOfUnit(t,e){return"year"===e?startOfYear(t):"month"===e?startOfMonth(t):startOfDay(t)}export function endOfUnit(t,e){return"year"===e?makeDate(t.getFullYear(),11,31):"month"===e?makeDate(t.getFullYear(),t.getMonth()+1,0):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);return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),daysInMonth(n.getFullYear(),n.getMonth()))),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(endOfUnit(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}function t(t,e,r){if(t.set(e,r),t.size>64){const e=t.keys().next();e.done||t.delete(e.value)}return r}const e=new Map;export function dateFormatter(r,n){const o=`${r??""}\0${JSON.stringify(n)}`,a=e.get(o);return a||t(e,o,new Intl.DateTimeFormat(r,n))}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 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(e,r,a="narrow"){const i=`w ${e??""} ${r} ${a}`,u=o.get(i);if(u)return u;const s=dateFormatter(e,{weekday:a});return t(o,i,Array.from({length:7},(t,e)=>s.format(addDays(n,(r+e)%7))))}export function monthLabels(e,r="short"){const n=`m ${e??""} ${r}`,a=o.get(n);if(a)return a;const i=dateFormatter(e,{month:r});return t(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)}export function isHour12(t){const e=dateFormatter(t,{hour:"numeric"}).resolvedOptions();return e.hourCycle?"h11"===e.hourCycle||"h12"===e.hourCycle:!0===e.hour12}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)]}export function localeWeekStart(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}
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))}