@matekit/react 0.0.0-stage → 0.1.1
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/CHANGELOG.md +102 -0
- package/LICENSE +202 -0
- package/NOTICE +56 -0
- package/README.md +115 -2
- package/dist/atoms/Divider/Divider.d.ts +49 -0
- package/dist/atoms/Divider/Divider.js +29 -0
- package/dist/atoms/FocusRing/FocusRing.d.ts +16 -0
- package/dist/atoms/FocusRing/FocusRing.js +16 -0
- package/dist/atoms/Group/Group.d.ts +38 -0
- package/dist/atoms/Group/Group.js +34 -0
- package/dist/atoms/Icon/Icon.d.ts +23 -0
- package/dist/atoms/Icon/Icon.js +19 -0
- package/dist/atoms/Interactive/Interactive.d.ts +98 -0
- package/dist/atoms/Interactive/Interactive.js +87 -0
- package/dist/atoms/Ripple/Ripple.d.ts +14 -0
- package/dist/atoms/Ripple/Ripple.js +63 -0
- package/dist/atoms/Shape/Shape.d.ts +24 -0
- package/dist/atoms/Shape/Shape.js +19 -0
- package/dist/atoms/Shape/shapes.d.ts +8 -0
- package/dist/atoms/Shape/shapes.js +40 -0
- package/dist/atoms/Stack/Stack.d.ts +58 -0
- package/dist/atoms/Stack/Stack.js +33 -0
- package/dist/atoms/StateLayer/StateLayer.d.ts +17 -0
- package/dist/atoms/StateLayer/StateLayer.js +17 -0
- package/dist/atoms/index.d.ts +10 -0
- package/dist/atoms/index.js +10 -0
- package/dist/fonts/roboto-flex/OFL.txt +93 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-greek.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-vietnamese.woff2 +0 -0
- package/dist/icons/icons.d.ts +89 -0
- package/dist/icons/icons.js +186 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/internal/accessible-name.d.ts +17 -0
- package/dist/internal/accessible-name.js +33 -0
- package/dist/internal/anchor-position.d.ts +99 -0
- package/dist/internal/anchor-position.js +159 -0
- package/dist/internal/anchored-drag.d.ts +25 -0
- package/dist/internal/anchored-drag.js +106 -0
- package/dist/internal/dev.d.ts +2 -0
- package/dist/internal/dev.js +18 -0
- package/dist/internal/diagnostics.d.ts +46 -0
- package/dist/internal/diagnostics.js +125 -0
- package/dist/internal/group-label.d.ts +22 -0
- package/dist/internal/group-label.js +50 -0
- package/dist/internal/interactive.d.ts +28 -0
- package/dist/internal/interactive.js +18 -0
- package/dist/internal/layout-element.d.ts +21 -0
- package/dist/internal/layout-element.js +33 -0
- package/dist/internal/merge-refs.d.ts +13 -0
- package/dist/internal/merge-refs.js +35 -0
- package/dist/internal/modal-dialog.d.ts +63 -0
- package/dist/internal/modal-dialog.js +267 -0
- package/dist/internal/navigation-count.d.ts +38 -0
- package/dist/internal/navigation-count.js +60 -0
- package/dist/internal/navigation-item.d.ts +14 -0
- package/dist/internal/navigation-item.js +17 -0
- package/dist/internal/nearest-scroller.d.ts +4 -0
- package/dist/internal/nearest-scroller.js +17 -0
- package/dist/internal/open-state.d.ts +15 -0
- package/dist/internal/open-state.js +42 -0
- package/dist/internal/roving-focus.d.ts +41 -0
- package/dist/internal/roving-focus.js +126 -0
- package/dist/internal/settle-animations.d.ts +33 -0
- package/dist/internal/settle-animations.js +48 -0
- package/dist/internal/time-period.d.ts +10 -0
- package/dist/internal/time-period.js +26 -0
- package/dist/internal/time.d.ts +23 -0
- package/dist/internal/time.js +69 -0
- package/dist/internal/typeahead.d.ts +17 -0
- package/dist/internal/typeahead.js +35 -0
- package/dist/molecules/Badge/Badge.d.ts +25 -0
- package/dist/molecules/Badge/Badge.js +16 -0
- package/dist/molecules/Button/Button.d.ts +48 -0
- package/dist/molecules/Button/Button.js +34 -0
- package/dist/molecules/Card/Card.d.ts +159 -0
- package/dist/molecules/Card/Card.js +119 -0
- package/dist/molecules/Checkbox/Checkbox.d.ts +26 -0
- package/dist/molecules/Checkbox/Checkbox.js +40 -0
- package/dist/molecules/Chip/AssistChip.d.ts +23 -0
- package/dist/molecules/Chip/AssistChip.js +22 -0
- package/dist/molecules/Chip/ChipGroup.d.ts +85 -0
- package/dist/molecules/Chip/ChipGroup.js +92 -0
- package/dist/molecules/Chip/FilterChip.d.ts +33 -0
- package/dist/molecules/Chip/FilterChip.js +30 -0
- package/dist/molecules/Chip/InputChip.d.ts +60 -0
- package/dist/molecules/Chip/InputChip.js +107 -0
- package/dist/molecules/Chip/SuggestionChip.d.ts +24 -0
- package/dist/molecules/Chip/SuggestionChip.js +17 -0
- package/dist/molecules/Chip/chip-content.d.ts +39 -0
- package/dist/molecules/Chip/chip-content.js +95 -0
- package/dist/molecules/Chip/chip-element.d.ts +14 -0
- package/dist/molecules/Chip/chip-element.js +14 -0
- package/dist/molecules/Chip/strings.d.ts +8 -0
- package/dist/molecules/Chip/strings.js +5 -0
- package/dist/molecules/Fab/Fab.d.ts +78 -0
- package/dist/molecules/Fab/Fab.js +52 -0
- package/dist/molecules/IconButton/IconButton.d.ts +59 -0
- package/dist/molecules/IconButton/IconButton.js +36 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.d.ts +38 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.js +25 -0
- package/dist/molecules/LoadingIndicator/determinate.d.ts +3 -0
- package/dist/molecules/LoadingIndicator/determinate.js +47 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.d.ts +21 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.js +72 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.d.ts +35 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.js +30 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.d.ts +43 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.js +28 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.d.ts +5 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.js +19 -0
- package/dist/molecules/ProgressIndicator/progress.d.ts +24 -0
- package/dist/molecules/ProgressIndicator/progress.js +60 -0
- package/dist/molecules/RadioButton/RadioButton.d.ts +27 -0
- package/dist/molecules/RadioButton/RadioButton.js +70 -0
- package/dist/molecules/RadioButton/RadioGroup.d.ts +73 -0
- package/dist/molecules/RadioButton/RadioGroup.js +82 -0
- package/dist/molecules/ScrollField/ScrollField.d.ts +61 -0
- package/dist/molecules/ScrollField/ScrollField.js +352 -0
- package/dist/molecules/Slider/RangeSlider.d.ts +60 -0
- package/dist/molecules/Slider/RangeSlider.js +169 -0
- package/dist/molecules/Slider/Slider.d.ts +54 -0
- package/dist/molecules/Slider/Slider.js +71 -0
- package/dist/molecules/Slider/slider-shared.d.ts +26 -0
- package/dist/molecules/Slider/slider-shared.js +98 -0
- package/dist/molecules/Switch/Switch.d.ts +22 -0
- package/dist/molecules/Switch/Switch.js +20 -0
- package/dist/molecules/TextField/TextField.d.ts +83 -0
- package/dist/molecules/TextField/TextField.js +146 -0
- package/dist/molecules/TextField/TextFieldSlots.d.ts +22 -0
- package/dist/molecules/TextField/TextFieldSlots.js +24 -0
- package/dist/molecules/TimeInput/TimeInput.d.ts +108 -0
- package/dist/molecules/TimeInput/TimeInput.js +347 -0
- package/dist/molecules/TimeInput/strings.d.ts +13 -0
- package/dist/molecules/TimeInput/strings.js +10 -0
- package/dist/molecules/TimeScroll/TimeScroll.d.ts +106 -0
- package/dist/molecules/TimeScroll/TimeScroll.js +213 -0
- package/dist/molecules/TimeScroll/strings.d.ts +13 -0
- package/dist/molecules/TimeScroll/strings.js +12 -0
- package/dist/molecules/index.d.ts +27 -0
- package/dist/molecules/index.js +25 -0
- package/dist/organisms/BottomSheet/BottomSheet.d.ts +128 -0
- package/dist/organisms/BottomSheet/BottomSheet.js +432 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.d.ts +17 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.js +16 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.d.ts +37 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.js +206 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.d.ts +31 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.js +12 -0
- package/dist/organisms/BottomSheet/sheet-drag.d.ts +1 -0
- package/dist/organisms/BottomSheet/sheet-drag.js +4 -0
- package/dist/organisms/BottomSheet/strings.d.ts +9 -0
- package/dist/organisms/BottomSheet/strings.js +8 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.d.ts +97 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.js +242 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.d.ts +36 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.js +47 -0
- package/dist/organisms/Dialog/Dialog.d.ts +186 -0
- package/dist/organisms/Dialog/Dialog.js +193 -0
- package/dist/organisms/Dialog/DialogSlots.d.ts +60 -0
- package/dist/organisms/Dialog/DialogSlots.js +54 -0
- package/dist/organisms/Dialog/strings.d.ts +5 -0
- package/dist/organisms/Dialog/strings.js +5 -0
- package/dist/organisms/FabMenu/FabMenu.d.ts +104 -0
- package/dist/organisms/FabMenu/FabMenu.js +142 -0
- package/dist/organisms/FabMenu/strings.d.ts +9 -0
- package/dist/organisms/FabMenu/strings.js +5 -0
- package/dist/organisms/List/List.d.ts +190 -0
- package/dist/organisms/List/List.js +148 -0
- package/dist/organisms/Menu/Menu.d.ts +313 -0
- package/dist/organisms/Menu/Menu.js +865 -0
- package/dist/organisms/Menu/MenuSlots.d.ts +35 -0
- package/dist/organisms/Menu/MenuSlots.js +36 -0
- package/dist/organisms/NavigationBar/NavigationBar.d.ts +96 -0
- package/dist/organisms/NavigationBar/NavigationBar.js +77 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.d.ts +105 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.js +272 -0
- package/dist/organisms/NavigationRail/NavigationRail.d.ts +148 -0
- package/dist/organisms/NavigationRail/NavigationRail.js +114 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.d.ts +54 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.js +96 -0
- package/dist/organisms/NavigationRail/strings.d.ts +7 -0
- package/dist/organisms/NavigationRail/strings.js +7 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.d.ts +109 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.js +86 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.d.ts +118 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.js +132 -0
- package/dist/organisms/Search/Search.d.ts +213 -0
- package/dist/organisms/Search/Search.js +783 -0
- package/dist/organisms/Search/SearchSlots.d.ts +18 -0
- package/dist/organisms/Search/SearchSlots.js +19 -0
- package/dist/organisms/Search/strings.d.ts +21 -0
- package/dist/organisms/Search/strings.js +12 -0
- package/dist/organisms/Select/Select.d.ts +186 -0
- package/dist/organisms/Select/Select.js +597 -0
- package/dist/organisms/Select/SelectSlots.d.ts +12 -0
- package/dist/organisms/Select/SelectSlots.js +12 -0
- package/dist/organisms/SideSheet/SideSheet.d.ts +88 -0
- package/dist/organisms/SideSheet/SideSheet.js +109 -0
- package/dist/organisms/SideSheet/SideSheetSlots.d.ts +35 -0
- package/dist/organisms/SideSheet/SideSheetSlots.js +37 -0
- package/dist/organisms/SideSheet/strings.d.ts +7 -0
- package/dist/organisms/SideSheet/strings.js +6 -0
- package/dist/organisms/Snackbar/Snackbar.d.ts +46 -0
- package/dist/organisms/Snackbar/Snackbar.js +36 -0
- package/dist/organisms/Snackbar/SnackbarHost.d.ts +57 -0
- package/dist/organisms/Snackbar/SnackbarHost.js +221 -0
- package/dist/organisms/Snackbar/snackbar-queue.d.ts +81 -0
- package/dist/organisms/Snackbar/snackbar-queue.js +114 -0
- package/dist/organisms/Snackbar/strings.d.ts +8 -0
- package/dist/organisms/Snackbar/strings.js +5 -0
- package/dist/organisms/SplitButton/SplitButton.d.ts +73 -0
- package/dist/organisms/SplitButton/SplitButton.js +77 -0
- package/dist/organisms/SplitButton/strings.d.ts +9 -0
- package/dist/organisms/SplitButton/strings.js +5 -0
- package/dist/organisms/Tabs/TabLink.d.ts +27 -0
- package/dist/organisms/Tabs/TabLink.js +25 -0
- package/dist/organisms/Tabs/TabNav.d.ts +19 -0
- package/dist/organisms/Tabs/TabNav.js +55 -0
- package/dist/organisms/Tabs/Tabs.d.ts +147 -0
- package/dist/organisms/Tabs/Tabs.js +223 -0
- package/dist/organisms/Tabs/tab-content.d.ts +23 -0
- package/dist/organisms/Tabs/tab-content.js +105 -0
- package/dist/organisms/Tabs/tab-fit.d.ts +4 -0
- package/dist/organisms/Tabs/tab-fit.js +65 -0
- package/dist/organisms/Tabs/tab-motion.d.ts +2 -0
- package/dist/organisms/Tabs/tab-motion.js +68 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.d.ts +26 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.js +34 -0
- package/dist/organisms/Toolbar/Toolbar.d.ts +75 -0
- package/dist/organisms/Toolbar/Toolbar.js +84 -0
- package/dist/organisms/Toolbar/ToolbarLayout.d.ts +44 -0
- package/dist/organisms/Toolbar/ToolbarLayout.js +90 -0
- package/dist/organisms/Toolbar/ToolbarScroll.d.ts +8 -0
- package/dist/organisms/Toolbar/ToolbarScroll.js +222 -0
- package/dist/organisms/Tooltip/RichTooltip.d.ts +73 -0
- package/dist/organisms/Tooltip/RichTooltip.js +250 -0
- package/dist/organisms/Tooltip/Tooltip.d.ts +52 -0
- package/dist/organisms/Tooltip/Tooltip.js +99 -0
- package/dist/organisms/Tooltip/tooltip-behavior.d.ts +43 -0
- package/dist/organisms/Tooltip/tooltip-behavior.js +307 -0
- package/dist/organisms/TopAppBar/TopAppBar.d.ts +107 -0
- package/dist/organisms/TopAppBar/TopAppBar.js +78 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.d.ts +7 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.js +155 -0
- package/dist/organisms/index.d.ts +36 -0
- package/dist/organisms/index.js +36 -0
- package/dist/palettes/blue.css +275 -0
- package/dist/palettes/green.css +275 -0
- package/dist/palettes/index.css +823 -0
- package/dist/palettes/orange.css +275 -0
- package/dist/shapes.css +115 -0
- package/dist/strings/index.d.ts +35 -0
- package/dist/strings/index.js +39 -0
- package/dist/styles-no-fonts.css +12025 -0
- package/dist/styles.css +12123 -0
- package/dist/stylesheet.d.ts +2 -0
- package/dist/tokens/breakpoints.d.ts +33 -0
- package/dist/tokens/breakpoints.js +31 -0
- package/dist/tokens/space.d.ts +26 -0
- package/dist/tokens/space.js +26 -0
- package/package.json +110 -3
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { type CSSProperties, type HTMLAttributes, type ButtonHTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
|
|
2
|
+
type FocusTarget = 'first' | 'last' | 'none';
|
|
3
|
+
/**
|
|
4
|
+
* Why a menu asked to open or close (`onOpenChange(open, reason)`):
|
|
5
|
+
* - `trigger`: the trigger opened it (click, Enter, Space, Arrow Down or Arrow Up) or closed it
|
|
6
|
+
* (a click on it while open);
|
|
7
|
+
* - `escape`: Escape inside the menu (focus goes back to the trigger);
|
|
8
|
+
* - `select`: an item was chosen (unless its `onSelect` called `preventDefault()`);
|
|
9
|
+
* - `tab`: Tab left the menu (focus moves on from the trigger);
|
|
10
|
+
* - `outside`: a click outside the menu and the trigger (focus stays where the click put it).
|
|
11
|
+
*/
|
|
12
|
+
export type MenuOpenChangeReason = 'trigger' | 'escape' | 'select' | 'tab' | 'outside';
|
|
13
|
+
/**
|
|
14
|
+
* Why a submenu asked to open or close (`MenuSub`'s `onOpenChange(open, reason)`):
|
|
15
|
+
* - `trigger`: its `MenuSubTrigger` opened it (click, Enter, Space, or Right Arrow; Left Arrow in
|
|
16
|
+
* right-to-left);
|
|
17
|
+
* - `hover`: the pointer rested on the trigger (opens after a short delay), or moved on to another
|
|
18
|
+
* item of the same menu, or left the trigger and did not reach the submenu (closes);
|
|
19
|
+
* - `escape`: Escape inside the submenu (only that submenu closes; focus returns to its trigger);
|
|
20
|
+
* - `arrow`: Left Arrow inside the submenu (Right Arrow in right-to-left), like `escape`;
|
|
21
|
+
* - `replaced`: another submenu of the same menu opened;
|
|
22
|
+
* - `select`, `tab`, `outside`: an item was chosen, Tab left, or a click landed outside: the whole menu
|
|
23
|
+
* closes, with the same reason in the `Menu`'s `onOpenChange`;
|
|
24
|
+
* - `parent`: the menu it opens from closed for another reason.
|
|
25
|
+
*/
|
|
26
|
+
export type MenuSubOpenChangeReason = 'trigger' | 'hover' | 'escape' | 'arrow' | 'replaced' | 'select' | 'tab' | 'outside' | 'parent';
|
|
27
|
+
type CloseRequest = MenuOpenChangeReason | 'arrow' | 'hover' | 'replaced';
|
|
28
|
+
type OpenRequest = 'trigger' | 'hover';
|
|
29
|
+
interface MenuContextValue {
|
|
30
|
+
open: boolean;
|
|
31
|
+
requestOpen: (focus: FocusTarget, reason?: OpenRequest) => void;
|
|
32
|
+
requestClose: (reason: CloseRequest) => void;
|
|
33
|
+
closedBecause: () => CloseRequest | null;
|
|
34
|
+
rootTriggerRef: RefObject<HTMLElement | null>;
|
|
35
|
+
parentOpen: boolean | undefined;
|
|
36
|
+
focusRequest: number;
|
|
37
|
+
focusTarget: RefObject<FocusTarget>;
|
|
38
|
+
returnFocus: RefObject<boolean>;
|
|
39
|
+
triggerRef: RefObject<HTMLElement | null>;
|
|
40
|
+
contentRef: RefObject<HTMLDivElement | null>;
|
|
41
|
+
triggerId: string | undefined;
|
|
42
|
+
setTriggerId: (id: string | undefined) => void;
|
|
43
|
+
generatedTriggerId: string;
|
|
44
|
+
contentId: string;
|
|
45
|
+
anchorName: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function useMenu(part: string): MenuContextValue;
|
|
48
|
+
export declare const MENU_SUB_HOVER_DELAY = 400;
|
|
49
|
+
export interface MenuProps {
|
|
50
|
+
/** Open or closed, controlled. Without it, the menu keeps its own state from `defaultOpen`. */
|
|
51
|
+
open?: boolean | undefined;
|
|
52
|
+
/** Initial state when uncontrolled. Defaults to `false`. */
|
|
53
|
+
defaultOpen?: boolean | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* The user asked to open or close, with the reason (`MenuOpenChangeReason`): the trigger, Escape,
|
|
56
|
+
* Tab, a click outside or choosing an item. Controlled, the menu only changes when `open` does.
|
|
57
|
+
*/
|
|
58
|
+
onOpenChange?: ((open: boolean, reason: MenuOpenChangeReason) => void) | undefined;
|
|
59
|
+
children?: ReactNode;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Material 3 Expressive menu, with the WAI-ARIA APG "menu button" pattern. It renders no element:
|
|
63
|
+
* it groups the trigger (`MenuTrigger`) and the menu (`MenuContent`).
|
|
64
|
+
*
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <Menu>
|
|
67
|
+
* <MenuTrigger><IconButton label="More options"><MoreVertIcon /></IconButton></MenuTrigger>
|
|
68
|
+
* <MenuContent>
|
|
69
|
+
* <MenuItem onSelect={edit}><MenuItemLeading><EditIcon /></MenuItemLeading>Edit</MenuItem>
|
|
70
|
+
* <MenuDivider />
|
|
71
|
+
* <MenuItem onSelect={remove}><MenuItemLeading><DeleteIcon /></MenuItemLeading>Delete</MenuItem>
|
|
72
|
+
* </MenuContent>
|
|
73
|
+
* </Menu>
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* - **Keyboard:** on the trigger, Enter, Space and Down Arrow open the menu and focus the first
|
|
77
|
+
* item; Up Arrow opens it and focuses the last one. In the menu, the arrows move with
|
|
78
|
+
* wrap-around, Home and End go to the ends, a letter focuses the next item that starts with it,
|
|
79
|
+
* Escape closes and returns focus to the trigger, and Tab closes and moves to the next focusable.
|
|
80
|
+
* - **Choosing** an item calls its `onSelect` and closes the menu; `event.preventDefault()` in
|
|
81
|
+
* `onSelect` keeps it open (for example, in a `menuitemcheckbox`).
|
|
82
|
+
* - A click outside the menu and the trigger closes it, without moving focus.
|
|
83
|
+
*/
|
|
84
|
+
export declare function Menu({ open, defaultOpen, onOpenChange, children }: MenuProps): import("react").JSX.Element;
|
|
85
|
+
interface TriggerChildProps {
|
|
86
|
+
id?: string | undefined;
|
|
87
|
+
style?: CSSProperties | undefined;
|
|
88
|
+
onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;
|
|
89
|
+
onKeyDown?: ((event: KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
90
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
91
|
+
}
|
|
92
|
+
export interface MenuTriggerProps {
|
|
93
|
+
/**
|
|
94
|
+
* The trigger: a single element, which must be (or render) a `<button>` and pass `id`, `style`,
|
|
95
|
+
* `ref`, `onClick`, `onKeyDown` and the `aria-*` attributes to that button; `Button` and
|
|
96
|
+
* `IconButton` do.
|
|
97
|
+
*/
|
|
98
|
+
children: ReactElement<TriggerChildProps>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Turns the child button into the menu's trigger, without adding elements: it adds
|
|
102
|
+
* `aria-haspopup="menu"`, `aria-expanded`, `aria-controls`, an `id` (if it has none), the
|
|
103
|
+
* `anchor-name` the menu uses to sit next to it and the events that open it. Its own `onClick`,
|
|
104
|
+
* `onKeyDown`, `style` and `ref` are kept; an `onClick` that calls `preventDefault()` keeps the menu
|
|
105
|
+
* from opening or closing.
|
|
106
|
+
*
|
|
107
|
+
* ```tsx
|
|
108
|
+
* <MenuTrigger><Button variant="tonal">Sort</Button></MenuTrigger>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare function MenuTrigger({ children }: MenuTriggerProps): ReactElement<TriggerChildProps, string | import("react").JSXElementConstructor<any>>;
|
|
112
|
+
/** The kit's color scheme of a menu, the same names as `ToolbarColor`. */
|
|
113
|
+
export type MenuColor = 'standard' | 'vibrant';
|
|
114
|
+
export interface MenuContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color'> {
|
|
115
|
+
/**
|
|
116
|
+
* The kit's color scheme: `standard` (`surface-container-low` container, selected items in
|
|
117
|
+
* `tertiary-container`) or `vibrant` (`tertiary-container` container, selected in `tertiary`).
|
|
118
|
+
* Defaults to `standard`.
|
|
119
|
+
*/
|
|
120
|
+
color?: MenuColor | undefined;
|
|
121
|
+
/** Ref to the container (`role="menu"`, a popover). */
|
|
122
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The menu: a popover (`popover="manual"`, in the top layer) with `role="menu"`, placed next to the
|
|
126
|
+
* trigger with CSS anchor positioning: below and start-aligned; if it does not fit, above or
|
|
127
|
+
* towards the other side. Its accessible name is the trigger's (`aria-labelledby`).
|
|
128
|
+
*
|
|
129
|
+
* It is always mounted, and hidden while the menu is closed. On close, it animates its exit and
|
|
130
|
+
* only then hides. Native props, `className`, `style` and `ref` reach the container. Width between
|
|
131
|
+
* 112 and 280 px depending on the content.
|
|
132
|
+
*/
|
|
133
|
+
export declare function MenuContent({ color, ...props }: MenuContentProps): import("react").JSX.Element;
|
|
134
|
+
export interface MenuSubProps {
|
|
135
|
+
/** Open or closed, controlled. Without it, the submenu keeps its own state from `defaultOpen`. */
|
|
136
|
+
open?: boolean | undefined;
|
|
137
|
+
/** Initial state when uncontrolled. Defaults to `false`. */
|
|
138
|
+
defaultOpen?: boolean | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* The user asked to open or close the submenu, with the reason (`MenuSubOpenChangeReason`): its
|
|
141
|
+
* trigger, the pointer, Escape or Left Arrow, another submenu opening, or the whole menu closing.
|
|
142
|
+
* Controlled, the submenu only changes when `open` does; it shows only while the menu it opens
|
|
143
|
+
* from is open.
|
|
144
|
+
*/
|
|
145
|
+
onOpenChange?: ((open: boolean, reason: MenuSubOpenChangeReason) => void) | undefined;
|
|
146
|
+
children?: ReactNode;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A submenu inside `MenuContent` (or inside another submenu, or a `MenuGroup`), with the WAI-ARIA APG
|
|
150
|
+
* "Menu and Menubar" keyboard. It renders no element: it groups the item that opens it
|
|
151
|
+
* (`MenuSubTrigger`) and the submenu (`MenuSubContent`).
|
|
152
|
+
*
|
|
153
|
+
* ```tsx
|
|
154
|
+
* <MenuContent>
|
|
155
|
+
* <MenuItem>Bold</MenuItem>
|
|
156
|
+
* <MenuSub>
|
|
157
|
+
* <MenuSubTrigger><MenuItemLeading><FormatAlignLeftIcon /></MenuItemLeading>Align</MenuSubTrigger>
|
|
158
|
+
* <MenuSubContent>
|
|
159
|
+
* <MenuItem onSelect={() => align('start')}>Start</MenuItem>
|
|
160
|
+
* <MenuItem onSelect={() => align('center')}>Center</MenuItem>
|
|
161
|
+
* </MenuSubContent>
|
|
162
|
+
* </MenuSub>
|
|
163
|
+
* </MenuContent>
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* - **Opening:** a click, Enter, Space or Right Arrow (Left Arrow in right-to-left) on the trigger
|
|
167
|
+
* opens the submenu and focuses its first item; the pointer resting on the trigger opens it after
|
|
168
|
+
* 400 ms, without moving focus. One submenu per menu is open at a time.
|
|
169
|
+
* - **Going back:** Escape or Left Arrow (Right Arrow in right-to-left) closes only the submenu and
|
|
170
|
+
* returns focus to its trigger. Moving the pointer on to another item closes it; moving diagonally
|
|
171
|
+
* towards the submenu does not.
|
|
172
|
+
* - **Choosing** an item, Tab or a click outside closes the whole menu, with that reason in the
|
|
173
|
+
* `Menu`'s `onOpenChange` too.
|
|
174
|
+
*/
|
|
175
|
+
export declare function MenuSub({ open, defaultOpen, onOpenChange, children }: MenuSubProps): import("react").JSX.Element;
|
|
176
|
+
export interface MenuSubTriggerProps extends Omit<MenuItemBaseProps, 'onSelect'> {
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The item that opens a submenu: a `menuitem` with `aria-haspopup="menu"`, `aria-expanded` and
|
|
180
|
+
* `aria-controls`, the look of a `MenuItem` and the kit's `arrow_right` icon as its trailing content
|
|
181
|
+
* (mirrored in right-to-left). While its submenu is open it shows the kit's "Active" state (the
|
|
182
|
+
* state layer at 8 %). It does not choose anything: a click opens the submenu.
|
|
183
|
+
*
|
|
184
|
+
* Its children are the item's content, as in `MenuItem` (`MenuItemLeading`, the text,
|
|
185
|
+
* `MenuItemSupporting`). A disabled trigger is focusable and does not open.
|
|
186
|
+
*
|
|
187
|
+
* ```tsx
|
|
188
|
+
* <MenuSubTrigger><MenuItemLeading><ShareIcon /></MenuItemLeading>Share</MenuSubTrigger>
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare function MenuSubTrigger({ disabled, onClick, onKeyDown, onPointerEnter, onPointerLeave, className, style, children, ref, ...props }: MenuSubTriggerProps): import("react").JSX.Element;
|
|
192
|
+
export interface MenuSubContentProps extends MenuContentProps {
|
|
193
|
+
/**
|
|
194
|
+
* The kit's color scheme, as in `MenuContent`. Defaults to the color of the menu the submenu opens
|
|
195
|
+
* from.
|
|
196
|
+
*/
|
|
197
|
+
color?: MenuColor | undefined;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* The submenu: a popover like `MenuContent` (`role="menu"`, named by its trigger, with the same look,
|
|
201
|
+
* groups included), placed next to its `MenuSubTrigger` with CSS anchor positioning: at the trigger's
|
|
202
|
+
* end side with their tops aligned; if it does not fit, towards the start side, or upwards with
|
|
203
|
+
* their bottoms aligned. Arrows, Home, End and typeahead stay inside the submenu.
|
|
204
|
+
*/
|
|
205
|
+
export declare function MenuSubContent({ color, ...props }: MenuSubContentProps): import("react").JSX.Element;
|
|
206
|
+
interface MenuItemBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'onSelect' | 'disabled' | 'role'> {
|
|
207
|
+
/**
|
|
208
|
+
* Disabled: announced (`aria-disabled`) and focusable with the arrows, as APG asks for menus, but
|
|
209
|
+
* it does not activate.
|
|
210
|
+
*/
|
|
211
|
+
disabled?: boolean | undefined;
|
|
212
|
+
/**
|
|
213
|
+
* The item was chosen (click, Enter or Space). Then the menu closes and focus returns to the
|
|
214
|
+
* trigger; `event.preventDefault()` keeps it open.
|
|
215
|
+
*/
|
|
216
|
+
onSelect?: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined;
|
|
217
|
+
/** Ref to the `<button>`. */
|
|
218
|
+
ref?: Ref<HTMLButtonElement> | undefined;
|
|
219
|
+
}
|
|
220
|
+
/** Regular item (`role="menuitem"`): an action. */
|
|
221
|
+
interface MenuItemActionProps extends MenuItemBaseProps {
|
|
222
|
+
type?: 'item' | undefined;
|
|
223
|
+
selected?: undefined;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Selectable item: Material 3's "selected". `radio` is one option among several (`menuitemradio`,
|
|
227
|
+
* like Compose's `SelectableDropdownMenuItem`, role RadioButton); `checkbox` toggles on its own
|
|
228
|
+
* (`menuitemcheckbox`, like `CheckableDropdownMenuItem`, role Checkbox). `selected` is announced as
|
|
229
|
+
* `aria-checked`.
|
|
230
|
+
*/
|
|
231
|
+
interface MenuItemSelectableProps extends MenuItemBaseProps {
|
|
232
|
+
type: 'radio' | 'checkbox';
|
|
233
|
+
selected: boolean;
|
|
234
|
+
}
|
|
235
|
+
export type MenuItemProps = MenuItemActionProps | MenuItemSelectableProps;
|
|
236
|
+
/**
|
|
237
|
+
* Menu item, on a `<button>` out of the Tab order (`tabindex="-1"`): focus moves with the arrows.
|
|
238
|
+
* 44 px tall with 2 px above and below (48 px rows), state layer, ripple and focus ring.
|
|
239
|
+
*
|
|
240
|
+
* The text goes as a child; the leading icon, in `MenuItemLeading`, and the trailing content
|
|
241
|
+
* (shortcut, icon), in `MenuItemTrailing`. If the text mixes elements (`Open <b>all</b>`), wrap it
|
|
242
|
+
* in a `<span>`.
|
|
243
|
+
*
|
|
244
|
+
* ```tsx
|
|
245
|
+
* <MenuItem type="radio" selected={sort === 'name'} onSelect={() => setSort('name')}>
|
|
246
|
+
* <MenuItemLeading>{sort === 'name' ? <CheckIcon /> : null}</MenuItemLeading>
|
|
247
|
+
* Name
|
|
248
|
+
* </MenuItem>
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export declare function MenuItem({ type, selected, disabled, onSelect, onClick, className, children, ...props }: MenuItemProps): import("react").JSX.Element;
|
|
252
|
+
export interface MenuItemSupportingProps extends HTMLAttributes<HTMLSpanElement> {
|
|
253
|
+
/** Ref to the text element. */
|
|
254
|
+
ref?: Ref<HTMLSpanElement> | undefined;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Supporting text of a `MenuItem`, under its label (Body Medium, `on-surface-variant`; Compose's
|
|
258
|
+
* `supportingText`). The item's accessible name stays its label: this text is its description
|
|
259
|
+
* (`aria-describedby`), read after the name. The item grows from 44 to 64 px with 12 px above and
|
|
260
|
+
* below. It goes under the label even if written before it.
|
|
261
|
+
*
|
|
262
|
+
* ```tsx
|
|
263
|
+
* <MenuItem>
|
|
264
|
+
* <MenuItemLeading><EditIcon /></MenuItemLeading>
|
|
265
|
+
* Edit
|
|
266
|
+
* <MenuItemSupporting>Change the title and the cover</MenuItemSupporting>
|
|
267
|
+
* </MenuItem>
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare function MenuItemSupporting({ id, className, ...props }: MenuItemSupportingProps): import("react").JSX.Element;
|
|
271
|
+
export interface MenuGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
272
|
+
/** Ref to the group element. */
|
|
273
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* A group of items inside `MenuContent` (`role="group"`, named by its `MenuGroupLabel`), drawn as
|
|
277
|
+
* its own surface, like Compose's `DropdownMenuGroup`: with groups, `MenuContent` paints no
|
|
278
|
+
* background or shadow and each group does, 2 px apart, with large outer corners and small inner
|
|
279
|
+
* ones by position (first, middle, last; one group alone keeps the menu's shape). Inside a group the
|
|
280
|
+
* items keep the menu's look, and the keyboard moves through the items of all groups as one list.
|
|
281
|
+
*
|
|
282
|
+
* Put every item of the menu in a group: an item outside one would sit on no surface (development
|
|
283
|
+
* builds warn with `MK_MENU_ITEM_OUTSIDE_GROUP`).
|
|
284
|
+
*
|
|
285
|
+
* ```tsx
|
|
286
|
+
* <MenuContent>
|
|
287
|
+
* <MenuGroup>
|
|
288
|
+
* <MenuGroupLabel>Edit</MenuGroupLabel>
|
|
289
|
+
* <MenuItem>Cut</MenuItem>
|
|
290
|
+
* <MenuItem>Copy</MenuItem>
|
|
291
|
+
* </MenuGroup>
|
|
292
|
+
* <MenuGroup>
|
|
293
|
+
* <MenuItem>Settings</MenuItem>
|
|
294
|
+
* </MenuGroup>
|
|
295
|
+
* </MenuContent>
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
export declare function MenuGroup({ className, ...props }: MenuGroupProps): import("react").JSX.Element;
|
|
299
|
+
export interface MenuGroupLabelProps extends HTMLAttributes<HTMLDivElement> {
|
|
300
|
+
/** Ref to the label element. */
|
|
301
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The heading of a `MenuGroup` (the kit's section label: 32 px, Label Large, `on-surface-variant`,
|
|
305
|
+
* or `on-tertiary-container` in a `vibrant` menu). It names the group (`aria-labelledby`), without
|
|
306
|
+
* passing ids. It is not focusable, and the arrows and the typeahead skip it.
|
|
307
|
+
*
|
|
308
|
+
* ```tsx
|
|
309
|
+
* <MenuGroup><MenuGroupLabel>Sort by</MenuGroupLabel>…</MenuGroup>
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
export declare function MenuGroupLabel({ className, ...props }: MenuGroupLabelProps): import("react").JSX.Element;
|
|
313
|
+
export {};
|