material-plus-ui 1.3.1 → 1.5.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/.fix.py +92 -0
- package/README.md +2 -2
- package/dist/components/alert/MPAlert.d.ts +26 -0
- package/dist/components/alert/MPAlert.js +1 -1
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/animate-marquee/MPAnimateMarquee.js +1 -1
- package/dist/components/avatar/MPAvatar.js +1 -1
- package/dist/components/avatar-group/MPAvatarGroup.d.ts +74 -0
- package/dist/components/avatar-group/MPAvatarGroup.js +2 -0
- package/dist/components/avatar-group/index.d.ts +2 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/breadcrumb/MPBreadcrumb.d.ts +10 -4
- package/dist/components/breadcrumb/MPBreadcrumb.js +1 -1
- package/dist/components/button/MPButton.js +1 -1
- package/dist/components/button-group/MPButtonGroup.d.ts +9 -0
- package/dist/components/button-group/MPButtonGroup.js +1 -1
- package/dist/components/carousel/MPCarousel.d.ts +12 -7
- package/dist/components/carousel/MPCarousel.js +1 -1
- package/dist/components/chat-bubble/MPChatBubble.d.ts +15 -2
- package/dist/components/chat-bubble/MPChatBubble.js +1 -1
- package/dist/components/checkbox/MPCheckbox.d.ts +6 -0
- package/dist/components/checkbox/MPCheckbox.js +1 -1
- package/dist/components/color-picker/MPColorPicker.d.ts +20 -17
- package/dist/components/color-picker/MPColorPicker.js +1 -1
- package/dist/components/combobox/MPCombobox.d.ts +22 -4
- package/dist/components/combobox/MPCombobox.js +1 -1
- package/dist/components/command-palette/MPCommandPalette.d.ts +132 -0
- package/dist/components/command-palette/MPCommandPalette.js +2 -0
- package/dist/components/command-palette/index.d.ts +2 -0
- package/dist/components/command-palette/index.js +1 -0
- package/dist/components/container/MPContainer.js +1 -1
- package/dist/components/date-time-picker/MPDateTimePicker.d.ts +5 -0
- package/dist/components/dialog/MPDialog.js +1 -1
- package/dist/components/divider/MPDivider.js +1 -1
- package/dist/components/drawer/MPDrawer.js +1 -1
- package/dist/components/fieldset/MPFieldset.d.ts +52 -0
- package/dist/components/fieldset/MPFieldset.js +2 -0
- package/dist/components/fieldset/index.d.ts +2 -0
- package/dist/components/fieldset/index.js +1 -0
- package/dist/components/file-picker/MPFilePicker.d.ts +10 -3
- package/dist/components/file-picker/MPFilePicker.js +1 -1
- package/dist/components/floating-action-button/MPFloatingActionButton.js +1 -1
- package/dist/components/footer/MPFooter.d.ts +94 -0
- package/dist/components/footer/MPFooter.js +2 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/footer/index.js +1 -0
- package/dist/components/form/MPForm.d.ts +73 -0
- package/dist/components/form/MPForm.js +2 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +1 -0
- package/dist/components/header/MPHeader.d.ts +122 -0
- package/dist/components/header/MPHeader.js +2 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +1 -0
- package/dist/components/highlight/MPHighlight.d.ts +7 -0
- package/dist/components/menu/MPMenu.d.ts +4 -2
- package/dist/components/menu/MPMenu.js +1 -1
- package/dist/components/menubar/MPMenubar.d.ts +89 -0
- package/dist/components/menubar/MPMenubar.js +2 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +1 -0
- package/dist/components/navigation-menu/MPNavigationMenu.d.ts +158 -0
- package/dist/components/navigation-menu/MPNavigationMenu.js +2 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/index.js +1 -0
- package/dist/components/number-field/MPNumberField.d.ts +19 -4
- package/dist/components/number-field/MPNumberField.js +1 -1
- package/dist/components/overlay/MPOverlay.d.ts +8 -2
- package/dist/components/overlay/MPOverlay.js +1 -1
- package/dist/components/page-layout/MPPageLayout.d.ts +145 -0
- package/dist/components/page-layout/MPPageLayout.js +2 -0
- package/dist/components/page-layout/index.d.ts +2 -0
- package/dist/components/page-layout/index.js +1 -0
- package/dist/components/panes/MPPanes.js +1 -1
- package/dist/components/popover/MPPopover.js +1 -1
- package/dist/components/progress-box/MPProgressBox.js +1 -1
- package/dist/components/progress-circular/MPProgressCircular.js +1 -1
- package/dist/components/progress-linear/MPProgressLinear.js +1 -1
- package/dist/components/radio-group/MPRadioGroup.d.ts +12 -0
- package/dist/components/radio-group/MPRadioGroup.js +1 -1
- package/dist/components/segmented-button/MPSegmentedButton.d.ts +7 -0
- package/dist/components/segmented-button/MPSegmentedButton.js +1 -1
- package/dist/components/select/MPSelect.d.ts +19 -1
- package/dist/components/select/MPSelect.js +1 -1
- package/dist/components/shortcut/MPShortcut.js +1 -1
- package/dist/components/sidebar/MPSidebar.d.ts +160 -0
- package/dist/components/sidebar/MPSidebar.js +2 -0
- package/dist/components/sidebar/MPSidebarTrigger.d.ts +45 -0
- package/dist/components/sidebar/MPSidebarTrigger.js +2 -0
- package/dist/components/sidebar/index.d.ts +4 -0
- package/dist/components/sidebar/index.js +1 -0
- package/dist/components/skeleton/MPSkeleton.js +1 -1
- package/dist/components/slider/MPSlider.d.ts +6 -0
- package/dist/components/slider/MPSlider.js +1 -1
- package/dist/components/snackbar/MPSnackbar.js +1 -1
- package/dist/components/switch/MPSwitch.d.ts +6 -0
- package/dist/components/switch/MPSwitch.js +1 -1
- package/dist/components/table/MPTable.d.ts +27 -5
- package/dist/components/table/MPTable.js +1 -1
- package/dist/components/text-field/MPTextField.d.ts +21 -2
- package/dist/components/text-field/MPTextField.js +1 -1
- package/dist/components/text-link/MPTextLink.d.ts +7 -1
- package/dist/components/text-link/MPTextLink.js +1 -1
- package/dist/components/time-picker/MPTimePicker.d.ts +4 -0
- package/dist/components/toggle/MPToggle.d.ts +72 -0
- package/dist/components/toggle/MPToggle.js +2 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle-group/MPToggleGroup.d.ts +74 -0
- package/dist/components/toggle-group/MPToggleGroup.js +2 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/tooltip/MPTooltip.js +1 -1
- package/dist/components/transfer/MPTransfer.d.ts +98 -0
- package/dist/components/transfer/MPTransfer.js +2 -0
- package/dist/components/transfer/index.d.ts +2 -0
- package/dist/components/transfer/index.js +1 -0
- package/dist/constants/glyphs.d.ts +10 -0
- package/dist/constants/glyphs.js +1 -1
- package/dist/constants/icons.d.ts +1 -0
- package/dist/constants/icons.js +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -1
- package/dist/internal/Calendar.js +1 -1
- package/dist/internal/FieldOutline.js +1 -1
- package/dist/internal/SupportingText.d.ts +1 -1
- package/dist/internal/SupportingText.js +1 -1
- package/dist/internal/animate.d.ts +0 -17
- package/dist/internal/animate.js +1 -1
- package/dist/internal/avatar-group.d.ts +22 -0
- package/dist/internal/avatar-group.js +2 -0
- package/dist/internal/button-group.d.ts +20 -1
- package/dist/internal/button-group.js +1 -1
- package/dist/internal/color.d.ts +0 -5
- package/dist/internal/color.js +1 -1
- package/dist/internal/date.js +1 -1
- package/dist/internal/i18n.d.ts +201 -4
- package/dist/internal/keys.d.ts +72 -0
- package/dist/internal/keys.js +2 -0
- package/dist/internal/length.d.ts +42 -0
- package/dist/internal/length.js +1 -0
- package/dist/internal/link.d.ts +44 -0
- package/dist/internal/link.js +1 -0
- package/dist/internal/locale.d.ts +20 -1
- package/dist/internal/locale.js +1 -1
- package/dist/internal/messages/breadcrumb.d.ts +3 -0
- package/dist/internal/messages/breadcrumb.js +1 -0
- package/dist/internal/messages/carousel.d.ts +3 -0
- package/dist/internal/messages/carousel.js +1 -0
- package/dist/internal/messages/color-picker.d.ts +3 -0
- package/dist/internal/messages/color-picker.js +1 -0
- package/dist/internal/messages/combobox.d.ts +3 -0
- package/dist/internal/messages/combobox.js +1 -0
- package/dist/internal/messages/command.d.ts +3 -0
- package/dist/internal/messages/command.js +1 -0
- package/dist/internal/messages/file-picker.d.ts +3 -0
- package/dist/internal/messages/file-picker.js +1 -0
- package/dist/internal/messages/layout.d.ts +3 -0
- package/dist/internal/messages/layout.js +1 -0
- package/dist/internal/messages/number-field.d.ts +3 -0
- package/dist/internal/messages/number-field.js +1 -0
- package/dist/internal/messages/overlay.d.ts +3 -0
- package/dist/internal/messages/overlay.js +1 -0
- package/dist/internal/messages/table.d.ts +3 -0
- package/dist/internal/messages/table.js +1 -0
- package/dist/internal/messages/text-link.d.ts +3 -0
- package/dist/internal/messages/text-link.js +1 -0
- package/dist/internal/messages/transfer.d.ts +3 -0
- package/dist/internal/messages/transfer.js +1 -0
- package/dist/internal/page-layout.d.ts +182 -0
- package/dist/internal/page-layout.js +2 -0
- package/dist/internal/scale.d.ts +17 -0
- package/dist/internal/scale.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh-hans.js +1 -1
- package/dist/locales/zh-hant.js +1 -1
- package/dist/styles/accordion.css +1 -1
- package/dist/styles/alert.css +1 -1
- package/dist/styles/avatar-group.css +2 -0
- package/dist/styles/avatar.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/blockquote.css +1 -1
- package/dist/styles/bottom-navigation.css +1 -1
- package/dist/styles/box.css +1 -1
- package/dist/styles/breadcrumb.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/chat-bubble.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chip.css +1 -1
- package/dist/styles/collapsible.css +1 -1
- package/dist/styles/color-picker.css +1 -1
- package/dist/styles/combobox.css +1 -1
- package/dist/styles/command-palette.css +2 -0
- package/dist/styles/date-picker.css +1 -1
- package/dist/styles/date-range-picker.css +1 -1
- package/dist/styles/date-time-picker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/empty.css +1 -1
- package/dist/styles/fieldset.css +2 -0
- package/dist/styles/file-picker.css +1 -1
- package/dist/styles/floating-action-button.css +1 -1
- package/dist/styles/footer.css +2 -0
- package/dist/styles/form.css +2 -0
- package/dist/styles/header.css +2 -0
- package/dist/styles/highlight.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/locale.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/menubar.css +2 -0
- package/dist/styles/navigation-menu.css +2 -0
- package/dist/styles/number-field.css +1 -1
- package/dist/styles/otp-field.css +1 -1
- package/dist/styles/overlay.css +1 -1
- package/dist/styles/page-layout.css +2 -0
- package/dist/styles/pagination.css +1 -1
- package/dist/styles/panes.css +1 -1
- package/dist/styles/pill.css +1 -1
- package/dist/styles/popover.css +1 -1
- package/dist/styles/progress-box.css +1 -1
- package/dist/styles/progress-circular.css +1 -1
- package/dist/styles/progress-linear.css +1 -1
- package/dist/styles/radio-group.css +1 -1
- package/dist/styles/segmented-button.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/sidebar.css +2 -0
- package/dist/styles/skeleton.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/spoiler.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/table.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/text-link.css +1 -1
- package/dist/styles/time-picker.css +1 -1
- package/dist/styles/timeline.css +1 -1
- package/dist/styles/toggle-group.css +2 -0
- package/dist/styles/toggle.css +2 -0
- package/dist/styles/transfer.css +2 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { MPColor, MPOrientation, MPSize } from '../../types.js';
|
|
3
|
+
export interface MPNavigationMenuProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'color' | 'defaultValue' | 'onChange'> {
|
|
4
|
+
/**
|
|
5
|
+
* Which way the row runs. `vertical` is a rail whose panels open beside it
|
|
6
|
+
* rather than under it; the arrow keys follow either way.
|
|
7
|
+
* @default 'horizontal'
|
|
8
|
+
*/
|
|
9
|
+
orientation?: MPOrientation;
|
|
10
|
+
/** Which item's panel is open, by its `value`. Nullish is closed. */
|
|
11
|
+
value?: string | null;
|
|
12
|
+
/** Which starts open, for an uncontrolled menu. */
|
|
13
|
+
defaultValue?: string | null;
|
|
14
|
+
onValueChange?: (value: string | null) => void;
|
|
15
|
+
/**
|
|
16
|
+
* How long the pointer rests on an item before its panel opens, in
|
|
17
|
+
* milliseconds.
|
|
18
|
+
*/
|
|
19
|
+
delay?: number;
|
|
20
|
+
/** And how long a panel stays after the pointer leaves. */
|
|
21
|
+
closeDelay?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Distance from the row, in pixels.
|
|
24
|
+
* @default 8
|
|
25
|
+
*/
|
|
26
|
+
sideOffset?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The row's height and type scale.
|
|
29
|
+
* @default 'md'
|
|
30
|
+
*/
|
|
31
|
+
size?: MPSize;
|
|
32
|
+
/**
|
|
33
|
+
* Which accent family an open item's label reads. The panel itself stays
|
|
34
|
+
* neutral, as MD3's menu surface does.
|
|
35
|
+
* @default 'primary'
|
|
36
|
+
*/
|
|
37
|
+
color?: MPColor;
|
|
38
|
+
/**
|
|
39
|
+
* The name the `<nav>` is announced by, through `aria-label` in the rest
|
|
40
|
+
* props.
|
|
41
|
+
*
|
|
42
|
+
* There is deliberately no default. A generic one would say nothing a screen
|
|
43
|
+
* reader was not already saying — it announces an unnamed `<nav>` as
|
|
44
|
+
* "navigation" on its own — so a name is only worth having when it
|
|
45
|
+
* distinguishes this bar from another region on the page.
|
|
46
|
+
*
|
|
47
|
+
* Which is exactly when it becomes necessary: a page with a main bar, a
|
|
48
|
+
* footer's links and a table of contents offers three regions called
|
|
49
|
+
* "navigation" and no way to tell them apart. Name them the moment there is
|
|
50
|
+
* more than one.
|
|
51
|
+
*/
|
|
52
|
+
children?: React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
export interface MPNavigationMenuItemProps {
|
|
55
|
+
/** The word in the row. */
|
|
56
|
+
label: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Makes the item a plain link rather than something that opens a panel.
|
|
59
|
+
*
|
|
60
|
+
* An item with an `href` and no children is a **destination**, and it is
|
|
61
|
+
* announced as one — which is the whole reason a site's navigation is not an
|
|
62
|
+
* [MPMenu](../inputs/menu).
|
|
63
|
+
*/
|
|
64
|
+
href?: string;
|
|
65
|
+
/** Where the link opens. Ignored without `href`. */
|
|
66
|
+
target?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The link's relationship to the page. Ignored without `href`.
|
|
69
|
+
*
|
|
70
|
+
* Left unset, a `target="_blank"` destination gets `noopener noreferrer` —
|
|
71
|
+
* the pair that stops the opened page reaching back through `window.opener`.
|
|
72
|
+
* Setting it replaces that rather than adding to it, so a destination that
|
|
73
|
+
* also needs `nofollow` should say `rel="noopener noreferrer nofollow"`.
|
|
74
|
+
*/
|
|
75
|
+
rel?: string;
|
|
76
|
+
/** A glyph before the label. */
|
|
77
|
+
startIcon?: React.ReactNode;
|
|
78
|
+
/**
|
|
79
|
+
* Identifies the item, for a controlled menu. Base UI gives each item an
|
|
80
|
+
* identity of its own, so an uncontrolled menu needs none.
|
|
81
|
+
*/
|
|
82
|
+
value?: string;
|
|
83
|
+
/** Unavailable. The word stays in the row and opens nothing. */
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* How many columns the panel lays its links out in.
|
|
87
|
+
* @default 1
|
|
88
|
+
*/
|
|
89
|
+
columns?: number;
|
|
90
|
+
/** The panel's contents — usually `MPNavigationMenuLink`s. */
|
|
91
|
+
children?: React.ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Added to the word in the row — the link, or the trigger that opens the panel
|
|
94
|
+
* — rather than to the panel. The panel is portalled out of this element and
|
|
95
|
+
* carries `mp-navigation-menu__panel`.
|
|
96
|
+
*/
|
|
97
|
+
className?: string;
|
|
98
|
+
style?: React.CSSProperties;
|
|
99
|
+
}
|
|
100
|
+
export interface MPNavigationMenuLinkProps extends Omit<React.ComponentPropsWithoutRef<'a'>, 'color' | 'title'> {
|
|
101
|
+
/** Where it goes. */
|
|
102
|
+
href: string;
|
|
103
|
+
/** The row's name. */
|
|
104
|
+
title: React.ReactNode;
|
|
105
|
+
/** A second line under it, one step down the scale and muted. */
|
|
106
|
+
description?: React.ReactNode;
|
|
107
|
+
/** A glyph before the title. */
|
|
108
|
+
startIcon?: React.ReactNode;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* One row inside a panel: where it goes, what it is called, and a line saying
|
|
112
|
+
* what is there.
|
|
113
|
+
*
|
|
114
|
+
* A real `<a>`, which is the point of the whole component — a site's navigation
|
|
115
|
+
* is a list of destinations, and a destination that is a `<div>` with a click
|
|
116
|
+
* handler is not in the link list, not on the status bar and not in a crawler's
|
|
117
|
+
* index.
|
|
118
|
+
*/
|
|
119
|
+
export declare const MPNavigationMenuLink: React.ForwardRefExoticComponent<MPNavigationMenuLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
120
|
+
/**
|
|
121
|
+
* One word in the row, and what opens under it.
|
|
122
|
+
*
|
|
123
|
+
* With children it is a trigger and a panel; with an `href` and nothing else it
|
|
124
|
+
* is a link — and the difference is not cosmetic. The second is announced as a
|
|
125
|
+
* destination and the first as something that expands.
|
|
126
|
+
*/
|
|
127
|
+
export declare function MPNavigationMenuItem({ label, href, target, rel, startIcon, value, disabled, columns, children, className, style }: MPNavigationMenuItemProps): React.JSX.Element;
|
|
128
|
+
/**
|
|
129
|
+
* A site's navigation: a row of destinations, some of which open a panel of more
|
|
130
|
+
* of them.
|
|
131
|
+
*
|
|
132
|
+
* ## Why this is not an MPMenu
|
|
133
|
+
*
|
|
134
|
+
* Because of what the rows **are**.
|
|
135
|
+
*
|
|
136
|
+
* An [MPMenu](../inputs/menu) holds actions, so its rows are `menuitem`s and the
|
|
137
|
+
* whole thing is a widget that takes the arrow keys. This holds links, so it is
|
|
138
|
+
* a `<nav>` full of real `<a>`s — which is what puts each destination in a
|
|
139
|
+
* screen reader's link list, on the browser's status bar, on the middle-click
|
|
140
|
+
* menu and in a crawler's index.
|
|
141
|
+
*
|
|
142
|
+
* The rule is short: reach for a menu when the row **does** something, and for
|
|
143
|
+
* this when the row **goes** somewhere.
|
|
144
|
+
*
|
|
145
|
+
* ## One panel, resized
|
|
146
|
+
*
|
|
147
|
+
* One panel is open at a time and it resizes between items rather than closing
|
|
148
|
+
* and reopening, which is Base UI's doing. It is also why the popup animates its
|
|
149
|
+
* width and height as well as its opacity: crossing the row should read as one
|
|
150
|
+
* surface following the pointer, not as three sheets flashing.
|
|
151
|
+
*
|
|
152
|
+
* ## Where it goes
|
|
153
|
+
*
|
|
154
|
+
* In an [MPHeader](../layout/header)'s middle slot, which is what that slot is
|
|
155
|
+
* for. Down the side of a page it is `orientation="vertical"`, which is a rail
|
|
156
|
+
* whose panels open beside it.
|
|
157
|
+
*/
|
|
158
|
+
export declare const MPNavigationMenu: React.ForwardRefExoticComponent<MPNavigationMenuProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as n,Fragment as a}from"react/jsx-runtime";import*as t from"react";import{NavigationMenu as i}from"@base-ui/react/navigation-menu";import{MPIcon as r}from"../icon/MPIcon.js";import{ChevronDownIcon as o}from"../../constants/icons.js";import{accentSlots as s}from"../../internal/accent.js";import{linkRel as l}from"../../internal/link.js";import{MPStateLayer as c}from"../../internal/StateLayer.js";import{CONTROL_GAP as m,CONTROL_HEIGHT as p,CONTROL_ICON as d,CONTROL_PAD_X as u,CONTROL_TEXT as f,hasContent as h,META_TEXT as g}from"../../internal/scale.js";import{PORTAL_LAYER as x}from"../../internal/surface.js";const v=/*@__PURE__*/t.createContext({size:"md"}),y=/*@__PURE__*/["mp-navigation-menu__popup rounded-mp-xs shadow-mp-2","bg-mp-surface-container text-mp-on-surface box-border overflow-hidden outline-none","transition-[opacity,width,height] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard data-starting-style:opacity-0 data-ending-style:opacity-0"].join(" "),N={xs:"p-1",sm:"p-1.5",md:"p-2",lg:"p-2.5",xl:"p-3"};export const MPNavigationMenuLink=/*@__PURE__*/t.forwardRef(function({href:a,title:r,description:o,startIcon:s,target:p,rel:d,className:x,children:y,...N},j){const{size:b}=t.useContext(v);return n(i.Link,{ref:j,href:a,target:p,rel:l(p,d),className:["mp-navigation-menu__link group text-mp-on-surface rounded-mp-xs relative flex","min-w-0 cursor-pointer items-start bg-transparent py-2 no-underline outline-none",m[b],u[b],x??""].filter(Boolean).join(" "),...N,children:[e(c,{}),h(s)?e("span",{className:"relative flex h-[1lh] shrink-0 items-center",children:s}):null,n("span",{className:"relative flex min-w-0 flex-col gap-0.5",children:[e("span",{className:`font-medium ${f[b]}`,children:r}),h(o)?e("span",{className:`text-mp-on-surface-variant ${g}`,children:o}):null,y]})]})});export function MPNavigationMenuItem({label:s,href:g,target:x,rel:y,startIcon:j,value:b,disabled:w=!1,columns:M=1,children:P,className:_,style:z}){const{size:k}=t.useContext(v),C=void 0!==g&&!h(P),I=Number.isFinite(M)?Math.max(1,Math.round(M)):1,L=["mp-navigation-menu__item group text-mp-on-surface relative inline-flex shrink-0","rounded-mp-full cursor-pointer items-center justify-center bg-transparent","appearance-none font-[inherit] whitespace-nowrap no-underline select-none","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none","transition-colors duration-(--mp-sys-motion-duration-short4)","data-popup-open:text-(--_mp-accent)","data-disabled:text-mp-on-surface/38 data-disabled:cursor-default",p[k],f[k],m[k],u[k],_??""].filter(Boolean).join(" ");return e(i.Item,{value:b,children:C?n(i.Link,{href:g,target:x,rel:l(x,y),className:L,style:z,children:[e(c,{}),h(j)?e("span",{className:"relative flex",children:j}):null,e("span",{className:"relative",children:s})]}):n(a,{children:[n(i.Trigger,{disabled:w,className:L,style:z,children:[w?null:e(c,{className:"group-data-popup-open:opacity-8"}),h(j)?e("span",{className:"relative flex",children:j}):null,e("span",{className:"relative",children:s}),e(i.Icon,{className:["relative flex items-center transition-transform","duration-(--mp-sys-motion-duration-short4) ease-mp-standard","data-popup-open:rotate-180"].join(" "),children:e(r,{icon:o,size:d[k]})})]}),e(i.Content,{className:`mp-navigation-menu__panel grid gap-1 ${N[k]}`,style:I>1?{gridTemplateColumns:`repeat(${I}, minmax(0, 1fr))`}:void 0,children:P})]})})}export const MPNavigationMenu=/*@__PURE__*/t.forwardRef(function({orientation:a="horizontal",value:r,defaultValue:o,onValueChange:l,delay:c,closeDelay:p,sideOffset:d=8,size:u="md",color:f="primary",className:h,style:g,children:N,...j},b){const w=t.useMemo(()=>({size:u}),[u]);return e(v.Provider,{value:w,children:n(i.Root,{ref:b,orientation:a,value:r,defaultValue:o,onValueChange:e=>l?.(e),delay:c,closeDelay:p,"data-mp-size":u,className:["mp-navigation-menu",h??""].filter(Boolean).join(" "),style:{...s(f),...g},...j,children:[e(i.List,{className:["flex items-center","vertical"===a?"flex-col items-stretch":"flex-row",m[u]].join(" "),children:N}),e(i.Portal,{children:e(i.Positioner,{className:x,sideOffset:d,collisionPadding:12,style:s(f),children:e(i.Popup,{className:y,children:e(i.Viewport,{})})})})]})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPNavigationMenu,MPNavigationMenuItem,MPNavigationMenuLink}from"./MPNavigationMenu.js";
|
|
@@ -49,16 +49,25 @@ export interface MPNumberFieldProps extends MPStyleProps {
|
|
|
49
49
|
* report `1240`.
|
|
50
50
|
*/
|
|
51
51
|
format?: Intl.NumberFormatOptions;
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Which locale the number is written and parsed in. Defaults to the runtime's.
|
|
54
|
+
*
|
|
55
|
+
* A plain BCP 47 string also names the language the two steppers are announced
|
|
56
|
+
* in; anything wider falls back to the nearest `MPLocaleProvider`, then to
|
|
57
|
+
* English.
|
|
58
|
+
*/
|
|
53
59
|
locale?: Intl.LocalesArgument;
|
|
54
60
|
/**
|
|
55
61
|
* Where the steppers sit, or `none` for a field without them.
|
|
56
62
|
* @default 'end'
|
|
57
63
|
*/
|
|
58
64
|
steppers?: MPNumberFieldSteppers;
|
|
59
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The accessible name of the increment button. Defaults to the word for it in
|
|
67
|
+
* `locale`.
|
|
68
|
+
*/
|
|
60
69
|
incrementLabel?: string;
|
|
61
|
-
/** The
|
|
70
|
+
/** The same for the decrement button. */
|
|
62
71
|
decrementLabel?: string;
|
|
63
72
|
/**
|
|
64
73
|
* Label for the field, drawn in the outline's notch and — while the field is
|
|
@@ -98,6 +107,12 @@ export interface MPNumberFieldProps extends MPStyleProps {
|
|
|
98
107
|
name?: string;
|
|
99
108
|
/** The id put on the control and pointed at by the label. */
|
|
100
109
|
id?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Added to the field's outermost element — the box around the control, its
|
|
112
|
+
* steppers and its supporting line, rather than to the `<input>` itself.
|
|
113
|
+
*/
|
|
114
|
+
className?: string;
|
|
115
|
+
style?: React.CSSProperties;
|
|
101
116
|
}
|
|
102
117
|
/**
|
|
103
118
|
* A Material Design field that only holds a number.
|
|
@@ -114,4 +129,4 @@ export interface MPNumberFieldProps extends MPStyleProps {
|
|
|
114
129
|
* owns the parsing against the locale, the clamping, the press-and-hold repeat on
|
|
115
130
|
* the steppers, and the hidden input that submits with a form.
|
|
116
131
|
*/
|
|
117
|
-
export declare function MPNumberField({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, largeStep, smallStep, allowWheelScrub, format, locale, steppers, incrementLabel, decrementLabel, label, floatingLabel, description, errorMessage, placeholder, startIcon, size, fullWidth, required, disabled, readOnly, name, id }: MPNumberFieldProps): React.JSX.Element;
|
|
132
|
+
export declare function MPNumberField({ value, defaultValue, onValueChange, onValueCommitted, min, max, step, largeStep, smallStep, allowWheelScrub, format, locale, steppers, incrementLabel, decrementLabel, label, floatingLabel, description, errorMessage, placeholder, startIcon, size, fullWidth, required, disabled, readOnly, name, id, className, style }: MPNumberFieldProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as a from"react";import{NumberField as r}from"@base-ui/react/number-field";import{Field as n}from"@base-ui/react/field";import{MPIcon as t}from"../icon/MPIcon.js";import{AddIcon as i,RemoveIcon as s}from"../../constants/icons.js";import{MPFieldLabel as o,MPFieldOutline as p,useFloatingLabel as m}from"../../internal/FieldOutline.js";import{useMPLocale as d,useMPMessages as c}from"../../internal/locale.js";import{NUMBER_FIELD as u}from"../../internal/messages/number-field.js";import{MPStateLayer as f}from"../../internal/StateLayer.js";import{MPSupportingText as h}from"../../internal/SupportingText.js";import{CONTROL_ICON as g,PROSE_TEXT as x,hasContent as b}from"../../internal/scale.js";const j={xs:{padding:"px-2",height:"h-8",stepper:"size-6"},sm:{padding:"px-3",height:"h-10",stepper:"size-8"},md:{padding:"px-4",height:"h-14",stepper:"size-10"},lg:{padding:"px-4",height:"h-16",stepper:"size-11"},xl:{padding:"px-5",height:"h-18",stepper:"size-12"}};export function MPNumberField({value:v,defaultValue:y,onValueChange:N,onValueCommitted:z,min:S,max:w,step:V,largeStep:k,smallStep:I,allowWheelScrub:q=!1,format:C,locale:L,steppers:M="end",incrementLabel:F,decrementLabel:O,label:P,floatingLabel:W=!0,description:B,errorMessage:R,placeholder:_,startIcon:D,size:G="md",fullWidth:T=!1,required:$=!1,disabled:A=!1,readOnly:E=!1,name:H,id:J,className:K,style:Q}){const U=c(u,d("string"==typeof L?L:void 0)),X=b(R),Y=j[G],Z=a.useId(),ee=J??Z,le="none"!==M&&!E&&!A,[ae,re]=a.useState(y??null),ne=void 0===v?ae:v,{shrunk:te,focusProps:ie}=m({floating:W&&b(P),filled:null!==ne,pinned:!!D||le&&"split"===M}),se=/*@__PURE__*/["mp-number-field__stepper group relative flex shrink-0 items-center justify-center","rounded-mp-full cursor-pointer appearance-none bg-transparent p-0 font-[inherit]","text-mp-on-surface-variant outline-none","disabled:text-mp-on-surface/38 disabled:cursor-default",Y.stepper].join(" "),oe=l(r.Decrement,{"aria-label":O??U.decrease,className:se,children:[e(f,{}),e(t,{icon:s,size:g[G]})]}),pe=l(r.Increment,{"aria-label":F??U.increase,className:se,children:[e(f,{}),e(t,{icon:i,size:g[G]})]});return l(n.Root,{className:["mp-number-field group flex-col align-top",T?"flex w-full":"inline-flex w-fit",K??""].filter(Boolean).join(" "),style:Q,disabled:A,invalid:X,"data-mp-size":G,...ie,children:[e(r.Root,{id:ee,name:H,className:"contents",value:v,defaultValue:y,onValueChange:e=>{re(e),N?.(e)},onValueCommitted:e=>z?.(e),min:S,max:w,step:V,largeStep:k,smallStep:I,allowWheelScrub:q,format:C,locale:L,disabled:A,readOnly:E,required:$,children:l("div",{className:"relative w-full",children:[l(r.Group,{className:["flex w-full items-center gap-2",Y.height,le&&"end"===M?`${Y.padding} pe-1`:le&&"split"===M?"px-1":Y.padding].join(" "),children:[le&&"split"===M?oe:null,D?e("span",{className:["flex shrink-0 items-center",A?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:D}):null,e(r.Input,{placeholder:te?_:void 0,className:["w-full min-w-0 flex-1 tabular-nums",x[G],"font-[family-name:var(--mp-sys-typescale-body-large-font)]","appearance-none border-0 bg-transparent px-0 outline-none","caret-mp-primary text-mp-on-surface","placeholder:text-mp-on-surface-variant","disabled:text-mp-on-surface/38 disabled:placeholder:text-mp-on-surface/38",le&&"split"===M?"text-center":""].filter(Boolean).join(" ")}),le&&"end"===M?l("span",{className:"flex shrink-0 items-center",children:[oe,pe]}):null,le&&"split"===M?pe:null]}),e(p,{label:P,required:$,notched:te}),b(P)?e(o,{size:G,label:P,required:$,htmlFor:ee,shrunk:te}):null]})}),e(h,{description:B,errorMessage:R,className:Y.padding})]})}
|
|
@@ -73,9 +73,15 @@ export interface MPOverlayProps {
|
|
|
73
73
|
* this library does: an overlay that holds nothing readable — a bare spinner, a
|
|
74
74
|
* `clear` sheet — still has to say what it is, and the alternative is a modal
|
|
75
75
|
* region a screen reader announces as nothing at all.
|
|
76
|
-
*
|
|
76
|
+
*
|
|
77
|
+
* Defaults to the word for it in `locale`.
|
|
77
78
|
*/
|
|
78
79
|
label?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Which language that default is written in. Falls back to the nearest
|
|
82
|
+
* `MPLocaleProvider`, then to English.
|
|
83
|
+
*/
|
|
84
|
+
locale?: string;
|
|
79
85
|
/** What sits on top — a spinner, a line of text, a small card. */
|
|
80
86
|
children?: React.ReactNode;
|
|
81
87
|
className?: string;
|
|
@@ -93,4 +99,4 @@ export interface MPOverlayProps {
|
|
|
93
99
|
* else Base UI owns: the portal, the scroll lock, the focus held inside, the page
|
|
94
100
|
* behind going inert, and focus returning to wherever it came from on close.
|
|
95
101
|
*/
|
|
96
|
-
export declare function MPOverlay({ open, defaultOpen, onOpenChange, tone, dismissible, modal, align, size, label, className, style, children }: MPOverlayProps): React.JSX.Element;
|
|
102
|
+
export declare function MPOverlay({ open, defaultOpen, onOpenChange, tone, dismissible, modal, align, size, label, locale: localeProp, className, style, children }: MPOverlayProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Dialog as r}from"@base-ui/react/dialog";import{FADE as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Dialog as r}from"@base-ui/react/dialog";import{useMPLocale as l,useMPMessages as s}from"../../internal/locale.js";import{OVERLAY as t}from"../../internal/messages/overlay.js";import{FADE as n,PORTAL_LAYER as i,SCRIM as o}from"../../internal/surface.js";import{SHEET_PAD as m}from"../../internal/scale.js";const c={scrim:o,blur:"bg-mp-scrim/20 [backdrop-filter:blur(14px)_saturate(1.4)]",solid:"bg-mp-surface",clear:""},p={start:"items-start",center:"items-center",end:"items-end"};export function MPOverlay({open:o,defaultOpen:f,onOpenChange:d,tone:u="scrim",dismissible:x=!1,modal:b=!0,align:j="center",size:h="md",label:y,locale:g,className:O,style:N,children:P}){const k=s(t,l(g));return e(r.Root,{open:o,defaultOpen:f,modal:b,disablePointerDismissal:!x,onOpenChange:(e,a)=>{x||e||"escape-key"!==a.reason?d?.(e):a.cancel()},children:a(r.Portal,{children:[e(r.Backdrop,{className:`${i} fixed inset-0 ${n} ${c[u]}`}),e(r.Viewport,{className:[i,"fixed inset-0 flex justify-center",p[j],m[h]].join(" "),children:e(r.Popup,{"aria-label":y??k.label,"data-mp-size":h,className:["mp-overlay flex max-h-full max-w-full flex-col items-center justify-center","text-mp-on-surface outline-none",n,O??""].filter(Boolean).join(" "),style:N,children:P})})]})})}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type MPPageCollapse, type MPPageScroll, type MPPageSpan } from '../../internal/page-layout.js';
|
|
3
|
+
export type { MPPageCollapse, MPPageScroll, MPPageSpan, MPSidebarSide } from '../../internal/page-layout.js';
|
|
4
|
+
export interface MPPageLayoutProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
5
|
+
/** The bar across the top. An [MPHeader](./header), usually. */
|
|
6
|
+
header?: React.ReactNode;
|
|
7
|
+
/** The sheet at the end. An [MPFooter](./footer), usually. */
|
|
8
|
+
footer?: React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* The leading column — the left of an English page, the right of an Arabic
|
|
11
|
+
* one. An [MPSidebar](./sidebar), which is told which end it is on and needs
|
|
12
|
+
* no `side` of its own here.
|
|
13
|
+
*/
|
|
14
|
+
sidebar?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* The trailing column, for the layouts that have two: navigation down one
|
|
17
|
+
* side and a table of contents, an inspector or a filter panel down the
|
|
18
|
+
* other. Each is a sidebar with its own width, its own drawer and its own
|
|
19
|
+
* trigger.
|
|
20
|
+
*/
|
|
21
|
+
endSidebar?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Which of the header and the sidebars takes the top corner.
|
|
24
|
+
* @default 'full'
|
|
25
|
+
*/
|
|
26
|
+
headerSpan?: MPPageSpan;
|
|
27
|
+
/**
|
|
28
|
+
* The same question for the footer, and worth answering separately: a
|
|
29
|
+
* dashboard with a full-height navigation drawer still usually wants its
|
|
30
|
+
* copyright line under the content rather than under the drawer.
|
|
31
|
+
* @default 'full'
|
|
32
|
+
*/
|
|
33
|
+
footerSpan?: MPPageSpan;
|
|
34
|
+
/**
|
|
35
|
+
* What scrolls: the document, or only the region between the bars.
|
|
36
|
+
* @default 'page'
|
|
37
|
+
*/
|
|
38
|
+
scroll?: MPPageScroll;
|
|
39
|
+
/**
|
|
40
|
+
* How tall the layout is.
|
|
41
|
+
*
|
|
42
|
+
* - `viewport` — the window's, which is what a page wants: a short page still
|
|
43
|
+
* pushes its footer to the bottom of the screen, and with `scroll="content"`
|
|
44
|
+
* the layout is exactly one screen tall. The default.
|
|
45
|
+
* - `auto` — its parent's, for a layout that is not the page: a shell inside a
|
|
46
|
+
* preview, a pane of a larger tool.
|
|
47
|
+
* - a length — a number in pixels, or any CSS length.
|
|
48
|
+
*
|
|
49
|
+
* It sets a floor while the page scrolls and an exact height while only the
|
|
50
|
+
* content does, which is the same difference `scroll` makes everywhere else.
|
|
51
|
+
* @default 'viewport'
|
|
52
|
+
*/
|
|
53
|
+
height?: 'viewport' | 'auto' | number | string;
|
|
54
|
+
/**
|
|
55
|
+
* The window size class below which the sidebars stop being columns and
|
|
56
|
+
* become drawers, opened by an [MPSidebarTrigger](./sidebar#mpsidebartrigger).
|
|
57
|
+
* `none` keeps them columns at every width.
|
|
58
|
+
*
|
|
59
|
+
* `expanded` is the default because it is MD3's own answer: the specification
|
|
60
|
+
* gives a standard navigation drawer to an expanded window and puts the same
|
|
61
|
+
* destinations behind a modal drawer below one.
|
|
62
|
+
* @default 'expanded'
|
|
63
|
+
*/
|
|
64
|
+
collapseBelow?: MPPageCollapse;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the leading sidebar's drawer is open. Use with
|
|
67
|
+
* `onSidebarOpenChange` for a controlled layout — a route change that should
|
|
68
|
+
* close the drawer behind it, a state the application already holds.
|
|
69
|
+
*/
|
|
70
|
+
sidebarOpen?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Which state it starts in.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
defaultSidebarOpen?: boolean;
|
|
76
|
+
onSidebarOpenChange?: (open: boolean) => void;
|
|
77
|
+
/** The same three for the trailing sidebar. */
|
|
78
|
+
endSidebarOpen?: boolean;
|
|
79
|
+
/** @default false */
|
|
80
|
+
defaultEndSidebarOpen?: boolean;
|
|
81
|
+
onEndSidebarOpenChange?: (open: boolean) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Puts a "Skip to content" link first in the document, drawn only while it
|
|
84
|
+
* holds the focus.
|
|
85
|
+
*
|
|
86
|
+
* On by default, and the one thing here that is not a style decision. A
|
|
87
|
+
* keyboard reader arriving on a page whose navigation holds forty links has to
|
|
88
|
+
* walk past all forty on every page before reaching the article; this is the
|
|
89
|
+
* one link that spares them, and it costs a sighted reader nothing because it
|
|
90
|
+
* is invisible until it is tabbed to.
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
skipLink?: boolean;
|
|
94
|
+
/** What that link says. Defaults to the word for it in `locale`. */
|
|
95
|
+
skipLabel?: string;
|
|
96
|
+
/**
|
|
97
|
+
* The `id` the skip link jumps to, put on the `<main>`.
|
|
98
|
+
* @default 'main'
|
|
99
|
+
*/
|
|
100
|
+
mainId?: string;
|
|
101
|
+
/** Anything else the `<main>` needs — a `className`, an `aria-label`. */
|
|
102
|
+
mainProps?: Omit<React.ComponentPropsWithoutRef<'main'>, 'id' | 'children'>;
|
|
103
|
+
/**
|
|
104
|
+
* Which language the layout's own words are in. Falls back to the nearest
|
|
105
|
+
* `MPLocaleProvider`, then to English. Inherited by every sidebar and trigger
|
|
106
|
+
* inside it, so it is written once per page.
|
|
107
|
+
*/
|
|
108
|
+
locale?: string;
|
|
109
|
+
/** The page. Rendered inside the `<main>`. */
|
|
110
|
+
children?: React.ReactNode;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The skeleton a page is hung on: a header, a footer, one sidebar or two, and
|
|
114
|
+
* the content between them.
|
|
115
|
+
*
|
|
116
|
+
* What it is really for is the **landmarks**. A page assembled out of divs is a
|
|
117
|
+
* page a screen reader offers as one undifferentiated region and a crawler reads
|
|
118
|
+
* as one undifferentiated blob; the same page built out of `<header>`, `<nav>`,
|
|
119
|
+
* `<aside>`, `<main>` and `<footer>` has a table of contents. Those tags come
|
|
120
|
+
* from the components this one arranges — it contributes exactly one element of
|
|
121
|
+
* its own, plus the `<main>` and the link that jumps to it.
|
|
122
|
+
*
|
|
123
|
+
* ## The arrangement is CSS, and that is the design
|
|
124
|
+
*
|
|
125
|
+
* Everything that decides where a column goes is flexbox and a media query, so
|
|
126
|
+
* the layout is right in the first frame the browser paints and right on a page
|
|
127
|
+
* whose JavaScript never arrives. The only things measured are the header's and
|
|
128
|
+
* the footer's heights, and only because a column that holds its place has to
|
|
129
|
+
* start below a bar whose height nobody but the bar knows.
|
|
130
|
+
*
|
|
131
|
+
* ## Why it draws no gutter and no measure
|
|
132
|
+
*
|
|
133
|
+
* That is [MPContainer](./container)'s job, and a layout that also did it would
|
|
134
|
+
* be a second spelling of one idea. Put a container inside the `<main>`, where a
|
|
135
|
+
* page can hold a full-width dashboard on one route and a 600dp article on the
|
|
136
|
+
* next.
|
|
137
|
+
*
|
|
138
|
+
* ## Why it takes no surface
|
|
139
|
+
*
|
|
140
|
+
* No `variant`, no `color`, no shadow, for [MPContainer](./container)'s reason:
|
|
141
|
+
* the outermost element on a page is the one thing that must not decide what the
|
|
142
|
+
* page looks like. The bars and the columns paint themselves; between them is
|
|
143
|
+
* whatever the application's own background is.
|
|
144
|
+
*/
|
|
145
|
+
export declare const MPPageLayout: React.ForwardRefExoticComponent<MPPageLayoutProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e,jsxs as l}from"react/jsx-runtime";import*as o from"react";import{useMPLocale as t,useMPMessages as n}from"../../internal/locale.js";import{LAYOUT as r}from"../../internal/messages/layout.js";import{MPPageLayoutContext as a,MPSidebarSideContext as i}from"../../internal/page-layout.js";import{hasContent as s}from"../../internal/scale.js";import{cssLength as u}from"../../internal/length.js";const p=["header","footer"];export const MPPageLayout=/*@__PURE__*/o.forwardRef(function({header:c,footer:f,sidebar:d,endSidebar:m,headerSpan:h="full",footerSpan:v="full",scroll:y="page",height:x="viewport",collapseBelow:b="expanded",sidebarOpen:g,defaultSidebarOpen:w=!1,onSidebarOpenChange:j,endSidebarOpen:_,defaultEndSidebarOpen:k=!1,onEndSidebarOpenChange:S,skipLink:P=!0,skipLabel:C,mainId:O="main",mainProps:N,locale:B,className:$,style:R,children:z,...E},I){const L=t(B),M=n(r,L),[H,T]=o.useState(w),[q,A]=o.useState(k),D=o.useMemo(()=>({start:g??H,end:_??q}),[g,H,_,q]),F=o.useCallback((e,l)=>{if("start"===e)return void 0===g&&T(l),void j?.(l);void 0===_&&A(l),S?.(l)},[g,_,j,S]),G=o.useRef(null),J=o.useCallback(e=>{G.current=e,"function"==typeof I?I(e):I&&(I.current=e)},[I]),K=o.useRef({header:null,footer:null}),Q=o.useRef(null),U=o.useCallback(()=>{const e=G.current;if(e)for(const l of p){const o=K.current[l],t="header"===l?h:v;if(!o){e.style.setProperty(`--_mp-layout-${l}`,"0px"),e.style.setProperty(`--_mp-layout-${l}-inset`,"0px");continue}const n=getComputedStyle(o).position,r=`${o.offsetHeight}px`,a="sticky"===n||"fixed"===n;e.style.setProperty(`--_mp-layout-${l}`,a&&"full"===t?r:"0px"),e.style.setProperty(`--_mp-layout-${l}-inset`,"fixed"===n?r:"0px")}},[h,v]),V=o.useCallback(()=>{const e=Q.current;if(e){e.disconnect();for(const l of p){const o=K.current[l];o&&e.observe(o)}}U()},[U]);o.useEffect(()=>(Q.current=new ResizeObserver(()=>U()),V(),()=>{Q.current?.disconnect(),Q.current=null}),[U,V]);const W=o.useCallback((e,l)=>{K.current[e]=l,V()},[V]),X=o.useMemo(()=>({present:!0,register:W,collapseBelow:b,open:D,setOpen:F,scroll:y,locale:L}),[W,b,D,F,y,L]),Y="content"===y,Z=u("viewport"===x||"auto"===x?void 0:x),ee=void 0!==Z?"":"auto"===x?Y?"h-full":"min-h-full":Y?"h-dvh":"min-h-dvh",le=s(c)?c:null,oe=s(f)?f:null;return e(a.Provider,{value:X,children:l("div",{ref:J,"data-mp-scroll":y,className:["mp-page-layout relative flex w-full flex-col",Y?"overflow-hidden":"",ee,"full"===h?"[padding-top:var(--_mp-layout-header-inset,0px)]":"","full"===v?"[padding-bottom:var(--_mp-layout-footer-inset,0px)]":"",$??""].filter(Boolean).join(" "),style:void 0===Z?R:{...Y?{height:Z}:{minHeight:Z},...R},...E,children:[P?e("a",{href:`#${O}`,className:["mp-page-layout__skip absolute start-3 top-3 z-50 size-px overflow-hidden","whitespace-nowrap [clip-path:inset(50%)]","focus:size-auto focus:overflow-visible focus:[clip-path:none]","focus:bg-mp-primary focus:text-mp-on-primary focus:rounded-mp-full","focus:shadow-mp-2 focus:text-mp-label-large focus:px-4 focus:py-2.5","focus:no-underline focus:outline-none"].join(" "),children:C??M.skipToContent}):null,"full"===h?le:null,l("div",{className:["flex w-full flex-1",Y?"min-h-0":""].filter(Boolean).join(" "),children:[s(d)?e(i.Provider,{value:"start",children:d}):null,l("div",{className:["flex min-w-0 flex-1 flex-col",Y?"min-h-0":"","content"===h?"[padding-top:var(--_mp-layout-header-inset,0px)]":"","content"===v?"[padding-bottom:var(--_mp-layout-footer-inset,0px)]":""].filter(Boolean).join(" "),children:["content"===h?le:null,e("main",{...N,id:O,tabIndex:N?.tabIndex??-1,className:["mp-page-layout__main min-w-0 flex-1",Y?"min-h-0 overflow-y-auto":"",N?.className??""].filter(Boolean).join(" "),children:z}),"content"===v?oe:null]}),s(m)?e(i.Provider,{value:"end",children:m}):null]}),"full"===v?oe:null]})})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{MPPageLayout}from"./MPPageLayout.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{accentSlots as r}from"../../internal/accent.js";const
|
|
2
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import*as n from"react";import{accentSlots as r}from"../../internal/accent.js";import{pixelsIn as o}from"../../internal/length.js";const i=/*@__PURE__*/n.createContext({basis:null,id:null}),a={xs:"basis-1",sm:"basis-1.5",md:"basis-2",lg:"basis-2.5",xl:"basis-3"},s={xs:4,sm:6,md:8,lg:10,xl:12};function l(e,t,n){if(null!=e)return"number"==typeof e?t*e/100:o(e,t,n)}export const MPPanes=/*@__PURE__*/n.forwardRef(function({orientation:o="horizontal",resizable:c=!0,color:u="primary",size:d="md",onResize:m,onResizeEnd:f,className:p,style:h,children:g,...v},y){const x=n.Children.toArray(g).filter(n.isValidElement),b=x.length,w=n.useId(),z=n.useRef(null),S=n.useCallback(e=>{z.current=e,"function"==typeof y?y(e):y&&(y.current=e)},[y]),j=n.useRef([]),E=x.map(e=>e.props),[R,M]=n.useState(null),k=R&&R.length===b?R:null,C=n.useRef(null);n.useLayoutEffect(()=>{j.current=E,C.current=k});const L=n.useRef(null);n.useEffect(()=>()=>{null!==L.current&&(document.body.style.userSelect=L.current,L.current=null)},[]);const P="horizontal"===o,$=s[d]*Math.max(0,b-1);function _(e){const t=z.current,n=C.current;if(!c||!t||!n||void 0===n[e+1])return null;const r=t.getBoundingClientRect(),o=(P?r.width:r.height)-$;if(o<=0)return null;const i=j.current[e],a=j.current[e+1],s=n[e]*o,u=s+n[e+1]*o,d=Math.max(l(i?.minSize,o,t)??0,u-(l(a?.maxSize,o,t)??u)),f=Math.min(l(i?.maxSize,o,t)??u,u-(l(a?.minSize,o,t)??0));return f<d?null:{root:t,current:n,lower:d,upper:f,start:s,resize(t){const r=Math.min(f,Math.max(d,s+t)),i=[...n];return i[e]=r/o,i[e+1]=(u-r)/o,M(i),m?.(i.map(e=>100*e)),i}}}n.useEffect(()=>{const e=z.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect(),n=(P?t.width:t.height)-$;n<=0||M(t=>t&&t.length===b?t:function(e,t,n){const r=e.map(e=>l(e.defaultSize,t,n)),o=r.reduce((e,t)=>e+(t??0),0),i=r.filter(e=>void 0===e).length,a=i>0?Math.max(0,t-o)/i:0,s=r.map(e=>Math.max(0,e??a)),c=s.reduce((e,t)=>e+t,0);return c<=0?s.map(()=>1/Math.max(1,s.length)):s.map(e=>e/c)}(j.current,n,e))};t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[b,P,$]);const B=["mp-panes__handle group/handle relative z-1 flex shrink-0 grow-0 items-center justify-center",a[d],"transition-colors duration-(--mp-sys-motion-duration-short4)","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-0","focus-visible:outline-solid outline-none",c?[P?"cursor-col-resize":"cursor-row-resize","hover:bg-(--_mp-accent)/8 data-[dragging]:bg-(--_mp-accent)/10"].join(" "):""].filter(Boolean).join(" ");return e("div",{ref:S,"data-mp-size":d,className:["mp-panes flex h-full w-full",P?"flex-row":"flex-col","min-h-0 min-w-0",p??""].filter(Boolean).join(" "),style:{...r(u),...h},...v,children:x.map((r,o)=>t(n.Fragment,{children:[o>0?e("div",{role:"separator","aria-orientation":P?"vertical":"horizontal","aria-valuenow":k?Math.round(100*k[o-1]):void 0,"aria-valuemin":0,"aria-valuemax":100,"aria-disabled":!c||void 0,"aria-controls":`${w}-${o-1}`,tabIndex:c?0:-1,className:B,onPointerDown:e=>{0===e.button&&function(e,t){const n=_(e);if(!n)return;const r=t.currentTarget;try{r.setPointerCapture(t.pointerId)}catch{}r.dataset.dragging="true";const o=document.body.style.userSelect;L.current=o,document.body.style.userSelect="none";const i=P?t.clientX:t.clientY,a=P&&"rtl"===getComputedStyle(n.root).direction?-1:1;let s=n.current;const l=e=>{const t=P?e.clientX:e.clientY;s=n.resize((t-i)*a)},c=()=>{r.removeEventListener("pointermove",l),r.removeEventListener("pointerup",c),r.removeEventListener("pointercancel",c),delete r.dataset.dragging,document.body.style.userSelect=o,L.current=null,f?.(s.map(e=>100*e))};r.addEventListener("pointermove",l),r.addEventListener("pointerup",c),r.addEventListener("pointercancel",c)}(o-1,e)},onKeyDown:e=>{const t=P?"ArrowLeft":"ArrowUp",n=P?"ArrowRight":"ArrowDown";if(e.key===t||e.key===n){e.preventDefault();const t=P&&"rtl"===getComputedStyle(e.currentTarget).direction?-1:1;return void function(e,t){const n=_(e);if(!n)return;const r=n.resize(t);f?.(r.map(e=>100*e))}(o-1,(e.key===n?16:-16)*t)}"Home"!==e.key&&"End"!==e.key||(e.preventDefault(),function(e,t){const n=_(e);if(!n)return;const r=n.resize(n[t]-n.start);f?.(r.map(e=>100*e))}(o-1,"Home"===e.key?"lower":"upper"))},children:e("span",{"aria-hidden":"true",className:["bg-mp-outline-variant pointer-events-none","transition-colors duration-(--mp-sys-motion-duration-short4)",P?"h-full w-px":"h-px w-full",c?["group-hover/handle:bg-(--_mp-accent)","group-focus-visible/handle:bg-(--_mp-accent)","group-data-[dragging]/handle:bg-(--_mp-accent)"].join(" "):""].filter(Boolean).join(" ")})}):null,e(i.Provider,{value:{basis:k?`calc((100% - ${$}px) * ${k[o].toFixed(6)})`:null,id:`${w}-${o}`},children:r})]},r.key??o))})});export const MPPane=/*@__PURE__*/n.forwardRef(function({defaultSize:t,minSize:r,maxSize:o,className:a,style:s,children:l,...c},u){const{basis:d,id:m}=n.useContext(i);return e("div",{ref:u,id:m??void 0,className:["mp-pane relative min-h-0 min-w-0 overflow-auto",a??""].filter(Boolean).join(" "),style:{flex:d?`0 0 ${d}`:"1 1 0%",...s},...c,children:l})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Popover as s}from"@base-ui/react/popover";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as i}from"../../constants/icons.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{
|
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{Popover as s}from"@base-ui/react/popover";import{MPIcon as t}from"../icon/MPIcon.js";import{CloseIcon as i}from"../../constants/icons.js";import{useMPLocale as a,useMPMessages as l}from"../../internal/locale.js";import{cssLength as r}from"../../internal/length.js";import{COMMON as n}from"../../internal/messages/common.js";import{MPStateLayer as m}from"../../internal/StateLayer.js";import{hasContent as c,META_TEXT as d,PROSE_TEXT as p,SHEET_GAP as f,SHEET_PAD as u,SHEET_TITLE as h}from"../../internal/scale.js";import{FADE as x,PORTAL_LAYER as g}from"../../internal/surface.js";const v={xs:"max-w-56",sm:"max-w-64",md:"max-w-80",lg:"max-w-96",xl:"max-w-lg"},b={xs:8,sm:9,md:10,lg:11,xl:12};export const MPPopoverClose=s.Close;export function MPPopover({trigger:j,title:w,description:N,side:O="bottom",align:P="center",sideOffset:y=8,alignOffset:C=0,arrow:z=!1,open:k,defaultOpen:M,onOpenChange:L,modal:B=!1,dismissible:T=!0,showClose:$=!1,closeLabel:A,locale:D,width:I,size:R="md",className:S,style:W,children:_}){const q=a(D),E=l(n,q),F=c(w)||c(N),G=b[R];return o(s.Root,{open:k,defaultOpen:M,modal:B,onOpenChange:(e,o)=>{T||e||"escape-key"!==o.reason&&"outside-press"!==o.reason&&"focus-out"!==o.reason?L?.(e):o.cancel()},children:[j?e(s.Trigger,{render:j}):null,e(s.Portal,{children:e(s.Positioner,{className:g,side:O,align:P,sideOffset:y,alignOffset:C,children:o(s.Popup,{"data-mp-size":R,className:["mp-popover rounded-mp-md relative flex flex-col outline-none","bg-mp-surface-container text-mp-on-surface shadow-mp-2","box-border",u[R],f[R],p[R],void 0===I?v[R]:"",x,S??""].filter(Boolean).join(" "),style:{...void 0===I?null:{maxWidth:r(I)},...W},children:[z?e(s.Arrow,{className:["data-[side=top]:bottom-[-1px]","data-[side=bottom]:top-[-1px] data-[side=bottom]:rotate-180","data-[side=left]:right-[-1px] data-[side=left]:-rotate-90","data-[side=right]:left-[-1px] data-[side=right]:rotate-90"].join(" "),children:e("svg",{width:G,height:G/2,viewBox:"0 0 10 5","aria-hidden":"true",className:"block",children:e("path",{d:"M0 0h10L5 5z",fill:"var(--_mp-color-surface-container)"})})}):null,F||$?o("div",{className:"flex shrink-0 items-start gap-3",children:[o("div",{className:"flex min-w-0 flex-1 flex-col",children:[c(w)?e(s.Title,{className:`m-0 ${h[R]}`,children:w}):null,c(N)?e(s.Description,{className:`text-mp-on-surface-variant m-0 ${d}`,children:N}):null]}),$?o(s.Close,{"aria-label":A??E.close,className:["group text-mp-on-surface-variant relative flex size-8 shrink-0","rounded-mp-full -m-1 cursor-pointer items-center justify-center","appearance-none border-0 bg-transparent","outline-mp-secondary focus-visible:outline-2 focus-visible:outline-offset-2","focus-visible:outline-solid outline-none"].join(" "),children:[e(m,{}),e(t,{icon:i,size:18})]}):null]}):null,c(_)?e("div",{className:"min-w-0",children:_}):null]})})})]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as l}from"../../internal/accent.js";import{META_TEXT as t,STACK_GAP as n}from"../../internal/scale.js";import{SEGMENT_GAP as o,SEGMENT_RADIUS as i,SEGMENT_SIZE as m,progressAriaText as c,progressFraction as u,progressText as f}from"../../internal/progress.js";export const MPProgressBox=/*@__PURE__*/r.forwardRef(function({size:r="md",color:p="primary",count:d=4,value:x=null,min:h=0,max:g=100,label:b,showValue:j=!1,format:y,className:v,style:w},N){const M=u(x,h,g),B=null===M,V=void 0!==y,_=Math.max(1,Math.floor(d));return a(s.Root,{ref:N,value:null===M?null:x??null,min:h,max:g,format:y,getAriaValueText:c(M,V),"data-mp-size":r,className:["mp-progress-box inline-flex flex-col",n[r],v??""].filter(Boolean).join(" "),style:{...l(p),...w},children:[b||j?a("div",{className:["flex items-baseline gap-2",b?"justify-between":"justify-end",t].join(" "),children:[b?e(s.Label,{className:"text-mp-on-surface min-w-0 truncate",children:b}):null,j?e(s.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:e=>f(M,e,V)}):null]}):null,e(s.Track,{className:`flex ${o[r]}`,children:Array.from({length:_},(a,s)=>e("span",{className:["bg-mp-on-surface/12 relative overflow-hidden",m[r],i[r],B?"mp-progress-segment-wave bg-(--_mp-accent)":""].filter(Boolean).join(" "),style:B?{"--_mp-index":s}:void 0,children:B?null:e("span",{className:"absolute inset-y-0 start-0 bg-(--_mp-accent) transition-[width] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",style:{width:`${Math.min(100,Math.max(0,100*(M*_-s)))}%`}})},s))})]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as r,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as t}from"../../internal/accent.js";import{CONTROL_GAP as o,META_TEXT as n}from"../../internal/scale.js";import{RING_DIAMETER as
|
|
2
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";import*as a from"react";import{Progress as s}from"@base-ui/react/progress";import{accentSlots as t}from"../../internal/accent.js";import{CONTROL_GAP as o,META_TEXT as n}from"../../internal/scale.js";import{RING_DIAMETER as l,RING_STROKE as i,progressAriaText as c,progressFraction as m,progressText as u}from"../../internal/progress.js";export const MPProgressCircular=/*@__PURE__*/a.forwardRef(function({size:a="md",color:p="primary",value:f=null,min:h=0,max:d=100,label:x,showValue:k=!1,format:g,className:v,style:y},j){const N=m(f,h,d),w=null===N,b=void 0!==g,$=l[a],L=i[a],V=$/2,z=V-L/2;return e(s.Root,{ref:j,value:null===N?null:f??null,min:h,max:d,format:g,getAriaValueText:c(N,b),"data-mp-size":a,className:["mp-progress-circular inline-flex items-center",o[a],n,v??""].filter(Boolean).join(" "),style:{...t(p),...y},children:[e("svg",{className:w?"mp-progress-circular-turn shrink-0":"shrink-0",width:$,height:$,viewBox:`0 0 ${$} ${$}`,fill:"none","aria-hidden":"true",children:[r("circle",{cx:V,cy:V,r:z,stroke:"var(--_mp-color-on-surface)",strokeOpacity:.12,strokeWidth:L}),r("circle",{cx:V,cy:V,r:z,pathLength:100,stroke:"var(--_mp-accent)",strokeWidth:L,strokeLinecap:"round",className:w?"mp-progress-circular-arc":"transition-[stroke-dashoffset] duration-(--mp-sys-motion-duration-short4) ease-mp-standard",transform:`rotate(-90 ${V} ${V})`,...w?null:{strokeDasharray:100,strokeDashoffset:100*(1-N)}})]}),x?r(s.Label,{className:"text-mp-on-surface min-w-0 truncate",children:x}):null,k?r(s.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:r=>u(N,r,b)}):null]})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Progress as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Progress as l}from"@base-ui/react/progress";import{accentSlots as s}from"../../internal/accent.js";import{META_TEXT as n,STACK_GAP as t}from"../../internal/scale.js";import{BAR_THICKNESS as i,progressAriaText as o,progressFraction as m,progressText as c}from"../../internal/progress.js";export const MPProgressLinear=/*@__PURE__*/r.forwardRef(function({size:u="md",color:p="primary",value:f=null,min:d=0,max:x=100,label:g,showValue:h=!1,format:j,className:b,style:N},w){const v=m(f,d,x),y=null===v,V=void 0!==j,$="absolute inset-y-0 rounded-mp-full bg-(--_mp-accent)";return a(l.Root,{ref:w,value:null===v?null:f??null,min:d,max:x,format:j,getAriaValueText:o(v,V),"data-mp-size":u,className:["mp-progress-linear flex w-full flex-col",t[u],b??""].filter(Boolean).join(" "),style:{...s(p),...N},children:[g||h?a("div",{className:["flex items-baseline gap-2",g?"justify-between":"justify-end",n].join(" "),children:[g?e(l.Label,{className:"text-mp-on-surface min-w-0 truncate",children:g}):null,h?e(l.Value,{className:"text-mp-on-surface-variant shrink-0 tabular-nums",children:e=>c(v,e,V)}):null]}):null,e(l.Track,{className:["rounded-mp-full bg-mp-on-surface/12 relative w-full overflow-hidden",i[u]].join(" "),children:y?a(r.Fragment,{children:[e("span",{className:`${$} mp-progress-linear-lead`}),e("span",{className:`${$} mp-progress-linear-trail`})]}):e(l.Indicator,{className:`${$} start-0 transition-[width] duration-(--mp-sys-motion-duration-short4) ease-mp-standard`})})]})});
|
|
@@ -11,6 +11,12 @@ export interface MPRadioProps {
|
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
/** The id put on the control and pointed at by the label. */
|
|
13
13
|
id?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Added to the option's outermost element — the box around the dot, its label
|
|
16
|
+
* and its description, rather than to the dot itself.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* One option in an `MPRadioGroup`.
|
|
@@ -64,6 +70,12 @@ export interface MPRadioGroupProps {
|
|
|
64
70
|
name?: string;
|
|
65
71
|
/** The `MPRadio`s. */
|
|
66
72
|
children?: React.ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* Added to the group's outermost element — the box around the set's label, the
|
|
75
|
+
* options and the supporting line, rather than to the run of options.
|
|
76
|
+
*/
|
|
77
|
+
className?: string;
|
|
78
|
+
style?: React.CSSProperties;
|
|
67
79
|
}
|
|
68
80
|
/**
|
|
69
81
|
* A Material Design radio group: a set of options where exactly one is chosen.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Radio as i}from"@base-ui/react/radio";import{RadioGroup as
|
|
2
|
+
import{jsx as e,jsxs as a}from"react/jsx-runtime";import*as r from"react";import{Radio as i}from"@base-ui/react/radio";import{RadioGroup as l}from"@base-ui/react/radio-group";import{Field as n}from"@base-ui/react/field";import{accentSlots as o}from"../../internal/accent.js";import{MPStateLayer as t}from"../../internal/StateLayer.js";import{MPSupportingText as s}from"../../internal/SupportingText.js";import{META_TEXT as d,PROSE_TEXT as c,hasContent as p}from"../../internal/scale.js";const m={xs:{ring:"size-4",fill:"size-2",halo:"size-8"},sm:{ring:"size-[18px]",fill:"size-[9px]",halo:"size-9"},md:{ring:"size-5",fill:"size-2.5",halo:"size-10"},lg:{ring:"size-[22px]",fill:"size-[11px]",halo:"size-11"},xl:{ring:"size-6",fill:"size-3",halo:"size-12"}},u=/*@__PURE__*/r.createContext({size:"md",readOnly:!1,invalid:!1});export const MPRadio=/*@__PURE__*/r.forwardRef(function({value:l,label:o,description:s,disabled:f=!1,id:x,className:g,style:h},b){const y=r.useContext(u),z=m[y.size],j=r.useId(),v=x??j;return e(n.Root,{className:["mp-radio inline-block align-top",g??""].filter(Boolean).join(" "),style:h,disabled:f,"data-mp-value":l,children:a("div",{className:["flex items-start gap-3",c[y.size]].join(" "),children:[e("span",{className:"flex h-[1lh] shrink-0 items-center",children:a(i.Root,{ref:b,id:v,value:l,disabled:f,className:["mp-radio__dot group relative inline-flex shrink-0 items-center justify-center","box-border rounded-full border-2 p-0","appearance-none bg-transparent font-[inherit] outline-none","transition-[border-color] duration-(--mp-sys-motion-duration-short4)",z.ring,f?"border-mp-on-surface/38 cursor-default":[y.readOnly?"cursor-default":"cursor-pointer",y.invalid?"border-mp-error":"border-mp-on-surface-variant","data-checked:border-(--_mp-accent)"].join(" ")].join(" "),children:[f?null:e(t,{layer:["top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full",z.halo,"bg-mp-on-surface","group-data-checked:bg-(--_mp-accent)"].join(" ")}),e(i.Indicator,{className:["rounded-full",z.fill,"transition-[opacity,scale] duration-(--mp-sys-motion-duration-short4)","ease-mp-standard","data-starting-style:scale-0 data-starting-style:opacity-0","data-ending-style:scale-0 data-ending-style:opacity-0",f?"bg-mp-on-surface/38":"bg-(--_mp-accent)"].join(" ")})]})}),p(o)||p(s)?a("span",{className:"flex min-w-0 flex-col gap-0.5",children:[p(o)?e(n.Label,{htmlFor:v,className:["leading-[1.4]",f?"text-mp-on-surface/38 cursor-default":y.readOnly?"text-mp-on-surface":"text-mp-on-surface cursor-pointer"].join(" "),children:o}):null,p(s)?e(n.Description,{className:`${d} text-mp-on-surface-variant data-disabled:text-mp-on-surface/38`,children:s}):null]}):null]})})});export const MPRadioGroup=/*@__PURE__*/r.forwardRef(function({value:i,defaultValue:t,onValueChange:c,label:m,description:f,errorMessage:x,orientation:g="vertical",size:h="md",color:b="primary",required:y=!1,disabled:z=!1,readOnly:j=!1,name:v,children:N,className:R,style:O},k){const w=p(x),M=w?"error":b,_=r.useId(),C=r.useMemo(()=>({size:h,readOnly:j,invalid:w}),[h,j,w]);return e(u.Provider,{value:C,children:a(n.Root,{className:["mp-radio-group flex flex-col gap-2",R??""].filter(Boolean).join(" "),disabled:z,invalid:w,"data-mp-size":h,"data-mp-orientation":g,style:{...o(M),...O},children:[p(m)?a("span",{id:_,className:[d,z?"text-mp-on-surface/38":"text-mp-on-surface-variant"].join(" "),children:[m,y?e("span",{"aria-hidden":"true",children:" *"}):null]}):null,e(l,{ref:k,"aria-labelledby":p(m)?_:void 0,value:i,defaultValue:t,onValueChange:e=>c?.(String(e??"")),disabled:z,readOnly:j,required:y,name:v,className:["flex","horizontal"===g?"flex-row flex-wrap gap-x-6 gap-y-2":"flex-col gap-2"].join(" "),children:N}),e(s,{description:f,errorMessage:x})]})})});
|