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,67 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Which keyboard the shortcut is being read on.
|
|
5
|
+
*
|
|
6
|
+
* `auto` asks the browser, which is right for a shortcut a reader is about to
|
|
7
|
+
* press. The three explicit values are for documentation that has to name a
|
|
8
|
+
* platform rather than the reader's own — a support page describing the Windows
|
|
9
|
+
* build, a table comparing the two.
|
|
10
|
+
*/
|
|
11
|
+
export type MPShortcutOS = 'auto' | 'mac' | 'windows' | 'linux';
|
|
12
|
+
export interface MPShortcutProps extends Omit<React.ComponentPropsWithoutRef<'span'>, 'color' | 'children'> {
|
|
13
|
+
/**
|
|
14
|
+
* The keys, innermost punctuation and all.
|
|
15
|
+
*
|
|
16
|
+
* A string is split on `+` — `'Mod+Shift+P'` — which covers everything except
|
|
17
|
+
* a shortcut whose key *is* a plus. For that one, pass the array form:
|
|
18
|
+
* `keys={['Ctrl', '+']}`.
|
|
19
|
+
*/
|
|
20
|
+
keys: string | string[];
|
|
21
|
+
/**
|
|
22
|
+
* Which keyboard to name the modifiers for.
|
|
23
|
+
* @default 'auto'
|
|
24
|
+
*/
|
|
25
|
+
os?: MPShortcutOS;
|
|
26
|
+
/**
|
|
27
|
+
* What goes between two keys. Omit it for the platform's own convention: a `+`
|
|
28
|
+
* on Windows and Linux, and nothing at all on macOS, where a shortcut is
|
|
29
|
+
* written as a run of symbols — `⇧⌘P`, never `⇧+⌘+P`.
|
|
30
|
+
*/
|
|
31
|
+
separator?: React.ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* How much surface a key cap paints.
|
|
34
|
+
* @default 'outlined'
|
|
35
|
+
*/
|
|
36
|
+
variant?: MPVariant;
|
|
37
|
+
/**
|
|
38
|
+
* @default 'md'
|
|
39
|
+
*/
|
|
40
|
+
size?: MPSize;
|
|
41
|
+
/**
|
|
42
|
+
* @default 'secondary'
|
|
43
|
+
*/
|
|
44
|
+
color?: MPColor;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A keyboard key, or a combination of them.
|
|
48
|
+
*
|
|
49
|
+
* Two things make this more than a styled `<kbd>`, and both are about the label
|
|
50
|
+
* rather than the box around it.
|
|
51
|
+
*
|
|
52
|
+
* The first is `Mod`. A shortcut written as `Ctrl+K` is wrong for every Mac
|
|
53
|
+
* reader and one written as `⌘K` is wrong for everybody else, so the token that
|
|
54
|
+
* means "the modifier shortcuts are built on" resolves per platform — and `os`
|
|
55
|
+
* is there for the pages that have to name a platform rather than the reader's.
|
|
56
|
+
*
|
|
57
|
+
* The second is that `⌘` is not a word. A screen reader reads it as "place of
|
|
58
|
+
* interest sign", so every key drawn as a glyph carries its name beside it in a
|
|
59
|
+
* clipped box. What is announced is "Command K", which is what the shortcut is
|
|
60
|
+
* called.
|
|
61
|
+
*
|
|
62
|
+
* The keys are real `<kbd>` elements; the wrapper around them is a `<span>`.
|
|
63
|
+
* Nesting `<kbd>` inside `<kbd>` is allowed and would also be defensible, but a
|
|
64
|
+
* `kbd` wrapper is a second box for a host stylesheet to reach into for no gain
|
|
65
|
+
* — the semantics are carried by the keys themselves either way.
|
|
66
|
+
*/
|
|
67
|
+
export declare const MPShortcut: React.ForwardRefExoticComponent<MPShortcutProps & React.RefAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as a}from"react/jsx-runtime";import*as t from"react";import{accentSlots as o}from"../../internal/accent";import{VISUALLY_HIDDEN as r}from"../../internal/visually-hidden";const m=e=>({symbol:e,name:e}),l={mod:{mac:{symbol:"⌘",name:"Command"},windows:m("Ctrl"),linux:m("Ctrl")},meta:{mac:{symbol:"⌘",name:"Command"},windows:m("Win"),linux:m("Super")},ctrl:{mac:{symbol:"⌃",name:"Control"},windows:m("Ctrl"),linux:m("Ctrl")},alt:{mac:{symbol:"⌥",name:"Option"},windows:m("Alt"),linux:m("Alt")},shift:{mac:{symbol:"⇧",name:"Shift"},windows:m("Shift"),linux:m("Shift")},enter:{mac:{symbol:"↩",name:"Enter"},windows:m("Enter"),linux:m("Enter")},tab:{mac:{symbol:"⇥",name:"Tab"},windows:m("Tab"),linux:m("Tab")},escape:{mac:{symbol:"⎋",name:"Escape"},windows:m("Esc"),linux:m("Esc")},backspace:{mac:{symbol:"⌫",name:"Backspace"},windows:m("Backspace"),linux:m("Backspace")},delete:{mac:{symbol:"⌦",name:"Delete"},windows:m("Del"),linux:m("Del")},capslock:{mac:{symbol:"⇪",name:"Caps Lock"},windows:m("Caps Lock"),linux:m("Caps Lock")}},s={cmdorctrl:"mod",commandorcontrol:"mod",cmd:"meta",command:"meta",super:"meta",win:"meta",windows:"meta",control:"ctrl",option:"alt",opt:"alt",return:"enter",esc:"escape",del:"delete",caps:"capslock"},i={up:{symbol:"↑",name:"Arrow up"},down:{symbol:"↓",name:"Arrow down"},left:{symbol:"←",name:"Arrow left"},right:{symbol:"→",name:"Arrow right"},arrowup:{symbol:"↑",name:"Arrow up"},arrowdown:{symbol:"↓",name:"Arrow down"},arrowleft:{symbol:"←",name:"Arrow left"},arrowright:{symbol:"→",name:"Arrow right"}};function c(){if("undefined"==typeof navigator)return"windows";const e=navigator.userAgentData,n=`${e?.platform??""} ${navigator.platform??""} ${navigator.userAgent??""}`;return/mac|iphone|ipad|ipod/i.test(n)?"mac":/win/i.test(n)?"windows":"linux"}function d(){return()=>{}}function p(){return"windows"}const u={xs:"h-5",sm:"h-6",md:"h-8",lg:"h-10",xl:"h-12"},w={xs:"min-w-5",sm:"min-w-6",md:"min-w-8",lg:"min-w-10",xl:"min-w-12"},x={xs:"text-mp-label-small",sm:"text-mp-label-medium",md:"text-mp-label-large",lg:"text-mp-label-large",xl:"text-mp-title-medium"},f={xs:"px-1",sm:"px-1.5",md:"px-2",lg:"px-2.5",xl:"px-3"},b={xs:"rounded-mp-xs",sm:"rounded-mp-xs",md:"rounded-mp-sm",lg:"rounded-mp-sm",xl:"rounded-mp-md"},y={filled:"bg-(--_mp-accent) text-(--_mp-on-accent)",tonal:"bg-(--_mp-accent-container) text-(--_mp-on-accent-container)",elevated:"shadow-mp-1 bg-mp-surface-container-low text-mp-on-surface-variant",outlined:"border-mp-outline-variant text-mp-on-surface-variant border bg-transparent",text:"text-mp-on-surface-variant bg-mp-surface-container"};export const MPShortcut=t.forwardRef(function({variant:h="outlined",size:g="md",color:v="secondary",keys:A,os:k="auto",separator:C,className:E,style:S,...j},B){const N=t.useSyncExternalStore(d,c,p),_="auto"===k?N:k,D=function(e){return Array.isArray(e)?e.map(e=>e.trim()).filter(Boolean):e.split("+").map(e=>e.trim()).filter(Boolean)}(A),L=D.map(e=>function(e,n){const a=e.toLowerCase().replace(/[\s_-]/g,""),t=s[a]??a,o=i[t];if(o)return o;const r=l[t];return r?r[n]:m(1===e.length?e.toUpperCase():e)}(e,_)),T=void 0===C?"mac"===_?null:"+":C,$=["inline-flex shrink-0 items-center justify-center","font-mono leading-none whitespace-nowrap tabular-nums",u[g],w[g],x[g],f[g],b[g],y[h]].join(" ");return e("span",{ref:B,"data-mp-size":g,"data-mp-variant":h,className:["mp-shortcut inline-flex max-w-full items-center gap-1 align-middle",E??""].filter(Boolean).join(" "),style:{...o(v),...S},...j,children:L.map((o,m)=>a(t.Fragment,{children:[m>0&&null!==T?e("span",{"aria-hidden":"true",className:"text-mp-on-surface-variant",children:T}):null,e("kbd",{className:$,children:o.symbol===o.name?o.symbol:a(n,{children:[e("span",{"aria-hidden":"true",children:o.symbol}),e("span",{className:r,children:o.name})]})})]},m))})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPShortcut}from"./MPShortcut";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import type { MPColor, MPSize } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* What the placeholder is standing in for.
|
|
6
|
+
*
|
|
7
|
+
* - `line` — a run of text. Sized off the type scale, so a `md` line is exactly
|
|
8
|
+
* as tall as the `md` type it will be replaced by.
|
|
9
|
+
* - `rect` — a block: an image, a chart, a card, a map.
|
|
10
|
+
* - `circle` — an avatar, or anything else round.
|
|
11
|
+
*/
|
|
12
|
+
export type MPSkeletonShape = 'line' | 'rect' | 'circle';
|
|
13
|
+
export interface MPSkeletonProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> {
|
|
14
|
+
/** @default 'line' */
|
|
15
|
+
shape?: MPSkeletonShape;
|
|
16
|
+
/**
|
|
17
|
+
* How many lines to draw, for `shape="line"`. The last one is drawn short, the
|
|
18
|
+
* way the last line of a paragraph is, so a block of them reads as prose
|
|
19
|
+
* rather than as a barcode. Ignored by the other two shapes.
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
lines?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The scale of the thing being stood in for: the type scale for a `line`, the
|
|
25
|
+
* diameter for a `circle`, the default block height for a `rect`.
|
|
26
|
+
* @default 'md'
|
|
27
|
+
*/
|
|
28
|
+
size?: MPSize;
|
|
29
|
+
/**
|
|
30
|
+
* Which accent family tints the placeholder.
|
|
31
|
+
*
|
|
32
|
+
* Like `MPDivider` this has **no default**, and for a related reason: a
|
|
33
|
+
* placeholder is not a thing yet, so it has no meaning to carry. Left unset it
|
|
34
|
+
* is `surface-container-highest` — MD3's role for a container with nothing in
|
|
35
|
+
* it, which is precisely what this is. Setting it swaps in the family's
|
|
36
|
+
* container tone, for the rare page where the wait itself is branded.
|
|
37
|
+
*/
|
|
38
|
+
color?: MPColor;
|
|
39
|
+
/** An explicit width. Numbers are pixels. */
|
|
40
|
+
width?: number | string;
|
|
41
|
+
/** An explicit height. Numbers are pixels. */
|
|
42
|
+
height?: number | string;
|
|
43
|
+
/**
|
|
44
|
+
* The pulse. Turn it off for a page holding dozens of them, or where the wait
|
|
45
|
+
* is expected to be long enough that motion becomes noise.
|
|
46
|
+
*
|
|
47
|
+
* This is not the accessibility switch — a reduced-motion preference stops the
|
|
48
|
+
* animation without being asked, below.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
animated?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* What a screen reader is told, if anything.
|
|
54
|
+
*
|
|
55
|
+
* Unset — the default — the placeholder is `aria-hidden`, because a dozen
|
|
56
|
+
* boxes each announcing themselves is worse than silence. Give the *one*
|
|
57
|
+
* skeleton that stands for the whole region a label and it becomes a live
|
|
58
|
+
* `status` instead.
|
|
59
|
+
*/
|
|
60
|
+
label?: string;
|
|
61
|
+
/** Renders something other than a `<div>`. Base UI's own escape hatch. */
|
|
62
|
+
render?: useRender.RenderProp;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The shape of something that has not loaded yet.
|
|
66
|
+
*
|
|
67
|
+
* It reserves the space the real thing will take, which is the whole job: a card
|
|
68
|
+
* that grows by 200px when its image arrives has moved everything below it while
|
|
69
|
+
* somebody was reading it. A spinner cannot do that.
|
|
70
|
+
*
|
|
71
|
+
* The three shapes are the three things a layout is made of — a run of text, a
|
|
72
|
+
* block and a circle — and each is sized off the ladder the real component uses,
|
|
73
|
+
* so a `md` line is as tall as `md` type and a `md` circle is exactly an
|
|
74
|
+
* `MPAvatar` at `md`.
|
|
75
|
+
*/
|
|
76
|
+
export declare const MPSkeleton: React.ForwardRefExoticComponent<MPSkeletonProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import*as r from"react";import{useRender as l}from"@base-ui/react/use-render";import{CONTROL_SQUARE as o}from"../../internal/scale";const a={xs:"h-3",sm:"h-3.5",md:"h-4",lg:"h-4",xl:"h-5.5"},n={xs:"gap-1",sm:"gap-1.5",md:"gap-2",lg:"gap-2",xl:"gap-1.5"},i={xs:"h-12",sm:"h-16",md:"h-20",lg:"h-28",xl:"h-36"},t="overflow-hidden bg-(--_mp-placeholder)";function s(e){if(void 0!==e)return"number"==typeof e?`${e}px`:e}export const MPSkeleton=r.forwardRef(function({shape:r="line",lines:m=1,size:d="md",color:p,width:c,height:h,animated:f=!0,label:u,render:x,className:g,style:w,...v},b){const y=f?"animate-pulse motion-reduce:animate-none":"",$="circle"===r?`rounded-mp-full shrink-0 ${o[d]}`:"rect"===r?`rounded-mp-md w-full ${void 0===h?i[d]:""}`:`rounded-mp-xs w-full ${a[d]}`,j=u?{role:"status","aria-busy":!0,"aria-label":u}:{"aria-hidden":!0},k="line"===r&&m>1;return l({render:x,ref:b,props:{"data-mp-size":d,className:(k?["mp-skeleton flex w-full flex-col",n[d],g??""]:["mp-skeleton",t,y,$,g??""]).filter(Boolean).join(" "),style:{"--_mp-placeholder":p?`var(--_mp-color-${p}-container)`:"var(--_mp-color-surface-container-highest)",width:s(c),height:k?void 0:s(h),...w},...j,...k?{children:Array.from({length:m},(r,l)=>e("div",{className:[t,y,"rounded-mp-xs",a[d],l===m-1?"w-3/5":"w-full"].filter(Boolean).join(" ")},l))}:null,...v}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSkeleton}from"./MPSkeleton";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPOrientation, MPSize } from '../../types';
|
|
3
|
+
export interface MPSliderProps {
|
|
4
|
+
/**
|
|
5
|
+
* The value, or the values. An array is what makes it a range slider — there is
|
|
6
|
+
* no separate `range` prop, because the shape of the value already says which
|
|
7
|
+
* one this is.
|
|
8
|
+
*/
|
|
9
|
+
value?: number | readonly number[];
|
|
10
|
+
/** The starting value, for an uncontrolled slider. */
|
|
11
|
+
defaultValue?: number | readonly number[];
|
|
12
|
+
/** Called on every move, with the same shape `value` takes. */
|
|
13
|
+
onValueChange?: (value: number | number[]) => void;
|
|
14
|
+
/** Called once the drag ends, which is where an expensive update belongs. */
|
|
15
|
+
onValueCommitted?: (value: number | number[]) => void;
|
|
16
|
+
/** The bottom of the range. @default 0 */
|
|
17
|
+
min?: number;
|
|
18
|
+
/** The top of the range. @default 100 */
|
|
19
|
+
max?: number;
|
|
20
|
+
/** How far one arrow key, or one notch of the drag, moves. @default 1 */
|
|
21
|
+
step?: number;
|
|
22
|
+
/** The label above the track. */
|
|
23
|
+
label?: React.ReactNode;
|
|
24
|
+
/** The line under the track. */
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Shows the current value beside the label. A slider with no readout is a
|
|
28
|
+
* control whose value can only be estimated, which is fine for a volume dial
|
|
29
|
+
* and wrong for anything with units.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
showValue?: boolean;
|
|
33
|
+
/** How the readout is written. Passed to `Intl.NumberFormat`. */
|
|
34
|
+
format?: Intl.NumberFormatOptions;
|
|
35
|
+
/**
|
|
36
|
+
* Which way the slider runs. A vertical slider has no length of its own, so
|
|
37
|
+
* give it a height — the default is a starting point, not a rule.
|
|
38
|
+
* @default 'horizontal'
|
|
39
|
+
*/
|
|
40
|
+
orientation?: MPOrientation;
|
|
41
|
+
/**
|
|
42
|
+
* The rail's thickness and the handle's size.
|
|
43
|
+
* @default 'md'
|
|
44
|
+
*/
|
|
45
|
+
size?: MPSize;
|
|
46
|
+
/**
|
|
47
|
+
* Which accent family the active track and handle take.
|
|
48
|
+
* @default 'primary'
|
|
49
|
+
*/
|
|
50
|
+
color?: MPColor;
|
|
51
|
+
/** Greys the slider out and stops it taking input. */
|
|
52
|
+
disabled?: boolean;
|
|
53
|
+
/** Name of the form control. */
|
|
54
|
+
name?: string;
|
|
55
|
+
/** The accessible name, for a slider with no visible `label`. */
|
|
56
|
+
'aria-label'?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A Material Design slider.
|
|
60
|
+
*
|
|
61
|
+
* The active part of the track is the accent family and the rest is
|
|
62
|
+
* `surface-container-highest`, which is MD3's own pairing and the reason the
|
|
63
|
+
* inactive half reads as a groove rather than as a second value.
|
|
64
|
+
*
|
|
65
|
+
* Base UI owns everything that makes a slider hard: the pointer maths, the
|
|
66
|
+
* keyboard steps, `aria-valuenow` and friends, the thumbs of a range slider
|
|
67
|
+
* refusing to cross, and the hidden input that submits with a form.
|
|
68
|
+
*
|
|
69
|
+
* ## The handle is a circle, not a bar
|
|
70
|
+
*
|
|
71
|
+
* Material's 2025 revision draws the handle as a tall thin bar with a gap either
|
|
72
|
+
* side of it. This is the earlier one, deliberately: the gap has to be punched
|
|
73
|
+
* out of the track with a colour that matches whatever the slider is sitting on,
|
|
74
|
+
* and a component library does not know what that is. A handle that assumes the
|
|
75
|
+
* page is `surface` leaves a pale notch in the track on every screen that is not.
|
|
76
|
+
*/
|
|
77
|
+
export declare const MPSlider: React.ForwardRefExoticComponent<MPSliderProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import*as r from"react";import{Slider as a}from"@base-ui/react/slider";import{accentSlots as l}from"../../internal/accent";import{MPStateLayer as t}from"../../internal/StateLayer";import{META_TEXT as n,hasContent as i}from"../../internal/scale";const o={xs:{thickness:"h-0.5",cross:"w-0.5",handle:"size-3.5",strip:"h-8",stripCross:"w-8"},sm:{thickness:"h-[3px]",cross:"w-[3px]",handle:"size-4",strip:"h-9",stripCross:"w-9"},md:{thickness:"h-1",cross:"w-1",handle:"size-5",strip:"h-10",stripCross:"w-10"},lg:{thickness:"h-1.5",cross:"w-1.5",handle:"size-6",strip:"h-11",stripCross:"w-11"},xl:{thickness:"h-2",cross:"w-2",handle:"size-7",strip:"h-12",stripCross:"w-12"}},c={xs:"size-8",sm:"size-9",md:"size-10",lg:"size-11",xl:"size-12"};export const MPSlider=r.forwardRef(function({value:r,defaultValue:m,onValueChange:u,onValueCommitted:p,min:d=0,max:f=100,step:h=1,label:x,description:g,showValue:b=!1,format:w,orientation:j="horizontal",size:z="md",color:v="primary",disabled:C=!1,name:y,"aria-label":N},_){const k="vertical"===j,V=o[z],$=r??m,A=Array.isArray($)?$.length:1;return s(a.Root,{ref:_,value:r,defaultValue:m,onValueChange:e=>u?.(e),onValueCommitted:e=>p?.(e),min:d,max:f,step:h,disabled:C,orientation:j,format:w,name:y,"data-mp-size":z,className:["mp-slider flex",k?"w-fit flex-col items-center gap-2":"w-full flex-col gap-1",C?"cursor-default":""].filter(Boolean).join(" "),style:l(v),children:[i(x)||b?s("div",{className:["flex w-full items-baseline gap-2",n].join(" "),children:[i(x)?e(a.Label,{className:C?"text-mp-on-surface/38":"text-mp-on-surface-variant",children:x}):null,b?e(a.Value,{className:["ms-auto tabular-nums",C?"text-mp-on-surface/38":"text-mp-on-surface"].join(" ")}):null]}):null,e(a.Control,{className:["mp-slider__control flex touch-none items-center justify-center select-none",k?`${V.stripCross} h-40 flex-col`:`w-full ${V.strip}`,C?"":"cursor-pointer"].filter(Boolean).join(" "),children:s(a.Track,{className:["mp-slider__track rounded-mp-full relative",k?`${V.cross} h-full`:`${V.thickness} w-full`,C?"bg-mp-on-surface/12":"bg-mp-surface-container-highest"].join(" "),children:[e(a.Indicator,{className:["rounded-mp-full",C?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")}),Array.from({length:A},(s,r)=>e(a.Thumb,{index:r,"aria-label":i(x)?void 0:N,className:["mp-slider__handle group rounded-mp-full relative outline-none",V.handle,C?"bg-mp-on-surface/38 cursor-default":"bg-(--_mp-accent) cursor-grab active:cursor-grabbing"].join(" "),children:C?null:e(t,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",c[z],"bg-(--_mp-accent)"].join(" "),className:"group-data-dragging:opacity-16"})},r))]})}),i(g)?e("div",{className:[n,C?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:g}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSlider}from"./MPSlider";
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPAlign, MPColor, MPSize } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Where the stack sits.
|
|
5
|
+
*
|
|
6
|
+
* Written as two words rather than as a `side` plus an `align`, because they are
|
|
7
|
+
* not independent: a snackbar stack is always pinned to the top or the bottom,
|
|
8
|
+
* never to a side, and offering `left`/`right` as a "side" would invite a column
|
|
9
|
+
* down the middle of the screen that no layout survives. The second half is
|
|
10
|
+
* `MPAlign`, the same word every other component uses.
|
|
11
|
+
*/
|
|
12
|
+
export type MPSnackbarPosition = `top-${MPAlign}` | `bottom-${MPAlign}`;
|
|
13
|
+
/**
|
|
14
|
+
* The per-snackbar overrides, carried in Base UI's own `data` slot.
|
|
15
|
+
*
|
|
16
|
+
* `data` is the field Base UI reserves for exactly this. Shadowing the manager's
|
|
17
|
+
* own option names instead is how a library ends up with two `type` props that
|
|
18
|
+
* mean different things.
|
|
19
|
+
*/
|
|
20
|
+
export interface MPSnackbarData {
|
|
21
|
+
color?: MPColor;
|
|
22
|
+
icon?: React.ReactNode | false;
|
|
23
|
+
}
|
|
24
|
+
export interface MPSnackbarOptions extends MPSnackbarData {
|
|
25
|
+
/**
|
|
26
|
+
* Reusing an id updates that snackbar in place and restarts its timer, which
|
|
27
|
+
* is what "uploading… / uploaded" wants: one message that changed its mind,
|
|
28
|
+
* not two stacked on each other.
|
|
29
|
+
*/
|
|
30
|
+
id?: string;
|
|
31
|
+
/**
|
|
32
|
+
* What it says.
|
|
33
|
+
*
|
|
34
|
+
* One slot, not a title and a body — MD3's snackbar has a single run of
|
|
35
|
+
* supporting text, up to two lines, and nothing else. A message that needs a
|
|
36
|
+
* heading is not a snackbar; it is a dialog the reader has not been shown yet.
|
|
37
|
+
*/
|
|
38
|
+
message?: React.ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* How long before it dismisses itself, in milliseconds. `0` keeps it up until
|
|
41
|
+
* it is closed — which is the right answer for anything the reader has to act
|
|
42
|
+
* on, because a snackbar that leaves before it is read said nothing.
|
|
43
|
+
*/
|
|
44
|
+
timeout?: number;
|
|
45
|
+
/**
|
|
46
|
+
* `high` interrupts a screen reader; `low` waits for a pause. An error is worth
|
|
47
|
+
* interrupting for and a save confirmation is not.
|
|
48
|
+
* @default 'low'
|
|
49
|
+
*/
|
|
50
|
+
priority?: 'low' | 'high';
|
|
51
|
+
/** The label of the action. Passing it is what makes the action appear. */
|
|
52
|
+
actionLabel?: React.ReactNode;
|
|
53
|
+
onAction?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
54
|
+
/** Called when it closes, however it closed. */
|
|
55
|
+
onClose?: () => void;
|
|
56
|
+
/** Called once it has finished animating out and left the DOM. */
|
|
57
|
+
onRemove?: () => void;
|
|
58
|
+
}
|
|
59
|
+
export interface MPSnackbarProviderProps {
|
|
60
|
+
/**
|
|
61
|
+
* Which family every snackbar's plate is painted in.
|
|
62
|
+
*
|
|
63
|
+
* **No default**, and it is the same decision `MPTooltip` makes for the same
|
|
64
|
+
* reason. MD3's snackbar is `inverse-surface` under `inverse-on-surface`: the
|
|
65
|
+
* neutral palette read at the *other* end of the scheme, so the plate is dark
|
|
66
|
+
* on a light page and light on a dark one. That is what makes it legible over
|
|
67
|
+
* whatever the reader happened to be looking at, which is the only content a
|
|
68
|
+
* snackbar ever appears over.
|
|
69
|
+
*
|
|
70
|
+
* Setting it swaps in an accent container. Worth doing for an application whose
|
|
71
|
+
* messages are all one kind; wrong as a way of saying "this one is an error",
|
|
72
|
+
* because a snackbar is not where an error belongs.
|
|
73
|
+
*/
|
|
74
|
+
color?: MPColor;
|
|
75
|
+
/**
|
|
76
|
+
* Where the stack is pinned.
|
|
77
|
+
*
|
|
78
|
+
* `bottom-start` is MD3's own placement — the snackbar sits above the reading
|
|
79
|
+
* flow's end corner, out of the way of everything except a floating action
|
|
80
|
+
* button, which is the one thing the specification asks it to move.
|
|
81
|
+
* @default 'bottom-start'
|
|
82
|
+
*/
|
|
83
|
+
position?: MPSnackbarPosition;
|
|
84
|
+
/**
|
|
85
|
+
* How long a snackbar lasts by default, in milliseconds. `0` keeps every one of
|
|
86
|
+
* them up until it is closed.
|
|
87
|
+
* @default 5000
|
|
88
|
+
*/
|
|
89
|
+
timeout?: number;
|
|
90
|
+
/**
|
|
91
|
+
* How many are shown at once. The rest are kept and revealed as the stack
|
|
92
|
+
* drains rather than being thrown away.
|
|
93
|
+
* @default 3
|
|
94
|
+
*/
|
|
95
|
+
limit?: number;
|
|
96
|
+
/**
|
|
97
|
+
* How wide a snackbar may get. Numbers are pixels. MD3's own maximum is 600dp
|
|
98
|
+
* and its minimum is 344dp, which is what the two ends of the plate are set to.
|
|
99
|
+
* @default 600
|
|
100
|
+
*/
|
|
101
|
+
width?: number | string;
|
|
102
|
+
/**
|
|
103
|
+
* The type scale the plate is drawn at.
|
|
104
|
+
* @default 'md'
|
|
105
|
+
*/
|
|
106
|
+
size?: MPSize;
|
|
107
|
+
/**
|
|
108
|
+
* Shows the × on every snackbar.
|
|
109
|
+
*
|
|
110
|
+
* On by default. MD3 treats the close affordance as optional, but a snackbar
|
|
111
|
+
* with `timeout: 0` and no action would otherwise have no way out at all —
|
|
112
|
+
* and the stack is what decides that, not the call site.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
showClose?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Accessible name of every snackbar's × button. Defaults to the word for
|
|
118
|
+
* "close" in `locale`.
|
|
119
|
+
*/
|
|
120
|
+
closeLabel?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Which language the × button's default name is written in. Falls back to the
|
|
123
|
+
* nearest `MPLocaleProvider`, then to English.
|
|
124
|
+
*/
|
|
125
|
+
locale?: string;
|
|
126
|
+
children?: React.ReactNode;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Raises snackbars from anywhere under an `MPSnackbarProvider`.
|
|
130
|
+
*
|
|
131
|
+
* A hook rather than a component, because what a caller has at the moment a
|
|
132
|
+
* message is warranted is a click handler, not a place in the tree — and an
|
|
133
|
+
* `<MPSnackbar open={…}/>` they would have to keep mounted, with a piece of state
|
|
134
|
+
* per message, is the shape this component exists to avoid.
|
|
135
|
+
*/
|
|
136
|
+
export declare function useMPSnackbar(): {
|
|
137
|
+
/** Raises a snackbar and returns its id. */
|
|
138
|
+
add: (options: MPSnackbarOptions) => string;
|
|
139
|
+
/** Closes one snackbar, or every one of them when called with nothing. */
|
|
140
|
+
close: (id?: string) => void;
|
|
141
|
+
/** Changes a snackbar already on screen. */
|
|
142
|
+
update: (id: string, options: MPSnackbarOptions) => void;
|
|
143
|
+
/**
|
|
144
|
+
* One snackbar that follows a promise: the waiting message while it runs,
|
|
145
|
+
* then the success or the failure. Base UI applies `timeout: 0` to the
|
|
146
|
+
* waiting state, so a slow request cannot dismiss its own message.
|
|
147
|
+
*/
|
|
148
|
+
promise: <Value>(promise: Promise<Value>, options: {
|
|
149
|
+
loading: MPSnackbarOptions;
|
|
150
|
+
success: MPSnackbarOptions | ((value: Value) => MPSnackbarOptions);
|
|
151
|
+
error: MPSnackbarOptions | ((error: unknown) => MPSnackbarOptions);
|
|
152
|
+
}) => Promise<Value>;
|
|
153
|
+
/** Every snackbar currently in the stack, newest first. */
|
|
154
|
+
snackbars: import("@base-ui/react").ToastObject<MPSnackbarData>[];
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Puts the snackbar stack on the page and lets anything under it raise a message.
|
|
158
|
+
*
|
|
159
|
+
* Wrap the application once. Everything about how a snackbar *looks* is decided
|
|
160
|
+
* here — where the stack sits, how wide it is, how long it lasts — so the call
|
|
161
|
+
* site stays the one thing it should be: what happened.
|
|
162
|
+
*
|
|
163
|
+
* Base UI owns the parts that are genuinely hard and invisible when they work:
|
|
164
|
+
* the timers and their pausing on hover and on window blur, the limit, the swipe,
|
|
165
|
+
* the F6 focus hotkey, and the live region that makes a message which appeared
|
|
166
|
+
* out of nowhere reach a screen reader at all.
|
|
167
|
+
*
|
|
168
|
+
* ## Why this is not called Toast
|
|
169
|
+
*
|
|
170
|
+
* Material has a name for this component and it is snackbar. "Toast" is Android's
|
|
171
|
+
* older, non-interactive notification — it has no action, cannot be dismissed and
|
|
172
|
+
* is not part of Material Design 3 — so a `Toast` here would be a different
|
|
173
|
+
* component wearing the name of one the specification still ships.
|
|
174
|
+
*/
|
|
175
|
+
export declare function MPSnackbarProvider({ color, position, timeout, limit, width, size, showClose, closeLabel, locale: localeProp, children }: MPSnackbarProviderProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import*as t from"react";import{Toast as i}from"@base-ui/react/toast";import{MPIcon as s}from"../icon/MPIcon";import{CloseIcon as n}from"../../constants/icons";import{accentSlots as r}from"../../internal/accent";import{useMPLocale as l,useMPMessages as a}from"../../internal/locale";import{MPStateLayer as c}from"../../internal/StateLayer";import{FADE as m,PORTAL_LAYER as p}from"../../internal/surface";const u={"top-start":"top-0 items-start","top-center":"top-0 items-center","top-end":"top-0 items-end","bottom-start":"bottom-0 flex-col-reverse items-start","bottom-center":"bottom-0 flex-col-reverse items-center","bottom-end":"bottom-0 flex-col-reverse items-end"},d={xs:"text-mp-body-small",sm:"text-mp-body-small",md:"text-mp-body-medium",lg:"text-mp-body-medium",xl:"text-mp-body-large"},f={xs:"min-h-9 gap-1.5 py-1.5 ps-3 pe-1.5",sm:"min-h-10 gap-2 py-2 ps-3.5 pe-2",md:"min-h-12 gap-2 py-2.5 ps-4 pe-2",lg:"min-h-14 gap-3 py-3 ps-5 pe-2.5",xl:"min-h-16 gap-3 py-3.5 pe-3 ps-6"},x={xs:16,sm:18,md:20,lg:22,xl:24};function b(e){const{color:o,icon:t,message:i,actionLabel:s,onAction:n,...r}=e;return{...r,title:i,data:{color:o,icon:t},actionProps:void 0===s?void 0:{children:s,onClick:n}}}export function useMPSnackbar(){const e=i.useToastManager();return t.useMemo(()=>({add:o=>e.add(b(o)),close:o=>e.close(o),update:(o,t)=>e.update(o,b(t)),promise:(o,t)=>e.promise(o,{loading:b(t.loading),success:e=>b("function"==typeof t.success?t.success(e):t.success),error:e=>b("function"==typeof t.error?t.error(e):t.error)}),snackbars:e.toasts}),[e])}function h({toast:t,color:l,size:a,showClose:p,closeLabel:u,swipeDirection:b}){const h=t.data?.color??l,v=t.data?.icon,y={"--_mp-plate":h?`var(--_mp-color-${h}-container)`:"var(--_mp-color-inverse-surface)","--_mp-on-plate":h?`var(--_mp-color-on-${h}-container)`:"var(--_mp-color-inverse-on-surface)","--_mp-plate-action":h?`var(--_mp-color-${h})`:"var(--_mp-color-inverse-primary)",...h?r(h):null};return o(i.Root,{toast:t,swipeDirection:b,"data-mp-size":a,className:["mp-snackbar rounded-mp-xs shadow-mp-3 pointer-events-auto flex w-full items-center","bg-(--_mp-plate) text-(--_mp-on-plate) outline-none",f[a],d[a],m,"data-limited:hidden"].join(" "),style:y,children:[v?e("span",{className:"flex shrink-0 items-center",children:v}):null,e(i.Title,{render:e("span",{}),className:"min-w-0 flex-1 py-0.5 ps-1 [min-inline-size:min(280px,100%)]"}),e(i.Action,{className:["text-mp-label-large flex shrink-0 cursor-pointer items-center","rounded-mp-full h-8 px-3 text-(--_mp-plate-action)","transition-colors duration-(--mp-sys-motion-duration-short4)","hover:bg-(--_mp-plate-action)/8 focus-visible:bg-(--_mp-plate-action)/10","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" ")}),p?o(i.Close,{"aria-label":u,className:["group rounded-mp-full relative flex size-8 shrink-0 cursor-pointer","items-center justify-center text-(--_mp-on-plate)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(c,{}),e(s,{icon:n,size:x[a]})]}):null]})}function v({position:o,width:t,...s}){const{toasts:n}=i.useToastManager(),r=[o.startsWith("top")?"up":"down","left","right"];return e(i.Portal,{children:e(i.Viewport,{className:[p,"pointer-events-none fixed inset-x-0 flex flex-col gap-2 p-4",u[o]].join(" "),children:n.map(o=>e("div",{className:"w-full",style:{maxWidth:"number"==typeof t?`${t}px`:t},children:e(h,{toast:o,swipeDirection:r,...s})},o.id))})})}export function MPSnackbarProvider({color:t,position:s="bottom-start",timeout:n=5e3,limit:r=3,width:c=600,size:m="md",showClose:p=!0,closeLabel:u,locale:d,children:f}){const x=l(d),b=a("common",x);return o(i.Provider,{timeout:n,limit:r,children:[f,e(v,{position:s,width:c,color:t,size:m,showClose:p,closeLabel:u??b.close})]})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSnackbarProvider,useMPSnackbar}from"./MPSnackbar";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPSize, MPVariant } from '../../types';
|
|
3
|
+
export interface MPSpoilerProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'color' | 'onChange'> {
|
|
4
|
+
/** Whether the content is uncovered. Use with `onRevealedChange` to control it. */
|
|
5
|
+
revealed?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Where an uncontrolled spoiler starts.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
defaultRevealed?: boolean;
|
|
11
|
+
/** Called when the reveal or hide button is pressed. */
|
|
12
|
+
onRevealedChange?: (revealed: boolean) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Which language the cover is written in. Falls back to the nearest
|
|
15
|
+
* `MPLocaleProvider`, then to English.
|
|
16
|
+
*
|
|
17
|
+
* Both strings can be written out instead, in `label` and `description`; this
|
|
18
|
+
* is for the far more common case where the page already knows its language
|
|
19
|
+
* and nobody should have to translate a button that says "Reveal".
|
|
20
|
+
*/
|
|
21
|
+
locale?: string;
|
|
22
|
+
/** The reveal button's label. Defaults to the `locale`'s word for it. */
|
|
23
|
+
label?: React.ReactNode;
|
|
24
|
+
/** The hide button's label, when `reversible` is on. */
|
|
25
|
+
hideLabel?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* The line above the button, saying why the content is covered. Defaults to
|
|
28
|
+
* the `locale`'s wording; pass `false` for a cover with nothing written on it.
|
|
29
|
+
*/
|
|
30
|
+
description?: React.ReactNode | false;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces the default reveal button entirely.
|
|
33
|
+
*
|
|
34
|
+
* The replacement is yours to wire up: pass `revealed` and `onRevealedChange`
|
|
35
|
+
* and drive it from your own control. `label` is the prop for the far commoner
|
|
36
|
+
* case of wanting different words on the button that is already there.
|
|
37
|
+
*/
|
|
38
|
+
action?: React.ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Keeps the content coverable: once revealed, a hide button appears under it.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
reversible?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Clamps the covered box to this height — a CSS length, or a number in pixels.
|
|
46
|
+
* Revealing releases it and the content takes whatever height it needs.
|
|
47
|
+
*
|
|
48
|
+
* Left out, the box is exactly as tall as what it holds, which is right for a
|
|
49
|
+
* paragraph or a picture. Set it for something long enough that a page of
|
|
50
|
+
* blurred content would be a page of nothing.
|
|
51
|
+
*/
|
|
52
|
+
maxHeight?: number | string;
|
|
53
|
+
/**
|
|
54
|
+
* How hard the content is blurred, in pixels.
|
|
55
|
+
* @default 10
|
|
56
|
+
*/
|
|
57
|
+
blur?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Inner padding around the content. Turn it off for something that should
|
|
60
|
+
* reach the edges — a picture, a video.
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
padded?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* How much surface the sheet paints. `text` draws no box at all, which is what
|
|
66
|
+
* a spoiler sitting inside running prose usually wants.
|
|
67
|
+
* @default 'outlined'
|
|
68
|
+
*/
|
|
69
|
+
variant?: MPVariant;
|
|
70
|
+
/**
|
|
71
|
+
* The room inside, and the size of the button on the cover.
|
|
72
|
+
* @default 'md'
|
|
73
|
+
*/
|
|
74
|
+
size?: MPSize;
|
|
75
|
+
/**
|
|
76
|
+
* Which accent family the reveal button reads. The sheet stays neutral, as
|
|
77
|
+
* every container in this library does.
|
|
78
|
+
* @default 'primary'
|
|
79
|
+
*/
|
|
80
|
+
color?: MPColor;
|
|
81
|
+
/** What is being covered. */
|
|
82
|
+
children?: React.ReactNode;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Content that is covered until somebody asks for it.
|
|
86
|
+
*
|
|
87
|
+
* MD3 does not describe this, and it is the library's own for the reason
|
|
88
|
+
* [MPProgressBox](../feedback/progress-box) is: a real thing, drawn out of the
|
|
89
|
+
* specification's own parts. There is no primitive under it either, and there
|
|
90
|
+
* should not be — a spoiler has no keyboard contract of its own beyond the
|
|
91
|
+
* button on its cover, which is a real [MPButton](../inputs/button).
|
|
92
|
+
*
|
|
93
|
+
* The cover is a **blur** rather than a `display: none`, which is the whole
|
|
94
|
+
* point: a reader can see that there is something there, roughly how much of it
|
|
95
|
+
* there is, and — with `maxHeight` — that it has been clamped. What they cannot
|
|
96
|
+
* do is read it by accident, which is the one thing a spoiler is for.
|
|
97
|
+
*
|
|
98
|
+
* ## What `inert` buys, and why `aria-hidden` would not
|
|
99
|
+
*
|
|
100
|
+
* While it is covered the content is `inert`, so it is not tabbable, not
|
|
101
|
+
* readable by a screen reader, and not selectable by a drag across the page. All
|
|
102
|
+
* three matter: a spoiler that can be defeated by Ctrl-A is not a spoiler, and
|
|
103
|
+
* `aria-hidden` alone would leave a keyboard reader tabbing into a link their
|
|
104
|
+
* screen reader has been told is not there.
|
|
105
|
+
*/
|
|
106
|
+
export declare const MPSpoiler: React.ForwardRefExoticComponent<MPSpoilerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import*as a from"react";import{MPButton as o}from"../button/MPButton";import{inertProps as i}from"../../internal/inert";import{useMPLocale as n,useMPMessages as t}from"../../internal/locale";import{hasContent as l,META_TEXT as d,SHEET_PAD as s,SHEET_PAD_X as c,SHEET_PAD_Y as m}from"../../internal/scale";import{CONTAINER_SURFACE as p}from"../../internal/surface";const f="[background-color:color-mix(in_oklab,var(--_mp-color-surface)_55%,transparent)]";export const MPSpoiler=a.forwardRef(function({revealed:u,defaultRevealed:v=!1,onRevealedChange:x,locale:h,label:b,hideLabel:j,description:N,action:g,reversible:y=!1,maxHeight:z,blur:k=10,padded:w=!0,variant:B="outlined",size:C="md",color:R="primary",className:_,children:H,...M},P){const S=n(h),$=t("spoiler",S),I=a.useId(),[L,q]=a.useState(v),A=u??L,D=e=>{void 0===u&&q(e),x?.(e)},E=!1===N?null:N??$.notice;return r("div",{ref:P,"data-mp-size":C,"data-mp-variant":B,"data-mp-revealed":A||void 0,className:["mp-spoiler rounded-mp-md relative isolate overflow-hidden","box-border",p[B],"text-mp-on-surface",_??""].filter(Boolean).join(" "),...M,children:[e("div",{id:I,className:["min-w-0",w?s[C]:"","transition-[filter] duration-(--mp-sys-motion-duration-short4) ease-mp-standard","motion-reduce:transition-none",A?"":"select-none"].filter(Boolean).join(" "),style:{filter:A?void 0:`blur(${k}px)`,maxHeight:A?void 0:z,overflow:A?void 0:"hidden"},...i(!A),children:H}),A?null:r("div",{className:["absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 text-center",s[C],f].join(" "),children:[l(E)?e("p",{className:`text-mp-on-surface-variant m-0 ${d}`,children:E}):null,g??e(o,{variant:"tonal",size:C,color:R,onClick:()=>D(!0),"aria-expanded":!1,"aria-controls":I,children:b??$.reveal})]}),A&&y?e("div",{className:["flex justify-end",c[C],m[C],"pt-0"].join(" "),children:e(o,{variant:"text",size:C,color:R,onClick:()=>D(!1),"aria-expanded":!0,"aria-controls":I,children:j??$.hide})}):null]})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPSpoiler}from"./MPSpoiler";
|