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.
- package/LICENSE +1 -1
- package/README.md +28 -18
- package/dist/a2ui/catalog.d.ts +104 -0
- package/dist/a2ui/catalog.js +1 -0
- package/dist/a2ui/components/MPA2uiAudioPlayer.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiAudioPlayer.js +2 -0
- package/dist/a2ui/components/MPA2uiButton.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiButton.js +2 -0
- package/dist/a2ui/components/MPA2uiCard.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiCard.js +2 -0
- package/dist/a2ui/components/MPA2uiCheckBox.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiCheckBox.js +2 -0
- package/dist/a2ui/components/MPA2uiChoicePicker.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiChoicePicker.js +2 -0
- package/dist/a2ui/components/MPA2uiColumn.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiColumn.js +2 -0
- package/dist/a2ui/components/MPA2uiDateTimeInput.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiDateTimeInput.js +2 -0
- package/dist/a2ui/components/MPA2uiDivider.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiDivider.js +2 -0
- package/dist/a2ui/components/MPA2uiIcon.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiIcon.js +2 -0
- package/dist/a2ui/components/MPA2uiImage.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiImage.js +2 -0
- package/dist/a2ui/components/MPA2uiList.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiList.js +2 -0
- package/dist/a2ui/components/MPA2uiModal.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiModal.js +2 -0
- package/dist/a2ui/components/MPA2uiRow.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiRow.js +2 -0
- package/dist/a2ui/components/MPA2uiSlider.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiSlider.js +2 -0
- package/dist/a2ui/components/MPA2uiTabs.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiTabs.js +2 -0
- package/dist/a2ui/components/MPA2uiText.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiText.js +2 -0
- package/dist/a2ui/components/MPA2uiTextField.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiTextField.js +2 -0
- package/dist/a2ui/components/MPA2uiVideo.d.ts +1 -0
- package/dist/a2ui/components/MPA2uiVideo.js +2 -0
- package/dist/a2ui/extended/MPA2uiBarChart.d.ts +1 -0
- package/dist/a2ui/extended/MPA2uiBarChart.js +2 -0
- package/dist/a2ui/extended/MPA2uiDataTable.d.ts +1 -0
- package/dist/a2ui/extended/MPA2uiDataTable.js +2 -0
- package/dist/a2ui/extended/MPA2uiLineChart.d.ts +1 -0
- package/dist/a2ui/extended/MPA2uiLineChart.js +2 -0
- package/dist/a2ui/extended/MPA2uiPieChart.d.ts +1 -0
- package/dist/a2ui/extended/MPA2uiPieChart.js +2 -0
- package/dist/a2ui/extended/MPA2uiStatistic.d.ts +1 -0
- package/dist/a2ui/extended/MPA2uiStatistic.js +2 -0
- package/dist/a2ui/extended/api.d.ts +1436 -0
- package/dist/a2ui/extended/api.js +1 -0
- package/dist/a2ui/extended/chart.d.ts +26 -0
- package/dist/a2ui/extended/chart.js +1 -0
- package/dist/a2ui/index.d.ts +103 -0
- package/dist/a2ui/index.js +1 -0
- package/dist/a2ui/internal/children.d.ts +28 -0
- package/dist/a2ui/internal/children.js +1 -0
- package/dist/a2ui/internal/common.d.ts +113 -0
- package/dist/a2ui/internal/common.js +1 -0
- package/dist/a2ui/internal/icons.d.ts +3 -0
- package/dist/a2ui/internal/icons.js +1 -0
- package/dist/components/alert/MPAlert.d.ts +2 -2
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/anchor/MPAnchor.js +1 -1
- package/dist/components/animate-counter/MPAnimateCounter.js +1 -1
- package/dist/components/animate-grow/MPAnimateGrow.d.ts +1 -1
- package/dist/components/animate-slide/MPAnimateSlide.d.ts +1 -1
- package/dist/components/animate-zoom/MPAnimateZoom.d.ts +2 -2
- package/dist/components/app-logo/MPAppLogo.d.ts +16 -1
- package/dist/components/app-logo/MPAppLogo.js +1 -1
- package/dist/components/area-chart/MPAreaChart.d.ts +18 -3
- package/dist/components/area-chart/MPAreaChart.js +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.d.ts +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
- package/dist/components/avatar/MPAvatar.d.ts +1 -1
- package/dist/components/bar-chart/MPBarChart.d.ts +15 -5
- package/dist/components/bar-chart/MPBarChart.js +1 -1
- package/dist/components/blockquote/MPBlockquote.d.ts +9 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/box/MPBox.d.ts +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/chip/MPChip.d.ts +2 -2
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/confirm/MPConfirmProvider.js +1 -1
- package/dist/components/data-table/MPDataTable.d.ts +20 -1
- package/dist/components/data-table/MPDataTable.js +1 -1
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/empty/MPEmpty.d.ts +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/grid/MPGrid.d.ts +25 -8
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/heatmap-chart/MPHeatmapChart.d.ts +12 -3
- package/dist/components/heatmap-chart/MPHeatmapChart.js +1 -1
- package/dist/components/hover-card/MPHoverCard.d.ts +1 -0
- package/dist/components/hover-card/MPHoverCard.js +1 -1
- package/dist/components/icon/MPIcon.js +1 -1
- package/dist/components/image/MPImage.d.ts +112 -4
- package/dist/components/image/MPImage.js +1 -1
- package/dist/components/image/index.d.ts +1 -1
- package/dist/components/line-chart/MPLineChart.d.ts +20 -2
- package/dist/components/line-chart/MPLineChart.js +1 -1
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +1 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/pie-chart/MPPieChart.d.ts +23 -1
- package/dist/components/pie-chart/MPPieChart.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +2 -2
- package/dist/components/popover/MPPopover.d.ts +1 -0
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/portal/MPPortal.d.ts +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/scatter-chart/MPScatterChart.d.ts +5 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/sparkline/MPSparkline.d.ts +14 -1
- package/dist/components/sparkline/MPSparkline.js +1 -1
- package/dist/components/statistic/MPStatistic.js +1 -1
- package/dist/components/stepper/MPStepper.js +1 -1
- package/dist/components/table/MPTable.d.ts +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/timeline-chart/MPTimelineChart.d.ts +6 -2
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/tour/MPTour.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/typography/MPTypography.d.ts +1 -1
- package/dist/constants/glyphs.d.ts +32 -32
- package/dist/constants/icons.d.ts +32 -32
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/ChartChrome.d.ts +63 -19
- package/dist/internal/ChartChrome.js +1 -1
- package/dist/internal/ChartFrame.d.ts +24 -4
- package/dist/internal/ChartFrame.js +1 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/PopupArrow.d.ts +60 -0
- package/dist/internal/PopupArrow.js +2 -0
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/chart.d.ts +91 -13
- package/dist/internal/chart.js +1 -1
- package/dist/internal/color-scheme.d.ts +0 -9
- package/dist/internal/color-scheme.js +1 -1
- package/dist/internal/data-table.d.ts +35 -2
- package/dist/internal/data-table.js +1 -1
- package/dist/internal/date.d.ts +22 -18
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +14 -0
- package/dist/internal/intl.d.ts +64 -0
- package/dist/internal/intl.js +1 -0
- package/dist/internal/messages/chart.d.ts +1 -1
- package/dist/internal/messages/chart.js +1 -1
- package/dist/internal/messages/transfer.d.ts +1 -1
- package/dist/internal/messages/transfer.js +1 -1
- package/dist/internal/text.js +1 -1
- package/dist/internal/time-scale.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/app-logo.css +1 -1
- package/dist/styles/area-chart.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/bar-chart.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/calendar.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/chat-bubble.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/code-block.css +1 -1
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/confirm.css +1 -1
- package/dist/styles/data-table.css +1 -1
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/file-picker.css +1 -1
- package/dist/styles/flex.css +1 -1
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/gauge-chart.css +1 -1
- package/dist/styles/grid.css +1 -1
- package/dist/styles/heatmap-chart.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/icon.css +1 -1
- package/dist/styles/image.css +1 -1
- package/dist/styles/line-chart.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +1 -1
- package/dist/styles/navigation-menu.css +1 -1
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/pie-chart.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popconfirm.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/rating.css +1 -1
- package/dist/styles/scatter-chart.css +1 -1
- package/dist/styles/scroll-zone.css +1 -1
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/sparkline.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/statistic.css +1 -1
- package/dist/styles/stepper.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text-link.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/timeline-chart.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/toggle.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/tour.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/tree-select.css +1 -1
- package/dist/styles/tree-view.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1253 -55
- package/dist/types.d.ts +210 -3
- package/package.json +47 -26
- package/.fix.py +0 -92
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{MPBox as l}from"../box/MPBox.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as s}from"../icon/MPIcon.js";import{MPIconButton as i}from"../icon-button/MPIconButton.js";import{MPTextField as n}from"../text-field/MPTextField.js";import{ArrowRightIcon as o}from"../../constants/icons.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{cssLength as d}from"../../internal/length.js";import{TRANSFER as u}from"../../internal/messages/transfer.js";import{useMPColor as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{MPBox as l}from"../box/MPBox.js";import{MPCheckbox as r}from"../checkbox/MPCheckbox.js";import{MPIcon as s}from"../icon/MPIcon.js";import{MPIconButton as i}from"../icon-button/MPIconButton.js";import{MPTextField as n}from"../text-field/MPTextField.js";import{ArrowRightIcon as o}from"../../constants/icons.js";import{useMPLocale as c,useMPMessages as m}from"../../internal/locale.js";import{cssLength as d}from"../../internal/length.js";import{TRANSFER as u}from"../../internal/messages/transfer.js";import{fillMessage as h}from"../../internal/i18n.js";import{VISUALLY_HIDDEN as f}from"../../internal/visually-hidden.js";import{useMPColor as p,useMPSize as v}from"../../internal/config.js";import{hasContent as g,META_TEXT as b,SHEET_PAD_X as x}from"../../internal/scale.js";const w={xs:"py-1",sm:"py-1.5",md:"py-2",lg:"py-2.5",xl:"py-3"},k={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"},S=new Set;function j({title:s,rows:i,total:o,ticked:c,arrived:m,onTick:d,onTickAll:u,search:h,onSearch:f,searchable:p,disabled:v,height:g,messages:S,variant:j,size:y,color:N}){const T=i.filter(e=>!e.disabled),z=T.filter(e=>c.has(e.value)),C=T.length>0&&z.length===T.length,$=z.length>0&&!C,_=x[y],M=t.useId();return a(l,{variant:j,size:y,padded:!1,className:"mp-transfer__panel flex min-w-0 flex-col overflow-hidden",children:[a("div",{className:["mp-transfer__heading border-mp-outline-variant flex items-center gap-2 border-b",_,w[y]].join(" "),children:[e("div",{className:"min-w-0 flex-1",children:e(r,{size:y,color:N,checked:C,indeterminate:$,disabled:v||0===T.length,label:e("span",{id:M,className:"block truncate font-medium",children:s}),onCheckedChange:e=>u(e)})}),a("span",{className:`text-mp-on-surface-variant shrink-0 tabular-nums ${b}`,children:[z.length,"/",o]})]}),p?e("div",{className:`${_} ${w[y]}`,children:e(n,{size:y,fullWidth:!0,disabled:v,placeholder:S.search,"aria-label":S.search,value:h,onChange:f})}):null,e("div",{role:"group","aria-labelledby":M,className:`mp-transfer__list flex flex-col overflow-y-auto overscroll-contain ${_} ${w[y]}`,style:{height:g},children:0===i.length?e("span",{className:`text-mp-on-surface-variant ${b} ${k[y]}`,children:S.empty}):i.map((a,t)=>e("div",{className:[k[y],m.has(a.value)?"mp-row-arrive":""].filter(Boolean).join(" "),children:e(r,{size:y,color:N,label:a.label,checked:c.has(a.value),disabled:v||a.disabled,onCheckedChange:e=>d(a.value,e)})},`${t}:${a.value}`))})]})}function y(e,a){if(""===a)return e;const t=a.toLowerCase();return e.filter(e=>"string"!=typeof e.label||e.label.toLowerCase().includes(t))}export const MPTransfer=/*@__PURE__*/t.forwardRef(function({items:l,value:r,defaultValue:n,onValueChange:b,sourceLabel:x,targetLabel:w,searchable:k=!1,height:N=220,disabled:T=!1,variant:z="outlined",size:C,color:$,locale:_,labels:M,className:P,...B},L){const A=v(C),I=p($),V=c(_),E=m(u,V,M),[F,R]=t.useState(n??[]),W=r??F,[q,D]=t.useState(()=>new Set),[G,H]=t.useState(()=>({values:new Set,toTarget:!0})),[J,K]=t.useState(""),[O,Q]=t.useState(""),[U,X]=t.useState(null),Y=t.useMemo(()=>new Set(W),[W]),Z=l.filter(e=>!Y.has(e.value)),ee=l.filter(e=>Y.has(e.value));t.useEffect(()=>{const e=new Set(l.map(e=>e.value));D(a=>{const t=[...a].filter(a=>e.has(a));return t.length===a.size?a:new Set(t)})},[l]);const ae=(e,a)=>{D(t=>{const l=new Set(t);return a?l.add(e):l.delete(e),l})},te=(e,a)=>{D(t=>{const l=new Set(t);for(const t of e)t.disabled||(a?l.add(t.value):l.delete(t.value));return l})},le=(e,a)=>{const t=e.filter(e=>!e.disabled&&q.has(e.value));if(0===t.length)return;const s=new Set(t.map(e=>e.value)),i=a?l.filter(e=>Y.has(e.value)||s.has(e.value)).map(e=>e.value):W.filter(e=>!s.has(e));D(e=>new Set([...e].filter(e=>!s.has(e)))),H({values:s,toTarget:a}),X(e=>{return{tick:(e?.tick??0)+1,text:h(E.moved,{count:String(t.length),list:(l=a?w:x,r=a?E.target:E.source,"string"==typeof l&&""!==l?l:r)})};var l,r}),(e=>{void 0===r&&R(e),b?.(e)})(i)},re=y(Z,J),se=y(ee,O),ie=re.some(e=>!e.disabled&&q.has(e.value)),ne=se.some(e=>!e.disabled&&q.has(e.value)),oe=d(N),ce={ticked:q,disabled:T,height:oe,messages:E,variant:z,size:A,color:I,searchable:k};return a("div",{ref:L,"data-mp-size":A,className:["mp-transfer grid w-full items-center gap-3","[grid-template-columns:minmax(0,1fr)]","mp-medium:[grid-template-columns:minmax(0,1fr)_auto_minmax(0,1fr)]",P??""].filter(Boolean).join(" "),...B,children:[e(j,{...ce,title:g(x)?x:E.source,rows:re,total:Z.length,arrived:G.toTarget?S:G.values,onTick:ae,onTickAll:e=>te(re,e),search:J,onSearch:K}),a("div",{className:"flex flex-row justify-center gap-2 mp-medium:flex-col",children:[e(i,{size:A,color:I,variant:"text"===z?"text":"outlined",label:E.toTarget,disabled:T||!ie,onClick:()=>le(re,!0),icon:e(s,{icon:o,className:"rotate-90 mp-medium:rotate-0"})}),e(i,{size:A,color:I,variant:"text"===z?"text":"outlined",label:E.toSource,disabled:T||!ne,onClick:()=>le(se,!1),icon:e(s,{icon:o,className:"-rotate-90 mp-medium:rotate-180"})})]}),e("span",{className:f,"aria-live":"polite","aria-atomic":"true",children:U?e("span",{children:U.text},U.tick):null}),e(j,{...ce,title:g(w)?w:E.target,rows:se,total:ee.length,arrived:G.toTarget?G.values:S,onTick:ae,onTickAll:e=>te(se,e),search:O,onSearch:Q})]})});
|
|
@@ -83,7 +83,7 @@ export interface MPTypographyProps extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
83
83
|
* `transition="fade"` is the whole of what most callers want; the object form
|
|
84
84
|
* takes a duration, an edge to come from, or a scale to start at. Anything
|
|
85
85
|
* that has to run again — on scroll, on hover, under your own control — is an
|
|
86
|
-
* [MPAnimateFade](../
|
|
86
|
+
* [MPAnimateFade](../transitions/animate-fade) and its siblings.
|
|
87
87
|
*/
|
|
88
88
|
transition?: MPTransition;
|
|
89
89
|
}
|
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
/** The glyph a password field shows while the password is legible. */
|
|
2
|
-
export declare const VisibilityIcon: import("
|
|
2
|
+
export declare const VisibilityIcon: import("lucide-react").LucideIcon;
|
|
3
3
|
/** The glyph a password field shows while the password is masked. */
|
|
4
|
-
export declare const VisibilityOffIcon: import("
|
|
4
|
+
export declare const VisibilityOffIcon: import("lucide-react").LucideIcon;
|
|
5
5
|
/** Dismiss: a chip, a dialog, an alert. */
|
|
6
|
-
export declare const CloseIcon: import("
|
|
6
|
+
export declare const CloseIcon: import("lucide-react").LucideIcon;
|
|
7
7
|
/** A ticked option, a completed step. */
|
|
8
|
-
export declare const CheckIcon: import("
|
|
8
|
+
export declare const CheckIcon: import("lucide-react").LucideIcon;
|
|
9
9
|
/** Disclosure, pointing down. */
|
|
10
|
-
export declare const ChevronDownIcon: import("
|
|
10
|
+
export declare const ChevronDownIcon: import("lucide-react").LucideIcon;
|
|
11
11
|
/** Disclosure, pointing up. */
|
|
12
|
-
export declare const ChevronUpIcon: import("
|
|
12
|
+
export declare const ChevronUpIcon: import("lucide-react").LucideIcon;
|
|
13
13
|
/** Previous, in a pager or a carousel. */
|
|
14
|
-
export declare const ChevronLeftIcon: import("
|
|
14
|
+
export declare const ChevronLeftIcon: import("lucide-react").LucideIcon;
|
|
15
15
|
/** Next, in a pager or a carousel. */
|
|
16
|
-
export declare const ChevronRightIcon: import("
|
|
16
|
+
export declare const ChevronRightIcon: import("lucide-react").LucideIcon;
|
|
17
17
|
/** First, in a pager: the stepper that jumps to an end rather than by one. */
|
|
18
|
-
export declare const ChevronsLeftIcon: import("
|
|
18
|
+
export declare const ChevronsLeftIcon: import("lucide-react").LucideIcon;
|
|
19
19
|
/** And last. */
|
|
20
|
-
export declare const ChevronsRightIcon: import("
|
|
20
|
+
export declare const ChevronsRightIcon: import("lucide-react").LucideIcon;
|
|
21
21
|
/** Search, for a field's leading adornment. */
|
|
22
|
-
export declare const SearchIcon: import("
|
|
22
|
+
export declare const SearchIcon: import("lucide-react").LucideIcon;
|
|
23
23
|
/** Sorted ascending: the arrow a table's sorted column carries. */
|
|
24
|
-
export declare const ArrowUpIcon: import("
|
|
24
|
+
export declare const ArrowUpIcon: import("lucide-react").LucideIcon;
|
|
25
25
|
/** Sorted descending. */
|
|
26
|
-
export declare const ArrowDownIcon: import("
|
|
26
|
+
export declare const ArrowDownIcon: import("lucide-react").LucideIcon;
|
|
27
27
|
/** And then: the mark a breadcrumb can put between two steps. */
|
|
28
|
-
export declare const ArrowRightIcon: import("
|
|
28
|
+
export declare const ArrowRightIcon: import("lucide-react").LucideIcon;
|
|
29
29
|
/** The trail a breadcrumb hides behind, and any other "there is more here". */
|
|
30
|
-
export declare const MoreIcon: import("
|
|
30
|
+
export declare const MoreIcon: import("lucide-react").LucideIcon;
|
|
31
31
|
/** A link that goes somewhere on this site. */
|
|
32
|
-
export declare const LinkIcon: import("
|
|
32
|
+
export declare const LinkIcon: import("lucide-react").LucideIcon;
|
|
33
33
|
/** A link that takes over the window. */
|
|
34
|
-
export declare const ExternalLinkIcon: import("
|
|
34
|
+
export declare const ExternalLinkIcon: import("lucide-react").LucideIcon;
|
|
35
35
|
/** Copy to clipboard. */
|
|
36
|
-
export declare const CopyIcon: import("
|
|
36
|
+
export declare const CopyIcon: import("lucide-react").LucideIcon;
|
|
37
37
|
/** Source as it was written — `MPCodeBlock`'s toggle out of the colouring. */
|
|
38
|
-
export declare const CodeIcon: import("
|
|
38
|
+
export declare const CodeIcon: import("lucide-react").LucideIcon;
|
|
39
39
|
/** A picture that could not be fetched — `MPImage`'s own fallback. */
|
|
40
|
-
export declare const BrokenImageIcon: import("
|
|
40
|
+
export declare const BrokenImageIcon: import("lucide-react").LucideIcon;
|
|
41
41
|
/** Severity: something worth knowing. */
|
|
42
|
-
export declare const InfoIcon: import("
|
|
42
|
+
export declare const InfoIcon: import("lucide-react").LucideIcon;
|
|
43
43
|
/** Severity: it worked. */
|
|
44
|
-
export declare const SuccessIcon: import("
|
|
44
|
+
export declare const SuccessIcon: import("lucide-react").LucideIcon;
|
|
45
45
|
/** Severity: proceed carefully. */
|
|
46
|
-
export declare const WarningIcon: import("
|
|
46
|
+
export declare const WarningIcon: import("lucide-react").LucideIcon;
|
|
47
47
|
/** Severity: it did not work. */
|
|
48
|
-
export declare const ErrorIcon: import("
|
|
48
|
+
export declare const ErrorIcon: import("lucide-react").LucideIcon;
|
|
49
49
|
/** One step up: a number field's increment. */
|
|
50
|
-
export declare const AddIcon: import("
|
|
50
|
+
export declare const AddIcon: import("lucide-react").LucideIcon;
|
|
51
51
|
/** One step down: a number field's decrement, and a half-ticked checkbox. */
|
|
52
|
-
export declare const RemoveIcon: import("
|
|
52
|
+
export declare const RemoveIcon: import("lucide-react").LucideIcon;
|
|
53
53
|
/** Send a file the other way. A file picker's dropzone. */
|
|
54
|
-
export declare const UploadIcon: import("
|
|
54
|
+
export declare const UploadIcon: import("lucide-react").LucideIcon;
|
|
55
55
|
/** A day on a calendar: what a date picker's trigger wears. */
|
|
56
|
-
export declare const CalendarIcon: import("
|
|
56
|
+
export declare const CalendarIcon: import("lucide-react").LucideIcon;
|
|
57
57
|
/** A time of day: what a time picker's trigger wears. */
|
|
58
|
-
export declare const ClockIcon: import("
|
|
58
|
+
export declare const ClockIcon: import("lucide-react").LucideIcon;
|
|
59
59
|
/**
|
|
60
60
|
* A score. Drawn as an outline, and filled by whatever is scoring with it —
|
|
61
61
|
* lucide draws it `fill="none"`, and `MPRating` overlays a copy in `fill-current`
|
|
62
62
|
* rather than shipping a second glyph.
|
|
63
63
|
*/
|
|
64
|
-
export declare const StarIcon: import("
|
|
64
|
+
export declare const StarIcon: import("lucide-react").LucideIcon;
|
|
65
65
|
/** Work in progress, spun by whatever is waiting on it. */
|
|
66
|
-
export declare const SpinnerIcon: import("
|
|
66
|
+
export declare const SpinnerIcon: import("lucide-react").LucideIcon;
|
|
67
67
|
/**
|
|
68
68
|
* Three lines: the navigation a window has become too narrow to show.
|
|
69
69
|
*
|
|
@@ -73,4 +73,4 @@ export declare const SpinnerIcon: import("react").ForwardRefExoticComponent<Omit
|
|
|
73
73
|
* argument that ever justifies a symbol — and `MPSidebarTrigger` gives it a
|
|
74
74
|
* name for the readers it still says nothing to.
|
|
75
75
|
*/
|
|
76
|
-
export declare const MenuIcon: import("
|
|
76
|
+
export declare const MenuIcon: import("lucide-react").LucideIcon;
|
|
@@ -41,38 +41,38 @@ export * from './glyphs.js';
|
|
|
41
41
|
* file. Reach for the named exports when only one or two are needed.
|
|
42
42
|
*/
|
|
43
43
|
export declare const ICONS: {
|
|
44
|
-
readonly visibility: import("
|
|
45
|
-
readonly 'visibility-off': import("
|
|
46
|
-
readonly close: import("
|
|
47
|
-
readonly check: import("
|
|
48
|
-
readonly 'chevron-down': import("
|
|
49
|
-
readonly 'chevron-up': import("
|
|
50
|
-
readonly 'chevron-left': import("
|
|
51
|
-
readonly 'chevron-right': import("
|
|
52
|
-
readonly 'chevrons-left': import("
|
|
53
|
-
readonly 'chevrons-right': import("
|
|
54
|
-
readonly search: import("
|
|
55
|
-
readonly 'arrow-up': import("
|
|
56
|
-
readonly 'arrow-down': import("
|
|
57
|
-
readonly 'arrow-right': import("
|
|
58
|
-
readonly more: import("
|
|
59
|
-
readonly menu: import("
|
|
60
|
-
readonly link: import("
|
|
61
|
-
readonly 'external-link': import("
|
|
62
|
-
readonly copy: import("
|
|
63
|
-
readonly code: import("
|
|
64
|
-
readonly 'broken-image': import("
|
|
65
|
-
readonly info: import("
|
|
66
|
-
readonly success: import("
|
|
67
|
-
readonly warning: import("
|
|
68
|
-
readonly error: import("
|
|
69
|
-
readonly add: import("
|
|
70
|
-
readonly remove: import("
|
|
71
|
-
readonly upload: import("
|
|
72
|
-
readonly calendar: import("
|
|
73
|
-
readonly clock: import("
|
|
74
|
-
readonly star: import("
|
|
75
|
-
readonly spinner: import("
|
|
44
|
+
readonly visibility: import("lucide-react").LucideIcon;
|
|
45
|
+
readonly 'visibility-off': import("lucide-react").LucideIcon;
|
|
46
|
+
readonly close: import("lucide-react").LucideIcon;
|
|
47
|
+
readonly check: import("lucide-react").LucideIcon;
|
|
48
|
+
readonly 'chevron-down': import("lucide-react").LucideIcon;
|
|
49
|
+
readonly 'chevron-up': import("lucide-react").LucideIcon;
|
|
50
|
+
readonly 'chevron-left': import("lucide-react").LucideIcon;
|
|
51
|
+
readonly 'chevron-right': import("lucide-react").LucideIcon;
|
|
52
|
+
readonly 'chevrons-left': import("lucide-react").LucideIcon;
|
|
53
|
+
readonly 'chevrons-right': import("lucide-react").LucideIcon;
|
|
54
|
+
readonly search: import("lucide-react").LucideIcon;
|
|
55
|
+
readonly 'arrow-up': import("lucide-react").LucideIcon;
|
|
56
|
+
readonly 'arrow-down': import("lucide-react").LucideIcon;
|
|
57
|
+
readonly 'arrow-right': import("lucide-react").LucideIcon;
|
|
58
|
+
readonly more: import("lucide-react").LucideIcon;
|
|
59
|
+
readonly menu: import("lucide-react").LucideIcon;
|
|
60
|
+
readonly link: import("lucide-react").LucideIcon;
|
|
61
|
+
readonly 'external-link': import("lucide-react").LucideIcon;
|
|
62
|
+
readonly copy: import("lucide-react").LucideIcon;
|
|
63
|
+
readonly code: import("lucide-react").LucideIcon;
|
|
64
|
+
readonly 'broken-image': import("lucide-react").LucideIcon;
|
|
65
|
+
readonly info: import("lucide-react").LucideIcon;
|
|
66
|
+
readonly success: import("lucide-react").LucideIcon;
|
|
67
|
+
readonly warning: import("lucide-react").LucideIcon;
|
|
68
|
+
readonly error: import("lucide-react").LucideIcon;
|
|
69
|
+
readonly add: import("lucide-react").LucideIcon;
|
|
70
|
+
readonly remove: import("lucide-react").LucideIcon;
|
|
71
|
+
readonly upload: import("lucide-react").LucideIcon;
|
|
72
|
+
readonly calendar: import("lucide-react").LucideIcon;
|
|
73
|
+
readonly clock: import("lucide-react").LucideIcon;
|
|
74
|
+
readonly star: import("lucide-react").LucideIcon;
|
|
75
|
+
readonly spinner: import("lucide-react").LucideIcon;
|
|
76
76
|
};
|
|
77
77
|
/** Every role name `ICONS` answers to. */
|
|
78
78
|
export type MPIconName = keyof typeof ICONS;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as r}from"../components/button/MPButton.js";import{MPIcon as l}from"../components/icon/MPIcon.js";import{MPIconButton as a}from"../components/icon-button/MPIconButton.js";import{ChevronDownIcon as s,ChevronLeftIcon as c,ChevronRightIcon as i}from"../constants/icons.js";import{MPStateLayer as u}from"./StateLayer.js";import{CONTROL_ICON as m,META_TEXT as d,PROSE_TEXT as h}from"./scale.js";import{VISUALLY_HIDDEN as p}from"./visually-hidden.js";import{addDays as f,addMonths as g,addYears as y,calendarWeeks as v,compareDay as b,dateFormatter as w,isDayOutside as x,isMonthBeforeYear as D,isSameDay as S,isSameMonth as M,isUnitOutside as N,isValidDate as P,makeDate as _,meridiemLabels as C,monthLabels as k,startOfDay as j,startOfMonth as z,today as A,weekdayLabels as E,withTime as T,YEAR_PAGE_SIZE as F,yearPageStart as Y}from"./date.js";const B={xs:"1.75rem",sm:"2rem",md:"2.5rem",lg:"2.75rem",xl:"3rem"},R={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"},H=/*@__PURE__*/["group relative flex cursor-pointer items-center justify-center overflow-hidden","box-border appearance-none font-[inherit] tabular-nums select-none","transition-[background-color,border-color,color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:z-10 focus-visible:outline-2","focus-visible:outline-offset-[-2px] focus-visible:outline-solid outline-none"].join(" "),$={day:0,month:1,year:2};function K({children:n,label:o,selected:r,inRange:l=!1,rangeEdge:a=null,current:s=!1,muted:c=!1,disabled:i=!1,focused:m=!1,className:d,onClick:h,onPointerEnter:p,onKeyDown:f}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":i||void 0,tabIndex:m?0:-1,"data-focus-target":m?"true":void 0,className:[H,"start"===a?"rounded-s-mp-full":"end"===a?"rounded-e-mp-full":"middle"===a?"rounded-none":"rounded-mp-full",i?"bg-transparent cursor-default text-mp-on-surface/38":r?"bg-(--_mp-accent) text-(--_mp-on-accent)":l?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":s?"bg-transparent border border-(--_mp-accent) text-(--_mp-accent)":c?"bg-transparent text-mp-on-surface-variant":"bg-transparent text-mp-on-surface",d??""].filter(Boolean).join(" "),onClick:()=>{i||h()},onPointerEnter:p,onKeyDown:f,children:[i?null:e(u,{}),n]})}function L({size:o,color:u,view:d,month:p,locale:f,labels:g,showPreviousButton:y,showNextButton:v,onStep:b,onViewChange:w}){const x=k(f,"long")[p.getMonth()],S=String(p.getFullYear()),M=D(f),N=R[o],P="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],_=(t,n)=>n?e(a,{size:N,color:u,label:P[-1===t?0:1],icon:e(l,{icon:-1===t?c:i,size:m[N],className:"rtl:rotate-180"}),onClick:()=>b(t)}):e("span",{"aria-hidden":"true",className:"size-(--_mp-cell)"}),C=t=>e(l,{icon:s,size:m[N],className:["transition-transform duration-(--mp-sys-motion-duration-short4)",t?"rotate-180":""].filter(Boolean).join(" ")}),j=e(r,{variant:"text",size:N,color:u,"aria-label":g.chooseMonth,"aria-expanded":"month"===d,endIcon:C("month"===d),onClick:()=>w("month"===d?"day":"month"),children:x},"month"),z=e(r,{variant:"text",size:N,color:u,className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,endIcon:C("year"===d),onClick:()=>w("year"===d?"day":"year"),children:S},"year"),A=Y(p.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[_(-1,y),e("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1",children:"year"===d?e("span",{className:`text-mp-on-surface flex h-(--_mp-cell) items-center tabular-nums ${h[o]}`,children:`${A}–${A+F-1}`}):"month"===d?z:t(n,M?{children:[j,z]}:{children:[z,j]})}),_(1,v)]})}export function Calendar({size:n,color:r,locale:l,weekStartsOn:a,month:s,onMonthChange:c,selected:i,rangeStart:u=null,rangeEnd:m=null,onSelect:d,onPreviewChange:h,minDate:p,maxDate:f,shouldDisableDate:v,showOutsideDays:b=!0,autoFocus:w=!1,showPreviousButton:D=!0,showNextButton:S=!0,precision:N="day",labels:C}){const[k,E]=o.useState(N),T=$[k]<$[N]?N:k,Y=o.useMemo(()=>i.filter(P),[i]),[R,H]=o.useState(()=>{const e=Y.find(e=>M(e,s));return e?j(e):M(A(),s)?A():z(s)}),K=o.useRef(w),U=o.useRef(null);o.useEffect(()=>{H(e=>M(e,s)?e:z(s))},[s]),o.useLayoutEffect(()=>{K.current&&(K.current=!1,U.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>x(e,p,f)||(v?.(e)??!1),[p,f,v]),G=e=>{K.current=!0,E(e)},W=e=>{K.current=!0,c(e)};return t("div",{ref:U,className:"mp-calendar flex flex-col gap-1",style:{"--_mp-cell":B[n]},onPointerLeave:()=>h?.(null),children:[e(L,{size:n,color:r,view:T,month:s,locale:l,labels:C,showPreviousButton:D,showNextButton:S,onStep:e=>{c("day"===T?g(s,e):y(s,"month"===T?e:e*F))},onViewChange:G}),e("div",{className:"h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*7)]",children:"day"===T?e(I,{size:n,locale:l,weekStartsOn:a,month:s,chosen:Y,rangeStart:u,rangeEnd:m,focusedDate:R,showOutsideDays:b,isDisabled:V,onSelect:e=>{H(e),d(e)},onPreviewChange:h,onMoveFocus:e=>{K.current=!0,H(e),M(e,s)||c(z(e))}}):"month"===T?e(O,{size:n,locale:l,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{const t=_(s.getFullYear(),e,1);"month"!==N?(c(t),G("day")):d(t)}}):e(q,{size:n,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{"year"!==N?(c(_(e,s.getMonth(),1)),G("month")):d(_(e,0,1))}})})]})}function U(e){return"rtl"===getComputedStyle(e).direction?-1:1}function I({size:n,locale:r,weekStartsOn:l,month:a,chosen:s,rangeStart:c,rangeEnd:i,focusedDate:u,showOutsideDays:m,isDisabled:p,onSelect:y,onPreviewChange:x,onMoveFocus:D}){const N=E(r,l,"narrow"),_=E(r,l,"long"),C=(j=i,P(k=c)&&P(j)?b(k,j)<=0?[k,j]:[j,k]:null);var k,j;const z=A(),T=o.useMemo(()=>{const e=w(r,{dateStyle:"full"});return v(a,l).map(t=>t.map(t=>({date:t,label:e.format(t)})))},[a,l,r]),F=o.useRef(null),Y=o.useRef(a);o.useLayoutEffect(()=>{const e=F.current,t=Y.current;if(Y.current=a,!e||M(t,a))return;const n=t.getTime()<a.getTime(),o="rtl"===getComputedStyle(e).direction;e.style.setProperty("--_mp-calendar-from",String(n===o?-1:1)),e.dataset.mpPaged="true",e.style.animationName="none",e.offsetWidth,e.style.animationName=""},[a]);return t("div",{role:"grid","aria-label":w(r,{year:"numeric",month:"long"}).format(a),className:"flex h-full flex-col",children:[e("div",{role:"rowgroup",children:e("div",{role:"row",className:"grid grid-cols-7",children:N.map((t,n)=>e("span",{role:"columnheader","aria-label":_[n],className:`text-mp-on-surface-variant flex h-(--_mp-cell) items-center justify-center select-none ${d}`,children:t},n))})}),e("div",{ref:F,role:"rowgroup",className:"mp-calendar__page flex flex-1 flex-col",children:T.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(({date:t,label:o})=>{const r=!M(t,a);if(r&&!m)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--_mp-cell)"},t.getTime());const c=s.some(e=>S(e,t)),i=null!==C&&b(t,C[0])>=0&&b(t,C[1])<=0,d=null!==C&&i&&S(t,C[0]),v=null!==C&&i&&S(t,C[1]);return e(K,{label:o,selected:c,inRange:i&&!c,rangeEdge:i?d&&v?"both":d?"start":v?"end":"middle":null,current:S(t,z)&&!c,muted:r,disabled:p(t),focused:S(t,u),className:`size-(--_mp-cell) ${h[n]}`,onClick:()=>y(t),onPointerEnter:()=>x?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-l+7)%7,o=U(e.currentTarget),r={ArrowLeft:()=>f(t,-o),ArrowRight:()=>f(t,o),ArrowUp:()=>f(t,-7),ArrowDown:()=>f(t,7),Home:()=>f(t,-n),End:()=>f(t,6-n),PageUp:()=>g(t,e.shiftKey?-12:-1),PageDown:()=>g(t,e.shiftKey?12:1)}[e.key];r&&(e.preventDefault(),D(r()))})(e,t),children:t.getDate()},t.getTime())})},o))})]})}function O({size:t,locale:n,month:r,chosen:l,minDate:a,maxDate:s,onMoveCursor:c,onPick:i}){const u=k(n,"short"),m=r.getFullYear(),d=new Date,p=o.useMemo(()=>{const e=w(n,{year:"numeric",month:"long"});return Array.from({length:12},(t,n)=>e.format(_(m,n,1)))},[n,m]),f=e=>{const t=U(e.currentTarget),n={ArrowLeft:-t,ArrowRight:t,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==n&&(e.preventDefault(),c(g(z(r),n)))};return e("div",{role:"grid","aria-label":String(m),className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(o=>{const c=3*n+o;return e(K,{label:p[c],selected:l.some(e=>e.getFullYear()===m&&e.getMonth()===c),current:d.getFullYear()===m&&d.getMonth()===c,disabled:N(_(m,c,1),"month",a,s),focused:c===r.getMonth(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>i(c),onKeyDown:f,children:u[c]},c)})},n))})}function q({size:t,month:n,chosen:o,minDate:r,maxDate:l,onMoveCursor:a,onPick:s}){const c=Y(n.getFullYear()),i=(new Date).getFullYear(),u=e=>{const t=U(e.currentTarget),o={ArrowLeft:-t,ArrowRight:t,ArrowUp:-4,ArrowDown:4,PageUp:-F,PageDown:F}[e.key];void 0!==o&&(e.preventDefault(),a(y(z(n),o)))};return e("div",{role:"grid","aria-label":`${c}–${c+F-1}`,className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(a=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(m=>{const d=c+4*a+m;return e(K,{label:String(d),selected:o.some(e=>e.getFullYear()===d),current:d===i,disabled:N(_(d,0,1),"year",r,l),focused:d===n.getFullYear(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>s(d),onKeyDown:u,children:d},d)})},a))})}function V(e,t){return Number.isFinite(e)?Math.min(t,Math.max(1,Math.round(e))):1}function G(e,t="auto"){const n=e.parentElement;if(!n)return;const o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),l=o.top-r.top-n.clientTop+n.scrollTop,a=l+o.height;l<n.scrollTop?n.scrollTo({top:l,behavior:t}):a>n.scrollTop+n.clientHeight&&n.scrollTo({top:a-n.clientHeight,behavior:t})}export function MPTimeGrid({size:n,locale:r,value:l,referenceDate:a,onChange:s,hour12:c,showSeconds:i,hourStep:m,minuteStep:d,secondStep:f,shouldDisableTime:g,autoFocus:y=!1,labels:v}){const b=l??a,x=o.useRef(null),[D,S]=o.useMemo(()=>C(r),[r]);o.useEffect(()=>{const e=x.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(e=>G(e,"instant")),y){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[y]);const M=o.useMemo(()=>{const e=c?12:24,t=V(m,e),n=Array.from({length:Math.ceil(e/t)},(e,n)=>n*t);return c?n.map(e=>0===e?12:e):n},[c,m]),N=o.useMemo(()=>{const e=V(d,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[d]),P=o.useMemo(()=>{const e=V(f,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[f]),_=e=>String(e).padStart(2,"0"),k=c?b.getHours()%12||12:b.getHours(),[j,z]=o.useState({}),A=(o,r,a,i,m)=>{const d=null===l?-1:a.findIndex(e=>i(e)),p=j[o]??(d>=0?d:0);return e("div",{role:"listbox","aria-label":r,className:["mp-time-grid__column flex flex-col gap-0.5 overflow-y-auto overscroll-contain","motion-safe:scroll-smooth","h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"].join(" "),onKeyDown:e=>{const t={ArrowDown:1,ArrowUp:-1,PageDown:5,PageUp:-5}[e.key],n=void 0!==t?(e=>{const t=[...e.children].indexOf(document.activeElement);return t>=0?t:p})(e.currentTarget)+t:"Home"===e.key?0:"End"===e.key?a.length-1:null;null!==n&&(e.preventDefault(),((e,t)=>{const n=Math.min(a.length-1,Math.max(0,e)),r=t.children[n];z(e=>({...e,[o]:n})),r instanceof HTMLElement&&(r.focus({preventScroll:!0}),G(r))})(n,e.currentTarget))},children:a.map((r,a)=>{const d=((e,t)=>T(b,"hour"===e?{hours:c?t%12+(b.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:b.getHours()%12+12*t}))(o,r),f=null!==l&&i(r),y=g?.(d,o)??!1;return t("button",{type:"button",role:"option","aria-selected":f,"aria-disabled":y||void 0,"data-chosen":f?"true":void 0,tabIndex:a===p?0:-1,className:[H,"rounded-mp-full h-(--_mp-cell) w-full shrink-0",h[n],y?"bg-transparent cursor-default text-mp-on-surface/38":f?"bg-(--_mp-accent) text-(--_mp-on-accent)":"bg-transparent text-mp-on-surface"].join(" "),onFocus:()=>z(e=>({...e,[o]:a})),onClick:()=>{y||s(d)},children:[y?null:e(u,{}),m(r)]},r)})},o)};return t("div",{ref:x,className:"mp-time-grid flex gap-1",style:{"--_mp-cell":B[n]},children:[A("hour",v.hour,M,e=>e===k,e=>c?String(e):_(e)),A("minute",v.minute,N,e=>e===b.getMinutes(),_),i?A("second",v.second,P,e=>e===b.getSeconds(),_):null,c?A("meridiem",v.meridiem,[0,1],e=>(b.getHours()>=12?1:0)===e,e=>0===e?D:S):null,e("span",{className:p,"aria-live":"polite",children:null===l?"":w(r,{hour:"numeric",minute:"2-digit",...i?{second:"2-digit"}:{}}).format(l)})]})}
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{MPButton as r}from"../components/button/MPButton.js";import{MPIcon as l}from"../components/icon/MPIcon.js";import{MPIconButton as a}from"../components/icon-button/MPIconButton.js";import{ChevronDownIcon as s,ChevronLeftIcon as c,ChevronRightIcon as i}from"../constants/icons.js";import{MPStateLayer as u}from"./StateLayer.js";import{CONTROL_ICON as m,META_TEXT as d,PROSE_TEXT as h}from"./scale.js";import{VISUALLY_HIDDEN as p}from"./visually-hidden.js";import{addDays as f,addMonths as g,addYears as b,calendarWeeks as y,compareDay as v,dateFormatter as w,isDayOutside as x,isMonthBeforeYear as D,isSameDay as S,isSameMonth as M,isUnitOutside as N,isValidDate as P,makeDate as _,meridiemLabels as C,monthLabels as k,startOfDay as j,startOfMonth as z,today as A,weekdayLabels as E,withTime as T,YEAR_PAGE_SIZE as F,yearPageStart as Y}from"./date.js";const B={xs:"1.75rem",sm:"2rem",md:"2.5rem",lg:"2.75rem",xl:"3rem"},R={xs:"xs",sm:"xs",md:"sm",lg:"sm",xl:"md"},H=/*@__PURE__*/["group relative flex cursor-pointer items-center justify-center overflow-hidden","box-border appearance-none p-0 font-[inherit] tabular-nums select-none","transition-[background-color,border-color,color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:z-10 focus-visible:outline-2","focus-visible:outline-offset-[-2px] focus-visible:outline-solid outline-none"].join(" "),$={day:0,month:1,year:2};function K({children:n,label:o,selected:r,inRange:l=!1,rangeEdge:a=null,current:s=!1,muted:c=!1,disabled:i=!1,focused:m=!1,className:d,onClick:h,onPointerEnter:p,onKeyDown:f}){return t("button",{type:"button",role:"gridcell","aria-label":o,"aria-selected":r,"aria-current":s?"date":void 0,"aria-disabled":i||void 0,tabIndex:m?0:-1,"data-focus-target":m?"true":void 0,className:[H,"start"===a?"rounded-s-mp-full":"end"===a?"rounded-e-mp-full":"middle"===a?"rounded-none":"rounded-mp-full",i?"border-0 bg-transparent cursor-default text-mp-on-surface/38":r?"border-0 bg-(--_mp-accent) text-(--_mp-on-accent)":l?"border-0 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":s?"bg-transparent border border-(--_mp-accent) text-(--_mp-accent)":c?"border-0 bg-transparent text-mp-on-surface-variant":"border-0 bg-transparent text-mp-on-surface",d??""].filter(Boolean).join(" "),onClick:()=>{i||h()},onPointerEnter:p,onKeyDown:f,children:[i?null:e(u,{}),n]})}function L({size:o,color:u,view:d,month:p,locale:f,labels:g,showPreviousButton:b,showNextButton:y,onStep:v,onViewChange:w}){const x=k(f,"long")[p.getMonth()],S=String(p.getFullYear()),M=D(f),N=R[o],P="day"===d?[g.previousMonth,g.nextMonth]:"month"===d?[g.previousYear,g.nextYear]:[g.previousYears,g.nextYears],_=(t,n)=>n?e(a,{size:N,color:u,label:P[-1===t?0:1],icon:e(l,{icon:-1===t?c:i,size:m[N],className:"rtl:rotate-180"}),onClick:()=>v(t)}):e("span",{"aria-hidden":"true",className:"size-(--_mp-cell)"}),C=t=>e(l,{icon:s,size:m[N],className:["transition-transform duration-(--mp-sys-motion-duration-short4)",t?"rotate-180":""].filter(Boolean).join(" ")}),j=e(r,{variant:"text",size:N,color:u,"aria-label":g.chooseMonth,"aria-expanded":"month"===d,endIcon:C("month"===d),onClick:()=>w("month"===d?"day":"month"),children:x},"month"),z=e(r,{variant:"text",size:N,color:u,className:"tabular-nums","aria-label":g.chooseYear,"aria-expanded":"year"===d,endIcon:C("year"===d),onClick:()=>w("year"===d?"day":"year"),children:S},"year"),A=Y(p.getFullYear());return t("div",{className:"flex items-center justify-between gap-1",children:[_(-1,b),e("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-1",children:"year"===d?e("span",{className:`text-mp-on-surface flex h-(--_mp-cell) items-center tabular-nums ${h[o]}`,children:`${A}–${A+F-1}`}):"month"===d?z:t(n,M?{children:[j,z]}:{children:[z,j]})}),_(1,y)]})}export function Calendar({size:n,color:r,locale:l,weekStartsOn:a,month:s,onMonthChange:c,selected:i,rangeStart:u=null,rangeEnd:m=null,onSelect:d,onPreviewChange:h,minDate:p,maxDate:f,shouldDisableDate:y,showOutsideDays:v=!0,autoFocus:w=!1,showPreviousButton:D=!0,showNextButton:S=!0,precision:N="day",labels:C}){const[k,E]=o.useState(N),T=$[k]<$[N]?N:k,Y=o.useMemo(()=>i.filter(P),[i]),[R,H]=o.useState(()=>{const e=Y.find(e=>M(e,s));return e?j(e):M(A(),s)?A():z(s)}),K=o.useRef(w),U=o.useRef(null);o.useEffect(()=>{H(e=>M(e,s)?e:z(s))},[s]),o.useLayoutEffect(()=>{K.current&&(K.current=!1,U.current?.querySelector('[data-focus-target="true"]')?.focus({preventScroll:!0}))});const V=o.useCallback(e=>x(e,p,f)||(y?.(e)??!1),[p,f,y]),G=e=>{K.current=!0,E(e)},W=e=>{K.current=!0,c(e)};return t("div",{ref:U,className:"mp-calendar flex flex-col gap-1",style:{"--_mp-cell":B[n]},onPointerLeave:()=>h?.(null),children:[e(L,{size:n,color:r,view:T,month:s,locale:l,labels:C,showPreviousButton:D,showNextButton:S,onStep:e=>{c("day"===T?g(s,e):b(s,"month"===T?e:e*F))},onViewChange:G}),e("div",{className:"h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*7)]",children:"day"===T?e(I,{size:n,locale:l,weekStartsOn:a,month:s,chosen:Y,rangeStart:u,rangeEnd:m,focusedDate:R,showOutsideDays:v,isDisabled:V,onSelect:e=>{H(e),d(e)},onPreviewChange:h,onMoveFocus:e=>{K.current=!0,H(e),M(e,s)||c(z(e))}}):"month"===T?e(O,{size:n,locale:l,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{const t=_(s.getFullYear(),e,1);"month"!==N?(c(t),G("day")):d(t)}}):e(q,{size:n,month:s,chosen:Y,minDate:p,maxDate:f,onMoveCursor:W,onPick:e=>{"year"!==N?(c(_(e,s.getMonth(),1)),G("month")):d(_(e,0,1))}})})]})}function U(e){return"rtl"===getComputedStyle(e).direction?-1:1}function I({size:n,locale:r,weekStartsOn:l,month:a,chosen:s,rangeStart:c,rangeEnd:i,focusedDate:u,showOutsideDays:m,isDisabled:p,onSelect:b,onPreviewChange:x,onMoveFocus:D}){const N=E(r,l,"narrow"),_=E(r,l,"long"),C=(j=i,P(k=c)&&P(j)?v(k,j)<=0?[k,j]:[j,k]:null);var k,j;const z=A(),T=o.useMemo(()=>{const e=w(r,{dateStyle:"full"});return y(a,l).map(t=>t.map(t=>({date:t,label:e.format(t)})))},[a,l,r]),F=o.useRef(null),Y=o.useRef(a);o.useLayoutEffect(()=>{const e=F.current,t=Y.current;if(Y.current=a,!e||M(t,a))return;const n=t.getTime()<a.getTime(),o="rtl"===getComputedStyle(e).direction;e.style.setProperty("--_mp-calendar-from",String(n===o?-1:1)),e.dataset.mpPaged="true",e.style.animationName="none",e.offsetWidth,e.style.animationName=""},[a]);return t("div",{role:"grid","aria-label":w(r,{year:"numeric",month:"long"}).format(a),className:"flex h-full flex-col",children:[e("div",{role:"rowgroup",children:e("div",{role:"row",className:"grid grid-cols-7",children:N.map((t,n)=>e("span",{role:"columnheader","aria-label":_[n],className:`text-mp-on-surface-variant flex h-(--_mp-cell) items-center justify-center select-none ${d}`,children:t},n))})}),e("div",{ref:F,role:"rowgroup",className:"mp-calendar__page flex flex-1 flex-col",children:T.map((t,o)=>e("div",{role:"row",className:"grid grid-cols-7",children:t.map(({date:t,label:o})=>{const r=!M(t,a);if(r&&!m)return e("span",{role:"gridcell","aria-hidden":"true",className:"size-(--_mp-cell)"},t.getTime());const c=s.some(e=>S(e,t)),i=null!==C&&v(t,C[0])>=0&&v(t,C[1])<=0,d=null!==C&&i&&S(t,C[0]),y=null!==C&&i&&S(t,C[1]);return e(K,{label:o,selected:c,inRange:i&&!c,rangeEdge:i?d&&y?"both":d?"start":y?"end":"middle":null,current:S(t,z)&&!c,muted:r,disabled:p(t),focused:S(t,u),className:`size-(--_mp-cell) ${h[n]}`,onClick:()=>b(t),onPointerEnter:()=>x?.(t),onKeyDown:e=>((e,t)=>{const n=(t.getDay()-l+7)%7,o=U(e.currentTarget),r={ArrowLeft:()=>f(t,-o),ArrowRight:()=>f(t,o),ArrowUp:()=>f(t,-7),ArrowDown:()=>f(t,7),Home:()=>f(t,-n),End:()=>f(t,6-n),PageUp:()=>g(t,e.shiftKey?-12:-1),PageDown:()=>g(t,e.shiftKey?12:1)}[e.key];r&&(e.preventDefault(),D(r()))})(e,t),children:t.getDate()},t.getTime())})},o))})]})}function O({size:t,locale:n,month:r,chosen:l,minDate:a,maxDate:s,onMoveCursor:c,onPick:i}){const u=k(n,"short"),m=r.getFullYear(),d=new Date,p=o.useMemo(()=>{const e=w(n,{year:"numeric",month:"long"});return Array.from({length:12},(t,n)=>e.format(_(m,n,1)))},[n,m]),f=e=>{const t=U(e.currentTarget),n={ArrowLeft:-t,ArrowRight:t,ArrowUp:-3,ArrowDown:3,PageUp:-12,PageDown:12}[e.key];void 0!==n&&(e.preventDefault(),c(g(z(r),n)))};return e("div",{role:"grid","aria-label":String(m),className:"flex h-full flex-col justify-evenly",children:[0,1,2,3].map(n=>e("div",{role:"row",className:"grid grid-cols-3 gap-1",children:[0,1,2].map(o=>{const c=3*n+o;return e(K,{label:p[c],selected:l.some(e=>e.getFullYear()===m&&e.getMonth()===c),current:d.getFullYear()===m&&d.getMonth()===c,disabled:N(_(m,c,1),"month",a,s),focused:c===r.getMonth(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>i(c),onKeyDown:f,children:u[c]},c)})},n))})}function q({size:t,month:n,chosen:o,minDate:r,maxDate:l,onMoveCursor:a,onPick:s}){const c=Y(n.getFullYear()),i=(new Date).getFullYear(),u=e=>{const t=U(e.currentTarget),o={ArrowLeft:-t,ArrowRight:t,ArrowUp:-4,ArrowDown:4,PageUp:-F,PageDown:F}[e.key];void 0!==o&&(e.preventDefault(),a(b(z(n),o)))};return e("div",{role:"grid","aria-label":`${c}–${c+F-1}`,className:"flex h-full flex-col justify-evenly",children:[0,1,2].map(a=>e("div",{role:"row",className:"grid grid-cols-4 gap-1",children:[0,1,2,3].map(m=>{const d=c+4*a+m;return e(K,{label:String(d),selected:o.some(e=>e.getFullYear()===d),current:d===i,disabled:N(_(d,0,1),"year",r,l),focused:d===n.getFullYear(),className:`h-(--_mp-cell) w-full ${h[t]}`,onClick:()=>s(d),onKeyDown:u,children:d},d)})},a))})}function V(e,t){return Number.isFinite(e)?Math.min(t,Math.max(1,Math.round(e))):1}function G(e,t="auto"){const n=e.parentElement;if(!n)return;const o=e.getBoundingClientRect(),r=n.getBoundingClientRect(),l=o.top-r.top-n.clientTop+n.scrollTop,a=l+o.height;l<n.scrollTop?n.scrollTo({top:l,behavior:t}):a>n.scrollTop+n.clientHeight&&n.scrollTo({top:a-n.clientHeight,behavior:t})}export function MPTimeGrid({size:n,locale:r,value:l,referenceDate:a,onChange:s,hour12:c,showSeconds:i,hourStep:m,minuteStep:d,secondStep:f,shouldDisableTime:g,autoFocus:b=!1,labels:y}){const v=l??a,x=o.useRef(null),[D,S]=o.useMemo(()=>C(r),[r]);o.useEffect(()=>{const e=x.current;if(e?.querySelectorAll('[data-chosen="true"]').forEach(e=>G(e,"instant")),b){const t=e?.querySelector('[role="listbox"]');(t?.querySelector('[data-chosen="true"]')??t?.querySelector('[role="option"]'))?.focus({preventScroll:!0})}},[b]);const M=o.useMemo(()=>{const e=c?12:24,t=V(m,e),n=Array.from({length:Math.ceil(e/t)},(e,n)=>n*t);return c?n.map(e=>0===e?12:e):n},[c,m]),N=o.useMemo(()=>{const e=V(d,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[d]),P=o.useMemo(()=>{const e=V(f,60);return Array.from({length:Math.ceil(60/e)},(t,n)=>n*e)},[f]),_=e=>String(e).padStart(2,"0"),k=c?v.getHours()%12||12:v.getHours(),[j,z]=o.useState({}),A=(o,r,a,i,m)=>{const d=null===l?-1:a.findIndex(e=>i(e)),p=j[o]??(d>=0?d:0);return e("div",{role:"listbox","aria-label":r,className:["mp-time-grid__column flex flex-col gap-0.5 overflow-y-auto overscroll-contain","motion-safe:scroll-smooth","h-[calc(var(--_mp-cell)*7)] w-[calc(var(--_mp-cell)*1.75)]","scroll-py-0.5 [scrollbar-width:thin]"].join(" "),onKeyDown:e=>{const t={ArrowDown:1,ArrowUp:-1,PageDown:5,PageUp:-5}[e.key],n=void 0!==t?(e=>{const t=[...e.children].indexOf(document.activeElement);return t>=0?t:p})(e.currentTarget)+t:"Home"===e.key?0:"End"===e.key?a.length-1:null;null!==n&&(e.preventDefault(),((e,t)=>{const n=Math.min(a.length-1,Math.max(0,e)),r=t.children[n];z(e=>({...e,[o]:n})),r instanceof HTMLElement&&(r.focus({preventScroll:!0}),G(r))})(n,e.currentTarget))},children:a.map((r,a)=>{const d=((e,t)=>T(v,"hour"===e?{hours:c?t%12+(v.getHours()>=12?12:0):t}:"minute"===e?{minutes:t}:"second"===e?{seconds:t}:{hours:v.getHours()%12+12*t}))(o,r),f=null!==l&&i(r),b=g?.(d,o)??!1;return t("button",{type:"button",role:"option","aria-selected":f,"aria-disabled":b||void 0,"data-chosen":f?"true":void 0,tabIndex:a===p?0:-1,className:[H,"rounded-mp-full h-(--_mp-cell) w-full shrink-0 border-0",h[n],b?"bg-transparent cursor-default text-mp-on-surface/38":f?"bg-(--_mp-accent) text-(--_mp-on-accent)":"bg-transparent text-mp-on-surface"].join(" "),onFocus:()=>z(e=>({...e,[o]:a})),onClick:()=>{b||s(d)},children:[b?null:e(u,{}),m(r)]},r)})},o)};return t("div",{ref:x,className:"mp-time-grid flex gap-1",style:{"--_mp-cell":B[n]},children:[A("hour",y.hour,M,e=>e===k,e=>c?String(e):_(e)),A("minute",y.minute,N,e=>e===v.getMinutes(),_),i?A("second",y.second,P,e=>e===v.getSeconds(),_):null,c?A("meridiem",y.meridiem,[0,1],e=>(v.getHours()>=12?1:0)===e,e=>0===e?D:S):null,e("span",{className:p,"aria-live":"polite",children:null===l?"":w(r,{hour:"numeric",minute:"2-digit",...i?{second:"2-digit"}:{}}).format(l)})]})}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ChartValue } from './chart.js';
|
|
3
|
-
import type { MPChartCategory, MPChartLegend, MPChartTooltip, MPChartTooltipItem, MPSide, MPSize } from '../types.js';
|
|
3
|
+
import type { MPChartCategory, MPChartLabelColor, MPChartLegend, MPChartTooltip, MPChartTooltipItem, MPSide, MPSize } from '../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Everything a chart draws that is not the data.
|
|
6
6
|
*
|
|
@@ -52,6 +52,22 @@ export interface ChartBaseProps extends Omit<React.ComponentPropsWithoutRef<'div
|
|
|
52
52
|
tooltip?: boolean | MPChartTooltip;
|
|
53
53
|
/** What to draw when there is nothing to draw. */
|
|
54
54
|
empty?: React.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* What ink the text naming a series is written in — the legend's entries, and
|
|
57
|
+
* the values written onto the marks.
|
|
58
|
+
*
|
|
59
|
+
* `'series'` matches each name to the mark it names, which is the fastest way
|
|
60
|
+
* to pair a long legend with a crowded plot. It is not the default because it
|
|
61
|
+
* is a trade: the eight chart slots are fitted to 3:1 against the surface,
|
|
62
|
+
* which is the bar for a *mark*, and small text wants 4.5:1. Reach for it on
|
|
63
|
+
* a chart whose legend is doing real work, and leave it alone where the
|
|
64
|
+
* swatch beside the name is already enough.
|
|
65
|
+
*
|
|
66
|
+
* Labels drawn **on** a fill — a pie's shares, a heatmap's cells — ignore it
|
|
67
|
+
* and keep the ink that reads against what they sit on.
|
|
68
|
+
* @default 'ink'
|
|
69
|
+
*/
|
|
70
|
+
labelColor?: MPChartLabelColor;
|
|
55
71
|
/** @default 'md' */
|
|
56
72
|
size?: MPSize;
|
|
57
73
|
}
|
|
@@ -74,12 +90,6 @@ export interface Visibility {
|
|
|
74
90
|
export declare function useVisibility(series: readonly {
|
|
75
91
|
hidden?: boolean;
|
|
76
92
|
}[]): Visibility;
|
|
77
|
-
export declare const LEGEND_SIDE: {
|
|
78
|
-
readonly top: "flex-col-reverse";
|
|
79
|
-
readonly bottom: "flex-col";
|
|
80
|
-
readonly left: "flex-row-reverse";
|
|
81
|
-
readonly right: "flex-row";
|
|
82
|
-
};
|
|
83
93
|
interface LegendProps {
|
|
84
94
|
/**
|
|
85
95
|
* What each entry is called. Names rather than series, because a pie's
|
|
@@ -94,24 +104,39 @@ interface LegendProps {
|
|
|
94
104
|
size: MPSize;
|
|
95
105
|
values?: readonly (string | undefined)[];
|
|
96
106
|
swatch?: (index: number, color: string) => React.ReactNode;
|
|
107
|
+
/** Writes each name in its own series' colour rather than in ordinary ink. */
|
|
108
|
+
colorNames?: boolean;
|
|
97
109
|
}
|
|
98
110
|
/**
|
|
99
111
|
* The identity channel that does not depend on being able to see a colour.
|
|
100
112
|
*
|
|
101
|
-
* A swatch and a word
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* in forced colours.
|
|
113
|
+
* A swatch and a word. The swatch carries the series' colour and the name
|
|
114
|
+
* beside it stays in ordinary ink, because a label written in the mark's colour
|
|
115
|
+
* is one more thing between the reader and the word — `colorNames` is the
|
|
116
|
+
* caller saying they want that trade anyway, and it is off unless they do.
|
|
106
117
|
*
|
|
107
118
|
* Interactive by default, and each entry is a real `<button>` with
|
|
108
119
|
* `aria-pressed`. A legend that filters is a control, and a control that is a
|
|
109
120
|
* `<div>` with an `onClick` is one a keyboard cannot reach.
|
|
121
|
+
*
|
|
122
|
+
* ## Off and quiet are two states, and they look different
|
|
123
|
+
*
|
|
124
|
+
* A series the reader has switched off is drawn at Material's disabled
|
|
125
|
+
* opacity — swatch and name together, the same treatment a disabled control
|
|
126
|
+
* gets, because that is what it is. A series merely standing back while another
|
|
127
|
+
* is hovered is quieter than usual and no more, so the two cannot be mistaken
|
|
128
|
+
* for each other at a glance. Opacity survives greyscale and forced colours,
|
|
129
|
+
* which a change of hue would not, and `aria-pressed` carries the same fact to
|
|
130
|
+
* a reader who is not looking at all.
|
|
110
131
|
*/
|
|
111
|
-
export declare function ChartLegend({ names, colors, options, visibility, size, values, swatch }: LegendProps): React.JSX.Element;
|
|
132
|
+
export declare function ChartLegend({ names, colors, options, visibility, size, values, swatch, colorNames }: LegendProps): React.JSX.Element;
|
|
112
133
|
interface PanelProps {
|
|
113
134
|
heading?: React.ReactNode;
|
|
114
135
|
items: readonly MPChartTooltipItem[];
|
|
136
|
+
/** What the rows add up to, where the chart is a picture of that sum. */
|
|
137
|
+
total?: string;
|
|
138
|
+
/** And what that row is called, in the chart's own language. */
|
|
139
|
+
totalLabel?: string;
|
|
115
140
|
x: number;
|
|
116
141
|
y: number;
|
|
117
142
|
flip: boolean;
|
|
@@ -124,7 +149,7 @@ interface PanelProps {
|
|
|
124
149
|
* would sit under the pointer, take the hover from the plot, and close itself —
|
|
125
150
|
* then reopen, then close, for as long as the reader held still.
|
|
126
151
|
*/
|
|
127
|
-
export declare function ChartTooltipPanel({ heading, items, x, y, flip, size }: PanelProps): React.JSX.Element;
|
|
152
|
+
export declare function ChartTooltipPanel({ heading, items, total, totalLabel, x, y, flip, size }: PanelProps): React.JSX.Element;
|
|
128
153
|
/**
|
|
129
154
|
* The same reading, said out loud instead of drawn.
|
|
130
155
|
*
|
|
@@ -138,9 +163,11 @@ export declare function ChartTooltipPanel({ heading, items, x, y, flip, size }:
|
|
|
138
163
|
* Empty when nothing is active, so leaving the chart clears what was said
|
|
139
164
|
* rather than leaving the last column standing in the region forever.
|
|
140
165
|
*/
|
|
141
|
-
export declare function ChartStatus({ heading, items }: {
|
|
166
|
+
export declare function ChartStatus({ heading, items, total, totalLabel }: {
|
|
142
167
|
heading?: React.ReactNode;
|
|
143
168
|
items: readonly MPChartTooltipItem[];
|
|
169
|
+
total?: string;
|
|
170
|
+
totalLabel?: string;
|
|
144
171
|
}): React.JSX.Element;
|
|
145
172
|
interface TableProps {
|
|
146
173
|
id: string;
|
|
@@ -184,11 +211,22 @@ export interface ChartShellProps extends Omit<React.ComponentPropsWithoutRef<'di
|
|
|
184
211
|
children: React.ReactNode;
|
|
185
212
|
/** Floated over the drawing. */
|
|
186
213
|
tooltip?: React.ReactNode;
|
|
214
|
+
/**
|
|
215
|
+
* A control over the corner of the plot — the one thing a chart has that is
|
|
216
|
+
* neither the picture nor a legend entry.
|
|
217
|
+
*
|
|
218
|
+
* A **sibling** of the plot rather than a child, for the reason the readout
|
|
219
|
+
* is one: `role="img"` is a leaf role, and a button inside it is a button no
|
|
220
|
+
* keyboard can reach and no screen reader can find.
|
|
221
|
+
*/
|
|
222
|
+
overlay?: React.ReactNode;
|
|
187
223
|
legend?: React.ReactNode;
|
|
188
224
|
legendSide?: MPSide;
|
|
189
225
|
status: {
|
|
190
226
|
heading?: React.ReactNode;
|
|
191
227
|
items: readonly MPChartTooltipItem[];
|
|
228
|
+
total?: string;
|
|
229
|
+
totalLabel?: string;
|
|
192
230
|
};
|
|
193
231
|
table?: React.ReactNode;
|
|
194
232
|
}
|
|
@@ -197,9 +235,15 @@ export interface ChartShellProps extends Omit<React.ComponentPropsWithoutRef<'di
|
|
|
197
235
|
* it and the table underneath.
|
|
198
236
|
*
|
|
199
237
|
* The readout is a **sibling** of the plot rather than a child, and that is a
|
|
200
|
-
* constraint rather than a layout preference — see `ChartStatus`.
|
|
201
|
-
*
|
|
202
|
-
*
|
|
238
|
+
* constraint rather than a layout preference — see `ChartStatus`. So is
|
|
239
|
+
* anything in `overlay`, for the same reason. Putting the arrangement here is
|
|
240
|
+
* what keeps the two frames from disagreeing about it: the one place this is
|
|
241
|
+
* easy to get wrong is the one place it must not be.
|
|
242
|
+
*
|
|
243
|
+
* The plot sits in a positioning box of its own rather than directly in the
|
|
244
|
+
* row. The box is always there, zoomed or not — a wrapper that came and went
|
|
245
|
+
* would unmount the plot with it, and a plot that unmounts takes the reader's
|
|
246
|
+
* focus with it.
|
|
203
247
|
*/
|
|
204
|
-
export declare function ChartShell({ size, plotRef, name, describedBy, interactive, height, plotProps, children, tooltip, legend, legendSide, status, table, className, ...rest }: ChartShellProps): React.JSX.Element;
|
|
248
|
+
export declare function ChartShell({ size, plotRef, name, describedBy, interactive, height, plotProps, children, tooltip, overlay, legend, legendSide, status, table, className, ...rest }: ChartShellProps): React.JSX.Element;
|
|
205
249
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as t,jsxs as l}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{VISUALLY_HIDDEN as n}from"./visually-hidden.js";import{cssLength as r}from"./length.js";import{PLOT_HEIGHT as i,formatCategory as s}from"./chart.js";export function useVisibility(e){const[t,l]=a.useState(()=>{const t=new Set;return e.forEach((e,l)=>{e.hidden&&t.add(l)}),t}),[n,r]=a.useState(null),i=a.useCallback(e=>{l(t=>{const l=new Set(t);return l.has(e)?l.delete(e):l.add(e),l})},[]);return{visible:e.map((e,l)=>!t.has(l)),hovered:n,toggle:i,setHovered:r}}const o={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},c={start:"justify-start",center:"justify-center",end:"justify-end"};export function ChartLegend({names:a,colors:n,options:r,visibility:i,size:s,values:o,swatch:m,colorNames:d=!1}){const u=!1!==r.interactive,p="xs"===s||"sm"===s?"text-mp-label-small":"text-mp-label-medium";return e("ul",{className:["mp-chart__legend m-0 flex list-none flex-wrap items-center gap-x-4 gap-y-1 p-0",c[r.align??"center"],p].join(" "),children:a.map((a,r)=>{const s=i.visible[r],c=s&&null!==i.hovered&&i.hovered!==r,p=a??`${r+1}`,h=l(t,{children:[e("span",{className:"shrink-0","aria-hidden":"true",children:m?m(r,n[r]):e("span",{className:"block size-2.5 rounded-mp-full",style:{background:n[r]}})}),e("span",{className:d?"truncate":"text-mp-on-surface-variant truncate",style:d?{color:n[r]}:void 0,children:p}),o?.[r]?e("span",{className:"text-mp-on-surface tabular-nums",children:o[r]}):null]}),f=s?c?"opacity-60":"":"opacity-38";return e("li",{className:"min-w-0",children:u?e("button",{type:"button","aria-pressed":s,onClick:()=>i.toggle(r),onPointerEnter:()=>i.setHovered(r),onPointerLeave:()=>i.setHovered(null),onFocus:e=>{e.currentTarget.matches(":focus-visible")&&i.setHovered(r)},onBlur:()=>i.setHovered(null),className:["flex min-w-0 cursor-pointer items-center gap-1.5 rounded-mp-xs","appearance-none border-0 bg-transparent p-0 text-inherit [font:inherit]","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2",f].filter(Boolean).join(" "),children:h}):e("span",{className:`flex min-w-0 items-center gap-1.5 ${f}`,children:h})},r)})})}export function ChartTooltipPanel({heading:t,items:a,total:n,totalLabel:r,x:i,y:s,flip:o,size:c}){return l("div",{"aria-hidden":"true",className:["mp-chart__tooltip pointer-events-none absolute z-10 min-w-24 max-w-64","bg-mp-surface-container-high shadow-mp-2 rounded-mp-xs px-2.5 py-2","xs"===c||"sm"===c?"text-mp-label-small":"text-mp-label-medium"].join(" "),style:{left:i,top:s,transform:`translate(${o?"calc(-100% - 12px)":"12px"}, -50%)`},children:[null==t||""===t?null:e("div",{className:"text-mp-on-surface-variant mb-1 truncate",children:t}),l("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:[a.map(t=>l("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"block size-2 shrink-0 rounded-mp-full",style:{background:t.color}}),t.name?e("span",{className:"text-mp-on-surface-variant min-w-0 truncate",children:t.name}):null,e("span",{className:"text-mp-on-surface ms-auto ps-2 tabular-nums",children:t.label??t.formatted})]},t.seriesIndex)),void 0===n?null:l("li",{className:"border-mp-outline-variant mt-1 flex items-center gap-1.5 border-0 border-t border-solid pt-1",children:[e("span",{className:"text-mp-on-surface-variant min-w-0 truncate",children:r}),e("span",{className:"text-mp-on-surface ms-auto ps-2 tabular-nums",children:n})]})]})]})}export function ChartStatus({heading:r,items:i,total:s,totalLabel:o}){return e("span",{role:"status","aria-live":"polite",className:n,children:0===i.length?null:l(t,{children:[null==r||""===r?null:l(t,{children:[r,", "]}),i.map((e,t)=>l(a.Fragment,{children:[t>0?", ":null,e.name?`${e.name}: `:null,e.label??e.formatted]},e.seriesIndex)),void 0===s?null:`, ${o}: ${s}`]})})}export function ChartTable({id:t,caption:a,corner:r,categories:i,names:o,values:c,format:m,locale:d,empty:u}){return e("div",{id:t,className:n,children:l("table",{children:[e("caption",{children:a}),e("thead",{children:l("tr",{children:[e("th",{scope:"col",children:r}),o.map((t,l)=>e("th",{scope:"col",children:t??l+1},l))]})}),e("tbody",{children:0===i.length?e("tr",{children:e("td",{colSpan:o.length+1,children:u})}):i.map((t,a)=>l("tr",{children:[e("th",{scope:"row",children:s(t,d)}),o.map((t,l)=>{const n=c[l]?.[a];return e("td",{children:n?.label??(null===n?.value||void 0===n?u:m(n.value))},l)})]},a))})]})})}export function ChartShell({size:t,plotRef:a,name:n,describedBy:s,interactive:c,height:m,plotProps:d,children:u,tooltip:p,overlay:h,legend:f,legendSide:x="bottom",status:b,table:v,className:g,...N}){return l("div",{"data-mp-size":t,className:["mp-chart flex min-w-0 flex-col gap-3",g??""].filter(Boolean).join(" "),...N,children:[l("div",{className:`flex min-w-0 gap-3 ${o[x]}`,children:[l("div",{className:"relative flex min-w-0 flex-1",children:[l("div",{ref:a,role:"img",tabIndex:c?0:void 0,"aria-label":n,"aria-describedby":s,...d,className:["mp-chart__plot rounded-mp-xs relative min-w-0 flex-1","focus-visible:outline-mp-primary focus-visible:outline-2 focus-visible:outline-offset-2"].join(" "),style:{height:r(m)??i[t]},children:[u,p]}),h]}),f]}),e(ChartStatus,{heading:b.heading,items:b.items,total:b.total,totalLabel:b.totalLabel}),v]})}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ChartBaseProps } from './ChartChrome.js';
|
|
3
3
|
import { BandScale, ChartValue, PlotBox, ValueScale } from './chart.js';
|
|
4
|
-
import type { MPChartAxis, MPChartCategory, MPChartSeries, MPChartTooltipItem, MPSize } from '../types.js';
|
|
4
|
+
import type { MPChartAxis, MPChartCategory, MPChartSeries, MPChartStack, MPChartTooltipItem, MPChartZoom, MPSize } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* The frame a chart with two axes is drawn in.
|
|
7
7
|
*
|
|
@@ -26,6 +26,15 @@ export interface CartesianChartProps extends ChartBaseProps {
|
|
|
26
26
|
xAxis?: MPChartAxis;
|
|
27
27
|
/** The value axis. */
|
|
28
28
|
yAxis?: MPChartAxis;
|
|
29
|
+
/**
|
|
30
|
+
* Lets a reader drag a range out of the category axis and redraws to it.
|
|
31
|
+
*
|
|
32
|
+
* For the chart with ninety points on it, where the shape of one week is
|
|
33
|
+
* inside a picture of a quarter. Everything follows the window — the scale,
|
|
34
|
+
* the panel, the readout and the table — so what is drawn is a chart of that
|
|
35
|
+
* range rather than a magnified picture of the whole one.
|
|
36
|
+
*/
|
|
37
|
+
zoom?: boolean | MPChartZoom;
|
|
29
38
|
}
|
|
30
39
|
/**
|
|
31
40
|
* One mark on a plot whose marks are not arranged in columns.
|
|
@@ -74,6 +83,15 @@ export interface CartesianLayout {
|
|
|
74
83
|
visible: readonly boolean[];
|
|
75
84
|
/** And what colour each one is, by its original index. */
|
|
76
85
|
colors: readonly string[];
|
|
86
|
+
/**
|
|
87
|
+
* What ink a value written onto one of series `index`' marks wears.
|
|
88
|
+
*
|
|
89
|
+
* Ordinary ink unless the caller asked for `labelColor="series"`. A chart
|
|
90
|
+
* whose labels sit **on** a fill rather than beside a mark ignores it: there
|
|
91
|
+
* the question is what reads against the colour underneath, which is not a
|
|
92
|
+
* question about identity at all.
|
|
93
|
+
*/
|
|
94
|
+
labelInk: (series: number) => string;
|
|
77
95
|
scale: ValueScale;
|
|
78
96
|
band: BandScale;
|
|
79
97
|
/** Bars run along the category axis rather than across it. */
|
|
@@ -102,6 +120,8 @@ export interface CartesianLayout {
|
|
|
102
120
|
zeroPx: number;
|
|
103
121
|
categories: readonly MPChartCategory[];
|
|
104
122
|
format: (value: number) => string;
|
|
123
|
+
/** A fraction as the chart writes a share — whole percentages. */
|
|
124
|
+
share: (fraction: number) => string;
|
|
105
125
|
size: MPSize;
|
|
106
126
|
}
|
|
107
127
|
/** The layout, plus everything the pointer decides. */
|
|
@@ -162,8 +182,8 @@ interface CartesianFrameProps extends CartesianChartProps {
|
|
|
162
182
|
} | null;
|
|
163
183
|
/** Bars, and only bars, run the other way. */
|
|
164
184
|
horizontal?: boolean;
|
|
165
|
-
/** The value axis measures totals rather than parts. */
|
|
166
|
-
stacked?:
|
|
185
|
+
/** The value axis measures totals rather than parts, or shares of one. */
|
|
186
|
+
stacked?: MPChartStack;
|
|
167
187
|
/** A line chart may leave zero out; a bar chart may not. */
|
|
168
188
|
includeZero?: boolean;
|
|
169
189
|
/** How much of a band the marks take. Bars need room reserved; lines do not. */
|
|
@@ -193,5 +213,5 @@ interface CartesianFrameProps extends CartesianChartProps {
|
|
|
193
213
|
/**
|
|
194
214
|
* The frame: two axes, a grid, a crosshair, a legend, a panel and the table.
|
|
195
215
|
*/
|
|
196
|
-
export declare function CartesianFrame({ series, categories, xAxis, yAxis, horizontal, stacked, includeZero, bandRatio, inset, headroom, markInset, xScale, marks, markRadius, swatch, scale: givenScale, table: givenTable, markTooltip, height, format, locale: localeProp, label, legend, tooltip, empty, size: sizeProp, className, style, children, ...rest }: CartesianFrameProps): React.JSX.Element;
|
|
216
|
+
export declare function CartesianFrame({ series, categories, xAxis, yAxis, horizontal, zoom, stacked, includeZero, bandRatio, inset, headroom, markInset, xScale, marks, markRadius, swatch, scale: givenScale, table: givenTable, markTooltip, height, format, locale: localeProp, label, legend, tooltip, empty, labelColor, size: sizeProp, className, style, children, ...rest }: CartesianFrameProps): React.JSX.Element;
|
|
197
217
|
export {};
|