@aurora-ds/components 1.8.7 → 1.9.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/dist/cjs/index.js +39 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +39 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -4100,6 +4100,7 @@ const MENU_ITEM_STYLES = createStyles((theme) => {
|
|
|
4100
4100
|
transition: `background-color ${theme.transition.fast}, border-color ${theme.transition.fast}`,
|
|
4101
4101
|
'&[data-selected]': {
|
|
4102
4102
|
backgroundColor: c.primarySubtle,
|
|
4103
|
+
borderLeftColor: c.primaryMain,
|
|
4103
4104
|
color: c.primaryMain,
|
|
4104
4105
|
fontWeight: theme.fontWeight.medium,
|
|
4105
4106
|
},
|
|
@@ -4156,10 +4157,27 @@ const MENU_ITEM_STYLES = createStyles((theme) => {
|
|
|
4156
4157
|
marginLeft: theme.spacing.sm,
|
|
4157
4158
|
flexShrink: 0,
|
|
4158
4159
|
},
|
|
4160
|
+
/**
|
|
4161
|
+
* Full-size transparent `<a>` wrapper used when `href` is provided.
|
|
4162
|
+
* Resets link defaults and mirrors the parent `<li>`'s flex layout so
|
|
4163
|
+
* the icon / label / chevron align correctly.
|
|
4164
|
+
*/
|
|
4165
|
+
link: {
|
|
4166
|
+
display: 'flex',
|
|
4167
|
+
alignItems: 'center',
|
|
4168
|
+
gap: theme.spacing.sm,
|
|
4169
|
+
width: '100%',
|
|
4170
|
+
color: 'inherit',
|
|
4171
|
+
textDecoration: 'none',
|
|
4172
|
+
outline: 'none',
|
|
4173
|
+
'&:focus-visible': {
|
|
4174
|
+
outline: 'none',
|
|
4175
|
+
},
|
|
4176
|
+
},
|
|
4159
4177
|
};
|
|
4160
4178
|
}, { id: 'menu-item' });
|
|
4161
4179
|
|
|
4162
|
-
const MenuItem = ({ ref, id, label, icon, iconColor, role = 'menuitem', checked, selected, focused, disabled, size = 'default', closeOnClick, submenu, submenuTrigger = 'click', submenuPlacement = 'right', onClick, ...rest }) => {
|
|
4180
|
+
const MenuItem = ({ ref, id, label, icon, iconColor, role = 'menuitem', checked, selected, focused, disabled, size = 'default', closeOnClick, submenu, submenuTrigger = 'click', submenuPlacement = 'right', href, target, onClick, ...rest }) => {
|
|
4163
4181
|
const hasSubmenu = submenu !== undefined;
|
|
4164
4182
|
const isCheckable = role === 'menuitemcheckbox' || role === 'menuitemradio';
|
|
4165
4183
|
const isOption = role === 'option';
|
|
@@ -4174,7 +4192,26 @@ const MenuItem = ({ ref, id, label, icon, iconColor, role = 'menuitem', checked,
|
|
|
4174
4192
|
const isFocused = focused || focusedId === itemId;
|
|
4175
4193
|
const { liRef, mergedRef, submenuOpen, handleClick, scheduleOpen, scheduleClose, clearTimers, closeSubmenu, } = useMenuItem({ ref, role, hasSubmenu, disabled, onClick, closeOnClick, submenuTrigger });
|
|
4176
4194
|
const isHoverTrigger = submenuTrigger === 'hover';
|
|
4177
|
-
|
|
4195
|
+
/**
|
|
4196
|
+
* When `href` is provided, the `<a>` is the browser navigation element.
|
|
4197
|
+
* - If `onClick` is also given (SPA routing): prevent browser navigation,
|
|
4198
|
+
* the click bubbles to `<li>` where `handleClick` calls `onClick` + `closeMenu`.
|
|
4199
|
+
* - If only `href` (plain link): let the browser navigate, `handleClick` on
|
|
4200
|
+
* the `<li>` still fires via bubbling and closes the menu.
|
|
4201
|
+
* - If `disabled`: prevent navigation entirely.
|
|
4202
|
+
*/
|
|
4203
|
+
const handleAnchorClick = (e) => {
|
|
4204
|
+
if (disabled) {
|
|
4205
|
+
e.preventDefault();
|
|
4206
|
+
return;
|
|
4207
|
+
}
|
|
4208
|
+
if (onClick) {
|
|
4209
|
+
// Prevent browser follow; SPA handler will be called via bubbling.
|
|
4210
|
+
e.preventDefault();
|
|
4211
|
+
}
|
|
4212
|
+
};
|
|
4213
|
+
const innerContent = (jsxs(Fragment$1, { children: [isCheckable && (jsxs("span", { className: MENU_ITEM_STYLES.indicator, "aria-hidden": true, children: [checked && role === 'menuitemcheckbox' && (jsx(Icon, { icon: CheckIcon, size: size === 'default' ? 'sm' : 'md', strokeColor: 'primaryMain' })), checked && role === 'menuitemradio' && (jsx("span", { className: MENU_ITEM_STYLES.radioDot }))] })), icon !== undefined && (jsx(Icon, { icon: icon, size: 'sm', strokeColor: iconColor ?? (isHighlighted ? 'primaryMain' : 'textSecondary') })), jsx(Text, { variant: 'span', fontSize: 'sm', className: MENU_ITEM_STYLES.label, children: label }), hasSubmenu && (jsx("span", { className: MENU_ITEM_STYLES.submenuChevron, "aria-hidden": true, children: jsx(Icon, { icon: ChevronRightIcon, size: 'sm', strokeColor: 'textTertiary' }) }))] }));
|
|
4214
|
+
return (jsxs(Fragment$1, { children: [jsx("li", { ref: mergedRef, id: itemId, role: role, "aria-checked": isCheckable ? Boolean(checked) : undefined, "aria-selected": isOption ? Boolean(selected) : undefined, "aria-disabled": disabled, "aria-haspopup": hasSubmenu ? 'menu' : undefined, "aria-expanded": hasSubmenu ? submenuOpen : undefined, "data-selected": isHighlighted || undefined, "data-focused": isFocused || undefined, "data-disabled": disabled || undefined, "data-submenu-open": hasSubmenu && submenuOpen || undefined, className: MENU_ITEM_STYLES.root({ size }), onClick: handleClick, onMouseEnter: hasSubmenu && !disabled && isHoverTrigger ? scheduleOpen : undefined, onMouseLeave: hasSubmenu && isHoverTrigger ? scheduleClose : undefined, ...rest, children: href ? (jsx("a", { href: href, target: target, rel: target === '_blank' ? 'noopener noreferrer' : undefined, "aria-disabled": disabled || undefined, className: MENU_ITEM_STYLES.link, tabIndex: -1, onClick: handleAnchorClick, children: innerContent })) : innerContent }), hasSubmenu && (jsx(MenuPanel, { open: submenuOpen, onClose: () => closeSubmenu(true), onArrowLeft: () => closeSubmenu(true), anchorEl: liRef.current, placement: submenuPlacement, isSubmenu: true, "aria-label": label, onMouseEnter: isHoverTrigger ? clearTimers : undefined, onMouseLeave: isHoverTrigger ? scheduleClose : undefined, children: submenu }))] }));
|
|
4178
4215
|
};
|
|
4179
4216
|
MenuItem.displayName = 'MenuItem';
|
|
4180
4217
|
|