@moneyforward/mfui-components 3.4.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/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/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 +13 -0
- package/package.json +1 -1
|
@@ -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
|
*
|
|
@@ -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
|
@@ -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;
|