material-plus-ui 1.4.0 → 1.6.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 +1 -1
- package/dist/components/accordion/MPAccordion.js +1 -1
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -1
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.js +1 -1
- package/dist/components/badge/MPBadge.js +1 -1
- package/dist/components/blockquote/MPBlockquote.js +1 -1
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +17 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -1
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.d.ts +49 -3
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/calendar/MPCalendar.d.ts +160 -0
- package/dist/components/calendar/MPCalendar.js +2 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/MPCard.js +1 -1
- package/dist/components/carousel/MPCarousel.js +1 -1
- 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/chip/MPChip.d.ts +21 -6
- package/dist/components/chip/MPChip.js +1 -1
- package/dist/components/collapsible/MPCollapsible.js +1 -1
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +52 -3
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +1 -1
- package/dist/components/command-palette/MPCommandPalette.js +1 -1
- package/dist/components/config/MPConfigProvider.d.ts +124 -0
- package/dist/components/config/MPConfigProvider.js +2 -0
- package/dist/components/config/index.d.ts +2 -0
- package/dist/components/config/index.js +1 -0
- package/dist/components/confirm/MPConfirmProvider.d.ts +143 -0
- package/dist/components/confirm/MPConfirmProvider.js +2 -0
- package/dist/components/confirm/index.d.ts +2 -0
- package/dist/components/confirm/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-picker/MPDatePicker.d.ts +53 -2
- package/dist/components/date-picker/MPDatePicker.js +1 -1
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -1
- package/dist/components/dialog/MPDialog.d.ts +16 -3
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.d.ts +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/empty/MPEmpty.js +1 -1
- package/dist/components/file-picker/MPFilePicker.d.ts +6 -0
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.js +1 -1
- package/dist/components/grid/MPGrid.d.ts +23 -1
- package/dist/components/grid/MPGrid.js +1 -1
- package/dist/components/header/MPHeader.js +1 -1
- package/dist/components/image/MPImage.d.ts +112 -0
- package/dist/components/image/MPImage.js +2 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/image/index.js +1 -0
- package/dist/components/list/MPList.d.ts +28 -0
- package/dist/components/list/MPList.js +1 -1
- package/dist/components/menu/MPMenu.d.ts +25 -4
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.d.ts +8 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +8 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +9 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/otp-field/MPOtpField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +1 -1
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/pagination/MPPagination.js +1 -1
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/pill/MPPill.js +1 -1
- package/dist/components/popconfirm/MPPopconfirm.d.ts +92 -0
- package/dist/components/popconfirm/MPPopconfirm.js +2 -0
- package/dist/components/popconfirm/index.d.ts +2 -0
- package/dist/components/popconfirm/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +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/rating/MPRating.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 +9 -2
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.js +1 -1
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +33 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.d.ts +20 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/spoiler/MPSpoiler.js +1 -1
- package/dist/components/stepper/MPStepper.d.ts +153 -0
- package/dist/components/stepper/MPStepper.js +2 -0
- package/dist/components/stepper/index.d.ts +2 -0
- package/dist/components/stepper/index.js +1 -0
- package/dist/components/switch/MPSwitch.d.ts +6 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +1 -1
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/tabs/MPTabs.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +46 -14
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/time-picker/MPTimePicker.js +1 -1
- package/dist/components/timeline/MPTimeline.d.ts +10 -2
- package/dist/components/timeline/MPTimeline.js +1 -1
- package/dist/components/toggle/MPToggle.js +1 -1
- package/dist/components/transfer/MPTransfer.js +1 -1
- package/dist/components/typography/MPTypography.d.ts +7 -0
- package/dist/components/typography/MPTypography.js +1 -2
- package/dist/components/visually-hidden/MPVisuallyHidden.d.ts +60 -0
- package/dist/components/visually-hidden/MPVisuallyHidden.js +2 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/index.js +1 -0
- package/dist/constants/glyphs.d.ts +2 -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/hooks/index.d.ts +23 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useMPColorScheme.d.ts +135 -0
- package/dist/hooks/useMPColorScheme.js +1 -0
- package/dist/hooks/useMPReducedMotion.d.ts +32 -0
- package/dist/hooks/useMPReducedMotion.js +1 -0
- package/dist/hooks/useMPShortcut.d.ts +105 -0
- package/dist/hooks/useMPShortcut.js +2 -0
- package/dist/hooks/useMPWindowClass.d.ts +48 -0
- package/dist/hooks/useMPWindowClass.js +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +19 -4
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/Picker.d.ts +15 -3
- package/dist/internal/Picker.js +1 -1
- package/dist/internal/color-scheme.d.ts +28 -0
- package/dist/internal/color-scheme.js +2 -0
- package/dist/internal/config.d.ts +43 -0
- package/dist/internal/config.js +2 -0
- package/dist/internal/date.d.ts +50 -3
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +26 -1
- package/dist/internal/messages/confirm.d.ts +3 -0
- package/dist/internal/messages/confirm.js +1 -0
- package/dist/internal/messages/picker.js +1 -1
- package/dist/internal/progress.d.ts +14 -0
- package/dist/internal/step.d.ts +71 -0
- package/dist/internal/step.js +1 -0
- package/dist/internal/window-class.d.ts +21 -0
- package/dist/internal/window-class.js +2 -0
- 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/animate-lighting.css +1 -1
- package/dist/styles/aspect-ratio.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/calendar.css +2 -0
- package/dist/styles/chip.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/config.css +2 -0
- package/dist/styles/confirm.css +2 -0
- package/dist/styles/grid.css +1 -1
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/image.css +2 -0
- package/dist/styles/list.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/popconfirm.css +2 -0
- 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/rating.css +1 -1
- package/dist/styles/shortcut.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/stepper.css +2 -0
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/tokens.css +1 -1
- package/dist/styles/transfer.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/visually-hidden.css +2 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +91 -5
- package/dist/types.d.ts +64 -0
- package/package.json +6 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MPStyleProps } from '../../types.js';
|
|
2
|
+
import type { MPControlEventProps, MPStyleProps } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* What a select's value may be.
|
|
5
5
|
*
|
|
@@ -18,7 +18,7 @@ export interface MPSelectOption {
|
|
|
18
18
|
/** Unavailable, but still listed — the option exists, it just cannot be taken. */
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export interface MPSelectProps extends MPStyleProps {
|
|
21
|
+
export interface MPSelectProps extends MPStyleProps, MPControlEventProps<HTMLButtonElement> {
|
|
22
22
|
/**
|
|
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
|
|
@@ -90,6 +90,13 @@ export interface MPSelectProps extends MPStyleProps {
|
|
|
90
90
|
* left out.
|
|
91
91
|
*/
|
|
92
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;
|
|
93
100
|
}
|
|
94
101
|
/**
|
|
95
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
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as n from"react";import{Select as t}from"@base-ui/react/select";import{Field as r}from"@base-ui/react/field";import{MPIcon as o}from"../icon/MPIcon.js";import{CheckIcon as i,ChevronDownIcon as l}from"../../constants/icons.js";import{MPFieldLabel as s,MPFieldOutline as c,useFloatingLabel as d}from"../../internal/FieldOutline.js";import{MPStateLayer as u}from"../../internal/StateLayer.js";import{MPSupportingText as m}from"../../internal/SupportingText.js";import{CONTROL_ICON as p,PROSE_TEXT as f,hasContent as h}from"../../internal/scale.js";import{FADE as g,PORTAL_LAYER as x}from"../../internal/surface.js";import{useMPSize as b}from"../../internal/config.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__*/n.forwardRef(function({items:j,value:y,defaultValue:N,onValueChange:w,onKeyDown:k,onKeyUp:C,onFocus:I,onBlur:S,onClick:M,onDoubleClick:z,onContextMenu:P,placeholder:O,label:V,floatingLabel:q=!0,description:B,errorMessage:D,startIcon:F,size:K,fullWidth:T=!1,required:_=!1,disabled:L=!1,readOnly:R=!1,name:U,id:W,className:$,style:A},E){const G=b(K),H=h(D),J=v[G],Q=n.useId(),X=W??Q,[Y,Z]=n.useState(N??null),[ee,ae]=n.useState(!1),ne=void 0===y?Y:y,{shrunk:te,focusProps:re}=d({floating:q&&h(V),filled:null!==ne&&""!==ne,pinned:ee||!!F}),oe=n.useMemo(()=>j.map(e=>({label:e.label??String(e.value),value:e.value})),[j]);return a(r.Root,{className:["mp-select group flex-col align-top",T?"flex w-full":"inline-flex w-fit",$??""].filter(Boolean).join(" "),style:A,disabled:L,invalid:H,"data-mp-size":G,...re,children:[a(t.Root,{id:X,name:U,items:oe,value:y,defaultValue:N,onValueChange:e=>{Z(e??null),w?.(e??null)},onOpenChange:ae,disabled:L,readOnly:R,required:_,children:[a("div",{className:"relative w-full",children:[a(t.Trigger,{ref:E,onKeyDown:k,onKeyUp:C,onFocus:I,onBlur:S,onClick:M,onDoubleClick:z,onContextMenu:P,className:["relative flex w-full items-center gap-2 select-none","appearance-none bg-transparent font-[inherit] outline-none",J.padding,J.height,f[G],L?"text-mp-on-surface/38 cursor-default":"text-mp-on-surface "+(R?"cursor-default":"cursor-pointer")].join(" "),children:[F?e("span",{className:["flex shrink-0 items-center",L?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:F}):null,e(t.Value,{className:["min-w-0 flex-1 truncate text-start","data-placeholder:text-mp-on-surface-variant",L?"data-placeholder:text-mp-on-surface/38":""].filter(Boolean).join(" "),placeholder:te?O:void 0}),e(t.Icon,{className:["flex shrink-0 items-center","transition-transform duration-(--mp-sys-motion-duration-short4)","data-popup-open:rotate-180",L?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:e(o,{icon:l,size:p[G]})})]}),e(c,{label:V,required:_,notched:te}),h(V)?e(s,{size:G,label:V,required:_,htmlFor:X,shrunk:te}):null]}),e(t.Portal,{children:e(t.Positioner,{className:x,sideOffset:4,alignItemWithTrigger:!1,children:e(t.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[G],g].join(" "),children:e(t.List,{className:"max-h-[min(20rem,var(--available-height))] overflow-y-auto overscroll-contain",children:j.map((n,r)=>a(t.Item,{value:n.value,disabled:n.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(u,{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(t.ItemIndicator,{children:e(o,{icon:i,size:18})})}),e(t.ItemText,{className:"min-w-0 flex-1 truncate",children:n.label??String(n.value)})]},`${r}:${String(n.value)}`))})})})})]}),e(m,{description:B,errorMessage:D,className:J.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 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
|
|
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";import{useMPSize as s}from"../../internal/config.js";const i=e=>({symbol:e,name:e}),c={mod:{mac:{symbol:"⌘",name:"Command"},windows:i("Ctrl"),linux:i("Ctrl")},meta:{mac:{symbol:"⌘",name:"Command"},windows:i("Win"),linux:i("Super")},ctrl:{mac:{symbol:"⌃",name:"Control"},windows:i("Ctrl"),linux:i("Ctrl")},alt:{mac:{symbol:"⌥",name:"Option"},windows:i("Alt"),linux:i("Alt")},shift:{mac:{symbol:"⇧",name:"Shift"},windows:i("Shift"),linux:i("Shift")},enter:{mac:{symbol:"↩",name:"Enter"},windows:i("Enter"),linux:i("Enter")},tab:{mac:{symbol:"⇥",name:"Tab"},windows:i("Tab"),linux:i("Tab")},escape:{mac:{symbol:"⎋",name:"Escape"},windows:i("Esc"),linux:i("Esc")},backspace:{mac:{symbol:"⌫",name:"Backspace"},windows:i("Backspace"),linux:i("Backspace")},delete:{mac:{symbol:"⌦",name:"Delete"},windows:i("Del"),linux:i("Del")},capslock:{mac:{symbol:"⇪",name:"Caps Lock"},windows:i("Caps Lock"),linux:i("Caps Lock")}},d={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"},p={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 u={xs:"h-5",sm:"h-6",md:"h-8",lg:"h-10",xl:"h-12"},w={xs:"min-w-5",sm:"min-w-6",md:"min-w-8",lg:"min-w-10",xl:"min-w-12"},x={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"},b={xs:"px-1",sm:"px-1.5",md:"px-2",lg:"px-2.5",xl:"px-3"},f={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"},y={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:h="outlined",size:g,color:k="secondary",keys:C,os:j="auto",separator:v,className:A,style:E,...N},S){const _=s(g),B=r(),L="auto"===j?B:j,D=o(C).map(e=>function(e,n){const a=e.toLowerCase().replace(/[\s_-]/g,""),m=d[a]??a,t=p[m];if(t)return t;const o=c[m];return o?o[n]:i(1===e.length?e.toUpperCase():e)}(e,L)),T=void 0===v?"mac"===L?null:"+":v,z=/*@__PURE__*/["inline-flex shrink-0 items-center justify-center","font-mono leading-none whitespace-nowrap tabular-nums",u[_],w[_],x[_],b[_],f[_],y[h]].join(" ");return e("span",{ref:S,"data-mp-size":_,"data-mp-variant":h,className:["mp-shortcut inline-flex max-w-full items-center gap-1 align-middle",A??""].filter(Boolean).join(" "),style:{...t(k),...E},...N,children:D.map((t,o)=>a(m.Fragment,{children:[o>0&&null!==T?e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant",children:T}):null,e("kbd",{className:z,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))})});
|
|
@@ -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{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
|
|
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";import{useMPSize as v}from"../../internal/config.js";const y={xs:"15rem",sm:"18rem",md:"22.5rem",lg:"26rem",xl:"30rem"};function h(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:g,minWidth:w=160,maxWidth:x=480,resizable:j=!1,onResize:_,onResizeEnd:R,collapseBelow:k,open:C,defaultOpen:z=!1,onOpenChange:P,sticky:E=!0,title:M,variant:L="outlined",size:B,padded:S=!0,label:N,locale:A,className:D,style:O,children:$,...I},W){const T=v(B),X=r.useContext(c),K=r.useContext(m),V=o??K??"start",q=i(A??X.locale),F=a(s,q),G=k??(X.present?X.collapseBelow:"none"),H=p(G),[J,Q]=r.useState(z),U=void 0!==C,Y=U?C:X.present?X.open[V]:J,Z=e=>{U||(X.present?X.setOpen(V,e):Q(e)),P?.(e)},ee=void 0===g?y[T]:"number"==typeof g?`${g}px`:g,te=r.useRef(null),re=r.useRef(ee),ne=r.useRef(null),oe=r.useId();re.current!==ee&&(re.current=ee,te.current=null);const ie=te.current??ee,ae=r.useRef(null),se=r.useCallback(e=>{ae.current=e,"function"==typeof W?W(e):W&&(W.current=e)},[W]),le=r.useRef(null);r.useEffect(()=>()=>le.current?.(),[]);const ue=e=>{const t=ae.current;if(!t)return e;const r=Math.min(h(x,480),Math.max(h(w,160),Math.round(e)));return te.current=`${r}px`,t.style.setProperty("--_mp-sidebar-width",te.current),ne.current?.setAttribute("aria-valuenow",String(r)),r};return H?e(n,{side:u(V),mode:"modal",open:Y,onOpenChange:Z,title:M??N??F.sidebar,size:T,locale:q,extent:void 0===g?void 0:ie,className:D,style:O,children:$}):t("aside",{ref:se,"aria-label":N??F.sidebar,"data-mp-size":T,"data-mp-variant":L,"data-mp-side":V,className:["mp-sidebar text-mp-on-surface relative box-border flex min-w-0 shrink-0 flex-col","w-(--_mp-sidebar-width)",l[L],"outlined"===L?"border-mp-outline-variant "+("start"===V?"border-e":"border-s"):"","content"===X.scroll?"h-full":E?["self-start sticky [top:var(--_mp-layout-header,0px)]","[height:calc(100dvh_-_var(--_mp-layout-header,0px)_-_var(--_mp-layout-footer,0px))]"].join(" "):"",d[G],D??""].filter(Boolean).join(" "),style:{"--_mp-sidebar-width":ie,...O},...I,children:[e("div",{id:oe,className:["mp-sidebar__body min-h-0 flex-1 overflow-y-auto overscroll-contain",S?`${f[T]} ${b[T]}`:""].filter(Boolean).join(" "),children:$}),j?e("div",{ref:ne,role:"separator","aria-orientation":"vertical","aria-label":F.resizeSidebar,"aria-valuemin":Math.round(h(w,160)),"aria-valuemax":Math.round(h(x,480)),"aria-valuenow":Math.round(h(ie,h(y[T],360))),"aria-controls":oe,tabIndex:0,className:["mp-sidebar__handle absolute inset-y-0 z-1 w-2 cursor-col-resize bg-transparent","start"===V?"-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=ae.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"===V===a?-1:1;let l=i;const u=e=>{l=ue(i+(e.clientX-o)*s),_?.(l)},d=()=>{le.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(),R?.(l)};le.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"===V===t?-1:1;(e=>{const t=ae.current;if(!t)return;const r=ue(t.getBoundingClientRect().width+e);_?.(r),R?.(r)})(("ArrowRight"===e.key?16:-16)*r)}}):null]})});
|
|
@@ -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";import{cssLength as a}from"../../internal/length.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";import{useMPSize as n}from"../../internal/config.js";const i={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"},t={xs:"h-12",sm:"h-16",md:"h-20",lg:"h-28",xl:"h-36"},m="overflow-hidden bg-(--_mp-placeholder)";export const MPSkeleton=/*@__PURE__*/r.forwardRef(function({shape:r="line",lines:d=1,size:p,color:h,width:c,height:f,animated:u=!0,label:g,render:x,className:w,style:j,...v},b){const k=n(p),y=u?"animate-pulse motion-reduce:animate-none":"",$="circle"===r?`rounded-mp-full shrink-0 ${o[k]}`:"rect"===r?`rounded-mp-md w-full ${void 0===f?t[k]:""}`:`rounded-mp-xs w-full ${i[k]}`,_=g?{role:"status","aria-busy":!0,"aria-label":g}:{"aria-hidden":!0},N="line"===r&&d>1;return l({render:x,ref:b,props:{"data-mp-size":k,className:(N?["mp-skeleton flex w-full flex-col",s[k],w??""]:["mp-skeleton",m,y,$,w??""]).filter(Boolean).join(" "),style:{"--_mp-placeholder":h?`var(--_mp-color-${h}-container)`:"var(--_mp-color-surface-container-highest)",width:a(c),height:N?void 0:a(f),...j},..._,...N?{children:Array.from({length:d},(r,l)=>e("div",{className:[m,y,"rounded-mp-xs",i[k],l===d-1?"w-3/5":"w-full"].filter(Boolean).join(" ")},l))}:null,...v}})});
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { MPColor, MPOrientation, MPSize } from '../../types.js';
|
|
3
|
+
export interface MPSliderMark {
|
|
4
|
+
/** Where on the range it sits. Outside `min`…`max` it is not drawn. */
|
|
5
|
+
value: number;
|
|
6
|
+
/**
|
|
7
|
+
* What is written under it — or beside it on a vertical slider. Left out, the
|
|
8
|
+
* mark is a tick on the track and nothing else.
|
|
9
|
+
*/
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
}
|
|
3
12
|
export interface MPSliderProps {
|
|
4
13
|
/**
|
|
5
14
|
* The value, or the values. An array is what makes it a range slider — there is
|
|
@@ -19,6 +28,24 @@ export interface MPSliderProps {
|
|
|
19
28
|
max?: number;
|
|
20
29
|
/** How far one arrow key, or one notch of the drag, moves. @default 1 */
|
|
21
30
|
step?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The ticks on the track, and optionally what is written under them.
|
|
33
|
+
*
|
|
34
|
+
* `true` puts one at every `step`, which is MD3's discrete slider — up to fifty
|
|
35
|
+
* of them, past which they stop being ticks and become a dotted line (see
|
|
36
|
+
* `MAX_TICKS`). An array names them instead, and is the form that can carry
|
|
37
|
+
* labels: `[{ value: 1990, label: '1990' }, …]` for the decade markings under
|
|
38
|
+
* a year range.
|
|
39
|
+
*
|
|
40
|
+
* A tick over the filled part of the track is drawn in the accent's own ink and
|
|
41
|
+
* one over the groove in `on-surface-variant`, which is the specification's
|
|
42
|
+
* pairing and the reason a tick stays visible as the handle passes it.
|
|
43
|
+
*
|
|
44
|
+
* Labels are laid out from the tick's centre and are not measured, so two that
|
|
45
|
+
* would collide will overlap — an array with fewer entries is the answer, not a
|
|
46
|
+
* smaller type scale.
|
|
47
|
+
*/
|
|
48
|
+
marks?: boolean | readonly MPSliderMark[];
|
|
22
49
|
/** The label above the track. */
|
|
23
50
|
label?: React.ReactNode;
|
|
24
51
|
/** The line under the track. */
|
|
@@ -54,6 +81,12 @@ export interface MPSliderProps {
|
|
|
54
81
|
name?: string;
|
|
55
82
|
/** The accessible name, for a slider with no visible `label`. */
|
|
56
83
|
'aria-label'?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Added to the slider's outermost element, which holds the label row as well
|
|
86
|
+
* as the track.
|
|
87
|
+
*/
|
|
88
|
+
className?: string;
|
|
89
|
+
style?: React.CSSProperties;
|
|
57
90
|
}
|
|
58
91
|
/**
|
|
59
92
|
* 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 a}from"react/jsx-runtime";import*as t from"react";import{Slider as r}from"@base-ui/react/slider";import{accentSlots as s}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as l,hasContent as i}from"../../internal/scale.js";import{useMPColor as o,useMPSize as m}from"../../internal/config.js";const u={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(" "),d={xs:"size-[2px]",sm:"size-[2px]",md:"size-[3px]",lg:"size-1",xl:"size-1.5"},p={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=/*@__PURE__*/t.forwardRef(function({value:f,defaultValue:h,onValueChange:g,onValueCommitted:b,min:x=0,max:v=100,step:w=1,marks:j,label:y,description:z,showValue:N=!1,format:_,orientation:k="horizontal",size:C,color:V,disabled:A=!1,name:M,"aria-label":S,className:$,style:I},B){const L=m(C),R=o(V),T="vertical"===k,F=u[L],P=t.useId(),X=f??h,Y=Array.isArray(X)?X.length:1,q=t.useMemo(()=>{if(!j||v<=x)return[];if(!0!==j)return j.filter(e=>e.value>=x&&e.value<=v);const e=Math.floor((v-x)/w);return!Number.isFinite(e)||e<1||e>50?[]:Array.from({length:e+1},(e,a)=>({value:x+a*w}))},[j,x,v,w]),[D,E]=t.useState(h),G=f??D,H=t.useMemo(()=>{const e=Array.isArray(G)?G:void 0===G?[]:[G];return 0===e.length?null:1===e.length?{from:x,to:e[0]}:{from:Math.min(...e),to:Math.max(...e)}},[G,x]),J=e=>(e-x)/(v-x)*100+"%";return a(r.Root,{ref:B,value:f,defaultValue:h,onValueChange:e=>{void 0===f&&E(e),g?.(e)},onValueCommitted:e=>b?.(e),min:x,max:v,step:w,disabled:A,orientation:k,format:_,name:M,"data-mp-size":L,className:["mp-slider flex",T?"w-fit flex-col items-center gap-2":"w-full flex-col gap-1",A?"cursor-default":"",$??""].filter(Boolean).join(" "),style:{...s(R),...I},children:[i(y)||N?a("div",{className:["flex w-full items-baseline gap-2",l].join(" "),children:[i(y)?e(r.Label,{className:A?"text-mp-on-surface/38":"text-mp-on-surface-variant",children:y}):null,N?e(r.Value,{className:["ms-auto tabular-nums",A?"text-mp-on-surface/38":"text-mp-on-surface"].join(" ")}):null]}):null,e(r.Control,{className:["mp-slider__control group/rail flex touch-none items-center justify-center select-none",T?`${F.stripCross} h-40 flex-col`:`w-full ${F.strip}`,A?"":"cursor-pointer"].filter(Boolean).join(" "),children:a(r.Track,{className:["mp-slider__track rounded-mp-full relative",T?`${F.cross} h-full`:`${F.thickness} w-full`,A?"bg-mp-on-surface/12":"bg-mp-surface-container-highest"].join(" "),children:[e(r.Indicator,{className:["rounded-mp-full","[transition-property:inset-inline-start,width,bottom,height]",c,"group-data-dragging/rail:transition-none",A?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")}),q.map(a=>{const t=null!==H&&a.value>=H.from&&a.value<=H.to;return e("span",{"aria-hidden":"true",className:["mp-slider__tick pointer-events-none absolute rounded-full",d[L],A?"bg-mp-on-surface/38":t?"bg-(--_mp-on-accent)":"bg-mp-on-surface-variant"].join(" "),style:T?{bottom:J(a.value),insetInlineStart:"50%",transform:"translate(-50%, 50%)"}:{insetInlineStart:J(a.value),top:"50%",transform:"translate(-50%, -50%)"}},`tick:${a.value}`)}),Array.from({length:Y},(a,t)=>e(r.Thumb,{index:t,"aria-label":i(y)?void 0:S,"aria-describedby":i(z)?P:void 0,className:["mp-slider__handle group rounded-mp-full relative outline-none","[transition-property:inset-inline-start,bottom]",c,"data-dragging:transition-none",F.handle,A?"bg-mp-on-surface/38 cursor-default":"bg-(--_mp-accent) cursor-grab active:cursor-grabbing"].join(" "),children:A?null:e(n,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",p[L],"bg-(--_mp-accent)"].join(" "),className:"group-data-dragging:opacity-16"})},t))]})}),q.some(e=>i(e.label))?e("div",{"aria-hidden":"true",className:["mp-slider__marks relative",l,T?"h-full":"w-full",A?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),style:T?void 0:{height:"1lh"},children:q.map(a=>i(a.label)?e("span",{className:"absolute whitespace-nowrap",style:T?{bottom:J(a.value),transform:"translateY(50%)"}:{insetInlineStart:J(a.value),transform:"translateX(-50%)"},children:a.label},`label:${a.value}`):null)}):null,i(z)?e("div",{id:P,className:[l,A?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:z}):null]})});
|
|
@@ -20,6 +20,25 @@ export type MPSnackbarPosition = `top-${MPAlign}` | `bottom-${MPAlign}`;
|
|
|
20
20
|
export interface MPSnackbarData {
|
|
21
21
|
color?: MPColor;
|
|
22
22
|
icon?: React.ReactNode | false;
|
|
23
|
+
/**
|
|
24
|
+
* Which stack this one joins, overriding the provider's `position`.
|
|
25
|
+
*
|
|
26
|
+
* For the message that has to be somewhere else *because of what it is* — a
|
|
27
|
+
* confirmation pinned under the thing it confirms, an error at the top of a
|
|
28
|
+
* page whose bottom corner is a toolbar. Not for a preference: an application
|
|
29
|
+
* whose snackbars all appear in the same wrong place should move the provider.
|
|
30
|
+
*
|
|
31
|
+
* All six stacks are on the page from the start whether or not anything is in
|
|
32
|
+
* them, which is not a detail: a stack is its own `aria-live` region, and a
|
|
33
|
+
* region added to the document at the same instant as the message inside it is
|
|
34
|
+
* a region a screen reader has nothing to compare against and does not read.
|
|
35
|
+
*/
|
|
36
|
+
position?: MPSnackbarPosition;
|
|
37
|
+
/**
|
|
38
|
+
* Added to this snackbar's plate — the element that draws the surface, not the
|
|
39
|
+
* stack around it.
|
|
40
|
+
*/
|
|
41
|
+
className?: string;
|
|
23
42
|
}
|
|
24
43
|
export interface MPSnackbarOptions extends MPSnackbarData {
|
|
25
44
|
/**
|
|
@@ -172,4 +191,4 @@ export declare function useMPSnackbar(): {
|
|
|
172
191
|
* is not part of Material Design 3 — so a `Toast` here would be a different
|
|
173
192
|
* component wearing the name of one the specification still ships.
|
|
174
193
|
*/
|
|
175
|
-
export declare function MPSnackbarProvider({ color, position, timeout, limit, width, size, showClose, closeLabel, locale: localeProp, children }: MPSnackbarProviderProps): React.JSX.Element;
|
|
194
|
+
export declare function MPSnackbarProvider({ color, position, timeout, limit, width, size: sizeProp, showClose, closeLabel, locale: localeProp, children }: MPSnackbarProviderProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as
|
|
2
|
+
import{jsx as t,jsxs as e}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 a}from"../../internal/accent.js";import{useMPLocale as r,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";import{useMPSize as u}from"../../internal/config.js";const f={"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"},b=/*@__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"},y={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"},h={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"},g={xs:16,sm:18,md:20,lg:22,xl:24};function v(t){const{color:e,icon:o,position:s,className:i,message:n,actionLabel:a,onAction:r,...l}=t;return{...l,title:n,data:{color:e,icon:o,position:s,className:i},actionProps:void 0===a?void 0:{children:a,onClick:r}}}export function useMPSnackbar(){const t=s.useToastManager();return o.useMemo(()=>({add:e=>t.add(v(e)),close:e=>t.close(e),update:(e,o)=>t.update(e,v(o)),promise:(e,o)=>t.promise(e,{loading:v(o.loading),success:t=>v("function"==typeof o.success?o.success(t):o.success),error:t=>v("function"==typeof o.error?o.error(t):o.error)}),snackbars:t.toasts}),[t])}function j({toast:o,color:r,size:l,showClose:m,closeLabel:p,swipeDirection:d,edge:u}){const f=o.data?.color??r,v=o.data?.icon,j={"--_mp-plate":f?`var(--_mp-color-${f}-container)`:"var(--_mp-color-inverse-surface)","--_mp-on-plate":f?`var(--_mp-color-on-${f}-container)`:"var(--_mp-color-inverse-on-surface)","--_mp-plate-action":f?`var(--_mp-color-${f})`:"var(--_mp-color-inverse-primary)",...f?a(f):null};return e(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",h[l],y[l],b,x[u],"data-limited:hidden",o.data?.className??""].filter(Boolean).join(" "),style:j,children:[v?t("span",{className:"flex shrink-0 items-center",children:v}):null,t(s.Title,{render:t("span",{}),className:"min-w-0 flex-1 py-0.5 ps-1 [min-inline-size:min(280px,100%)]"}),t(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?e(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:[t(c,{}),t(i,{icon:n,size:g[l]})]}):null]})}const w=["top-start","top-center","top-end","bottom-start","bottom-center","bottom-end"];function _({position:e,fallback:o,width:i,...n}){const{toasts:a}=s.useToastManager(),r=a.filter(t=>(t.data?.position??o)===e),l=e.startsWith("top")?"top":"bottom",m=["top"===l?"up":"down","left","right"];return t(s.Portal,{children:t(s.Viewport,{className:[d,"pointer-events-none fixed inset-x-0 flex flex-col gap-2 p-4",f[e]].join(" "),children:r.map(e=>t("div",{className:"w-full",style:{maxWidth:p(i)},children:t(j,{toast:e,swipeDirection:m,edge:l,...n})},e.id))})})}export function MPSnackbarProvider({color:o,position:i="bottom-start",timeout:n=5e3,limit:a=3,width:c=600,size:p,showClose:d=!0,closeLabel:f,locale:b,children:x}){const y=u(p),h=r(b),g=l(m,h);return e(s.Provider,{timeout:n,limit:a,children:[x,w.map(e=>t(_,{position:e,fallback:i,width:c,color:o,size:y,showClose:d,closeLabel:f??g.close},e))]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as o from"react";import{MPButton as i}from"../button/MPButton.js";import{inertProps as a}from"../../internal/inert.js";import{useMPLocale as n,useMPMessages as t}from"../../internal/locale.js";import{SPOILER as l}from"../../internal/messages/spoiler.js";import{hasContent as s,META_TEXT as d,SHEET_PAD as c,SHEET_PAD_X as m,SHEET_PAD_Y as p}from"../../internal/scale.js";import{CONTAINER_SURFACE as f}from"../../internal/surface.js";import{useMPColor as u,useMPSize as v}from"../../internal/config.js";const x="[background-color:color-mix(in_oklab,var(--_mp-color-surface)_55%,transparent)]";export const MPSpoiler=/*@__PURE__*/o.forwardRef(function({revealed:h,defaultRevealed:j=!1,onRevealedChange:b,locale:g,label:N,hideLabel:z,description:k,action:w,reversible:y=!1,maxHeight:B,blur:C=10,padded:R=!0,variant:_="outlined",size:H,color:M,className:P,children:S,...$},I){const L=v(H),q=u(M),A=n(g),D=t(l,A),E=o.useId(),[F,G]=o.useState(j),J=h??F,K=e=>{void 0===h&&G(e),b?.(e)},O=!1===k?null:k??D.notice;return r("div",{ref:I,"data-mp-size":L,"data-mp-variant":_,"data-mp-revealed":J||void 0,className:["mp-spoiler rounded-mp-md relative isolate overflow-hidden","box-border",f[_],"text-mp-on-surface",P??""].filter(Boolean).join(" "),...$,children:[e("div",{id:E,className:["min-w-0",R?c[L]:"","transition-[filter] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none",J?"":"select-none"].filter(Boolean).join(" "),style:{filter:J?void 0:`blur(${C}px)`,maxHeight:J?void 0:B,overflow:J?void 0:"hidden"},...a(!J),children:S}),J?null:r("div",{className:["absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 text-center",c[L],x].join(" "),children:[s(O)?e("p",{className:`text-mp-on-surface-variant m-0 ${d}`,children:O}):null,w??e(i,{variant:"tonal",size:L,color:q,onClick:()=>K(!0),"aria-expanded":!1,"aria-controls":E,children:N??D.reveal})]}),J&&y?e("div",{className:["flex justify-end",m[L],p[L],"pt-0"].join(" "),children:e(i,{variant:"text",size:L,color:q,onClick:()=>K(!1),"aria-expanded":!0,"aria-controls":E,children:z??D.hide})}):null]})});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPStepConnector, type MPStepStatus } from '../../internal/step.js';
|
|
3
|
+
import type { MPColor, MPOrientation, MPSize } from '../../types.js';
|
|
4
|
+
/** How far a step has got. The same three `MPTimeline` draws. */
|
|
5
|
+
export type MPStepStatusValue = MPStepStatus;
|
|
6
|
+
export interface MPStepperProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'onChange'> {
|
|
7
|
+
/**
|
|
8
|
+
* Which step is being worked on now, counting from zero. Everything before it
|
|
9
|
+
* is complete and everything after it is still to come.
|
|
10
|
+
*
|
|
11
|
+
* An index rather than a value, for the reason `MPTimeline`'s is: a step that
|
|
12
|
+
* had to be told where it was in the list would be a step every caller could
|
|
13
|
+
* put in the wrong place.
|
|
14
|
+
*/
|
|
15
|
+
active?: number;
|
|
16
|
+
/** Where an uncontrolled stepper starts. @default 0 */
|
|
17
|
+
defaultActive?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Called with the step that was pressed.
|
|
20
|
+
*
|
|
21
|
+
* **Leaving it out is what makes the steps unpressable.** A stepper with no
|
|
22
|
+
* handler is a progress indicator — it says where the reader is and offers no
|
|
23
|
+
* way to move, which is the right shape for a sequence the application drives
|
|
24
|
+
* with its own Next and Back buttons.
|
|
25
|
+
*/
|
|
26
|
+
onActiveChange?: (active: number) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a step can only be reached once the ones before it are done.
|
|
29
|
+
*
|
|
30
|
+
* On by default, because that is what a sequence *is*: a checkout that let
|
|
31
|
+
* somebody press Payment before Address would be offering a step it cannot
|
|
32
|
+
* complete. Off, every step is reachable at any time — a settings wizard, a
|
|
33
|
+
* form split into sections a reader can wander.
|
|
34
|
+
*
|
|
35
|
+
* A linear stepper still allows going **back**. What it refuses is jumping
|
|
36
|
+
* forward past the step the reader has actually reached.
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
linear?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Which way the sequence runs.
|
|
42
|
+
*
|
|
43
|
+
* `horizontal` is the default here and `vertical` is `MPTimeline`'s, and the
|
|
44
|
+
* two defaults disagree on purpose: a stepper is a small number of short
|
|
45
|
+
* labels across the top of a task, and a timeline is an arbitrary number of
|
|
46
|
+
* entries with an arbitrary amount to say about each.
|
|
47
|
+
* @default 'horizontal'
|
|
48
|
+
*/
|
|
49
|
+
orientation?: MPOrientation;
|
|
50
|
+
size?: MPSize;
|
|
51
|
+
color?: MPColor;
|
|
52
|
+
/** `MPStep` elements. Anything else is rendered where it is put. */
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export interface MPStepProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color'> {
|
|
56
|
+
/** What the step is called. */
|
|
57
|
+
label?: React.ReactNode;
|
|
58
|
+
/** A second line under it — what the step is for, or what it is waiting on. */
|
|
59
|
+
description?: React.ReactNode;
|
|
60
|
+
/**
|
|
61
|
+
* What goes inside the bullet.
|
|
62
|
+
*
|
|
63
|
+
* Left out, a complete step draws a tick, a failed one draws its error glyph
|
|
64
|
+
* and every other one draws its number — which is what a stepper's bullet is
|
|
65
|
+
* for, and why this is an override rather than the usual way in.
|
|
66
|
+
*/
|
|
67
|
+
bullet?: React.ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* Marks the step as failed. It is drawn in `error` and keeps its place in the
|
|
70
|
+
* sequence rather than being removed, because a sequence with a hole in it is
|
|
71
|
+
* one the reader cannot count.
|
|
72
|
+
*/
|
|
73
|
+
error?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* A note under the label — *Optional*, *Skipped*, *2 of 3 done*.
|
|
76
|
+
*
|
|
77
|
+
* A node rather than a boolean, and that is not a small difference: a boolean
|
|
78
|
+
* would mean this library shipping the **word** *Optional*, which would then
|
|
79
|
+
* need a translation in eighteen languages for a label only some applications
|
|
80
|
+
* ever draw. The caller has the word already, in their own copy and their own
|
|
81
|
+
* language.
|
|
82
|
+
*/
|
|
83
|
+
optional?: React.ReactNode;
|
|
84
|
+
/** Refuses the press whatever the reachability rule says. */
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* How the line to the next step is drawn.
|
|
88
|
+
* @default 'solid'
|
|
89
|
+
*/
|
|
90
|
+
connector?: MPStepConnector;
|
|
91
|
+
color?: MPColor;
|
|
92
|
+
/**
|
|
93
|
+
* The step's own panel, drawn **only while the step is active**.
|
|
94
|
+
*
|
|
95
|
+
* Which is the half a stepper has that a timeline does not: a wizard is a rail
|
|
96
|
+
* and one panel, and keeping the other panels mounted would mean a form whose
|
|
97
|
+
* hidden fields still submit.
|
|
98
|
+
*/
|
|
99
|
+
children?: React.ReactNode;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A sequence being worked through, with one panel at a time.
|
|
103
|
+
*
|
|
104
|
+
* ```tsx
|
|
105
|
+
* const [step, setStep] = useState(0);
|
|
106
|
+
*
|
|
107
|
+
* <MPStepper active={step} onActiveChange={setStep}>
|
|
108
|
+
* <MPStep label="Account">…</MPStep>
|
|
109
|
+
* <MPStep label="Payment">…</MPStep>
|
|
110
|
+
* <MPStep label="Done">…</MPStep>
|
|
111
|
+
* </MPStepper>;
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* ## How it differs from `MPTimeline`
|
|
115
|
+
*
|
|
116
|
+
* They draw the same picture from the same table — see `internal/step.ts` — and
|
|
117
|
+
* they are two components because they are two jobs:
|
|
118
|
+
*
|
|
119
|
+
* | | `MPTimeline` | `MPStepper` |
|
|
120
|
+
* | --- | --- | --- |
|
|
121
|
+
* | The sequence | happened | is being worked through |
|
|
122
|
+
* | The steps | are read | are pressed |
|
|
123
|
+
* | The content | is all on screen | is one panel |
|
|
124
|
+
* | Default orientation | `vertical` | `horizontal` |
|
|
125
|
+
*
|
|
126
|
+
* A stepper with no `onActiveChange` is the overlap: unpressable, one panel, and
|
|
127
|
+
* a progress indicator for a sequence the application's own Next and Back
|
|
128
|
+
* buttons drive.
|
|
129
|
+
*
|
|
130
|
+
* ## It ships no Next and Back
|
|
131
|
+
*
|
|
132
|
+
* On purpose. Those buttons belong to the form: what "next" means is whether the
|
|
133
|
+
* current step validates, and a library that drew them would either have to
|
|
134
|
+
* guess that or ask for a validator per step. `onActiveChange` and two
|
|
135
|
+
* `MPButton`s is four lines, and they are four lines the caller can read.
|
|
136
|
+
*
|
|
137
|
+
* ## Reachability
|
|
138
|
+
*
|
|
139
|
+
* `linear` decides which steps a press is allowed to reach. Going **back** is
|
|
140
|
+
* always allowed; what a linear stepper refuses is jumping forward past the step
|
|
141
|
+
* the reader has actually got to. An unreachable step is `aria-disabled` rather
|
|
142
|
+
* than removed from the tab order, so a reader arrowing along the rail is told
|
|
143
|
+
* *why* it will not open instead of finding a gap.
|
|
144
|
+
*/
|
|
145
|
+
export declare const MPStepper: React.ForwardRefExoticComponent<MPStepperProps & React.RefAttributes<HTMLDivElement>>;
|
|
146
|
+
/**
|
|
147
|
+
* One step in a sequence.
|
|
148
|
+
*
|
|
149
|
+
* Its index is not a prop and cannot be, for the reason `MPTimelineItem`'s is
|
|
150
|
+
* not: a step told where it was in the list is a step every caller could put in
|
|
151
|
+
* the wrong place. The stepper numbers its children as it walks them.
|
|
152
|
+
*/
|
|
153
|
+
export declare const MPStep: React.ForwardRefExoticComponent<MPStepProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import*as n from"react";import{MPIcon as r}from"../icon/MPIcon.js";import{CheckIcon as o,ErrorIcon as a}from"../../constants/icons.js";import{accentSlots as i}from"../../internal/accent.js";import{hasContent as s,META_TEXT as c,SHEET_TITLE as p}from"../../internal/scale.js";import{BORDER_STYLE as m,BULLET as u,BULLET_GAP as d,BULLET_SIZE as f,CONNECTOR_COLOR as x,ITEM_GAP as h,ITEM_GAP_X as v,TITLE_COLOR as b}from"../../internal/step.js";import{useMPColor as _,useMPSize as j}from"../../internal/config.js";const N=/*@__PURE__*/n.createContext(null),g=/*@__PURE__*/n.createContext(0);export const MPStepper=/*@__PURE__*/n.forwardRef(function({active:l,defaultActive:r=0,onActiveChange:o,linear:a=!0,orientation:s="horizontal",size:c,color:p,className:m,style:u,children:d,...x},h){const v=j(c),b=_(p),[y,z]=n.useState(r),C=l??y,[S,$]=n.useState(C);C>S&&$(C);const P=n.Children.toArray(d).filter(n.isValidElement),k=P.length,M=n.useCallback(e=>{void 0===l&&z(e),o?.(e)},[l,o]),A=n.useMemo(()=>({size:v,color:b,orientation:s,active:C,onSelect:o||void 0===l?M:null,linear:a,count:k,furthest:S}),[v,b,s,C,o,l,M,a,k,S]),B="horizontal"===s;return e(N.Provider,{value:A,children:t("div",{...x,ref:h,"data-mp-size":v,className:["mp-stepper flex flex-col",m??""].filter(Boolean).join(" "),style:{...i(b),...u},children:[e("ol",{className:["mp-stepper__rail flex list-none p-0",B?"flex-row items-start":"flex-col"].join(" "),style:{"--_mp-bullet":f[v]},children:P.map((t,l)=>e(g.Provider,{value:l,children:t},l))}),e(w,{steps:P,active:C})]})})});function w({steps:t,active:l}){const n=t[l],r=n?.props.children;return s(r)?e("div",{className:"mp-stepper__panel mt-4",role:"group","aria-label":void 0,children:r}):null}export const MPStep=/*@__PURE__*/n.forwardRef(function({label:f,description:_,bullet:j,error:w=!1,optional:y,disabled:z=!1,connector:C="solid",color:S,className:$,style:P,children:k,...M},A){const B=n.useContext(N),R=n.useContext(g),E=B?.size??"md",F=B?.orientation??"horizontal",I=B?.active??0,V=B?.count??1,q=B?.furthest??0,D=B?.linear??!0,G=R<I?"complete":R===I?"current":"upcoming",H=S??(w?"error":B?.color??"primary"),J="horizontal"===F,K=R===V-1,L="none"!==C&&!K,O=!z&&(!D||R<=q),Q=null!=B?.onSelect&&O,T=j??("complete"!==G||w?w?e(r,{icon:a}):R+1:e(r,{icon:o})),U=e("span",{"aria-hidden":"true",className:["rounded-mp-full relative z-10 flex shrink-0 items-center justify-center","size-(--_mp-bullet) text-[calc(var(--_mp-bullet)*0.5)] leading-none font-medium","tabular-nums [&>svg]:size-[0.6em]",u[G],"transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4)"].join(" "),children:T}),W=L?e("span",{"aria-hidden":"true",className:["pointer-events-none absolute",J?"start-(--_mp-bullet) top-[calc(var(--_mp-bullet)/2_-_1px)] end-0 border-t-2":"top-(--_mp-bullet) start-[calc(var(--_mp-bullet)/2_-_1px)] bottom-0 border-s-2",m[C],x[G]].filter(Boolean).join(" ")}):null,X=t("span",{className:"flex min-w-0 flex-col gap-0.5 text-start "+(J?"mt-2":""),children:[s(f)?e("span",{className:`${p[E]} ${w?"text-mp-error":b[G]}`,children:f}):null,s(y)?e("span",{className:`text-mp-on-surface-variant ${c}`,children:y}):null,s(_)?e("span",{className:`text-mp-on-surface-variant ${c}`,children:_}):null]}),Y=t(l,{children:[W,t("span",{className:`flex min-w-0 ${J?"flex-col items-start":"flex-row"} ${J?"":d[E]}`,children:[U,X]})]});return e("li",{...M,ref:A,"aria-current":"current"===G?"step":void 0,className:["mp-stepper__step relative min-w-0",J?`flex-1 ${K?"":v[E]}`:K?"":h[E],$??""].filter(Boolean).join(" "),style:{...S||w?i(H):null,...P},children:Q?e("button",{type:"button",className:["group relative flex w-full min-w-0 cursor-pointer appearance-none bg-transparent p-0 text-start","outline-mp-secondary rounded-mp-xs focus-visible:outline-2 focus-visible:outline-offset-2","outline-none"].join(" "),onClick:()=>B?.onSelect?.(R),children:Y}):e("span",{className:"relative flex w-full min-w-0","aria-disabled":!(!B?.onSelect||O)||void 0,children:Y})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPStepper,MPStep}from"./MPStepper.js";
|
|
@@ -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
|
|
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";import{useMPColor as u,useMPSize as f}from"../../internal/config.js";const g={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:k,defaultChecked:b,onCheckedChange:x,label:y,description:j,errorMessage:z,icons:w=!1,labelPlacement:N="end",size:_,color:C,required:M=!1,disabled:v=!1,readOnly:P=!1,name:R,id:S,fullWidth:W=!1,className:q,style:B},F){const I=f(_),L=u(C),O=p(z),T=O?"error":L,A=g[I],D=r.useId(),E=S??D,G=e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(n.Root,{ref:F,id:E,name:R,checked:k,defaultChecked:b,required:M,disabled:v,readOnly:P,onCheckedChange:e=>x?.(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",A.track,v?["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(" "):[P?"cursor-default":"cursor-pointer","bg-mp-surface-container-highest inset-ring-2",O?"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",A.thumb,v?"bg-mp-on-surface/38 data-checked:bg-mp-surface-container-highest":[O?"bg-mp-error":"bg-mp-outline","data-checked:bg-(--_mp-on-accent)"].join(" ")].join(" "),children:[v?null:e(d,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",A.halo,"bg-mp-on-surface group-data-checked:bg-(--_mp-accent)"].join(" ")}),w?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",v?"text-mp-surface-container-highest":"text-(--_mp-accent)"].join(" "),children:e(s,{icon:o,size:A.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:A.glyph,strokeWidth:3})})]}):null]})})}),H=p(y)||p(j)||O?a("span",{className:["flex min-w-0 flex-col gap-0.5","start"===N?"flex-1":""].filter(Boolean).join(" "),children:[p(y)?a(i.Label,{htmlFor:E,className:["leading-[1.4]",v?"text-mp-on-surface/38 cursor-default":P?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:[y,M?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(h,{description:j,errorMessage:z})]}):null;return e(i.Root,{className:["mp-switch align-top",W?"flex w-full":"inline-flex",q??""].filter(Boolean).join(" "),disabled:v,invalid:O,"data-mp-size":I,style:{...l(T),...B},children:e("div",{className:["flex w-full items-start gap-3",m[I]].join(" "),children:a(t,"start"===N?{children:[H,G]}:{children:[G,H]})})})});
|
|
@@ -139,4 +139,4 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
139
139
|
* than a ref on the scroll container is worth — and a caller who needs one can
|
|
140
140
|
* put it on a `<div>` of their own around this.
|
|
141
141
|
*/
|
|
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;
|
|
142
|
+
export declare function MPTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, striped, hoverable, stickyHeader, onRowClick, variant, size: sizeProp, color: colorProp, 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*as r from"react";import{accentSlots as l}from"../../internal/accent.js";import{useMPLocale as o,useMPMessages 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 n}from"../../internal/locale.js";import{TABLE as a}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";import{useMPColor as c,useMPSize as d}from"../../internal/config.js";const p={xs:"0.625rem",sm:"0.75rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},u={xs:"0.375rem",sm:"0.625rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},x={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"},f={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"},y=/*@__PURE__*/["[--_mp-row:transparent]","transition-[background-color] duration-(--mp-sys-motion-duration-short4)"].join(" ");function g(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:b,getRowKey:h,caption:v,empty:j,locale:w,striped:k=!1,hoverable:N=!1,stickyHeader:_=!1,onRowClick:C,variant:$="outlined",size:A,color:B,className:z,style:T,...D}){const E=d(A),K=c(B),R=n(a,o(w)),H=p[E],I=u[E],M=Boolean(C),P=N||M,S={padding:`${I} ${H}`},V={...S,backgroundColor:"var(--_mp-color-surface-container)"},q={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"};return e("div",{"data-mp-size":E,"data-mp-variant":$,className:["mp-table rounded-mp-md overflow-x-auto",s[$],z??""].filter(Boolean).join(" "),style:{...l(K),...T},...D,children:t("table",{className:`text-mp-on-surface w-full text-start ${x[E]}`,style:{borderCollapse:"collapse"},children:[v?e("caption",{className:`text-mp-on-surface-variant ${m}`,style:{...S,textAlign:"start"},children:v}):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",f[E],_?"sticky top-0 z-10":""].filter(Boolean).join(" "),style:{...V,textAlign:t.align??"start"},children:t.label??t.key},t.key))})}),e("tbody",{children:0===b.length?e("tr",{className:y,style:q,children:e("td",{colSpan:r.length,className:"text-mp-on-surface-variant",style:{padding:`2rem ${H}`,textAlign:"center"},children:j??R.empty})}):b.map((t,l)=>e("tr",{className:[y,k&&l%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",P?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",M?["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:q,tabIndex:M?0:void 0,onClick:C?()=>C(t,l):void 0,onKeyDown:C?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),C(t,l))}:void 0,children:r.map(r=>e("td",{style:{...S,textAlign:r.align??"start"},children:r.render?r.render(t,l):g(t[r.key])},r.key))},h?h(t,l):l))})]})})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Tabs as i}from"@base-ui/react/tabs";import{accentSlots as o}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{CONTROL_GAP as r,hasContent as l,SHEET_GAP as s}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{Tabs as i}from"@base-ui/react/tabs";import{accentSlots as o}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{CONTROL_GAP as r,hasContent as l,SHEET_GAP as s}from"../../internal/scale.js";import{useMPColor as c,useMPSize as m}from"../../internal/config.js";const u=/*@__PURE__*/a.createContext({variant:"primary",size:"md",iconPosition:"top",fullWidth:!1}),p={xs:"h-8",sm:"h-10",md:"h-12",lg:"h-14",xl:"h-16"},d={xs:"h-11",sm:"h-13",md:"h-16",lg:"h-18",xl:"h-20"},f={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-title-small",lg:"text-mp-title-small",xl:"text-mp-title-medium"},h={xs:"px-3",sm:"px-3.5",md:"px-4",lg:"px-5",xl:"px-6"},x={xs:12,sm:14,md:16,lg:20,xl:24},v={xs:18,sm:20,md:24,lg:24,xl:28};function b(e,t,i,o=""){a.Children.toArray(e).forEach(e=>{if(!a.isValidElement(e))return void(l(e)&&t.push(e));if(e.type===a.Fragment)return void b(e.props.children,t,i,`${o}${String(e.key)}/`);const n=o?a.cloneElement(e,{key:`${o}${String(e.key)}`}):e;e.type===MPTabPanel?i.push(n):t.push(n)})}export const MPTabs=/*@__PURE__*/a.forwardRef(function({variant:n="primary",color:r,size:l,value:p,defaultValue:d,onValueChange:f,iconPosition:h,activateOnFocus:v=!1,loopFocus:y=!0,divider:g=!0,fullWidth:_=!1,className:w,style:j,children:P,"aria-label":N,...k},M){const $=c(r),z=m(l),C=h??("primary"===n?"top":"start"),F=a.useMemo(()=>({variant:n,size:z,iconPosition:C,fullWidth:_}),[n,z,C,_]),T=[],V=[];return b(P,T,V),e(u.Provider,{value:F,children:t(i.Root,{ref:M,value:p,defaultValue:d,onValueChange:e=>f?.(e),"data-mp-size":z,"data-mp-variant":n,className:["mp-tabs flex min-w-0 flex-col",s[z],w??""].filter(Boolean).join(" "),style:{...o($),"--_mp-tab-inset":`${x[z]}px`,...j},...k,children:[t(i.List,{"aria-label":N,activateOnFocus:v,loopFocus:y,className:["mp-tabs__list relative flex shrink-0",g?"border-mp-outline-variant border-b":"",_?"w-full":"","overflow-x-auto overflow-y-hidden"].filter(Boolean).join(" "),children:[T,e(i.Indicator,{className:["mp-tabs__indicator pointer-events-none absolute bottom-0","bg-(--_mp-accent)","primary"===n?["h-0.75 rounded-t-full","left-[calc(var(--active-tab-left)_+_var(--_mp-tab-inset))]","w-[calc(var(--active-tab-width)_-_2_*_var(--_mp-tab-inset))]"].join(" "):"left-(--active-tab-left) h-0.5 w-(--active-tab-width)","[transition-property:left,width]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard"].join(" ")})]}),V]})})});export const MPTab=/*@__PURE__*/a.forwardRef(function({value:o,icon:s,disabled:c=!1,className:m,children:x,...b},y){const{variant:g,size:_,iconPosition:w,fullWidth:j}=a.useContext(u),P="top"===w&&l(s);return t(i.Tab,{ref:y,value:o,disabled:c,className:["mp-tabs__tab group relative flex shrink-0 items-center justify-center","box-border appearance-none bg-transparent font-[inherit] whitespace-nowrap select-none","overflow-hidden outline-none","transition-[color] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",P?`flex-col gap-1 ${d[_]}`:`flex-row ${p[_]}`,P?"":r[_],f[_],h[_],c?"text-mp-on-surface/38 cursor-default":["text-mp-on-surface-variant cursor-pointer","primary"===g?"data-active:text-(--_mp-accent)":"data-active:text-mp-on-surface"].join(" "),"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid",j?"flex-1":"",m??""].filter(Boolean).join(" "),...b,children:[c?null:e(n,{}),l(s)?e("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:v[_],height:v[_]},children:s}):null,l(x)?e("span",{className:"relative truncate",children:x}):null]})});export const MPTabPanel=/*@__PURE__*/a.forwardRef(function({value:t,keepMounted:a=!1,className:o,children:n,...r},l){return e(i.Panel,{ref:l,value:t,keepMounted:a,className:["mp-tabs__panel text-mp-on-surface min-w-0 flex-1","rounded-mp-xs outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-opacity duration-(--mp-sys-motion-duration-short4) ease-mp-standard","data-starting-style:opacity-0",o??""].filter(Boolean).join(" "),...r,children:n})});
|