@moneyforward/mfui-components 3.3.0 → 3.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/dist/src/DropdownMenu/DropdownMenuItem/DropdownMenuItem.d.ts +1 -1
- package/dist/src/DropdownMenu/DropdownMenuItem/DropdownMenuItem.js +16 -4
- package/dist/src/DropdownMenu/DropdownMenuItem/DropdownMenuItem.types.d.ts +12 -0
- package/dist/src/HelpMessage/HelpMessage.d.ts +7 -2
- package/dist/src/HelpMessage/HelpMessage.js +23 -5
- package/dist/src/HelpMessage/HelpMessage.types.d.ts +10 -3
- package/dist/src/MainNavigation/BaseMainNavigation.js +1 -1
- package/dist/src/MainNavigation/MainNavigation.types.d.ts +8 -0
- package/dist/src/MainNavigation/NarrowViewportMainNavigation.js +1 -1
- package/dist/src/SubNavigation/SubNavigation.js +6 -0
- package/dist/src/SubNavigation/SubNavigation.types.d.ts +8 -0
- package/dist/styled-system/recipes/help-message-recipe.d.ts +1 -1
- package/dist/styled-system/recipes/help-message-recipe.js +3 -1
- package/dist/styles.css +18 -5
- package/package.json +1 -1
|
@@ -12,4 +12,4 @@ import { type DropdownMenuItemProps } from './DropdownMenuItem.types';
|
|
|
12
12
|
*
|
|
13
13
|
* Otherwise, it will be rendered as a div element.
|
|
14
14
|
*/
|
|
15
|
-
export declare function DropdownMenuItem({ children, className, href, target, customLinkComponent, onClick, 'aria-labelledby': ariaLabelledby, ...rest }: DropdownMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function DropdownMenuItem({ children, className, href, target, customLinkComponent, onClick, disabled, 'aria-labelledby': ariaLabelledby, ...rest }: DropdownMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -20,7 +20,7 @@ import { useDropdownMenuContext } from '../DropdownMenuContext';
|
|
|
20
20
|
*
|
|
21
21
|
* Otherwise, it will be rendered as a div element.
|
|
22
22
|
*/
|
|
23
|
-
export function DropdownMenuItem({ children, className, href, target, customLinkComponent, onClick, 'aria-labelledby': ariaLabelledby, ...rest }) {
|
|
23
|
+
export function DropdownMenuItem({ children, className, href, target, customLinkComponent, onClick, disabled, 'aria-labelledby': ariaLabelledby, ...rest }) {
|
|
24
24
|
const classes = dropdownMenuItemSlotRecipe();
|
|
25
25
|
const { closeMenuPopover } = useDropdownMenuContext();
|
|
26
26
|
const id = useId();
|
|
@@ -48,11 +48,13 @@ export function DropdownMenuItem({ children, className, href, target, customLink
|
|
|
48
48
|
}
|
|
49
49
|
}, []);
|
|
50
50
|
const handleClick = useCallback((event) => {
|
|
51
|
+
if (disabled)
|
|
52
|
+
return;
|
|
51
53
|
if (onClick) {
|
|
52
54
|
onClick(event);
|
|
53
55
|
closeMenuPopover?.();
|
|
54
56
|
}
|
|
55
|
-
}, [onClick, closeMenuPopover]);
|
|
57
|
+
}, [disabled, onClick, closeMenuPopover]);
|
|
56
58
|
const isButton = useMemo(() => onClick && !href, [onClick, href]);
|
|
57
59
|
const Tag = useMemo(() => {
|
|
58
60
|
if (href) {
|
|
@@ -66,6 +68,16 @@ export function DropdownMenuItem({ children, className, href, target, customLink
|
|
|
66
68
|
// If the href is provided, it should be an anchor element and focusable.
|
|
67
69
|
// If the href is undefined and onClick is provided, it should be a button element and focusable.
|
|
68
70
|
// If both are undefined, it should be a div element and not focusable.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
// If disabled is true, the menu item is not focusable.
|
|
72
|
+
const isFocusable = (!!href || !!onClick) && !disabled;
|
|
73
|
+
// Anchor navigation is suppressed when disabled to prevent unintended navigation.
|
|
74
|
+
const resolvedHref = isButton || disabled ? undefined : href;
|
|
75
|
+
// For button elements, use the native disabled attribute for full browser semantics.
|
|
76
|
+
// For anchor and div elements, use aria-disabled and data-disabled since they have no native disabled support.
|
|
77
|
+
const disabledProps = isButton
|
|
78
|
+
? { disabled }
|
|
79
|
+
: disabled
|
|
80
|
+
? { 'aria-disabled': true, 'data-disabled': '' }
|
|
81
|
+
: {};
|
|
82
|
+
return (_jsx(FocusIndicator, { position: "inside", children: _jsx(Tag, { ...rest, ref: itemRef, ...(ariaLabelledby && { id }), "data-mfui-menu-item": true, role: "menuitem", className: cx(classes.root, 'mfui-DropdownMenuItem__root', className), tabIndex: -1, href: resolvedHref, target: target, "data-mfui-focusable": isFocusable, type: onClick ? 'button' : undefined, "aria-labelledby": ariaLabelledby ? `${ariaLabelledby} ${id}` : undefined, ...disabledProps, onKeyDown: handleKeyDown, onClick: isButton ? handleClick : undefined, children: typeof children === 'string' ? _jsx(Typography, { variant: "body", children: children }) : children }) }));
|
|
71
83
|
}
|
|
@@ -16,6 +16,10 @@ type AnchorProps = {
|
|
|
16
16
|
* This property is ignored if the href property is provided.
|
|
17
17
|
*/
|
|
18
18
|
onClick?: undefined;
|
|
19
|
+
/**
|
|
20
|
+
* When true, the menu item is disabled and not interactive.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
19
23
|
};
|
|
20
24
|
type DivProps = {
|
|
21
25
|
/**
|
|
@@ -34,6 +38,10 @@ type DivProps = {
|
|
|
34
38
|
* If not provided and the href prop is not provided, the menu item will be rendered as a div element.
|
|
35
39
|
*/
|
|
36
40
|
onClick?: undefined;
|
|
41
|
+
/**
|
|
42
|
+
* When true, the menu item is disabled and not interactive.
|
|
43
|
+
*/
|
|
44
|
+
disabled?: boolean;
|
|
37
45
|
};
|
|
38
46
|
type ButtonProps = {
|
|
39
47
|
/**
|
|
@@ -52,6 +60,10 @@ type ButtonProps = {
|
|
|
52
60
|
* The handler to call when the menu item is clicked or the Enter key is pressed.
|
|
53
61
|
*/
|
|
54
62
|
onClick?: ComponentPropsWithoutRef<'button'>['onClick'];
|
|
63
|
+
/**
|
|
64
|
+
* When true, the menu item is disabled and not interactive.
|
|
65
|
+
*/
|
|
66
|
+
disabled?: boolean;
|
|
55
67
|
};
|
|
56
68
|
/**
|
|
57
69
|
* The props for the MenuItem component.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The HelpMessage component
|
|
3
|
-
*
|
|
2
|
+
* The HelpMessage component displays contextual messages with an icon and color
|
|
3
|
+
* that reflect the message's intent. Supports four variants via `messageType`:
|
|
4
|
+
* - `neutral` (default): informational, uses IconInfo. Icon is hidden by default; opt in with `showIcon`. No ARIA role.
|
|
5
|
+
* - `error`: validation or system error, uses IconError. Sets `role="alert"` — announces immediately to screen readers.
|
|
6
|
+
* - `caution`: warning or advisory, uses IconCaution. No ARIA role by default — add `role="status"` or `aria-live="polite"` when rendered dynamically.
|
|
7
|
+
* - `success`: confirmation or positive feedback, uses IconApproval. Sets `role="status"` — announces politely when the user is idle.
|
|
4
8
|
*
|
|
5
9
|
* Also extends the props of the `<div>` element.
|
|
6
10
|
*
|
|
@@ -8,6 +12,7 @@
|
|
|
8
12
|
*/
|
|
9
13
|
export declare const HelpMessage: import("react").ForwardRefExoticComponent<{
|
|
10
14
|
messageType?: import("../../styled-system/recipes").HelpMessageRecipeVariant["messageType"];
|
|
15
|
+
showIcon?: boolean;
|
|
11
16
|
messageAlign?: "left" | "center";
|
|
12
17
|
children?: import("..").TypographyProps["children"];
|
|
13
18
|
} & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useId } from 'react';
|
|
3
|
-
import { Error } from '@moneyforward/mfui-icons-react';
|
|
3
|
+
import { Approval, Caution, Error, Info } from '@moneyforward/mfui-icons-react';
|
|
4
4
|
import { cx } from '../../styled-system/css';
|
|
5
5
|
import { helpMessageRecipe } from '../../styled-system/recipes';
|
|
6
6
|
import { Typography } from '../Typography';
|
|
7
|
+
const messageTypeRoleMap = {
|
|
8
|
+
neutral: undefined,
|
|
9
|
+
error: 'alert',
|
|
10
|
+
caution: undefined,
|
|
11
|
+
success: 'status',
|
|
12
|
+
};
|
|
13
|
+
const messageTypeIconMap = {
|
|
14
|
+
neutral: Info,
|
|
15
|
+
error: Error,
|
|
16
|
+
caution: Caution,
|
|
17
|
+
success: Approval,
|
|
18
|
+
};
|
|
7
19
|
/**
|
|
8
|
-
* The HelpMessage component
|
|
9
|
-
*
|
|
20
|
+
* The HelpMessage component displays contextual messages with an icon and color
|
|
21
|
+
* that reflect the message's intent. Supports four variants via `messageType`:
|
|
22
|
+
* - `neutral` (default): informational, uses IconInfo. Icon is hidden by default; opt in with `showIcon`. No ARIA role.
|
|
23
|
+
* - `error`: validation or system error, uses IconError. Sets `role="alert"` — announces immediately to screen readers.
|
|
24
|
+
* - `caution`: warning or advisory, uses IconCaution. No ARIA role by default — add `role="status"` or `aria-live="polite"` when rendered dynamically.
|
|
25
|
+
* - `success`: confirmation or positive feedback, uses IconApproval. Sets `role="status"` — announces politely when the user is idle.
|
|
10
26
|
*
|
|
11
27
|
* Also extends the props of the `<div>` element.
|
|
12
28
|
*
|
|
13
29
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div
|
|
14
30
|
*/
|
|
15
|
-
export const HelpMessage = forwardRef(({ messageType = 'neutral', messageAlign = 'left', children, className, ...props }, ref) => {
|
|
31
|
+
export const HelpMessage = forwardRef(({ messageType = 'neutral', messageAlign = 'left', showIcon, children, className, ...props }, ref) => {
|
|
16
32
|
const classes = helpMessageRecipe({ messageType, messageAlign });
|
|
17
33
|
const id = useId();
|
|
18
34
|
const ariaLabelledByContentId = `help-message-content-${id}`;
|
|
19
|
-
|
|
35
|
+
const shouldShowIcon = showIcon ?? messageType !== 'neutral';
|
|
36
|
+
const Icon = messageTypeIconMap[messageType];
|
|
37
|
+
return (_jsxs("div", { ref: ref, role: messageTypeRoleMap[messageType], "aria-labelledby": ariaLabelledByContentId, ...props, className: cx(classes.root, 'mfui-HelpMessage__root', className), children: [shouldShowIcon ? _jsx(Icon, { "aria-hidden": true, className: cx(classes.icon, 'mfui-HelpMessage__icon') }) : null, _jsx(Typography, { id: ariaLabelledByContentId, variant: "helpMessage", className: cx(classes.message, 'mfui-HelpMessage__message'), children: children })] }));
|
|
20
38
|
});
|
|
@@ -6,13 +6,20 @@ import { type TypographyProps } from '../Typography';
|
|
|
6
6
|
*/
|
|
7
7
|
export type HelpMessageProps = {
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* The intent of the message. Controls the icon and color.
|
|
10
|
+
* - `neutral`: informational (IconInfo)
|
|
11
|
+
* - `error`: validation or system error (IconError). Sets `role="alert"` for screen readers.
|
|
12
|
+
* - `caution`: warning or advisory (IconCaution). No ARIA role is set by default — add `role="status"` or `aria-live="polite"` when rendering dynamically.
|
|
13
|
+
* - `success`: confirmation or positive feedback (IconApproval)
|
|
12
14
|
*
|
|
13
15
|
* @default 'neutral'
|
|
14
16
|
*/
|
|
15
17
|
messageType?: HelpMessageRecipeVariant['messageType'];
|
|
18
|
+
/**
|
|
19
|
+
* Whether to display the icon next to the message.
|
|
20
|
+
* Defaults to `false` for `neutral` (for backward compatibility) and `true` for all other types.
|
|
21
|
+
*/
|
|
22
|
+
showIcon?: boolean;
|
|
16
23
|
/**
|
|
17
24
|
* The alignment of the message.
|
|
18
25
|
*
|
|
@@ -37,7 +37,7 @@ export function BaseMainNavigation({ className, featureShortcut, navigationItems
|
|
|
37
37
|
else {
|
|
38
38
|
setOpenPopoverIndex(null);
|
|
39
39
|
}
|
|
40
|
-
} })) : (_jsxs("details", { open: hasCurrentNavigationInChildren(navigation.children), className: cx(classes.parentDetails, 'mfui-BaseMainNavigation__parentDetails'), children: [_jsx(FocusIndicator, { position: "inside", children: _jsxs("summary", { className: cx(classes.parentSummary, 'mfui-BaseMainNavigation__parentSummary'), children: [_jsx("div", { className: cx(classes.parentSummaryIcon, 'mfui-BaseMainNavigation__parentSummaryIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label }), _jsx(DisclosureBasicCollapsed, { className: "mfui-BaseMainNavigation__icon_collapsed", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-collapsed" }), _jsx(DisclosureBasicExpanded, { className: "mfui-BaseMainNavigation__icon_expanded", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-expanded" })] }) }), _jsx("ul", { className: cx(classes.childrenList, 'mfui-BaseMainNavigation__childrenList'), children: navigation.children.map((child, childIndex) => (_jsx("li", { className: cx(classes.childrenListItem, 'mfui-BaseMainNavigation__childrenListItem'), children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: child.isExternal, href: child.href, className: cx(classes.childrenListItemAnchor, 'mfui-BaseMainNavigation__childrenListItemAnchor'), "aria-current": child.isCurrent ? 'page' : undefined, children: _jsx(Typography, { variant: "controlLabel", children: child.label }) }) }) }, childIndex))) })] }))) : (_jsx(Tooltip, { className: cx(classes.listItemTooltip, 'mfui-BaseMainNavigation__listItemTooltip'), content: navigation.label, disabled: !isCollapsed, placement: "right", children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: navigation.isExternal, href: navigation.href, className: cx(classes.listItemAnchor, 'mfui-BaseMainNavigation__listItemAnchor'), "aria-label": isCollapsed ? navigation.label : undefined, "aria-current": navigation.isCurrent ? 'page' : undefined, children: _jsxs("div", { className: cx(classes.labelGroup, 'mfui-BaseMainNavigation__labelGroup'), children: [_jsxs("div", { className: cx(classes.iconAndLabel, 'mfui-BaseMainNavigation__iconAndLabel'), children: [_jsx("div", { className: cx(classes.listItemAnchorIcon, 'mfui-BaseMainNavigation__listItemAnchorIcon'), children: navigation.icon }), isCollapsed ? null : _jsx(Typography, { variant: "controlLabel", children: navigation.label })] }), navigation.locked ? (_jsx(Lock, { className: cx(classes.lockIcon, 'mfui-BaseMainNavigation__lockIcon'), "aria-label": navigation.lockIconProps?.['aria-label'] ?? 'ロックされています' })) : null, !isCollapsed && navigation.statusSlot && navigation.locked !== true
|
|
40
|
+
} })) : (_jsxs("details", { open: navigation.isOpenByDefault || hasCurrentNavigationInChildren(navigation.children), className: cx(classes.parentDetails, 'mfui-BaseMainNavigation__parentDetails'), children: [_jsx(FocusIndicator, { position: "inside", children: _jsxs("summary", { className: cx(classes.parentSummary, 'mfui-BaseMainNavigation__parentSummary'), children: [_jsx("div", { className: cx(classes.parentSummaryIcon, 'mfui-BaseMainNavigation__parentSummaryIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label }), _jsx(DisclosureBasicCollapsed, { className: "mfui-BaseMainNavigation__icon_collapsed", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-collapsed" }), _jsx(DisclosureBasicExpanded, { className: "mfui-BaseMainNavigation__icon_expanded", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-expanded" })] }) }), _jsx("ul", { className: cx(classes.childrenList, 'mfui-BaseMainNavigation__childrenList'), children: navigation.children.map((child, childIndex) => (_jsx("li", { className: cx(classes.childrenListItem, 'mfui-BaseMainNavigation__childrenListItem'), children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: child.isExternal, href: child.href, className: cx(classes.childrenListItemAnchor, 'mfui-BaseMainNavigation__childrenListItemAnchor'), "aria-current": child.isCurrent ? 'page' : undefined, children: _jsx(Typography, { variant: "controlLabel", children: child.label }) }) }) }, childIndex))) })] }))) : (_jsx(Tooltip, { className: cx(classes.listItemTooltip, 'mfui-BaseMainNavigation__listItemTooltip'), content: navigation.label, disabled: !isCollapsed, placement: "right", children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: navigation.isExternal, href: navigation.href, className: cx(classes.listItemAnchor, 'mfui-BaseMainNavigation__listItemAnchor'), "aria-label": isCollapsed ? navigation.label : undefined, "aria-current": navigation.isCurrent ? 'page' : undefined, children: _jsxs("div", { className: cx(classes.labelGroup, 'mfui-BaseMainNavigation__labelGroup'), children: [_jsxs("div", { className: cx(classes.iconAndLabel, 'mfui-BaseMainNavigation__iconAndLabel'), children: [_jsx("div", { className: cx(classes.listItemAnchorIcon, 'mfui-BaseMainNavigation__listItemAnchorIcon'), children: navigation.icon }), isCollapsed ? null : _jsx(Typography, { variant: "controlLabel", children: navigation.label })] }), navigation.locked ? (_jsx(Lock, { className: cx(classes.lockIcon, 'mfui-BaseMainNavigation__lockIcon'), "aria-label": navigation.lockIconProps?.['aria-label'] ?? 'ロックされています' })) : null, !isCollapsed && navigation.statusSlot && navigation.locked !== true
|
|
41
41
|
? navigation.statusSlot
|
|
42
42
|
: null] }) }) }) })) }, index))) }) }), enableCollapsible ? (_jsx("div", { className: cx(classes.footer, 'mfui-BaseMainNavigation__footer'), children: _jsx(Tooltip, { content: toggleButtonLabel, placement: "right", children: _jsx(ToggleButton, { className: cx(classes.toggleButton, 'mfui-BaseMainNavigation__toggleButton'), iconClassName: cx(classes.toggleButtonIcon, 'mfui-BaseMainNavigation__toggleButtonIcon'), isCollapsed: isCollapsed, "aria-label": toggleButtonLabel, targetId: navId, handleClickToggleButton: handleClickToggleButton }) }) })) : null] }));
|
|
43
43
|
}
|
|
@@ -81,6 +81,14 @@ type ParentNavigationItem = {
|
|
|
81
81
|
* This property is not allowed for the parent navigation items.
|
|
82
82
|
*/
|
|
83
83
|
isCurrent?: undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the nested navigation is open by default.
|
|
86
|
+
* When set to true, the parent navigation item is expanded on initial render,
|
|
87
|
+
* regardless of whether any child has `isCurrent: true`.
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
isOpenByDefault?: boolean;
|
|
84
92
|
/**
|
|
85
93
|
* Nested navigation items.
|
|
86
94
|
*
|
|
@@ -47,5 +47,5 @@ export const NarrowViewportMainNavigation = forwardRef(({ className, featureShor
|
|
|
47
47
|
}
|
|
48
48
|
return (_jsx(Portal, { children: _jsxs("div", { ref: dialogRef, role: "dialog", className: cx(classes.root, 'mfui-NarrowViewportMainNavigation__root', className), tabIndex: -1, onKeyDown: handleOnKeyDown, children: [_jsx("div", { "data-mfui-content": "backdrop", className: cx(classes.backdrop, 'mfui-NarrowViewportMainNavigation__backdrop'), onClick: handleCloseMainNavigation }), _jsxs("div", { "data-mfui-content": "inside", className: cx(classes.container, 'mfui-NarrowViewportMainNavigation__container'), onClick: (event) => {
|
|
49
49
|
event.stopPropagation();
|
|
50
|
-
}, children: [featureShortcut ? (_jsx("div", { className: cx(classes.featureShortcut, 'mfui-NarrowViewportMainNavigation__featureShortcut'), children: _jsx(FocusIndicator, { children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: featureShortcut.isExternal, href: featureShortcut.href, className: cx(classes.featureShortcutAnchor, 'mfui-NarrowViewportMainNavigation__featureShortcutAnchor'), onClick: handleCloseMainNavigation, children: _jsx(Typography, { variant: "controlLabel", children: featureShortcut.label }) }) }) })) : null, _jsx("nav", { className: cx(classes.nav, 'mfui-NarrowViewportMainNavigation__nav'), children: _jsx("ul", { className: cx(classes.list, 'mfui-NarrowViewportMainNavigation__list'), children: navigationItems.map((navigation, index) => (_jsx("li", { className: cx(classes.listItem, 'mfui-NarrowViewportMainNavigation__listItem'), children: navigation.children ? (_jsxs("details", { open: hasCurrentNavigationInChildren(navigation.children), className: cx(classes.parentDetails, 'mfui-NarrowViewportMainNavigation__parentDetails'), children: [_jsx(FocusIndicator, { position: "inside", children: _jsxs("summary", { className: cx(classes.parentSummary, 'mfui-NarrowViewportMainNavigation__parentSummary'), children: [_jsx("div", { className: cx(classes.parentSummaryIcon, 'mfui-NarrowViewportMainNavigation__parentSummaryIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label }), _jsx(DisclosureBasicCollapsed, { className: "mfui-NarrowViewportMainNavigation__icon_collapsed", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-collapsed" }), _jsx(DisclosureBasicExpanded, { className: "mfui-NarrowViewportMainNavigation__icon_expanded", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-expanded" })] }) }), _jsx("ul", { className: cx(classes.childrenList, 'mfui-NarrowViewportMainNavigation__childrenList'), children: navigation.children.map((child, childIndex) => (_jsx("li", { className: cx(classes.childrenListItem, 'mfui-NarrowViewportMainNavigation__childrenListItem'), children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: child.isExternal, href: child.href, className: cx(classes.childrenListItemAnchor, 'mfui-NarrowViewportMainNavigation__childrenListItemAnchor'), "aria-current": child.isCurrent ? 'page' : undefined, onClick: handleCloseMainNavigation, children: _jsx(Typography, { variant: "controlLabel", children: child.label }) }) }) }, childIndex))) })] })) : (_jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: navigation.isExternal, href: navigation.href, className: cx(classes.listItemAnchor, 'mfui-NarrowViewportMainNavigation__listItemAnchor'), "aria-current": navigation.isCurrent ? 'page' : undefined, children: _jsxs("div", { className: cx(classes.labelGroup, 'mfui-NarrowViewportMainNavigation__labelGroup'), children: [_jsxs("div", { className: cx(classes.iconAndLabel, 'mfui-NarrowViewportMainNavigation__iconAndLabel'), children: [_jsx("div", { className: cx(classes.listItemAnchorIcon, 'mfui-NarrowViewportMainNavigation__listItemAnchorIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label })] }), navigation.locked ? (_jsx(Lock, { className: cx(classes.lockIcon, 'mfui-NarrowViewportMainNavigation__lockIcon'), "aria-label": navigation.lockIconProps?.['aria-label'] ?? 'ロックされています' })) : null] }) }) })) }, index))) }) })] })] }) }));
|
|
50
|
+
}, children: [featureShortcut ? (_jsx("div", { className: cx(classes.featureShortcut, 'mfui-NarrowViewportMainNavigation__featureShortcut'), children: _jsx(FocusIndicator, { children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: featureShortcut.isExternal, href: featureShortcut.href, className: cx(classes.featureShortcutAnchor, 'mfui-NarrowViewportMainNavigation__featureShortcutAnchor'), onClick: handleCloseMainNavigation, children: _jsx(Typography, { variant: "controlLabel", children: featureShortcut.label }) }) }) })) : null, _jsx("nav", { className: cx(classes.nav, 'mfui-NarrowViewportMainNavigation__nav'), children: _jsx("ul", { className: cx(classes.list, 'mfui-NarrowViewportMainNavigation__list'), children: navigationItems.map((navigation, index) => (_jsx("li", { className: cx(classes.listItem, 'mfui-NarrowViewportMainNavigation__listItem'), children: navigation.children ? (_jsxs("details", { open: navigation.isOpenByDefault || hasCurrentNavigationInChildren(navigation.children), className: cx(classes.parentDetails, 'mfui-NarrowViewportMainNavigation__parentDetails'), children: [_jsx(FocusIndicator, { position: "inside", children: _jsxs("summary", { className: cx(classes.parentSummary, 'mfui-NarrowViewportMainNavigation__parentSummary'), children: [_jsx("div", { className: cx(classes.parentSummaryIcon, 'mfui-NarrowViewportMainNavigation__parentSummaryIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label }), _jsx(DisclosureBasicCollapsed, { className: "mfui-NarrowViewportMainNavigation__icon_collapsed", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-collapsed" }), _jsx(DisclosureBasicExpanded, { className: "mfui-NarrowViewportMainNavigation__icon_expanded", "aria-hidden": "true", "data-mfui-content": "main-navigation-icon-expanded" })] }) }), _jsx("ul", { className: cx(classes.childrenList, 'mfui-NarrowViewportMainNavigation__childrenList'), children: navigation.children.map((child, childIndex) => (_jsx("li", { className: cx(classes.childrenListItem, 'mfui-NarrowViewportMainNavigation__childrenListItem'), children: _jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: child.isExternal, href: child.href, className: cx(classes.childrenListItemAnchor, 'mfui-NarrowViewportMainNavigation__childrenListItemAnchor'), "aria-current": child.isCurrent ? 'page' : undefined, onClick: handleCloseMainNavigation, children: _jsx(Typography, { variant: "controlLabel", children: child.label }) }) }) }, childIndex))) })] })) : (_jsx(FocusIndicator, { position: "inside", children: _jsx(NavigationLink, { tag: InternalLinkTag, isExternal: navigation.isExternal, href: navigation.href, className: cx(classes.listItemAnchor, 'mfui-NarrowViewportMainNavigation__listItemAnchor'), "aria-current": navigation.isCurrent ? 'page' : undefined, children: _jsxs("div", { className: cx(classes.labelGroup, 'mfui-NarrowViewportMainNavigation__labelGroup'), children: [_jsxs("div", { className: cx(classes.iconAndLabel, 'mfui-NarrowViewportMainNavigation__iconAndLabel'), children: [_jsx("div", { className: cx(classes.listItemAnchorIcon, 'mfui-NarrowViewportMainNavigation__listItemAnchorIcon'), children: navigation.icon }), _jsx(Typography, { variant: "controlLabel", children: navigation.label })] }), navigation.locked ? (_jsx(Lock, { className: cx(classes.lockIcon, 'mfui-NarrowViewportMainNavigation__lockIcon'), "aria-label": navigation.lockIconProps?.['aria-label'] ?? 'ロックされています' })) : null] }) }) })) }, index))) }) })] })] }) }));
|
|
51
51
|
});
|
|
@@ -65,6 +65,12 @@ function NavigationLabelGroup({ label, labelIcon, locked, lockIconProps, statusS
|
|
|
65
65
|
*/
|
|
66
66
|
function NavigationLink({ navigationItem, customLinkComponent, classes, }) {
|
|
67
67
|
const { label, href, isCurrent, isExternal, labelIcon, statusSlot, locked, lockIconProps } = navigationItem;
|
|
68
|
+
if (navigationItem.children === undefined && navigationItem.onClick) {
|
|
69
|
+
const { onClick } = navigationItem;
|
|
70
|
+
return (_jsx(FocusIndicator, { children: _jsx("button", { type: "button", className: cx(classes.link, 'mfui-SubNavigation__link'), "aria-current": isCurrent ? 'page' : undefined, onClick: () => {
|
|
71
|
+
onClick(navigationItem.href);
|
|
72
|
+
}, children: _jsx(NavigationLabelGroup, { label, labelIcon, locked, lockIconProps, statusSlot, classes }) }) }));
|
|
73
|
+
}
|
|
68
74
|
if (customLinkComponent && !isExternal) {
|
|
69
75
|
const Tag = customLinkComponent;
|
|
70
76
|
return (_jsx(FocusIndicator, { children: _jsx(Tag, { href: href, className: cx(classes.link, 'mfui-SubNavigation__link'), "aria-current": isCurrent ? 'page' : undefined, children: _jsx(NavigationLabelGroup, { label, labelIcon, locked, lockIconProps, statusSlot, classes }) }) }));
|
|
@@ -68,6 +68,14 @@ type ChildlessNavigationItem = BaseNavigationItem & {
|
|
|
68
68
|
* The path or URL to the linked page.
|
|
69
69
|
*/
|
|
70
70
|
href: string;
|
|
71
|
+
/**
|
|
72
|
+
* If provided, the item is rendered as a button instead of a link.
|
|
73
|
+
* The handler is called with the item's `href` value as an argument.
|
|
74
|
+
*
|
|
75
|
+
* Use this for state-based navigation patterns where you want to update
|
|
76
|
+
* application state on click without performing browser navigation.
|
|
77
|
+
*/
|
|
78
|
+
onClick?: (href: string) => void;
|
|
71
79
|
};
|
|
72
80
|
/**
|
|
73
81
|
* The navigation item that has nested children.
|
|
@@ -4,7 +4,7 @@ import type { DistributiveOmit, Pretty } from '../types/system-types';
|
|
|
4
4
|
|
|
5
5
|
interface HelpMessageRecipeVariant {
|
|
6
6
|
messageAlign: "left" | "center"
|
|
7
|
-
messageType: "neutral" | "error"
|
|
7
|
+
messageType: "neutral" | "error" | "caution" | "success"
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
type HelpMessageRecipeVariantMap = {
|
package/dist/styles.css
CHANGED
|
@@ -720,17 +720,17 @@
|
|
|
720
720
|
min-height: var(--mfui-sizes-mfui\.size\.dimension\.control-component\.height\.comfort);
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
.mfui-DYOKU:is(:disabled, [disabled], [data-disabled], [aria-disabled=true]) {
|
|
724
|
+
color: var(--mfui-colors-mfui\.color\.disabled\.content);
|
|
725
|
+
background-color: var(--mfui-colors-mfui\.color\.base\.background\.none);
|
|
726
|
+
}
|
|
727
|
+
|
|
723
728
|
.mfui-DYOKU[data-mfui-focusable=true]:is(:focus-visible, [data-focus-visible]) {
|
|
724
729
|
color: var(--mfui-colors-mfui\.color\.base\.content\.hovered);
|
|
725
730
|
background-color: var(--mfui-colors-mfui\.color\.base\.background\.hovered);
|
|
726
731
|
z-index: 1;
|
|
727
732
|
}
|
|
728
733
|
|
|
729
|
-
.mfui-DYOKU[data-mfui-focusable=true]:is(:disabled, [disabled], [data-disabled], [aria-disabled=true]) {
|
|
730
|
-
color: var(--mfui-colors-mfui\.color\.disabled\.content);
|
|
731
|
-
background-color: var(--mfui-colors-mfui\.color\.base\.background\.pressed);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
734
|
.mfui-DYOKU[data-mfui-focusable=true]:is(:hover, [data-hover]):not(:disabled, [disabled], [data-disabled]) {
|
|
735
735
|
color: var(--mfui-colors-mfui\.color\.base\.content\.hovered);
|
|
736
736
|
background-color: var(--mfui-colors-mfui\.color\.base\.background\.hovered);
|
|
@@ -2947,13 +2947,18 @@
|
|
|
2947
2947
|
}
|
|
2948
2948
|
|
|
2949
2949
|
.mfui-ljuOJV {
|
|
2950
|
+
border: none;
|
|
2950
2951
|
text-decoration: none;
|
|
2951
2952
|
padding-block: var(--mfui-spacing-mfui\.size\.padding\.sub-navigation\.vertical\.comfort);
|
|
2952
2953
|
padding-inline: var(--mfui-spacing-mfui\.size\.padding\.sub-navigation\.horizontal\.comfort);
|
|
2953
2954
|
border-radius: var(--mfui-radii-mfui\.size\.radius\.control-component\.comfort);
|
|
2955
|
+
background-color: transparent;
|
|
2956
|
+
cursor: pointer;
|
|
2957
|
+
text-align: left;
|
|
2954
2958
|
display: flex;
|
|
2955
2959
|
align-items: flex-start;
|
|
2956
2960
|
color: var(--mfui-colors-mfui\.color\.base\.content\.none);
|
|
2961
|
+
width: 100%;
|
|
2957
2962
|
}
|
|
2958
2963
|
|
|
2959
2964
|
.mfui-ljuOJV[aria-current=page] {
|
|
@@ -5596,6 +5601,14 @@
|
|
|
5596
5601
|
color: var(--mfui-colors-mfui\.color\.signal-red\.content\.none);
|
|
5597
5602
|
}
|
|
5598
5603
|
|
|
5604
|
+
.mfui-LuZio {
|
|
5605
|
+
color: var(--mfui-colors-mfui\.color\.signal-yellow\.content\.none);
|
|
5606
|
+
}
|
|
5607
|
+
|
|
5608
|
+
.mfui-foXPig {
|
|
5609
|
+
color: var(--mfui-colors-mfui\.color\.signal-green\.content\.none);
|
|
5610
|
+
}
|
|
5611
|
+
|
|
5599
5612
|
.mfui-dTaPGi {
|
|
5600
5613
|
display: inline-flex;
|
|
5601
5614
|
align-items: center;
|