material-plus-ui 1.5.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/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.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.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 +21 -2
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.js +1 -1
- package/dist/components/navigation-menu/MPNavigationMenu.js +1 -1
- package/dist/components/number-field/MPNumberField.d.ts +3 -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.js +1 -1
- package/dist/components/rating/MPRating.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +2 -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 +27 -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.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 +38 -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,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{accentSlots as i}from"../../internal/accent.js";import{inertProps as r}from"../../internal/inert.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{CONTROL_GAP as a,CONTROL_ICON as l,CONTROL_TEXT as c,hasContent as m,META_TEXT as d,PROSE_TEXT as p,SHEET_PAD_X as u}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{accentSlots as i}from"../../internal/accent.js";import{inertProps as r}from"../../internal/inert.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{CONTROL_GAP as a,CONTROL_ICON as l,CONTROL_TEXT as c,hasContent as m,META_TEXT as d,PROSE_TEXT as p,SHEET_PAD_X as u}from"../../internal/scale.js";import{useMPSize as f}from"../../internal/config.js";const h={xs:"min-h-8",sm:"min-h-10",md:"min-h-14",lg:"min-h-16",xl:"min-h-18"},x={xs:"px-4",sm:"px-5",md:"px-6",lg:"px-8",xl:"px-10"},b={filled:"shadow-mp-2 bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"shadow-mp-2 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-2 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline shadow-mp-1 border bg-mp-surface-container text-mp-on-surface",text:"shadow-mp-1 bg-mp-surface-container text-mp-on-surface"},w={static:{top:"",bottom:""},sticky:{top:"sticky top-3 z-20",bottom:"sticky bottom-3 z-20"},fixed:{top:"fixed inset-x-0 top-3 z-30 mx-auto w-fit",bottom:"fixed inset-x-0 bottom-3 z-30 mx-auto w-fit"}};export const MPPill=/*@__PURE__*/o.forwardRef(function({startIcon:g,endIcon:v,title:j,description:y,details:N,expanded:k=!1,position:_="static",side:z="top",onClick:B,variant:C="filled",size:I,color:R="secondary",className:$,style:H,children:P,...S},E){const F=f(I),L=o.useRef(null),M=o.useId(),[O,q]=o.useState(0);o.useEffect(()=>{const e=L.current;if(!e)return;const t=new ResizeObserver(()=>q(e.scrollHeight));return t.observe(e),q(e.scrollHeight),()=>t.disconnect()},[N]);const A=Boolean(B),D=u[F],G=t(n,{children:[m(g)?e("span",{className:"flex shrink-0 items-center justify-center overflow-hidden rounded-mp-full [&_img]:size-full [&_img]:object-cover",style:{width:l[F],height:l[F]},children:g}):null,m(j)||m(y)||m(P)?t("span",{className:["flex min-w-0 flex-1 flex-col items-center justify-center text-center",x[F]].join(" "),children:[m(j)?e("span",{className:"max-w-full truncate",children:j}):null,m(y)?e("span",{className:`max-w-full truncate font-normal ${d} [color:color-mix(in_oklab,currentColor_72%,transparent)]`,children:y}):null,P]}):null]});return t("div",{ref:E,"data-mp-size":F,"data-mp-variant":C,"data-mp-expanded":k||void 0,className:["mp-pill inline-flex max-w-full flex-col overflow-hidden align-middle","box-border whitespace-nowrap select-none",k?"rounded-mp-xl":"rounded-mp-full","transition-[border-radius,background-color,box-shadow]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none",c[F],b[C],w[_][z],$??""].filter(Boolean).join(" "),style:{...i(R),...H},...S,children:[t("div",{className:["flex shrink-0 items-center py-1",h[F],a[F],A?"ps-0":D,m(v)?"pe-1":A?"pe-0":""].filter(Boolean).join(" "),children:[A?t("button",{type:"button",className:["group relative flex min-w-0 flex-1 cursor-pointer items-center justify-center","self-stretch appearance-none border-0 bg-transparent font-[inherit] text-inherit","rounded-[inherit]",a[F],D,"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),"aria-expanded":m(N)?k:void 0,"aria-controls":m(N)?M:void 0,onClick:B,children:[e(s,{}),G]}):G,m(v)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:v}):null]}),m(N)?e("div",{id:M,className:["overflow-hidden","transition-[height] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none"].join(" "),style:{height:k?O:0},...r(!k),children:e("div",{ref:L,className:`${D} pb-2 whitespace-normal ${p[F]}`,children:N})}):null]})});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPAlign, MPColor, MPSide, MPSize } from '../../types.js';
|
|
3
|
+
export interface MPPopconfirmProps {
|
|
4
|
+
/**
|
|
5
|
+
* The control that asks, and that the question hangs off. Exactly one element,
|
|
6
|
+
* and it must accept a ref and spread props — every Material Plus component
|
|
7
|
+
* does.
|
|
8
|
+
*/
|
|
9
|
+
trigger: React.ReactElement;
|
|
10
|
+
/** The question, as the popup's heading. */
|
|
11
|
+
title?: React.ReactNode;
|
|
12
|
+
/** A line under it — what happens, and to what. */
|
|
13
|
+
description?: React.ReactNode;
|
|
14
|
+
/** Anything else the popup should hold. */
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* Called when the reader says yes.
|
|
18
|
+
*
|
|
19
|
+
* A callback rather than a promise, and that is the whole difference from
|
|
20
|
+
* [`useMPConfirm`](../feedback/confirm): this one is written where the button
|
|
21
|
+
* is, so there is already a handler there to put it in.
|
|
22
|
+
*/
|
|
23
|
+
onConfirm?: () => void;
|
|
24
|
+
/** Called when they say no. Dismissing counts — see `onOpenChange`. */
|
|
25
|
+
onCancel?: () => void;
|
|
26
|
+
/** What the yes button says. @default the translation of `Confirm` */
|
|
27
|
+
confirmLabel?: React.ReactNode;
|
|
28
|
+
/** What the no button says. @default the translation of `Cancel` */
|
|
29
|
+
cancelLabel?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The accent the yes button is drawn in. `'error'` is what a destructive
|
|
32
|
+
* question wants, and it is not the default for the reason `useMPConfirm`
|
|
33
|
+
* gives: a red button on every confirmation stops being a warning.
|
|
34
|
+
*/
|
|
35
|
+
color?: MPColor;
|
|
36
|
+
/** Which edge of the trigger the question appears on. @default 'top' */
|
|
37
|
+
side?: MPSide;
|
|
38
|
+
/** @default 'center' */
|
|
39
|
+
align?: MPAlign;
|
|
40
|
+
/** @default true */
|
|
41
|
+
arrow?: boolean;
|
|
42
|
+
size?: MPSize;
|
|
43
|
+
open?: boolean;
|
|
44
|
+
defaultOpen?: boolean;
|
|
45
|
+
onOpenChange?: (open: boolean) => void;
|
|
46
|
+
className?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A confirmation that stays where the control is.
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <MPPopconfirm
|
|
53
|
+
* trigger={<MPButton color="error">Delete</MPButton>}
|
|
54
|
+
* title="Delete this row?"
|
|
55
|
+
* confirmLabel="Delete"
|
|
56
|
+
* color="error"
|
|
57
|
+
* onConfirm={() => remove(id)}
|
|
58
|
+
* />
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* ## When this rather than `useMPConfirm`
|
|
62
|
+
*
|
|
63
|
+
* They ask the same question and the difference is **where the reader's eye
|
|
64
|
+
* is**, which is a real difference and not a stylistic one:
|
|
65
|
+
*
|
|
66
|
+
* | | `MPPopconfirm` | [`useMPConfirm`](../feedback/confirm) |
|
|
67
|
+
* | --- | --- | --- |
|
|
68
|
+
* | Appears | at the control | in the middle of the screen |
|
|
69
|
+
* | The page behind | stays put | goes under a scrim |
|
|
70
|
+
* | Costs | one element | a provider |
|
|
71
|
+
* | Answers with | a callback | a promise |
|
|
72
|
+
*
|
|
73
|
+
* A row of twelve delete buttons is the case for this one: a modal that covered
|
|
74
|
+
* the table would take away the row the reader was pointing at, and having to
|
|
75
|
+
* re-find it afterwards is how the wrong row gets deleted. A confirmation about
|
|
76
|
+
* the *page* — leaving with unsaved changes, an irreversible account action —
|
|
77
|
+
* wants the modal, because it is not about a thing on the page at all.
|
|
78
|
+
*
|
|
79
|
+
* ## Every other way out is *no*
|
|
80
|
+
*
|
|
81
|
+
* Escape, a press outside and the cancel button all close it without confirming,
|
|
82
|
+
* and `onCancel` is called for all three. That is the same rule `useMPConfirm`
|
|
83
|
+
* follows and for the same reason: the safe answer to "are you sure" is no.
|
|
84
|
+
*
|
|
85
|
+
* ## It is a popover, not a dialog
|
|
86
|
+
*
|
|
87
|
+
* So it does not trap the focus and the page behind it stays live. That is the
|
|
88
|
+
* point of the shape — but it also means a reader can walk away from the
|
|
89
|
+
* question with Tab, which a modal would not allow. Use the modal where the
|
|
90
|
+
* answer genuinely has to be given.
|
|
91
|
+
*/
|
|
92
|
+
export declare function MPPopconfirm({ trigger, title, description, children, onConfirm, onCancel, confirmLabel, cancelLabel, color: colorProp, side, align, arrow, size: sizeProp, open: openProp, defaultOpen, onOpenChange, className }: MPPopconfirmProps): React.JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as o from"react";import{MPButton as n}from"../button/MPButton.js";import{MPPopover as i}from"../popover/MPPopover.js";import{useMPLocale as t,useMPMessages as a}from"../../internal/locale.js";import{CONFIRM as s}from"../../internal/messages/confirm.js";import{useMPColor as c,useMPSize as l}from"../../internal/config.js";export function MPPopconfirm({trigger:m,title:p,description:f,children:d,onConfirm:g,onCancel:j,confirmLabel:u,cancelLabel:h,color:x,side:v="top",align:C="center",arrow:P=!0,size:z,open:b,defaultOpen:M,onOpenChange:N,className:O}){const k=l(z),w=c(x),L=a(s,t()),[y,B]=o.useState(M??!1),S=e=>{void 0===b&&B(e),N?.(e)},q=e=>{S(!1),e?g?.():j?.()};return r(i,{trigger:m,title:p,description:f,side:v,align:C,arrow:P,size:k,open:b??y,onOpenChange:e=>{e?S(!0):q(!1)},className:O,children:[d,r("div",{className:"mt-3 flex justify-end gap-1",children:[e(n,{variant:"text",size:"sm",onClick:()=>q(!1),children:h??L.cancel}),e(n,{variant:"text",size:"sm",color:w,onClick:()=>q(!0),children:u??L.confirm})]})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPPopconfirm}from"./MPPopconfirm.js";
|
|
@@ -140,4 +140,4 @@ export declare const MPPopoverClose: React.ForwardRefExoticComponent<Omit<import
|
|
|
140
140
|
* dialog's `surface-container-high` at elevation 3, because a popover has not
|
|
141
141
|
* taken the page and should not sit above the menus that did not either.
|
|
142
142
|
*/
|
|
143
|
-
export declare function MPPopover({ trigger, title, description, side, align, sideOffset, alignOffset, arrow, open, defaultOpen, onOpenChange, modal, dismissible, showClose, closeLabel, locale: localeProp, width, size, className, style, children }: MPPopoverProps): React.JSX.Element;
|
|
143
|
+
export declare function MPPopover({ trigger, title, description, side, align, sideOffset, alignOffset, arrow, open, defaultOpen, onOpenChange, modal, dismissible, showClose, closeLabel, locale: localeProp, width, size: sizeProp, className, style, children }: MPPopoverProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Popover as
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Popover as i}from"@base-ui/react/popover";import{MPIcon as s}from"../icon/MPIcon.js";import{CloseIcon as t}from"../../constants/icons.js";import{useMPLocale as r,useMPMessages as a}from"../../internal/locale.js";import{cssLength as l}from"../../internal/length.js";import{COMMON as n}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{hasContent as c,META_TEXT as d,PROSE_TEXT as p,SHEET_GAP as f,SHEET_PAD as u,SHEET_TITLE as h}from"../../internal/scale.js";import{FADE as x,PORTAL_LAYER as g}from"../../internal/surface.js";import{useMPSize as v}from"../../internal/config.js";const b={xs:"max-w-56",sm:"max-w-64",md:"max-w-80",lg:"max-w-96",xl:"max-w-lg"},j={xs:8,sm:9,md:10,lg:11,xl:12};export const MPPopoverClose=i.Close;export function MPPopover({trigger:w,title:N,description:O,side:P="bottom",align:y="center",sideOffset:C=8,alignOffset:z=0,arrow:k=!1,open:M,defaultOpen:L,onOpenChange:B,modal:T=!1,dismissible:$=!0,showClose:A=!1,closeLabel:D,locale:I,width:R,size:S,className:W,style:_,children:q}){const E=v(S),F=r(I),G=a(n,F),H=c(N)||c(O),J=j[E];return o(i.Root,{open:M,defaultOpen:L,modal:T,onOpenChange:(e,o)=>{$||e||"escape-key"!==o.reason&&"outside-press"!==o.reason&&"focus-out"!==o.reason?B?.(e):o.cancel()},children:[w?e(i.Trigger,{render:w}):null,e(i.Portal,{children:e(i.Positioner,{className:g,side:P,align:y,sideOffset:C,alignOffset:z,children:o(i.Popup,{"data-mp-size":E,className:["mp-popover rounded-mp-md relative flex flex-col outline-none","bg-mp-surface-container text-mp-on-surface shadow-mp-2","box-border",u[E],f[E],p[E],void 0===R?b[E]:"",x,W??""].filter(Boolean).join(" "),style:{...void 0===R?null:{maxWidth:l(R)},..._},children:[k?e(i.Arrow,{className:["data-[side=top]:bottom-[-1px]","data-[side=bottom]:top-[-1px] data-[side=bottom]:rotate-180","data-[side=left]:right-[-1px] data-[side=left]:-rotate-90","data-[side=right]:left-[-1px] data-[side=right]:rotate-90"].join(" "),children:e("svg",{width:J,height:J/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:e("path",{d:"M0 0h10L5 5z",fill:"var(--_mp-color-surface-container)"})})}):null,H||A?o("div",{className:"flex shrink-0 items-start gap-3",children:[o("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(N)?e(i.Title,{className:`m-0 ${h[E]}`,children:N}):null,c(O)?e(i.Description,{className:`text-mp-on-surface-variant m-0 ${d}`,children:O}):null]}),A?o(i.Close,{"aria-label":D??G.close,className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","rounded-mp-full -m-1 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(m,{}),e(s,{icon:t,size:18})]}):null]}):null,c(q)?e("div",{className:"min-w-0",children:q}):null]})})})]})}
|
|
@@ -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 l from"react";import{Progress as n}from"@base-ui/react/progress";import{accentSlots as r}from"../../internal/accent.js";import{VISUALLY_HIDDEN as s}from"../../internal/visually-hidden.js";import{META_TEXT as t,STACK_GAP as o}from"../../internal/scale.js";import{SEGMENT_GAP as i,SEGMENT_RADIUS as m,SEGMENT_SIZE as c,progressAriaText as u,progressFraction as f,progressText as p}from"../../internal/progress.js";import{useMPColor as d,useMPSize as h}from"../../internal/config.js";export const MPProgressBox=/*@__PURE__*/l.forwardRef(function({size:l,color:x,count:b=4,value:g=null,min:j=0,max:v=100,label:y,hideLabel:N=!1,showValue:w=!1,format:M,className:B,style:L},V){const _=h(l),k=d(x),z=f(g,j,v),A=null===z,P=void 0!==M,R=N?null:y,T=Math.max(1,Math.floor(b));return a(n.Root,{ref:V,value:null===z?null:g??null,min:j,max:v,format:M,getAriaValueText:u(z,P),"data-mp-size":_,className:["mp-progress-box inline-flex flex-col",o[_],B??""].filter(Boolean).join(" "),style:{...r(k),...L},children:[N&&y?e(n.Label,{className:s,children:y}):null,R||w?a("div",{className:["flex items-baseline gap-2",R?"justify-between":"justify-end",t].join(" "),children:[R?e(n.Label,{className:"text-mp-on-surface min-w-0 truncate",children:R}):null,w?e(n.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:e=>p(z,e,P)}):null]}):null,e(n.Track,{className:`flex ${i[_]}`,children:Array.from({length:T},(a,l)=>e("span",{className:["bg-mp-on-surface/12 relative overflow-hidden",c[_],m[_],A?"mp-progress-segment-wave bg-(--_mp-accent)":""].filter(Boolean).join(" "),style:A?{"--_mp-index":l}:void 0,children:A?null:e("span",{className:"absolute inset-y-0 start-0 bg-(--_mp-accent) transition-[width] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",style:{width:`${Math.min(100,Math.max(0,100*(z*T-l)))}%`}})},l))})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as t}from"../../internal/accent.js";import{CONTROL_GAP as
|
|
2
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as t}from"../../internal/accent.js";import{VISUALLY_HIDDEN as o}from"../../internal/visually-hidden.js";import{CONTROL_GAP as l,META_TEXT as n}from"../../internal/scale.js";import{RING_DIAMETER as i,RING_STROKE as c,progressAriaText as m,progressFraction as u,progressText as p}from"../../internal/progress.js";import{useMPColor as f,useMPSize as h}from"../../internal/config.js";export const MPProgressCircular=/*@__PURE__*/a.forwardRef(function({size:a,color:d,value:x=null,min:k=0,max:g=100,label:j,hideLabel:v=!1,showValue:y=!1,format:N,className:b,style:w},L){const $=h(a),V=f(d),z=u(x,k,g),B=null===z,D=void 0!==N,P=i[$],R=c[$],W=P/2,_=W-R/2;return e(s.Root,{ref:L,value:null===z?null:x??null,min:k,max:g,format:N,getAriaValueText:m(z,D),"data-mp-size":$,className:["mp-progress-circular inline-flex items-center",l[$],n,b??""].filter(Boolean).join(" "),style:{...t(V),...w},children:[e("svg",{className:B?"mp-progress-circular-turn shrink-0":"shrink-0",width:P,height:P,viewBox:`0 0 ${P} ${P}`,fill:"none","aria-hidden":"true",children:[r("circle",{cx:W,cy:W,r:_,stroke:"var(--_mp-color-on-surface)",strokeOpacity:.12,strokeWidth:R}),r("circle",{cx:W,cy:W,r:_,pathLength:100,stroke:"var(--_mp-accent)",strokeWidth:R,strokeLinecap:"round",className:B?"mp-progress-circular-arc":"transition-[stroke-dashoffset] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",transform:`rotate(-90 ${W} ${W})`,...B?null:{strokeDasharray:100,strokeDashoffset:100*(1-z)}})]}),v?j?r(s.Label,{className:o,children:j}):null:j?r(s.Label,{className:"text-mp-on-surface min-w-0 truncate",children:j}):null,y?r(s.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:r=>p(z,r,D)}):null]})});
|
|
@@ -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 l from"react";import{Progress as r}from"@base-ui/react/progress";import{accentSlots as s}from"../../internal/accent.js";import{VISUALLY_HIDDEN as n}from"../../internal/visually-hidden.js";import{META_TEXT as t,STACK_GAP as i}from"../../internal/scale.js";import{BAR_THICKNESS as o,progressAriaText as m,progressFraction as c,progressText as u}from"../../internal/progress.js";import{useMPColor as f,useMPSize as p}from"../../internal/config.js";export const MPProgressLinear=/*@__PURE__*/l.forwardRef(function({size:d,color:h,value:j=null,min:g=0,max:x=100,label:b,hideLabel:N=!1,showValue:v=!1,format:w,className:y,style:L},V){const $=p(d),k=f(h),z=c(j,g,x),P=null===z,R=N?null:b,T=void 0!==w,A="absolute inset-y-0 rounded-mp-full bg-(--_mp-accent)";return a(r.Root,{ref:V,value:null===z?null:j??null,min:g,max:x,format:w,getAriaValueText:m(z,T),"data-mp-size":$,className:["mp-progress-linear flex w-full flex-col",i[$],y??""].filter(Boolean).join(" "),style:{...s(k),...L},children:[N&&b?e(r.Label,{className:n,children:b}):null,R||v?a("div",{className:["flex items-baseline gap-2",R?"justify-between":"justify-end",t].join(" "),children:[R?e(r.Label,{className:"text-mp-on-surface min-w-0 truncate",children:R}):null,v?e(r.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:e=>u(z,e,T)}):null]}):null,e(r.Track,{className:["rounded-mp-full bg-mp-on-surface/12 relative w-full overflow-hidden",o[$]].join(" "),children:P?a(l.Fragment,{children:[e("span",{className:`${A} mp-progress-linear-lead`}),e("span",{className:`${A} mp-progress-linear-trail`})]}):e(r.Indicator,{className:`${A} start-0 transition-[width] duration-(--mp-sys-motion-duration-short4) ease-mp-standard`})})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Radio as i}from"@base-ui/react/radio";import{RadioGroup as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Radio as i}from"@base-ui/react/radio";import{RadioGroup as n}from"@base-ui/react/radio-group";import{Field as l}from"@base-ui/react/field";import{accentSlots as o}from"../../internal/accent.js";import{MPStateLayer as t}from"../../internal/StateLayer.js";import{MPSupportingText as s}from"../../internal/SupportingText.js";import{META_TEXT as d,PROSE_TEXT as c,hasContent as p}from"../../internal/scale.js";import{useMPColor as m,useMPSize as u}from"../../internal/config.js";const f={xs:{ring:"size-4",fill:"size-2",halo:"size-8"},sm:{ring:"size-[18px]",fill:"size-[9px]",halo:"size-9"},md:{ring:"size-5",fill:"size-2.5",halo:"size-10"},lg:{ring:"size-[22px]",fill:"size-[11px]",halo:"size-11"},xl:{ring:"size-6",fill:"size-3",halo:"size-12"}},g=/*@__PURE__*/r.createContext({size:"md",readOnly:!1,invalid:!1});export const MPRadio=/*@__PURE__*/r.forwardRef(function({value:n,label:o,description:s,disabled:m=!1,id:u,className:x,style:h},b){const y=r.useContext(g),z=f[y.size],j=r.useId(),v=u??j;return e(l.Root,{className:["mp-radio inline-block align-top",x??""].filter(Boolean).join(" "),style:h,disabled:m,"data-mp-value":n,children:a("div",{className:["flex items-start gap-3",c[y.size]].join(" "),children:[e("span",{className:"flex h-[1lh] shrink-0 items-center",children:a(i.Root,{ref:b,id:v,value:n,disabled:m,className:["mp-radio__dot group relative inline-flex shrink-0 items-center justify-center","box-border rounded-full border-2 p-0","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color] duration-(--mp-sys-motion-duration-short4)",z.ring,m?"border-mp-on-surface/38 cursor-default":[y.readOnly?"cursor-default":"cursor-pointer",y.invalid?"border-mp-error":"border-mp-on-surface-variant","data-checked:border-(--_mp-accent)"].join(" ")].join(" "),children:[m?null:e(t,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",z.halo,"bg-mp-on-surface","group-data-checked:bg-(--_mp-accent)"].join(" ")}),e(i.Indicator,{className:["rounded-full",z.fill,"transition-[opacity,scale] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:scale-0 data-starting-style:opacity-0","data-ending-style:scale-0 data-ending-style:opacity-0",m?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")})]})}),p(o)||p(s)?a("span",{className:"flex min-w-0 flex-col gap-0.5",children:[p(o)?e(l.Label,{htmlFor:v,className:["leading-[1.4]",m?"text-mp-on-surface/38 cursor-default":y.readOnly?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:o}):null,p(s)?e(l.Description,{className:`${d} text-mp-on-surface-variant data-disabled:text-mp-on-surface/38`,children:s}):null]}):null]})})});export const MPRadioGroup=/*@__PURE__*/r.forwardRef(function({value:i,defaultValue:t,onValueChange:c,label:f,description:x,errorMessage:h,orientation:b="vertical",size:y,color:z,required:j=!1,disabled:v=!1,readOnly:N=!1,name:R,children:O,className:k,style:w},M){const _=u(y),C=m(z),V=p(h),I=V?"error":C,P=r.useId(),S=r.useMemo(()=>({size:_,readOnly:N,invalid:V}),[_,N,V]);return e(g.Provider,{value:S,children:a(l.Root,{className:["mp-radio-group flex flex-col gap-2",k??""].filter(Boolean).join(" "),disabled:v,invalid:V,"data-mp-size":_,"data-mp-orientation":b,style:{...o(I),...w},children:[p(f)?a("span",{id:P,className:[d,v?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[f,j?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(n,{ref:M,"aria-labelledby":p(f)?P:void 0,value:i,defaultValue:t,onValueChange:e=>c?.(String(e??"")),disabled:v,readOnly:N,required:j,name:R,className:["flex","horizontal"===b?"flex-row flex-wrap gap-x-6 gap-y-2":"flex-col gap-2"].join(" "),children:O}),e(s,{description:x,errorMessage:h})]})})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{MPIcon as i}from"../icon/MPIcon.js";import{StarIcon as a}from"../../constants/icons.js";import{accentSlots as r}from"../../internal/accent.js";import{fillMessage as o}from"../../internal/i18n.js";import{useMPLocale as s,useMPMessages as l}from"../../internal/locale.js";import{RATING as m}from"../../internal/messages/rating.js";import{VISUALLY_HIDDEN as c}from"../../internal/visually-hidden.js";import{useMPColor as d,useMPSize as u}from"../../internal/config.js";const p={xs:16,sm:20,md:24,lg:30,xl:36},h={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"};export const MPRating=/*@__PURE__*/n.forwardRef(function({value:f,defaultValue:g=0,onValueChange:x,count:v=5,precision:y=1,icon:j,emptyIcon:b,clearable:M=!0,readOnly:N=!1,disabled:P=!1,name:w,required:S=!1,size:R,color:_,locale:z,labels:I,structuredData:k=!1,className:q,style:C,onPointerLeave:L,...V},A){const B=u(R),F=d(_),D=s(z),E=l(m,D,I),O=n.useId(),T=w??O,[G,H]=n.useState(g),J=void 0!==f,K=J?f:G,[Q,U]=n.useState(null),W=Math.max(1,Math.floor(v)),X=y>0&&y<=1?y:1,Y=Math.round(1/X),Z=Math.max(0,Math.min(W,Q??K)),$=e=>e<=0?E.empty:o(E.value,{value:String(e),max:String(W)}),ee=e=>{J||H(e),x?.(e)},te=t=>{const n=e(i,{icon:a,size:p[B],className:t?"[&>svg]:fill-current":""});return(t?j:b)??n},ne=Array.from({length:W},(n,i)=>{const a=Math.max(0,Math.min(1,Z-i));return t("span",{className:["mp-rating__star relative inline-flex shrink-0","rounded-mp-xs",N||P?"":["outline-mp-secondary has-[:focus-visible]:outline-2","has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-solid"].join(" ")].filter(Boolean).join(" "),style:{width:p[B],height:p[B]},children:[e("span",{className:["flex items-center justify-center",P?"text-mp-on-surface/38":"text-mp-outline"].join(" "),style:{width:p[B],height:p[B]},children:te(!1)}),e("span",{"aria-hidden":"true",className:"mp-rating__fill pointer-events-none absolute inset-y-0 start-0 overflow-hidden",style:{width:100*a+"%"},children:e("span",{className:["flex items-center justify-center","transition-colors duration-(--mp-sys-motion-duration-short4)",P?"text-mp-on-surface/38":"text-(--_mp-accent)"].join(" "),style:{width:p[B],height:p[B]},children:te(!0)})}),N?null:Array.from({length:Y},(t,n)=>{const a=Number((i+(n+1)*X).toFixed(4));return e("label",{className:["absolute inset-y-0",P?"":"cursor-pointer"].join(" "),style:{insetInlineStart:100*n/Y+"%",width:100/Y+"%"},onPointerEnter:()=>{P||U(a)},children:e("input",{type:"radio",className:c,name:T,value:a,checked:K===a,disabled:P,required:S,"aria-label":$(a),onChange:()=>ee(a),onClick:()=>{M&&K===a&&ee(0)}})},a)})]},i)}),ie=["mp-rating inline-flex items-center align-middle",h[B],q??""].filter(Boolean).join(" "),ae={...r(F),...C};if(N){const i=Math.max(0,Math.min(W,K));return t("div",{ref:A,role:"img","data-mp-size":B,"aria-label":$(i),itemScope:k||void 0,itemType:k?"https://schema.org/Rating":void 0,className:ie,style:ae,onPointerLeave:L,...V,children:[k?t(n.Fragment,{children:[e("meta",{itemProp:"ratingValue",content:String(i)}),e("meta",{itemProp:"bestRating",content:String(W)}),e("meta",{itemProp:"worstRating",content:"0"})]}):null,ne]})}return e("div",{ref:A,role:"radiogroup","data-mp-size":B,"aria-label":E.label,"aria-disabled":P||void 0,"aria-required":S||void 0,className:ie,style:ae,onPointerLeave:e=>{U(null),L?.(e)},...V,children:ne})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Toggle as o}from"@base-ui/react/toggle";import{ToggleGroup as r}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 c,CONTROL_ICON as d,CONTROL_PAD_X as m,CONTROL_TEXT as u}from"../../internal/scale.js";import{useMPSize as p}from"../../internal/config.js";export const MPSegmentedButton=/*@__PURE__*/n.forwardRef(function({items:n,value:f,defaultValue:b,onValueChange:h,multiple:g=!1,showCheck:y=!0,size:j,fullWidth:x=!1,disabled:v=!1,"aria-label":w,className:N,style:B},V){const k=p(j);return e(r,{ref:V,"aria-label":w,value:f,defaultValue:b,onValueChange:e=>h?.(e),multiple:g,disabled:v,"data-mp-size":k,className:["mp-segmented-button rounded-mp-full box-border items-center align-middle","overflow-hidden border",v?"border-mp-on-surface/12":"border-mp-outline",x?"flex w-full":"inline-flex w-fit",c[k],N??""].filter(Boolean).join(" "),style:B,children:n.map((n,r)=>{const c=v||n.disabled;return t(o,{value:n.value,disabled:n.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[k],l[k],m[k],0===r?"":"border-s",c?"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(" "),x?"flex-1":""].filter(Boolean).join(" "),children:[c?null:e(i,{}),y||n.icon?t("span",{className:"relative flex shrink-0 items-center justify-center",style:{width:d[k],height:d[k]},children:[y?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:d[k]})}):null,n.icon?e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard",y?"group-data-pressed:opacity-0":""].filter(Boolean).join(" "),children:n.icon}):null]}):null,e("span",{className:"truncate",children:n.label})]},`${r}:${n.value}`)})})});
|
|
@@ -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
|
|
@@ -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. */
|
|
@@ -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))]})}
|