material-plus-ui 1.3.1 → 1.4.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/README.md +2 -2
- package/dist/components/alert/MPAlert.d.ts +26 -0
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.d.ts +74 -0
- package/dist/components/avatar-group/MPAvatarGroup.js +2 -0
- package/dist/components/avatar-group/index.d.ts +2 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +10 -4
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/button-group/MPButtonGroup.d.ts +9 -0
- package/dist/components/button-group/MPButtonGroup.js +1 -1
- package/dist/components/carousel/MPCarousel.d.ts +12 -7
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.d.ts +15 -2
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/color-picker/MPColorPicker.d.ts +20 -17
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +22 -4
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +132 -0
- package/dist/components/command-palette/MPCommandPalette.js +2 -0
- package/dist/components/command-palette/index.d.ts +2 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.d.ts +5 -0
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/fieldset/MPFieldset.d.ts +52 -0
- package/dist/components/fieldset/MPFieldset.js +2 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.js +1 -0
- package/dist/components/file-picker/MPFilePicker.d.ts +4 -3
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.d.ts +94 -0
- package/dist/components/footer/MPFooter.js +2 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/footer/index.js +1 -0
- package/dist/components/form/MPForm.d.ts +73 -0
- package/dist/components/form/MPForm.js +2 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/header/MPHeader.d.ts +122 -0
- package/dist/components/header/MPHeader.js +2 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +1 -0
- package/dist/components/highlight/MPHighlight.d.ts +7 -0
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.d.ts +82 -0
- package/dist/components/menubar/MPMenubar.js +2 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +151 -0
- package/dist/components/navigation-menu/MPNavigationMenu.js +2 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +1 -0
- package/dist/components/number-field/MPNumberField.d.ts +12 -3
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +8 -2
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/page-layout/MPPageLayout.d.ts +145 -0
- package/dist/components/page-layout/MPPageLayout.js +2 -0
- package/dist/components/page-layout/index.d.ts +2 -0
- package/dist/components/page-layout/index.js +1 -0
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +12 -1
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +160 -0
- package/dist/components/sidebar/MPSidebar.js +2 -0
- package/dist/components/sidebar/MPSidebarTrigger.d.ts +45 -0
- package/dist/components/sidebar/MPSidebarTrigger.js +2 -0
- package/dist/components/sidebar/index.d.ts +4 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +27 -5
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +13 -2
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.d.ts +7 -1
- package/dist/components/text-link/MPTextLink.js +1 -1
- package/dist/components/time-picker/MPTimePicker.d.ts +4 -0
- package/dist/components/toggle/MPToggle.d.ts +72 -0
- package/dist/components/toggle/MPToggle.js +2 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle-group/MPToggleGroup.d.ts +74 -0
- package/dist/components/toggle-group/MPToggleGroup.js +2 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/transfer/MPTransfer.d.ts +98 -0
- package/dist/components/transfer/MPTransfer.js +2 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/index.js +1 -0
- package/dist/constants/glyphs.d.ts +10 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +1 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/SupportingText.d.ts +1 -1
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +0 -17
- package/dist/internal/animate.js +1 -1
- package/dist/internal/avatar-group.d.ts +22 -0
- package/dist/internal/avatar-group.js +2 -0
- package/dist/internal/button-group.d.ts +20 -1
- package/dist/internal/button-group.js +1 -1
- package/dist/internal/color.d.ts +0 -5
- package/dist/internal/color.js +1 -1
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +201 -4
- package/dist/internal/keys.d.ts +72 -0
- package/dist/internal/keys.js +2 -0
- package/dist/internal/length.d.ts +42 -0
- package/dist/internal/length.js +1 -0
- package/dist/internal/link.d.ts +44 -0
- package/dist/internal/link.js +1 -0
- package/dist/internal/locale.d.ts +20 -1
- package/dist/internal/locale.js +1 -1
- package/dist/internal/messages/breadcrumb.d.ts +3 -0
- package/dist/internal/messages/breadcrumb.js +1 -0
- package/dist/internal/messages/carousel.d.ts +3 -0
- package/dist/internal/messages/carousel.js +1 -0
- package/dist/internal/messages/color-picker.d.ts +3 -0
- package/dist/internal/messages/color-picker.js +1 -0
- package/dist/internal/messages/combobox.d.ts +3 -0
- package/dist/internal/messages/combobox.js +1 -0
- package/dist/internal/messages/command.d.ts +3 -0
- package/dist/internal/messages/command.js +1 -0
- package/dist/internal/messages/file-picker.d.ts +3 -0
- package/dist/internal/messages/file-picker.js +1 -0
- package/dist/internal/messages/layout.d.ts +3 -0
- package/dist/internal/messages/layout.js +1 -0
- package/dist/internal/messages/number-field.d.ts +3 -0
- package/dist/internal/messages/number-field.js +1 -0
- package/dist/internal/messages/overlay.d.ts +3 -0
- package/dist/internal/messages/overlay.js +1 -0
- package/dist/internal/messages/table.d.ts +3 -0
- package/dist/internal/messages/table.js +1 -0
- package/dist/internal/messages/text-link.d.ts +3 -0
- package/dist/internal/messages/text-link.js +1 -0
- package/dist/internal/messages/transfer.d.ts +3 -0
- package/dist/internal/messages/transfer.js +1 -0
- package/dist/internal/page-layout.d.ts +182 -0
- package/dist/internal/page-layout.js +2 -0
- package/dist/internal/scale.d.ts +17 -0
- package/dist/internal/scale.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/avatar-group.css +2 -0
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/chat-bubble.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +2 -0
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/fieldset.css +2 -0
- package/dist/styles/file-picker.css +1 -1
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/footer.css +2 -0
- package/dist/styles/form.css +2 -0
- package/dist/styles/header.css +2 -0
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/locale.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +2 -0
- package/dist/styles/navigation-menu.css +2 -0
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +2 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +2 -0
- package/dist/styles/skeleton.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text-link.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/toggle-group.css +2 -0
- package/dist/styles/toggle.css +2 -0
- package/dist/styles/transfer.css +2 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPIconButtonProps } from '../icon-button/MPIconButton.js';
|
|
3
|
+
import { type MPPageCollapse, type MPSidebarSide } from '../../internal/page-layout.js';
|
|
4
|
+
export interface MPSidebarTriggerProps extends Omit<MPIconButtonProps, 'icon' | 'label'> {
|
|
5
|
+
/**
|
|
6
|
+
* Which of the layout's two sidebars it opens.
|
|
7
|
+
* @default 'start'
|
|
8
|
+
*/
|
|
9
|
+
side?: MPSidebarSide;
|
|
10
|
+
/**
|
|
11
|
+
* The width below which the button appears — the same one the sidebar
|
|
12
|
+
* collapses at, since the button exists exactly while the column does not.
|
|
13
|
+
* Inherited from the [MPPageLayout](./page-layout), which is where it should
|
|
14
|
+
* be set.
|
|
15
|
+
*/
|
|
16
|
+
collapseBelow?: MPPageCollapse;
|
|
17
|
+
/** The glyph. Three lines, unless something else is given. */
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* What it does, in words. Defaults to "Open sidebar" / "Close sidebar" in
|
|
21
|
+
* `locale`, and it changes with the state because the button does.
|
|
22
|
+
*/
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Which language that word is in. Inherited from the layout. */
|
|
25
|
+
locale?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The button that brings back an [MPSidebar](#mpsidebar) the window has become
|
|
29
|
+
* too narrow to hold.
|
|
30
|
+
*
|
|
31
|
+
* It is drawn only while that is true, and the "while" is a **media query**
|
|
32
|
+
* rather than a piece of state: the button carries a class that hides it from
|
|
33
|
+
* the breakpoint up. That matters more than it looks — a trigger whose presence
|
|
34
|
+
* depended on `matchMedia` would be missing from the markup a server sends and
|
|
35
|
+
* would pop into the header a moment after the page arrived, on every phone,
|
|
36
|
+
* every time.
|
|
37
|
+
*
|
|
38
|
+
* Put it in an [MPHeader](./header)'s `brand` slot, ahead of the mark, which is
|
|
39
|
+
* where thirty years of hamburgers have taught readers to look for it.
|
|
40
|
+
*
|
|
41
|
+
* It has to be inside an [MPPageLayout](./page-layout) to have something to
|
|
42
|
+
* open: outside one there is no sidebar it could be talking about, and it
|
|
43
|
+
* renders nothing at all rather than a button that does nothing.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MPSidebarTrigger: React.ForwardRefExoticComponent<MPSidebarTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as o}from"react/jsx-runtime";import*as e from"react";import{MPIcon as r}from"../icon/MPIcon.js";import{MPIconButton as n}from"../icon-button/MPIconButton.js";import{MenuIcon as t}from"../../constants/icons.js";import{useMPLocale as a,useMPMessages as i}from"../../internal/locale.js";import{LAYOUT as s}from"../../internal/messages/layout.js";import{COLLAPSED_ONLY as l,MPPageLayoutContext as c}from"../../internal/page-layout.js";export const MPSidebarTrigger=/*@__PURE__*/e.forwardRef(function({side:m="start",collapseBelow:p,icon:f,label:u,locale:j,className:d,onClick:b,...g},x){const B=e.useContext(c),w=a(j??B.locale),C=i(s,w);if(!B.present)return null;const M=p??B.collapseBelow,P=B.open[m];return o(n,{ref:x,icon:f??o(r,{icon:t}),label:u??(P?C.closeSidebar:C.openSidebar),"aria-expanded":P,className:["mp-sidebar-trigger",l[M],d??""].filter(Boolean).join(" "),onClick:o=>{B.setOpen(m,!P),b?.(o)},...g})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSidebar}from"./MPSidebar.js";export{MPSidebarTrigger}from"./MPSidebarTrigger.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{useRender as l}from"@base-ui/react/use-render";import{CONTROL_SQUARE as o}from"../../internal/scale.js";const
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{useRender as l}from"@base-ui/react/use-render";import{CONTROL_SQUARE as o}from"../../internal/scale.js";import{cssLength as a}from"../../internal/length.js";const n={xs:"h-3",sm:"h-3.5",md:"h-4",lg:"h-4",xl:"h-5.5"},s={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2",xl:"gap-1.5"},i={xs:"h-12",sm:"h-16",md:"h-20",lg:"h-28",xl:"h-36"},t="overflow-hidden bg-(--_mp-placeholder)";export const MPSkeleton=/*@__PURE__*/r.forwardRef(function({shape:r="line",lines:m=1,size:d="md",color:p,width:h,height:c,animated:f=!0,label:u,render:g,className:x,style:w,...j},v){const b=f?"animate-pulse motion-reduce:animate-none":"",k="circle"===r?`rounded-mp-full shrink-0 ${o[d]}`:"rect"===r?`rounded-mp-md w-full ${void 0===c?i[d]:""}`:`rounded-mp-xs w-full ${n[d]}`,y=u?{role:"status","aria-busy":!0,"aria-label":u}:{"aria-hidden":!0},$="line"===r&&m>1;return l({render:g,ref:v,props:{"data-mp-size":d,className:($?["mp-skeleton flex w-full flex-col",s[d],x??""]:["mp-skeleton",t,b,k,x??""]).filter(Boolean).join(" "),style:{"--_mp-placeholder":p?`var(--_mp-color-${p}-container)`:"var(--_mp-color-surface-container-highest)",width:a(h),height:$?void 0:a(c),...w},...y,...$?{children:Array.from({length:m},(r,l)=>e("div",{className:[t,b,"rounded-mp-xs",n[d],l===m-1?"w-3/5":"w-full"].filter(Boolean).join(" ")},l))}:null,...j}})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as s from"react";import{Slider as a}from"@base-ui/react/slider";import{accentSlots as t}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as i,hasContent as o}from"../../internal/scale.js";const l={xs:{thickness:"h-0.5",cross:"w-0.5",handle:"size-3.5",strip:"h-8",stripCross:"w-8"},sm:{thickness:"h-[3px]",cross:"w-[3px]",handle:"size-4",strip:"h-9",stripCross:"w-9"},md:{thickness:"h-1",cross:"w-1",handle:"size-5",strip:"h-10",stripCross:"w-10"},lg:{thickness:"h-1.5",cross:"w-1.5",handle:"size-6",strip:"h-11",stripCross:"w-11"},xl:{thickness:"h-2",cross:"w-2",handle:"size-7",strip:"h-12",stripCross:"w-12"}},c=/*@__PURE__*/["duration-(--mp-sys-motion-duration-short2) ease-mp-standard","motion-reduce:transition-none"].join(" "),m={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=/*@__PURE__*/s.forwardRef(function({value:
|
|
2
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as s from"react";import{Slider as a}from"@base-ui/react/slider";import{accentSlots as t}from"../../internal/accent.js";import{MPStateLayer as n}from"../../internal/StateLayer.js";import{META_TEXT as i,hasContent as o}from"../../internal/scale.js";const l={xs:{thickness:"h-0.5",cross:"w-0.5",handle:"size-3.5",strip:"h-8",stripCross:"w-8"},sm:{thickness:"h-[3px]",cross:"w-[3px]",handle:"size-4",strip:"h-9",stripCross:"w-9"},md:{thickness:"h-1",cross:"w-1",handle:"size-5",strip:"h-10",stripCross:"w-10"},lg:{thickness:"h-1.5",cross:"w-1.5",handle:"size-6",strip:"h-11",stripCross:"w-11"},xl:{thickness:"h-2",cross:"w-2",handle:"size-7",strip:"h-12",stripCross:"w-12"}},c=/*@__PURE__*/["duration-(--mp-sys-motion-duration-short2) ease-mp-standard","motion-reduce:transition-none"].join(" "),m={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=/*@__PURE__*/s.forwardRef(function({value:d,defaultValue:u,onValueChange:p,onValueCommitted:f,min:h=0,max:g=100,step:x=1,label:b,description:w,showValue:j=!1,format:y,orientation:z="horizontal",size:v="md",color:C="primary",disabled:N=!1,name:_,"aria-label":k},V){const $="vertical"===z,A=l[v],B=s.useId(),I=d??u,L=Array.isArray(I)?I.length:1;return r(a.Root,{ref:V,value:d,defaultValue:u,onValueChange:e=>p?.(e),onValueCommitted:e=>f?.(e),min:h,max:g,step:x,disabled:N,orientation:z,format:y,name:_,"data-mp-size":v,className:["mp-slider flex",$?"w-fit flex-col items-center gap-2":"w-full flex-col gap-1",N?"cursor-default":""].filter(Boolean).join(" "),style:t(C),children:[o(b)||j?r("div",{className:["flex w-full items-baseline gap-2",i].join(" "),children:[o(b)?e(a.Label,{className:N?"text-mp-on-surface/38":"text-mp-on-surface-variant",children:b}):null,j?e(a.Value,{className:["ms-auto tabular-nums",N?"text-mp-on-surface/38":"text-mp-on-surface"].join(" ")}):null]}):null,e(a.Control,{className:["mp-slider__control group/rail flex touch-none items-center justify-center select-none",$?`${A.stripCross} h-40 flex-col`:`w-full ${A.strip}`,N?"":"cursor-pointer"].filter(Boolean).join(" "),children:r(a.Track,{className:["mp-slider__track rounded-mp-full relative",$?`${A.cross} h-full`:`${A.thickness} w-full`,N?"bg-mp-on-surface/12":"bg-mp-surface-container-highest"].join(" "),children:[e(a.Indicator,{className:["rounded-mp-full","[transition-property:inset-inline-start,width,bottom,height]",c,"group-data-dragging/rail:transition-none",N?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")}),Array.from({length:L},(r,s)=>e(a.Thumb,{index:s,"aria-label":o(b)?void 0:k,"aria-describedby":o(w)?B:void 0,className:["mp-slider__handle group rounded-mp-full relative outline-none","[transition-property:inset-inline-start,bottom]",c,"data-dragging:transition-none",A.handle,N?"bg-mp-on-surface/38 cursor-default":"bg-(--_mp-accent) cursor-grab active:cursor-grabbing"].join(" "),children:N?null:e(n,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",m[v],"bg-(--_mp-accent)"].join(" "),className:"group-data-dragging:opacity-16"})},s))]})}),o(w)?e("div",{id:B,className:[i,N?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:w}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{MPIcon as i}from"../icon/MPIcon.js";import{CloseIcon as n}from"../../constants/icons.js";import{accentSlots as r}from"../../internal/accent.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Toast as s}from"@base-ui/react/toast";import{MPIcon as i}from"../icon/MPIcon.js";import{CloseIcon as n}from"../../constants/icons.js";import{accentSlots as r}from"../../internal/accent.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{COMMON as m}from"../../internal/messages/common.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{cssLength as p}from"../../internal/length.js";import{PORTAL_LAYER as d}from"../../internal/surface.js";const u={"top-start":"top-0 items-start","top-center":"top-0 items-center","top-end":"top-0 items-end","bottom-start":"bottom-0 flex-col-reverse items-start","bottom-center":"bottom-0 flex-col-reverse items-center","bottom-end":"bottom-0 flex-col-reverse items-end"},f=/*@__PURE__*/["transition-[opacity,translate] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),x={top:"motion-safe:data-starting-style:-translate-y-full motion-safe:data-ending-style:-translate-y-full",bottom:"motion-safe:data-starting-style:translate-y-full motion-safe:data-ending-style:translate-y-full"},b={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},y={xs:"min-h-9 gap-1.5 py-1.5 ps-3 pe-1.5",sm:"min-h-10 gap-2 py-2 ps-3.5 pe-2",md:"min-h-12 gap-2 py-2.5 ps-4 pe-2",lg:"min-h-14 gap-3 py-3 ps-5 pe-2.5",xl:"min-h-16 gap-3 py-3.5 pe-3 ps-6"},h={xs:16,sm:18,md:20,lg:22,xl:24};function g(e){const{color:t,icon:o,message:s,actionLabel:i,onAction:n,...r}=e;return{...r,title:s,data:{color:t,icon:o},actionProps:void 0===i?void 0:{children:i,onClick:n}}}export function useMPSnackbar(){const e=s.useToastManager();return o.useMemo(()=>({add:t=>e.add(g(t)),close:t=>e.close(t),update:(t,o)=>e.update(t,g(o)),promise:(t,o)=>e.promise(t,{loading:g(o.loading),success:e=>g("function"==typeof o.success?o.success(e):o.success),error:e=>g("function"==typeof o.error?o.error(e):o.error)}),snackbars:e.toasts}),[e])}function v({toast:o,color:a,size:l,showClose:m,closeLabel:p,swipeDirection:d,edge:u}){const g=o.data?.color??a,v=o.data?.icon,j={"--_mp-plate":g?`var(--_mp-color-${g}-container)`:"var(--_mp-color-inverse-surface)","--_mp-on-plate":g?`var(--_mp-color-on-${g}-container)`:"var(--_mp-color-inverse-on-surface)","--_mp-plate-action":g?`var(--_mp-color-${g})`:"var(--_mp-color-inverse-primary)",...g?r(g):null};return t(s.Root,{toast:o,swipeDirection:d,"data-mp-size":l,className:["mp-snackbar rounded-mp-xs shadow-mp-3 pointer-events-auto flex w-full items-center","bg-(--_mp-plate) text-(--_mp-on-plate) outline-none",y[l],b[l],f,x[u],"data-limited:hidden"].join(" "),style:j,children:[v?e("span",{className:"flex shrink-0 items-center",children:v}):null,e(s.Title,{render:e("span",{}),className:"min-w-0 flex-1 py-0.5 ps-1 [min-inline-size:min(280px,100%)]"}),e(s.Action,{className:["text-mp-label-large flex shrink-0 cursor-pointer items-center","rounded-mp-full h-8 px-3 text-(--_mp-plate-action)","transition-colors duration-(--mp-sys-motion-duration-short4)","hover:bg-(--_mp-plate-action)/8 focus-visible:bg-(--_mp-plate-action)/10","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ")}),m?t(s.Close,{"aria-label":p,className:["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer","items-center justify-center text-(--_mp-on-plate)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(c,{}),e(i,{icon:n,size:h[l]})]}):null]})}function j({position:t,width:o,...i}){const{toasts:n}=s.useToastManager(),r=t.startsWith("top")?"top":"bottom",a=["top"===r?"up":"down","left","right"];return e(s.Portal,{children:e(s.Viewport,{className:[d,"pointer-events-none fixed inset-x-0 flex flex-col gap-2 p-4",u[t]].join(" "),children:n.map(t=>e("div",{className:"w-full",style:{maxWidth:p(o)},children:e(v,{toast:t,swipeDirection:a,edge:r,...i})},t.id))})})}export function MPSnackbarProvider({color:o,position:i="bottom-start",timeout:n=5e3,limit:r=3,width:c=600,size:p="md",showClose:d=!0,closeLabel:u,locale:f,children:x}){const b=a(f),y=l(m,b);return t(s.Provider,{timeout:n,limit:r,children:[x,e(j,{position:i,width:c,color:o,size:p,showClose:d,closeLabel:u??y.close})]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";const u={xs:{track:"h-5 w-8",thumb:"
|
|
2
|
+
import{jsx as e,Fragment as t,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Switch as n}from"@base-ui/react/switch";import{Field as i}from"@base-ui/react/field";import{MPIcon as s}from"../icon/MPIcon.js";import{CheckIcon as o,CloseIcon as c}from"../../constants/icons.js";import{accentSlots as l}from"../../internal/accent.js";import{MPStateLayer as d}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{PROSE_TEXT as m,hasContent as p}from"../../internal/scale.js";const u={xs:{track:"h-5 w-8",thumb:"start-[5px] size-2.5 data-checked:start-[15px] data-checked:size-3.5",halo:"size-8",glyph:8},sm:{track:"h-6 w-10",thumb:"start-1.5 size-3 data-checked:start-[19px] data-checked:size-[18px]",halo:"size-9",glyph:10},md:{track:"h-8 w-13",thumb:"start-2 size-4 data-checked:start-6 data-checked:size-6",halo:"size-10",glyph:14},lg:{track:"h-9 w-15",thumb:"start-[9px] size-[18px] data-checked:start-7 data-checked:size-7",halo:"size-11",glyph:16},xl:{track:"h-10 w-17",thumb:"start-2.5 size-5 data-checked:start-[33px] data-checked:size-[30px]",halo:"size-12",glyph:18}};export const MPSwitch=/*@__PURE__*/r.forwardRef(function({checked:f,defaultChecked:g,onCheckedChange:k,label:b,description:x,errorMessage:y,icons:j=!1,labelPlacement:z="end",size:w="md",color:N="primary",required:_=!1,disabled:C=!1,readOnly:M=!1,name:v,id:P,fullWidth:R=!1},S){const W=p(y),q=W?"error":N,F=u[w],I=r.useId(),L=P??I,O=e("span",{className:"flex h-[1lh] shrink-0 items-center",children:e(n.Root,{ref:S,id:L,name:v,checked:f,defaultChecked:g,required:_,disabled:C,readOnly:M,onCheckedChange:e=>k?.(e),className:["mp-switch__track group relative box-border inline-flex shrink-0 p-0","rounded-mp-full appearance-none font-[inherit] outline-none","transition-[background-color,box-shadow]","duration-(--mp-sys-motion-duration-short4) ease-mp-standard",F.track,C?["bg-mp-surface-container-highest inset-ring-2 inset-ring-mp-on-surface/12","cursor-default","data-checked:bg-mp-on-surface/12 data-checked:inset-ring-0"].join(" "):[M?"cursor-default":"cursor-pointer","bg-mp-surface-container-highest inset-ring-2",W?"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",F.thumb,C?"bg-mp-on-surface/38 data-checked:bg-mp-surface-container-highest":[W?"bg-mp-error":"bg-mp-outline","data-checked:bg-(--_mp-on-accent)"].join(" ")].join(" "),children:[C?null:e(d,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",F.halo,"bg-mp-on-surface group-data-checked:bg-(--_mp-accent)"].join(" ")}),j?a(t,{children:[e("span",{className:["absolute inset-0 flex items-center justify-center","transition-opacity duration-(--mp-sys-motion-duration-short4)","ease-mp-standard opacity-0 group-data-checked:opacity-100",C?"text-mp-surface-container-highest":"text-(--_mp-accent)"].join(" "),children:e(s,{icon:o,size:F.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:F.glyph,strokeWidth:3})})]}):null]})})}),T=p(b)||p(x)||W?a("span",{className:["flex min-w-0 flex-col gap-0.5","start"===z?"flex-1":""].filter(Boolean).join(" "),children:[p(b)?a(i.Label,{htmlFor:L,className:["leading-[1.4]",C?"text-mp-on-surface/38 cursor-default":M?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:[b,_?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(h,{description:x,errorMessage:y})]}):null;return e(i.Root,{className:["mp-switch align-top",R?"flex w-full":"inline-flex"].join(" "),disabled:C,invalid:W,"data-mp-size":w,style:l(q),children:e("div",{className:["flex w-full items-start gap-3",m[w]].join(" "),children:a(t,"start"===z?{children:[T,O]}:{children:[O,T]})})})});
|
|
@@ -32,14 +32,31 @@ export interface MPTableColumn<Row> {
|
|
|
32
32
|
align?: MPTableAlign;
|
|
33
33
|
/**
|
|
34
34
|
* Renders the cell. Without it the cell is `row[key]` rendered as-is, which
|
|
35
|
-
* covers strings
|
|
35
|
+
* covers strings, numbers and elements.
|
|
36
|
+
*
|
|
37
|
+
* Anything else — a `Date`, a nested object, an array — draws an empty cell
|
|
38
|
+
* rather than being handed to React, which would throw. Reach for this the
|
|
39
|
+
* moment a column holds something that is not already text.
|
|
36
40
|
*/
|
|
37
41
|
render?: (row: Row, index: number) => React.ReactNode;
|
|
38
42
|
}
|
|
39
43
|
export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children'> {
|
|
40
44
|
/** The columns, in the order they appear. */
|
|
41
45
|
headers: readonly MPTableColumn<Row>[];
|
|
42
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The rows. *
|
|
48
|
+
* ## How long a list this holds
|
|
49
|
+
*
|
|
50
|
+
* Every row is rendered, and there is no windowing. That is the right default
|
|
51
|
+
* — windowing costs a measured container, a scroll listener and a row height
|
|
52
|
+
* the component would have to decide for the caller — and it has a ceiling: a
|
|
53
|
+
* few hundred rows is nothing, a few thousand is a visible pause when the list
|
|
54
|
+
* opens, and past that the answer is a narrower list rather than a faster one.
|
|
55
|
+
*
|
|
56
|
+
* A list somebody has to scroll ten thousand rows of is a list that wanted a
|
|
57
|
+
* filter. Where it genuinely is that long, window it yourself and pass the
|
|
58
|
+
* slice.
|
|
59
|
+
*/
|
|
43
60
|
items: readonly Row[];
|
|
44
61
|
/**
|
|
45
62
|
* A stable key per row. Defaults to the row's index, which is fine for a
|
|
@@ -49,10 +66,15 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
49
66
|
/** Shown above the table, and read out as its accessible name. */
|
|
50
67
|
caption?: React.ReactNode;
|
|
51
68
|
/**
|
|
52
|
-
* What to show instead of rows when `items` is empty.
|
|
53
|
-
*
|
|
69
|
+
* What to show instead of rows when `items` is empty. Defaults to the wording
|
|
70
|
+
* in `locale`.
|
|
54
71
|
*/
|
|
55
72
|
empty?: React.ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Which language that line is written in. Falls back to the nearest
|
|
75
|
+
* `MPLocaleProvider`, then to English.
|
|
76
|
+
*/
|
|
77
|
+
locale?: string;
|
|
56
78
|
/**
|
|
57
79
|
* Tints every other row. Useful for a wide table where the eye has to track
|
|
58
80
|
* across; noise on a narrow one.
|
|
@@ -117,4 +139,4 @@ export interface MPTableProps<Row> extends Omit<React.ComponentPropsWithoutRef<'
|
|
|
117
139
|
* than a ref on the scroll container is worth — and a caller who needs one can
|
|
118
140
|
* put it on a `<div>` of their own around this.
|
|
119
141
|
*/
|
|
120
|
-
export declare function MPTable<Row>({ headers, items, getRowKey, caption, empty, striped, hoverable, stickyHeader, onRowClick, variant, size, color, className, style, ...props }: MPTableProps<Row>): React.JSX.Element;
|
|
142
|
+
export declare function MPTable<Row>({ headers, items, getRowKey, caption, empty, locale: localeProp, striped, hoverable, stickyHeader, onRowClick, variant, size, color, className, style, ...props }: MPTableProps<Row>): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{accentSlots as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as r from"react";import{accentSlots as l}from"../../internal/accent.js";import{useMPLocale as o,useMPMessages as a}from"../../internal/locale.js";import{TABLE as n}from"../../internal/messages/table.js";import{cssLength as i}from"../../internal/length.js";import{META_TEXT as m}from"../../internal/scale.js";import{CONTAINER_SURFACE as s}from"../../internal/surface.js";const c={xs:"0.625rem",sm:"0.75rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},d={xs:"0.375rem",sm:"0.625rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},p={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},u={xs:"text-mp-label-medium",sm:"text-mp-label-medium",md:"text-mp-title-small",lg:"text-mp-title-small",xl:"text-mp-title-medium"},x=/*@__PURE__*/["[--_mp-row:transparent]","transition-[background-color] duration-(--mp-sys-motion-duration-short4)"].join(" ");function y(e){if(null==e)return null;const t=typeof e;return"string"===t||"number"===t||"bigint"===t||"boolean"===t||r.isValidElement(e)?e:null}export function MPTable({headers:r,items:f,getRowKey:b,caption:g,empty:h,locale:v,striped:w=!1,hoverable:j=!1,stickyHeader:k=!1,onRowClick:N,variant:_="outlined",size:C="md",color:$="primary",className:A,style:B,...z}){const T=a(n,o(v)),D=c[C],E=d[C],K=Boolean(N),R=j||K,H={padding:`${E} ${D}`},I={...H,backgroundColor:"var(--_mp-color-surface-container)"},M={borderTop:"1px solid var(--_mp-color-outline-variant)",backgroundColor:"var(--_mp-row)"};return e("div",{"data-mp-size":C,"data-mp-variant":_,className:["mp-table rounded-mp-md overflow-x-auto",s[_],A??""].filter(Boolean).join(" "),style:{...l($),...B},...z,children:t("table",{className:`text-mp-on-surface w-full text-start ${p[C]}`,style:{borderCollapse:"collapse"},children:[g?e("caption",{className:`text-mp-on-surface-variant ${m}`,style:{...H,textAlign:"start"},children:g}):null,e("colgroup",{children:r.map(t=>e("col",{style:void 0===t.width?void 0:{width:i(t.width)}},t.key))}),e("thead",{children:e("tr",{children:r.map(t=>e("th",{scope:"col",className:["text-mp-on-surface-variant whitespace-nowrap",u[C],k?"sticky top-0 z-10":""].filter(Boolean).join(" "),style:{...I,textAlign:t.align??"start"},children:t.label??t.key},t.key))})}),e("tbody",{children:0===f.length?e("tr",{className:x,style:M,children:e("td",{colSpan:r.length,className:"text-mp-on-surface-variant",style:{padding:`2rem ${D}`,textAlign:"center"},children:h??T.empty})}):f.map((t,l)=>e("tr",{className:[x,w&&l%2==1?"[--_mp-row:var(--_mp-color-surface-container-low)]":"",R?"hover:[--_mp-row:var(--_mp-color-surface-container)]":"",K?["cursor-pointer","outline-mp-secondary focus-visible:outline-2","focus-visible:-outline-offset-2 focus-visible:outline-solid outline-none"].join(" "):""].filter(Boolean).join(" "),style:M,tabIndex:K?0:void 0,onClick:N?()=>N(t,l):void 0,onKeyDown:N?e=>{"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),N(t,l))}:void 0,children:r.map(r=>e("td",{style:{...H,textAlign:r.align??"start"},children:r.render?r.render(t,l):y(t[r.key])},r.key))},b?b(t,l):l))})]})})}
|
|
@@ -110,8 +110,19 @@ export interface MPTextFieldProps extends MPStyleProps {
|
|
|
110
110
|
*/
|
|
111
111
|
onChange?: (value: string) => void;
|
|
112
112
|
/**
|
|
113
|
-
* Called when Enter is pressed.
|
|
114
|
-
*
|
|
113
|
+
* Called when Enter is pressed.
|
|
114
|
+
*
|
|
115
|
+
* On a single-line field the key is then swallowed, so a surrounding form is
|
|
116
|
+
* submitted once rather than also natively.
|
|
117
|
+
*
|
|
118
|
+
* On a **multiline** field it is not, and both things happen: this fires *and*
|
|
119
|
+
* a newline is inserted. That is deliberate — the prop reports the keystroke
|
|
120
|
+
* rather than deciding what the field does with it — but it is worth knowing
|
|
121
|
+
* before wiring it to something that sends. `disableEnterKey` is what makes
|
|
122
|
+
* Enter a submission there and nothing else.
|
|
123
|
+
*
|
|
124
|
+
* Never called for the Enter that commits an IME composition: that keystroke
|
|
125
|
+
* belongs to the input method, not to the form.
|
|
115
126
|
*/
|
|
116
127
|
onSubmit?: () => void;
|
|
117
128
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Field as n}from"@base-ui/react/field";import{MPIcon as
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as o from"react";import{Field as n}from"@base-ui/react/field";import{MPIcon as r}from"../icon/MPIcon.js";import{MPFieldLabel as a,MPFieldOutline as i,useFloatingLabel as l}from"../../internal/FieldOutline.js";import{MPSupportingText as s}from"../../internal/SupportingText.js";import{VisibilityIcon as d,VisibilityOffIcon as p}from"../../constants/icons.js";import{useMPLocale as u,useMPMessages as c}from"../../internal/locale.js";import{TEXT_FIELD as m}from"../../internal/messages/text-field.js";const f={xs:{padding:"px-2",control:"py-1.5",text:"text-mp-body-medium",icon:16},sm:{padding:"px-3",control:"py-2.5",text:"text-mp-body-medium",icon:18},md:{padding:"px-4",control:"py-4",text:"text-mp-body-large",icon:20},lg:{padding:"px-4",control:"py-5",text:"text-mp-body-large",icon:22},xl:{padding:"px-5",control:"py-6",text:"text-mp-body-large",icon:24}};export const MPTextField=/*@__PURE__*/o.forwardRef(function({value:x,name:b,type:g="text",placeholder:y,autoComplete:h,label:v,floatingLabel:w=!0,onChange:j,onFormReset:C,onSubmit:k,errorMessage:z="",required:M=!1,fullWidth:E=!1,readOnly:N=!1,autoFocus:S=!1,size:F="md",disabled:P=!1,disableEnterKey:q=!1,rows:D,maxLength:L,startIcon:R,resizable:I=!1,id:O,locale:B,passwordLabels:K},T){const U=u(B),$=c(m,U,K),_=o.useRef(null),[W,A]=o.useState(!1),[G,H]=o.useState(!1),[J,Q]=o.useState(x),V=o.useId(),X=O??V,Y=!!D,Z=z.length>0,ee=f[F],te=G?J:x,{shrunk:oe,focusProps:ne}=l({floating:w&&!!v,filled:te.length>0,pinned:!!R}),re=o.useCallback(e=>{_.current=e,"function"==typeof T?T(e):T&&(T.current=e)},[T]),ae=e=>{e.preventDefault()};return o.useEffect(()=>{G||Q(x)},[x,G]),o.useEffect(()=>{S&&!window.matchMedia("(max-width: 599.95px)").matches&&_.current?.focus()},[]),t(n.Root,{className:["mp-text-field group relative",E?"w-full":"inline-block","align-top"].join(" "),disabled:P,invalid:Z,"data-mp-size":F,...ne,children:[t("div",{className:["relative flex w-full items-center gap-2",ee.padding,Y?"py-2":""].filter(Boolean).join(" "),children:[e(i,{label:v,required:M,notched:oe}),R?e("span",{className:"text-mp-on-surface-variant group-data-disabled:text-mp-on-surface/38 flex shrink-0 items-center",children:R}):null,e(n.Control,{render:Y?e("textarea",{rows:D}):e("input",{}),id:X,name:b,type:Y?void 0:W?"text":g,required:M,readOnly:N,disabled:P,autoComplete:h,placeholder:oe?y:void 0,maxLength:L,value:te,ref:re,className:[`${ee.text} text-mp-on-surface w-full min-w-0 flex-1`,"font-[family-name:var(--mp-sys-typescale-body-large-font)]","appearance-none border-0 bg-transparent px-0 outline-none","caret-mp-primary",ee.control,Y?"py-0":"",Y&&I?"resize-y":"resize-none","group-data-disabled:text-mp-on-surface/38","placeholder:text-mp-on-surface-variant group-data-disabled:placeholder:text-mp-on-surface/38"].filter(Boolean).join(" "),onChange:e=>{C?.();const t=e.target.value;G&&Q(t),j?.(t)},onCompositionStart:()=>{H(!0),Q(x)},onCompositionUpdate:e=>{Q(e.target.value)},onCompositionEnd:e=>{H(!1);const t=e.target.value;C?.(),j?.(t),Q(t)},onKeyDown:e=>{if("Enter"===e.key){if(function(e){const t=e.nativeEvent;return t.isComposing||229===t.keyCode}(e))return;k?.(),Y&&!q||e.preventDefault()}}}),"password"!==g||Y?null:e("button",{type:"button","aria-label":W?$.hidePassword:$.showPassword,onClick:()=>A(e=>!e),onMouseDown:ae,onMouseUp:ae,disabled:P,className:["text-mp-on-surface-variant -me-1 flex shrink-0 items-center justify-center","cursor-pointer appearance-none border-0 bg-transparent p-1 font-[inherit]","rounded-full","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none","hover:text-mp-on-surface focus-visible:text-mp-primary","disabled:text-mp-on-surface/38 disabled:cursor-default"].join(" "),children:e(r,{icon:W?d:p,size:ee.icon})}),v?e(a,{size:F,label:v,required:M,htmlFor:X,shrunk:oe,multiline:Y}):null]}),e(s,{errorMessage:z,className:`mp-text-field__support mt-1 ${ee.padding}`})]})});
|
|
@@ -53,9 +53,15 @@ export interface MPTextLinkProps extends Omit<React.ComponentPropsWithoutRef<'a'
|
|
|
53
53
|
/**
|
|
54
54
|
* What a screen reader hears after the label when `newTab` is on. A link
|
|
55
55
|
* without it says nothing of its own, so this changes nothing there.
|
|
56
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* Defaults to the wording in `locale`.
|
|
57
58
|
*/
|
|
58
59
|
newTabLabel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Which language that wording is in. Falls back to the nearest
|
|
62
|
+
* `MPLocaleProvider`, then to English.
|
|
63
|
+
*/
|
|
64
|
+
locale?: string;
|
|
59
65
|
/**
|
|
60
66
|
* Renders something other than an `<a>` — the `Link` a router brings, most of
|
|
61
67
|
* the time. `href` still goes through, so `render={<NextLink href="…" />}`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,Fragment as n,jsxs as
|
|
2
|
+
import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import*as o from"react";import{useRender as i}from"@base-ui/react/use-render";import{MPIcon as l}from"../icon/MPIcon.js";import{ExternalLinkIcon as t,LinkIcon as s}from"../../constants/icons.js";import{accentSlots as a}from"../../internal/accent.js";import{linkRel as m}from"../../internal/link.js";import{useMPLocale as c,useMPMessages as p}from"../../internal/locale.js";import{TEXT_LINK as u}from"../../internal/messages/text-link.js";import{PROSE_TEXT as d}from"../../internal/scale.js";import{VISUALLY_HIDDEN as f}from"../../internal/visually-hidden.js";const k={always:"[&.mp-link]:underline",hover:"[&.mp-link]:no-underline [&.mp-link]:hover:underline",none:"[&.mp-link]:no-underline"},x=/*@__PURE__*/["[&.mp-link]:[text-underline-offset:0.2em]","[&.mp-link]:[text-decoration-thickness:0.08em]","[&.mp-link]:[text-decoration-color:color-mix(in_oklab,currentColor_45%,transparent)]","[&.mp-link]:hover:[text-decoration-color:currentColor]"].join(" ");export const MPTextLink=/*@__PURE__*/o.forwardRef(function({href:o,underline:h="always",color:b,size:j,newTab:v=!1,icon:y,newTabLabel:w,locale:g,render:_,className:N,style:T,children:z,...C},L){const M=p(u,c(g)),P=v?"_blank":C.target,B="_blank"===P,F=y??B,I=!0===F?e(l,{icon:B?t:s,size:"0.95em"}):F,R=["mp-link cursor-pointer","transition-[color,text-decoration-color]","duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid focus-visible:rounded-mp-xs outline-none",j?d[j]:"",k[h],x,b?"[&.mp-link]:text-(--_mp-accent)":"[&.mp-link]:text-inherit",N??""].filter(Boolean).join(" ");return i({render:_??e("a",{}),ref:L,props:{href:o,target:P,rel:m(P,C.rel),className:R,style:b?{...a(b),...T}:T,children:r(n,{children:[z,I?e("span",{className:"ms-[0.25em] inline-flex align-baseline",children:I}):null,B?r(n,{children:[" ",e("span",{className:f,children:w??M.newTab})]}):null]}),...C}})});
|
|
@@ -44,6 +44,10 @@ export interface MPTimePickerProps extends MPPickerShellProps {
|
|
|
44
44
|
showSeconds?: boolean;
|
|
45
45
|
/**
|
|
46
46
|
* How far apart the rows of each column are.
|
|
47
|
+
*
|
|
48
|
+
* Rounded, and held between 1 and the column's own span: a step of nought has
|
|
49
|
+
* no number of rows at all, and one wider than the column leaves the single
|
|
50
|
+
* row it can offer.
|
|
47
51
|
* @default 1
|
|
48
52
|
*/
|
|
49
53
|
hourStep?: number;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPStyleProps, MPVariant } from '../../types.js';
|
|
3
|
+
export interface MPToggleProps extends MPStyleProps, Omit<React.ComponentPropsWithoutRef<'button'>, 'color' | 'value'> {
|
|
4
|
+
/**
|
|
5
|
+
* How much surface the toggle paints while it is **off**. On is always the
|
|
6
|
+
* accent asserting itself, whichever weight was asked for.
|
|
7
|
+
* @default 'outlined'
|
|
8
|
+
*/
|
|
9
|
+
variant?: MPVariant;
|
|
10
|
+
/**
|
|
11
|
+
* Which accent family it turns on in. Not an arbitrary colour: to change what
|
|
12
|
+
* `primary` *is*, set the token.
|
|
13
|
+
* @default 'primary'
|
|
14
|
+
*/
|
|
15
|
+
color?: MPColor;
|
|
16
|
+
/** Whether it is on. Use with `onPressedChange` for a controlled toggle. */
|
|
17
|
+
pressed?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether it starts on, for an uncontrolled one.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
defaultPressed?: boolean;
|
|
23
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
24
|
+
/** Identifies the toggle inside an [MPToggleGroup](./toggle#mptogglegroup). */
|
|
25
|
+
value?: string;
|
|
26
|
+
/** A glyph before the label. */
|
|
27
|
+
startIcon?: React.ReactNode;
|
|
28
|
+
/** A glyph after it. */
|
|
29
|
+
endIcon?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The label. Left out, the toggle goes square around whatever glyph it was
|
|
32
|
+
* given — which is what a toolbar toggle is, and what MD3 calls a *toggle icon
|
|
33
|
+
* button*. An icon-only toggle still needs an `aria-label`.
|
|
34
|
+
*/
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A button that stays down.
|
|
39
|
+
*
|
|
40
|
+
* The difference from an [MPSwitch](./switch) is what the press *is*: a switch
|
|
41
|
+
* changes a setting, and the change is the point. A toggle changes the state of
|
|
42
|
+
* the thing beside it — bold on the selected words, the grid on the canvas, the
|
|
43
|
+
* filter on the list — and the thing beside it is what the reader is looking at.
|
|
44
|
+
*
|
|
45
|
+
* The difference from an [MPCheckbox](./checkbox) is that this is a control
|
|
46
|
+
* rather than an answer, so it never goes in a form. A checkbox's value is
|
|
47
|
+
* submitted; a toggle's state is acted on immediately.
|
|
48
|
+
*
|
|
49
|
+
* Base UI's `Toggle` is underneath, which owns `aria-pressed` and the
|
|
50
|
+
* controlled/uncontrolled pair. What is left here is the surface, and the rule
|
|
51
|
+
* that **off is neutral**.
|
|
52
|
+
*
|
|
53
|
+
* ## Why off is neutral and on is the accent
|
|
54
|
+
*
|
|
55
|
+
* Because a toggle has to be readable at a glance in a row of eight of them, and
|
|
56
|
+
* the axis a reader can actually judge in isolation is hue, not saturation. A
|
|
57
|
+
* set where off is a paler accent and on is a stronger one is a set nobody can
|
|
58
|
+
* read without comparing two of them side by side.
|
|
59
|
+
*
|
|
60
|
+
* It is also what leaves `color` meaning something. On a button the family says
|
|
61
|
+
* *what kind of action this is*; here it says what "on" looks like, and an
|
|
62
|
+
* unpressed toggle that already wore it would have spent the signal.
|
|
63
|
+
*
|
|
64
|
+
* ## Icon only
|
|
65
|
+
*
|
|
66
|
+
* With no children the toggle goes square around its glyph, exactly as
|
|
67
|
+
* [MPButton](./button) does — which for a `corner-full` control is a circle, and
|
|
68
|
+
* is MD3's own toggle icon button. There is no separate component for it, for
|
|
69
|
+
* [MPIconButton](./icon-button)'s reason inverted: the *name* is what an icon
|
|
70
|
+
* button adds, and a toggle already has to be given one.
|
|
71
|
+
*/
|
|
72
|
+
export declare const MPToggle: React.ForwardRefExoticComponent<MPToggleProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{Toggle as r}from"@base-ui/react/toggle";import{accentSlots as o}from"../../internal/accent.js";import{MPButtonGroupContext as a}from"../../internal/button-group.js";import{MPStateLayer as s}from"../../internal/StateLayer.js";import{CONTROL_GAP as i,CONTROL_HEIGHT as c,CONTROL_PAD_X as l,CONTROL_SQUARE as p,CONTROL_TEXT as m,hasContent as d}from"../../internal/scale.js";const u={filled:"bg-mp-surface-container-highest text-mp-on-surface-variant",tonal:"bg-mp-surface-container text-mp-on-surface-variant",elevated:"shadow-mp-1 bg-mp-surface-container-low text-mp-on-surface-variant",outlined:"border-mp-outline border bg-transparent text-mp-on-surface-variant",text:"bg-transparent text-mp-on-surface-variant"},f={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",outlined:"border-(--_mp-accent) border bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",text:"bg-transparent text-(--_mp-accent)"},b={filled:"bg-mp-on-surface/12 text-mp-on-surface/38",tonal:"bg-mp-on-surface/12 text-mp-on-surface/38",elevated:"bg-mp-on-surface/12 text-mp-on-surface/38 shadow-none",outlined:"border-mp-on-surface/12 border bg-transparent text-mp-on-surface/38",text:"bg-transparent text-mp-on-surface/38"};export const MPToggle=/*@__PURE__*/n.forwardRef(function({variant:g,size:x,color:v,disabled:h,pressed:w,defaultPressed:_,onPressedChange:j,value:y,startIcon:P,endIcon:z,fullWidth:C=!1,className:k,style:I,children:N,...B},L){const M=n.useContext(a),R=g??M?.variant??"outlined",S=x??M?.size??"md",T=v??M?.color??"primary",W=h??M?.disabled??!1,$=!d(N);return t(r,{ref:L,value:y,pressed:w,defaultPressed:_,onPressedChange:e=>j?.(e),disabled:W,"data-mp-size":S,"data-mp-variant":R,className:e=>["mp-toggle group relative inline-flex shrink-0 items-center justify-center","rounded-mp-full box-border overflow-hidden align-middle whitespace-nowrap select-none","cursor-pointer appearance-none font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4)",c[S],m[S],i[S],$?`${p[S]} px-0`:l[S],W?b[R]:e.pressed?f[R]:u[R],W?"cursor-default":"",C?"w-full":"",k??""].filter(Boolean).join(" "),style:{...o(T),...I},...B,children:[W?null:e(s,{}),P,N,z]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPToggle}from"./MPToggle.js";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPOrientation, MPStyleProps, MPVariant } from '../../types.js';
|
|
3
|
+
export interface MPToggleGroupProps extends MPStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'onChange'> {
|
|
4
|
+
/**
|
|
5
|
+
* Passed to every toggle in the set.
|
|
6
|
+
* @default 'outlined'
|
|
7
|
+
*/
|
|
8
|
+
variant?: MPVariant;
|
|
9
|
+
/** Passed to every toggle in the set. */
|
|
10
|
+
color?: MPColor;
|
|
11
|
+
/**
|
|
12
|
+
* Which toggles are on, by their `value`.
|
|
13
|
+
*
|
|
14
|
+
* An array in both the single and the multiple case — Base UI's own shape, and
|
|
15
|
+
* the same decision [MPSegmentedButton](./segmented-button) makes: a `value`
|
|
16
|
+
* whose *type* changed with a boolean prop would be a union every caller has
|
|
17
|
+
* to narrow before they can read it.
|
|
18
|
+
*/
|
|
19
|
+
value?: readonly string[];
|
|
20
|
+
/** Which start on, for an uncontrolled set. */
|
|
21
|
+
defaultValue?: readonly string[];
|
|
22
|
+
onValueChange?: (value: string[]) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether more than one may be on at a time. Off, turning one on turns the
|
|
25
|
+
* last one off — which is a one-of-a-set, and worth a second thought: if what
|
|
26
|
+
* is being chosen is a **value** rather than a state, that is an
|
|
27
|
+
* [MPSegmentedButton](./segmented-button) or an
|
|
28
|
+
* [MPRadioGroup](./radio-group).
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
multiple?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Which way the toggles run.
|
|
34
|
+
* @default 'horizontal'
|
|
35
|
+
*/
|
|
36
|
+
orientation?: MPOrientation;
|
|
37
|
+
/** Disables every toggle in the set at once. */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the arrow keys wrap around at the ends.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
loopFocus?: boolean;
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A run of toggles that share one state.
|
|
48
|
+
*
|
|
49
|
+
* Two things happen here and only one of them is visual. The corners that face a
|
|
50
|
+
* neighbour are cut back to `corner-small` — MD3's connected button group, the
|
|
51
|
+
* same shape an [MPButtonGroup](./button-group) draws, out of the same table.
|
|
52
|
+
*
|
|
53
|
+
* The other half is that the **set owns the value**: the toggles report into one
|
|
54
|
+
* array, `multiple` decides whether more than one of them can be on, and
|
|
55
|
+
* `variant`, `size`, `color` and `disabled` are set once here rather than on
|
|
56
|
+
* every toggle. A run where the fourth toggle is a rung out is not a run.
|
|
57
|
+
*
|
|
58
|
+
* Base UI owns the roving tab index — one tab stop for the whole set, with the
|
|
59
|
+
* arrow keys moving inside it — which is what makes a toolbar of eight toggles
|
|
60
|
+
* two key presses deep instead of eight.
|
|
61
|
+
*
|
|
62
|
+
* ## When this is the wrong component
|
|
63
|
+
*
|
|
64
|
+
* When what is being chosen is a **value** rather than a state. A run of toggles
|
|
65
|
+
* with `multiple` off is a one-of-a-set, and the two components that say so
|
|
66
|
+
* properly are [MPSegmentedButton](./segmented-button) — which is MD3's own
|
|
67
|
+
* control for picking between two and five views — and
|
|
68
|
+
* [MPRadioGroup](./radio-group), which is what a form's value comes from.
|
|
69
|
+
*
|
|
70
|
+
* A toggle group is for a **toolbar**: bold, italic, underline; grid, snap,
|
|
71
|
+
* rulers. Each one is a state of the thing beside it, and they happen to sit
|
|
72
|
+
* together.
|
|
73
|
+
*/
|
|
74
|
+
export declare const MPToggleGroup: React.ForwardRefExoticComponent<MPToggleGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import*as o from"react";import{ToggleGroup as l}from"@base-ui/react/toggle-group";import{GROUP_JOIN as a,MPButtonGroupContext as r}from"../../internal/button-group.js";export const MPToggleGroup=/*@__PURE__*/o.forwardRef(function({variant:i,size:t,color:n,value:u,defaultValue:s,onValueChange:f,multiple:c=!1,orientation:d="horizontal",disabled:m,loopFocus:p=!0,fullWidth:g=!1,className:v,children:x,...h},b){const j=o.useMemo(()=>({variant:i,size:t,color:n,disabled:m}),[i,t,n,m]);return e(r.Provider,{value:j,children:e(l,{ref:b,value:u,defaultValue:s,onValueChange:e=>f?.(e),multiple:c,orientation:d,disabled:m,loopFocus:p,"data-mp-orientation":d,className:["mp-toggle-group inline-flex gap-0.5 align-middle","vertical"===d?"flex-col":"flex-row",a[d],"[&>*]:relative [&>*:focus-visible]:z-10",g?"flex w-full [&>*]:flex-1":"",v??""].filter(Boolean).join(" "),...h,children:x})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPToggleGroup}from"./MPToggleGroup.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as t,jsxs as o}from"react/jsx-runtime";import*as e from"react";import{Tooltip as a}from"@base-ui/react/tooltip";import{accentSlots as i}from"../../internal/accent.js";export const MPTooltipProvider=a.Provider;const l={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"},s={xs:"px-1.5",sm:"px-2",md:"px-2",lg:"px-3",xl:"px-4"},r={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-small",lg:"text-mp-body-medium",xl:"text-mp-body-medium"},d={xs:6,sm:7,md:8,lg:9,xl:10};export function MPTooltip({content:p,children:n,size:m="sm",color:c,side:x="top",align:y="center",sideOffset:u=6,delay:h,closeDelay:f,arrow:g=!0,open:b,defaultOpen:v,onOpenChange:_,disabled:P=!1,className:j,style:O}){const w=d[m],N=e.useId(),[z,T]=e.useState(v??!1),M=b??z,B={"--_mp-tooltip":c?`var(--_mp-color-${c})`:"var(--_mp-color-inverse-surface)","--_mp-on-tooltip":c?`var(--_mp-color-on-${c})`:"var(--_mp-color-inverse-on-surface)",...c?i(c):null};return o(a.Root,{open:b,defaultOpen:v,onOpenChange:t=>{T(t),_?.(t)},children:[t(a.Trigger,{render:n,delay:h,closeDelay:f,disabled:P,"aria-describedby":M?N:void 0}),t(a.Portal,{children:t(a.Positioner,{className:"mp-portal z-50 outline-none",side:x,align:y,sideOffset:u,children:o(a.Popup,{id:N,role:"tooltip","data-mp-size":m,className:["mp-tooltip rounded-mp-xs max-w-64 outline-none","bg-(--_mp-tooltip) text-(--_mp-on-tooltip)","transition-opacity duration-(--mp-sys-motion-duration-short4)","data-starting-style:opacity-0 data-ending-style:opacity-0","data-instant:duration-0",s[m],l[m],r[m],j??""].filter(Boolean).join(" "),style:{...B,...O},children:[g?t(a.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:t("svg",{width:w,height:w/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:t("path",{d:"M0 0h10L5 5z",fill:"var(--_mp-tooltip)"})})}):null,p]})})})]})}
|
|
2
|
+
import{jsx as t,jsxs as o}from"react/jsx-runtime";import*as e from"react";import{Tooltip as a}from"@base-ui/react/tooltip";import{accentSlots as i}from"../../internal/accent.js";export const MPTooltipProvider=a.Provider;const l={xs:"py-0.5",sm:"py-1",md:"py-1",lg:"py-1.5",xl:"py-2"},s={xs:"px-1.5",sm:"px-2",md:"px-2",lg:"px-3",xl:"px-4"},r={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-small",lg:"text-mp-body-medium",xl:"text-mp-body-medium"},d={xs:6,sm:7,md:8,lg:9,xl:10};export function MPTooltip({content:p,children:n,size:m="sm",color:c,side:x="top",align:y="center",sideOffset:u=6,delay:h,closeDelay:f,arrow:g=!0,open:b,defaultOpen:v,onOpenChange:_,disabled:P=!1,className:j,style:O}){const w=d[m],N=e.useId(),[z,T]=e.useState(v??!1),M=b??z,B={"--_mp-tooltip":c?`var(--_mp-color-${c})`:"var(--_mp-color-inverse-surface)","--_mp-on-tooltip":c?`var(--_mp-color-on-${c})`:"var(--_mp-color-inverse-on-surface)",...c?i(c):null};return o(a.Root,{open:b,defaultOpen:v,onOpenChange:t=>{void 0===b&&T(t),_?.(t)},children:[t(a.Trigger,{render:n,delay:h,closeDelay:f,disabled:P,"aria-describedby":M?N:void 0}),t(a.Portal,{children:t(a.Positioner,{className:"mp-portal z-50 outline-none",side:x,align:y,sideOffset:u,children:o(a.Popup,{id:N,role:"tooltip","data-mp-size":m,className:["mp-tooltip rounded-mp-xs max-w-64 outline-none","bg-(--_mp-tooltip) text-(--_mp-on-tooltip)","transition-opacity duration-(--mp-sys-motion-duration-short4)","data-starting-style:opacity-0 data-ending-style:opacity-0","data-instant:duration-0",s[m],l[m],r[m],j??""].filter(Boolean).join(" "),style:{...B,...O},children:[g?t(a.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:t("svg",{width:w,height:w/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:t("path",{d:"M0 0h10L5 5z",fill:"var(--_mp-tooltip)"})})}):null,p]})})})]})}
|