@ufoui/core 0.0.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/LICENSE +150 -0
- package/README.md +37 -0
- package/TRADEMARK.md +10 -0
- package/components/article/article.d.ts +25 -0
- package/components/aside/aside.d.ts +27 -0
- package/components/avatar/avatar.d.ts +35 -0
- package/components/badge/badge.d.ts +57 -0
- package/components/base/boxBase/boxBase.d.ts +126 -0
- package/components/base/buttonBase/buttonBase.d.ts +126 -0
- package/components/base/checkboxBase/checkboxBase.d.ts +124 -0
- package/components/base/dialogBase/dialog.d.ts +35 -0
- package/components/base/fieldBase/fieldBase.d.ts +50 -0
- package/components/base/inlineBase/inlineBase.d.ts +62 -0
- package/components/button/button.d.ts +24 -0
- package/components/card/card.d.ts +15 -0
- package/components/checkbox/checkbox.d.ts +31 -0
- package/components/chip/chip.d.ts +7 -0
- package/components/content/content.d.ts +28 -0
- package/components/dateInput/dateInput.d.ts +2 -0
- package/components/dateTimeInput/dateTimeInput.d.ts +2 -0
- package/components/dialog/dialogActions.d.ts +15 -0
- package/components/dialog/dialogContent.d.ts +9 -0
- package/components/dialog/dialogTitle.d.ts +16 -0
- package/components/div/div.d.ts +29 -0
- package/components/divider/divider.d.ts +70 -0
- package/components/divider/divider.guards.d.ts +15 -0
- package/components/emailInput/emailInput.d.ts +2 -0
- package/components/fab/fab.d.ts +29 -0
- package/components/fieldset/fieldset.d.ts +45 -0
- package/components/flex/flex.d.ts +36 -0
- package/components/footer/footer.d.ts +27 -0
- package/components/grid/grid.d.ts +38 -0
- package/components/header/header.d.ts +27 -0
- package/components/iconButton/iconButton.d.ts +27 -0
- package/components/listItem/listItem.d.ts +179 -0
- package/components/listItem/listItem.guards.d.ts +15 -0
- package/components/main/main.d.ts +27 -0
- package/components/menu/menu.d.ts +177 -0
- package/components/menu/menu.guards.d.ts +15 -0
- package/components/menuItem/menuItem.d.ts +179 -0
- package/components/menuItem/menuItem.guards.d.ts +15 -0
- package/components/nav/nav.d.ts +27 -0
- package/components/numberInput/numberInput.d.ts +2 -0
- package/components/option/option.d.ts +6 -0
- package/components/option/option.guards.d.ts +16 -0
- package/components/radio/radio.d.ts +31 -0
- package/components/radiogroup/radioGroup.d.ts +47 -0
- package/components/section/section.d.ts +27 -0
- package/components/select/select.d.ts +32 -0
- package/components/spinner/spinner.d.ts +7 -0
- package/components/switch/switch.d.ts +102 -0
- package/components/telInput/telInput.d.ts +2 -0
- package/components/textField/textField.d.ts +9 -0
- package/components/themeProvider/themeProvider.d.ts +54 -0
- package/components/timeInput/timeInput.d.ts +2 -0
- package/components/toggleButton/toggleButton.d.ts +6 -0
- package/components/tooltip/tooltip.d.ts +8 -0
- package/components/urlInput/urlInput.d.ts +2 -0
- package/context/fieldsetContext.d.ts +22 -0
- package/context/radioGroupContext.d.ts +28 -0
- package/context/themeContext.d.ts +61 -0
- package/hooks/useAnimate.d.ts +55 -0
- package/hooks/useClickOutside.d.ts +36 -0
- package/hooks/useEscapeHandler.d.ts +1 -0
- package/hooks/useFocusState.d.ts +16 -0
- package/hooks/useFocusVisible.d.ts +20 -0
- package/hooks/useTheme.d.ts +12 -0
- package/index.css +1 -0
- package/index.d.ts +53 -0
- package/index.mjs +3300 -0
- package/internal/inlineTooltip/inlineTooltip.d.ts +11 -0
- package/internal/inlineTooltip/inlineTooltip2.d.ts +10 -0
- package/internal/inlineTooltip/inlineTooltipManager.d.ts +12 -0
- package/package.json +38 -0
- package/types/index.d.ts +2 -0
- package/types/motion.d.ts +17 -0
- package/types/theme.d.ts +246 -0
- package/utils/calculateFloatingPosition.d.ts +68 -0
- package/utils/color.d.ts +415 -0
- package/utils/generateMaterialColors.d.ts +31 -0
- package/utils/generateSchemes.d.ts +32 -0
- package/utils/inputhMethod.d.ts +17 -0
- package/utils/utils.d.ts +202 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BoxBaseProps } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link Footer}.
|
|
4
|
+
* Extends {@link BoxBaseProps} except for `elementClass` and `component`.
|
|
5
|
+
*
|
|
6
|
+
* @category Box
|
|
7
|
+
*/
|
|
8
|
+
export type FooterProps = Omit<BoxBaseProps, 'elementClass' | 'component'>;
|
|
9
|
+
/**
|
|
10
|
+
* Semantic layout wrapper for the native `<footer>` element.
|
|
11
|
+
*
|
|
12
|
+
* Built on top of {@link BoxBase}, inheriting its layout and styling props.
|
|
13
|
+
* Defaults to a row layout (`direction="row"`) and applies
|
|
14
|
+
* the semantic UUI class `"uui-footer"`.
|
|
15
|
+
*
|
|
16
|
+
* Use for closing sections, legal notices, or persistent bottom content.
|
|
17
|
+
*
|
|
18
|
+
* @function
|
|
19
|
+
* @param props - All layout and style props inherited from {@link BoxBase}.
|
|
20
|
+
* @example
|
|
21
|
+
* <Footer elevation={1} shape="rounded">
|
|
22
|
+
* © 2025 My Company
|
|
23
|
+
* </Footer>
|
|
24
|
+
*
|
|
25
|
+
* @category Box
|
|
26
|
+
*/
|
|
27
|
+
export declare const Footer: import('react').ForwardRefExoticComponent<FooterProps & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BoxBaseProps } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for the {@link Grid} component.
|
|
4
|
+
*
|
|
5
|
+
* Extends {@link BoxBaseProps} with flex-related props removed.
|
|
6
|
+
* Intended for CSS Grid–only layouts.
|
|
7
|
+
*
|
|
8
|
+
* @category Grid
|
|
9
|
+
*/
|
|
10
|
+
export type GridProps = Omit<BoxBaseProps, 'elementClass' | 'type' | 'direction' | 'wrap'>;
|
|
11
|
+
/**
|
|
12
|
+
* Grid layout container.
|
|
13
|
+
*
|
|
14
|
+
* Explicit CSS Grid wrapper used for two-dimensional layouts.
|
|
15
|
+
* Use this component when working with grid semantics such as
|
|
16
|
+
* columns, rows, gaps, and auto-placement flow.
|
|
17
|
+
*
|
|
18
|
+
* Built on top of {@link BoxBase} and exposes only grid-relevant layout props.
|
|
19
|
+
*
|
|
20
|
+
* @category Grid
|
|
21
|
+
* @function
|
|
22
|
+
* @param props - Grid layout props inherited from {@link BoxBase}.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* <Grid cols={3} gap={16}>
|
|
26
|
+
* <Item />
|
|
27
|
+
* <Item />
|
|
28
|
+
* <Item />
|
|
29
|
+
* </Grid>
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* <Grid rows="auto 1fr auto" gapY={8}>
|
|
33
|
+
* <Header />
|
|
34
|
+
* <Content />
|
|
35
|
+
* <Footer />
|
|
36
|
+
* </Grid>
|
|
37
|
+
*/
|
|
38
|
+
export declare const Grid: import('react').ForwardRefExoticComponent<GridProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BoxBaseProps } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link Header}.
|
|
4
|
+
* Extends {@link BoxBaseProps} except for `elementClass` and `component`.
|
|
5
|
+
*
|
|
6
|
+
* @category Box
|
|
7
|
+
*/
|
|
8
|
+
export type HeaderProps = Omit<BoxBaseProps, 'elementClass' | 'component'>;
|
|
9
|
+
/**
|
|
10
|
+
* Semantic layout wrapper for the native `<header>` element.
|
|
11
|
+
*
|
|
12
|
+
* Built on top of {@link BoxBase}, inheriting its layout and styling props.
|
|
13
|
+
* Defaults to a row layout (`direction="row"`) and applies
|
|
14
|
+
* the semantic UUI class `"uui-header"`.
|
|
15
|
+
*
|
|
16
|
+
* Use for introductory or navigational top-level content.
|
|
17
|
+
*
|
|
18
|
+
* @function
|
|
19
|
+
* @param props - All layout and style props inherited from {@link BoxBase}.
|
|
20
|
+
* @example
|
|
21
|
+
* <Header elevation={1} shape="rounded">
|
|
22
|
+
* <Logo />
|
|
23
|
+
* </Header>
|
|
24
|
+
*
|
|
25
|
+
* @category Box
|
|
26
|
+
*/
|
|
27
|
+
export declare const Header: import('react').ForwardRefExoticComponent<HeaderProps & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ButtonBaseProps } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link IconButton}.
|
|
4
|
+
* Extends {@link ButtonBaseProps} except for text and trailing content.
|
|
5
|
+
*
|
|
6
|
+
* @category IconButton
|
|
7
|
+
*/
|
|
8
|
+
export type IconButtonProps = Omit<ButtonBaseProps, 'elementClass' | 'endIcon' | 'trailing'>;
|
|
9
|
+
/**
|
|
10
|
+
* Icon-only button used for compact or secondary actions.
|
|
11
|
+
*
|
|
12
|
+
* Use when an action is represented by an icon instead of text.
|
|
13
|
+
* An accessible label (`aria-label` or `label`) is required.
|
|
14
|
+
*
|
|
15
|
+
* @category IconButton
|
|
16
|
+
* @function
|
|
17
|
+
* @param props - All icon button props inherited from {@link ButtonBase}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <IconButton label="Add" icon={<AddIcon />} />
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <IconButton aria-label="Close">
|
|
24
|
+
* <CloseIcon />
|
|
25
|
+
* </IconButton>
|
|
26
|
+
*/
|
|
27
|
+
export declare const IconButton: import('react').ForwardRefExoticComponent<IconButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { default as React, HTMLProps, ReactNode } from 'react';
|
|
2
|
+
import { ElementDensity, ElementFocusEffect, ElementFont, ElementSelectedEffect, ElementShape, ElementTouchEffect } from '../utils';
|
|
3
|
+
import { MenuVariant } from '../menu/menu';
|
|
4
|
+
import { SurfaceColor } from '../../utils/color';
|
|
5
|
+
/**
|
|
6
|
+
* Visual variant of a ListItem.
|
|
7
|
+
*
|
|
8
|
+
* Inherited from {@link MenuVariant}.
|
|
9
|
+
*
|
|
10
|
+
* @category ListItem
|
|
11
|
+
*/
|
|
12
|
+
export type ListItemVariant = MenuVariant;
|
|
13
|
+
/**
|
|
14
|
+
* Defines the behavioral type of a ListItem.
|
|
15
|
+
*
|
|
16
|
+
* - `item` – simple action item
|
|
17
|
+
* - `checkbox` – toggleable multiple-selection item
|
|
18
|
+
* - `radio` – mutually exclusive selection item
|
|
19
|
+
* - `option` – selectable option item
|
|
20
|
+
*
|
|
21
|
+
* @category ListItem
|
|
22
|
+
*/
|
|
23
|
+
export type ListItemType = 'item' | 'checkbox' | 'radio' | 'option';
|
|
24
|
+
/**
|
|
25
|
+
* Change event payload for selectable menu items
|
|
26
|
+
* (checkbox, radio and option).
|
|
27
|
+
*
|
|
28
|
+
* @category ListItem
|
|
29
|
+
*/
|
|
30
|
+
export interface ListItemChangeEvent {
|
|
31
|
+
/** Checkbox or radio checked state. */
|
|
32
|
+
checked?: boolean;
|
|
33
|
+
/** Item name identifier. */
|
|
34
|
+
name?: string;
|
|
35
|
+
/** Selection state for option items. */
|
|
36
|
+
selected?: boolean;
|
|
37
|
+
/** Item value identifier. */
|
|
38
|
+
value?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Props for the {@link ListItem} component.
|
|
42
|
+
*
|
|
43
|
+
* @category ListItem
|
|
44
|
+
*/
|
|
45
|
+
export interface ListItemProps extends Omit<HTMLProps<HTMLDivElement>, 'ref' | 'onChange'> {
|
|
46
|
+
/** Marks item as active (roving focus). */
|
|
47
|
+
active?: boolean;
|
|
48
|
+
/** Badge content rendered at the end. */
|
|
49
|
+
badge?: ReactNode;
|
|
50
|
+
/** Checked state for checkbox or radio items. */
|
|
51
|
+
checked?: boolean;
|
|
52
|
+
/** Icon shown when item is checked. */
|
|
53
|
+
checkedIcon?: ReactNode;
|
|
54
|
+
/** Item content or nested submenu. */
|
|
55
|
+
children?: ReactNode;
|
|
56
|
+
/** Base surface color of the item. */
|
|
57
|
+
color?: SurfaceColor;
|
|
58
|
+
/** Density preset controlling spacing. */
|
|
59
|
+
density?: ElementDensity;
|
|
60
|
+
/** Secondary description text. */
|
|
61
|
+
description?: string;
|
|
62
|
+
/** Text color of the description. */
|
|
63
|
+
descriptionColor?: SurfaceColor;
|
|
64
|
+
/** Font token applied to the description text. */
|
|
65
|
+
descriptionFont?: ElementFont;
|
|
66
|
+
/** Disables interactions and focus. */
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
/** Icon rendered at the end (alias for `trailing`). */
|
|
69
|
+
endIcon?: ReactNode;
|
|
70
|
+
/** Whether a nested submenu is expanded. */
|
|
71
|
+
expanded?: boolean;
|
|
72
|
+
/** Reserves leading slot even without an icon. */
|
|
73
|
+
fixedLeading?: boolean;
|
|
74
|
+
/** Visual focus effects applied when active. */
|
|
75
|
+
focusEffects?: ElementFocusEffect[];
|
|
76
|
+
/** Forces focus-visible styling. */
|
|
77
|
+
focusVisible?: boolean;
|
|
78
|
+
/** Alias for labelFont. */
|
|
79
|
+
font?: ElementFont;
|
|
80
|
+
/** Enables horizontal layout mode. */
|
|
81
|
+
horizontal?: boolean;
|
|
82
|
+
/** Icon rendered at the start (alias for `leading`). */
|
|
83
|
+
icon?: ReactNode;
|
|
84
|
+
/** Primary label text. */
|
|
85
|
+
label?: string;
|
|
86
|
+
/** Text color of the label. */
|
|
87
|
+
labelColor?: SurfaceColor;
|
|
88
|
+
/** Font token applied to the label text. */
|
|
89
|
+
labelFont?: ElementFont;
|
|
90
|
+
/** Custom leading content. */
|
|
91
|
+
leading?: ReactNode;
|
|
92
|
+
/** Item name used in change events. */
|
|
93
|
+
name?: string;
|
|
94
|
+
/** Change handler for checkbox, radio and option items. */
|
|
95
|
+
onChange?: (e: ListItemChangeEvent) => void;
|
|
96
|
+
/** Click handler for action items. */
|
|
97
|
+
onClick?: React.MouseEventHandler<HTMLDivElement>;
|
|
98
|
+
/** Selected state for option items. */
|
|
99
|
+
selected?: boolean;
|
|
100
|
+
/** Background color used when selected. */
|
|
101
|
+
selectedColor?: SurfaceColor;
|
|
102
|
+
/** Visual effects applied when selected. */
|
|
103
|
+
selectedEffects?: ElementSelectedEffect[];
|
|
104
|
+
/** Shape token applied to the item. */
|
|
105
|
+
shape?: ElementShape;
|
|
106
|
+
/** Keyboard shortcut label. */
|
|
107
|
+
shortcut?: string;
|
|
108
|
+
/** Text color of the shortcut label. */
|
|
109
|
+
shortcutColor?: SurfaceColor;
|
|
110
|
+
/** Font token applied to the shortcut text. */
|
|
111
|
+
shortcutFont?: ElementFont;
|
|
112
|
+
/** Overrides automatic text color. */
|
|
113
|
+
textColor?: SurfaceColor;
|
|
114
|
+
/** Touch and click feedback effects. */
|
|
115
|
+
touchEffects?: ElementTouchEffect[];
|
|
116
|
+
/** Custom trailing content. */
|
|
117
|
+
trailing?: ReactNode;
|
|
118
|
+
/** Item behavior type. */
|
|
119
|
+
type?: ListItemType;
|
|
120
|
+
/** Icon shown when item is unchecked. */
|
|
121
|
+
uncheckedIcon?: ReactNode;
|
|
122
|
+
/** Item value used in change events. */
|
|
123
|
+
value?: string;
|
|
124
|
+
/** Visual variant inherited from Menu. */
|
|
125
|
+
variant?: ListItemVariant;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Internal props injected by Menu.
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
* @category ListItem
|
|
132
|
+
*/
|
|
133
|
+
export interface ListItemInternalProps {
|
|
134
|
+
/** Disables pointer and keyboard interactions. */
|
|
135
|
+
__interactionsDisabled?: boolean;
|
|
136
|
+
/** Item index inside the parent menu. */
|
|
137
|
+
__index?: number;
|
|
138
|
+
/** Index exposed for DOM queries. */
|
|
139
|
+
'data-menu-index'?: number;
|
|
140
|
+
/** ARIA role family inherited from parent container. */
|
|
141
|
+
roleFamily?: 'menu' | 'listbox' | 'command' | 'toolbar';
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* **ListItem** - single interactive item inside a {@link Menu}.
|
|
145
|
+
*
|
|
146
|
+
* Represents an action, checkbox, radio item or selectable option.
|
|
147
|
+
* Supports icons, badges, shortcuts, descriptions and nested submenus.
|
|
148
|
+
*
|
|
149
|
+
* Keyboard interaction and focus are handled by the parent Menu.
|
|
150
|
+
*
|
|
151
|
+
* @param props
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```tsx
|
|
155
|
+
* <ListItem label="Open" onClick={handleOpen} />
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* <ListItem
|
|
161
|
+
* type="checkbox"
|
|
162
|
+
* label="Show grid"
|
|
163
|
+
* checked={enabled}
|
|
164
|
+
* onChange={() => setEnabled(v => !v)}
|
|
165
|
+
* />
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* <ListItem label="More">
|
|
171
|
+
* <Menu>
|
|
172
|
+
* <ListItem label="Sub item" />
|
|
173
|
+
* </Menu>
|
|
174
|
+
* </ListItem>
|
|
175
|
+
* ```
|
|
176
|
+
* @function
|
|
177
|
+
* @category ListItem
|
|
178
|
+
*/
|
|
179
|
+
export declare const ListItem: React.ForwardRefExoticComponent<ListItemProps & ListItemInternalProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React, ReactElement } from 'react';
|
|
2
|
+
import { ListItemInternalProps, ListItemProps } from './listItem';
|
|
3
|
+
export declare const IS_LIST_ITEM: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard that checks whether a React node is a MenuItem component.
|
|
6
|
+
*
|
|
7
|
+
* Identifies MenuItem elements by the internal {@link IS_LIST_ITEM} symbol
|
|
8
|
+
* attached to the component type.
|
|
9
|
+
*
|
|
10
|
+
* @param el - React node to test.
|
|
11
|
+
* @returns `true` if the node is a MenuItem element.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function isListItem(el: React.ReactNode): el is ReactElement<ListItemProps & ListItemInternalProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BoxBaseProps } from '../core';
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link Main}.
|
|
4
|
+
* Extends {@link BoxBaseProps} except for `elementClass` and `component`.
|
|
5
|
+
*
|
|
6
|
+
* @category Box
|
|
7
|
+
*/
|
|
8
|
+
export type MainProps = Omit<BoxBaseProps, 'elementClass' | 'component'>;
|
|
9
|
+
/**
|
|
10
|
+
* Semantic layout wrapper for the native `<main>` element.
|
|
11
|
+
*
|
|
12
|
+
* Built on top of {@link BoxBase}, inheriting its layout and styling props.
|
|
13
|
+
* Defaults to a column layout (`direction="col"`) and applies
|
|
14
|
+
* the semantic UUI class `"uui-main"`.
|
|
15
|
+
*
|
|
16
|
+
* Use for the primary content region of an application or document.
|
|
17
|
+
*
|
|
18
|
+
* @function
|
|
19
|
+
* @param props - All layout and style props inherited from {@link BoxBase}.
|
|
20
|
+
* @example
|
|
21
|
+
* <Main elevation={1} shape="rounded">
|
|
22
|
+
* <Section />
|
|
23
|
+
* </Main>
|
|
24
|
+
*
|
|
25
|
+
* @category Box
|
|
26
|
+
*/
|
|
27
|
+
export declare const Main: import('react').ForwardRefExoticComponent<MainProps & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { default as React, HTMLAttributes, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { ElementAlign, ElementBorder, ElementDensity, ElementElevation, ElementFocusEffect, ElementFont, ElementSelectedEffect, ElementShape, ElementTouchEffect } from '../utils';
|
|
3
|
+
import { MotionAnimation, MotionStyle } from '../types';
|
|
4
|
+
import { BorderColor, SurfaceColor } from '../../utils/color';
|
|
5
|
+
import { ElementFloatingMode } from '../../utils/calculateFloatingPosition';
|
|
6
|
+
/**
|
|
7
|
+
* Visual style preset for the Menu component.
|
|
8
|
+
*
|
|
9
|
+
* - `modern` – MD3 menu (expressive).
|
|
10
|
+
* - `classic` – MD3 menu (baseline).
|
|
11
|
+
*
|
|
12
|
+
* @category Menu
|
|
13
|
+
*/
|
|
14
|
+
export type MenuVariant = 'modern' | 'classic';
|
|
15
|
+
/**
|
|
16
|
+
* Animation setting for the Menu component.
|
|
17
|
+
*
|
|
18
|
+
* - `auto` – resolves to the default animation (`"scale"`).
|
|
19
|
+
* - `none` – disables all animations.
|
|
20
|
+
* - `MotionAnimation` – any supported motion animation type.
|
|
21
|
+
*
|
|
22
|
+
* @category Menu
|
|
23
|
+
*/
|
|
24
|
+
export type MenuAnimation = 'auto' | 'none' | MotionAnimation;
|
|
25
|
+
/**
|
|
26
|
+
* Props for the {@link Menu} component.
|
|
27
|
+
*
|
|
28
|
+
* @category Menu
|
|
29
|
+
*/
|
|
30
|
+
export interface MenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color'> {
|
|
31
|
+
/** Reference to the trigger element used for positioning. */
|
|
32
|
+
anchorRef?: RefObject<HTMLElement> | null;
|
|
33
|
+
/** Animation setting (`auto`, `none`, or motion animation type). */
|
|
34
|
+
animation?: MenuAnimation;
|
|
35
|
+
/** Border width (0–4). */
|
|
36
|
+
border?: ElementBorder;
|
|
37
|
+
/** Border color token. */
|
|
38
|
+
borderColor?: BorderColor;
|
|
39
|
+
/** Icon used for checked checkbox items. */
|
|
40
|
+
checkedIcon?: ReactNode;
|
|
41
|
+
/** Menu items. Must be `MenuItem` or compatible custom nodes. */
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
/** Whether menu closes automatically on item change. */
|
|
44
|
+
closeOnChange?: boolean;
|
|
45
|
+
/** Surface background token for the menu container. */
|
|
46
|
+
color?: SurfaceColor;
|
|
47
|
+
/** Density preset (`comfortable`, `compact`, `dense`). */
|
|
48
|
+
density?: ElementDensity;
|
|
49
|
+
/** Text color for item descriptions. */
|
|
50
|
+
descriptionColor?: SurfaceColor;
|
|
51
|
+
/** Font token applied to menu item descriptions. */
|
|
52
|
+
descriptionFont?: ElementFont;
|
|
53
|
+
/** Enables docked positioning mode. */
|
|
54
|
+
docked?: boolean;
|
|
55
|
+
/** Elevation level of the menu surface when docked. */
|
|
56
|
+
dockedElevation?: ElementElevation;
|
|
57
|
+
/** Duration (ms) of open/close animation. Default: 250 */
|
|
58
|
+
duration?: number;
|
|
59
|
+
/** Elevation level of the menu surface. */
|
|
60
|
+
elevation?: ElementElevation;
|
|
61
|
+
/** Reserves leading slot for all menu items. */
|
|
62
|
+
fixedLeading?: boolean;
|
|
63
|
+
/** Floating behaviour mode (`menu`, `submenu`, `dropdown`, `tooltip`). */
|
|
64
|
+
floatingMode?: ElementFloatingMode;
|
|
65
|
+
/** Alias for labelFont */
|
|
66
|
+
font?: ElementFont;
|
|
67
|
+
/** Enables horizontal menu layout. */
|
|
68
|
+
horizontal?: boolean;
|
|
69
|
+
/** Focus effects applied to menu items. */
|
|
70
|
+
itemFocusEffects?: ElementFocusEffect[];
|
|
71
|
+
/** Selected state effects applied to menu items. */
|
|
72
|
+
itemSelectedEffects?: ElementSelectedEffect[];
|
|
73
|
+
/** Touch and click feedback effects for menu items. */
|
|
74
|
+
itemTouchEffects?: ElementTouchEffect[];
|
|
75
|
+
/** Text color for item labels. */
|
|
76
|
+
labelColor?: SurfaceColor;
|
|
77
|
+
/** Font token applied to menu item primary labels. */
|
|
78
|
+
labelFont?: ElementFont;
|
|
79
|
+
/** Motion style variant (expressive or regular). */
|
|
80
|
+
motionStyle?: MotionStyle;
|
|
81
|
+
/** Offset (px) between menu and anchor. @default 4 */
|
|
82
|
+
offset?: number;
|
|
83
|
+
/** Callback fired when the menu requests to close. */
|
|
84
|
+
onClose?: () => void;
|
|
85
|
+
/** Controls visibility of the menu. */
|
|
86
|
+
open?: boolean;
|
|
87
|
+
/** Opens the menu on pointer hover. */
|
|
88
|
+
openOnHover?: boolean;
|
|
89
|
+
/** Preferred placement relative to the anchor. */
|
|
90
|
+
placement?: ElementAlign;
|
|
91
|
+
/** Icon used for checked radio items. */
|
|
92
|
+
radioCheckedIcon?: ReactNode;
|
|
93
|
+
/** Icon used for unchecked radio items. */
|
|
94
|
+
radioUncheckedIcon?: ReactNode;
|
|
95
|
+
/** Background color used for selected items. */
|
|
96
|
+
selectedColor?: SurfaceColor;
|
|
97
|
+
/** Shape token controlling menu corner rounding. */
|
|
98
|
+
shape?: ElementShape;
|
|
99
|
+
/** Text color for shortcut labels. */
|
|
100
|
+
shortcutColor?: SurfaceColor;
|
|
101
|
+
/** Font token applied to menu item shortcut labels. */
|
|
102
|
+
shortcutFont?: ElementFont;
|
|
103
|
+
/** Overrides automatic text color. */
|
|
104
|
+
textColor?: SurfaceColor;
|
|
105
|
+
/** Icon used for unchecked checkbox items. */
|
|
106
|
+
uncheckedIcon?: ReactNode;
|
|
107
|
+
/** Visual preset (`modern` = MD3 expressive, `classic` = MD3 baseline). */
|
|
108
|
+
variant?: MenuVariant;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Internal props used for nested and recursive menu rendering.
|
|
112
|
+
*
|
|
113
|
+
* These props are injected automatically by the Menu system
|
|
114
|
+
* and must not be provided manually.
|
|
115
|
+
*
|
|
116
|
+
* @category Menu
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
export interface MenuInternalProps {
|
|
120
|
+
/** Closes the root menu instance. */
|
|
121
|
+
__closeRootMenu?: () => void;
|
|
122
|
+
/** Shared group identifier for nested menus. */
|
|
123
|
+
__groupId?: string;
|
|
124
|
+
/** Horizontal nesting depth for keyboard navigation. */
|
|
125
|
+
__horizontalDepth?: number;
|
|
126
|
+
/** Nesting depth of the menu tree (0 = root). */
|
|
127
|
+
__level?: number;
|
|
128
|
+
/** Handles horizontal navigation between sibling menus. */
|
|
129
|
+
__navigateHorizontal?: (goNext: boolean) => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* **Menu** - menu component with optional docking and multi-level submenus.
|
|
133
|
+
*
|
|
134
|
+
* Renders a menu component following the MD3 specification.
|
|
135
|
+
* The menu can be positioned relative to an anchor element using floating
|
|
136
|
+
* layout logic or rendered in a docked mode without floating positioning.
|
|
137
|
+
*
|
|
138
|
+
* Supports nested submenus, keyboard navigation,
|
|
139
|
+
* motion configuration, density presets, elevation, shape, borders
|
|
140
|
+
* and two MD3 visual variants (`modern`, `classic`).
|
|
141
|
+
*
|
|
142
|
+
*
|
|
143
|
+
* @param props
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```tsx
|
|
147
|
+
* <Menu open anchorRef={buttonRef}>
|
|
148
|
+
* <MenuItem label="Open" />
|
|
149
|
+
* <Divider/>
|
|
150
|
+
* <MenuItem label="Save" />
|
|
151
|
+
* </Menu>
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* <Menu open docked>
|
|
157
|
+
* <MenuItem label="Settings" />
|
|
158
|
+
* <MenuItem label="Logout" />
|
|
159
|
+
* </Menu>
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```tsx
|
|
164
|
+
* <Menu open>
|
|
165
|
+
* <MenuItem label="View">
|
|
166
|
+
* <Menu>
|
|
167
|
+
* <MenuItem label="Zoom in" />
|
|
168
|
+
* <MenuItem label="Zoom out" />
|
|
169
|
+
* </Menu>
|
|
170
|
+
* </MenuItem>
|
|
171
|
+
* </Menu>
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @category Menu
|
|
175
|
+
* @function
|
|
176
|
+
*/
|
|
177
|
+
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & MenuInternalProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React, ReactElement } from 'react';
|
|
2
|
+
import { MenuInternalProps, MenuProps } from '../core';
|
|
3
|
+
export declare const IS_MENU: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Type guard that checks whether a React node is a Menu component.
|
|
6
|
+
*
|
|
7
|
+
* Identifies Menu elements by the internal {@link IS_MENU} symbol
|
|
8
|
+
* attached to the component type.
|
|
9
|
+
*
|
|
10
|
+
* @param el - React node to test.
|
|
11
|
+
* @returns `true` if the node is a Menu element.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function isMenu(el: React.ReactNode): el is ReactElement<MenuProps & MenuInternalProps>;
|