@moderneinc/design-system-components 6.0.1-next.ba17df → 6.0.1-next.d0f7d0
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/dist/MenuItem/MenuItem.d.ts +30 -11
- package/dist/index.d.ts +30 -11
- package/dist/index.esm.js +11 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -6
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -19,15 +19,26 @@ type ModMenuItemOwnProps = {
|
|
|
19
19
|
*/
|
|
20
20
|
secondaryText?: string;
|
|
21
21
|
/**
|
|
22
|
-
* URL to navigate to.
|
|
23
|
-
* MUI
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* URL to navigate to. Supplying `href` roots the item at an anchor instead of the `li`
|
|
23
|
+
* MUI defaults to, so it navigates and offers the browser's open-in-new-tab on middle-
|
|
24
|
+
* or right-click. Pass `component` explicitly (e.g. a router link such as Next.js
|
|
25
|
+
* `Link`) to override that default.
|
|
26
|
+
*
|
|
27
|
+
* The anchor then sits directly inside `MenuList`'s `ul`. `role="menuitem"` keeps that
|
|
28
|
+
* correct for ARIA, but `ul`'s content model permits only `li`, so HTML validators and
|
|
29
|
+
* axe-core's `list` rule flag it. This is the pattern MUI's own docs use for link menu
|
|
30
|
+
* items, and what `ModListItem` already produces inside `List`.
|
|
26
31
|
*/
|
|
27
32
|
href?: string;
|
|
28
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Anchor `target`, e.g. `_blank`. Only meaningful with `href` — without one the item
|
|
35
|
+
* roots at `li` and this renders as an inert attribute, the same trap as #722.
|
|
36
|
+
*/
|
|
29
37
|
target?: string;
|
|
30
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Anchor `rel`, e.g. `noopener noreferrer`. Only meaningful with `href` — without one
|
|
40
|
+
* the item roots at `li` and this renders as an inert attribute.
|
|
41
|
+
*/
|
|
31
42
|
rel?: string;
|
|
32
43
|
/**
|
|
33
44
|
* Menu item content (text label)
|
|
@@ -35,6 +46,14 @@ type ModMenuItemOwnProps = {
|
|
|
35
46
|
children?: ReactNode;
|
|
36
47
|
};
|
|
37
48
|
export type ModMenuItemProps<C extends ElementType = typeof MenuItem> = ModMenuItemOwnProps & Omit<ComponentPropsWithoutRef<C>, keyof ModMenuItemOwnProps> & {
|
|
49
|
+
/**
|
|
50
|
+
* Root element or component. Naming one bypasses the `href` → anchor default, so pass
|
|
51
|
+
* a link component (`'a'`, Next.js `Link`, …) if the item still has to navigate:
|
|
52
|
+
* `component="div"` with an `href` renders an inert attribute. `component="button"` is
|
|
53
|
+
* the exception — ButtonBase promotes a `button` root to an anchor itself.
|
|
54
|
+
*
|
|
55
|
+
* @default 'li', or 'a' when `href` is set
|
|
56
|
+
*/
|
|
38
57
|
component?: C;
|
|
39
58
|
};
|
|
40
59
|
/**
|
|
@@ -54,19 +73,19 @@ export type ModMenuItemProps<C extends ElementType = typeof MenuItem> = ModMenuI
|
|
|
54
73
|
* // Disabled state
|
|
55
74
|
* <ModMenuItem disabled>Disabled item</ModMenuItem>
|
|
56
75
|
*
|
|
57
|
-
* // As an anchor — `
|
|
58
|
-
* <ModMenuItem
|
|
76
|
+
* // As an anchor — `href` alone is enough
|
|
77
|
+
* <ModMenuItem href="/api-explorer">API explorer</ModMenuItem>
|
|
59
78
|
*
|
|
60
79
|
* // External link
|
|
61
|
-
* <ModMenuItem
|
|
80
|
+
* <ModMenuItem href="https://docs.example.com" target="_blank" rel="noopener noreferrer">
|
|
62
81
|
* Documentation
|
|
63
82
|
* </ModMenuItem>
|
|
64
83
|
*
|
|
65
|
-
* // Client-side routing (Next.js)
|
|
84
|
+
* // Client-side routing (Next.js) — an explicit `component` wins over the anchor default
|
|
66
85
|
* <ModMenuItem component={NextLink} href="/api-explorer">API explorer</ModMenuItem>
|
|
67
86
|
* ```
|
|
68
87
|
*/
|
|
69
|
-
export declare function ModMenuItem<C extends ElementType = typeof MenuItem>({ icon, shortcut, secondaryText, children, ...rest }: ModMenuItemProps<C>): import("react/jsx-runtime").JSX.Element;
|
|
88
|
+
export declare function ModMenuItem<C extends ElementType = typeof MenuItem>({ icon, shortcut, secondaryText, children, component, href, ...rest }: ModMenuItemProps<C>): import("react/jsx-runtime").JSX.Element;
|
|
70
89
|
export declare namespace ModMenuItem {
|
|
71
90
|
var displayName: string;
|
|
72
91
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1052,15 +1052,26 @@ type ModMenuItemOwnProps = {
|
|
|
1052
1052
|
*/
|
|
1053
1053
|
secondaryText?: string;
|
|
1054
1054
|
/**
|
|
1055
|
-
* URL to navigate to.
|
|
1056
|
-
* MUI
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1055
|
+
* URL to navigate to. Supplying `href` roots the item at an anchor instead of the `li`
|
|
1056
|
+
* MUI defaults to, so it navigates and offers the browser's open-in-new-tab on middle-
|
|
1057
|
+
* or right-click. Pass `component` explicitly (e.g. a router link such as Next.js
|
|
1058
|
+
* `Link`) to override that default.
|
|
1059
|
+
*
|
|
1060
|
+
* The anchor then sits directly inside `MenuList`'s `ul`. `role="menuitem"` keeps that
|
|
1061
|
+
* correct for ARIA, but `ul`'s content model permits only `li`, so HTML validators and
|
|
1062
|
+
* axe-core's `list` rule flag it. This is the pattern MUI's own docs use for link menu
|
|
1063
|
+
* items, and what `ModListItem` already produces inside `List`.
|
|
1059
1064
|
*/
|
|
1060
1065
|
href?: string;
|
|
1061
|
-
/**
|
|
1066
|
+
/**
|
|
1067
|
+
* Anchor `target`, e.g. `_blank`. Only meaningful with `href` — without one the item
|
|
1068
|
+
* roots at `li` and this renders as an inert attribute, the same trap as #722.
|
|
1069
|
+
*/
|
|
1062
1070
|
target?: string;
|
|
1063
|
-
/**
|
|
1071
|
+
/**
|
|
1072
|
+
* Anchor `rel`, e.g. `noopener noreferrer`. Only meaningful with `href` — without one
|
|
1073
|
+
* the item roots at `li` and this renders as an inert attribute.
|
|
1074
|
+
*/
|
|
1064
1075
|
rel?: string;
|
|
1065
1076
|
/**
|
|
1066
1077
|
* Menu item content (text label)
|
|
@@ -1068,6 +1079,14 @@ type ModMenuItemOwnProps = {
|
|
|
1068
1079
|
children?: ReactNode;
|
|
1069
1080
|
};
|
|
1070
1081
|
type ModMenuItemProps<C extends ElementType = typeof MenuItem> = ModMenuItemOwnProps & Omit<ComponentPropsWithoutRef<C>, keyof ModMenuItemOwnProps> & {
|
|
1082
|
+
/**
|
|
1083
|
+
* Root element or component. Naming one bypasses the `href` → anchor default, so pass
|
|
1084
|
+
* a link component (`'a'`, Next.js `Link`, …) if the item still has to navigate:
|
|
1085
|
+
* `component="div"` with an `href` renders an inert attribute. `component="button"` is
|
|
1086
|
+
* the exception — ButtonBase promotes a `button` root to an anchor itself.
|
|
1087
|
+
*
|
|
1088
|
+
* @default 'li', or 'a' when `href` is set
|
|
1089
|
+
*/
|
|
1071
1090
|
component?: C;
|
|
1072
1091
|
};
|
|
1073
1092
|
/**
|
|
@@ -1087,19 +1106,19 @@ type ModMenuItemProps<C extends ElementType = typeof MenuItem> = ModMenuItemOwnP
|
|
|
1087
1106
|
* // Disabled state
|
|
1088
1107
|
* <ModMenuItem disabled>Disabled item</ModMenuItem>
|
|
1089
1108
|
*
|
|
1090
|
-
* // As an anchor — `
|
|
1091
|
-
* <ModMenuItem
|
|
1109
|
+
* // As an anchor — `href` alone is enough
|
|
1110
|
+
* <ModMenuItem href="/api-explorer">API explorer</ModMenuItem>
|
|
1092
1111
|
*
|
|
1093
1112
|
* // External link
|
|
1094
|
-
* <ModMenuItem
|
|
1113
|
+
* <ModMenuItem href="https://docs.example.com" target="_blank" rel="noopener noreferrer">
|
|
1095
1114
|
* Documentation
|
|
1096
1115
|
* </ModMenuItem>
|
|
1097
1116
|
*
|
|
1098
|
-
* // Client-side routing (Next.js)
|
|
1117
|
+
* // Client-side routing (Next.js) — an explicit `component` wins over the anchor default
|
|
1099
1118
|
* <ModMenuItem component={NextLink} href="/api-explorer">API explorer</ModMenuItem>
|
|
1100
1119
|
* ```
|
|
1101
1120
|
*/
|
|
1102
|
-
declare function ModMenuItem<C extends ElementType = typeof MenuItem>({ icon, shortcut, secondaryText, children, ...rest }: ModMenuItemProps<C>): react_jsx_runtime.JSX.Element;
|
|
1121
|
+
declare function ModMenuItem<C extends ElementType = typeof MenuItem>({ icon, shortcut, secondaryText, children, component, href, ...rest }: ModMenuItemProps<C>): react_jsx_runtime.JSX.Element;
|
|
1103
1122
|
declare namespace ModMenuItem {
|
|
1104
1123
|
var displayName: string;
|
|
1105
1124
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -1854,20 +1854,25 @@ const Shortcut = styled('span')(({ theme }) => ({
|
|
|
1854
1854
|
* // Disabled state
|
|
1855
1855
|
* <ModMenuItem disabled>Disabled item</ModMenuItem>
|
|
1856
1856
|
*
|
|
1857
|
-
* // As an anchor — `
|
|
1858
|
-
* <ModMenuItem
|
|
1857
|
+
* // As an anchor — `href` alone is enough
|
|
1858
|
+
* <ModMenuItem href="/api-explorer">API explorer</ModMenuItem>
|
|
1859
1859
|
*
|
|
1860
1860
|
* // External link
|
|
1861
|
-
* <ModMenuItem
|
|
1861
|
+
* <ModMenuItem href="https://docs.example.com" target="_blank" rel="noopener noreferrer">
|
|
1862
1862
|
* Documentation
|
|
1863
1863
|
* </ModMenuItem>
|
|
1864
1864
|
*
|
|
1865
|
-
* // Client-side routing (Next.js)
|
|
1865
|
+
* // Client-side routing (Next.js) — an explicit `component` wins over the anchor default
|
|
1866
1866
|
* <ModMenuItem component={NextLink} href="/api-explorer">API explorer</ModMenuItem>
|
|
1867
1867
|
* ```
|
|
1868
1868
|
*/
|
|
1869
|
-
function ModMenuItem({ icon, shortcut, secondaryText, children, ...rest }) {
|
|
1870
|
-
|
|
1869
|
+
function ModMenuItem({ icon, shortcut, secondaryText, children, component, href, ...rest }) {
|
|
1870
|
+
// MUI roots MenuItem at `li`, and ButtonBase only swaps in a link component when the
|
|
1871
|
+
// root is `button` (as of @mui/material 9.2) — so an `href` on the default root lands as
|
|
1872
|
+
// an attribute on the `<li>` and never navigates (#722). Root at an anchor instead,
|
|
1873
|
+
// unless the caller named a component (e.g. a router link) themselves.
|
|
1874
|
+
const rootProps = { ...rest, href, component: component ?? (href ? 'a' : undefined) };
|
|
1875
|
+
return (jsx(StyledMenuItem, { ...rootProps, children: jsxs(MenuItemContent, { children: [icon && jsx(IconWrapper$1, { children: icon }), jsxs(LabelContainer$3, { children: [jsx(Label$3, { children: children }), secondaryText && jsx(SecondaryLabel, { children: secondaryText })] }), shortcut && jsx(Shortcut, { children: shortcut })] }) }));
|
|
1871
1876
|
}
|
|
1872
1877
|
ModMenuItem.displayName = 'ModMenuItem';
|
|
1873
1878
|
|