material-plus-ui 1.3.1 → 1.5.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/.fix.py +92 -0
- package/README.md +2 -2
- package/dist/components/alert/MPAlert.d.ts +26 -0
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.d.ts +74 -0
- package/dist/components/avatar-group/MPAvatarGroup.js +2 -0
- package/dist/components/avatar-group/index.d.ts +2 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +10 -4
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/button-group/MPButtonGroup.d.ts +9 -0
- package/dist/components/button-group/MPButtonGroup.js +1 -1
- package/dist/components/carousel/MPCarousel.d.ts +12 -7
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.d.ts +15 -2
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/checkbox/MPCheckbox.d.ts +6 -0
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/color-picker/MPColorPicker.d.ts +20 -17
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +22 -4
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +132 -0
- package/dist/components/command-palette/MPCommandPalette.js +2 -0
- package/dist/components/command-palette/index.d.ts +2 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.d.ts +5 -0
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/fieldset/MPFieldset.d.ts +52 -0
- package/dist/components/fieldset/MPFieldset.js +2 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.js +1 -0
- package/dist/components/file-picker/MPFilePicker.d.ts +10 -3
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.d.ts +94 -0
- package/dist/components/footer/MPFooter.js +2 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/footer/index.js +1 -0
- package/dist/components/form/MPForm.d.ts +73 -0
- package/dist/components/form/MPForm.js +2 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/header/MPHeader.d.ts +122 -0
- package/dist/components/header/MPHeader.js +2 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +1 -0
- package/dist/components/highlight/MPHighlight.d.ts +7 -0
- package/dist/components/menu/MPMenu.d.ts +4 -2
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.d.ts +89 -0
- package/dist/components/menubar/MPMenubar.js +2 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +158 -0
- package/dist/components/navigation-menu/MPNavigationMenu.js +2 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +1 -0
- package/dist/components/number-field/MPNumberField.d.ts +19 -4
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +8 -2
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/page-layout/MPPageLayout.d.ts +145 -0
- package/dist/components/page-layout/MPPageLayout.js +2 -0
- package/dist/components/page-layout/index.d.ts +2 -0
- package/dist/components/page-layout/index.js +1 -0
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.d.ts +12 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.d.ts +7 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +19 -1
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +160 -0
- package/dist/components/sidebar/MPSidebar.js +2 -0
- package/dist/components/sidebar/MPSidebarTrigger.d.ts +45 -0
- package/dist/components/sidebar/MPSidebarTrigger.js +2 -0
- package/dist/components/sidebar/index.d.ts +4 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +6 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/switch/MPSwitch.d.ts +6 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +27 -5
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +21 -2
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.d.ts +7 -1
- package/dist/components/text-link/MPTextLink.js +1 -1
- package/dist/components/time-picker/MPTimePicker.d.ts +4 -0
- package/dist/components/toggle/MPToggle.d.ts +72 -0
- package/dist/components/toggle/MPToggle.js +2 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle-group/MPToggleGroup.d.ts +74 -0
- package/dist/components/toggle-group/MPToggleGroup.js +2 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/transfer/MPTransfer.d.ts +98 -0
- package/dist/components/transfer/MPTransfer.js +2 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/index.js +1 -0
- package/dist/constants/glyphs.d.ts +10 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +1 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/SupportingText.d.ts +1 -1
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +0 -17
- package/dist/internal/animate.js +1 -1
- package/dist/internal/avatar-group.d.ts +22 -0
- package/dist/internal/avatar-group.js +2 -0
- package/dist/internal/button-group.d.ts +20 -1
- package/dist/internal/button-group.js +1 -1
- package/dist/internal/color.d.ts +0 -5
- package/dist/internal/color.js +1 -1
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +201 -4
- package/dist/internal/keys.d.ts +72 -0
- package/dist/internal/keys.js +2 -0
- package/dist/internal/length.d.ts +42 -0
- package/dist/internal/length.js +1 -0
- package/dist/internal/link.d.ts +44 -0
- package/dist/internal/link.js +1 -0
- package/dist/internal/locale.d.ts +20 -1
- package/dist/internal/locale.js +1 -1
- package/dist/internal/messages/breadcrumb.d.ts +3 -0
- package/dist/internal/messages/breadcrumb.js +1 -0
- package/dist/internal/messages/carousel.d.ts +3 -0
- package/dist/internal/messages/carousel.js +1 -0
- package/dist/internal/messages/color-picker.d.ts +3 -0
- package/dist/internal/messages/color-picker.js +1 -0
- package/dist/internal/messages/combobox.d.ts +3 -0
- package/dist/internal/messages/combobox.js +1 -0
- package/dist/internal/messages/command.d.ts +3 -0
- package/dist/internal/messages/command.js +1 -0
- package/dist/internal/messages/file-picker.d.ts +3 -0
- package/dist/internal/messages/file-picker.js +1 -0
- package/dist/internal/messages/layout.d.ts +3 -0
- package/dist/internal/messages/layout.js +1 -0
- package/dist/internal/messages/number-field.d.ts +3 -0
- package/dist/internal/messages/number-field.js +1 -0
- package/dist/internal/messages/overlay.d.ts +3 -0
- package/dist/internal/messages/overlay.js +1 -0
- package/dist/internal/messages/table.d.ts +3 -0
- package/dist/internal/messages/table.js +1 -0
- package/dist/internal/messages/text-link.d.ts +3 -0
- package/dist/internal/messages/text-link.js +1 -0
- package/dist/internal/messages/transfer.d.ts +3 -0
- package/dist/internal/messages/transfer.js +1 -0
- package/dist/internal/page-layout.d.ts +182 -0
- package/dist/internal/page-layout.js +2 -0
- package/dist/internal/scale.d.ts +17 -0
- package/dist/internal/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/avatar-group.css +2 -0
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.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/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +2 -0
- 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/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/fieldset.css +2 -0
- package/dist/styles/file-picker.css +1 -1
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/footer.css +2 -0
- package/dist/styles/form.css +2 -0
- package/dist/styles/header.css +2 -0
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/locale.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +2 -0
- package/dist/styles/navigation-menu.css +2 -0
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +2 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +2 -0
- package/dist/styles/skeleton.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.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.css +1 -1
- package/dist/styles/toggle-group.css +2 -0
- package/dist/styles/toggle.css +2 -0
- package/dist/styles/transfer.css +2 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -50,6 +50,13 @@ export interface MPSegmentedButtonProps extends MPStyleProps {
|
|
|
50
50
|
disabled?: boolean;
|
|
51
51
|
/** The accessible name of the set. */
|
|
52
52
|
'aria-label'?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Added to the set rather than to a segment. A segment carries
|
|
55
|
+
* `mp-segmented-button__segment`, which is what a descendant selector reaches
|
|
56
|
+
* one by.
|
|
57
|
+
*/
|
|
58
|
+
className?: string;
|
|
59
|
+
style?: React.CSSProperties;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
62
|
* A Material Design segmented button: two to five choices in one pill.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{Toggle as n}from"@base-ui/react/toggle";import{ToggleGroup as o}from"@base-ui/react/toggle-group";import{MPIcon as a}from"../icon/MPIcon.js";import{CheckIcon as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{Toggle as n}from"@base-ui/react/toggle";import{ToggleGroup as o}from"@base-ui/react/toggle-group";import{MPIcon as a}from"../icon/MPIcon.js";import{CheckIcon as s}from"../../constants/icons.js";import{MPStateLayer as i}from"../../internal/StateLayer.js";import{CONTROL_GAP as l,CONTROL_HEIGHT as d,CONTROL_ICON as c,CONTROL_PAD_X as m,CONTROL_TEXT as u}from"../../internal/scale.js";export const MPSegmentedButton=/*@__PURE__*/r.forwardRef(function({items:r,value:p,defaultValue:f,onValueChange:b,multiple:h=!1,showCheck:g=!0,size:y="md",fullWidth:j=!1,disabled:x=!1,"aria-label":v,className:w,style:N},B){return e(o,{ref:B,"aria-label":v,value:p,defaultValue:f,onValueChange:e=>b?.(e),multiple:h,disabled:x,"data-mp-size":y,className:["mp-segmented-button rounded-mp-full box-border items-center align-middle","overflow-hidden border",x?"border-mp-on-surface/12":"border-mp-outline",j?"flex w-full":"inline-flex w-fit",d[y],w??""].filter(Boolean).join(" "),style:N,children:r.map((r,o)=>{const d=x||r.disabled;return t(n,{value:r.value,disabled:r.disabled,className:["mp-segmented-button__segment group relative flex h-full items-center","box-border justify-center bg-transparent font-[inherit] whitespace-nowrap","select-none","appearance-none overflow-hidden outline-none","transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",u[y],l[y],m[y],0===o?"":"border-s",d?"border-mp-on-surface/12 text-mp-on-surface/38 cursor-default":["border-mp-outline cursor-pointer","text-mp-on-surface","data-pressed:bg-mp-secondary-container","data-pressed:text-mp-on-secondary-container"].join(" "),j?"flex-1":""].filter(Boolean).join(" "),children:[d?null:e(i,{}),g||r.icon?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:c[y],height:c[y]},children:[g?e("span",{className:["absolute inset-0 flex items-center justify-center opacity-0","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard group-data-pressed:opacity-100"].join(" "),children:e(a,{icon:s,size:c[y]})}):null,r.icon?e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",g?"group-data-pressed:opacity-0":""].filter(Boolean).join(" "),children:r.icon}):null]}):null,e("span",{className:"truncate",children:r.label})]},`${o}:${r.value}`)})})});
|
|
@@ -23,7 +23,18 @@ export interface MPSelectProps extends MPStyleProps {
|
|
|
23
23
|
* The options, as data. There is no `<MPSelect.Option>` to compose: what a
|
|
24
24
|
* caller has is almost always an array already, and the list has to be
|
|
25
25
|
* available to the trigger before the popup has ever been opened — otherwise
|
|
26
|
-
* a closed select can only show its raw value.
|
|
26
|
+
* a closed select can only show its raw value. *
|
|
27
|
+
* ## How long a list this holds
|
|
28
|
+
*
|
|
29
|
+
* Every row is rendered, and there is no windowing. That is the right default
|
|
30
|
+
* — windowing costs a measured container, a scroll listener and a row height
|
|
31
|
+
* the component would have to decide for the caller — and it has a ceiling: a
|
|
32
|
+
* few hundred rows is nothing, a few thousand is a visible pause when the list
|
|
33
|
+
* opens, and past that the answer is a narrower list rather than a faster one.
|
|
34
|
+
*
|
|
35
|
+
* A list somebody has to scroll ten thousand rows of is a list that wanted a
|
|
36
|
+
* filter. Where it genuinely is that long, window it yourself and pass the
|
|
37
|
+
* slice.
|
|
27
38
|
*/
|
|
28
39
|
items: readonly MPSelectOption[];
|
|
29
40
|
/** The chosen value. Use with `onValueChange` for a controlled select. */
|
|
@@ -79,6 +90,13 @@ export interface MPSelectProps extends MPStyleProps {
|
|
|
79
90
|
* left out.
|
|
80
91
|
*/
|
|
81
92
|
id?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Added to the select's outermost element — the box around the trigger and its
|
|
95
|
+
* supporting line. It is not the trigger, and it is not the popup: the popup is
|
|
96
|
+
* portalled out of this element entirely.
|
|
97
|
+
*/
|
|
98
|
+
className?: string;
|
|
99
|
+
style?: React.CSSProperties;
|
|
82
100
|
}
|
|
83
101
|
/**
|
|
84
102
|
* A Material Design select.
|
|
@@ -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{Select as n}from"@base-ui/react/select";import{Field as r}from"@base-ui/react/field";import{MPIcon as i}from"../icon/MPIcon.js";import{CheckIcon as l,ChevronDownIcon as o}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as d,useFloatingLabel as c}from"../../internal/FieldOutline.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{MPSupportingText as p}from"../../internal/SupportingText.js";import{CONTROL_ICON as u,PROSE_TEXT as f,hasContent as h}from"../../internal/scale.js";import{FADE as g,PORTAL_LAYER as x}from"../../internal/surface.js";const v={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}};export const MPSelect=/*@__PURE__*/t.forwardRef(function({items:b,value:j,defaultValue:N,onValueChange:y,placeholder:w,label:I,floatingLabel:S=!0,description:k,errorMessage:z,startIcon:P,size:M="md",fullWidth:O=!1,required:V=!1,disabled:q=!1,readOnly:T=!1,name:_,id:C},
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Select as n}from"@base-ui/react/select";import{Field as r}from"@base-ui/react/field";import{MPIcon as i}from"../icon/MPIcon.js";import{CheckIcon as l,ChevronDownIcon as o}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as d,useFloatingLabel as c}from"../../internal/FieldOutline.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{MPSupportingText as p}from"../../internal/SupportingText.js";import{CONTROL_ICON as u,PROSE_TEXT as f,hasContent as h}from"../../internal/scale.js";import{FADE as g,PORTAL_LAYER as x}from"../../internal/surface.js";const v={xs:{padding:"px-2",height:"h-8"},sm:{padding:"px-3",height:"h-10"},md:{padding:"px-4",height:"h-14"},lg:{padding:"px-4",height:"h-16"},xl:{padding:"px-5",height:"h-18"}};export const MPSelect=/*@__PURE__*/t.forwardRef(function({items:b,value:j,defaultValue:N,onValueChange:y,placeholder:w,label:I,floatingLabel:S=!0,description:k,errorMessage:z,startIcon:P,size:M="md",fullWidth:O=!1,required:V=!1,disabled:q=!1,readOnly:T=!1,name:_,id:C,className:L,style:R},B){const F=h(z),W=v[M],$=t.useId(),A=C??$,[D,E]=t.useState(N??null),[G,H]=t.useState(!1),J=void 0===j?D:j,{shrunk:K,focusProps:Q}=c({floating:S&&h(I),filled:null!==J&&""!==J,pinned:G||!!P}),U=t.useMemo(()=>b.map(e=>({label:e.label??String(e.value),value:e.value})),[b]);return a(r.Root,{className:["mp-select group flex-col align-top",O?"flex w-full":"inline-flex w-fit",L??""].filter(Boolean).join(" "),style:R,disabled:q,invalid:F,"data-mp-size":M,...Q,children:[a(n.Root,{id:A,name:_,items:U,value:j,defaultValue:N,onValueChange:e=>{E(e??null),y?.(e??null)},onOpenChange:H,disabled:q,readOnly:T,required:V,children:[a("div",{className:"relative w-full",children:[a(n.Trigger,{ref:B,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",W.padding,W.height,f[M],q?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(T?"cursor-default":"cursor-pointer")].join(" "),children:[P?e("span",{className:["flex shrink-0 items-center",q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:P}):null,e(n.Value,{className:["min-w-0 flex-1 truncate text-start","data-placeholder:text-mp-on-surface-variant",q?"data-placeholder:text-mp-on-surface/38":""].filter(Boolean).join(" "),placeholder:K?w:void 0}),e(n.Icon,{className:["flex shrink-0 items-center","transition-transform duration-(--mp-sys-motion-duration-short4)","data-popup-open:rotate-180",q?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:e(i,{icon:o,size:u[M]})})]}),e(d,{label:I,required:V,notched:K}),h(I)?e(s,{size:M,label:I,required:V,htmlFor:A,shrunk:K}):null]}),e(n.Portal,{children:e(n.Positioner,{className:x,sideOffset:4,alignItemWithTrigger:!1,children:e(n.Popup,{className:["mp-select__popup rounded-mp-xs shadow-mp-2 bg-mp-surface-container p-2","text-mp-on-surface min-w-[var(--anchor-width)] outline-none",f[M],g].join(" "),children:e(n.List,{className:"max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain",children:b.map((t,r)=>a(n.Item,{value:t.value,disabled:t.disabled,className:["mp-select__item group rounded-mp-xs relative flex cursor-pointer items-center","gap-3 py-2 pe-3 ps-2 select-none outline-none","transition-[background-color,color]","duration-(--mp-sys-motion-duration-short4)","data-selected:text-mp-on-secondary-container","data-selected:bg-mp-secondary-container","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default"].join(" "),children:[e(m,{className:"group-data-highlighted:opacity-8 group-data-disabled:opacity-0"}),e("span",{className:"flex size-5 shrink-0 items-center justify-center",children:e(n.ItemIndicator,{children:e(i,{icon:l,size:18})})}),e(n.ItemText,{className:"min-w-0 flex-1 truncate",children:t.label??String(t.value)})]},`${r}:${String(t.value)}`))})})})})]}),e(p,{description:k,errorMessage:z,className:W.padding})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as n,jsxs as a}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,Fragment as n,jsxs as a}from"react/jsx-runtime";import*as m from"react";import{accentSlots as t}from"../../internal/accent.js";import{tokenizeShortcut as o,useDetectedOS as r}from"../../internal/keys.js";import{VISUALLY_HIDDEN as l}from"../../internal/visually-hidden.js";const s=e=>({symbol:e,name:e}),i={mod:{mac:{symbol:"⌘",name:"Command"},windows:s("Ctrl"),linux:s("Ctrl")},meta:{mac:{symbol:"⌘",name:"Command"},windows:s("Win"),linux:s("Super")},ctrl:{mac:{symbol:"⌃",name:"Control"},windows:s("Ctrl"),linux:s("Ctrl")},alt:{mac:{symbol:"⌥",name:"Option"},windows:s("Alt"),linux:s("Alt")},shift:{mac:{symbol:"⇧",name:"Shift"},windows:s("Shift"),linux:s("Shift")},enter:{mac:{symbol:"↩",name:"Enter"},windows:s("Enter"),linux:s("Enter")},tab:{mac:{symbol:"⇥",name:"Tab"},windows:s("Tab"),linux:s("Tab")},escape:{mac:{symbol:"⎋",name:"Escape"},windows:s("Esc"),linux:s("Esc")},backspace:{mac:{symbol:"⌫",name:"Backspace"},windows:s("Backspace"),linux:s("Backspace")},delete:{mac:{symbol:"⌦",name:"Delete"},windows:s("Del"),linux:s("Del")},capslock:{mac:{symbol:"⇪",name:"Caps Lock"},windows:s("Caps Lock"),linux:s("Caps Lock")}},c={cmdorctrl:"mod",commandorcontrol:"mod",cmd:"meta",command:"meta",super:"meta",win:"meta",windows:"meta",control:"ctrl",option:"alt",opt:"alt",return:"enter",esc:"escape",del:"delete",caps:"capslock"},d={up:{symbol:"↑",name:"Arrow up"},down:{symbol:"↓",name:"Arrow down"},left:{symbol:"←",name:"Arrow left"},right:{symbol:"→",name:"Arrow right"},arrowup:{symbol:"↑",name:"Arrow up"},arrowdown:{symbol:"↓",name:"Arrow down"},arrowleft:{symbol:"←",name:"Arrow left"},arrowright:{symbol:"→",name:"Arrow right"}};const p={xs:"h-5",sm:"h-6",md:"h-8",lg:"h-10",xl:"h-12"},u={xs:"min-w-5",sm:"min-w-6",md:"min-w-8",lg:"min-w-10",xl:"min-w-12"},w={xs:"text-mp-label-small",sm:"text-mp-label-medium",md:"text-mp-label-large",lg:"text-mp-label-large",xl:"text-mp-title-medium"},x={xs:"px-1",sm:"px-1.5",md:"px-2",lg:"px-2.5",xl:"px-3"},b={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"},f={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-mp-on-surface-variant",outlined:"border-mp-outline-variant text-mp-on-surface-variant border bg-transparent",text:"text-mp-on-surface-variant bg-mp-surface-container"};export const MPShortcut=/*@__PURE__*/m.forwardRef(function({variant:y="outlined",size:h="md",color:g="secondary",keys:k,os:C="auto",separator:v,className:A,style:j,...E},N){const S=r(),_="auto"===C?S:C,B=o(k).map(e=>function(e,n){const a=e.toLowerCase().replace(/[\s_-]/g,""),m=c[a]??a,t=d[m];if(t)return t;const o=i[m];return o?o[n]:s(1===e.length?e.toUpperCase():e)}(e,_)),L=void 0===v?"mac"===_?null:"+":v,D=/*@__PURE__*/["inline-flex shrink-0 items-center justify-center","font-mono leading-none whitespace-nowrap tabular-nums",p[h],u[h],w[h],x[h],b[h],f[y]].join(" ");return e("span",{ref:N,"data-mp-size":h,"data-mp-variant":y,className:["mp-shortcut inline-flex max-w-full items-center gap-1 align-middle",A??""].filter(Boolean).join(" "),style:{...t(g),...j},...E,children:B.map((t,o)=>a(m.Fragment,{children:[o>0&&null!==L?e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant",children:L}):null,e("kbd",{className:D,children:t.symbol===t.name?t.symbol:a(n,{children:[e("span",{"aria-hidden":"true",children:t.symbol}),e("span",{className:l,children:t.name})]})})]},o))})});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPPageCollapse, type MPSidebarSide } from '../../internal/page-layout.js';
|
|
3
|
+
import type { MPSize, MPVariant } from '../../types.js';
|
|
4
|
+
export type { MPPageCollapse, MPSidebarSide } from '../../internal/page-layout.js';
|
|
5
|
+
export interface MPSidebarProps extends Omit<React.ComponentPropsWithoutRef<'aside'>, 'title'> {
|
|
6
|
+
/**
|
|
7
|
+
* Which end of the band it takes. Logical rather than physical — `start` is
|
|
8
|
+
* the left of an English page and the right of an Arabic one — because
|
|
9
|
+
* navigation sits beside the text it belongs to in every writing direction.
|
|
10
|
+
*
|
|
11
|
+
* Inside an [MPPageLayout](./page-layout) this is already decided by which
|
|
12
|
+
* slot the sidebar was handed to, and setting it again is only a way of
|
|
13
|
+
* disagreeing with the layout.
|
|
14
|
+
* @default 'start'
|
|
15
|
+
*/
|
|
16
|
+
side?: MPSidebarSide;
|
|
17
|
+
/**
|
|
18
|
+
* How wide the column is — a number in pixels or any CSS length. Left out, it
|
|
19
|
+
* is the width `size` implies.
|
|
20
|
+
*
|
|
21
|
+
* With `resizable` this is only the width the column *starts* at: a drag
|
|
22
|
+
* writes over it, and the caller hears about it through `onResizeEnd`.
|
|
23
|
+
*/
|
|
24
|
+
width?: number | string;
|
|
25
|
+
/**
|
|
26
|
+
* How narrow it may be dragged.
|
|
27
|
+
* @default 160
|
|
28
|
+
*/
|
|
29
|
+
minWidth?: number | string;
|
|
30
|
+
/**
|
|
31
|
+
* And how wide.
|
|
32
|
+
* @default 480
|
|
33
|
+
*/
|
|
34
|
+
maxWidth?: number | string;
|
|
35
|
+
/**
|
|
36
|
+
* Lets the reader drag the inner edge to change the column's width.
|
|
37
|
+
*
|
|
38
|
+
* Off by default. A sidebar that can be resized is a sidebar whose width is
|
|
39
|
+
* the reader's to remember, so a caller who turns this on usually also wants
|
|
40
|
+
* to store what `onResizeEnd` reports.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
resizable?: boolean;
|
|
44
|
+
/** Fires with the width in pixels while the edge is being dragged. */
|
|
45
|
+
onResize?: (width: number) => void;
|
|
46
|
+
/** Fires once, with the same number, when it is let go. */
|
|
47
|
+
onResizeEnd?: (width: number) => void;
|
|
48
|
+
/**
|
|
49
|
+
* The window size class below which the column becomes a drawer, opened by an
|
|
50
|
+
* [MPSidebarTrigger](#mpsidebartrigger). `none` keeps it a column at every
|
|
51
|
+
* width.
|
|
52
|
+
*
|
|
53
|
+
* Defaults to the [MPPageLayout](./page-layout)'s own `collapseBelow`, and to
|
|
54
|
+
* `none` outside one: a sidebar that collapsed with nothing on the page able
|
|
55
|
+
* to bring it back would be a sidebar the reader has lost.
|
|
56
|
+
*/
|
|
57
|
+
collapseBelow?: MPPageCollapse;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the drawer is open. Only meaningful once the sidebar has collapsed;
|
|
60
|
+
* a column is not opened, it is there.
|
|
61
|
+
*
|
|
62
|
+
* Inside an [MPPageLayout](./page-layout) the layout owns this — it is what a
|
|
63
|
+
* trigger anywhere on the page talks to — so control it there rather than
|
|
64
|
+
* here. `onOpenChange` still fires either way.
|
|
65
|
+
*/
|
|
66
|
+
open?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Which state it starts in, for an uncontrolled standalone sidebar.
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
defaultOpen?: boolean;
|
|
72
|
+
onOpenChange?: (open: boolean) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the column holds its place while the page scrolls past it.
|
|
75
|
+
*
|
|
76
|
+
* On by default, and it costs nothing when it is not needed: with the page
|
|
77
|
+
* scrolling it becomes a `sticky` column as tall as what is left of the window
|
|
78
|
+
* under the header, and with only the content scrolling it is already as tall
|
|
79
|
+
* as the layout and this changes nothing.
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
sticky?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The heading, drawn only while the sidebar is a drawer.
|
|
85
|
+
*
|
|
86
|
+
* A column has the page around it to say what it is. A panel that has covered
|
|
87
|
+
* the page does not, and a dialog with no heading has no accessible name — so
|
|
88
|
+
* without one the drawer falls back to `label`, and then to the word for
|
|
89
|
+
* "sidebar" in `locale`.
|
|
90
|
+
*/
|
|
91
|
+
title?: React.ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* How much surface the column paints, on the **container** ladder — a sidebar
|
|
94
|
+
* is never dyed, because what sits on it arrives with colours of its own.
|
|
95
|
+
*
|
|
96
|
+
* `outlined` is the default: the page's own surface, with a hairline down the
|
|
97
|
+
* edge that faces the content. That is the column *in the layout*. Once it has
|
|
98
|
+
* collapsed it is an [MPDrawer](./drawer), which paints MD3's own navigation
|
|
99
|
+
* drawer surface and takes no weight from here.
|
|
100
|
+
* @default 'outlined'
|
|
101
|
+
*/
|
|
102
|
+
variant?: MPVariant;
|
|
103
|
+
/**
|
|
104
|
+
* The column's default width and the air around its content. `md` is 360px,
|
|
105
|
+
* which is MD3's own navigation drawer and the same rung
|
|
106
|
+
* [MPDrawer](./drawer) is drawn at.
|
|
107
|
+
* @default 'md'
|
|
108
|
+
*/
|
|
109
|
+
size?: MPSize;
|
|
110
|
+
/**
|
|
111
|
+
* The gutter, and the air above and below the content.
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
padded?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The name the region is announced by.
|
|
117
|
+
*
|
|
118
|
+
* Every `<aside>` on a page should have one, and a page with two sidebars
|
|
119
|
+
* *must*, or a screen reader offers two regions called "complementary".
|
|
120
|
+
* Defaults to the word for "sidebar" in `locale`.
|
|
121
|
+
*/
|
|
122
|
+
label?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Which language the sidebar's own words are in. Falls back to the
|
|
125
|
+
* [MPPageLayout](./page-layout)'s, then to the nearest `MPLocaleProvider`,
|
|
126
|
+
* then to English.
|
|
127
|
+
*/
|
|
128
|
+
locale?: string;
|
|
129
|
+
/** Everything in it: a nav, a filter panel, a table of contents. */
|
|
130
|
+
children?: React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A column beside the page's content, and a drawer once the window is too narrow
|
|
134
|
+
* to hold one.
|
|
135
|
+
*
|
|
136
|
+
* Two presentations of one panel, which is exactly the distinction MD3 draws:
|
|
137
|
+
* the **standard** navigation drawer is part of the layout and the content is
|
|
138
|
+
* laid out around it, and below an expanded window the same destinations arrive
|
|
139
|
+
* as a **modal** drawer over a scrim. They are one component here because they
|
|
140
|
+
* are one thing — a caller should not have to swap components at a breakpoint —
|
|
141
|
+
* and because the children exist once either way, so nothing inside is put into
|
|
142
|
+
* the document twice for a screen reader to read twice.
|
|
143
|
+
*
|
|
144
|
+
* A real `<aside>`, which is the `complementary` landmark: the region a screen
|
|
145
|
+
* reader offers as "related to the page but not the page", and what a crawler
|
|
146
|
+
* reads as navigation chrome rather than as the article.
|
|
147
|
+
*
|
|
148
|
+
* ## Which of the two is showing is answered twice, on purpose
|
|
149
|
+
*
|
|
150
|
+
* In CSS for the first paint, and in JavaScript from then on.
|
|
151
|
+
*
|
|
152
|
+
* The markup a server sends is the **column**, because a collapsed sidebar is a
|
|
153
|
+
* drawer, a modal drawer is a portal into `document.body`, and there is no body
|
|
154
|
+
* to portal into while the markup is being rendered. So a narrow screen would
|
|
155
|
+
* draw a full-width sidebar and throw it away a moment later — the class that
|
|
156
|
+
* hides the column below the breakpoint is what stops that, and `matchMedia` is
|
|
157
|
+
* what decides, once there is a window to ask, that the drawer should exist at
|
|
158
|
+
* all.
|
|
159
|
+
*/
|
|
160
|
+
export declare const MPSidebar: React.ForwardRefExoticComponent<MPSidebarProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{MPDrawer as n}from"../drawer/MPDrawer.js";import{pixelsIn as o}from"../../internal/length.js";import{useMPLocale as i,useMPMessages as a}from"../../internal/locale.js";import{LAYOUT as s}from"../../internal/messages/layout.js";import{BAR_SURFACE as l,drawerSide as u,EXPANDED_ONLY as d,MPPageLayoutContext as c,MPSidebarSideContext as m,useMPCollapsed as p}from"../../internal/page-layout.js";import{SHEET_PAD_X as f,SHEET_PAD_Y as b}from"../../internal/scale.js";const v={xs:"15rem",sm:"18rem",md:"22.5rem",lg:"26rem",xl:"30rem"};function y(e,t){return null==e?t:"number"==typeof e?e:o(e,"undefined"==typeof window?void 0:window.innerWidth)??t}export const MPSidebar=/*@__PURE__*/r.forwardRef(function({side:o,width:h,minWidth:g=160,maxWidth:w=480,resizable:x=!1,onResize:_,onResizeEnd:j,collapseBelow:R,open:k,defaultOpen:C=!1,onOpenChange:z,sticky:P=!0,title:E,variant:M="outlined",size:L="md",padded:B=!0,label:S,locale:N,className:A,style:D,children:O,...$},I){const W=r.useContext(c),T=r.useContext(m),X=o??T??"start",K=i(N??W.locale),V=a(s,K),q=R??(W.present?W.collapseBelow:"none"),F=p(q),[G,H]=r.useState(C),J=void 0!==k,Q=J?k:W.present?W.open[X]:G,U=e=>{J||(W.present?W.setOpen(X,e):H(e)),z?.(e)},Y=void 0===h?v[L]:"number"==typeof h?`${h}px`:h,Z=r.useRef(null),ee=r.useRef(Y),te=r.useRef(null),re=r.useId();ee.current!==Y&&(ee.current=Y,Z.current=null);const ne=Z.current??Y,oe=r.useRef(null),ie=r.useCallback(e=>{oe.current=e,"function"==typeof I?I(e):I&&(I.current=e)},[I]),ae=r.useRef(null);r.useEffect(()=>()=>ae.current?.(),[]);const se=e=>{const t=oe.current;if(!t)return e;const r=Math.min(y(w,480),Math.max(y(g,160),Math.round(e)));return Z.current=`${r}px`,t.style.setProperty("--_mp-sidebar-width",Z.current),te.current?.setAttribute("aria-valuenow",String(r)),r};return F?e(n,{side:u(X),mode:"modal",open:Q,onOpenChange:U,title:E??S??V.sidebar,size:L,locale:K,extent:void 0===h?void 0:ne,className:A,style:D,children:O}):t("aside",{ref:ie,"aria-label":S??V.sidebar,"data-mp-size":L,"data-mp-variant":M,"data-mp-side":X,className:["mp-sidebar text-mp-on-surface relative box-border flex min-w-0 shrink-0 flex-col","w-(--_mp-sidebar-width)",l[M],"outlined"===M?"border-mp-outline-variant "+("start"===X?"border-e":"border-s"):"","content"===W.scroll?"h-full":P?["self-start sticky [top:var(--_mp-layout-header,0px)]","[height:calc(100dvh_-_var(--_mp-layout-header,0px)_-_var(--_mp-layout-footer,0px))]"].join(" "):"",d[q],A??""].filter(Boolean).join(" "),style:{"--_mp-sidebar-width":ne,...D},...$,children:[e("div",{id:re,className:["mp-sidebar__body min-h-0 flex-1 overflow-y-auto overscroll-contain",B?`${f[L]} ${b[L]}`:""].filter(Boolean).join(" "),children:O}),x?e("div",{ref:te,role:"separator","aria-orientation":"vertical","aria-label":V.resizeSidebar,"aria-valuemin":Math.round(y(g,160)),"aria-valuemax":Math.round(y(w,480)),"aria-valuenow":Math.round(y(ne,y(v[L],360))),"aria-controls":re,tabIndex:0,className:["mp-sidebar__handle absolute inset-y-0 z-1 w-2 cursor-col-resize bg-transparent","start"===X?"-me-1 end-0":"-ms-1 start-0","hover:bg-mp-outline-variant data-dragging:bg-mp-outline-variant","transition-colors duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-0","focus-visible:outline-solid outline-none"].join(" "),onPointerDown:e=>{const t=oe.current;if(!t||0!==e.button)return;const r=e.currentTarget;r.setPointerCapture(e.pointerId),r.dataset.dragging="true";const n=document.body.style.getPropertyValue("-webkit-user-select");document.body.style.setProperty("-webkit-user-select","none");const o=e.clientX,i=t.getBoundingClientRect().width,a="rtl"===getComputedStyle(t).direction,s="start"===X===a?-1:1;let l=i;const u=e=>{l=se(i+(e.clientX-o)*s),_?.(l)},d=()=>{ae.current=null,r.removeEventListener("pointermove",u),r.removeEventListener("pointerup",c),r.removeEventListener("pointercancel",c),delete r.dataset.dragging,n?document.body.style.setProperty("-webkit-user-select",n):document.body.style.removeProperty("-webkit-user-select")},c=()=>{d(),j?.(l)};ae.current=d,r.addEventListener("pointermove",u),r.addEventListener("pointerup",c),r.addEventListener("pointercancel",c)},onKeyDown:e=>{if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;e.preventDefault();const t="rtl"===getComputedStyle(e.currentTarget).direction,r="start"===X===t?-1:1;(e=>{const t=oe.current;if(!t)return;const r=se(t.getBoundingClientRect().width+e);_?.(r),j?.(r)})(("ArrowRight"===e.key?16:-16)*r)}}):null]})});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPIconButtonProps } from '../icon-button/MPIconButton.js';
|
|
3
|
+
import { type MPPageCollapse, type MPSidebarSide } from '../../internal/page-layout.js';
|
|
4
|
+
export interface MPSidebarTriggerProps extends Omit<MPIconButtonProps, 'icon' | 'label'> {
|
|
5
|
+
/**
|
|
6
|
+
* Which of the layout's two sidebars it opens.
|
|
7
|
+
* @default 'start'
|
|
8
|
+
*/
|
|
9
|
+
side?: MPSidebarSide;
|
|
10
|
+
/**
|
|
11
|
+
* The width below which the button appears — the same one the sidebar
|
|
12
|
+
* collapses at, since the button exists exactly while the column does not.
|
|
13
|
+
* Inherited from the [MPPageLayout](./page-layout), which is where it should
|
|
14
|
+
* be set.
|
|
15
|
+
*/
|
|
16
|
+
collapseBelow?: MPPageCollapse;
|
|
17
|
+
/** The glyph. Three lines, unless something else is given. */
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* What it does, in words. Defaults to "Open sidebar" / "Close sidebar" in
|
|
21
|
+
* `locale`, and it changes with the state because the button does.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Which language that word is in. Inherited from the layout. */
|
|
25
|
+
locale?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The button that brings back an [MPSidebar](#mpsidebar) the window has become
|
|
29
|
+
* too narrow to hold.
|
|
30
|
+
*
|
|
31
|
+
* It is drawn only while that is true, and the "while" is a **media query**
|
|
32
|
+
* rather than a piece of state: the button carries a class that hides it from
|
|
33
|
+
* the breakpoint up. That matters more than it looks — a trigger whose presence
|
|
34
|
+
* depended on `matchMedia` would be missing from the markup a server sends and
|
|
35
|
+
* would pop into the header a moment after the page arrived, on every phone,
|
|
36
|
+
* every time.
|
|
37
|
+
*
|
|
38
|
+
* Put it in an [MPHeader](./header)'s `brand` slot, ahead of the mark, which is
|
|
39
|
+
* where thirty years of hamburgers have taught readers to look for it.
|
|
40
|
+
*
|
|
41
|
+
* It has to be inside an [MPPageLayout](./page-layout) to have something to
|
|
42
|
+
* open: outside one there is no sidebar it could be talking about, and it
|
|
43
|
+
* renders nothing at all rather than a button that does nothing.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MPSidebarTrigger: React.ForwardRefExoticComponent<MPSidebarTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as o}from"react/jsx-runtime";import*as e from"react";import{MPIcon as r}from"../icon/MPIcon.js";import{MPIconButton as n}from"../icon-button/MPIconButton.js";import{MenuIcon as t}from"../../constants/icons.js";import{useMPLocale as a,useMPMessages as i}from"../../internal/locale.js";import{LAYOUT as s}from"../../internal/messages/layout.js";import{COLLAPSED_ONLY as l,MPPageLayoutContext as c}from"../../internal/page-layout.js";export const MPSidebarTrigger=/*@__PURE__*/e.forwardRef(function({side:m="start",collapseBelow:p,icon:f,label:u,locale:j,className:d,onClick:b,...g},x){const B=e.useContext(c),w=a(j??B.locale),C=i(s,w);if(!B.present)return null;const M=p??B.collapseBelow,P=B.open[m];return o(n,{ref:x,icon:f??o(r,{icon:t}),label:u??(P?C.closeSidebar:C.openSidebar),"aria-expanded":P,className:["mp-sidebar-trigger",l[M],d??""].filter(Boolean).join(" "),onClick:o=>{B.setOpen(m,!P),b?.(o)},...g})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSidebar}from"./MPSidebar.js";export{MPSidebarTrigger}from"./MPSidebarTrigger.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{useRender as l}from"@base-ui/react/use-render";import{CONTROL_SQUARE as o}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{useRender as l}from"@base-ui/react/use-render";import{CONTROL_SQUARE as o}from"../../internal/scale.js";import{cssLength as a}from"../../internal/length.js";const n={xs:"h-3",sm:"h-3.5",md:"h-4",lg:"h-4",xl:"h-5.5"},s={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2",xl:"gap-1.5"},i={xs:"h-12",sm:"h-16",md:"h-20",lg:"h-28",xl:"h-36"},t="overflow-hidden bg-(--_mp-placeholder)";export const MPSkeleton=/*@__PURE__*/r.forwardRef(function({shape:r="line",lines:m=1,size:d="md",color:p,width:h,height:c,animated:f=!0,label:u,render:g,className:x,style:w,...j},v){const b=f?"animate-pulse motion-reduce:animate-none":"",k="circle"===r?`rounded-mp-full shrink-0 ${o[d]}`:"rect"===r?`rounded-mp-md w-full ${void 0===c?i[d]:""}`:`rounded-mp-xs w-full ${n[d]}`,y=u?{role:"status","aria-busy":!0,"aria-label":u}:{"aria-hidden":!0},$="line"===r&&m>1;return l({render:g,ref:v,props:{"data-mp-size":d,className:($?["mp-skeleton flex w-full flex-col",s[d],x??""]:["mp-skeleton",t,b,k,x??""]).filter(Boolean).join(" "),style:{"--_mp-placeholder":p?`var(--_mp-color-${p}-container)`:"var(--_mp-color-surface-container-highest)",width:a(h),height:$?void 0:a(c),...w},...y,...$?{children:Array.from({length:m},(r,l)=>e("div",{className:[t,b,"rounded-mp-xs",n[d],l===m-1?"w-3/5":"w-full"].filter(Boolean).join(" ")},l))}:null,...j}})});
|
|
@@ -54,6 +54,12 @@ export interface MPSliderProps {
|
|
|
54
54
|
name?: string;
|
|
55
55
|
/** The accessible name, for a slider with no visible `label`. */
|
|
56
56
|
'aria-label'?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Added to the slider's outermost element, which holds the label row as well
|
|
59
|
+
* as the track.
|
|
60
|
+
*/
|
|
61
|
+
className?: string;
|
|
62
|
+
style?: React.CSSProperties;
|
|
57
63
|
}
|
|
58
64
|
/**
|
|
59
65
|
* A Material Design slider.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as r from"react";import{Slider as a}from"@base-ui/react/slider";import{accentSlots as t}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as i,hasContent as o}from"../../internal/scale.js";const l={xs:{thickness:"h-0.5",cross:"w-0.5",handle:"size-3.5",strip:"h-8",stripCross:"w-8"},sm:{thickness:"h-[3px]",cross:"w-[3px]",handle:"size-4",strip:"h-9",stripCross:"w-9"},md:{thickness:"h-1",cross:"w-1",handle:"size-5",strip:"h-10",stripCross:"w-10"},lg:{thickness:"h-1.5",cross:"w-1.5",handle:"size-6",strip:"h-11",stripCross:"w-11"},xl:{thickness:"h-2",cross:"w-2",handle:"size-7",strip:"h-12",stripCross:"w-12"}},c=/*@__PURE__*/["duration-(--mp-sys-motion-duration-short2) ease-mp-standard","motion-reduce:transition-none"].join(" "),m={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=/*@__PURE__*/r.forwardRef(function({value:d,defaultValue:u,onValueChange:p,onValueCommitted:f,min:h=0,max:g=100,step:x=1,label:b,description:w,showValue:j=!1,format:y,orientation:z="horizontal",size:v="md",color:C="primary",disabled:N=!1,name:_,"aria-label":k,className:V,style:$},A){const B="vertical"===z,I=l[v],L=r.useId(),R=d??u,S=Array.isArray(R)?R.length:1;return s(a.Root,{ref:A,value:d,defaultValue:u,onValueChange:e=>p?.(e),onValueCommitted:e=>f?.(e),min:h,max:g,step:x,disabled:N,orientation:z,format:y,name:_,"data-mp-size":v,className:["mp-slider flex",B?"w-fit flex-col items-center gap-2":"w-full flex-col gap-1",N?"cursor-default":"",V??""].filter(Boolean).join(" "),style:{...t(C),...$},children:[o(b)||j?s("div",{className:["flex w-full items-baseline gap-2",i].join(" "),children:[o(b)?e(a.Label,{className:N?"text-mp-on-surface/38":"text-mp-on-surface-variant",children:b}):null,j?e(a.Value,{className:["ms-auto tabular-nums",N?"text-mp-on-surface/38":"text-mp-on-surface"].join(" ")}):null]}):null,e(a.Control,{className:["mp-slider__control group/rail flex touch-none items-center justify-center select-none",B?`${I.stripCross} h-40 flex-col`:`w-full ${I.strip}`,N?"":"cursor-pointer"].filter(Boolean).join(" "),children:s(a.Track,{className:["mp-slider__track rounded-mp-full relative",B?`${I.cross} h-full`:`${I.thickness} w-full`,N?"bg-mp-on-surface/12":"bg-mp-surface-container-highest"].join(" "),children:[e(a.Indicator,{className:["rounded-mp-full","[transition-property:inset-inline-start,width,bottom,height]",c,"group-data-dragging/rail:transition-none",N?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")}),Array.from({length:S},(s,r)=>e(a.Thumb,{index:r,"aria-label":o(b)?void 0:k,"aria-describedby":o(w)?L:void 0,className:["mp-slider__handle group rounded-mp-full relative outline-none","[transition-property:inset-inline-start,bottom]",c,"data-dragging:transition-none",I.handle,N?"bg-mp-on-surface/38 cursor-default":"bg-(--_mp-accent) cursor-grab active:cursor-grabbing"].join(" "),children:N?null:e(n,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",m[v],"bg-(--_mp-accent)"].join(" "),className:"group-data-dragging:opacity-16"})},r))]})}),o(w)?e("div",{id:L,className:[i,N?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:w}):null]})});
|
|
@@ -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{Toast as s}from"@base-ui/react/toast";import{MPIcon as i}from"../icon/MPIcon.js";import{CloseIcon as n}from"../../constants/icons.js";import{accentSlots as r}from"../../internal/accent.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{MPIcon as i}from"../icon/MPIcon.js";import{CloseIcon as n}from"../../constants/icons.js";import{accentSlots as r}from"../../internal/accent.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{cssLength as p}from"../../internal/length.js";import{PORTAL_LAYER as d}from"../../internal/surface.js";const u={"top-start":"top-0 items-start","top-center":"top-0 items-center","top-end":"top-0 items-end","bottom-start":"bottom-0 flex-col-reverse items-start","bottom-center":"bottom-0 flex-col-reverse items-center","bottom-end":"bottom-0 flex-col-reverse items-end"},f=/*@__PURE__*/["transition-[opacity,translate] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),x={top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},b={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},y={xs:"min-h-9 gap-1.5 py-1.5 ps-3 pe-1.5",sm:"min-h-10 gap-2 py-2 ps-3.5 pe-2",md:"min-h-12 gap-2 py-2.5 ps-4 pe-2",lg:"min-h-14 gap-3 py-3 ps-5 pe-2.5",xl:"min-h-16 gap-3 py-3.5 pe-3 ps-6"},h={xs:16,sm:18,md:20,lg:22,xl:24};function g(e){const{color:t,icon:o,message:s,actionLabel:i,onAction:n,...r}=e;return{...r,title:s,data:{color:t,icon:o},actionProps:void 0===i?void 0:{children:i,onClick:n}}}export function useMPSnackbar(){const e=s.useToastManager();return o.useMemo(()=>({add:t=>e.add(g(t)),close:t=>e.close(t),update:(t,o)=>e.update(t,g(o)),promise:(t,o)=>e.promise(t,{loading:g(o.loading),success:e=>g("function"==typeof o.success?o.success(e):o.success),error:e=>g("function"==typeof o.error?o.error(e):o.error)}),snackbars:e.toasts}),[e])}function v({toast:o,color:a,size:l,showClose:m,closeLabel:p,swipeDirection:d,edge:u}){const g=o.data?.color??a,v=o.data?.icon,j={"--_mp-plate":g?`var(--_mp-color-${g}-container)`:"var(--_mp-color-inverse-surface)","--_mp-on-plate":g?`var(--_mp-color-on-${g}-container)`:"var(--_mp-color-inverse-on-surface)","--_mp-plate-action":g?`var(--_mp-color-${g})`:"var(--_mp-color-inverse-primary)",...g?r(g):null};return t(s.Root,{toast:o,swipeDirection:d,"data-mp-size":l,className:["mp-snackbar rounded-mp-xs shadow-mp-3 pointer-events-auto flex w-full items-center","bg-(--_mp-plate) text-(--_mp-on-plate) outline-none",y[l],b[l],f,x[u],"data-limited:hidden"].join(" "),style:j,children:[v?e("span",{className:"flex shrink-0 items-center",children:v}):null,e(s.Title,{render:e("span",{}),className:"min-w-0 flex-1 py-0.5 ps-1 [min-inline-size:min(280px,100%)]"}),e(s.Action,{className:["text-mp-label-large flex shrink-0 cursor-pointer items-center","rounded-mp-full h-8 px-3 text-(--_mp-plate-action)","transition-colors duration-(--mp-sys-motion-duration-short4)","hover:bg-(--_mp-plate-action)/8 focus-visible:bg-(--_mp-plate-action)/10","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ")}),m?t(s.Close,{"aria-label":p,className:["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer","items-center justify-center text-(--_mp-on-plate)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(c,{}),e(i,{icon:n,size:h[l]})]}):null]})}function j({position:t,width:o,...i}){const{toasts:n}=s.useToastManager(),r=t.startsWith("top")?"top":"bottom",a=["top"===r?"up":"down","left","right"];return e(s.Portal,{children:e(s.Viewport,{className:[d,"pointer-events-none fixed inset-x-0 flex flex-col gap-2 p-4",u[t]].join(" "),children:n.map(t=>e("div",{className:"w-full",style:{maxWidth:p(o)},children:e(v,{toast:t,swipeDirection:a,edge:r,...i})},t.id))})})}export function MPSnackbarProvider({color:o,position:i="bottom-start",timeout:n=5e3,limit:r=3,width:c=600,size:p="md",showClose:d=!0,closeLabel:u,locale:f,children:x}){const b=a(f),y=l(m,b);return t(s.Provider,{timeout:n,limit:r,children:[x,e(j,{position:i,width:c,color:o,size:p,showClose:d,closeLabel:u??y.close})]})}
|
|
@@ -59,6 +59,12 @@ export interface MPSwitchProps {
|
|
|
59
59
|
* against the far edge. This is what makes a column of settings line up.
|
|
60
60
|
*/
|
|
61
61
|
fullWidth?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Added to the outermost element — the box around the track, its label and its
|
|
64
|
+
* supporting line, rather than to the track itself.
|
|
65
|
+
*/
|
|
66
|
+
className?: string;
|
|
67
|
+
style?: React.CSSProperties;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* A Material Design switch.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";const u={xs:{track:"h-5 w-8",thumb:"
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";const u={xs:{track:"h-5 w-8",thumb:"start-[5px] size-2.5 data-checked:start-[15px] data-checked:size-3.5",halo:"size-8",glyph:8},sm:{track:"h-6 w-10",thumb:"start-1.5 size-3 data-checked:start-[19px] data-checked:size-[18px]",halo:"size-9",glyph:10},md:{track:"h-8 w-13",thumb:"start-2 size-4 data-checked:start-6 data-checked:size-6",halo:"size-10",glyph:14},lg:{track:"h-9 w-15",thumb:"start-[9px] size-[18px] data-checked:start-7 data-checked:size-7",halo:"size-11",glyph:16},xl:{track:"h-10 w-17",thumb:"start-2.5 size-5 data-checked:start-[33px] data-checked:size-[30px]",halo:"size-12",glyph:18}};export const MPSwitch=/*@__PURE__*/r.forwardRef(function({checked:f,defaultChecked:g,onCheckedChange:k,label:b,description:x,errorMessage:y,icons:j=!1,labelPlacement:z="end",size:w="md",color:N="primary",required:_=!1,disabled:C=!1,readOnly:M=!1,name:v,id:P,fullWidth:R=!1,className:S,style:W},q){const B=p(y),F=B?"error":N,I=u[w],L=r.useId(),O=P??L,T=e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(n.Root,{ref:q,id:O,name:v,checked:f,defaultChecked:g,required:_,disabled:C,readOnly:M,onCheckedChange:e=>k?.(e),className:["mp-switch__track group relative box-border inline-flex shrink-0 p-0","rounded-mp-full appearance-none font-[inherit] outline-none","transition-[background-color,box-shadow]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",I.track,C?["bg-mp-surface-container-highest inset-ring-2 inset-ring-mp-on-surface/12","cursor-default","data-checked:bg-mp-on-surface/12 data-checked:inset-ring-0"].join(" "):[M?"cursor-default":"cursor-pointer","bg-mp-surface-container-highest inset-ring-2",B?"inset-ring-mp-error":"inset-ring-mp-outline","data-checked:inset-ring-0 data-checked:bg-(--_mp-accent)"].join(" ")].join(" "),children:a(n.Thumb,{className:["mp-switch__thumb absolute top-1/2 flex -translate-y-1/2 items-center justify-center","rounded-full","transition-[inset-inline-start,width,height,background-color]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",I.thumb,C?"bg-mp-on-surface/38 data-checked:bg-mp-surface-container-highest":[B?"bg-mp-error":"bg-mp-outline","data-checked:bg-(--_mp-on-accent)"].join(" ")].join(" "),children:[C?null:e(d,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",I.halo,"bg-mp-on-surface group-data-checked:bg-(--_mp-accent)"].join(" ")}),j?a(t,{children:[e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard opacity-0 group-data-checked:opacity-100",C?"text-mp-surface-container-highest":"text-(--_mp-accent)"].join(" "),children:e(s,{icon:o,size:I.glyph,strokeWidth:3})}),e("span",{className:["absolute inset-0 flex items-center justify-center","text-mp-surface-container-highest","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard group-data-checked:opacity-0"].join(" "),children:e(s,{icon:c,size:I.glyph,strokeWidth:3})})]}):null]})})}),A=p(b)||p(x)||B?a("span",{className:["flex min-w-0 flex-col gap-0.5","start"===z?"flex-1":""].filter(Boolean).join(" "),children:[p(b)?a(i.Label,{htmlFor:O,className:["leading-[1.4]",C?"text-mp-on-surface/38 cursor-default":M?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:[b,_?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(h,{description:x,errorMessage:y})]}):null;return e(i.Root,{className:["mp-switch align-top",R?"flex w-full":"inline-flex",S??""].filter(Boolean).join(" "),disabled:C,invalid:B,"data-mp-size":w,style:{...l(F),...W},children:e("div",{className:["flex w-full items-start gap-3",m[w]].join(" "),children:a(t,"start"===z?{children:[A,T]}:{children:[T,A]})})})});
|
|
@@ -32,14 +32,31 @@ export interface MPTableColumn<Row> {
|
|
|
32
32
|
align?: MPTableAlign;
|
|
33
33
|
/**
|
|
34
34
|
* Renders the cell. Without it the cell is `row[key]` rendered as-is, which
|
|
35
|
-
* covers strings
|
|
35
|
+
* covers strings, numbers and elements.
|
|
36
|
+
*
|
|
37
|
+
* Anything else — a `Date`, a nested object, an array — draws an empty cell
|
|
38
|
+
* rather than being handed to React, which would throw. Reach for this the
|
|
39
|
+
* moment a column holds something that is not already text.
|
|
36
40
|
*/
|
|
37
41
|
render?: (row: Row, index: number) => React.ReactNode;
|
|
38
42
|
}
|
|
39
43
|
export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children'> {
|
|
40
44
|
/** The columns, in the order they appear. */
|
|
41
45
|
headers: readonly MPTableColumn<Row>[];
|
|
42
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The rows. *
|
|
48
|
+
* ## How long a list this holds
|
|
49
|
+
*
|
|
50
|
+
* Every row is rendered, and there is no windowing. That is the right default
|
|
51
|
+
* — windowing costs a measured container, a scroll listener and a row height
|
|
52
|
+
* the component would have to decide for the caller — and it has a ceiling: a
|
|
53
|
+
* few hundred rows is nothing, a few thousand is a visible pause when the list
|
|
54
|
+
* opens, and past that the answer is a narrower list rather than a faster one.
|
|
55
|
+
*
|
|
56
|
+
* A list somebody has to scroll ten thousand rows of is a list that wanted a
|
|
57
|
+
* filter. Where it genuinely is that long, window it yourself and pass the
|
|
58
|
+
* slice.
|
|
59
|
+
*/
|
|
43
60
|
items: readonly Row[];
|
|
44
61
|
/**
|
|
45
62
|
* A stable key per row. Defaults to the row's index, which is fine for a
|
|
@@ -49,10 +66,15 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
49
66
|
/** Shown above the table, and read out as its accessible name. */
|
|
50
67
|
caption?: React.ReactNode;
|
|
51
68
|
/**
|
|
52
|
-
* What to show instead of rows when `items` is empty.
|
|
53
|
-
*
|
|
69
|
+
* What to show instead of rows when `items` is empty. Defaults to the wording
|
|
70
|
+
* in `locale`.
|
|
54
71
|
*/
|
|
55
72
|
empty?: React.ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Which language that line is written in. Falls back to the nearest
|
|
75
|
+
* `MPLocaleProvider`, then to English.
|
|
76
|
+
*/
|
|
77
|
+
locale?: string;
|
|
56
78
|
/**
|
|
57
79
|
* Tints every other row. Useful for a wide table where the eye has to track
|
|
58
80
|
* across; noise on a narrow one.
|
|
@@ -117,4 +139,4 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
117
139
|
* than a ref on the scroll container is worth — and a caller who needs one can
|
|
118
140
|
* put it on a `<div>` of their own around this.
|
|
119
141
|
*/
|
|
120
|
-
export declare function MPTable<Row>({ headers, items, getRowKey, caption, empty, striped, hoverable, stickyHeader, onRowClick, variant, size, color, className, style, ...props }: MPTableProps<Row>): React.JSX.Element;
|
|
142
|
+
export declare function MPTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, striped, hoverable, stickyHeader, onRowClick, variant, size, color, className, style, ...props }: MPTableProps<Row>): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{accentSlots as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{accentSlots as l}from"../../internal/accent.js";import{useMPLocale as o,useMPMessages as a}from"../../internal/locale.js";import{TABLE as n}from"../../internal/messages/table.js";import{cssLength as i}from"../../internal/length.js";import{META_TEXT as m}from"../../internal/scale.js";import{CONTAINER_SURFACE as s}from"../../internal/surface.js";const c={xs:"0.625rem",sm:"0.75rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},d={xs:"0.375rem",sm:"0.625rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},p={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},u={xs:"text-mp-label-medium",sm:"text-mp-label-medium",md:"text-mp-title-small",lg:"text-mp-title-small",xl:"text-mp-title-medium"},x=/*@__PURE__*/["[--_mp-row:transparent]","transition-[background-color] duration-(--mp-sys-motion-duration-short4)"].join(" ");function y(e){if(null==e)return null;const t=typeof e;return"string"===t||"number"===t||"bigint"===t||"boolean"===t||r.isValidElement(e)?e:null}export function MPTable({headers:r,items:f,getRowKey:b,caption:g,empty:h,locale:v,striped:w=!1,hoverable:j=!1,stickyHeader:k=!1,onRowClick:N,variant:_="outlined",size:C="md",color:$="primary",className:A,style:B,...z}){const T=a(n,o(v)),D=c[C],E=d[C],K=Boolean(N),R=j||K,H={padding:`${E} ${D}`},I={...H,backgroundColor:"var(--_mp-color-surface-container)"},M={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"};return e("div",{"data-mp-size":C,"data-mp-variant":_,className:["mp-table rounded-mp-md overflow-x-auto",s[_],A??""].filter(Boolean).join(" "),style:{...l($),...B},...z,children:t("table",{className:`text-mp-on-surface w-full text-start ${p[C]}`,style:{borderCollapse:"collapse"},children:[g?e("caption",{className:`text-mp-on-surface-variant ${m}`,style:{...H,textAlign:"start"},children:g}):null,e("colgroup",{children:r.map(t=>e("col",{style:void 0===t.width?void 0:{width:i(t.width)}},t.key))}),e("thead",{children:e("tr",{children:r.map(t=>e("th",{scope:"col",className:["text-mp-on-surface-variant whitespace-nowrap",u[C],k?"sticky top-0 z-10":""].filter(Boolean).join(" "),style:{...I,textAlign:t.align??"start"},children:t.label??t.key},t.key))})}),e("tbody",{children:0===f.length?e("tr",{className:x,style:M,children:e("td",{colSpan:r.length,className:"text-mp-on-surface-variant",style:{padding:`2rem ${D}`,textAlign:"center"},children:h??T.empty})}):f.map((t,l)=>e("tr",{className:[x,w&&l%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",R?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",K?["cursor-pointer","outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" "):""].filter(Boolean).join(" "),style:M,tabIndex:K?0:void 0,onClick:N?()=>N(t,l):void 0,onKeyDown:N?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),N(t,l))}:void 0,children:r.map(r=>e("td",{style:{...H,textAlign:r.align??"start"},children:r.render?r.render(t,l):y(t[r.key])},r.key))},b?b(t,l):l))})]})})}
|
|
@@ -110,8 +110,19 @@ export interface MPTextFieldProps extends MPStyleProps {
|
|
|
110
110
|
*/
|
|
111
111
|
onChange?: (value: string) => void;
|
|
112
112
|
/**
|
|
113
|
-
* Called when Enter is pressed.
|
|
114
|
-
*
|
|
113
|
+
* Called when Enter is pressed.
|
|
114
|
+
*
|
|
115
|
+
* On a single-line field the key is then swallowed, so a surrounding form is
|
|
116
|
+
* submitted once rather than also natively.
|
|
117
|
+
*
|
|
118
|
+
* On a **multiline** field it is not, and both things happen: this fires *and*
|
|
119
|
+
* a newline is inserted. That is deliberate — the prop reports the keystroke
|
|
120
|
+
* rather than deciding what the field does with it — but it is worth knowing
|
|
121
|
+
* before wiring it to something that sends. `disableEnterKey` is what makes
|
|
122
|
+
* Enter a submission there and nothing else.
|
|
123
|
+
*
|
|
124
|
+
* Never called for the Enter that commits an IME composition: that keystroke
|
|
125
|
+
* belongs to the input method, not to the form.
|
|
115
126
|
*/
|
|
116
127
|
onSubmit?: () => void;
|
|
117
128
|
/**
|
|
@@ -119,6 +130,14 @@ export interface MPTextFieldProps extends MPStyleProps {
|
|
|
119
130
|
* form-level error that a further edit has made stale.
|
|
120
131
|
*/
|
|
121
132
|
onFormReset?: () => void;
|
|
133
|
+
/**
|
|
134
|
+
* Added to the field's outermost element — the box around the control and its
|
|
135
|
+
* supporting line, rather than to the `<input>` itself. The control carries a
|
|
136
|
+
* type scale of its own, so a `text-*` written here does not reach it; that is
|
|
137
|
+
* what `size` is for.
|
|
138
|
+
*/
|
|
139
|
+
className?: string;
|
|
140
|
+
style?: React.CSSProperties;
|
|
122
141
|
}
|
|
123
142
|
/**
|
|
124
143
|
* A Material Design text field that survives an IME.
|