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,127 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* What is drawn between two steps of the trail.
|
|
5
|
+
*
|
|
6
|
+
* Four named marks rather than a free-for-all, because a separator is read
|
|
7
|
+
* hundreds of times a day and the difference between them is meaning, not
|
|
8
|
+
* decoration: a `chevron` and an `arrow` say "and then", a `slash` says "path",
|
|
9
|
+
* a `dot` says "these are peers of one thing". Anything else can still be passed
|
|
10
|
+
* as a node.
|
|
11
|
+
*/
|
|
12
|
+
export type MPBreadcrumbSeparator = 'chevron' | 'arrow' | 'slash' | 'dot';
|
|
13
|
+
export interface MPBreadcrumbProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'color'> {
|
|
14
|
+
/** @default 'md' */
|
|
15
|
+
size?: MPSize;
|
|
16
|
+
/**
|
|
17
|
+
* The accent family a step picks up when it is hovered.
|
|
18
|
+
* @default 'primary'
|
|
19
|
+
*/
|
|
20
|
+
color?: MPColor;
|
|
21
|
+
/**
|
|
22
|
+
* The mark between two steps. One of the four names, or any node.
|
|
23
|
+
* @default 'chevron'
|
|
24
|
+
*/
|
|
25
|
+
separator?: MPBreadcrumbSeparator | React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* How many steps to show before the middle is folded away behind a `…`. Left
|
|
28
|
+
* out, the whole trail is shown however long it gets.
|
|
29
|
+
*/
|
|
30
|
+
maxItems?: number;
|
|
31
|
+
/**
|
|
32
|
+
* How many steps stay at the front of a folded trail.
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
35
|
+
itemsBeforeCollapse?: number;
|
|
36
|
+
/**
|
|
37
|
+
* How many stay at the end.
|
|
38
|
+
* @default 1
|
|
39
|
+
*/
|
|
40
|
+
itemsAfterCollapse?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Whether pressing the `…` unfolds the trail in place. Turn it off to leave
|
|
43
|
+
* the fold as a plain mark.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
expandable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The name the trail is announced by.
|
|
49
|
+
* @default 'Breadcrumb'
|
|
50
|
+
*/
|
|
51
|
+
label?: string;
|
|
52
|
+
/**
|
|
53
|
+
* What the `…` is announced as.
|
|
54
|
+
* @default 'Show hidden steps'
|
|
55
|
+
*/
|
|
56
|
+
expandLabel?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Publishes the trail as schema.org `BreadcrumbList` microdata, which is what
|
|
59
|
+
* a search engine reads to draw the trail under a result instead of the bare
|
|
60
|
+
* URL.
|
|
61
|
+
*
|
|
62
|
+
* Off by default, and that is not timidity: a page may only claim one
|
|
63
|
+
* breadcrumb trail, so a component that emitted this unasked would collide
|
|
64
|
+
* with the JSON-LD a site already has in its `<head>` — and two trails is
|
|
65
|
+
* worse than none. Turn it on when this component *is* the page's trail.
|
|
66
|
+
*
|
|
67
|
+
* What it adds is attributes and `<meta>`; nothing about the drawing, the
|
|
68
|
+
* layout or the accessibility tree changes.
|
|
69
|
+
*
|
|
70
|
+
* ## It does not survive a fold
|
|
71
|
+
*
|
|
72
|
+
* `BreadcrumbList` positions have to run 1, 2, 3 with nothing missing, and a
|
|
73
|
+
* folded trail does not render the steps behind its `…` — so publishing one
|
|
74
|
+
* would describe a trail that skips from 2 to 6. Turning this on therefore
|
|
75
|
+
* turns `maxItems` off. A trail worth publishing is a trail worth showing.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
structuredData?: boolean;
|
|
79
|
+
/** The `MPBreadcrumbItem`s. */
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
export interface MPBreadcrumbItemProps extends Omit<React.ComponentPropsWithoutRef<'li'>, 'color' | 'onClick'> {
|
|
83
|
+
/** Renders the step as a link. */
|
|
84
|
+
href?: string;
|
|
85
|
+
/** Fires when the step is pressed. Renders it as a button when there is no `href`. */
|
|
86
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
87
|
+
/** Content before the label — a home glyph, a repository avatar. */
|
|
88
|
+
startIcon?: React.ReactNode;
|
|
89
|
+
/** Content after the label. */
|
|
90
|
+
endIcon?: React.ReactNode;
|
|
91
|
+
/**
|
|
92
|
+
* Marks this step as the page you are on, which stops it being a link.
|
|
93
|
+
*
|
|
94
|
+
* The last step is the current one on its own, so this is only needed for a
|
|
95
|
+
* trail that ends somewhere the reader is not — and setting it anywhere takes
|
|
96
|
+
* the mark off the last step, because only one step in a trail can be it.
|
|
97
|
+
*/
|
|
98
|
+
current?: boolean;
|
|
99
|
+
/** Unavailable. Stops answering, keeps its place in the trail. */
|
|
100
|
+
disabled?: boolean;
|
|
101
|
+
/** The step's label. */
|
|
102
|
+
children?: React.ReactNode;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The trail of pages above the one being read.
|
|
106
|
+
*
|
|
107
|
+
* Two things make this more than a row of links. The first is that the last step
|
|
108
|
+
* is where the reader already is, so it is not a link at all — it carries
|
|
109
|
+
* `aria-current="page"` and stops being pressable, and the component works that
|
|
110
|
+
* out rather than asking every caller to remember it. The second is the fold: a
|
|
111
|
+
* trail seven levels deep is a trail nobody reads, so the middle collapses to a
|
|
112
|
+
* `…` that puts it back when pressed.
|
|
113
|
+
*
|
|
114
|
+
* The separators are drawn by the trail rather than by the steps. A step does not
|
|
115
|
+
* know whether anything follows it, and a mark that belonged to a step would have
|
|
116
|
+
* to be taken off the last one by hand.
|
|
117
|
+
*/
|
|
118
|
+
export declare const MPBreadcrumb: React.ForwardRefExoticComponent<MPBreadcrumbProps & React.RefAttributes<HTMLElement>>;
|
|
119
|
+
/**
|
|
120
|
+
* One step of the trail.
|
|
121
|
+
*
|
|
122
|
+
* It renders three different things and the caller picks by what they pass: an
|
|
123
|
+
* `<a>` with an `href`, a `<button>` with an `onClick`, and a plain `<span>` with
|
|
124
|
+
* neither — which is what the last step is, because the page you are already on
|
|
125
|
+
* is not somewhere to go.
|
|
126
|
+
*/
|
|
127
|
+
export declare const MPBreadcrumbItem: React.ForwardRefExoticComponent<MPBreadcrumbItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as n,Fragment as t}from"react/jsx-runtime";import*as r from"react";import{MPIcon as o}from"../icon/MPIcon";import{ArrowRightIcon as i,ChevronRightIcon as a,MoreIcon as s}from"../../constants/icons";import{accentSlots as l}from"../../internal/accent";import{CONTROL_GAP as c,hasContent as m,PROSE_TEXT as d}from"../../internal/scale";const u=r.createContext({size:"md",last:!1,position:null}),p={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2.5",xl:"gap-3"},h={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-xs",lg:"rounded-mp-sm",xl:"rounded-mp-sm"};const f=["chevron","arrow","slash","dot"];export const MPBreadcrumb=r.forwardRef(function({size:t="md",color:c="primary",separator:m="chevron",maxItems:h,itemsBeforeCollapse:x=1,itemsAfterCollapse:b=1,expandable:v=!0,label:g="Breadcrumb",expandLabel:N="Show hidden steps",structuredData:y=!1,className:k,style:B,children:j,...w},z){const[C,P]=r.useState(!1),M=r.Children.toArray(j).filter(r.isValidElement),I=M.length,S=M.some(e=>!0===e.props.current),L=!C&&!y&&void 0!==h&&I>Math.max(h,1)&&I-x-b>1?[...M.slice(0,Math.max(0,x)),null,...M.slice(I-Math.max(0,b))]:M,_="string"==typeof(A=m)&&f.includes(A)?function(n){switch(n){case"chevron":return e(o,{icon:a,size:"1.1em",className:"rtl:rotate-180"});case"arrow":return e(o,{icon:i,size:"1em",className:"rtl:rotate-180"});case"slash":return e("span",{"aria-hidden":"true",children:"/"});case"dot":return e("span",{"aria-hidden":"true",children:"·"});default:return null}}(m):m;var A;const E=r.useMemo(()=>Array.from({length:L.length},(e,n)=>({size:t,last:!S&&n===L.length-1,position:y?n+1:null})),[t,S,L.length,y]),F=["rounded-mp-xs text-mp-on-surface-variant inline-flex items-center px-0.5","appearance-none border-0 bg-transparent font-[inherit]","transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",v?["cursor-pointer hover:bg-(--_mp-accent-container) hover:text-(--_mp-on-accent-container)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "):""].filter(Boolean).join(" ");return e("nav",{ref:z,"aria-label":g,"data-mp-size":t,className:["mp-breadcrumb flex",d[t],k??""].filter(Boolean).join(" "),style:{...l(c),...B},...w,children:e("ol",{role:"list",itemScope:y||void 0,itemType:y?"https://schema.org/BreadcrumbList":void 0,className:`flex list-none flex-wrap items-center p-0 ${p[t]}`,children:L.map((t,i)=>n(r.Fragment,{children:[i>0?e("li",{"aria-hidden":"true",className:"text-mp-on-surface-variant flex shrink-0 items-center select-none",children:_}):null,t?e(u.Provider,{value:E[i],children:t}):e("li",{className:"flex shrink-0 items-center",children:v?e("button",{type:"button",className:F,"aria-label":N,onClick:()=>P(!0),children:e(o,{icon:s,size:"1.1em"})}):e("span",{className:F,"aria-hidden":"true",children:e(o,{icon:s,size:"1.1em"})})})]},t?t.key??i:"fold"))})})});export const MPBreadcrumbItem=r.forwardRef(function({href:o,onClick:i,startIcon:a,endIcon:s,current:l,disabled:d=!1,className:p,children:f,...x},b){const{size:v,last:g,position:N}=r.useContext(u),y=l??g,k=Boolean(o||i)&&!y&&!d,B=null!==N,j=["inline-flex min-w-0 items-center px-1 no-underline","appearance-none border-0 bg-transparent font-[inherit] text-[inherit]",c[v],h[v],"transition-[background-color,color] duration-(--mp-sys-motion-duration-short4)",d?"text-mp-on-surface/38 cursor-default":y?"text-mp-on-surface font-medium":k?["text-mp-on-surface-variant cursor-pointer","hover:bg-(--_mp-accent-container) hover:text-(--_mp-on-accent-container)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-1","focus-visible:outline-solid outline-none"].join(" "):"text-mp-on-surface-variant"].filter(Boolean).join(" "),w=n(t,{children:[m(a)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:a}):null,e("span",{className:"truncate",itemProp:B?"name":void 0,children:f}),m(s)?e("span",{className:"flex h-[1lh] shrink-0 items-center",children:s}):null]});return n("li",{ref:b,itemProp:B?"itemListElement":void 0,itemScope:B||void 0,itemType:B?"https://schema.org/ListItem":void 0,className:["flex min-w-0 items-center",p??""].filter(Boolean).join(" "),...x,children:[B?e("meta",{itemProp:"position",content:String(N)}):null,k&&o?e("a",{href:o,itemProp:B?"item":void 0,className:j,onClick:i,children:w}):k?e("button",{type:"button",className:j,onClick:i,children:w}):e("span",{className:j,"aria-current":y?"page":void 0,"aria-disabled":d||void 0,children:w})]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPBreadcrumb,MPBreadcrumbItem}from"./MPBreadcrumb";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPStyleProps, MPVariant } from '../../types';
|
|
3
|
+
export interface MPButtonProps extends MPStyleProps, Omit<React.ComponentPropsWithoutRef<'button'>, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* How much surface the button paints.
|
|
6
|
+
* @default 'filled'
|
|
7
|
+
*/
|
|
8
|
+
variant?: MPVariant;
|
|
9
|
+
/**
|
|
10
|
+
* Which accent family it reads. Not an arbitrary colour: to change what
|
|
11
|
+
* `primary` *is*, set the token.
|
|
12
|
+
* @default 'primary'
|
|
13
|
+
*/
|
|
14
|
+
color?: MPColor;
|
|
15
|
+
/** Content placed before the label. */
|
|
16
|
+
startIcon?: React.ReactNode;
|
|
17
|
+
/** Content placed after the label. */
|
|
18
|
+
endIcon?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Swaps `startIcon` for a spinner and stops the button firing, while leaving it
|
|
21
|
+
* focusable and otherwise unchanged.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately not `disabled`. A button that vanishes from the tab order the
|
|
24
|
+
* moment it is pressed takes the keyboard focus with it, and the reader is
|
|
25
|
+
* returned to the top of the document while the request they just made is
|
|
26
|
+
* still in flight.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The accessible name of the spinner, announced while `loading`. Defaults to
|
|
32
|
+
* the word for "loading" in `locale`.
|
|
33
|
+
*/
|
|
34
|
+
loadingLabel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Which language the spinner's default name is written in. Falls back to the
|
|
37
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
38
|
+
*/
|
|
39
|
+
locale?: string;
|
|
40
|
+
/**
|
|
41
|
+
* `button`, not `submit`. A native button defaults to submitting the form
|
|
42
|
+
* around it, which turns every unrelated button inside a form into one that
|
|
43
|
+
* submits it.
|
|
44
|
+
* @default 'button'
|
|
45
|
+
*/
|
|
46
|
+
type?: 'button' | 'submit' | 'reset';
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A Material Design button.
|
|
51
|
+
*
|
|
52
|
+
* Five variants, four accent families and the library's size ladder, drawn from
|
|
53
|
+
* MD3's own component tokens: the container and label colours per variant, the
|
|
54
|
+
* state layer, the spec's disabled opacities, and the shape — `corner-full`,
|
|
55
|
+
* because a Material button has been a pill since 2021 and a rounded rectangle
|
|
56
|
+
* is the single fastest way to make a screen look like it is from 2018.
|
|
57
|
+
*
|
|
58
|
+
* Base UI's `Button` is underneath, which is what makes `disabled` behave: it
|
|
59
|
+
* keeps a disabled button out of the tab order without the composition problems
|
|
60
|
+
* a plain `aria-disabled` brings, and publishes `data-pressed` so a press driven
|
|
61
|
+
* from the keyboard lights the same state layer a pointer press does.
|
|
62
|
+
*
|
|
63
|
+
* ## Two things this does not have
|
|
64
|
+
*
|
|
65
|
+
* **No `href`.** A button that navigates is a link, and the difference is not
|
|
66
|
+
* cosmetic: a link is announced as one, opens in a new tab on the middle button,
|
|
67
|
+
* and shows its destination in the status bar. Wrap an `<a>` in the styling, or
|
|
68
|
+
* pass `render={<a href="…" />}` — Base UI's own escape hatch — rather than
|
|
69
|
+
* teaching the button to lie about what it is.
|
|
70
|
+
*
|
|
71
|
+
* **No ripple.** MD3 dropped it: the state layer below is what replaced it, and
|
|
72
|
+
* it says the same thing without an animation that has to finish before the
|
|
73
|
+
* screen it triggered is allowed to change.
|
|
74
|
+
*/
|
|
75
|
+
export declare const MPButton: React.ForwardRefExoticComponent<MPButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{Button as n}from"@base-ui/react/button";import{MPIcon as r}from"../icon/MPIcon";import{SpinnerIcon as a}from"../../constants/icons";import{accentSlots as i}from"../../internal/accent";import{MPButtonGroupContext as s}from"../../internal/button-group";import{useMPLocale as l,useMPMessages as c}from"../../internal/locale";import{MPStateLayer as m}from"../../internal/StateLayer";import{CONTROL_GAP as p,CONTROL_HEIGHT as d,CONTROL_ICON as u,CONTROL_PAD_X as f,CONTROL_SQUARE as b,CONTROL_TEXT as x,hasContent as g}from"../../internal/scale";const v={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 hover:shadow-mp-2 bg-mp-surface-container-low text-(--_mp-accent)",outlined:"border-mp-outline border bg-transparent text-(--_mp-accent)",text:"bg-transparent text-(--_mp-accent)"},h={filled:"bg-mp-on-surface/12 text-mp-on-surface/38",tonal:"bg-mp-on-surface/12 text-mp-on-surface/38",elevated:"bg-mp-on-surface/12 text-mp-on-surface/38 shadow-none",outlined:"border-mp-on-surface/12 border bg-transparent text-mp-on-surface/38",text:"bg-transparent text-mp-on-surface/38"};export const MPButton=t.forwardRef(function({variant:w,size:y,color:_,disabled:j,startIcon:k,endIcon:z,loading:B=!1,loadingLabel:C,locale:I,fullWidth:N=!1,type:P="button",className:L,style:M,children:D,onClick:R,...S},W){const $=l(I),q=c("common",$),A=t.useContext(s),E=w??A?.variant??"filled",F=y??A?.size??"md",G=_??A?.color??"primary",H=j??A?.disabled??!1,J=!g(D);return o(n,{ref:W,type:P,disabled:H,"aria-busy":B||void 0,"aria-disabled":B||void 0,"data-mp-size":F,"data-mp-variant":E,"data-loading":B||void 0,className:["mp-button group relative inline-flex shrink-0 items-center justify-center","rounded-mp-full box-border overflow-hidden align-middle whitespace-nowrap select-none","cursor-pointer appearance-none font-[inherit]","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-[background-color,border-color,box-shadow,color]","duration-(--mp-sys-motion-duration-short4)",d[F],x[F],p[F],J?`${b[F]} px-0`:f[F],H?h[E]:v[E],H?"cursor-default":"",B?"cursor-progress":"",N?"w-full":"",L??""].filter(Boolean).join(" "),style:{...i(G),...M},onClick:e=>{if(B)return e.preventDefault(),void e.stopPropagation();R?.(e)},...S,children:[H?null:e(m,{}),B?e(r,{icon:a,size:u[F],label:C??q.loading,className:"animate-spin"}):k,D,z]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPButton}from"./MPButton";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPOrientation, MPStyleProps, MPVariant } from '../../types';
|
|
3
|
+
export interface MPButtonGroupProps extends MPStyleProps, Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
4
|
+
/**
|
|
5
|
+
* Which way the buttons run.
|
|
6
|
+
* @default 'horizontal'
|
|
7
|
+
*/
|
|
8
|
+
orientation?: MPOrientation;
|
|
9
|
+
/** Passed to every button in the group. */
|
|
10
|
+
variant?: MPVariant;
|
|
11
|
+
/** Passed to every button in the group. */
|
|
12
|
+
color?: MPColor;
|
|
13
|
+
/** Disables every button in the group at once. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A run of buttons that belong together.
|
|
19
|
+
*
|
|
20
|
+
* Two things happen here and only one of them is visual. The corners that face a
|
|
21
|
+
* neighbour are cut back — that is the look. The other half is that `variant`,
|
|
22
|
+
* `size`, `color` and `disabled` are set once for the set rather than repeated on
|
|
23
|
+
* every button, which is the failure this exists to prevent: a group where one
|
|
24
|
+
* button is a size out is not a group.
|
|
25
|
+
*
|
|
26
|
+
* The buttons stay real `MPButton`s, and the group does not manage selection.
|
|
27
|
+
* For one-of-a-set, reach for `MPSegmentedButton` — a row of buttons that
|
|
28
|
+
* remembers which one was pressed is a radio group wearing a costume, and it
|
|
29
|
+
* announces itself to a screen reader as four unrelated actions.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MPButtonGroup: React.ForwardRefExoticComponent<MPButtonGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import*as r from"react";import{MPButtonGroupContext as e}from"../../internal/button-group";const t={horizontal:"[&>*:not(:first-child)]:rounded-s-mp-sm [&>*:not(:last-child)]:rounded-e-mp-sm",vertical:"[&>*:not(:first-child)]:rounded-t-mp-sm [&>*:not(:last-child)]:rounded-b-mp-sm"};export const MPButtonGroup=r.forwardRef(function({variant:i,size:l,color:n,disabled:a,orientation:s="horizontal",fullWidth:d=!1,className:c,children:m,...u},f){const p=r.useMemo(()=>({variant:i,size:l,color:n,disabled:a}),[i,l,n,a]);return o(e.Provider,{value:p,children:o("div",{ref:f,role:"group","data-mp-orientation":s,className:["mp-button-group inline-flex gap-0.5 align-middle","vertical"===s?"flex-col":"flex-row",t[s],"[&>*]:relative [&>*:focus-visible]:z-10",d?"flex w-full [&>*]:flex-1":"",c??""].filter(Boolean).join(" "),...u,children:m})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPButtonGroup}from"./MPButtonGroup";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPBoxProps } from '../box/MPBox';
|
|
3
|
+
export interface MPCardProps extends Omit<MPBoxProps, 'title' | 'padded'> {
|
|
4
|
+
/**
|
|
5
|
+
* The card's heading.
|
|
6
|
+
*
|
|
7
|
+
* A plain string is set in the card's own title role. Pass a real heading
|
|
8
|
+
* element — `title={<h3>Totals</h3>}` — when the card should appear in the
|
|
9
|
+
* document outline: it inherits the typography rather than the browser's, so
|
|
10
|
+
* nothing about it looks different.
|
|
11
|
+
*/
|
|
12
|
+
title?: React.ReactNode;
|
|
13
|
+
/** A second line under it, one step down the type scale and muted. */
|
|
14
|
+
subtitle?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Content pinned to the end of the header row — a menu button, a status chip.
|
|
17
|
+
* It stays on the title's line while the title wraps beside it.
|
|
18
|
+
*/
|
|
19
|
+
headerAction?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* A picture, a chart, a map: drawn **edge to edge** across the top, so the
|
|
22
|
+
* card's own corners crop it.
|
|
23
|
+
*
|
|
24
|
+
* MD3's own card anatomy puts the media above the headline, and it is a slot
|
|
25
|
+
* of its own rather than part of `children` because it is the one part of a
|
|
26
|
+
* card that must not be padded.
|
|
27
|
+
*/
|
|
28
|
+
media?: React.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* The bottom area. Laid out as a wrapping row, so a pair of buttons needs no
|
|
31
|
+
* wrapper of its own; anything else brings its own layout.
|
|
32
|
+
*/
|
|
33
|
+
footer?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Draws a hairline between the sections instead of separating them with space.
|
|
36
|
+
*
|
|
37
|
+
* The rules run the full width of the sheet, so the padding moves off the card
|
|
38
|
+
* and onto each section.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
dividers?: boolean;
|
|
42
|
+
/** The card's body. */
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An [MPBox](./box) with the parts a card is made of laid out on it: a picture,
|
|
47
|
+
* a heading, a subheading, a body and a footer.
|
|
48
|
+
*
|
|
49
|
+
* The sections are props rather than compound sub-components — no `<MPCard.Header>`
|
|
50
|
+
* — for the reason [MPDialog](../feedback/dialog) gives: the arrangement of a
|
|
51
|
+
* card is fixed, and what a caller wants to decide is what goes in each slot,
|
|
52
|
+
* not what order the slots come in. Every `MPBox` prop passes straight through,
|
|
53
|
+
* so a card is styled on exactly the same axes as the box it is.
|
|
54
|
+
*
|
|
55
|
+
* ## The surface is MD3's card, and so is the anatomy
|
|
56
|
+
*
|
|
57
|
+
* `corner-medium`, and three of the five variants are the specification's own
|
|
58
|
+
* card variants to the letter: `filled` is `surface-container-highest`,
|
|
59
|
+
* `elevated` is `surface-container-low` under a level-1 shadow, `outlined` is a
|
|
60
|
+
* hairline in `outline-variant`. None of them is dyed, and there is no `color`
|
|
61
|
+
* — see `MPBox` for the argument, which is the same one.
|
|
62
|
+
*
|
|
63
|
+
* ## What a card deliberately is not
|
|
64
|
+
*
|
|
65
|
+
* It is not pressable. MD3 does describe a card as a container that *may* be
|
|
66
|
+
* interactive, and a `href` or an `onClick` here would be the wrong shape for
|
|
67
|
+
* it: a card with a heading, a body and two buttons in its footer that is also
|
|
68
|
+
* one big link is a link containing links, which the HTML parser will take
|
|
69
|
+
* apart. Make the **heading** the link, or give the footer a button. What a
|
|
70
|
+
* whole-card target is for is a grid of tiles, and a tile is an
|
|
71
|
+
* [MPBox](./box) with an `<a>` in it.
|
|
72
|
+
*/
|
|
73
|
+
export declare const MPCard: React.ForwardRefExoticComponent<MPCardProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as l,Fragment as a}from"react/jsx-runtime";import*as r from"react";import{MPBox as n}from"../box/MPBox";import{hasContent as i,META_TEXT as o,PROSE_TEXT as t,SHEET_GAP as c,SHEET_PAD_X as s,SHEET_PAD_Y as d,SHEET_TITLE as m}from"../../internal/scale";export const MPCard=r.forwardRef(function({size:r="md",title:f,subtitle:u,headerAction:p,media:x,footer:h,dividers:_=!1,className:v,children:N,...w},b){const k=s[r],$=d[r],g=_?`${k} ${$}`:k,j=i(f)||i(u)||i(p),y=i(x),B=[j?{key:"header",className:"mp-card__header flex items-start gap-3",content:l(a,{children:[i(f)||i(u)?l("div",{className:"flex min-w-0 flex-1 flex-col",children:[i(f)?e("div",{className:`mp-card__title ${m[r]}`,children:f}):null,i(u)?e("div",{className:`text-mp-on-surface-variant ${o}`,children:u}):null]}):null,i(p)?e("div",{className:"ms-auto shrink-0",children:p}):null]})}:null,i(N)?{key:"content",className:`mp-card__body min-w-0 ${t[r]}`,content:N}:null,i(h)?{key:"footer",className:"mp-card__footer flex flex-wrap items-center gap-2",content:h}:null].filter(e=>null!==e);return l(n,{ref:b,size:r,padded:!1,className:["mp-card flex flex-col",y?"overflow-hidden":"",v??""].filter(Boolean).join(" "),...w,children:[y?e("div",{className:"mp-card__media [&_img]:block [&_img]:w-full [&_video]:block [&_video]:w-full",children:x}):null,B.length>0?e("div",{className:["flex min-w-0 flex-col",_?"":`${$} ${c[r]}`].filter(Boolean).join(" "),children:B.map((l,a)=>e("div",{className:[g,l.className,_&&a>0?"border-mp-outline-variant border-t":""].filter(Boolean).join(" "),children:l.content},l.key))}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPCard}from"./MPCard";
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
export interface MPCarouselProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'defaultValue' | 'onChange'> {
|
|
4
|
+
/** Which slide is showing, counted from 0. Use with `onValueChange`. */
|
|
5
|
+
value?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Which starts showing, for an uncontrolled carousel.
|
|
8
|
+
* @default 0
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: number;
|
|
11
|
+
onValueChange?: (index: number) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the arrows wrap from the last slide back to the first.
|
|
14
|
+
*
|
|
15
|
+
* With it off they go `disabled` at the ends instead, which is the honest
|
|
16
|
+
* thing for a set that has a beginning and an end — a gallery of three
|
|
17
|
+
* photographs does, a rotating banner does not.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
loop?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Advances on its own.
|
|
23
|
+
*
|
|
24
|
+
* Off by default and deliberately so: a carousel that moves while it is being
|
|
25
|
+
* read is the most complained-about pattern on the web. It pauses on hover, on
|
|
26
|
+
* focus anywhere inside it, while the tab is in the background, and it does not
|
|
27
|
+
* start at all for a reader who has asked for reduced motion.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
autoPlay?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* How long each slide is held, in milliseconds.
|
|
33
|
+
* @default 5000
|
|
34
|
+
*/
|
|
35
|
+
interval?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The previous/next buttons.
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
arrows?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The row of position marks under the frame.
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
indicators?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* How much surface the frame paints behind the slides.
|
|
48
|
+
*
|
|
49
|
+
* `text` is the one to reach for when the pictures already have edges of their
|
|
50
|
+
* own — it draws no frame at all, and the slides are the whole component.
|
|
51
|
+
* @default 'outlined'
|
|
52
|
+
*/
|
|
53
|
+
variant?: MPVariant;
|
|
54
|
+
/**
|
|
55
|
+
* The size of the arrows and the marks, and how far the arrows sit in from the
|
|
56
|
+
* frame's edge. Not the size of a slide, which is whatever the frame is.
|
|
57
|
+
* @default 'md'
|
|
58
|
+
*/
|
|
59
|
+
size?: MPSize;
|
|
60
|
+
/**
|
|
61
|
+
* Which accent family the current mark and the arrows read.
|
|
62
|
+
* @default 'primary'
|
|
63
|
+
*/
|
|
64
|
+
color?: MPColor;
|
|
65
|
+
/**
|
|
66
|
+
* The carousel's accessible name.
|
|
67
|
+
* @default 'Carousel'
|
|
68
|
+
*/
|
|
69
|
+
label?: string;
|
|
70
|
+
/** @default 'Previous slide' */
|
|
71
|
+
previousLabel?: string;
|
|
72
|
+
/** @default 'Next slide' */
|
|
73
|
+
nextLabel?: string;
|
|
74
|
+
/**
|
|
75
|
+
* How one slide is named to a screen reader, and how its mark is labelled.
|
|
76
|
+
* @default (index, count) => `Slide ${index} of ${count}`
|
|
77
|
+
*/
|
|
78
|
+
slideLabel?: (index: number, count: number) => string;
|
|
79
|
+
/** The slides. Every top-level child becomes one. */
|
|
80
|
+
children?: React.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A strip of slides, one of which is in view.
|
|
84
|
+
*
|
|
85
|
+
* The mechanism is a scroll container with CSS scroll snapping, and nearly
|
|
86
|
+
* everything good about this component follows from that one choice. Swiping on
|
|
87
|
+
* a phone and two-finger dragging on a trackpad both work, because they are the
|
|
88
|
+
* browser's own scrolling rather than a gesture handler pretending to be it. The
|
|
89
|
+
* strip runs the other way under RTL without being told, because scrolling is
|
|
90
|
+
* directional and `translate` is not. And nothing is transformed, so the house
|
|
91
|
+
* rule against moving a surface holds here for free — a translated track would
|
|
92
|
+
* have had to argue for an exception.
|
|
93
|
+
*
|
|
94
|
+
* The motion is `scroll-behavior: smooth`, which means a reader who has asked for
|
|
95
|
+
* reduced motion gets an instant cut out of the same code path rather than out of
|
|
96
|
+
* a second one written to remember them.
|
|
97
|
+
*
|
|
98
|
+
* ## Why every child is a slide
|
|
99
|
+
*
|
|
100
|
+
* There is no `MPCarouselSlide`. `<MPCarousel><img /><img /></MPCarousel>` is the
|
|
101
|
+
* whole API, and the wrapper this component puts around each child is what
|
|
102
|
+
* carries the snap point, the width and the `role="group"` /
|
|
103
|
+
* `aria-roledescription="slide"` pair a screen reader needs — none of which a
|
|
104
|
+
* caller should have to remember to put on a photograph.
|
|
105
|
+
*
|
|
106
|
+
* ## What this is, in MD3's terms
|
|
107
|
+
*
|
|
108
|
+
* The specification describes four carousel layouts, three of which — hero,
|
|
109
|
+
* multi-browse and uncontained — resize their items as they travel past the
|
|
110
|
+
* frame's edge. This is the fourth: one item to a view, snapping. The other three
|
|
111
|
+
* are a per-item transform driven by scroll position, which is a different
|
|
112
|
+
* component and not one this library ships yet; what is here is drawn out of the
|
|
113
|
+
* specification's own parts — a filled icon button either side, a selected
|
|
114
|
+
* indicator that is a bar rather than a bigger dot.
|
|
115
|
+
*/
|
|
116
|
+
export declare const MPCarousel: React.ForwardRefExoticComponent<MPCarouselProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as t from"react";import{MPIconButton as n}from"../icon-button/MPIconButton";import{MPIcon as o}from"../icon/MPIcon";import{ChevronLeftIcon as a,ChevronRightIcon as i}from"../../constants/icons";import{accentSlots as l}from"../../internal/accent";import{CONTROL_ICON as s}from"../../internal/scale";import{CONTAINER_SURFACE as c}from"../../internal/surface";import{VISUALLY_HIDDEN as u}from"../../internal/visually-hidden";const d={xs:"start-1 end-1",sm:"start-1.5 end-1.5",md:"start-2 end-2",lg:"start-3 end-3",xl:"start-4 end-4"},m={xs:{rest:"h-1 w-1",current:"h-1 w-3",gap:"gap-1"},sm:{rest:"h-1 w-1",current:"h-1 w-3.5",gap:"gap-1"},md:{rest:"h-1.5 w-1.5",current:"h-1.5 w-4",gap:"gap-1.5"},lg:{rest:"h-1.5 w-1.5",current:"h-1.5 w-5",gap:"gap-2"},xl:{rest:"h-2 w-2",current:"h-2 w-6",gap:"gap-2"}},f=(e,r)=>`Slide ${e} of ${r}`;export const MPCarousel=t.forwardRef(function({value:p,defaultValue:h=0,onValueChange:b,loop:v=!0,autoPlay:w=!1,interval:g=5e3,arrows:x=!0,indicators:N=!0,variant:y="outlined",size:M="md",color:k="primary",label:R="Carousel",previousLabel:j="Previous slide",nextLabel:C="Next slide",slideLabel:P=f,className:z,style:I,children:$,...L},E){const S=t.Children.toArray($),T=S.length,[A,B]=t.useState(h),F=Math.min(Math.max(p??A,0),Math.max(T-1,0)),V=t.useRef(null),W=t.useRef([]),q=t.useRef(!1),_=t.useRef(!1),D=t.useRef(!1),[G,H]=t.useState(!1),J=t.useRef(F),K=t.useRef(b);J.current=F,K.current=b;const O=t.useCallback((e,r=!1)=>{if(0===T)return;const t=v?(e%T+T)%T:Math.min(Math.max(e,0),T-1);q.current=r,void 0===p&&B(t),t!==J.current&&K.current?.(t)},[T,v,p]);t.useEffect(()=>{if(q.current)return void(q.current=!1);if(!_.current)return void(_.current=!0);W.current[F]?.scrollIntoView({block:"nearest",inline:"start"}),D.current=!0;const e=window.setTimeout(()=>{D.current=!1},700);return()=>window.clearTimeout(e)},[F]),t.useEffect(()=>{if(!w||G||T<2)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;const e=window.setInterval(()=>{document.hidden||O(J.current+1)},g);return()=>window.clearInterval(e)},[w,G,T,g,O]);const Q=t.useRef(0);t.useEffect(()=>()=>cancelAnimationFrame(Q.current),[]);const U=F<=0,X=F>=T-1;return r("div",{ref:E,role:"region","aria-roledescription":"carousel","aria-label":R,"data-mp-size":M,"data-mp-variant":y,className:["mp-carousel flex w-full flex-col",z??""].filter(Boolean).join(" "),style:{...l(k),...I},onPointerEnter:()=>H(!0),onPointerLeave:()=>H(!1),onFocus:()=>H(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||H(!1)},...L,children:[r("div",{className:["relative min-w-0 overflow-hidden","rounded-mp-md box-border",c[y],"text-mp-on-surface"].join(" "),children:[e("div",{ref:V,tabIndex:0,role:"group","aria-label":R,className:["flex min-w-0 snap-x snap-mandatory overflow-x-auto scroll-smooth","motion-reduce:scroll-auto","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden","outline-mp-secondary focus-visible:outline-2 focus-visible:-outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),onScroll:()=>{Q.current||(Q.current=requestAnimationFrame(()=>{Q.current=0;const e=V.current;if(!e||0===e.clientWidth||D.current)return;const r=Math.round(Math.abs(e.scrollLeft)/e.clientWidth);r!==J.current&&r>=0&&r<T&&O(r,!0)}))},children:S.map((r,t)=>e("div",{ref:e=>{W.current[t]=e,W.current.length=T},role:"group","aria-roledescription":"slide","aria-label":P(t+1,T),className:"w-full shrink-0 grow-0 basis-full snap-start",children:r},t))}),x&&T>1?r("div",{className:`pointer-events-none absolute inset-y-0 flex items-center ${d[M]}`,children:[e(n,{variant:"filled",size:M,color:k,label:j,disabled:!v&&U,className:"pointer-events-auto",icon:e(o,{icon:a,size:s[M],className:"rtl:rotate-180"}),onClick:()=>O(F-1)}),e("span",{className:"flex-1"}),e(n,{variant:"filled",size:M,color:k,label:C,disabled:!v&&X,className:"pointer-events-auto",icon:e(o,{icon:i,size:s[M],className:"rtl:rotate-180"}),onClick:()=>O(F+1)})]}):null]}),N&&T>1?e("div",{className:`flex shrink-0 items-center justify-center pt-2 ${m[M].gap}`,children:S.map((r,t)=>e("button",{type:"button","aria-label":P(t+1,T),"aria-current":t===F?"true":void 0,className:["rounded-mp-full cursor-pointer appearance-none border-0 p-0","transition-[width,background-color] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard motion-reduce:transition-none","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none",t===F?`${m[M].current} bg-(--_mp-accent)`:`${m[M].rest} bg-mp-outline-variant hover:bg-mp-outline`].join(" "),onClick:()=>O(t)},t))}):null,e("span",{className:u,"aria-live":w?"off":"polite",children:T>0?P(F+1,T):""})]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPCarousel}from"./MPCarousel";
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Whose message this is.
|
|
5
|
+
*
|
|
6
|
+
* `start` and `end` rather than `them`/`me` or `left`/`right`: a thread runs the
|
|
7
|
+
* way the language does, and the same two words already mean this everywhere
|
|
8
|
+
* else in the library. `start` is the default because a message from somebody
|
|
9
|
+
* else is the one you have no other way of knowing about.
|
|
10
|
+
*/
|
|
11
|
+
export type MPChatBubbleSide = 'start' | 'end';
|
|
12
|
+
/**
|
|
13
|
+
* How far a message has got.
|
|
14
|
+
*
|
|
15
|
+
* The first four are a ladder and the fifth is not on it: `failed` is the
|
|
16
|
+
* message that did not go, which is why it is the only one drawn in another
|
|
17
|
+
* colour family.
|
|
18
|
+
*/
|
|
19
|
+
export type MPChatBubbleStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'failed';
|
|
20
|
+
/** What a link inside a message unfurls to. */
|
|
21
|
+
export interface MPChatBubblePreview {
|
|
22
|
+
/** Where the card goes. */
|
|
23
|
+
url: string;
|
|
24
|
+
/** The page's title. */
|
|
25
|
+
title?: React.ReactNode;
|
|
26
|
+
/** Its summary, clamped to two lines. */
|
|
27
|
+
description?: React.ReactNode;
|
|
28
|
+
/** The share image, drawn across the top of the card. */
|
|
29
|
+
image?: string;
|
|
30
|
+
/** Who published it — a domain, a site name. */
|
|
31
|
+
site?: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Opens the card in a new tab.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
newTab?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface MPChatBubbleProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'title'> {
|
|
39
|
+
/**
|
|
40
|
+
* Whose message this is.
|
|
41
|
+
* @default 'start'
|
|
42
|
+
*/
|
|
43
|
+
side?: MPChatBubbleSide;
|
|
44
|
+
/** Who sent it, above the bubble. */
|
|
45
|
+
name?: React.ReactNode;
|
|
46
|
+
/** When it was sent, beside the name. */
|
|
47
|
+
time?: React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* The sender's picture — an [MPAvatar](../display/avatar), at the size the
|
|
50
|
+
* thread uses. Left out, the bubble takes the whole row.
|
|
51
|
+
*/
|
|
52
|
+
avatar?: React.ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* How far the message has got, drawn as a mark under the bubble. Left out,
|
|
55
|
+
* nothing is drawn — a received message has no delivery state worth showing.
|
|
56
|
+
*/
|
|
57
|
+
status?: MPChatBubbleStatus;
|
|
58
|
+
/** Overrides the word the mark is read out as. */
|
|
59
|
+
statusLabel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Draws the three dots instead of the message. Whatever is in `children` is
|
|
62
|
+
* left alone, so the same bubble can go back to it when the message arrives.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
typing?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A picture, a video, a map — drawn edge to edge above the text, so the
|
|
68
|
+
* bubble's own corners crop it.
|
|
69
|
+
*/
|
|
70
|
+
media?: React.ReactNode;
|
|
71
|
+
/** A link in the message, unfurled into a card under the text. */
|
|
72
|
+
preview?: MPChatBubblePreview;
|
|
73
|
+
/**
|
|
74
|
+
* The message's own actions — an [MPMenu](../inputs/menu) trigger, most of the
|
|
75
|
+
* time. Sits beside the bubble and stays out of the way until the row is
|
|
76
|
+
* hovered or something in it takes focus.
|
|
77
|
+
*/
|
|
78
|
+
actions?: React.ReactNode;
|
|
79
|
+
/**
|
|
80
|
+
* Which language the marks are read out in. Falls back to the nearest
|
|
81
|
+
* `MPLocaleProvider`, then to English.
|
|
82
|
+
*/
|
|
83
|
+
locale?: string;
|
|
84
|
+
/**
|
|
85
|
+
* How much surface the bubble paints.
|
|
86
|
+
*
|
|
87
|
+
* A bubble *is* the thing being coloured, unlike a card — so this is the
|
|
88
|
+
* control ladder rather than the container one, and `filled` floods it with
|
|
89
|
+
* the accent. That is what tells your own messages from everyone else's at a
|
|
90
|
+
* glance rather than one line at a time.
|
|
91
|
+
*
|
|
92
|
+
* `side` deliberately does not decide it: which end of the thread is filled is
|
|
93
|
+
* a decision about the product, not about the component, and a thread that
|
|
94
|
+
* fills neither is a perfectly good thread.
|
|
95
|
+
* @default 'tonal'
|
|
96
|
+
*/
|
|
97
|
+
variant?: MPVariant;
|
|
98
|
+
/**
|
|
99
|
+
* The type scale of the message, and the room inside the bubble.
|
|
100
|
+
* @default 'md'
|
|
101
|
+
*/
|
|
102
|
+
size?: MPSize;
|
|
103
|
+
/**
|
|
104
|
+
* @default 'primary'
|
|
105
|
+
*/
|
|
106
|
+
color?: MPColor;
|
|
107
|
+
/** The message. */
|
|
108
|
+
children?: React.ReactNode;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* One message in a conversation.
|
|
112
|
+
*
|
|
113
|
+
* MD3 does not describe a chat bubble — this is the library's own shape, in the
|
|
114
|
+
* sense [MPProgressBox](../feedback/progress-box) is — but every part of it is
|
|
115
|
+
* drawn out of the specification's own roles, so a thread of these sits in a
|
|
116
|
+
* Material page without announcing that it is extra.
|
|
117
|
+
*
|
|
118
|
+
* Everything around the bubble is optional and nothing about it is fixed by
|
|
119
|
+
* `side`: the avatar, the sender's name, the time, the delivery mark, the media
|
|
120
|
+
* above the text and the link card below it are each drawn only when they are
|
|
121
|
+
* given something. What `side` decides is which way the row runs and which
|
|
122
|
+
* corner of the bubble is cut short.
|
|
123
|
+
*
|
|
124
|
+
* ## Why `variant` is not tied to `side`
|
|
125
|
+
*
|
|
126
|
+
* Filling the reading-end column is a convention, not a law. It is also a
|
|
127
|
+
* decision about the product — some threads fill neither end, and a support
|
|
128
|
+
* inbox may want the *agent's* messages filled rather than the reader's. So
|
|
129
|
+
* `side` decides the geometry and `variant` decides the emphasis, and a caller
|
|
130
|
+
* who wants the usual arrangement writes it once.
|
|
131
|
+
*/
|
|
132
|
+
export declare const MPChatBubble: React.ForwardRefExoticComponent<MPChatBubbleProps & React.RefAttributes<HTMLDivElement>>;
|