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
|
@@ -52,7 +52,7 @@ export interface MPEmptyProps extends Omit<React.ComponentPropsWithoutRef<'div'>
|
|
|
52
52
|
* `transition="fade"` is the whole of what most callers want; the object form
|
|
53
53
|
* takes a duration, an edge to come from, or a scale to start at. Anything
|
|
54
54
|
* that has to run again — on scroll, on hover, under your own control — is an
|
|
55
|
-
* [MPAnimateFade](../
|
|
55
|
+
* [MPAnimateFade](../transitions/animate-fade) and its siblings.
|
|
56
56
|
*/
|
|
57
57
|
transition?: MPTransition;
|
|
58
58
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as t,jsxs as e}from"react/jsx-runtime";import*as o from"react";import{Button as n}from"@base-ui/react/button";import{accentSlots as a}from"../../internal/accent.js";import{cssLength as i}from"../../internal/length.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{hasContent as r}from"../../internal/scale.js";import{useMPColor as m,useMPSize as l}from"../../internal/config.js";const p={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"bg-mp-surface-container-high text-(--_mp-accent)"},d={xs:"h-10",sm:"h-12",md:"h-14",lg:"h-18",xl:"h-24"},f={xs:"min-w-10 gap-0 px-0",sm:"min-w-12 gap-0 px-0",md:"min-w-14 gap-0 px-0",lg:"min-w-18 gap-0 px-0",xl:"min-w-24 gap-0 px-0"},c={xs:"rounded-mp-md",sm:"rounded-mp-lg",md:"rounded-mp-lg",lg:"rounded-mp-xl",xl:"rounded-mp-xl"},x={xs:24,sm:24,md:24,lg:30,xl:36},u={xs:"text-mp-label-large",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"},b={xs:"min-w-16 gap-1.5 px-3",sm:"min-w-18 gap-2 px-4",md:"min-w-20 gap-2 px-4",lg:"min-w-24 gap-2.5 px-5",xl:"min-w-28 gap-3 px-6"},g={absolute:"absolute z-30",sticky:"sticky z-30",fixed:"fixed z-40"},h={"top-start":"top-(--_mp-fab-offset) start-(--_mp-fab-offset)","top-end":"top-(--_mp-fab-offset) end-(--_mp-fab-offset)","bottom-start":"bottom-(--_mp-fab-offset) start-(--_mp-fab-offset)","bottom-end":"bottom-(--_mp-fab-offset) end-(--_mp-fab-offset)"};export const MPFloatingActionButton=/*@__PURE__*/o.forwardRef(function({icon:o,label:w,extended:_=!1,variant:y="tonal",color:j,size:v,position:k="fixed",corner:z="bottom-end",offset:N=16,disabled:B=!1,type:$="button",className:A,style:F,...L},M){const P=m(j),R=l(v);return e(n,{ref:M,type:$,disabled:B,"aria-label":w,"data-mp-size":R,"data-mp-variant":y,className:["mp-fab group inline-flex shrink-0 items-center justify-center","box-border overflow-hidden align-middle whitespace-nowrap select-none","cursor-pointer appearance-none border-0 font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-[background-color,box-shadow,color,min-width,padding,gap]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",c[R],d[R],u[R],_?b[R]:f[R],B?"bg-mp-on-surface/12 text-mp-on-surface/38 cursor-default shadow-none":`${p[y]} shadow-mp-3`,"static"===k?"relative":`${g[k]} ${h[z]}`,A??""].filter(Boolean).join(" "),style:{...a(P),"--_mp-fab-offset":i(N),...F},...L,children:[B?null:t(s,{}),r(o)?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:x[R],height:x[R]},children:o}):null,t("span",{className:["relative grid transition-[grid-template-columns]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",_?"grid-cols-[1fr]":"grid-cols-[0fr]"].join(" "),children:t("span",{className:"min-w-0 truncate",children:w})})]})});
|
|
@@ -15,19 +15,28 @@ export type MPGridAlign = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
|
15
15
|
/** The same, for one item overriding the row it is in. */
|
|
16
16
|
export type MPGridAlignSelf = MPGridAlign | 'auto';
|
|
17
17
|
/**
|
|
18
|
-
* How wide one item is: a number of the grid's columns, or `'
|
|
18
|
+
* How wide one item is: a number of the grid's columns, `'grow'` or `'auto'`.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* cannot
|
|
24
|
-
* row have been laid out
|
|
25
|
-
*
|
|
20
|
+
* Neither word is a measurement, and they are the two ends of the same question
|
|
21
|
+
* a column count cannot answer. `'grow'` is "whatever the row has left after
|
|
22
|
+
* everybody else has taken theirs" — the width a thumbnail's neighbour wants,
|
|
23
|
+
* and one the arithmetic cannot reach because the remainder is only known once
|
|
24
|
+
* the other items in *that* row have been laid out. `'auto'` is "exactly what is
|
|
25
|
+
* inside me", which the arithmetic cannot reach either: what is inside an item
|
|
26
|
+
* is measured by the browser, and a share of twelve columns has to be written
|
|
27
|
+
* down in advance.
|
|
28
|
+
*
|
|
29
|
+
* They pair. A control bar whose left half is a set of transport buttons and
|
|
30
|
+
* whose right half is however many icon buttons the page turned out to need is
|
|
31
|
+
* `span="grow"` and `span="auto"`, and neither side has a number in it — which
|
|
32
|
+
* matters because the number would be wrong: four 32px buttons in `span={2}` of
|
|
33
|
+
* a 768px bar is 128px against 128px, and the pixel that sub-pixel rounding
|
|
34
|
+
* takes off wraps the last button onto a second row.
|
|
26
35
|
*
|
|
27
36
|
* Two growing items in a row split the remainder equally rather than by their
|
|
28
37
|
* contents, which is the useful half of what makes it predictable.
|
|
29
38
|
*/
|
|
30
|
-
export type MPGridSpan = number | 'grow';
|
|
39
|
+
export type MPGridSpan = number | 'grow' | 'auto';
|
|
31
40
|
export interface MPGridProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
32
41
|
/**
|
|
33
42
|
* How many columns a row is divided into. Every `span` and every `offset`
|
|
@@ -96,6 +105,14 @@ export interface MPGridItemProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
|
96
105
|
* when the picture's column count changes. It is responsive like any other
|
|
97
106
|
* value: `span={{ compact: 12, medium: 'grow' }}` stacks on a phone and fills
|
|
98
107
|
* the rest of the row from 600dp.
|
|
108
|
+
*
|
|
109
|
+
* `span="auto"` is the other end of that: exactly the width of what is inside
|
|
110
|
+
* the item, however much that turns out to be. It is the span for a group
|
|
111
|
+
* whose size is a runtime question — a row of icon buttons where how many
|
|
112
|
+
* there are depends on what the page can do — and it pairs with `'grow'`, one
|
|
113
|
+
* item taking what it needs and the other taking the rest. An `'auto'` item
|
|
114
|
+
* does not shrink, so contents wider than the row overflow rather than
|
|
115
|
+
* squeezing what is beside them.
|
|
99
116
|
* @default the grid's full width
|
|
100
117
|
*/
|
|
101
118
|
span?: MPResponsive<MPGridSpan>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";import{classMap as n,responsiveSlots as r,withBaseline as s}from"../../internal/responsive.js";import{WINDOW_CLASSES as a}from"../../internal/window-class.js";function o(e){return String(Math.max(1,Math.round(e)))}function c(e){return String(Math.max(1,Math.round(e)))}function i(e){const t=n(e),r=Object.values(t).some(e=>"grow"===e),
|
|
2
|
+
import*as e from"react";import{useRender as t}from"@base-ui/react/use-render";import{classMap as n,responsiveSlots as r,withBaseline as s}from"../../internal/responsive.js";import{WINDOW_CLASSES as a}from"../../internal/window-class.js";function o(e){return String(Math.max(1,Math.round(e)))}function c(e){return String(Math.max(1,Math.round(e)))}function i(e){const t=n(e),r=Object.values(t),s=r.some(e=>"grow"===e),o=r.some(e=>"auto"===e),i={};for(const e of a){const n=t[e];void 0!==n&&("grow"!==n&&"auto"!==n&&(i[`--_mp-span-${e}`]=c(n)),s&&(i[`--_mp-grow-${e}`]="grow"===n?"1":"0"),o&&(i[`--_mp-width-${e}`]="auto"===n?"auto":"var(--_mp-span-width)"))}return i}function l(e){return String(Math.max(0,Math.round(e)))}function f(e){const t=.25*Math.max(0,e);return`${Number(t.toFixed(5))}rem`}const p={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between","space-around":"justify-around","space-evenly":"justify-evenly"},u={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch",baseline:"items-baseline"},m={start:"content-start",center:"content-center",end:"content-end","space-between":"content-between","space-around":"content-around","space-evenly":"content-evenly",stretch:"content-stretch"},d={auto:"self-auto",start:"self-start",center:"self-center",end:"self-end",stretch:"self-stretch",baseline:"self-baseline"};export const MPGrid=/*@__PURE__*/e.forwardRef(function({columns:e,spacing:n,rowSpacing:a,columnSpacing:c,justifyContent:i,alignItems:l,alignContent:d,wrap:g=!0,render:h,className:w,style:y,children:x,...j},b){return t({render:h,ref:b,props:{className:["mp-grid flex",g?"flex-wrap":"flex-nowrap","gap-x-(--_mp-gap-x) gap-y-(--_mp-gap-y)",i?p[i]:"",l?u[l]:"",d?m[d]:"",w??""].filter(Boolean).join(" "),style:{...r("cols",s(e,12),o),...r("gap-x",s(c??n,4),f),...r("gap-y",s(a??n,4),f),...y},children:x,...j}})});export const MPGridItem=/*@__PURE__*/e.forwardRef(function({span:e,offset:n,alignSelf:s,render:a,className:o,style:c,children:f,...p},u){return t({render:a,ref:u,props:{className:["mp-grid-item",s?d[s]:"",o??""].filter(Boolean).join(" "),"data-mp-offset":null==n?void 0:"",style:{...i(e),...r("offset",n,l),...c},children:f,...p}})});
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ChartBaseProps } from '../../internal/ChartChrome.js';
|
|
3
3
|
import type { MPChartAxis, MPChartCategory, MPChartSeries } from '../../types.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* No `labelColor`: every piece of text this chart writes sits **on** a ramp
|
|
6
|
+
* step, where the question is what reads against the fill underneath. There are
|
|
7
|
+
* no series here for an ink to name, either.
|
|
8
|
+
*/
|
|
9
|
+
export interface MPHeatmapChartProps extends Omit<ChartBaseProps, 'labelColor'> {
|
|
5
10
|
/**
|
|
6
11
|
* The rows. Each series is one row and its `data` are that row's cells, in
|
|
7
12
|
* the order `categories` names the columns.
|
|
@@ -9,9 +14,13 @@ export interface MPHeatmapChartProps extends ChartBaseProps {
|
|
|
9
14
|
series: readonly MPChartSeries[];
|
|
10
15
|
/** The column headings. */
|
|
11
16
|
categories?: readonly MPChartCategory[];
|
|
12
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* The column axis. Only `label`, `hidden`, `thickness`, `tickFormat` and
|
|
19
|
+
* `tickLabels` mean anything here — there is no scale to pin and no grid to
|
|
20
|
+
* cast when both axes are categorical.
|
|
21
|
+
*/
|
|
13
22
|
xAxis?: MPChartAxis;
|
|
14
|
-
/** The row axis,
|
|
23
|
+
/** The row axis, minus `tickLabels`: a row already has a line of its own. */
|
|
15
24
|
yAxis?: MPChartAxis;
|
|
16
25
|
/**
|
|
17
26
|
* Where the colour scale starts and ends. Taken from the data otherwise.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as l from"react";import{useMPElementSize as a}from"../../hooks/useMPElementSize.js";import{useMPLocale as n,useMPMessages as r}from"../../internal/locale.js";import{useMPSize as o}from"../../internal/config.js";import{CHART as i}from"../../internal/messages/chart.js";import{TABLE as m}from"../../internal/messages/table.js";import{ChartShell as s,ChartTable as c,ChartTooltipPanel as h}from"../../internal/ChartChrome.js";import{CHART_FONT_SIZE as u,MARK_GAP as d,PLOT_HEIGHT as f,RAMP_STEPS as p,formatCategory as x,formatStatistic as g,rampFill as v,rampInk as y,rampStep as w,textWidth as M,tickTurn as b,toValues as k,truncate as j,turnedBand as A,turnedRoom as $}from"../../internal/chart.js";export function MPHeatmapChart({series:N,categories:B,xAxis:S,yAxis:_,min:z,max:P,valueLabels:C=!1,height:D,format:L,locale:R,label:I,legend:E,tooltip:F,empty:W,size:H,className:K,style:U,...X}){const Y=o(H),q=n(R),G=r(i,q),J=r(m,q),O=l.useRef(null),Q=a(O),T=l.useId(),[V,Z]=l.useState(null),ee=l.useMemo(()=>k(N),[N]),te=ee.reduce((e,t)=>Math.max(e,t.length),0),le=l.useCallback(e=>g(e,q,L,!0),[L,q]),ae=N.map((e,t)=>e.name??String(t+1)),ne=Array.from({length:te},(e,t)=>S?.tickFormat?String(S.tickFormat(B?.[t]??t,t)):x(B?.[t]??t,q)),re=ee.flat().filter(e=>null!==e.value),oe=z??(re.length>0?Math.min(...re.map(e=>e.value)):0),ie=P??(re.length>0?Math.max(...re.map(e=>e.value)):0),me=ie-oe||1,se=u[Y],ce=Q.width,he="number"==typeof D?D:void 0===D?f[Y]:Q.height,ue=ae.reduce((e,t)=>Math.max(e,M(t,se)),0),de=_?.hidden?0:_?.thickness??Math.min(140,ue+10),fe=Math.max(0,ce-de),pe=te>0?fe/te:0,xe=S?.hidden?0:b(S?.tickLabels??"auto",ne,se,pe),ge=Math.min(120,.5*he),ve=ne.map((e,t)=>j(e,xe>0?Math.min($(xe,ge,se),xe>=90?1/0:(de+pe*(t+.5))/Math.cos(xe*Math.PI/180)):pe-2,se)),ye=ve.reduce((e,t)=>Math.max(e,M(t,se)),0),we=S?.hidden?0:S?.thickness??(xe>0?8+A(xe,ye,se)+4:se+12),Me=de,be=0,ke=Math.max(0,he-we),je=ee.length>0?ke/ee.length:0,Ae=(e,t)=>{Z(l=>{const a=l??{row:0,column:0};return{row:Math.min(ee.length-1,Math.max(0,a.row+(l?e:0))),column:Math.min(te-1,Math.max(0,a.column+(l?t:0)))}})},$e=V?ee[V.row]?.[V.column]??null:null,Ne=V&&$e&&null!==$e.value?[{seriesIndex:V.row,name:ae[V.row],color:v(w(($e.value-oe)/me)),value:$e.value,formatted:le($e.value),label:$e.label}]:[],Be=!1===F?{mode:"none"}:!0===F||void 0===F?{}:F,Se=!1!==E&&re.length>0,_e=0===te||0===ee.length||0===re.length,ze=Array.from({length:te},(e,t)=>ee.map(e=>e[t]??{value:null}));return e(s,{...X,size:Y,className:["mp-heatmap-chart",K??""].filter(Boolean).join(" "),style:U,plotRef:O,name:I??G.label,describedBy:_e?void 0:T,interactive:!_e,height:D,legendSide:"bottom",plotProps:{onPointerMove:_e||"none"===Be.mode?void 0:e=>Z(((e,t)=>{const l=O.current;if(!l||pe<=0||je<=0)return null;const a=l.getBoundingClientRect(),n=Math.floor((e-a.left-Me)/pe),r=Math.floor((t-a.top-be)/je);return n<0||n>=te||r<0||r>=ee.length?null:{row:r,column:n}})(e.clientX,e.clientY)),onPointerLeave:()=>Z(null),onKeyDown:_e||"none"===Be.mode?void 0:e=>{if("ArrowRight"===e.key)Ae(0,1);else if("ArrowLeft"===e.key)Ae(0,-1);else if("ArrowDown"===e.key)Ae(1,0);else if("ArrowUp"===e.key)Ae(-1,0);else{if("Escape"!==e.key)return;Z(null)}e.preventDefault()},onBlur:()=>Z(null)},tooltip:V&&Ne.length>0&&"none"!==Be.mode?e(h,{heading:`${ae[V.row]} · ${ne[V.column]}`,items:Ne,x:Me+(V.column+.5)*pe,y:be+(V.row+.5)*je,flip:V.column>te/2,size:Y}):null,legend:Se?t("div",{className:"mp-chart__legend flex items-center justify-center gap-2",children:[e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:le(oe)}),e("span",{className:"flex","aria-hidden":"true",children:Array.from({length:p},(t,l)=>e("span",{className:"block h-3 w-6 first:rounded-s-mp-xs last:rounded-e-mp-xs",style:{background:v(l)}},l))}),e("span",{className:"text-mp-on-surface-variant text-mp-label-small tabular-nums",children:le(ie)})]}):null,status:{heading:V?`${ae[V.row]} · ${ne[V.column]}`:void 0,items:Ne},table:_e?null:e(c,{id:T,caption:I??G.table,corner:_?.label??G.category,categories:ae,names:ne,values:ze,format:le,locale:q,empty:J.empty}),children:_e?e("div",{className:"text-mp-on-surface-variant text-mp-body-small flex h-full items-center justify-center",children:W??J.empty}):ce>0&&he>0?t("svg",{width:ce,height:he,viewBox:`0 0 ${ce} ${he}`,"aria-hidden":"true",className:"block overflow-visible",children:[e("g",{className:"mp-heatmap-chart__cells",children:ee.map((l,a)=>Array.from({length:te},(n,r)=>{const o=l[r],i=V?.row===a&&V?.column===r,m=Me+r*pe,s=be+a*je,c=Math.max(0,pe-d),h=Math.max(0,je-d);if(!o||null===o.value)return e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:"none",stroke:"var(--_mp-color-outline-variant)",strokeWidth:1,strokeDasharray:"2 2",rx:2},r);const u=w((o.value-oe)/me);return t("g",{children:[e("rect",{x:m+d/2,y:s+d/2,width:c,height:h,fill:o.color??v(u),rx:2,stroke:i?"var(--_mp-color-on-surface)":"none",strokeWidth:i?2:0}),C&&c>M(le(o.value),se)+8&&h>se+4?e("text",{x:m+pe/2,y:s+je/2,textAnchor:"middle",dominantBaseline:"central",fill:y(u),fontSize:se,children:le(o.value)}):null]},r)}))}),_?.hidden?null:ae.map((t,l)=>e("text",{x:Me-8,y:be+(l+.5)*je,textAnchor:"end",dominantBaseline:"central",fill:"var(--_mp-color-on-surface-variant)",fontSize:se,children:j(t,de-10,se)},`r${l}`)),S?.hidden?null:ve.map((t,l)=>{const a=Me+(l+.5)*pe,n=be+ke;return e("text",{x:a,y:xe>0?n+8:n+se+4,textAnchor:xe>0?"end":"middle",dominantBaseline:xe>0?"central":void 0,transform:xe>0?`rotate(${-xe} ${a} ${n+8})`:void 0,fill:"var(--_mp-color-on-surface-variant)",fontSize:se,children:t},`c${l}`)})]}):null})}
|
|
@@ -68,6 +68,7 @@ export interface MPHoverCardProps extends Omit<React.ComponentPropsWithoutRef<'d
|
|
|
68
68
|
/** Takes room out of that padding, two pixels a face per step. @default 0 */
|
|
69
69
|
density?: MPDensity;
|
|
70
70
|
}
|
|
71
|
+
/** The wedge, at roughly a third of the sheet's corner per step. */
|
|
71
72
|
/**
|
|
72
73
|
* A card that opens when the pointer rests on something, holding a preview of
|
|
73
74
|
* what is on the other side of it.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{POPUP_ARROW_SIZE as a,POPUP_ARROW_TURN as l,PopupArrow as n}from"../../internal/PopupArrow.js";import{PreviewCard as o}from"@base-ui/react/preview-card";import{cssLength as s}from"../../internal/length.js";import{sheetPad as t}from"../../internal/density.js";import{hasContent as d,META_TEXT as m,PROSE_TEXT as c,SHEET_GAP as p,SHEET_TITLE as f}from"../../internal/scale.js";import{FADE as u,PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPDensity as h,useMPSize as v}from"../../internal/config.js";const g={xs:"max-w-64",sm:"max-w-72",md:"max-w-96",lg:"max-w-md",xl:"max-w-xl"};export function MPHoverCard({trigger:w,title:j,description:y,children:b,side:N="bottom",align:O="center",sideOffset:P=8,alignOffset:_=0,arrow:$=!1,open:z,defaultOpen:C,onOpenChange:A,delay:D,closeDelay:B,width:H,size:I,density:M,className:R,style:T,...W}){const k=v(I),q=h(M),E=d(j)||d(y),F=a[k],G=i.useId(),J=`${G}-title`,K=`${G}-description`;return r(o.Root,{open:z,defaultOpen:C,onOpenChange:e=>A?.(e),children:[e(o.Trigger,{render:w,delay:D,closeDelay:B}),e(o.Portal,{children:e(o.Positioner,{className:x,side:N,align:O,sideOffset:P,alignOffset:_,children:r(o.Popup,{"data-mp-size":k,"aria-labelledby":d(j)?J:void 0,"aria-describedby":d(y)?K:void 0,className:["mp-hover-card rounded-mp-md relative flex flex-col outline-none","bg-mp-surface-container text-mp-on-surface shadow-mp-2","box-border",t(k,q),p[k],c[k],void 0===H?g[k]:"",u,R??""].filter(Boolean).join(" "),style:{...void 0===H?null:{maxWidth:s(H)},...T},...W,children:[$?e(o.Arrow,{className:l,children:e(n,{size:F,fill:"var(--_mp-color-surface-container)"})}):null,E?r("div",{className:"flex min-w-0 flex-col",children:[d(j)?e("div",{id:J,className:`mp-hover-card__title m-0 ${f[k]}`,children:j}):null,d(y)?e("div",{id:K,className:`mp-hover-card__description text-mp-on-surface-variant m-0 ${m}`,children:y}):null]}):null,d(b)?e("div",{className:"min-w-0",children:b}):null]})})})]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as i from"react";function o(e){return!i.isValidElement(e)}export const MPIcon=/*@__PURE__*/i.forwardRef(function({icon:r,size:t,color:
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as i from"react";function o(e){return!i.isValidElement(e)}export const MPIcon=/*@__PURE__*/i.forwardRef(function({icon:r,size:t,color:n,strokeWidth:l,center:s=!1,label:c,className:a,style:d,...m},f){const h=["mp-icon inline-flex shrink-0 items-center justify-center align-middle","[&>svg]:shrink-0 [&>img]:shrink-0",void 0===t?"":"[&>svg]:block [&>svg]:size-full [&>img]:block [&>img]:size-full",s?"justify-self-center":"",a??""].filter(Boolean).join(" ");return e("span",{ref:f,className:h,style:{...void 0===t?{}:{width:t,height:t,fontSize:t},...void 0===n?{}:{color:n},...d},role:c?"img":void 0,"aria-label":c,"aria-hidden":!c||void 0,...m,children:o(r)?i.createElement(r,{size:t,color:void 0===n?"currentColor":n,strokeWidth:l}):r})});
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MPSize } from '../../types.js';
|
|
3
|
-
/** How the picture is fitted into the box it was given. CSS's own
|
|
4
|
-
export type MPImageFit = 'cover' | 'contain' | 'fill' | 'none';
|
|
3
|
+
/** How the picture is fitted into the box it was given. CSS's own words. */
|
|
4
|
+
export type MPImageFit = 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
5
5
|
/** What the picture is doing right now. */
|
|
6
6
|
export type MPImageState = 'loading' | 'loaded' | 'error';
|
|
7
|
+
/** A picture that stands in while the real one arrives. */
|
|
8
|
+
export interface MPImagePlaceholder {
|
|
9
|
+
/**
|
|
10
|
+
* A URL, a data URI, or a `Blob` such as a file the reader has just picked.
|
|
11
|
+
*
|
|
12
|
+
* A `Blob` is drawn through an object URL made for it, so keep the same Blob
|
|
13
|
+
* from one render to the next: a new one on every render makes a new URL on
|
|
14
|
+
* every render, and each of those renders again.
|
|
15
|
+
*/
|
|
16
|
+
src: string | Blob;
|
|
17
|
+
/**
|
|
18
|
+
* Blurs the stand-in. `true` is a 20px radius, and a number is a radius in
|
|
19
|
+
* pixels.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
blur?: boolean | number;
|
|
23
|
+
}
|
|
24
|
+
/** A turn in degrees, clockwise, a quarter at a time. */
|
|
25
|
+
export type MPImageRotate = 0 | 90 | 180 | 270;
|
|
26
|
+
/** Which way the picture is mirrored, along the axes it is shown on. */
|
|
27
|
+
export type MPImageFlip = 'none' | 'horizontal' | 'vertical' | 'both';
|
|
28
|
+
/**
|
|
29
|
+
* The part of the picture a crop keeps, in `object-position`'s words: the
|
|
30
|
+
* centre, a side, a corner, or two percentages across and down.
|
|
31
|
+
*/
|
|
32
|
+
export type MPImagePosition = 'center' | 'top' | 'right' | 'bottom' | 'left' | 'top left' | 'top right' | 'bottom left' | 'bottom right' | `${number}% ${number}%`;
|
|
7
33
|
export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>, 'onError'> {
|
|
8
34
|
/** Where the picture is. */
|
|
9
35
|
src?: string;
|
|
@@ -26,18 +52,44 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
|
|
|
26
52
|
*/
|
|
27
53
|
ratio?: number | string;
|
|
28
54
|
/**
|
|
29
|
-
* How the picture is fitted into that box.
|
|
55
|
+
* How the picture is fitted into that box. `scale-down` is `contain` that
|
|
56
|
+
* never enlarges a file smaller than the box.
|
|
30
57
|
* @default 'cover'
|
|
31
58
|
*/
|
|
32
59
|
fit?: MPImageFit;
|
|
60
|
+
/**
|
|
61
|
+
* The width of the file, or of the box when it is given without `height`.
|
|
62
|
+
*
|
|
63
|
+
* With `height` as well, the two are the file's size in pixels, as on an
|
|
64
|
+
* `<img>`, and they reserve its proportion. Alone, it makes the box that wide,
|
|
65
|
+
* no wider than its container, and as tall as the picture or `ratio` makes
|
|
66
|
+
* it. A number or a string of digits is pixels, and any other string is a CSS
|
|
67
|
+
* length.
|
|
68
|
+
*/
|
|
69
|
+
width?: number | string;
|
|
70
|
+
/**
|
|
71
|
+
* The height of the file, or of the box when it is given without `width`.
|
|
72
|
+
*
|
|
73
|
+
* With `width` as well, the two are the file's size in pixels. Alone, it makes
|
|
74
|
+
* the box that tall and as wide as its container, or as wide as `ratio` makes
|
|
75
|
+
* it when there is one. A number or a string of digits is pixels, and any
|
|
76
|
+
* other string is a CSS length.
|
|
77
|
+
*/
|
|
78
|
+
height?: number | string;
|
|
33
79
|
/**
|
|
34
80
|
* Drawn while the picture is on its way.
|
|
35
81
|
*
|
|
36
82
|
* A shimmer by default, on the surface the box sits on. `false` draws nothing,
|
|
37
83
|
* which is what a picture inside something that already has its own loading
|
|
38
84
|
* treatment wants.
|
|
85
|
+
*
|
|
86
|
+
* `{ src, blur }` draws a picture instead: a small copy of the file, a data
|
|
87
|
+
* URI or a `Blob`, fitted, placed, turned and mirrored like the picture, and
|
|
88
|
+
* blurred if `blur` says so. It gives way once the picture has faded in over
|
|
89
|
+
* it. Like the shimmer, it fills the box, so the box needs a reserved size: a
|
|
90
|
+
* `ratio`, or both `width` and `height`.
|
|
39
91
|
*/
|
|
40
|
-
placeholder?: React.ReactNode | false;
|
|
92
|
+
placeholder?: React.ReactNode | false | MPImagePlaceholder;
|
|
41
93
|
/**
|
|
42
94
|
* Drawn instead of the picture when it does not arrive.
|
|
43
95
|
*
|
|
@@ -75,6 +127,62 @@ export interface MPImageProps extends Omit<React.ComponentPropsWithoutRef<'img'>
|
|
|
75
127
|
* arrives either way.
|
|
76
128
|
*/
|
|
77
129
|
onStateChange?: (state: MPImageState) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Turns the picture clockwise, in quarter turns.
|
|
132
|
+
*
|
|
133
|
+
* Only quarters, because a picture turned by any other angle stops covering
|
|
134
|
+
* its box, and filling the corners would mean enlarging it by an amount the
|
|
135
|
+
* caller would then want to tune. A quarter turn swaps the box's proportion:
|
|
136
|
+
* `width` and `height`, when both are given, are read as the file's size and
|
|
137
|
+
* reserve the turned shape, and without them the shape is read from the file
|
|
138
|
+
* once it arrives. An explicit `ratio` is the layout's shape and is kept.
|
|
139
|
+
*
|
|
140
|
+
* Drawn with the `rotate` property rather than `transform`, so a `transform`
|
|
141
|
+
* of your own, such as a hover zoom, still applies on top.
|
|
142
|
+
* @default 0
|
|
143
|
+
*/
|
|
144
|
+
rotate?: MPImageRotate;
|
|
145
|
+
/**
|
|
146
|
+
* Mirrors the picture along the axes it is shown on.
|
|
147
|
+
*
|
|
148
|
+
* `horizontal` swaps left and right on the screen whether or not the picture
|
|
149
|
+
* is turned. Drawn with the `scale` property, so it leaves `transform` free as
|
|
150
|
+
* `rotate` does, and `preview` opens the picture mirrored.
|
|
151
|
+
* @default 'none'
|
|
152
|
+
*/
|
|
153
|
+
flip?: MPImageFlip;
|
|
154
|
+
/**
|
|
155
|
+
* Which part of the picture a `cover` crop keeps, and where `contain`, `none`
|
|
156
|
+
* and `scale-down` leave their empty space.
|
|
157
|
+
*
|
|
158
|
+
* Read on the picture as it is shown, so `top` keeps the top of a picture
|
|
159
|
+
* that has been turned or mirrored. Physical rather than logical: the subject
|
|
160
|
+
* of a photograph does not move to the other side on a right-to-left page. A
|
|
161
|
+
* value in any other form reaches `object-position` as written.
|
|
162
|
+
* @default 'center'
|
|
163
|
+
*/
|
|
164
|
+
position?: MPImagePosition;
|
|
165
|
+
/**
|
|
166
|
+
* What fills the room `fit` leaves around the picture.
|
|
167
|
+
*
|
|
168
|
+
* `blur` draws the same picture behind itself, covering the box and blurred,
|
|
169
|
+
* the way a video player fills the sides of a portrait clip. It reuses the
|
|
170
|
+
* picture's request, and it is drawn only for a `fit` that can leave room:
|
|
171
|
+
* `contain`, `none` and `scale-down`. Any other string is a CSS `background`
|
|
172
|
+
* painted behind the picture: a colour, a custom property or a gradient.
|
|
173
|
+
* @default 'none'
|
|
174
|
+
*/
|
|
175
|
+
letterbox?: 'none' | 'blur' | (string & {});
|
|
176
|
+
/**
|
|
177
|
+
* Loads this picture first: the one a page is judged by, which is usually its
|
|
178
|
+
* Largest Contentful Paint.
|
|
179
|
+
*
|
|
180
|
+
* Sets `loading="eager"` and a high fetch priority. A `loading` or
|
|
181
|
+
* `fetchPriority` of your own still wins. Give it to one picture per page: a
|
|
182
|
+
* high priority on every picture raises none of them above the others.
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
priority?: boolean;
|
|
78
186
|
/** The corner and type scale of the placeholder and the fallback. @default 'md' */
|
|
79
187
|
size?: MPSize;
|
|
80
188
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as i}from"react/jsx-runtime";import*as o from"react";import{Dialog as n}from"@base-ui/react/dialog";import{MPIcon as r}from"../icon/MPIcon.js";import{BrokenImageIcon as a}from"../../constants/icons.js";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{COMMON as c}from"../../internal/messages/common.js";import{FADE as d,PORTAL_LAYER as u,SCRIM as h}from"../../internal/surface.js";import{useMPSize as m}from"../../internal/config.js";const f={cover:"object-cover",contain:"object-contain",fill:"object-fill",none:"object-none","scale-down":"object-scale-down"},p={position:"absolute",top:"50%",left:"50%",width:"100cqh",height:"100cqw",maxWidth:"none",translate:"-50% -50%"},g=Number.parseInt(o.version,10),b=!Number.isFinite(g)||0===g||g>=19?"fetchPriority":"fetchpriority",v={loading:"eager",[b]:"high"};function y(e,t){const i=2*e+"px";return t?{...p,width:`calc(100cqh + ${i})`,height:`calc(100cqw + ${i})`}:{position:"absolute",top:-e,left:-e,width:`calc(100% + ${i})`,height:`calc(100% + ${i})`,maxWidth:"none"}}const w=new Map([["left",[0,0]],["right",[0,1]],["top",[1,0]],["bottom",[1,1]]]);function j(e,t,i){const o=e.trim().split(/\s+/),n=[.5,.5],r=[!1,!1];if(o.length>2)return e;for(const[t,i]of o.entries()){if("center"===i)continue;const o=w.get(i),a=/^(-?\d*\.?\d+)%$/.exec(i),l=o?o[0]:t,s=o?o[1]:a?Number(a[1])/100:void 0;if(void 0===s||r[l])return e;n[l]=s,r[l]=!0}let[a,l]=n;"horizontal"!==i&&"both"!==i||(a=1-a),"vertical"!==i&&"both"!==i||(l=1-l);for(let e=0;e<t/90;e++)[a,l]=[l,1-a];const s=e=>Math.round(1e4*e)/100+"%";return`${s(a)} ${s(l)}`}function $(e){return"number"==typeof e?Number.isFinite(e)?e:void 0:void 0!==e&&/^\d+$/.test(e.trim())?Number(e):void 0}function x(e){const t=$(e);return void 0===t?String(e):`${t}px`}function N(e,t,i){const o=e??t,n=e??(i?t:void 0);if(!o)return{aspectRatio:"1",width:"min(100%, 100cqh)",containerType:"size"};const r=o.height,a=o.width;return{aspectRatio:`${r} / ${a}`,width:`min(100%, ${n?`${n.height}px, `:""}calc(100cqh * ${r} / ${a}))`,containerType:"size"}}function z(e){return e.naturalWidth>0&&e.naturalHeight>0?{width:e.naturalWidth,height:e.naturalHeight}:void 0}export const MPImage=/*@__PURE__*/o.forwardRef(function({src:g,alt:w,ratio:R,fit:k="cover",placeholder:L,fallback:P,preview:S=!1,previewSrc:T,previewLabel:W,onStateChange:q,rotate:M,flip:F="none",position:B="center",letterbox:E="none",priority:O=!1,size:U,className:I,style:C,width:H,height:V,onLoad:A,...D},G){const J=m(U),K=l(),Q=s(c,K),X="object"==typeof(Y=L)&&null!==Y&&!o.isValidElement(Y)&&"src"in Y?L:void 0;var Y;const Z=function(e){const[t,i]=o.useState();return o.useEffect(()=>{if(void 0===e||"string"==typeof e)return;const t=URL.createObjectURL(e);return i({blob:e,url:t}),()=>URL.revokeObjectURL(t)},[e]),void 0===e||"string"==typeof e?e:t?.blob===e?t.url:void 0}(X?.src),[_,ee]=o.useState({state:g?"loading":"error"}),[te,ie]=o.useState(),oe=o.useRef(null),{state:ne,natural:re}=_,ae=o.useCallback((e,t)=>{const i="loaded"===e&&t?z(t):void 0;ee(t=>t.state===e&&t.natural?.width===i?.width&&t.natural?.height===i?.height?t:(t.state!==e&&q?.(e),{state:e,natural:i}))},[q]),[le,se]=o.useState(g);g!==le&&(se(g),ee({state:g?"loading":"error"})),o.useEffect(()=>{const e=oe.current;e&&g&&e.complete&&ae(e.naturalWidth>0?"loaded":"error",e)},[g,ae]);const ce=function(e){return void 0!==e&&Number.isFinite(e)?(Math.round(e/90)%4+4)%4*90:0}(M),de=90===ce||270===ce,ue=function(e,t){const i="horizontal"===t||"both"===t,o="vertical"===t||"both"===t,[n,r]=90===e||270===e?[o,i]:[i,o];return{...e?{rotate:`${e}deg`}:null,...n||r?{scale:`${n?-1:1} ${r?-1:1}`}:null}}(ce,F),he="center"===B?{}:{objectPosition:j(B,ce,F)},me=void 0!==H&&void 0!==V,fe=void 0===H||me?void 0:x(H),pe=void 0===V||me?void 0:x(V),ge=me?$(H):void 0,be=me?$(V):void 0,ve=(ge&&be?{width:ge,height:be}:void 0)??re,ye=de&&void 0===R&&ve&&void 0===pe?`${ve.height} / ${ve.width}`:R,we="loaded"===ne,je=e("div",{className:["bg-mp-surface-container text-mp-on-surface-variant","flex size-full items-center justify-center"].join(" "),children:e(r,{icon:a,size:24})}),$e=e("div",{className:["bg-mp-surface-container-high size-full","motion-safe:animate-pulse motion-reduce:animate-none"].join(" ")}),xe=/*@__PURE__*/[we?"opacity-100":"opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)"].join(" "),Ne=D.loading??(O?"eager":void 0),ze=D.fetchPriority??(O?"high":void 0),Re="blur"===E&&("contain"===k||"none"===k||"scale-down"===k),ke="none"!==E&&"blur"!==E?E:void 0,Le=Boolean(Z)&&"error"!==ne,Pe=!0===X?.blur?20:"number"==typeof X?.blur&&Number.isFinite(X.blur)?Math.max(0,X.blur):0,Se=i(t,{children:[Re?e("img",{...ze?{[b]:ze}:null,src:g,srcSet:D.srcSet,sizes:D.sizes,loading:Ne,decoding:D.decoding,crossOrigin:D.crossOrigin,referrerPolicy:D.referrerPolicy,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none object-cover ${xe}`,style:{...ue,...he,filter:"blur(24px)",...y(48,de)}}):null,Le?e("img",{src:Z,alt:"","aria-hidden":"true",draggable:!1,className:`pointer-events-none select-none ${f[k]}`,style:{...ue,...he,...Pe?{filter:`blur(${Pe}px)`}:null,...y(2*Pe,de),...we?{opacity:0,transition:"opacity 0ms linear var(--mp-sys-motion-duration-short4)"}:null}}):null,e("img",{...O?v:null,...D,ref:e=>{oe.current=e,"function"==typeof G?G(e):G&&(G.current=e)},src:g,alt:w,width:me?H:void 0,height:me?V:void 0,className:`block size-full ${f[k]} ${xe}`,style:{...ue,...he,...Re||Le?{position:"relative"}:null,...de?p:null},onLoad:e=>{ae("loaded",e.currentTarget),A?.(e)},onError:()=>ae("error")}),"loading"!==ne||!1===L||X?null:e("span",{"aria-hidden":"true",className:"absolute inset-0",children:L??$e}),"error"===ne?e("span",{className:"absolute inset-0",children:P??je}):null]}),Te=["mp-image relative block overflow-hidden",I??""].filter(Boolean).join(" "),We={aspectRatio:ye,...void 0!==fe?{width:fe,maxWidth:"100%"}:null,...void 0!==pe?{height:pe}:null,...void 0!==pe&&void 0!==R?{width:"auto",maxWidth:"100%"}:null,...de?{containerType:"size"}:null,...void 0!==ke?{background:ke}:null,...C},qe=T??g,Me=te?.src===qe?te:void 0,Fe=e=>{const t=z(e.currentTarget);!t||t.width===Me?.width&&t.height===Me?.height||ie({...t,src:qe})};return S?i(n.Root,{children:[e(n.Trigger,{"data-mp-size":J,"data-mp-state":ne,disabled:"error"===ne,"aria-label":(W??w)||Q.open,className:[Te,"w-full","outline-mp-secondary cursor-zoom-in appearance-none border-0 bg-transparent p-0","focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-default","outline-none"].filter(Boolean).join(" "),style:We,children:Se}),i(n.Portal,{children:[e(n.Backdrop,{className:`${h} ${d} fixed inset-0 z-40`}),e(n.Popup,{className:[u,d,"fixed inset-0 flex items-center justify-center p-6"].join(" "),style:de?{containerType:"size"}:void 0,children:de?e("span",{className:"relative block shrink-0",style:N(Me,ve,void 0===T),children:e("img",{src:qe,alt:w,className:"object-contain",style:{...ue,...p},onLoad:Fe})}):e("img",{src:qe,alt:w,className:"max-h-full max-w-full object-contain",style:ue,onLoad:Fe})})]})]}):e("span",{"data-mp-size":J,"data-mp-state":ne,className:Te,style:We,children:Se})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MPImage } from './MPImage.js';
|
|
2
|
-
export type { MPImageProps, MPImageFit, MPImageState } from './MPImage.js';
|
|
2
|
+
export type { MPImageProps, MPImageFit, MPImageFlip, MPImagePlaceholder, MPImagePosition, MPImageRotate, MPImageState } from './MPImage.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type CartesianChartProps } from '../../internal/ChartFrame.js';
|
|
3
|
-
import type { MPChartCurve, MPChartValueLabels } from '../../types.js';
|
|
3
|
+
import type { MPChartCurve, MPChartGaps, MPChartValueLabels } from '../../types.js';
|
|
4
4
|
export interface MPLineChartProps extends CartesianChartProps {
|
|
5
5
|
/**
|
|
6
6
|
* How the line gets from one point to the next.
|
|
@@ -16,6 +16,16 @@ export interface MPLineChartProps extends CartesianChartProps {
|
|
|
16
16
|
* @default 'auto'
|
|
17
17
|
*/
|
|
18
18
|
markers?: boolean | 'auto';
|
|
19
|
+
/**
|
|
20
|
+
* What the line does where a series has no value.
|
|
21
|
+
*
|
|
22
|
+
* `break` stops and restarts, `connect` joins the two sides with a dashed
|
|
23
|
+
* run, and `zero` draws the missing reading at zero and widens the axis to
|
|
24
|
+
* hold it. The hover panel and the table still report a gap as a gap in all
|
|
25
|
+
* three.
|
|
26
|
+
* @default 'break'
|
|
27
|
+
*/
|
|
28
|
+
gaps?: MPChartGaps;
|
|
19
29
|
/**
|
|
20
30
|
* Which values are written onto the line itself.
|
|
21
31
|
* @default 'none'
|
|
@@ -55,6 +65,14 @@ export interface MPLineChartProps extends CartesianChartProps {
|
|
|
55
65
|
* nobody has, and it is the one kind of invented data a reader never questions
|
|
56
66
|
* — it looks exactly like the rest of the line.
|
|
57
67
|
*
|
|
68
|
+
* `gaps` is there for the two cases where the default is the wrong reading.
|
|
69
|
+
* `connect` joins the two sides and draws the joining run **dashed**, so the
|
|
70
|
+
* line carries on and the picture still says which part of it was measured.
|
|
71
|
+
* `zero` draws the missing reading at zero and widens the axis to hold it,
|
|
72
|
+
* which is right where a gap means "none of it happened" and wrong where it
|
|
73
|
+
* means "nobody was counting". The table behind the chart reports a gap as a
|
|
74
|
+
* gap whichever is chosen.
|
|
75
|
+
*
|
|
58
76
|
* ## The hover layer is not optional
|
|
59
77
|
*
|
|
60
78
|
* A chart in a browser is a thing a reader interrogates, so the crosshair and
|
|
@@ -63,4 +81,4 @@ export interface MPLineChartProps extends CartesianChartProps {
|
|
|
63
81
|
* gridline is answering it badly. The arrow keys walk the same columns, and a
|
|
64
82
|
* clipped live region says each one out loud.
|
|
65
83
|
*/
|
|
66
|
-
export declare function MPLineChart({ curve, markers, valueLabels, ...frame }: MPLineChartProps): React.JSX.Element;
|
|
84
|
+
export declare function MPLineChart({ curve, markers, gaps, valueLabels, ...frame }: MPLineChartProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{CartesianFrame as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{CartesianFrame as t}from"../../internal/ChartFrame.js";import{BRIDGE_DASH as l,LINE_WIDTH as n,MARKER_RADIUS as a,bridgePath as o,linePath as i}from"../../internal/chart.js";export function MPLineChart({curve:s="linear",markers:u="auto",gaps:c="break",valueLabels:m="none",...h}){return e(t,{...h,inset:!0,includeZero:"zero"===c,headroom:"none"===m?0:14,children:({plot:t,values:h,visible:d,colors:p,labelInk:f,point:x,size:v,hovered:k,activeIndex:j,format:y})=>{const b=n[v],g=a[v],L=h.reduce((e,r)=>Math.max(e,r.length),0),z=L>1?t.width/(L-1):t.width,M="auto"===u?z>=6*g:u;return e("g",{className:"mp-line-chart__marks",children:h.map((n,a)=>{if(!d[a])return null;const u=n.map((e,r)=>null===e.value?"zero"===c?x(r,0):null:x(r,e.value)),h=p[a];return r("g",{opacity:null!==k&&k!==a?.25:1,children:[e("path",{d:i(u,s),fill:"none",stroke:h,strokeWidth:b,strokeLinecap:"round",strokeLinejoin:"round"}),"connect"===c?e("path",{d:o(u),fill:"none",stroke:h,strokeWidth:b,strokeDasharray:`${b*l} ${b*l}`,strokeLinecap:"round"}):null,u.map((r,t)=>{if(!r)return null;const l=j===t;return M||l?e("circle",{cx:r.x,cy:r.y,r:l?g+1:g,fill:h,stroke:"var(--_mp-color-surface)",strokeWidth:2},t):null}),"none"===m?null:n.map((r,l)=>{const o=u[l];if(!o||null===r.value)return null;const i=n.filter(e=>null!==e.value),s=i.map(e=>e.value);if(!("all"===m||"last"===m&&r===i[i.length-1]||"extremes"===m&&(r.value===Math.min(...s)||r.value===Math.max(...s))))return null;const c=o.x>t.left+t.width-24?"end":o.x<t.left+24?"start":"middle";return e("text",{x:o.x,y:o.y-g-5,textAnchor:c,fill:f(a),fontSize:"xs"===v||"sm"===v?10:11,children:r.label??y(r.value)},l)})]},a)})})}})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r,Fragment as n}from"react/jsx-runtime";import*as t from"react";import{useRender as i}from"@base-ui/react/use-render";import{accentSlots as o}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{CONTROL_GAP as s,hasContent as a,PROSE_TEXT as d}from"../../internal/scale.js";import{sheetPadX as m}from"../../internal/density.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as u,useMPDensity as f,useMPSize as x}from"../../internal/config.js";const y=/*@__PURE__*/t.createContext({size:"md",color:"primary",density:0,dividers:!1}),h={xs:"py-1.5",sm:"py-2.5",md:"py-4",lg:"py-5",xl:"py-6"},v={xs:["py-1","py-0.5","py-0.5"],sm:["py-2","py-1.5","py-1"],md:["py-3.5","py-3","py-2.5"],lg:["py-4.5","py-4","py-3.5"],xl:["py-5.5","py-5","py-4.5"]};function b(e,r){return 0===r?h[e]:v[e][-r-1]}const j={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-medium"},g={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"};export const MPList=/*@__PURE__*/t.forwardRef(function({variant:r="outlined",elevation:n,size:l,color:s,density:a,dividers:d=!1,render:m,className:c,style:h,children:v,...b},j){const g=x(l),N=u(s),k=f(a),_=t.useMemo(()=>({size:g,color:N,density:k,dividers:d}),[g,N,k,d]),w=["mp-list rounded-mp-md flex flex-col",p(r,n),"text-mp-on-surface",d?"overflow-hidden [&>li+li]:border-mp-outline-variant [&>li+li]:border-t":"p-1",c??""].filter(Boolean).join(" "),z=i({render:m??e("ul",{}),ref:j,props:{role:"list","data-mp-size":g,"data-mp-variant":r,className:w,style:{...o(N),...h},children:v,...b}});return e(y.Provider,{value:_,children:z})});function N({render:r,props:n}){return i({render:r??(n.href?e("a",{}):e("button",{})),props:n})}export const MPListItem=/*@__PURE__*/t.forwardRef(function({startIcon:i,endIcon:o,description:p,action:u,href:f,target:x,rel:h,render:v,selected:k=!1,disabled:_=!1,className:w,children:z,onClick:B,...C},I){const{size:L,density:M,dividers:P}=t.useContext(y),R=Boolean(B||f)&&!_,F=m(L,M),S=["group relative flex min-w-0 flex-1 items-center overflow-hidden text-start","font-[inherit] no-underline",F,b(L,M),s[L],d[L],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",P?"":g[L],_?"text-mp-on-surface/38 cursor-default":k?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":"",R?["cursor-pointer appearance-none border-0",k?"":"bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].filter(Boolean).join(" "):""].filter(Boolean).join(" "),$=r(n,{children:[R?e(c,{}):null,a(i)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:i}):null,r("span",{className:"mp-list-item__text flex min-w-0 flex-1 flex-col",children:[a(z)?e("span",{className:"mp-list-item__label truncate",children:z}):null,a(p)?e("span",{className:["mp-list-item__description truncate",j[L],k?"opacity-80":"text-mp-on-surface-variant"].join(" "),children:p}):null]}),a(o)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:o}):null]});return r("li",{ref:I,"data-selected":k||void 0,className:["flex w-full items-center",w??""].filter(Boolean).join(" "),...C,children:[R&&f?e(N,{render:v,props:{href:f,target:x,rel:l(x,h),className:S,"aria-current":k?"page":void 0,onClick:B,children:$}}):R?e(N,{render:v,props:{type:v?void 0:"button",className:S,"aria-current":!!k||void 0,onClick:B,children:$}}):e("div",{className:S,"aria-disabled":_||void 0,children:$}),a(u)?e("div",{className:`flex shrink-0 items-center ${F}`,children:u}):null]})});
|
|
2
|
+
import{jsx as e,jsxs as r,Fragment as n}from"react/jsx-runtime";import*as t from"react";import{useRender as i}from"@base-ui/react/use-render";import{accentSlots as o}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{CONTROL_GAP as s,hasContent as a,PROSE_TEXT as d}from"../../internal/scale.js";import{sheetPadX as m}from"../../internal/density.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{containerSurface as p}from"../../internal/elevation.js";import{useMPColor as u,useMPDensity as f,useMPSize as x}from"../../internal/config.js";const y=/*@__PURE__*/t.createContext({size:"md",color:"primary",density:0,dividers:!1}),h={xs:"py-1.5",sm:"py-2.5",md:"py-4",lg:"py-5",xl:"py-6"},v={xs:["py-1","py-0.5","py-0.5"],sm:["py-2","py-1.5","py-1"],md:["py-3.5","py-3","py-2.5"],lg:["py-4.5","py-4","py-3.5"],xl:["py-5.5","py-5","py-4.5"]};function b(e,r){return 0===r?h[e]:v[e][-r-1]}const j={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-medium"},g={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"};export const MPList=/*@__PURE__*/t.forwardRef(function({variant:r="outlined",elevation:n,size:l,color:s,density:a,dividers:d=!1,render:m,className:c,style:h,children:v,...b},j){const g=x(l),N=u(s),k=f(a),_=t.useMemo(()=>({size:g,color:N,density:k,dividers:d}),[g,N,k,d]),w=["mp-list rounded-mp-md m-0 flex list-none flex-col",p(r,n),"text-mp-on-surface",d?"overflow-hidden p-0 [&>li+li]:border-mp-outline-variant [&>li+li]:border-t":"p-1",c??""].filter(Boolean).join(" "),z=i({render:m??e("ul",{}),ref:j,props:{role:"list","data-mp-size":g,"data-mp-variant":r,className:w,style:{...o(N),...h},children:v,...b}});return e(y.Provider,{value:_,children:z})});function N({render:r,props:n}){return i({render:r??(n.href?e("a",{}):e("button",{})),props:n})}export const MPListItem=/*@__PURE__*/t.forwardRef(function({startIcon:i,endIcon:o,description:p,action:u,href:f,target:x,rel:h,render:v,selected:k=!1,disabled:_=!1,className:w,children:z,onClick:B,...C},I){const{size:L,density:M,dividers:P}=t.useContext(y),R=Boolean(B||f)&&!_,F=m(L,M),S=["group relative flex min-w-0 flex-1 items-center overflow-hidden text-start","font-[inherit] no-underline",F,b(L,M),s[L],d[L],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",P?"":g[L],_?"text-mp-on-surface/38 cursor-default":k?"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)":"",R?["cursor-pointer appearance-none border-0",k?"":"bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].filter(Boolean).join(" "):""].filter(Boolean).join(" "),$=r(n,{children:[R?e(c,{}):null,a(i)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:i}):null,r("span",{className:"mp-list-item__text flex min-w-0 flex-1 flex-col",children:[a(z)?e("span",{className:"mp-list-item__label truncate",children:z}):null,a(p)?e("span",{className:["mp-list-item__description truncate",j[L],k?"opacity-80":"text-mp-on-surface-variant"].join(" "),children:p}):null]}),a(o)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:o}):null]});return r("li",{ref:I,"data-selected":k||void 0,className:["flex w-full items-center",w??""].filter(Boolean).join(" "),...C,children:[R&&f?e(N,{render:v,props:{href:f,target:x,rel:l(x,h),className:S,"aria-current":k?"page":void 0,onClick:B,children:$}}):R?e(N,{render:v,props:{type:v?void 0:"button",className:S,"aria-current":!!k||void 0,onClick:B,children:$}}):e("div",{className:S,"aria-disabled":_||void 0,children:$}),a(u)?e("div",{className:`flex shrink-0 items-center ${F}`,children:u}):null]})});
|
|
@@ -34,7 +34,7 @@ export interface MPMenuProps extends MPMenuSurfaceProps {
|
|
|
34
34
|
* Whether that trigger renders a real `<button>`.
|
|
35
35
|
*
|
|
36
36
|
* It nearly always does — an [MPButton](./button), an
|
|
37
|
-
* [MPIconButton](./icon-button), an [MPChip](
|
|
37
|
+
* [MPIconButton](./icon-button), an [MPChip](../display/chip) with an `onClick` — and
|
|
38
38
|
* this can be left alone. Set it `false` for a trigger that is deliberately
|
|
39
39
|
* something else: an avatar, a card, a row of text. Base UI then supplies the
|
|
40
40
|
* `role`, the tab stop and the Enter/Space handling a `<button>` would have
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Menubar as r}from"@base-ui/react/menubar";import{MPMenu as n}from"../menu/MPMenu.js";import{accentSlots as s}from"../../internal/accent.js";import{MPMenuContext as i}from"../../internal/menu.js";import{MPStateLayer as l}from"../../internal/StateLayer.js";import{CONTROL_GAP as a,hasContent as m}from"../../internal/scale.js";import{useMPColor as c,useMPSize as p}from"../../internal/config.js";const u={xs:"h-6",sm:"h-7",md:"h-8",lg:"h-10",xl:"h-12"},d={xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-4"},f={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"};export function MPMenubarMenu({label:r,startIcon:s,disabled:c=!1,children:p,className:x,style:b}){const{size:h,color:j}=o.useContext(i);return e(n,{size:h,color:j,disabled:c,openOnHover:!0,sideOffset:4,trigger:t("button",{type:"button",disabled:c,className:["mp-menubar__menu group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-xs cursor-pointer items-center justify-center bg-transparent","appearance-none font-[inherit] whitespace-nowrap select-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","disabled:text-mp-on-surface/38 disabled:cursor-default","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",u[h],d[h],f[h],a[h],x??""].filter(Boolean).join(" "),style:b,children:[c?null:e(l,{className:"group-data-popup-open:opacity-8"}),m(s)?e("span",{className:"relative flex",children:s}):null,e("span",{className:"relative",children:r})]}),children:p})}export const MPMenubar=/*@__PURE__*/o.forwardRef(function({orientation:t="horizontal",modal:n=!0,loopFocus:l=!0,disabled:m=!1,size:u,color:d,className:f,style:x,children:b,...h},j){const g=p(u),v=c(d),y=o.useMemo(()=>({size:g,color:v}),[g,v]);return e(i.Provider,{value:y,children:e(r,{ref:j,orientation:t,modal:n,loopFocus:l,disabled:m,"data-mp-size":g,"data-mp-orientation":t,className:["mp-menubar flex items-center","vertical"===t?"flex-col items-stretch":"flex-row",a[g],f??""].filter(Boolean).join(" "),style:{...s(v),...x},...h,children:b})})});
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Menubar as r}from"@base-ui/react/menubar";import{MPMenu as n}from"../menu/MPMenu.js";import{accentSlots as s}from"../../internal/accent.js";import{MPMenuContext as i}from"../../internal/menu.js";import{MPStateLayer as l}from"../../internal/StateLayer.js";import{CONTROL_GAP as a,hasContent as m}from"../../internal/scale.js";import{useMPColor as c,useMPSize as p}from"../../internal/config.js";const u={xs:"h-6",sm:"h-7",md:"h-8",lg:"h-10",xl:"h-12"},d={xs:"px-1.5",sm:"px-2",md:"px-2.5",lg:"px-3",xl:"px-4"},f={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-label-large",lg:"text-mp-title-medium",xl:"text-mp-title-medium"};export function MPMenubarMenu({label:r,startIcon:s,disabled:c=!1,children:p,className:x,style:b}){const{size:h,color:j}=o.useContext(i);return e(n,{size:h,color:j,disabled:c,openOnHover:!0,sideOffset:4,trigger:t("button",{type:"button",disabled:c,className:["mp-menubar__menu group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-xs cursor-pointer items-center justify-center bg-transparent","appearance-none border-0 font-[inherit] whitespace-nowrap select-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","disabled:text-mp-on-surface/38 disabled:cursor-default","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",u[h],d[h],f[h],a[h],x??""].filter(Boolean).join(" "),style:b,children:[c?null:e(l,{className:"group-data-popup-open:opacity-8"}),m(s)?e("span",{className:"relative flex",children:s}):null,e("span",{className:"relative",children:r})]}),children:p})}export const MPMenubar=/*@__PURE__*/o.forwardRef(function({orientation:t="horizontal",modal:n=!0,loopFocus:l=!0,disabled:m=!1,size:u,color:d,className:f,style:x,children:b,...h},j){const g=p(u),v=c(d),y=o.useMemo(()=>({size:g,color:v}),[g,v]);return e(i.Provider,{value:y,children:e(r,{ref:j,orientation:t,modal:n,loopFocus:l,disabled:m,"data-mp-size":g,"data-mp-orientation":t,className:["mp-menubar flex items-center","vertical"===t?"flex-col items-stretch":"flex-row",a[g],f??""].filter(Boolean).join(" "),style:{...s(v),...x},...h,children:b})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as a from"react";import{NavigationMenu as i}from"@base-ui/react/navigation-menu";import{MPIcon as r}from"../icon/MPIcon.js";import{ChevronDownIcon as o}from"../../constants/icons.js";import{accentSlots as s}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{CONTROL_GAP as m,CONTROL_HEIGHT as p,CONTROL_ICON as d,CONTROL_PAD_X as u,CONTROL_TEXT as f,hasContent as h,META_TEXT as g}from"../../internal/scale.js";import{PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPColor as v,useMPSize as N}from"../../internal/config.js";const y=/*@__PURE__*/a.createContext({size:"md"}),j=/*@__PURE__*/["mp-navigation-menu__popup rounded-mp-xs shadow-mp-2","bg-mp-surface-container text-mp-on-surface box-border overflow-hidden outline-none","transition-[opacity,width,height] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),b={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"};export const MPNavigationMenuLink=/*@__PURE__*/a.forwardRef(function({href:t,title:r,description:o,startIcon:s,target:p,rel:d,className:x,children:v,...N},j){const{size:b}=a.useContext(y);return n(i.Link,{ref:j,href:t,target:p,rel:l(p,d),className:["mp-navigation-menu__link group text-mp-on-surface rounded-mp-xs relative flex","min-w-0 cursor-pointer items-start bg-transparent py-2 no-underline outline-none",m[b],u[b],x??""].filter(Boolean).join(" "),...N,children:[e(c,{}),h(s)?e("span",{className:"relative flex h-[1lh] shrink-0 items-center",children:s}):null,n("span",{className:"relative flex min-w-0 flex-col gap-0.5",children:[e("span",{className:`font-medium ${f[b]}`,children:r}),h(o)?e("span",{className:`text-mp-on-surface-variant ${g}`,children:o}):null,v]})]})});export function MPNavigationMenuItem({label:s,href:g,target:x,rel:v,startIcon:N,value:j,disabled:w=!1,columns:M=1,children:P,className:_,style:z}){const{size:k}=a.useContext(y),C=void 0!==g&&!h(P),I=Number.isFinite(M)?Math.max(1,Math.round(M)):1,L=["mp-navigation-menu__item group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-full cursor-pointer items-center justify-center bg-transparent","appearance-none font-[inherit] whitespace-nowrap no-underline select-none","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default",p[k],f[k],m[k],u[k],_??""].filter(Boolean).join(" ");return e(i.Item,{value:j,children:C?n(i.Link,{href:g,target:x,rel:l(x,v),className:L,style:z,children:[e(c,{}),h(N)?e("span",{className:"relative flex",children:N}):null,e("span",{className:"relative",children:s})]}):n(t,{children:[n(i.Trigger,{disabled:w,className:L,style:z,children:[w?null:e(c,{className:"group-data-popup-open:opacity-8"}),h(N)?e("span",{className:"relative flex",children:N}):null,e("span",{className:"relative",children:s}),e(i.Icon,{className:["relative flex items-center transition-transform","duration-(--mp-sys-motion-duration-short4) ease-mp-standard","data-popup-open:rotate-180"].join(" "),children:e(r,{icon:o,size:d[k]})})]}),e(i.Content,{className:`mp-navigation-menu__panel grid gap-1 ${b[k]}`,style:I>1?{gridTemplateColumns:`repeat(${I}, minmax(0, 1fr))`}:void 0,children:P})]})})}export const MPNavigationMenu=/*@__PURE__*/a.forwardRef(function({orientation:t="horizontal",value:r,defaultValue:o,onValueChange:l,delay:c,closeDelay:p,sideOffset:d=8,size:u,color:f,className:h,style:g,children:b,...w},M){const P=N(u),_=v(f),z=a.useMemo(()=>({size:P}),[P]);return e(y.Provider,{value:z,children:n(i.Root,{ref:M,orientation:t,value:r,defaultValue:o,onValueChange:e=>l?.(e),delay:c,closeDelay:p,"data-mp-size":P,className:["mp-navigation-menu",h??""].filter(Boolean).join(" "),style:{...s(_),...g},...w,children:[e(i.List,{className:["flex items-center","vertical"===t?"flex-col items-stretch":"flex-row",m[P]].join(" "),children:b}),e(i.Portal,{children:e(i.Positioner,{className:x,sideOffset:d,collisionPadding:12,style:s(_),children:e(i.Popup,{className:j,children:e(i.Viewport,{})})})})]})})});
|
|
2
|
+
import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as a from"react";import{NavigationMenu as i}from"@base-ui/react/navigation-menu";import{MPIcon as r}from"../icon/MPIcon.js";import{ChevronDownIcon as o}from"../../constants/icons.js";import{accentSlots as s}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{CONTROL_GAP as m,CONTROL_HEIGHT as p,CONTROL_ICON as d,CONTROL_PAD_X as u,CONTROL_TEXT as f,hasContent as h,META_TEXT as g}from"../../internal/scale.js";import{PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPColor as v,useMPSize as N}from"../../internal/config.js";const y=/*@__PURE__*/a.createContext({size:"md"}),j=/*@__PURE__*/["mp-navigation-menu__popup rounded-mp-xs shadow-mp-2","bg-mp-surface-container text-mp-on-surface box-border overflow-hidden outline-none","transition-[opacity,width,height] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),b={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"};export const MPNavigationMenuLink=/*@__PURE__*/a.forwardRef(function({href:t,title:r,description:o,startIcon:s,target:p,rel:d,className:x,children:v,...N},j){const{size:b}=a.useContext(y);return n(i.Link,{ref:j,href:t,target:p,rel:l(p,d),className:["mp-navigation-menu__link group text-mp-on-surface rounded-mp-xs relative flex","min-w-0 cursor-pointer items-start bg-transparent py-2 no-underline outline-none",m[b],u[b],x??""].filter(Boolean).join(" "),...N,children:[e(c,{}),h(s)?e("span",{className:"relative flex h-[1lh] shrink-0 items-center",children:s}):null,n("span",{className:"relative flex min-w-0 flex-col gap-0.5",children:[e("span",{className:`font-medium ${f[b]}`,children:r}),h(o)?e("span",{className:`text-mp-on-surface-variant ${g}`,children:o}):null,v]})]})});export function MPNavigationMenuItem({label:s,href:g,target:x,rel:v,startIcon:N,value:j,disabled:w=!1,columns:M=1,children:P,className:_,style:z}){const{size:k}=a.useContext(y),C=void 0!==g&&!h(P),I=Number.isFinite(M)?Math.max(1,Math.round(M)):1,L=["mp-navigation-menu__item group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-full cursor-pointer items-center justify-center bg-transparent","appearance-none border-0 font-[inherit] whitespace-nowrap no-underline select-none","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default",p[k],f[k],m[k],u[k],_??""].filter(Boolean).join(" ");return e(i.Item,{value:j,children:C?n(i.Link,{href:g,target:x,rel:l(x,v),className:L,style:z,children:[e(c,{}),h(N)?e("span",{className:"relative flex",children:N}):null,e("span",{className:"relative",children:s})]}):n(t,{children:[n(i.Trigger,{disabled:w,className:L,style:z,children:[w?null:e(c,{className:"group-data-popup-open:opacity-8"}),h(N)?e("span",{className:"relative flex",children:N}):null,e("span",{className:"relative",children:s}),e(i.Icon,{className:["relative flex items-center transition-transform","duration-(--mp-sys-motion-duration-short4) ease-mp-standard","data-popup-open:rotate-180"].join(" "),children:e(r,{icon:o,size:d[k]})})]}),e(i.Content,{className:`mp-navigation-menu__panel grid gap-1 ${b[k]}`,style:I>1?{gridTemplateColumns:`repeat(${I}, minmax(0, 1fr))`}:void 0,children:P})]})})}export const MPNavigationMenu=/*@__PURE__*/a.forwardRef(function({orientation:t="horizontal",value:r,defaultValue:o,onValueChange:l,delay:c,closeDelay:p,sideOffset:d=8,size:u,color:f,className:h,style:g,children:b,...w},M){const P=N(u),_=v(f),z=a.useMemo(()=>({size:P}),[P]);return e(y.Provider,{value:z,children:n(i.Root,{ref:M,orientation:t,value:r,defaultValue:o,onValueChange:e=>l?.(e),delay:c,closeDelay:p,"data-mp-size":P,className:["mp-navigation-menu",h??""].filter(Boolean).join(" "),style:{...s(_),...g},...w,children:[e(i.List,{className:["m-0 flex list-none items-center p-0","vertical"===t?"flex-col items-stretch":"flex-row",m[P]].join(" "),children:b}),e(i.Portal,{children:e(i.Positioner,{className:x,sideOffset:d,collisionPadding:12,style:s(_),children:e(i.Popup,{className:j,children:e(i.Viewport,{})})})})]})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as l from"react";import{NumberField as
|
|
2
|
+
import{jsx as e,jsxs as n}from"react/jsx-runtime";import*as l from"react";import{NumberField as r}from"@base-ui/react/number-field";import{Field as a}from"@base-ui/react/field";import{MPIcon as t}from"../icon/MPIcon.js";import{AddIcon as i,RemoveIcon as o}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as p,useFloatingLabel as m}from"../../internal/FieldOutline.js";import{useMPLocale as d,useMPMessages as c}from"../../internal/locale.js";import{NUMBER_FIELD as u}from"../../internal/messages/number-field.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{CONTROL_ICON as x,PROSE_TEXT as g,hasContent as b}from"../../internal/scale.js";import{useMPSize as j}from"../../internal/config.js";const y={xs:{padding:"px-2",height:"h-8",stepper:"size-6"},sm:{padding:"px-3",height:"h-10",stepper:"size-8"},md:{padding:"px-4",height:"h-14",stepper:"size-10"},lg:{padding:"px-4",height:"h-16",stepper:"size-11"},xl:{padding:"px-5",height:"h-18",stepper:"size-12"}};export function MPNumberField({value:v,defaultValue:N,onValueChange:w,onValueCommitted:z,onKeyDown:C,onKeyUp:k,onFocus:S,onBlur:M,onClick:V,onDoubleClick:D,onContextMenu:F,min:I,max:q,step:B,largeStep:K,smallStep:L,allowWheelScrub:O=!1,format:P,locale:W,steppers:R="end",incrementLabel:U,decrementLabel:_,label:G,floatingLabel:T=!0,description:$,errorMessage:A,placeholder:E,startIcon:H,size:J,fullWidth:Q=!1,required:X=!1,disabled:Y=!1,readOnly:Z=!1,name:ee,id:ne,className:le,style:re}){const ae=j(J),te=c(u,d("string"==typeof W?W:void 0)),ie=b(A),oe=y[ae],se=l.useId(),pe=ne??se,me="none"!==R&&!Z&&!Y,[de,ce]=l.useState(N??null),ue=void 0===v?de:v,{shrunk:fe,focusProps:he}=m({floating:T&&b(G),filled:null!==ue,pinned:!!H||me&&"split"===R}),xe=/*@__PURE__*/["mp-number-field__stepper group relative flex shrink-0 items-center justify-center","rounded-mp-full cursor-pointer appearance-none border-0 bg-transparent p-0 font-[inherit]","text-mp-on-surface-variant outline-none","disabled:text-mp-on-surface/38 disabled:cursor-default",oe.stepper].join(" "),ge=n(r.Decrement,{"aria-label":_??te.decrease,className:xe,children:[e(f,{}),e(t,{icon:o,size:x[ae]})]}),be=n(r.Increment,{"aria-label":U??te.increase,className:xe,children:[e(f,{}),e(t,{icon:i,size:x[ae]})]});return n(a.Root,{className:["mp-number-field group flex-col align-top",Q?"flex w-full":"inline-flex w-fit",le??""].filter(Boolean).join(" "),style:re,disabled:Y,invalid:ie,"data-mp-size":ae,...he,children:[e(r.Root,{id:pe,name:ee,className:"contents",value:v,defaultValue:N,onValueChange:e=>{ce(e),w?.(e)},onValueCommitted:e=>z?.(e),min:I,max:q,step:B,largeStep:K,smallStep:L,allowWheelScrub:O,format:P,locale:W,disabled:Y,readOnly:Z,required:X,children:n("div",{className:"relative w-full",children:[n(r.Group,{className:["flex w-full items-center gap-2",oe.height,me&&"end"===R?`${oe.padding} pe-1`:me&&"split"===R?"px-1":oe.padding].join(" "),children:[me&&"split"===R?ge:null,H?e("span",{className:["flex shrink-0 items-center",Y?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:H}):null,e(r.Input,{placeholder:fe?E:void 0,onKeyDown:C,onKeyUp:k,onFocus:S,onBlur:M,onClick:V,onDoubleClick:D,onContextMenu:F,className:["w-full min-w-0 flex-1 tabular-nums",g[ae],"font-[family-name:var(--mp-sys-typescale-body-large-font)]","appearance-none border-0 bg-transparent px-0 outline-none","caret-mp-primary text-mp-on-surface","placeholder:text-mp-on-surface-variant","disabled:text-mp-on-surface/38 disabled:placeholder:text-mp-on-surface/38",me&&"split"===R?"text-center":""].filter(Boolean).join(" ")}),me&&"end"===R?n("span",{className:"flex shrink-0 items-center",children:[ge,be]}):null,me&&"split"===R?be:null]}),e(p,{label:G,required:X,notched:fe}),b(G)?e(s,{size:ae,label:G,required:X,htmlFor:pe,shrunk:fe}):null]})}),e(h,{description:$,errorMessage:A,className:oe.padding})]})}
|