material-plus-ui 0.0.1 → 1.1.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 +39 -28
- package/dist/components/accordion/MPAccordion.d.ts +115 -0
- package/dist/components/accordion/MPAccordion.js +1 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/alert/MPAlert.d.ts +91 -0
- package/dist/components/alert/MPAlert.js +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/animate-appear/MPAnimateAppear.d.ts +56 -0
- package/dist/components/animate-appear/MPAnimateAppear.js +1 -0
- package/dist/components/animate-appear/index.d.ts +2 -0
- package/dist/components/animate-appear/index.js +1 -0
- package/dist/components/animate-blink/MPAnimateBlink.d.ts +41 -0
- package/dist/components/animate-blink/MPAnimateBlink.js +1 -0
- package/dist/components/animate-blink/index.d.ts +2 -0
- package/dist/components/animate-blink/index.js +1 -0
- package/dist/components/animate-fade/MPAnimateFade.d.ts +38 -0
- package/dist/components/animate-fade/MPAnimateFade.js +1 -0
- package/dist/components/animate-fade/index.d.ts +2 -0
- package/dist/components/animate-fade/index.js +1 -0
- package/dist/components/animate-grow/MPAnimateGrow.d.ts +52 -0
- package/dist/components/animate-grow/MPAnimateGrow.js +1 -0
- package/dist/components/animate-grow/index.d.ts +2 -0
- package/dist/components/animate-grow/index.js +1 -0
- package/dist/components/animate-headline/MPAnimateHeadline.d.ts +63 -0
- package/dist/components/animate-headline/MPAnimateHeadline.js +1 -0
- package/dist/components/animate-headline/index.d.ts +2 -0
- package/dist/components/animate-headline/index.js +1 -0
- package/dist/components/animate-lighting/MPAnimateLighting.d.ts +68 -0
- package/dist/components/animate-lighting/MPAnimateLighting.js +1 -0
- package/dist/components/animate-lighting/index.d.ts +2 -0
- package/dist/components/animate-lighting/index.js +1 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.d.ts +66 -0
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -0
- package/dist/components/animate-marquee/index.d.ts +2 -0
- package/dist/components/animate-marquee/index.js +1 -0
- package/dist/components/animate-rotate/MPAnimateRotate.d.ts +56 -0
- package/dist/components/animate-rotate/MPAnimateRotate.js +1 -0
- package/dist/components/animate-rotate/index.d.ts +2 -0
- package/dist/components/animate-rotate/index.js +1 -0
- package/dist/components/animate-slide/MPAnimateSlide.d.ts +53 -0
- package/dist/components/animate-slide/MPAnimateSlide.js +1 -0
- package/dist/components/animate-slide/index.d.ts +2 -0
- package/dist/components/animate-slide/index.js +1 -0
- package/dist/components/animate-typing/MPAnimateTyping.d.ts +59 -0
- package/dist/components/animate-typing/MPAnimateTyping.js +1 -0
- package/dist/components/animate-typing/index.d.ts +2 -0
- package/dist/components/animate-typing/index.js +1 -0
- package/dist/components/animate-zoom/MPAnimateZoom.d.ts +44 -0
- package/dist/components/animate-zoom/MPAnimateZoom.js +1 -0
- package/dist/components/animate-zoom/index.d.ts +2 -0
- package/dist/components/animate-zoom/index.js +1 -0
- package/dist/components/aspect-ratio/MPAspectRatio.d.ts +69 -0
- package/dist/components/aspect-ratio/MPAspectRatio.js +1 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.js +1 -0
- package/dist/components/avatar/MPAvatar.d.ts +104 -0
- package/dist/components/avatar/MPAvatar.js +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/badge/MPBadge.d.ts +104 -0
- package/dist/components/badge/MPBadge.js +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/blockquote/MPBlockquote.d.ts +73 -0
- package/dist/components/blockquote/MPBlockquote.js +1 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/blockquote/index.js +1 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.d.ts +144 -0
- package/dist/components/bottom-navigation/MPBottomNavigation.js +1 -0
- package/dist/components/bottom-navigation/index.d.ts +2 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/box/MPBox.d.ts +78 -0
- package/dist/components/box/MPBox.js +1 -0
- package/dist/components/box/index.d.ts +2 -0
- package/dist/components/box/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +127 -0
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/MPButton.d.ts +75 -0
- package/dist/components/button/MPButton.js +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/MPButtonGroup.d.ts +31 -0
- package/dist/components/button-group/MPButtonGroup.js +1 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card/MPCard.d.ts +73 -0
- package/dist/components/card/MPCard.js +1 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/carousel/MPCarousel.d.ts +116 -0
- package/dist/components/carousel/MPCarousel.js +1 -0
- package/dist/components/carousel/index.d.ts +2 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/chat-bubble/MPChatBubble.d.ts +132 -0
- package/dist/components/chat-bubble/MPChatBubble.js +1 -0
- package/dist/components/chat-bubble/index.d.ts +2 -0
- package/dist/components/chat-bubble/index.js +1 -0
- package/dist/components/checkbox/MPCheckbox.d.ts +76 -0
- package/dist/components/checkbox/MPCheckbox.js +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/MPChip.d.ts +74 -0
- package/dist/components/chip/MPChip.js +1 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/collapsible/MPCollapsible.d.ts +97 -0
- package/dist/components/collapsible/MPCollapsible.js +1 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/color-picker/MPColorPicker.d.ts +131 -0
- package/dist/components/color-picker/MPColorPicker.js +1 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +1 -0
- package/dist/components/combobox/MPCombobox.d.ts +175 -0
- package/dist/components/combobox/MPCombobox.js +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/container/MPContainer.d.ts +75 -0
- package/dist/components/container/MPContainer.js +1 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/container/index.js +1 -0
- package/dist/components/date-picker/MPDatePicker.d.ts +98 -0
- package/dist/components/date-picker/MPDatePicker.js +1 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/date-range-picker/MPDateRangePicker.d.ts +98 -0
- package/dist/components/date-range-picker/MPDateRangePicker.js +1 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/index.js +1 -0
- package/dist/components/date-time-picker/MPDateTimePicker.d.ts +78 -0
- package/dist/components/date-time-picker/MPDateTimePicker.js +1 -0
- package/dist/components/date-time-picker/index.d.ts +2 -0
- package/dist/components/date-time-picker/index.js +1 -0
- package/dist/components/dialog/MPDialog.d.ts +150 -0
- package/dist/components/dialog/MPDialog.js +1 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/divider/MPDivider.d.ts +80 -0
- package/dist/components/divider/MPDivider.js +1 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/MPDrawer.d.ts +168 -0
- package/dist/components/drawer/MPDrawer.js +1 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/empty/MPEmpty.d.ts +74 -0
- package/dist/components/empty/MPEmpty.js +1 -0
- package/dist/components/empty/index.d.ts +2 -0
- package/dist/components/empty/index.js +1 -0
- package/dist/components/file-picker/MPFilePicker.d.ts +113 -0
- package/dist/components/file-picker/MPFilePicker.js +1 -0
- package/dist/components/file-picker/index.d.ts +2 -0
- package/dist/components/file-picker/index.js +1 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.d.ts +126 -0
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -0
- package/dist/components/floating-action-button/index.d.ts +2 -0
- package/dist/components/floating-action-button/index.js +1 -0
- package/dist/components/grid/MPGrid.d.ts +155 -0
- package/dist/components/grid/MPGrid.js +1 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/grid/index.js +1 -0
- package/dist/components/highlight/MPHighlight.d.ts +95 -0
- package/dist/components/highlight/MPHighlight.js +1 -0
- package/dist/components/highlight/index.d.ts +2 -0
- package/dist/components/highlight/index.js +1 -0
- package/dist/components/icon-button/MPIconButton.d.ts +59 -0
- package/dist/components/icon-button/MPIconButton.js +1 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/list/MPList.d.ts +96 -0
- package/dist/components/list/MPList.js +1 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/locale/MPLocaleProvider.d.ts +63 -0
- package/dist/components/locale/MPLocaleProvider.js +1 -0
- package/dist/components/locale/index.d.ts +2 -0
- package/dist/components/locale/index.js +1 -0
- package/dist/components/menu/MPMenu.d.ts +232 -0
- package/dist/components/menu/MPMenu.js +1 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/number-field/MPNumberField.d.ts +117 -0
- package/dist/components/number-field/MPNumberField.js +1 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/index.js +1 -0
- package/dist/components/otp-field/MPOtpField.d.ts +89 -0
- package/dist/components/otp-field/MPOtpField.js +1 -0
- package/dist/components/otp-field/index.d.ts +2 -0
- package/dist/components/otp-field/index.js +1 -0
- package/dist/components/overlay/MPOverlay.d.ts +96 -0
- package/dist/components/overlay/MPOverlay.js +1 -0
- package/dist/components/overlay/index.d.ts +2 -0
- package/dist/components/overlay/index.js +1 -0
- package/dist/components/pagination/MPPagination.d.ts +106 -0
- package/dist/components/pagination/MPPagination.js +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/panes/MPPanes.d.ts +100 -0
- package/dist/components/panes/MPPanes.js +1 -0
- package/dist/components/panes/index.d.ts +2 -0
- package/dist/components/panes/index.js +1 -0
- package/dist/components/pill/MPPill.d.ts +117 -0
- package/dist/components/pill/MPPill.js +1 -0
- package/dist/components/pill/index.d.ts +2 -0
- package/dist/components/pill/index.js +1 -0
- package/dist/components/popover/MPPopover.d.ts +143 -0
- package/dist/components/popover/MPPopover.js +1 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/progress-box/MPProgressBox.d.ts +40 -0
- package/dist/components/progress-box/MPProgressBox.js +1 -0
- package/dist/components/progress-box/index.d.ts +2 -0
- package/dist/components/progress-box/index.js +1 -0
- package/dist/components/progress-circular/MPProgressCircular.d.ts +32 -0
- package/dist/components/progress-circular/MPProgressCircular.js +1 -0
- package/dist/components/progress-circular/index.d.ts +2 -0
- package/dist/components/progress-circular/index.js +1 -0
- package/dist/components/progress-linear/MPProgressLinear.d.ts +32 -0
- package/dist/components/progress-linear/MPProgressLinear.js +1 -0
- package/dist/components/progress-linear/index.d.ts +2 -0
- package/dist/components/progress-linear/index.js +1 -0
- package/dist/components/radio-group/MPRadioGroup.d.ts +81 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/rating/MPRating.d.ts +135 -0
- package/dist/components/rating/MPRating.js +1 -0
- package/dist/components/rating/index.d.ts +2 -0
- package/dist/components/rating/index.js +1 -0
- package/dist/components/segmented-button/MPSegmentedButton.d.ts +75 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -0
- package/dist/components/segmented-button/index.d.ts +2 -0
- package/dist/components/segmented-button/index.js +1 -0
- package/dist/components/select/MPSelect.d.ts +103 -0
- package/dist/components/select/MPSelect.js +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/shortcut/MPShortcut.d.ts +67 -0
- package/dist/components/shortcut/MPShortcut.js +1 -0
- package/dist/components/shortcut/index.d.ts +2 -0
- package/dist/components/shortcut/index.js +1 -0
- package/dist/components/skeleton/MPSkeleton.d.ts +76 -0
- package/dist/components/skeleton/MPSkeleton.js +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/slider/MPSlider.d.ts +77 -0
- package/dist/components/slider/MPSlider.js +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/snackbar/MPSnackbar.d.ts +175 -0
- package/dist/components/snackbar/MPSnackbar.js +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/index.js +1 -0
- package/dist/components/spoiler/MPSpoiler.d.ts +106 -0
- package/dist/components/spoiler/MPSpoiler.js +1 -0
- package/dist/components/spoiler/index.d.ts +2 -0
- package/dist/components/spoiler/index.js +1 -0
- package/dist/components/switch/MPSwitch.d.ts +75 -0
- package/dist/components/switch/MPSwitch.js +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/MPTable.d.ts +120 -0
- package/dist/components/table/MPTable.js +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/MPTabs.d.ts +145 -0
- package/dist/components/tabs/MPTabs.js +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/text-field/MPTextField.d.ts +51 -22
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.d.ts +88 -0
- package/dist/components/text-link/MPTextLink.js +1 -0
- package/dist/components/text-link/index.d.ts +2 -0
- package/dist/components/text-link/index.js +1 -0
- package/dist/components/time-picker/MPTimePicker.d.ts +108 -0
- package/dist/components/time-picker/MPTimePicker.js +1 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/time-picker/index.js +1 -0
- package/dist/components/timeline/MPTimeline.d.ts +96 -0
- package/dist/components/timeline/MPTimeline.js +1 -0
- package/dist/components/timeline/index.d.ts +2 -0
- package/dist/components/timeline/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.d.ts +117 -0
- package/dist/components/tooltip/MPTooltip.js +1 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/typography/MPTypography.d.ts +94 -0
- package/dist/components/typography/MPTypography.js +1 -0
- package/dist/components/typography/index.d.ts +2 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/constants/icons.d.ts +49 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +73 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.d.ts +118 -0
- package/dist/internal/Calendar.js +1 -0
- package/dist/internal/FieldOutline.d.ts +109 -0
- package/dist/internal/FieldOutline.js +1 -0
- package/dist/internal/Picker.d.ts +153 -0
- package/dist/internal/Picker.js +1 -0
- package/dist/internal/StateLayer.d.ts +45 -0
- package/dist/internal/StateLayer.js +1 -0
- package/dist/internal/SupportingText.d.ts +23 -0
- package/dist/internal/SupportingText.js +1 -0
- package/dist/internal/WidthSizer.d.ts +31 -0
- package/dist/internal/WidthSizer.js +1 -0
- package/dist/internal/accent.d.ts +39 -0
- package/dist/internal/accent.js +1 -0
- package/dist/internal/animate.d.ts +179 -0
- package/dist/internal/animate.js +1 -0
- package/dist/internal/button-group.d.ts +21 -0
- package/dist/internal/button-group.js +1 -0
- package/dist/internal/color.d.ts +125 -0
- package/dist/internal/color.js +1 -0
- package/dist/internal/date.d.ts +179 -0
- package/dist/internal/date.js +1 -0
- package/dist/internal/i18n.d.ts +241 -0
- package/dist/internal/i18n.js +1 -0
- package/dist/internal/inert.d.ts +11 -0
- package/dist/internal/inert.js +1 -0
- package/dist/internal/locale.d.ts +43 -0
- package/dist/internal/locale.js +1 -0
- package/dist/internal/menu.d.ts +23 -0
- package/dist/internal/menu.js +1 -0
- package/dist/internal/progress.d.ts +126 -0
- package/dist/internal/progress.js +1 -0
- package/dist/internal/scale.d.ts +127 -0
- package/dist/internal/scale.js +1 -0
- package/dist/internal/surface.d.ts +76 -0
- package/dist/internal/surface.js +1 -0
- package/dist/internal/visually-hidden.d.ts +23 -0
- package/dist/internal/visually-hidden.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1871 -20
- package/dist/types.d.ts +262 -16
- package/package.json +16 -21
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Dialog } from '@base-ui/react/dialog';
|
|
3
|
+
import type { MPColor, MPSize } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* A dialog takes `size` and `color` and stops there.
|
|
6
|
+
*
|
|
7
|
+
* There is no `variant`: the five weights answer "how much of a surface does this
|
|
8
|
+
* paint against the page around it", and a modal has already taken the page.
|
|
9
|
+
* There is no `elevation` prop either — see the note on the sheet below.
|
|
10
|
+
*/
|
|
11
|
+
export interface MPDialogProps {
|
|
12
|
+
/** The dialog is shown. Use with `onOpenChange` for a controlled dialog. */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/** Whether the dialog starts open, for an uncontrolled one. */
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
onOpenChange?: (open: boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The element that opens the dialog, wired up by Base UI. Optional — a
|
|
19
|
+
* controlled dialog opened from elsewhere in the application needs no trigger
|
|
20
|
+
* at all, and passing one here is a convenience for the common case.
|
|
21
|
+
*/
|
|
22
|
+
trigger?: React.ReactElement;
|
|
23
|
+
/**
|
|
24
|
+
* A glyph above the headline.
|
|
25
|
+
*
|
|
26
|
+
* MD3's own hero icon, and passing one is what centres the header: a dialog
|
|
27
|
+
* with an icon is announcing something, and a dialog without one is asking
|
|
28
|
+
* something. Both are correct; they are two different dialogs.
|
|
29
|
+
*/
|
|
30
|
+
icon?: React.ReactNode;
|
|
31
|
+
/** The headline. Rendered as the `<h2>` that names the dialog. */
|
|
32
|
+
title?: React.ReactNode;
|
|
33
|
+
/** The supporting text under it, and the dialog's accessible description. */
|
|
34
|
+
description?: React.ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* The bottom row. Laid out end-aligned, so a pair of buttons needs no wrapper
|
|
37
|
+
* of its own — and `MPDialogClose` is what makes one of them dismiss.
|
|
38
|
+
*/
|
|
39
|
+
actions?: React.ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Draws a hairline between the header, the body and the actions instead of
|
|
42
|
+
* separating them with space. Worth turning on the moment the body scrolls: the
|
|
43
|
+
* lines are what say the header stayed put.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
dividers?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Shows the × in the corner.
|
|
49
|
+
*
|
|
50
|
+
* Defaults to whatever `fullScreen` is, which is MD3's own split: a basic
|
|
51
|
+
* dialog is answered by its actions and has no ×, while a full-screen dialog
|
|
52
|
+
* carries one at the start of its top bar because there is no scrim left to
|
|
53
|
+
* click. Set it explicitly to disagree with either.
|
|
54
|
+
*/
|
|
55
|
+
showClose?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible name of the × button. Defaults to the word for "close" in
|
|
58
|
+
* `locale`.
|
|
59
|
+
*/
|
|
60
|
+
closeLabel?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Which language the × button's default name is written in. Falls back to the
|
|
63
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
64
|
+
*/
|
|
65
|
+
locale?: string;
|
|
66
|
+
/**
|
|
67
|
+
* A hard cap on the sheet's width, overriding the one `size` implies. Numbers
|
|
68
|
+
* are pixels. For the dialog whose *content* decides its width — a wide table,
|
|
69
|
+
* a narrow confirmation — rather than for tuning the scale, which is `size`.
|
|
70
|
+
*/
|
|
71
|
+
width?: number | string;
|
|
72
|
+
/**
|
|
73
|
+
* The sheet takes the full width its `size` allows.
|
|
74
|
+
*
|
|
75
|
+
* On by default, which is the other way round from every other component in the
|
|
76
|
+
* library. Elsewhere `fullWidth` means "fill the container"; a dialog's
|
|
77
|
+
* container is the viewport, and a dialog that shrank to fit two words would be
|
|
78
|
+
* a tooltip.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
fullWidth?: boolean;
|
|
82
|
+
/** Fills the viewport edge to edge. For a phone-sized screen, or an editor. */
|
|
83
|
+
fullScreen?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the page behind is taken away. `'trap-focus'` keeps the page
|
|
86
|
+
* scrollable and clickable while still holding focus inside.
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
modal?: boolean | 'trap-focus';
|
|
90
|
+
/**
|
|
91
|
+
* Whether Escape or a click outside closes the dialog. Turn it off for the
|
|
92
|
+
* dialog that has to be answered — and then give it actions that answer it,
|
|
93
|
+
* because there will be no other way out.
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
dismissible?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The type scale the sheet is drawn at, and how wide it is allowed to get.
|
|
99
|
+
* @default 'md'
|
|
100
|
+
*/
|
|
101
|
+
size?: MPSize;
|
|
102
|
+
/**
|
|
103
|
+
* Which accent family the hero icon reads.
|
|
104
|
+
*
|
|
105
|
+
* The sheet itself stays neutral, exactly as MD3's does — a dialog is already
|
|
106
|
+
* the only thing on the screen, and painting it in an accent would be shouting
|
|
107
|
+
* at a reader who is not looking anywhere else. The icon is the one part that
|
|
108
|
+
* carries a family, and `secondary` is the spec's own choice for it.
|
|
109
|
+
* @default 'secondary'
|
|
110
|
+
*/
|
|
111
|
+
color?: MPColor;
|
|
112
|
+
/** The body. */
|
|
113
|
+
children?: React.ReactNode;
|
|
114
|
+
className?: string;
|
|
115
|
+
style?: React.CSSProperties;
|
|
116
|
+
}
|
|
117
|
+
export type MPDialogCloseProps = React.ComponentProps<typeof Dialog.Close>;
|
|
118
|
+
/**
|
|
119
|
+
* Closes the dialog it is inside.
|
|
120
|
+
*
|
|
121
|
+
* Exported because an uncontrolled dialog has no `setOpen` for its Cancel button
|
|
122
|
+
* to call, and the alternative — making every dialog controlled — is a piece of
|
|
123
|
+
* state per dialog that exists only to answer a button.
|
|
124
|
+
*
|
|
125
|
+
* `render` is Base UI's own escape hatch, so a real Material Plus button
|
|
126
|
+
* dismisses: `<MPDialogClose render={<MPButton variant="text">Cancel</MPButton>} />`.
|
|
127
|
+
*/
|
|
128
|
+
export declare const MPDialogClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
129
|
+
/**
|
|
130
|
+
* A sheet that takes the page away until it is answered.
|
|
131
|
+
*
|
|
132
|
+
* The sections are props rather than compound sub-components: the arrangement of
|
|
133
|
+
* a dialog is fixed — icon, headline, supporting text, body, actions — and what a
|
|
134
|
+
* caller wants to decide is what goes in each slot, not what order they come in.
|
|
135
|
+
*
|
|
136
|
+
* Base UI owns everything hard about it: the focus trap, the scroll lock, the
|
|
137
|
+
* `aria-labelledby` / `aria-describedby` wiring, restoring focus to the trigger,
|
|
138
|
+
* and the inert page behind. What is left here is the surface, the width ladder
|
|
139
|
+
* and the scroll behaviour — the header and the actions stay put while only the
|
|
140
|
+
* body scrolls, which is why `dividers` matters more here than on a list.
|
|
141
|
+
*
|
|
142
|
+
* ## The sheet
|
|
143
|
+
*
|
|
144
|
+
* `surface-container-high` at `corner-extra-large`, elevation 3 — MD3's own three
|
|
145
|
+
* choices for a dialog, and the only surface in this library that carries the
|
|
146
|
+
* third elevation level. There is no `elevation` prop for the same reason there
|
|
147
|
+
* is no `variant`: a dialog that could be told to sit flat on the page would be a
|
|
148
|
+
* dialog that could be told to stop being a dialog.
|
|
149
|
+
*/
|
|
150
|
+
export declare function MPDialog({ open, defaultOpen, onOpenChange, trigger, icon, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, width, fullWidth, fullScreen, modal, dismissible, size, color, className, style, children }: MPDialogProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import{Dialog as i}from"@base-ui/react/dialog";import{MPIcon as t}from"../icon/MPIcon";import{CloseIcon as n}from"../../constants/icons";import{accentSlots as o}from"../../internal/accent";import{useMPLocale as s,useMPMessages as r}from"../../internal/locale";import{MPStateLayer as a}from"../../internal/StateLayer";import{SHEET_GAP as m,hasContent as c}from"../../internal/scale";import{FADE as p,PORTAL_LAYER as d,SCRIM as x}from"../../internal/surface";const f={xs:"max-w-[320px]",sm:"max-w-[400px]",md:"max-w-[560px]",lg:"max-w-[720px]",xl:"max-w-[960px]"},u={xs:"p-3",sm:"p-4",md:"p-6",lg:"p-7",xl:"p-8"},h={xs:"px-3",sm:"px-4",md:"px-6",lg:"px-7",xl:"px-8"},g={xs:"py-3",sm:"py-4",md:"py-6",lg:"py-7",xl:"py-8"},y={xs:"text-mp-title-medium",sm:"text-mp-title-large",md:"text-mp-headline-small",lg:"text-mp-headline-medium",xl:"text-mp-headline-large"},v={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-large",xl:"text-mp-body-large"},b={xs:20,sm:22,md:24,lg:28,xl:32};export const MPDialogClose=i.Close;export function MPDialog({open:w,defaultOpen:j,onOpenChange:N,trigger:$,icon:k,title:C,description:P,actions:B,dividers:z=!1,showClose:D,closeLabel:O,locale:M,width:L,fullWidth:S=!0,fullScreen:T=!1,modal:W=!0,dismissible:I=!0,size:R="md",color:V="secondary",className:_,style:q,children:A}){const E=s(M),F=r("common",E),G=D??T,H=c(k),J=c(C)||c(P)||H,K=c(B),Q=z?u[R]:h[R],U="border-mp-outline-variant border-t";return l(i.Root,{open:w,defaultOpen:j,modal:W,disablePointerDismissal:!I,onOpenChange:(e,l)=>{I||e||"escape-key"!==l.reason?N?.(e):l.cancel()},children:[$?e(i.Trigger,{render:$}):null,l(i.Portal,{children:[e(i.Backdrop,{className:`${d} fixed inset-0 ${p} ${x}`}),e(i.Viewport,{className:[d,"fixed inset-0 flex justify-center",T?"items-stretch":"items-center p-4"].join(" "),children:l(i.Popup,{"data-mp-size":R,className:["mp-dialog relative flex w-full flex-col overflow-hidden","bg-mp-surface-container-high text-mp-on-surface shadow-mp-3 outline-none",T?"h-full max-w-none rounded-none":`rounded-mp-xl max-h-full ${void 0===L?f[R]:""}`,T||S?"":"w-auto",z?"":`${g[R]} ${m[R]}`,p,_??""].filter(Boolean).join(" "),style:{...o(V),...void 0===L||T?null:{maxWidth:"number"==typeof L?`${L}px`:L},...q},children:[J||G?l("div",{className:["flex shrink-0 items-start gap-3",Q,H&&!G?"flex-col items-center text-center":""].filter(Boolean).join(" "),children:[H?e("span",{className:"flex shrink-0 items-center justify-center text-(--_mp-accent)",children:k}):null,l("div",{className:`flex min-w-0 flex-1 flex-col ${m[R]}`,children:[c(C)?e(i.Title,{className:`m-0 ${y[R]}`,children:C}):null,c(P)?e(i.Description,{className:`text-mp-on-surface-variant m-0 ${v[R]}`,children:P}):null]}),G?l(i.Close,{"aria-label":O??F.close,className:["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full cursor-pointer items-center justify-center","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(a,{}),e(t,{icon:n,size:b[R]})]}):null]}):null,c(A)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",v[R],Q,z&&(J||G)?U:""].filter(Boolean).join(" "),children:A}):null,K?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",Q,z?U:""].filter(Boolean).join(" "),children:B}):null]})})]})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPDialog,MPDialogClose}from"./MPDialog";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPAlign, MPColor, MPOrientation, MPSize } from '../../types';
|
|
3
|
+
/** Where the label sits along a labelled divider. Ignored without a label. */
|
|
4
|
+
export type MPDividerTextAlign = MPAlign;
|
|
5
|
+
export interface MPDividerProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'children'> {
|
|
6
|
+
/**
|
|
7
|
+
* Which way the line runs. A vertical divider has no height of its own — it
|
|
8
|
+
* stretches to its flex parent, the way a rule between two toolbar groups
|
|
9
|
+
* should.
|
|
10
|
+
* @default 'horizontal'
|
|
11
|
+
*/
|
|
12
|
+
orientation?: MPOrientation;
|
|
13
|
+
/**
|
|
14
|
+
* Which accent family the rule is drawn in.
|
|
15
|
+
*
|
|
16
|
+
* **This is the one component in the library whose `color` has no default**,
|
|
17
|
+
* and the reason is the specification: MD3 gives a divider exactly one colour,
|
|
18
|
+
* `outline-variant`, and it is not an accent at all. It is the quietest line
|
|
19
|
+
* in the token sheet — quieter than `outline`, which is the edge of a control
|
|
20
|
+
* — because a divider's job is to separate two things without becoming a
|
|
21
|
+
* third.
|
|
22
|
+
*
|
|
23
|
+
* So left unset the rule is `outline-variant`, which is the Material divider.
|
|
24
|
+
* Setting it tints the rule with an accent, for the case a divider is carrying
|
|
25
|
+
* meaning rather than structure — the line under a failed section.
|
|
26
|
+
*/
|
|
27
|
+
color?: MPColor;
|
|
28
|
+
/** Type scale of the label. Nothing else on a divider has a size. */
|
|
29
|
+
size?: MPSize;
|
|
30
|
+
/**
|
|
31
|
+
* How far the rule runs — the width of a horizontal divider, the height of a
|
|
32
|
+
* vertical one. A number is pixels; a string is any CSS length, so `'50%'`
|
|
33
|
+
* and `'12rem'` both work.
|
|
34
|
+
*
|
|
35
|
+
* `length` rather than `width`, because a divider is the one component whose
|
|
36
|
+
* long axis turns with `orientation`: a `width` that meant height half the
|
|
37
|
+
* time would be a worse name than a longer one.
|
|
38
|
+
*
|
|
39
|
+
* Left out, a horizontal divider is the full width of its container and a
|
|
40
|
+
* vertical one stretches to the height of the flex row it is in — which is
|
|
41
|
+
* what a rule between two things should do by default.
|
|
42
|
+
*/
|
|
43
|
+
length?: number | string;
|
|
44
|
+
/**
|
|
45
|
+
* How thick the rule is. A number is pixels; a string is any CSS length.
|
|
46
|
+
*
|
|
47
|
+
* MD3's divider is 1dp and there is no second thickness in the specification.
|
|
48
|
+
* This exists for the hairline that has to survive a display where 1px is
|
|
49
|
+
* half a device pixel, not as a weight to design with.
|
|
50
|
+
* @default 1
|
|
51
|
+
*/
|
|
52
|
+
thickness?: number | string;
|
|
53
|
+
/** A label set into the line — "OR" between two sign-in options. */
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Where the label sits. `center` splits the line in half; `start` and `end`
|
|
57
|
+
* leave a short stub on the near side so the label still reads as set *into*
|
|
58
|
+
* the rule rather than floating above it.
|
|
59
|
+
* @default 'center'
|
|
60
|
+
*/
|
|
61
|
+
textAlign?: MPDividerTextAlign;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A rule between two things.
|
|
65
|
+
*
|
|
66
|
+
* With no children it is Base UI's `Separator` and nothing else — a real
|
|
67
|
+
* `role="separator"` with the right `aria-orientation`. With children the line
|
|
68
|
+
* breaks around the label.
|
|
69
|
+
*
|
|
70
|
+
* `separator` is not a name-from-content role, so the visible label does *not*
|
|
71
|
+
* become the accessible name on its own: a screen reader would announce a bare
|
|
72
|
+
* "separator" and the word "OR" would be read as loose text somewhere nearby. A
|
|
73
|
+
* string label is therefore copied into `aria-label`. Anything richer is left
|
|
74
|
+
* alone — only the caller knows which part of it is the name.
|
|
75
|
+
*
|
|
76
|
+
* There is no `variant` and no elevation. A divider is not a surface: it has no
|
|
77
|
+
* container to paint, so four of the five variants would have nothing to say and
|
|
78
|
+
* the fifth would be the line it already is.
|
|
79
|
+
*/
|
|
80
|
+
export declare const MPDivider: React.ForwardRefExoticComponent<MPDividerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{Separator as l}from"@base-ui/react/separator";import{hasContent as a}from"../../internal/scale";const i="[border-color:var(--_mp-line)]";function o(e){return"number"==typeof e?`${e}px`:e}const n={horizontal:{start:["w-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","w-4 shrink-0"]},vertical:{start:["h-4 shrink-0","flex-1"],center:["flex-1","flex-1"],end:["flex-1","h-4 shrink-0"]}},s={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-medium",lg:"text-mp-label-large",xl:"text-mp-label-large"},m={xs:"gap-1.5",sm:"gap-2",md:"gap-3",lg:"gap-3.5",xl:"gap-4"};export const MPDivider=t.forwardRef(function({orientation:t="horizontal",color:p,size:d="md",length:c,thickness:f,textAlign:h="center",className:x,style:u,children:v,...b},w){const g="vertical"===t,_=a(v),$={"--_mp-line":p?`var(--_mp-color-${p})`:"var(--_mp-color-outline-variant)","--_mp-rule":o(f)??"1px"},j=o(c),k={...$,...void 0===j?null:g?{height:j}:{width:j},...u};if(!_)return e(l,{ref:w,orientation:t,"data-mp-size":d,className:["mp-divider",g?"w-0 border-l [border-left-width:var(--_mp-rule)] "+(void 0===j?"self-stretch":""):"h-0 w-full border-t [border-top-width:var(--_mp-rule)]",i,x??""].filter(Boolean).join(" "),style:k,...b});const[N,y]=n[t][h],z=g?"w-0 border-l [border-left-width:var(--_mp-rule)]":"h-0 border-t [border-top-width:var(--_mp-rule)]";return r(l,{ref:w,orientation:t,"aria-label":"string"==typeof v?v:void 0,"data-mp-size":d,className:["mp-divider flex items-center",g?"w-auto flex-col "+(void 0===j?"self-stretch":""):"w-full",m[d],x??""].filter(Boolean).join(" "),style:k,...b,children:[e("span",{"aria-hidden":"true",className:`${z} ${N} ${i}`}),e("span",{className:["text-mp-on-surface-variant shrink-0 whitespace-nowrap",s[d],g?"[writing-mode:vertical-rl]":""].filter(Boolean).join(" "),children:v}),e("span",{"aria-hidden":"true",className:`${z} ${y} ${i}`})]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPDivider}from"./MPDivider";
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Dialog } from '@base-ui/react/dialog';
|
|
3
|
+
import type { MPSide, MPSize } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* How the panel relates to the page, in MD3's own two words for it.
|
|
6
|
+
*
|
|
7
|
+
* - `modal` — it is opened, it floats over the page on a scrim, it holds the
|
|
8
|
+
* focus, and it is dismissed. The navigation drawer behind a hamburger, the
|
|
9
|
+
* filter panel beside a table, the bottom sheet a phone raises.
|
|
10
|
+
* - `standard` — it is part of the layout and the page is laid out around it.
|
|
11
|
+
* No scrim, no portal, no focus trap, nothing to dismiss. The sidebar that is
|
|
12
|
+
* simply there.
|
|
13
|
+
*
|
|
14
|
+
* A separate axis from `variant`, which is why this component has no `variant`:
|
|
15
|
+
* the five weights answer "how much does this surface assert itself against the
|
|
16
|
+
* page", and a panel that has taken an edge of the window has answered it.
|
|
17
|
+
*/
|
|
18
|
+
export type MPDrawerMode = 'modal' | 'standard';
|
|
19
|
+
/**
|
|
20
|
+
* A drawer takes `side`, `mode` and `size`, and stops there.
|
|
21
|
+
*
|
|
22
|
+
* There is no `variant`, for [MPDialog](../feedback/dialog)'s reason. There is
|
|
23
|
+
* no `color` either: MD3's navigation drawer is `surface-container-low` under
|
|
24
|
+
* neutral ink, and what carries an accent inside one is the *selected row*,
|
|
25
|
+
* which belongs to whatever list the caller puts in it.
|
|
26
|
+
*/
|
|
27
|
+
export interface MPDrawerProps {
|
|
28
|
+
/**
|
|
29
|
+
* Which edge the panel is attached to.
|
|
30
|
+
*
|
|
31
|
+
* Physical rather than logical, the way `MPSide` is everywhere in this
|
|
32
|
+
* library: a drawer along the top of the window is along the top in every
|
|
33
|
+
* writing direction.
|
|
34
|
+
* @default 'left'
|
|
35
|
+
*/
|
|
36
|
+
side?: MPSide;
|
|
37
|
+
/** @default 'modal' */
|
|
38
|
+
mode?: MPDrawerMode;
|
|
39
|
+
/** The drawer is shown. Use with `onOpenChange` for a controlled drawer. */
|
|
40
|
+
open?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the drawer starts open, for an uncontrolled one.
|
|
43
|
+
*
|
|
44
|
+
* Defaults to `false` in `modal` mode and `true` in `standard` mode, because a
|
|
45
|
+
* fixed sidebar that had to be opened before it appeared would not be a fixed
|
|
46
|
+
* sidebar.
|
|
47
|
+
*/
|
|
48
|
+
defaultOpen?: boolean;
|
|
49
|
+
onOpenChange?: (open: boolean) => void;
|
|
50
|
+
/**
|
|
51
|
+
* The element that opens the drawer, wired up by Base UI.
|
|
52
|
+
*
|
|
53
|
+
* `modal` only. A `standard` drawer is not opened — it is in the layout — so a
|
|
54
|
+
* trigger there would have nothing to do and is not rendered.
|
|
55
|
+
*/
|
|
56
|
+
trigger?: React.ReactElement;
|
|
57
|
+
/** The heading. Rendered as the element that names the drawer. */
|
|
58
|
+
title?: React.ReactNode;
|
|
59
|
+
/** A line under it, and the drawer's accessible description. */
|
|
60
|
+
description?: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* The bottom row, held against the foot of the panel while the body scrolls.
|
|
63
|
+
* Laid out end-aligned, so a pair of buttons needs no wrapper of its own — and
|
|
64
|
+
* `MPDrawerClose` is what makes one of them dismiss.
|
|
65
|
+
*/
|
|
66
|
+
actions?: React.ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Draws a hairline between the header, the body and the actions instead of
|
|
69
|
+
* separating them with space. Worth turning on the moment the body scrolls:
|
|
70
|
+
* the lines are what say the header stayed put.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
dividers?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Shows the × in the corner.
|
|
76
|
+
*
|
|
77
|
+
* On in `modal` mode, where the panel has taken the page and the way out
|
|
78
|
+
* should not have to be remembered; off in `standard` mode, where a × that
|
|
79
|
+
* closes a fixed sidebar with nothing to reopen it is a one-way door.
|
|
80
|
+
*/
|
|
81
|
+
showClose?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Accessible name of the × button. Defaults to the word for "close" in
|
|
84
|
+
* `locale`.
|
|
85
|
+
*/
|
|
86
|
+
closeLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Which language the × button's default name is written in. Falls back to the
|
|
89
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
90
|
+
*/
|
|
91
|
+
locale?: string;
|
|
92
|
+
/**
|
|
93
|
+
* How far the panel reaches in from its edge: a **width** for `left` and
|
|
94
|
+
* `right`, a **height** for `top` and `bottom`. Numbers are pixels.
|
|
95
|
+
*
|
|
96
|
+
* Left alone, a side panel takes the width its `size` implies and a top or
|
|
97
|
+
* bottom panel is as tall as what is in it, up to 85% of the window.
|
|
98
|
+
*/
|
|
99
|
+
extent?: number | string;
|
|
100
|
+
/**
|
|
101
|
+
* Rounds the corners on the edge that faces the page — the top and bottom of a
|
|
102
|
+
* side panel, the inner pair of a top or bottom one.
|
|
103
|
+
*
|
|
104
|
+
* The corners against the window edge are always square, because a corner cut
|
|
105
|
+
* off something that has no visible end is a corner cut off nothing.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
rounded?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Whether pressing Escape or clicking the scrim closes the drawer. Turn it off
|
|
111
|
+
* for the drawer that has to be answered — and then give it actions that
|
|
112
|
+
* answer it, because there will be no other way out. `modal` only.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
dismissible?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* How far the panel reaches in by default, and the type scale inside it.
|
|
118
|
+
* `md` is MD3's own 360dp navigation drawer.
|
|
119
|
+
* @default 'md'
|
|
120
|
+
*/
|
|
121
|
+
size?: MPSize;
|
|
122
|
+
/** The body. */
|
|
123
|
+
children?: React.ReactNode;
|
|
124
|
+
className?: string;
|
|
125
|
+
style?: React.CSSProperties;
|
|
126
|
+
}
|
|
127
|
+
export type MPDrawerCloseProps = React.ComponentProps<typeof Dialog.Close>;
|
|
128
|
+
/**
|
|
129
|
+
* Closes the drawer it is inside.
|
|
130
|
+
*
|
|
131
|
+
* Exported for `MPDialogClose`'s reason: an uncontrolled drawer has no `setOpen`
|
|
132
|
+
* for its Cancel button to call, and making every drawer controlled is a piece
|
|
133
|
+
* of state per drawer that exists only to answer a button.
|
|
134
|
+
*
|
|
135
|
+
* It is a `modal` drawer's button — a `standard` one is not a Base UI dialog and
|
|
136
|
+
* has nothing for this to talk to. `render` is Base UI's own escape hatch, so a
|
|
137
|
+
* real Material Plus button dismisses:
|
|
138
|
+
* `<MPDrawerClose render={<MPButton variant="text">Cancel</MPButton>} />`.
|
|
139
|
+
*/
|
|
140
|
+
export declare const MPDrawerClose: React.ForwardRefExoticComponent<Omit<import("@base-ui/react").AlertDialogCloseProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
141
|
+
/**
|
|
142
|
+
* A panel attached to one edge of the window.
|
|
143
|
+
*
|
|
144
|
+
* Two things in one component, because they are the same panel: `modal` is the
|
|
145
|
+
* drawer you open — a scrim, a focus trap, Escape — and `standard` is the drawer
|
|
146
|
+
* that is simply part of the page. MD3 names both of them, and the reason they
|
|
147
|
+
* are not two components is that a sidebar becoming a hamburger at a breakpoint
|
|
148
|
+
* is one line rather than a swap.
|
|
149
|
+
*
|
|
150
|
+
* The sections are props rather than compound sub-components, as on
|
|
151
|
+
* [MPCard](../layout/card) and [MPDialog](../feedback/dialog): the arrangement
|
|
152
|
+
* is fixed — heading, description, body, actions — and the body is the only part
|
|
153
|
+
* that scrolls, so the heading and the actions stay put.
|
|
154
|
+
*
|
|
155
|
+
* In `modal` mode Base UI owns everything hard about it: the focus trap, the
|
|
156
|
+
* scroll lock, the `aria-labelledby` / `aria-describedby` wiring, restoring
|
|
157
|
+
* focus to the trigger, and the inert page behind.
|
|
158
|
+
*
|
|
159
|
+
* ## The surface, and why it does not slide
|
|
160
|
+
*
|
|
161
|
+
* `surface-container-low` at elevation 1 for the modal panel and `surface` flat
|
|
162
|
+
* for the standard one — MD3's own two answers. The transition is opacity only,
|
|
163
|
+
* exactly as on the dialog: a drawer is nothing but text and controls, and a
|
|
164
|
+
* panel that slid would drag its own sentences across the screen for the length
|
|
165
|
+
* of the animation. What says the panel came from an edge is that it is
|
|
166
|
+
* *attached* to one: square against the window, cut on the free side.
|
|
167
|
+
*/
|
|
168
|
+
export declare function MPDrawer({ side, mode, open, defaultOpen, onOpenChange, trigger, title, description, actions, dividers, showClose, closeLabel, locale: localeProp, extent, rounded, dismissible, size, className, style, children }: MPDrawerProps): React.JSX.Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as l,Fragment as o}from"react/jsx-runtime";import*as r from"react";import{Dialog as t}from"@base-ui/react/dialog";import{MPIcon as i}from"../icon/MPIcon";import{CloseIcon as n}from"../../constants/icons";import{useMPLocale as a,useMPMessages as s}from"../../internal/locale";import{MPStateLayer as d}from"../../internal/StateLayer";import{hasContent as m,META_TEXT as c,PROSE_TEXT as f,SHEET_GAP as p,SHEET_PAD_X as u,SHEET_PAD_Y as h,SHEET_TITLE as x}from"../../internal/scale";import{FADE as b,PORTAL_LAYER as g,SCRIM as v}from"../../internal/surface";const w={xs:"w-60",sm:"w-72",md:"w-90",lg:"w-104",xl:"w-120"},y={left:"rounded-r-mp-lg",right:"rounded-l-mp-lg",top:"rounded-b-mp-xl",bottom:"rounded-t-mp-xl"},$={left:"border-r",right:"border-l",top:"border-b",bottom:"border-t"},j={left:"flex-row justify-start",right:"flex-row justify-end",top:"flex-col justify-start",bottom:"flex-col justify-end"},N="border-mp-outline-variant border-t";export const MPDrawerClose=t.Close;export function MPDrawer({side:C="left",mode:k="modal",open:z,defaultOpen:P,onOpenChange:B,trigger:D,title:O,description:M,actions:L,dividers:S=!1,showClose:T,closeLabel:F,locale:I,extent:R,rounded:V=!0,dismissible:q=!0,size:A="md",className:E,style:G,children:H}){const J=a(I),K=s("common",J),Q="modal"===k,U="left"===C||"right"===C,W=T??Q,X=F??K.close,[Y,Z]=r.useState(P??!0),_=z??Y,ee=u[A],le=h[A],oe=S?`${ee} ${le}`:ee,re=m(O)||m(M),te=m(L),ie=void 0===R?null:{[U?"width":"height"]:"number"==typeof R?`${R}px`:R},ne=["mp-drawer relative flex flex-col overflow-hidden box-border","border-mp-outline-variant outline-none",Q?"bg-mp-surface-container-low shadow-mp-1":"bg-mp-surface","text-mp-on-surface",f[A],$[C],V?y[C]:"",Q?b:"",U?`h-full max-w-full ${void 0===R?w[A]:""}`:"w-full "+(void 0===R?"max-h-[85%]":""),S?"":`${le} ${p[A]}`,E??""].filter(Boolean).join(" "),ae=Q?t.Title:"h2",se=Q?t.Description:"p",de=["group text-mp-on-surface-variant relative flex size-10 shrink-0","rounded-mp-full 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(" "),me=l(o,{children:[re||W?l("div",{className:`flex shrink-0 items-start gap-3 ${oe}`,children:[l("div",{className:"flex min-w-0 flex-1 flex-col",children:[m(O)?e(ae,{className:`m-0 ${x[A]}`,children:O}):null,m(M)?e(se,{className:`text-mp-on-surface-variant m-0 ${c}`,children:M}):null]}),W?Q?l(t.Close,{"aria-label":X,className:de,children:[e(d,{}),e(i,{icon:n,size:20})]}):l("button",{type:"button","aria-label":X,className:de,onClick:()=>{void 0===z&&Z(!1),B?.(!1)},children:[e(d,{}),e(i,{icon:n,size:20})]}):null]}):null,m(H)?e("div",{className:["min-h-0 flex-1 overflow-y-auto overscroll-contain",oe,S&&(re||W)?N:"",S?"":"-my-1 py-1"].filter(Boolean).join(" "),children:H}):null,te?e("div",{className:["flex shrink-0 flex-wrap items-center justify-end gap-2",oe,S?N:""].filter(Boolean).join(" "),children:L}):null]});return Q?l(t.Root,{open:z,defaultOpen:P,disablePointerDismissal:!q,onOpenChange:(e,l)=>{q||e||"escape-key"!==l.reason?B?.(e):l.cancel()},children:[D?e(t.Trigger,{render:D}):null,l(t.Portal,{children:[e(t.Backdrop,{className:`${g} fixed inset-0 ${b} ${v}`}),e(t.Viewport,{className:`${g} fixed inset-0 flex ${j[C]}`,children:e(t.Popup,{"data-mp-size":A,"data-mp-side":C,"data-mp-mode":k,className:ne,style:{...ie,...G},children:me})})]})]}):_?e("div",{"data-mp-size":A,"data-mp-side":C,"data-mp-mode":k,className:ne,style:{...ie,...G},children:me}):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPDrawer,MPDrawerClose}from"./MPDrawer";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { MPSize, MPVariant } from '../../types';
|
|
4
|
+
export interface MPEmptyProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title'> {
|
|
5
|
+
/**
|
|
6
|
+
* The headline. Defaults to the words for "nothing here" in `locale`; pass
|
|
7
|
+
* `false` for a state that is a glyph and a sentence with no heading over
|
|
8
|
+
* them.
|
|
9
|
+
*/
|
|
10
|
+
title?: React.ReactNode | false;
|
|
11
|
+
/**
|
|
12
|
+
* Which language that default headline is written in. Falls back to the
|
|
13
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
14
|
+
*
|
|
15
|
+
* It matters more here than anywhere else in the library: this is the one
|
|
16
|
+
* invented string that is **drawn** rather than only read out, so a page in
|
|
17
|
+
* Korean with an empty list used to say "Nothing here" in the middle of it.
|
|
18
|
+
*/
|
|
19
|
+
locale?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The glyph above the headline. Defaults to the empty tray; pass `false` to
|
|
22
|
+
* drop it, or a node — an illustration, a brand mark, an icon from any set —
|
|
23
|
+
* to replace it.
|
|
24
|
+
*/
|
|
25
|
+
icon?: React.ReactNode | false;
|
|
26
|
+
/**
|
|
27
|
+
* What to do about it, under the text: a "Create the first one" button, a
|
|
28
|
+
* "Clear filters" link. Several of them sit in a row and wrap together.
|
|
29
|
+
*/
|
|
30
|
+
action?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* How much surface the state paints.
|
|
33
|
+
*
|
|
34
|
+
* `text` is the default here and on nothing else in the library. An empty
|
|
35
|
+
* state is nearly always already inside something — a card's body, a table
|
|
36
|
+
* below its header, a panel — and a second rectangle drawn inside the first is
|
|
37
|
+
* one rectangle too many. The other four are for the case where it is not.
|
|
38
|
+
* @default 'text'
|
|
39
|
+
*/
|
|
40
|
+
variant?: MPVariant;
|
|
41
|
+
/**
|
|
42
|
+
* @default 'md'
|
|
43
|
+
*/
|
|
44
|
+
size?: MPSize;
|
|
45
|
+
/** Renders something other than a `<div>`: `render={<td colSpan={5} />}`. */
|
|
46
|
+
render?: useRender.RenderProp;
|
|
47
|
+
/** The sentence under the headline: why it is empty, or what to do next. */
|
|
48
|
+
children?: React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What stands where content would have been: a glyph, a headline, a sentence and
|
|
52
|
+
* a way out.
|
|
53
|
+
*
|
|
54
|
+
* It is the other half of `MPSkeleton`. A skeleton is the shape of something on
|
|
55
|
+
* its way; this is the shape of something that is not coming — a search with no
|
|
56
|
+
* matches, an inbox nobody has written to, a folder before the first file. The
|
|
57
|
+
* two are never both right at once, and a list that shows neither has a blank
|
|
58
|
+
* rectangle where its answer should be.
|
|
59
|
+
*
|
|
60
|
+
* The headline is the only text in the library a component invents at full size,
|
|
61
|
+
* and it is defaulted rather than required for one reason: the version that says
|
|
62
|
+
* nothing useful is the version that gets shipped. `Nothing here` is a floor, and
|
|
63
|
+
* every slot above it — the glyph, the sentence, the action — is there to be
|
|
64
|
+
* filled with what is actually missing.
|
|
65
|
+
*
|
|
66
|
+
* ## No `color`
|
|
67
|
+
*
|
|
68
|
+
* Deliberately absent, where nearly every other component here has one. An empty
|
|
69
|
+
* state in the accent colour is making a claim about content that does not
|
|
70
|
+
* exist; the surface roles it reads are the neutral ones, and the way to say
|
|
71
|
+
* "this is a problem" is a `color="error"` button in `action` — which is the
|
|
72
|
+
* thing that can actually be pressed about it.
|
|
73
|
+
*/
|
|
74
|
+
export declare const MPEmpty: React.ForwardRefExoticComponent<MPEmptyProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as r}from"react/jsx-runtime";import*as n from"react";import{useRender as a}from"@base-ui/react/use-render";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale";import{hasContent as i,PROSE_TEXT as o,SHEET_GAP as m,SHEET_PAD_X as c,SHEET_TITLE as d}from"../../internal/scale";import{CONTAINER_SURFACE as p}from"../../internal/surface";const x={xs:"py-5",sm:"py-6",md:"py-8",lg:"py-10",xl:"py-12"},f={xs:"text-[1.5rem]",sm:"text-[1.75rem]",md:"text-[2.25rem]",lg:"text-[2.75rem]",xl:"text-[3.25rem]"};function u(){return t("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-[1em]",children:[e("path",{d:"M1.75 9.75h3l.9 1.6h4.7l.9-1.6h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e("path",{d:"m1.75 9.75 2.1-6a1.5 1.5 0 0 1 1.42-1h5.46a1.5 1.5 0 0 1 1.42 1l2.1 6v2a1.5 1.5 0 0 1-1.5 1.5h-9.5a1.5 1.5 0 0 1-1.5-1.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"})]})}export const MPEmpty=n.forwardRef(function({variant:n="text",size:h="md",title:v,icon:y,action:j,locale:N,render:k,className:g,style:w,children:z,...$},L){const B=l(N),C=s("empty",B),M=void 0===v?C.title:v,W=void 0===y?e(u,{}):y,b=i(M),E=["mp-empty flex w-full flex-col items-center justify-center text-center",c[h],x[h],"text"===n?"":"rounded-mp-md",m[h],p[n],"text-mp-on-surface",g??""].filter(Boolean).join(" ");return a({render:k,ref:L,props:{role:"status","data-mp-size":h,"data-mp-variant":n,className:E,style:w,children:t(r,{children:[i(W)?e("span",{className:`text-mp-on-surface-variant flex items-center ${f[h]} [&>svg]:size-[1em]`,children:W}):null,b||i(z)?t("div",{className:`flex max-w-prose flex-col items-center ${m[h]}`,children:[b?e("div",{className:d[h],children:M}):null,i(z)?e("div",{className:`${o[h]} ${b?"text-mp-on-surface-variant":""}`,children:z}):null]}):null,i(j)?e("div",{className:"flex flex-wrap items-center justify-center gap-2",children:j}):null]}),...$}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPEmpty}from"./MPEmpty";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPStyleProps } from '../../types';
|
|
3
|
+
/** Why a file was turned away. One reason per file, in the order they are checked. */
|
|
4
|
+
export type MPFileRejectionReason = 'type' | 'size' | 'count';
|
|
5
|
+
export interface MPFileRejection {
|
|
6
|
+
file: File;
|
|
7
|
+
reason: MPFileRejectionReason;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* `1.4 MB`, in the units the reader's own file browser uses.
|
|
11
|
+
*
|
|
12
|
+
* Base 1000 and `MB` rather than base 1024 and `MiB`: it is the number every
|
|
13
|
+
* desktop file manager shows, and a picker that disagrees with the Finder about
|
|
14
|
+
* how big a file is has picked a fight it cannot win.
|
|
15
|
+
*
|
|
16
|
+
* Exported because a caller writing their own `hint` — "up to 5 MB" — needs the
|
|
17
|
+
* same spelling the list underneath will use, and two spellings of one number in
|
|
18
|
+
* one component is the version of this that looks like a bug.
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatFileSize(bytes: number): string;
|
|
21
|
+
export interface MPFilePickerProps extends MPStyleProps {
|
|
22
|
+
/**
|
|
23
|
+
* Which files the browser's own dialog offers, in the `accept` grammar —
|
|
24
|
+
* `'image/*,.pdf'`. Dropped files are checked against it too, which the
|
|
25
|
+
* attribute alone does not do.
|
|
26
|
+
*/
|
|
27
|
+
accept?: string;
|
|
28
|
+
/** Whether more than one file may be chosen. @default false */
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
/** The largest a single file may be, in bytes. */
|
|
31
|
+
maxSize?: number;
|
|
32
|
+
/**
|
|
33
|
+
* How many files may be held at once. Checked against what is already chosen
|
|
34
|
+
* rather than against one drop, which is the difference between "you may drop
|
|
35
|
+
* five files" and "you may end up with five files" — only the second is what
|
|
36
|
+
* this means.
|
|
37
|
+
*/
|
|
38
|
+
maxFiles?: number;
|
|
39
|
+
/** The chosen files. Use with `onFilesChange` for a controlled picker. */
|
|
40
|
+
value?: readonly File[];
|
|
41
|
+
/** The files chosen at the start, for an uncontrolled picker. */
|
|
42
|
+
defaultValue?: readonly File[];
|
|
43
|
+
onFilesChange?: (files: File[]) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Called with everything that was turned away, and why. Without it a rejected
|
|
46
|
+
* file disappears in silence, which is the single worst thing a dropzone does.
|
|
47
|
+
*/
|
|
48
|
+
onReject?: (rejections: MPFileRejection[]) => void;
|
|
49
|
+
/** Label above the box. */
|
|
50
|
+
label?: React.ReactNode;
|
|
51
|
+
/** The line under the box. Replaced by `errorMessage` when there is one. */
|
|
52
|
+
description?: React.ReactNode;
|
|
53
|
+
/** The message under the box, which also turns the picker over. */
|
|
54
|
+
errorMessage?: React.ReactNode;
|
|
55
|
+
/** The line inside the box. @default 'Drop files here, or click to browse' */
|
|
56
|
+
title?: React.ReactNode;
|
|
57
|
+
/** The line under it — what is accepted, how big, how many. */
|
|
58
|
+
hint?: React.ReactNode;
|
|
59
|
+
/** The glyph above the title. Pass `null` for a box with no picture in it. */
|
|
60
|
+
icon?: React.ReactNode;
|
|
61
|
+
/** Lists the chosen files under the box, each with a way to remove it. @default true */
|
|
62
|
+
showList?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The accessible name of a file's remove button. Receives the file's name.
|
|
65
|
+
*
|
|
66
|
+
* Left out, each button is still named for its own file — in `locale`'s own
|
|
67
|
+
* word order — rather than being one of five buttons all called "Remove".
|
|
68
|
+
*/
|
|
69
|
+
removeLabel?: (name: string) => string;
|
|
70
|
+
/**
|
|
71
|
+
* Which language the remove buttons' default names are written in. Falls back
|
|
72
|
+
* to the nearest `MPLocaleProvider`, then to English.
|
|
73
|
+
*/
|
|
74
|
+
locale?: string;
|
|
75
|
+
/** Marks the field required. */
|
|
76
|
+
required?: boolean;
|
|
77
|
+
/** Greys the picker out and stops it taking files. */
|
|
78
|
+
disabled?: boolean;
|
|
79
|
+
/** Shows what was chosen without allowing it to be added to or removed from. */
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
/** Name of the form control. */
|
|
82
|
+
name?: string;
|
|
83
|
+
/** The id put on the browse button. */
|
|
84
|
+
id?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A box you drop files on, or click to open the file dialog.
|
|
88
|
+
*
|
|
89
|
+
* There is no Material component for this and no Base UI primitive under it, and
|
|
90
|
+
* both absences are fine: a dropzone is a `<div>` listening for four drag events
|
|
91
|
+
* plus an `<input type="file">` it clicks for you. There is no popup to position,
|
|
92
|
+
* no focus to trap, no roving anything. What it borrows from Material is the part
|
|
93
|
+
* that is a *surface* — the corner size, the `outline-variant` edge, the state
|
|
94
|
+
* layers, the supporting text — so it sits in a form with the rest of these
|
|
95
|
+
* components rather than beside them.
|
|
96
|
+
*
|
|
97
|
+
* The edge is dashed, which is the one place this library draws a line that is
|
|
98
|
+
* not solid. It is not decoration: a dashed rectangle is the established sign for
|
|
99
|
+
* "this area takes a drop", and a dropzone that looks like a card is a card
|
|
100
|
+
* nobody tries to drop on.
|
|
101
|
+
*
|
|
102
|
+
* ## The two things a hand-rolled dropzone gets wrong
|
|
103
|
+
*
|
|
104
|
+
* **The drag counter.** `dragenter` and `dragleave` both fire as the pointer
|
|
105
|
+
* crosses a *child* of the zone, so a zone that toggles a boolean flickers the
|
|
106
|
+
* entire time a file is being dragged across its own contents. Counting the
|
|
107
|
+
* events instead is the only version that survives having anything inside the
|
|
108
|
+
* box.
|
|
109
|
+
*
|
|
110
|
+
* **`accept`.** The browser enforces it on its own dialog and never on a drop.
|
|
111
|
+
* See `matchesAccept` above.
|
|
112
|
+
*/
|
|
113
|
+
export declare const MPFilePicker: React.ForwardRefExoticComponent<MPFilePickerProps & React.RefAttributes<HTMLInputElement>>;
|