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,104 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
/** What Base UI reports about the picture as it loads. */
|
|
4
|
+
export type MPAvatarLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
5
|
+
/**
|
|
6
|
+
* The crop.
|
|
7
|
+
*
|
|
8
|
+
* `circle` is the default and is what Material draws: MD3's avatar is a circle,
|
|
9
|
+
* and a round crop is what a portrait has been for as long as there have been
|
|
10
|
+
* portraits.
|
|
11
|
+
*
|
|
12
|
+
* `square` cuts the corners off instead, which is what a logo or a repository
|
|
13
|
+
* icon wants — those are drawn to the edges of a rectangle and a round crop eats
|
|
14
|
+
* them.
|
|
15
|
+
*/
|
|
16
|
+
export type MPAvatarShape = 'circle' | 'square';
|
|
17
|
+
export interface MPAvatarProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'color'> {
|
|
18
|
+
/**
|
|
19
|
+
* The picture. Until it loads — and forever, if it fails — the fallback is
|
|
20
|
+
* what is drawn, so an avatar is never an empty box.
|
|
21
|
+
*/
|
|
22
|
+
src?: string;
|
|
23
|
+
/** Candidate images at other resolutions, as on any `<img>`. */
|
|
24
|
+
srcSet?: string;
|
|
25
|
+
/**
|
|
26
|
+
* What the picture says, for a reader who cannot see it. Defaults to `name`,
|
|
27
|
+
* and to nothing at all when there is no name — an avatar next to the person's
|
|
28
|
+
* own name in the row is decoration, and reading it out says the name twice.
|
|
29
|
+
*/
|
|
30
|
+
alt?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Who or what this is. One prop doing three jobs: it names the picture, the
|
|
33
|
+
* initials are derived from it, and it is the sentence a screen reader hears
|
|
34
|
+
* instead of those initials.
|
|
35
|
+
*
|
|
36
|
+
* The initials are the first character of the first word plus the first
|
|
37
|
+
* character of the last — "Jane Doe" is `JD`, "홍길동" is `홍`. That rule is
|
|
38
|
+
* wrong for some names, which is what `initials` is for.
|
|
39
|
+
*/
|
|
40
|
+
name?: string;
|
|
41
|
+
/** The initials, written out, for when the rule derived the wrong ones. */
|
|
42
|
+
initials?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The crop.
|
|
45
|
+
* @default 'circle'
|
|
46
|
+
*/
|
|
47
|
+
shape?: MPAvatarShape;
|
|
48
|
+
/**
|
|
49
|
+
* How much surface is painted behind the fallback. Invisible once a picture
|
|
50
|
+
* has loaded, apart from the edge `outlined` keeps.
|
|
51
|
+
*
|
|
52
|
+
* `tonal` is the default because it is what MD3 draws a monogram on: the
|
|
53
|
+
* container tone of the accent family, with the matching `on-` ink. A page of
|
|
54
|
+
* `filled` avatars is a page of saturated circles nobody can read a name off.
|
|
55
|
+
* @default 'tonal'
|
|
56
|
+
*/
|
|
57
|
+
variant?: MPVariant;
|
|
58
|
+
/**
|
|
59
|
+
* The box the picture is drawn in — the control heights, so an avatar and the
|
|
60
|
+
* button beside it in a toolbar are the same height.
|
|
61
|
+
* @default 'md'
|
|
62
|
+
*/
|
|
63
|
+
size?: MPSize;
|
|
64
|
+
/** @default 'primary' */
|
|
65
|
+
color?: MPColor;
|
|
66
|
+
/**
|
|
67
|
+
* How long to wait before drawing the fallback, in milliseconds. Set it to
|
|
68
|
+
* roughly the time a cached image takes and the initials stop flashing up in
|
|
69
|
+
* front of a picture that was about to arrive anyway.
|
|
70
|
+
*/
|
|
71
|
+
delay?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Anything else the `<img>` needs — `loading`, `crossOrigin`, `referrerPolicy`.
|
|
74
|
+
*
|
|
75
|
+
* `className` is not among them, and deliberately: the picture is sized and
|
|
76
|
+
* cropped by the avatar's own box, and a class replacing that would be a
|
|
77
|
+
* picture that no longer fits the circle it is in. Style the avatar instead —
|
|
78
|
+
* `className` on the component reaches the box the picture fills.
|
|
79
|
+
*/
|
|
80
|
+
imageProps?: Omit<React.ComponentPropsWithoutRef<'img'>, 'src' | 'srcSet' | 'alt' | 'className'>;
|
|
81
|
+
/** Called as the picture moves between `idle`, `loading`, `loaded` and `error`. */
|
|
82
|
+
onLoadingStatusChange?: (status: MPAvatarLoadingStatus) => void;
|
|
83
|
+
/**
|
|
84
|
+
* The fallback, drawn instead of the initials. An icon, a logo, a single emoji
|
|
85
|
+
* — whatever stands in for this particular thing when there is no picture of
|
|
86
|
+
* it.
|
|
87
|
+
*/
|
|
88
|
+
children?: React.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A picture of a person or a thing, at a known size, that is never an empty box.
|
|
92
|
+
*
|
|
93
|
+
* Three things can be drawn in it and exactly one of them is at a time: the
|
|
94
|
+
* picture, if `src` is given and loads; otherwise whatever stands in for it —
|
|
95
|
+
* `children`, or `initials`, or the initials derived from `name`; and failing
|
|
96
|
+
* all of those, a silhouette. Which one is showing is Base UI's `Avatar` to
|
|
97
|
+
* decide, because "has the image loaded" is a question with four answers and a
|
|
98
|
+
* race in the middle of it.
|
|
99
|
+
*
|
|
100
|
+
* It carries no status dot of its own. An avatar with a green mark on it is an
|
|
101
|
+
* `MPBadge` with an avatar in it, and inventing a second spelling for that would
|
|
102
|
+
* give the library two of them.
|
|
103
|
+
*/
|
|
104
|
+
export declare const MPAvatar: React.ForwardRefExoticComponent<MPAvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{Avatar as n}from"@base-ui/react/avatar";import{accentSlots as r}from"../../internal/accent";import{CONTROL_SQUARE as l,hasContent as i}from"../../internal/scale";import{VISUALLY_HIDDEN as o}from"../../internal/visually-hidden";const m={xs:"text-mp-label-medium",sm:"text-mp-label-large",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},s={xs:"rounded-mp-xs",sm:"rounded-mp-sm",md:"rounded-mp-md",lg:"rounded-mp-md",xl:"rounded-mp-md"},c={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline border bg-transparent text-(--_mp-accent)",text:"text-mp-on-surface-variant bg-transparent"};function d(){return a("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"size-[60%]",children:[e("path",{d:"M12 12a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Z"}),e("path",{d:"M12 14.25c-4.28 0-7.75 2.42-7.75 5.4 0 .75.6 1.35 1.35 1.35h12.8c.75 0 1.35-.6 1.35-1.35 0-2.98-3.47-5.4-7.75-5.4Z"})]})}export const MPAvatar=t.forwardRef(function({src:t,srcSet:p,alt:u,name:f,initials:h,shape:x="circle",variant:g="tonal",size:v="md",color:b="primary",delay:y,imageProps:N,onLoadingStatusChange:j,className:w,style:z,children:_,...C},A){const B=f?function(e){const a=e.normalize("NFC").trim().split(/\s+/).filter(Boolean);return 0===a.length?"":((Array.from(a[0])[0]??"")+(a.length>1?Array.from(a[a.length-1])[0]??"":"")).toLocaleUpperCase()}(f):"",S=u??f,L=i(_)?_:(h??B)||e(d,{}),M=i(_)||Boolean(h??B),k=["mp-avatar relative inline-flex shrink-0 items-center justify-center overflow-hidden","align-middle leading-none font-medium whitespace-nowrap select-none",l[v],m[v],"circle"===x?"rounded-mp-full":s[v],c[g],w??""].filter(Boolean).join(" ");return a(n.Root,{ref:A,"data-mp-size":v,"data-mp-variant":g,className:k,style:{...r(b),...z},...C,children:[t?e(n.Image,{src:t,srcSet:p,alt:S??"",onLoadingStatusChange:j,...N,className:"size-full object-cover"}):null,a(n.Fallback,{delay:t?y:void 0,className:"flex size-full items-center justify-center",children:[S&&M?e("span",{className:o,children:S}):null,e("span",{"aria-hidden":!(!S||!M)||void 0,className:"contents",children:L})]})]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPAvatar}from"./MPAvatar";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPCorner, MPSize, MPVariant } from '../../types';
|
|
3
|
+
export interface MPBadgeProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'color' | 'content'> {
|
|
4
|
+
/**
|
|
5
|
+
* What the badge says — usually a count, sometimes a word.
|
|
6
|
+
*
|
|
7
|
+
* Omit it and the badge draws a dot instead, which is the honest thing when
|
|
8
|
+
* there is something to report but nothing to count. MD3 calls those two the
|
|
9
|
+
* large and the small badge, and they are the only two it has.
|
|
10
|
+
*/
|
|
11
|
+
content?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Caps a numeric `content` and adds a `+`. Only applies when the content is
|
|
14
|
+
* actually a number: a badge cannot know how to truncate a word.
|
|
15
|
+
* @default 99
|
|
16
|
+
*/
|
|
17
|
+
max?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Draws the marker as a dot even when there is content, keeping the content
|
|
20
|
+
* for screen readers only. For the corner that has to stay quiet.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
dot?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a `content` of `0` is shown. Off by default — zero unread messages
|
|
26
|
+
* is not news, and a badge that never goes away stops meaning anything.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
showZero?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Hides the marker without unmounting the anchor. The badge keeps its place in
|
|
32
|
+
* the DOM, so showing it again does not relayout what it sits on.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
invisible?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Which corner of the anchor it sits on.
|
|
38
|
+
* @default 'top-end'
|
|
39
|
+
*/
|
|
40
|
+
placement?: MPCorner;
|
|
41
|
+
/**
|
|
42
|
+
* The shape of the thing underneath, which is what decides how far the marker
|
|
43
|
+
* tucks in: a circle's corner is further from its centre than a square's, so a
|
|
44
|
+
* badge that looks right on an avatar hangs off an icon button.
|
|
45
|
+
* @default 'square'
|
|
46
|
+
*/
|
|
47
|
+
overlap?: 'square' | 'circle';
|
|
48
|
+
/**
|
|
49
|
+
* How much surface the marker paints.
|
|
50
|
+
* @default 'filled'
|
|
51
|
+
*/
|
|
52
|
+
variant?: MPVariant;
|
|
53
|
+
/**
|
|
54
|
+
* @default 'md'
|
|
55
|
+
*/
|
|
56
|
+
size?: MPSize;
|
|
57
|
+
/**
|
|
58
|
+
* Which accent family the marker reads.
|
|
59
|
+
*
|
|
60
|
+
* **`error`, not `primary`**, and it is the one component in the library that
|
|
61
|
+
* defaults there. MD3 gives the badge exactly one colour pair — `error` under
|
|
62
|
+
* `on-error` — because a badge exists to be noticed, and the error palette is
|
|
63
|
+
* the one palette in the system that is guaranteed to be loud whatever the
|
|
64
|
+
* source colour is. A count in the brand colour on a brand-coloured app bar is
|
|
65
|
+
* a count nobody sees.
|
|
66
|
+
* @default 'error'
|
|
67
|
+
*/
|
|
68
|
+
color?: MPColor;
|
|
69
|
+
/**
|
|
70
|
+
* What a screen reader hears instead of the raw content. `content={3}` on a
|
|
71
|
+
* bell is "3" to a reader and means nothing; `label="3 unread notifications"`
|
|
72
|
+
* is the sentence.
|
|
73
|
+
*/
|
|
74
|
+
label?: string;
|
|
75
|
+
/**
|
|
76
|
+
* What the badge is pinned to. Without it the badge is a standalone marker
|
|
77
|
+
* that lays out inline, which is what a status pill in a table cell is.
|
|
78
|
+
*/
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A small mark in the corner of something else: unread mail on an inbox icon, a
|
|
83
|
+
* status dot on an avatar, a count on a tab.
|
|
84
|
+
*
|
|
85
|
+
* The shell is a `<span>` that wraps the anchor and does nothing but establish a
|
|
86
|
+
* positioning context — no width, no padding, `align-middle` — so a badged icon
|
|
87
|
+
* button still measures and lines up exactly like a bare one. With no children
|
|
88
|
+
* the marker lays out inline instead, which is what a standalone status pill is.
|
|
89
|
+
*
|
|
90
|
+
* There is no Base UI primitive under this, and there should not be: a badge has
|
|
91
|
+
* no interaction, no state and no keyboard contract. It is a mark. Wiring it to
|
|
92
|
+
* a widget primitive would hand every decorative dot a role it cannot honour.
|
|
93
|
+
*
|
|
94
|
+
* What it does owe a screen reader is a sentence rather than a number, which is
|
|
95
|
+
* what `label` is for — `content={3}` beside a bell reads out as "3".
|
|
96
|
+
*
|
|
97
|
+
* ## The one place the library draws a pill that is not a button
|
|
98
|
+
*
|
|
99
|
+
* `corner-full`, at every size. MD3 shapes a badge as a full circle or a stadium
|
|
100
|
+
* because it is a *mark laid on* a surface rather than a surface of its own, and
|
|
101
|
+
* a mark has no edge to cut. It is also the only component that overlaps its
|
|
102
|
+
* neighbour, for the same reason.
|
|
103
|
+
*/
|
|
104
|
+
export declare const MPBadge: React.ForwardRefExoticComponent<MPBadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as m}from"react/jsx-runtime";import*as n from"react";import{accentSlots as a}from"../../internal/accent";import{hasContent as l}from"../../internal/scale";import{VISUALLY_HIDDEN as s}from"../../internal/visually-hidden";const i={xs:"h-3 min-w-3",sm:"h-3.5 min-w-3.5",md:"h-4 min-w-4",lg:"h-5 min-w-5",xl:"h-6 min-w-6"},o={xs:"size-1",sm:"size-1.5",md:"size-1.5",lg:"size-2",xl:"size-2.5"},r={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-small",lg:"text-mp-label-medium",xl:"text-mp-label-medium"},d={xs:"px-1",sm:"px-1",md:"px-1.5",lg:"px-1.5",xl:"px-2"},p={xs:{badge:"-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5",dot:"-mt-0.5 -mb-0.5 -ms-0.5 -me-0.5"},sm:{badge:"-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5",dot:"-mt-0.5 -mb-0.5 -ms-0.5 -me-0.5"},md:{badge:"-mt-2 -mb-2 -ms-2 -me-2",dot:"-mt-1 -mb-1 -ms-1 -me-1"},lg:{badge:"-mt-2.5 -mb-2.5 -ms-2.5 -me-2.5",dot:"-mt-1 -mb-1 -ms-1 -me-1"},xl:{badge:"-mt-3 -mb-3 -ms-3 -me-3",dot:"-mt-1.5 -mb-1.5 -ms-1.5 -me-1.5"}},c={"top-start":"top-0 start-0","top-end":"top-0 end-0","bottom-start":"bottom-0 start-0","bottom-end":"bottom-0 end-0"},b={"top-start":"mt-[7%] ms-[7%]","top-end":"mt-[7%] me-[7%]","bottom-start":"mb-[7%] ms-[7%]","bottom-end":"mb-[7%] me-[7%]"},x={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline border bg-mp-surface-container text-(--_mp-accent)",text:"text-(--_mp-accent) bg-transparent"};export const MPBadge=n.forwardRef(function({variant:n="filled",size:u="md",color:g="error",content:f,max:h=99,dot:v=!1,showZero:w=!1,invisible:z=!1,placement:_="top-end",overlap:j="square",label:y,className:N,style:k,children:B,...$},q){const F=l(B),M=!l(f)||0===f&&!w,P=v||M,R=z||M&&!v,Z=["mp-badge pointer-events-none z-10 inline-flex shrink-0 items-center justify-center","rounded-mp-full tabular-nums whitespace-nowrap",x[n],P?o[u]:[i[u],r[u],d[u]].join(" "),F?`absolute ${c[_]}`:"relative align-middle",F?P?p[u].dot:p[u].badge:"",F&&"circle"===j?b[_]:"",R?"invisible":"",N??""].filter(Boolean).join(" "),A=function(e,t){return"number"==typeof e&&e>t?`${t}+`:e}(f,h),C=e("span",{ref:q,"data-mp-size":u,"data-mp-variant":n,className:Z,style:{...a(g),...k},"aria-hidden":!!R||void 0,...$,children:R?null:m(t,{children:[P||y?e("span",{className:s,children:y??A}):null,P?null:e("span",{"aria-hidden":!!y||void 0,children:A})]})});return F?m("span",{className:"relative inline-flex shrink-0 align-middle",children:[B,C]}):C});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPBadge}from"./MPBadge";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* The props are a `<figure>`'s rather than a `<blockquote>`'s, which is a
|
|
5
|
+
* consequence of where the drawing happens: everything a caller passes lands on
|
|
6
|
+
* the wrapper, and the wrapper is a figure or a div. Both are `HTMLElement`, so
|
|
7
|
+
* an event handler written against one works on the other.
|
|
8
|
+
*/
|
|
9
|
+
export interface MPBlockquoteProps extends Omit<React.ComponentPropsWithoutRef<'figure'>, 'color'> {
|
|
10
|
+
/**
|
|
11
|
+
* How much surface the quote paints behind the words.
|
|
12
|
+
* @default 'text'
|
|
13
|
+
*/
|
|
14
|
+
variant?: MPVariant;
|
|
15
|
+
/**
|
|
16
|
+
* The type scale of the quote and the room around it.
|
|
17
|
+
* @default 'md'
|
|
18
|
+
*/
|
|
19
|
+
size?: MPSize;
|
|
20
|
+
/**
|
|
21
|
+
* Which accent family the rule down the leading edge is drawn in — and, on
|
|
22
|
+
* `filled` and `tonal`, the surface behind the words.
|
|
23
|
+
* @default 'primary'
|
|
24
|
+
*/
|
|
25
|
+
color?: MPColor;
|
|
26
|
+
/**
|
|
27
|
+
* Who said it. Its presence is what turns the quote into a `<figure>` with a
|
|
28
|
+
* `<figcaption>`, which is the markup the HTML specification asks for: an
|
|
29
|
+
* attribution is *about* the quote and is not part of what was said.
|
|
30
|
+
*/
|
|
31
|
+
author?: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Where it is from — a book, a talk, a page. Rendered inside a `<cite>`, which
|
|
34
|
+
* is the element for the title of a work and, per the specification, never for
|
|
35
|
+
* the name of a person. That is what `author` is.
|
|
36
|
+
*/
|
|
37
|
+
source?: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* URL of the document the quote was taken from. Lands on the `<blockquote>`'s
|
|
40
|
+
* own `cite` attribute, which is machine-readable and shown to nobody — use
|
|
41
|
+
* `source` for the part a reader should see.
|
|
42
|
+
*/
|
|
43
|
+
cite?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The mark drawn before the quote. Omit it for the house glyph, pass a node to
|
|
46
|
+
* replace it, pass `false` to take it away.
|
|
47
|
+
*/
|
|
48
|
+
icon?: React.ReactNode | false;
|
|
49
|
+
/** What was said. */
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Somebody else's words, set apart from your own.
|
|
54
|
+
*
|
|
55
|
+
* There is no Base UI primitive under this and there should not be: a quote has
|
|
56
|
+
* no state, no keyboard contract and nothing to interact with. What it has is
|
|
57
|
+
* markup that is easy to get wrong, and getting it right is most of the point.
|
|
58
|
+
*
|
|
59
|
+
* **Nothing is drawn on the `<blockquote>` itself.** The surface, the rule and
|
|
60
|
+
* the padding all belong to the element around it, and that is not tidiness —
|
|
61
|
+
* `blockquote` is one of the handful of tags a host stylesheet still styles by
|
|
62
|
+
* name. VitePress's `.vp-doc blockquote` sets a grey `border-left`, a
|
|
63
|
+
* `padding-left` and a `color`, all at a specificity a one-class utility cannot
|
|
64
|
+
* outrank, so a rule drawn on the quote itself would silently come out grey and
|
|
65
|
+
* a pixel too thin.
|
|
66
|
+
*
|
|
67
|
+
* The wrapper is a `<figure>` when there is an attribution and a `<div>` when
|
|
68
|
+
* there is not, because the HTML specification is explicit that the attribution
|
|
69
|
+
* goes *outside* the blockquote — a name inside it claims the speaker said their
|
|
70
|
+
* own name — and a `<figure>` with no `<figcaption>` in it is a figure of
|
|
71
|
+
* nothing.
|
|
72
|
+
*/
|
|
73
|
+
export declare const MPBlockquote: React.ForwardRefExoticComponent<MPBlockquoteProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as a from"react";import{accentSlots as r}from"../../internal/accent";import{hasContent as n,META_TEXT as i,SHEET_PAD as l}from"../../internal/scale";const o={xs:"text-mp-body-medium",sm:"text-mp-body-large",md:"text-mp-title-large",lg:"text-mp-headline-small",xl:"text-mp-headline-medium"},c="border-s-2 [border-inline-start-color:var(--_mp-accent)]",s={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-mp-on-surface",outlined:"border-mp-outline-variant border border-s-2 bg-transparent text-mp-on-surface",text:"bg-transparent text-mp-on-surface"};function m(){return e("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"size-full",children:e("path",{d:"M6.4 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6ZM13.3 3.6c-2.3.9-3.7 2.8-3.7 5.1 0 2 1.2 3.3 2.8 3.3 1.4 0 2.5-1 2.5-2.4 0-1.3-.9-2.2-2.1-2.2-.2 0-.4 0-.6.1.3-1 1.1-1.8 2.2-2.3l-1.1-1.6Z",fill:"currentColor"})})}export const MPBlockquote=a.forwardRef(function({variant:a="text",size:d="md",color:p="primary",author:u,source:f,cite:x,icon:h,className:b,style:g,children:v,...y},N){const j=n(u)||n(f),w=void 0===h?e(m,{}):h,z="text"!==a,_=["mp-blockquote flex flex-col",o[d],c,z?"rounded-mp-md rounded-s-none":"",s[a],z?l[d]:"ps-4",b??""].filter(Boolean).join(" "),k=t("blockquote",{cite:x,children:[n(w)?e("span",{"aria-hidden":"true",className:"mb-1 block size-[2em] opacity-38",children:w}):null,v]}),q={...r(p),...g};return j?t("figure",{ref:N,"data-mp-size":d,"data-mp-variant":a,className:_,style:q,...y,children:[k,t("figcaption",{className:["mt-2 flex flex-wrap items-baseline gap-x-1.5",z?"opacity-80":"text-mp-on-surface-variant",i].join(" "),children:[n(u)?t("span",{className:"font-medium",children:[e("span",{"aria-hidden":"true",children:"— "}),u]}):null,n(f)?e("cite",{className:"not-italic",children:f}):null]})]}):e("div",{ref:N,"data-mp-size":d,"data-mp-variant":a,className:_,style:q,...y,children:k})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPBlockquote}from"./MPBlockquote";
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { MPPosition, MPSize } from '../../types';
|
|
4
|
+
/** A destination's value. The same restraint `MPTabs` puts on a tab's. */
|
|
5
|
+
export type MPBottomNavigationValue = string | number;
|
|
6
|
+
/**
|
|
7
|
+
* Which names are drawn.
|
|
8
|
+
*
|
|
9
|
+
* MD3's three label behaviours, and the order they lose information in:
|
|
10
|
+
*
|
|
11
|
+
* - `all` — every destination is named. The default, and the only one that works
|
|
12
|
+
* for a reader who has not used the application before.
|
|
13
|
+
* - `selected` — only the destination the reader is on. The bar keeps its height
|
|
14
|
+
* either way.
|
|
15
|
+
* - `none` — glyphs only.
|
|
16
|
+
*
|
|
17
|
+
* Undrawn is never unsaid: in both of the last two the names stay in the
|
|
18
|
+
* document for a screen reader, because a glyph on its own has no accessible
|
|
19
|
+
* name at all.
|
|
20
|
+
*/
|
|
21
|
+
export type MPBottomNavigationLabels = 'all' | 'selected' | 'none';
|
|
22
|
+
export interface MPBottomNavigationProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'defaultValue' | 'onChange'> {
|
|
23
|
+
/** The destination the reader is on. Use with `onValueChange` for a controlled bar. */
|
|
24
|
+
value?: MPBottomNavigationValue | null;
|
|
25
|
+
/** Which starts current, for an uncontrolled bar. */
|
|
26
|
+
defaultValue?: MPBottomNavigationValue | null;
|
|
27
|
+
/** Called with the value of the destination that was pressed. */
|
|
28
|
+
onValueChange?: (value: MPBottomNavigationValue) => void;
|
|
29
|
+
/**
|
|
30
|
+
* How the bar sits in the page's scroll. `fixed` — the default, against the
|
|
31
|
+
* `static` everything else in this library defaults to — is what a bottom
|
|
32
|
+
* navigation bar is: held against the bottom edge of the window whatever the
|
|
33
|
+
* page under it does.
|
|
34
|
+
* @default 'fixed'
|
|
35
|
+
*/
|
|
36
|
+
position?: MPPosition;
|
|
37
|
+
/**
|
|
38
|
+
* Which names are drawn.
|
|
39
|
+
* @default 'all'
|
|
40
|
+
*/
|
|
41
|
+
labels?: MPBottomNavigationLabels;
|
|
42
|
+
/**
|
|
43
|
+
* The bar's height and type scale. `md` is MD3's own 80dp.
|
|
44
|
+
* @default 'md'
|
|
45
|
+
*/
|
|
46
|
+
size?: MPSize;
|
|
47
|
+
/**
|
|
48
|
+
* A hairline along the top edge.
|
|
49
|
+
*
|
|
50
|
+
* Off by default, because MD3 separates the bar from the page by *tone* — the
|
|
51
|
+
* container is `surface-container` against the page's `surface` — rather than
|
|
52
|
+
* by a rule. Turn it on when the page behind it is the same tone, which is
|
|
53
|
+
* where the tonal difference stops being visible.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
divider?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Keeps the destinations clear of a phone's home indicator by adding
|
|
59
|
+
* `env(safe-area-inset-bottom)` under them. The container still reaches the
|
|
60
|
+
* bottom of the screen — only the row moves up, so the surface runs under the
|
|
61
|
+
* indicator rather than stopping in a stripe above it.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
safeArea?: boolean;
|
|
65
|
+
/** Every destination stops answering. */
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* The name the bar is announced by — "Main", "Sections". A landmark with no
|
|
69
|
+
* name is a landmark a screen reader lists as "navigation".
|
|
70
|
+
*/
|
|
71
|
+
label?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Renders something other than a `<nav>`. Base UI's own escape hatch, and
|
|
74
|
+
* rarely what you want here: a row of destinations is navigation.
|
|
75
|
+
*/
|
|
76
|
+
render?: useRender.RenderProp;
|
|
77
|
+
/** The `MPBottomNavigationItem`s — three to five of them. */
|
|
78
|
+
children?: React.ReactNode;
|
|
79
|
+
}
|
|
80
|
+
export interface MPBottomNavigationItemProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'value'> {
|
|
81
|
+
/** Identifies the destination. What `onValueChange` reports. */
|
|
82
|
+
value: MPBottomNavigationValue;
|
|
83
|
+
/** The glyph, drawn inside the active indicator. */
|
|
84
|
+
icon?: React.ReactNode;
|
|
85
|
+
/**
|
|
86
|
+
* A second glyph for while this is the destination the reader is on — MD3
|
|
87
|
+
* fills the selected icon and outlines the rest, which is a signal that
|
|
88
|
+
* survives being seen out of the corner of an eye. Falls back to `icon`.
|
|
89
|
+
*/
|
|
90
|
+
activeIcon?: React.ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* Renders the destination as a real link.
|
|
93
|
+
*
|
|
94
|
+
* Worth reaching for: a long press then offers "open in a new tab", the
|
|
95
|
+
* address shows in the status bar, and a crawler can follow it — none of which
|
|
96
|
+
* a `<button>` that calls `router.push` can do. `onValueChange` still fires.
|
|
97
|
+
*/
|
|
98
|
+
href?: string;
|
|
99
|
+
/** Unavailable, but still part of the set. */
|
|
100
|
+
disabled?: boolean;
|
|
101
|
+
/** The destination's name. Read out even when `labels` keeps it undrawn. */
|
|
102
|
+
children?: React.ReactNode;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A row of destinations held against the bottom edge of the window.
|
|
106
|
+
*
|
|
107
|
+
* **MD3 calls this the navigation bar**; the name here is the one the pattern is
|
|
108
|
+
* still known by, and the two are the same component. What is drawn is the
|
|
109
|
+
* specification's: a `surface-container` bar 80dp tall, with the destination the
|
|
110
|
+
* reader is on marked by a 64×32dp `secondary-container` pill behind its glyph.
|
|
111
|
+
*
|
|
112
|
+
* ## Why it is a `<nav>` and not a tab list
|
|
113
|
+
*
|
|
114
|
+
* It is a deliberate choice about what is being promised. A tab list owes a
|
|
115
|
+
* keyboard reader one tab stop for the whole set and arrow keys within it, and
|
|
116
|
+
* owes a screen reader a panel per tab; a navigation bar switches what the
|
|
117
|
+
* *page* is, not which panel of one is showing. Claiming the role without the
|
|
118
|
+
* behaviour is worse for a keyboard reader than never claiming it.
|
|
119
|
+
*
|
|
120
|
+
* What is claimed instead is `aria-current="page"`, which is the honest
|
|
121
|
+
* statement: this is the destination you are on. Every item is an ordinary
|
|
122
|
+
* button or link, in the tab order, doing what buttons and links do.
|
|
123
|
+
*
|
|
124
|
+
* For dividing one screen into panels, that genuinely is [MPTabs](./tabs).
|
|
125
|
+
*
|
|
126
|
+
* ## Why it takes no `color`
|
|
127
|
+
*
|
|
128
|
+
* The active indicator is `secondary-container` because MD3 says it is, and for
|
|
129
|
+
* the reason [MPSegmentedButton](../inputs/segmented-button) gives: a mark
|
|
130
|
+
* saying *where you are* is not an accent statement. `primary` is what a screen
|
|
131
|
+
* reserves for the action it is about, and a navigation bar does nothing.
|
|
132
|
+
*/
|
|
133
|
+
export declare const MPBottomNavigation: React.ForwardRefExoticComponent<MPBottomNavigationProps & React.RefAttributes<HTMLElement>>;
|
|
134
|
+
/**
|
|
135
|
+
* One destination.
|
|
136
|
+
*
|
|
137
|
+
* It has no `size` and no colour of its own: both belong to the bar, which is
|
|
138
|
+
* the only place they can be set once and mean the same thing for every item. A
|
|
139
|
+
* bar whose third destination is a rung out is not a bar.
|
|
140
|
+
*
|
|
141
|
+
* With an `href` it is a real `<a>`; without one it is a `<button>`, because a
|
|
142
|
+
* `<div>` carrying a click handler is invisible to a keyboard.
|
|
143
|
+
*/
|
|
144
|
+
export declare const MPBottomNavigationItem: React.ForwardRefExoticComponent<MPBottomNavigationItemProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as a,Fragment as l}from"react/jsx-runtime";import*as t from"react";import{useRender as n}from"@base-ui/react/use-render";import{MPStateLayer as i}from"../../internal/StateLayer";import{hasContent as o}from"../../internal/scale";import{VISUALLY_HIDDEN as r}from"../../internal/visually-hidden";const s=t.createContext({value:null,change:()=>{},size:"md",labels:"all",disabled:!1}),c={xs:"h-14",sm:"h-16",md:"h-20",lg:"h-22",xl:"h-24"},m={xs:"h-6 w-12",sm:"h-7 w-14",md:"h-8 w-16",lg:"h-9 w-18",xl:"h-10 w-20"},d={xs:20,sm:22,md:24,lg:26,xl:28},u={xs:"text-mp-label-small",sm:"text-mp-label-small",md:"text-mp-label-medium",lg:"text-mp-label-medium",xl:"text-mp-label-large"},f={xs:"gap-0.5",sm:"gap-0.5",md:"gap-1",lg:"gap-1",xl:"gap-1.5"},p={static:"",absolute:"absolute inset-x-0 bottom-0 z-30",sticky:"sticky bottom-0 z-30",fixed:"fixed inset-x-0 bottom-0 z-40"};export const MPBottomNavigation=t.forwardRef(function({value:a,defaultValue:l=null,onValueChange:i,position:o="fixed",labels:r="all",size:m="md",divider:d=!1,safeArea:u=!0,disabled:f=!1,label:b,render:x,className:h,children:v,...g},w){const[y,z]=t.useState(l),N=void 0!==a,j=N?a:y,k=t.useCallback(e=>{N||z(e),i?.(e)},[N,i]),C=t.useMemo(()=>({value:j??null,change:k,size:m,labels:r,disabled:f}),[j,k,m,r,f]);return n({render:x??e("nav",{}),ref:w,props:{"aria-label":b,"data-mp-size":m,className:["mp-bottom-navigation bg-mp-surface-container text-mp-on-surface box-border w-full",d?"border-mp-outline-variant border-t":"",p[o],u?"pb-[env(safe-area-inset-bottom)]":"",h??""].filter(Boolean).join(" "),children:e(s.Provider,{value:C,children:e("div",{className:`flex w-full items-stretch ${c[m]}`,children:v})}),...g}})});export const MPBottomNavigationItem=t.forwardRef(function({value:n,icon:c,activeIcon:p,href:b,disabled:x=!1,className:h,children:v,onClick:g,...w},y){const z=t.useContext(s),N=x||z.disabled,j=null!==z.value&&z.value===n,k="all"===z.labels||"selected"===z.labels&&j,C=["mp-bottom-navigation__item group flex min-w-0 flex-1 flex-col items-center justify-center","box-border appearance-none bg-transparent px-1 font-[inherit] no-underline select-none",f[z.size],"outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none",N?"text-mp-on-surface/38 cursor-default":j?"text-mp-on-surface cursor-pointer":"text-mp-on-surface-variant cursor-pointer",h??""].filter(Boolean).join(" "),B=a(l,{children:[o(c)||o(p)?a("span",{className:["relative flex shrink-0 items-center justify-center overflow-hidden","rounded-mp-full","transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",m[z.size],j&&!N?"bg-mp-secondary-container text-mp-on-secondary-container":""].filter(Boolean).join(" "),children:[N?null:e(i,{}),e("span",{className:"relative flex items-center justify-center",style:{width:d[z.size],height:d[z.size]},children:j?p??c:c})]}):null,o(v)?e("span",{className:k?`max-w-full truncate ${u[z.size]}`:r,children:v}):null]}),M=e=>{N?e.preventDefault():(z.change(n),g?.(e))};return b?e("a",{ref:y,href:N?void 0:b,"aria-current":j?"page":void 0,"aria-disabled":N||void 0,className:C,onClick:M,...w,children:B}):e("button",{ref:y,type:"button",disabled:N,"aria-current":j?"page":void 0,className:C,onClick:M,...w,children:B})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPBottomNavigation,MPBottomNavigationItem}from"./MPBottomNavigation";
|
|
@@ -0,0 +1,78 @@
|
|
|
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 MPBoxProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/**
|
|
6
|
+
* How much surface the sheet paints.
|
|
7
|
+
*
|
|
8
|
+
* A container's ladder, so `filled` is MD3's own filled-card surface —
|
|
9
|
+
* `surface-container-highest` — and not the accent. See the note on the
|
|
10
|
+
* component below for why a box is never dyed.
|
|
11
|
+
* @default 'outlined'
|
|
12
|
+
*/
|
|
13
|
+
variant?: MPVariant;
|
|
14
|
+
/**
|
|
15
|
+
* The room inside.
|
|
16
|
+
*
|
|
17
|
+
* **This is the one component where `size` sets no height and no type scale.**
|
|
18
|
+
* A box is as tall as what it holds, and its children bring their own
|
|
19
|
+
* typography — a container that reset the type scale would make the same
|
|
20
|
+
* paragraph render at two sizes depending on what it happened to be wrapped
|
|
21
|
+
* in. So here the rung is the padding, and nothing else.
|
|
22
|
+
*
|
|
23
|
+
* The *corner* is not on the ladder either, which is where this library and
|
|
24
|
+
* most others part company. A radius in Material is a statement about what
|
|
25
|
+
* kind of object something is rather than a size to taste, and a box is a
|
|
26
|
+
* sheet: `corner-medium` at every rung, exactly as MD3 draws a card.
|
|
27
|
+
* @default 'md'
|
|
28
|
+
*/
|
|
29
|
+
size?: MPSize;
|
|
30
|
+
/**
|
|
31
|
+
* Inner padding. Turn it off for full-bleed content — a picture, a table, a
|
|
32
|
+
* list that draws its own rows.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
padded?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Renders something other than a `<div>`: `render={<section />}`,
|
|
38
|
+
* `render={<li />}`, or a function for full control. Base UI's own escape
|
|
39
|
+
* hatch, so it behaves here exactly as it does on every Base UI primitive.
|
|
40
|
+
*/
|
|
41
|
+
render?: useRender.RenderProp;
|
|
42
|
+
children?: React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A sheet with content on it. The plainest surface in the library: it groups
|
|
46
|
+
* things, and that is all it does.
|
|
47
|
+
*
|
|
48
|
+
* Everything structural — a heading, a footer, dividers, a picture across the
|
|
49
|
+
* top — belongs to [MPCard](./card), which is exactly this box with those
|
|
50
|
+
* sections laid out on it.
|
|
51
|
+
*
|
|
52
|
+
* ## Why a box is never dyed, and takes no `color`
|
|
53
|
+
*
|
|
54
|
+
* Because what it holds is somebody else's content, and that content arrives
|
|
55
|
+
* with its own colours: body text, links, buttons, fields. On an accent fill
|
|
56
|
+
* every one of them would need an on-accent treatment of its own, which is the
|
|
57
|
+
* opposite of what a container is for.
|
|
58
|
+
*
|
|
59
|
+
* So the ladder runs up the **neutral** surface roles. `filled` is
|
|
60
|
+
* `surface-container-highest`, which is MD3's own filled card; `elevated` and
|
|
61
|
+
* `outlined` are the specification's other two card variants to the letter. What
|
|
62
|
+
* separates them is how much light the sheet holds and whether it carries a
|
|
63
|
+
* hairline — never which family it reads.
|
|
64
|
+
*
|
|
65
|
+
* A component that *is* the thing being coloured says so by taking `color`:
|
|
66
|
+
* that is [MPAlert](../feedback/alert) for a message, [MPChip](../display/chip)
|
|
67
|
+
* for a token, [MPButton](../inputs/button) for an action.
|
|
68
|
+
*
|
|
69
|
+
* ## Why there is no `elevation`
|
|
70
|
+
*
|
|
71
|
+
* There is no `elevation` prop anywhere in this library, and a box is where the
|
|
72
|
+
* absence is most tempting to fix. It stays absent because MD3 does not treat
|
|
73
|
+
* height as a free axis: an elevated surface is `surface-container-low` under a
|
|
74
|
+
* level-1 shadow, and the tone and the shadow are one decision. A prop that
|
|
75
|
+
* raised a `filled` box would produce a surface the specification has no name
|
|
76
|
+
* for. `variant="elevated"` is that decision, made once.
|
|
77
|
+
*/
|
|
78
|
+
export declare const MPBox: React.ForwardRefExoticComponent<MPBoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";import{useRender as e}from"@base-ui/react/use-render";import{SHEET_PAD as a}from"../../internal/scale";import{CONTAINER_SURFACE as o}from"../../internal/surface";export const MPBox=r.forwardRef(function({variant:r="outlined",size:n="md",padded:t=!0,render:d,className:i,children:m,...s},p){return e({render:d,ref:p,props:{"data-mp-size":n,"data-mp-variant":r,className:["mp-box rounded-mp-md block","box-border",t?a[n]:"",o[r],"text-mp-on-surface",i??""].filter(Boolean).join(" "),children:m,...s}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPBox}from"./MPBox";
|