@moneyforward/mfui-components 4.1.2 → 4.3.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/DropdownMenu.js +11 -45
- package/dist/src/DropdownMenu/DropdownMenuItem/DropdownMenuItem.js +2 -2
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenu.d.ts +34 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenu.js +57 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenu.types.d.ts +79 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.d.ts +7 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.js +13 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.types.d.ts +6 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.types.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/index.d.ts +2 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/index.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.d.ts +11 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.js +20 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.types.d.ts +18 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.types.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/index.d.ts +2 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/index.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.d.ts +14 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.js +21 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.types.d.ts +9 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.types.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/index.d.ts +2 -0
- package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/index.js +1 -0
- package/dist/src/GlobalHeader/ApplicationMenu/index.d.ts +2 -0
- package/dist/src/GlobalHeader/ApplicationMenu/index.js +1 -0
- package/dist/src/GlobalHeader/GlobalHeader.d.ts +4 -0
- package/dist/src/GlobalHeader/GlobalHeader.js +7 -1
- package/dist/src/GlobalHeader/GlobalHeader.types.d.ts +47 -7
- package/dist/src/GlobalHeader/index.d.ts +1 -0
- package/dist/src/MultipleSelectBox/MultipleSelectBoxTrigger/MultipleSelectBoxTrigger.js +1 -1
- package/dist/src/SelectBox/SelectBox.js +1 -1
- package/dist/src/Toast/api/toast.d.ts +34 -0
- package/dist/src/Toast/api/toast.js +41 -0
- package/dist/src/shared/Menu/MenuCloseContext.d.ts +10 -0
- package/dist/src/shared/Menu/MenuCloseContext.js +7 -0
- package/dist/src/shared/Menu/MenuContainer.d.ts +10 -0
- package/dist/src/{DropdownMenu/DropdownMenuContainer/DropdownMenuContainer.js → shared/Menu/MenuContainer.js} +8 -7
- package/dist/src/{DropdownMenu/DropdownMenuContainer/DropdownMenuContainer.types.d.ts → shared/Menu/MenuContainer.types.d.ts} +6 -9
- package/dist/src/shared/Menu/MenuContainer.types.js +1 -0
- package/dist/src/shared/Menu/index.d.ts +5 -0
- package/dist/src/shared/Menu/index.js +3 -0
- package/dist/src/shared/Menu/useMenuTriggerActivation.d.ts +35 -0
- package/dist/src/shared/Menu/useMenuTriggerActivation.js +69 -0
- package/dist/styled-system/recipes/application-menu-divider-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/application-menu-divider-slot-recipe.js +32 -0
- package/dist/styled-system/recipes/application-menu-group-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/application-menu-group-slot-recipe.js +28 -0
- package/dist/styled-system/recipes/application-menu-item-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/application-menu-item-slot-recipe.js +28 -0
- package/dist/styled-system/recipes/application-menu-slot-recipe.d.ts +33 -0
- package/dist/styled-system/recipes/application-menu-slot-recipe.js +32 -0
- package/dist/styled-system/recipes/index.d.ts +4 -0
- package/dist/styled-system/recipes/index.js +4 -0
- package/dist/styles.css +47 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/src/DropdownMenu/DropdownMenuContainer/DropdownMenuContainer.d.ts +0 -6
- package/dist/src/DropdownMenu/DropdownMenuContainer/index.d.ts +0 -2
- package/dist/src/DropdownMenu/DropdownMenuContainer/index.js +0 -1
- package/dist/src/DropdownMenu/DropdownMenuContext.d.ts +0 -10
- package/dist/src/DropdownMenu/DropdownMenuContext.js +0 -7
- /package/dist/src/{DropdownMenu/DropdownMenuContainer/DropdownMenuContainer.types.js → GlobalHeader/ApplicationMenu/ApplicationMenu.types.js} +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useRef, useState, } from 'react';
|
|
4
3
|
import { DropdownMenuButtonTrigger } from './DropdownMenuButtonTrigger';
|
|
5
|
-
import { DropdownMenuContainer } from './DropdownMenuContainer';
|
|
6
4
|
import { DropdownMenuDivider } from './DropdownMenuDivider';
|
|
7
5
|
import { DropdownMenuItem } from './DropdownMenuItem';
|
|
8
6
|
import { IconButton } from '../IconButton';
|
|
9
7
|
import { Popover } from '../Popover';
|
|
10
|
-
import {
|
|
8
|
+
import { MenuContainer, MenuCloseProvider, useMenuTriggerActivation } from '../shared/Menu';
|
|
11
9
|
import { cx } from '../../styled-system/css';
|
|
12
10
|
import { dropdownMenuSlotRecipe } from '../../styled-system/recipes/dropdown-menu-slot-recipe';
|
|
11
|
+
import { dropdownMenuContainerSlotRecipe } from '../../styled-system/recipes';
|
|
13
12
|
import { DropdownMenuHeading } from './DropdownMenuHeading';
|
|
14
13
|
/**
|
|
15
14
|
* The dropdown menu component.
|
|
@@ -28,57 +27,24 @@ import { DropdownMenuHeading } from './DropdownMenuHeading';
|
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
29
|
export function DropdownMenu({ icon, label, children, triggerProps, tooltipLabel, tooltipPlacement, triggerMiddleTruncate, triggerTypographyVariant, menuPopoverProps, disabled, targetDOMNode, enableAutoUnmount, onOpenStateChanged, onBlur, }) {
|
|
31
|
-
const
|
|
32
|
-
// Tracks keyboard activation (Enter / Space) of the trigger. The resulting click event usually
|
|
33
|
-
// has `detail === 0`, but Safari reports keyboard-triggered clicks with `detail === 1`, so the
|
|
34
|
-
// keydown itself is recorded as the reliable signal.
|
|
35
|
-
const isTriggerActivatedByKeyboardRef = useRef(false);
|
|
36
|
-
const handleTriggerKeyDownLocal = useCallback((event) => {
|
|
37
|
-
// The flag only survives from an Enter / Space keydown to its follow-up click; any other key
|
|
38
|
-
// invalidates the pending keyboard activation so the flag cannot linger when the click never
|
|
39
|
-
// fires.
|
|
40
|
-
isTriggerActivatedByKeyboardRef.current = event.key === 'Enter' || event.key === ' ';
|
|
41
|
-
switch (event.key) {
|
|
42
|
-
case 'ArrowDown':
|
|
43
|
-
event.stopPropagation();
|
|
44
|
-
event.preventDefault();
|
|
45
|
-
setMenuDefaultFocusPosition('first');
|
|
46
|
-
break;
|
|
47
|
-
case 'ArrowUp':
|
|
48
|
-
event.stopPropagation();
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
setMenuDefaultFocusPosition('last');
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}, []);
|
|
30
|
+
const { menuDefaultFocusPosition, handleTriggerKeyDown, handleTriggerBlur, handleTriggerClick } = useMenuTriggerActivation();
|
|
54
31
|
const classes = dropdownMenuSlotRecipe();
|
|
55
|
-
|
|
32
|
+
const containerClasses = dropdownMenuContainerSlotRecipe();
|
|
33
|
+
return (_jsx(Popover, { targetDOMNode: targetDOMNode, minWidth: menuPopoverProps?.minWidth, allowedPlacements: menuPopoverProps?.allowedPlacements, renderTrigger: ({ togglePopover, isPopoverOpen, setTriggerRef, handleTriggerKeyDown: popoverHandleTriggerKeyDown, handleTriggerBlur: popoverHandleTriggerBlur, }) => {
|
|
56
34
|
const handleKeyDownCommon = (event) => {
|
|
57
|
-
|
|
58
|
-
handleTriggerKeyDown(event);
|
|
35
|
+
handleTriggerKeyDown(event, popoverHandleTriggerKeyDown);
|
|
59
36
|
};
|
|
60
37
|
const handleBlurCommon = (event) => {
|
|
61
|
-
|
|
62
|
-
// keydown whose follow-up click never fired), so a later mouse click cannot be
|
|
63
|
-
// misclassified as keyboard activation.
|
|
64
|
-
isTriggerActivatedByKeyboardRef.current = false;
|
|
65
|
-
handleTriggerBlur(event);
|
|
38
|
+
handleTriggerBlur(event, popoverHandleTriggerBlur);
|
|
66
39
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
// WAI-ARIA menu button pattern. Opening with the mouse focuses no item; the menu
|
|
70
|
-
// container receives focus instead so that arrow keys still work.
|
|
71
|
-
const isKeyboardActivation = isTriggerActivatedByKeyboardRef.current || event.detail === 0;
|
|
72
|
-
isTriggerActivatedByKeyboardRef.current = false;
|
|
73
|
-
setMenuDefaultFocusPosition(isKeyboardActivation ? 'first' : 'none');
|
|
74
|
-
togglePopover(event);
|
|
40
|
+
const handleClickCommon = (event) => {
|
|
41
|
+
handleTriggerClick(event, togglePopover);
|
|
75
42
|
};
|
|
76
|
-
return icon ? (_jsx(IconButton, { ref: setTriggerRef, "aria-expanded": isPopoverOpen, "aria-haspopup": "menu", disabled: disabled, onKeyDown: handleKeyDownCommon, onBlur: handleBlurCommon, onClick:
|
|
77
|
-
}, renderContent: ({ closePopover }) => (_jsx(
|
|
43
|
+
return icon ? (_jsx(IconButton, { ref: setTriggerRef, "aria-expanded": isPopoverOpen, "aria-haspopup": "menu", disabled: disabled, onKeyDown: handleKeyDownCommon, onBlur: handleBlurCommon, onClick: handleClickCommon, ...triggerProps, "aria-label": label, children: icon })) : (_jsx(DropdownMenuButtonTrigger, { label: label, tooltipLabel: tooltipLabel, tooltipPlacement: tooltipPlacement, triggerMiddleTruncate: triggerMiddleTruncate, triggerTypographyVariant: triggerTypographyVariant, triggerProps: triggerProps, disabled: disabled, isPopoverOpen: isPopoverOpen, setTriggerRef: setTriggerRef, togglePopover: handleClickCommon, handleTriggerKeyDown: handleKeyDownCommon, handleTriggerBlur: handleBlurCommon }));
|
|
44
|
+
}, renderContent: ({ closePopover }) => (_jsx(MenuCloseProvider, { value: { closeMenuPopover: closePopover }, children: _jsx(MenuContainer, { className: cx(containerClasses.root, 'mfui-DropdownMenuContainer__root'), defaultFocusItem: menuDefaultFocusPosition, onClose: closePopover, children: children }) })), enableAutoFocusOnPopover: false, enableAutoUnmount: enableAutoUnmount, contentProps: {
|
|
78
45
|
className: cx(classes.popover, menuPopoverProps?.className),
|
|
79
46
|
}, onBlur: onBlur, onOpenStateChanged: onOpenStateChanged }));
|
|
80
47
|
}
|
|
81
|
-
// Do not provide DropdownMenuContainer component since it is already defined inside the DropdownMenu component.
|
|
82
48
|
DropdownMenu.Divider = DropdownMenuDivider;
|
|
83
49
|
DropdownMenu.Item = DropdownMenuItem;
|
|
84
50
|
DropdownMenu.Heading = DropdownMenuHeading;
|
|
@@ -6,7 +6,7 @@ import { cx } from '../../../styled-system/css';
|
|
|
6
6
|
import { FocusIndicator } from '../../FocusIndicator';
|
|
7
7
|
import { dropdownMenuItemSlotRecipe } from '../../../styled-system/recipes';
|
|
8
8
|
import { Typography } from '../../Typography';
|
|
9
|
-
import {
|
|
9
|
+
import { useMenuCloseContext } from '../../shared/Menu';
|
|
10
10
|
/**
|
|
11
11
|
* The DropdownMenuItem component.
|
|
12
12
|
* It is used inside the DropdownMenu component.
|
|
@@ -22,7 +22,7 @@ import { useDropdownMenuContext } from '../DropdownMenuContext';
|
|
|
22
22
|
*/
|
|
23
23
|
export function DropdownMenuItem({ children, className, href, target, customLinkComponent, onClick, disabled, disabledMessage, 'aria-labelledby': ariaLabelledby, 'aria-describedby': ariaDescribedby, ...rest }) {
|
|
24
24
|
const classes = dropdownMenuItemSlotRecipe();
|
|
25
|
-
const { closeMenuPopover } =
|
|
25
|
+
const { closeMenuPopover } = useMenuCloseContext();
|
|
26
26
|
const id = useId();
|
|
27
27
|
const itemRef = useRef(null);
|
|
28
28
|
const handleKeyDown = useCallback((event) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ApplicationMenuProps } from './ApplicationMenu.types';
|
|
2
|
+
import { ApplicationMenuDivider } from './ApplicationMenuDivider';
|
|
3
|
+
import { ApplicationMenuItem } from './ApplicationMenuItem';
|
|
4
|
+
import { ApplicationMenuGroup } from './ApplicationMenuGroup';
|
|
5
|
+
import { DropdownMenuHeading } from '../../DropdownMenu/DropdownMenuHeading';
|
|
6
|
+
/**
|
|
7
|
+
* The application menu component.
|
|
8
|
+
* This component provides the applications dropdown menu of the GlobalHeader with its trigger
|
|
9
|
+
* icon button. It is provided as the `GlobalHeader.ApplicationMenu` sub-component.
|
|
10
|
+
* Pass it to the `applicationsMenuSlot` prop of the GlobalHeader component.
|
|
11
|
+
*
|
|
12
|
+
* The Item, Divider, Heading and Group components are provided as sub-components of
|
|
13
|
+
* GlobalHeader.ApplicationMenu. You can use them as follows:
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```jsx
|
|
17
|
+
* <GlobalHeader.ApplicationMenu label="マネーフォワード クラウドのサービス">
|
|
18
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">マイページ</GlobalHeader.ApplicationMenu.Item>
|
|
19
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
20
|
+
* <GlobalHeader.ApplicationMenu.Group label="経理">
|
|
21
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">クラウド会計</GlobalHeader.ApplicationMenu.Item>
|
|
22
|
+
* </GlobalHeader.ApplicationMenu.Group>
|
|
23
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
24
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">サービストップへ</GlobalHeader.ApplicationMenu.Item>
|
|
25
|
+
* </GlobalHeader.ApplicationMenu>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function ApplicationMenu({ children, label, tooltipPlacement, triggerProps, triggerIcon, menuPopoverProps, disabled, targetDOMNode, enableAutoUnmount, onOpenStateChanged, onBlur, }: ApplicationMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare namespace ApplicationMenu {
|
|
30
|
+
export { ApplicationMenuDivider as Divider };
|
|
31
|
+
export { ApplicationMenuItem as Item };
|
|
32
|
+
export { DropdownMenuHeading as Heading };
|
|
33
|
+
export { ApplicationMenuGroup as Group };
|
|
34
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Applications } from '@moneyforward/mfui-icons-react';
|
|
4
|
+
import { ApplicationMenuDivider } from './ApplicationMenuDivider';
|
|
5
|
+
import { ApplicationMenuItem } from './ApplicationMenuItem';
|
|
6
|
+
import { ApplicationMenuGroup } from './ApplicationMenuGroup';
|
|
7
|
+
import { IconButton } from '../../IconButton';
|
|
8
|
+
import { Popover } from '../../Popover';
|
|
9
|
+
import { Tooltip } from '../../Tooltip';
|
|
10
|
+
import { DropdownMenuHeading } from '../../DropdownMenu/DropdownMenuHeading';
|
|
11
|
+
import { MenuContainer, MenuCloseProvider, useMenuTriggerActivation } from '../../shared/Menu';
|
|
12
|
+
import { cx } from '../../../styled-system/css';
|
|
13
|
+
import { applicationMenuSlotRecipe } from '../../../styled-system/recipes';
|
|
14
|
+
/**
|
|
15
|
+
* The application menu component.
|
|
16
|
+
* This component provides the applications dropdown menu of the GlobalHeader with its trigger
|
|
17
|
+
* icon button. It is provided as the `GlobalHeader.ApplicationMenu` sub-component.
|
|
18
|
+
* Pass it to the `applicationsMenuSlot` prop of the GlobalHeader component.
|
|
19
|
+
*
|
|
20
|
+
* The Item, Divider, Heading and Group components are provided as sub-components of
|
|
21
|
+
* GlobalHeader.ApplicationMenu. You can use them as follows:
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <GlobalHeader.ApplicationMenu label="マネーフォワード クラウドのサービス">
|
|
26
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">マイページ</GlobalHeader.ApplicationMenu.Item>
|
|
27
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
28
|
+
* <GlobalHeader.ApplicationMenu.Group label="経理">
|
|
29
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">クラウド会計</GlobalHeader.ApplicationMenu.Item>
|
|
30
|
+
* </GlobalHeader.ApplicationMenu.Group>
|
|
31
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
32
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">サービストップへ</GlobalHeader.ApplicationMenu.Item>
|
|
33
|
+
* </GlobalHeader.ApplicationMenu>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function ApplicationMenu({ children, label, tooltipPlacement = 'bottomStart', triggerProps, triggerIcon, menuPopoverProps, disabled, targetDOMNode, enableAutoUnmount, onOpenStateChanged, onBlur, }) {
|
|
37
|
+
const { menuDefaultFocusPosition, handleTriggerKeyDown, handleTriggerBlur, handleTriggerClick } = useMenuTriggerActivation();
|
|
38
|
+
const classes = applicationMenuSlotRecipe();
|
|
39
|
+
return (_jsx(Popover, { targetDOMNode: targetDOMNode, minWidth: menuPopoverProps?.minWidth, allowedPlacements: menuPopoverProps?.allowedPlacements, renderTrigger: ({ togglePopover, isPopoverOpen, setTriggerRef, handleTriggerKeyDown: popoverHandleTriggerKeyDown, handleTriggerBlur: popoverHandleTriggerBlur, }) => {
|
|
40
|
+
const handleKeyDownCommon = (event) => {
|
|
41
|
+
handleTriggerKeyDown(event, popoverHandleTriggerKeyDown);
|
|
42
|
+
};
|
|
43
|
+
const handleBlurCommon = (event) => {
|
|
44
|
+
handleTriggerBlur(event, popoverHandleTriggerBlur);
|
|
45
|
+
};
|
|
46
|
+
const handleClickCommon = (event) => {
|
|
47
|
+
handleTriggerClick(event, togglePopover);
|
|
48
|
+
};
|
|
49
|
+
return (_jsx(Tooltip, { content: label, placement: tooltipPlacement, hideFromScreenReader: true, children: _jsx(IconButton, { ref: setTriggerRef, "aria-expanded": isPopoverOpen, "aria-haspopup": "menu", disabled: disabled, onKeyDown: handleKeyDownCommon, onBlur: handleBlurCommon, onClick: handleClickCommon, ...triggerProps, "aria-label": label, children: triggerIcon ?? _jsx(Applications, { "aria-hidden": true }) }) }));
|
|
50
|
+
}, renderContent: ({ closePopover }) => (_jsx(MenuCloseProvider, { value: { closeMenuPopover: closePopover }, children: _jsx(MenuContainer, { className: cx(classes.menuContainer, 'mfui-ApplicationMenu__menuContainer'), defaultFocusItem: menuDefaultFocusPosition, onClose: closePopover, children: children }) })), enableAutoFocusOnPopover: false, enableAutoUnmount: enableAutoUnmount, contentProps: {
|
|
51
|
+
className: cx(classes.popover, 'mfui-ApplicationMenu__popover', menuPopoverProps?.className),
|
|
52
|
+
}, onBlur: onBlur, onOpenStateChanged: onOpenStateChanged }));
|
|
53
|
+
}
|
|
54
|
+
ApplicationMenu.Divider = ApplicationMenuDivider;
|
|
55
|
+
ApplicationMenu.Item = ApplicationMenuItem;
|
|
56
|
+
ApplicationMenu.Heading = DropdownMenuHeading;
|
|
57
|
+
ApplicationMenu.Group = ApplicationMenuGroup;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { type IconButtonProps } from '../../IconButton';
|
|
3
|
+
import { type PopoverProps } from '../../Popover';
|
|
4
|
+
import { type TooltipProps } from '../../Tooltip';
|
|
5
|
+
export type ApplicationMenuProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The content of the application menu.
|
|
8
|
+
*
|
|
9
|
+
* Compose it with the `GlobalHeader.ApplicationMenu.Item` and `GlobalHeader.ApplicationMenu.Divider`
|
|
10
|
+
* components.
|
|
11
|
+
* Layout elements (e.g. columns grouping the application links) can be used freely
|
|
12
|
+
* around the items.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```jsx
|
|
16
|
+
* <GlobalHeader.ApplicationMenu label="マネーフォワード クラウドのサービス">
|
|
17
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">マイページ</GlobalHeader.ApplicationMenu.Item>
|
|
18
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
19
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">サービストップへ</GlobalHeader.ApplicationMenu.Item>
|
|
20
|
+
* </GlobalHeader.ApplicationMenu>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* The accessible label of the trigger icon button of the application menu.
|
|
26
|
+
* It is also shown as the tooltip content of the trigger.
|
|
27
|
+
*/
|
|
28
|
+
label: string;
|
|
29
|
+
/**
|
|
30
|
+
* The placement of the trigger tooltip.
|
|
31
|
+
*
|
|
32
|
+
* Accepts a single placement (e.g. `"top"`) for fixed positioning, or an array
|
|
33
|
+
* (e.g. `["top", "bottom"]`) for priority-based positioning with fallbacks.
|
|
34
|
+
*
|
|
35
|
+
* @default 'bottomStart'
|
|
36
|
+
*/
|
|
37
|
+
tooltipPlacement?: TooltipProps['placement'];
|
|
38
|
+
/**
|
|
39
|
+
* The props of the trigger icon button.
|
|
40
|
+
* Use this prop if you need to customize the style of the trigger icon button.
|
|
41
|
+
*/
|
|
42
|
+
triggerProps?: Pick<IconButtonProps, 'outlined' | 'className'>;
|
|
43
|
+
/**
|
|
44
|
+
* The icon of the trigger icon button.
|
|
45
|
+
*
|
|
46
|
+
* @default The Applications icon
|
|
47
|
+
*/
|
|
48
|
+
triggerIcon?: ReactElement;
|
|
49
|
+
/**
|
|
50
|
+
* The properties for the popover content panel.
|
|
51
|
+
*
|
|
52
|
+
* @property className - The class name of the popover content panel.
|
|
53
|
+
*
|
|
54
|
+
* @property minWidth - The minimum width of the popover content panel.
|
|
55
|
+
*
|
|
56
|
+
* @property allowedPlacements - Allowed placements for the popover relative to the trigger element.
|
|
57
|
+
*/
|
|
58
|
+
menuPopoverProps?: Pick<ComponentPropsWithoutRef<'div'>, 'className'> & {
|
|
59
|
+
minWidth?: PopoverProps['minWidth'];
|
|
60
|
+
allowedPlacements?: PopoverProps['allowedPlacements'];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The disabled state of the trigger element.
|
|
64
|
+
*/
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Callback fired when the open state of the ApplicationMenu changes.
|
|
68
|
+
*
|
|
69
|
+
* @param open - The new open state of the ApplicationMenu.
|
|
70
|
+
*/
|
|
71
|
+
onOpenStateChanged?: (open: boolean) => void;
|
|
72
|
+
/**
|
|
73
|
+
* The callback function that is called when the ApplicationMenu loses focus.
|
|
74
|
+
* This will only fire when the user truly leaves the component (not when the popover opens).
|
|
75
|
+
*
|
|
76
|
+
* @param event - The blur event from the trigger element
|
|
77
|
+
*/
|
|
78
|
+
onBlur?: (event: React.FocusEvent<HTMLElement>) => void;
|
|
79
|
+
} & Pick<PopoverProps, 'targetDOMNode' | 'enableAutoUnmount'>;
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ApplicationMenuDividerProps } from './ApplicationMenuDivider.types';
|
|
2
|
+
/**
|
|
3
|
+
* The divider component for the menu of the application menu.
|
|
4
|
+
* It separates the menu sections (e.g. the top links, the applications list and the bottom links).
|
|
5
|
+
* This component should be used inside the `ApplicationMenu` component.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ApplicationMenuDivider: import("react").ForwardRefExoticComponent<ApplicationMenuDividerProps & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { cx } from '../../../../styled-system/css';
|
|
4
|
+
import { applicationMenuDividerSlotRecipe } from '../../../../styled-system/recipes';
|
|
5
|
+
/**
|
|
6
|
+
* The divider component for the menu of the application menu.
|
|
7
|
+
* It separates the menu sections (e.g. the top links, the applications list and the bottom links).
|
|
8
|
+
* This component should be used inside the `ApplicationMenu` component.
|
|
9
|
+
*/
|
|
10
|
+
export const ApplicationMenuDivider = forwardRef(({ className }, ref) => {
|
|
11
|
+
const classes = applicationMenuDividerSlotRecipe();
|
|
12
|
+
return (_jsx("div", { ref: ref, role: "separator", className: cx(classes.root, 'mfui-ApplicationMenuDivider__root', className), children: _jsx("div", { className: cx(classes.line, 'mfui-ApplicationMenuDivider__line') }) }));
|
|
13
|
+
});
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuDivider/ApplicationMenuDivider.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApplicationMenuDivider } from './ApplicationMenuDivider';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ApplicationMenuGroupProps } from './ApplicationMenuGroup.types';
|
|
2
|
+
/**
|
|
3
|
+
* The ApplicationMenuGroup component.
|
|
4
|
+
* It is used inside the ApplicationMenu component to group related `ApplicationMenu.Item`s under
|
|
5
|
+
* a heading (e.g. the guideline's labelled application groups).
|
|
6
|
+
*
|
|
7
|
+
* It renders the heading (via `ApplicationMenu.Heading`) and wires up the group's
|
|
8
|
+
* `aria-labelledby` automatically, so screen readers announce the group's label together with
|
|
9
|
+
* each item inside it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ApplicationMenuGroup({ label, children, className }: ApplicationMenuGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { cx } from '../../../../styled-system/css';
|
|
5
|
+
import { applicationMenuGroupSlotRecipe } from '../../../../styled-system/recipes';
|
|
6
|
+
import { DropdownMenuHeading } from '../../../DropdownMenu/DropdownMenuHeading';
|
|
7
|
+
/**
|
|
8
|
+
* The ApplicationMenuGroup component.
|
|
9
|
+
* It is used inside the ApplicationMenu component to group related `ApplicationMenu.Item`s under
|
|
10
|
+
* a heading (e.g. the guideline's labelled application groups).
|
|
11
|
+
*
|
|
12
|
+
* It renders the heading (via `ApplicationMenu.Heading`) and wires up the group's
|
|
13
|
+
* `aria-labelledby` automatically, so screen readers announce the group's label together with
|
|
14
|
+
* each item inside it.
|
|
15
|
+
*/
|
|
16
|
+
export function ApplicationMenuGroup({ label, children, className }) {
|
|
17
|
+
const classes = applicationMenuGroupSlotRecipe();
|
|
18
|
+
const headingId = useId();
|
|
19
|
+
return (_jsxs("div", { role: "group", "aria-labelledby": headingId, className: cx(classes.root, 'mfui-ApplicationMenuGroup__root', className), children: [_jsx(DropdownMenuHeading, { id: headingId, children: label }), children] }));
|
|
20
|
+
}
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The props for the ApplicationMenuGroup component.
|
|
3
|
+
*/
|
|
4
|
+
export type ApplicationMenuGroupProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The heading label of the group, rendered via `ApplicationMenu.Heading` and wired to the
|
|
7
|
+
* group's `aria-labelledby` automatically.
|
|
8
|
+
*/
|
|
9
|
+
label: string;
|
|
10
|
+
/**
|
|
11
|
+
* The content of the group. Compose it with `ApplicationMenu.Item`.
|
|
12
|
+
*/
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The class name to apply to the component.
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuGroup/ApplicationMenuGroup.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApplicationMenuGroup } from './ApplicationMenuGroup';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ApplicationMenuItemProps } from './ApplicationMenuItem.types';
|
|
2
|
+
/**
|
|
3
|
+
* The ApplicationMenuItem component.
|
|
4
|
+
* It is used inside the ApplicationMenu component.
|
|
5
|
+
*
|
|
6
|
+
* It renders a `DropdownMenu.Item` with its own width/layout styling, so it inherits the same
|
|
7
|
+
* focus/keyboard navigation, `disabled`, `disabledMessage` and `aria-labelledby` behavior. See
|
|
8
|
+
* `DropdownMenu.Item` for the full behavior documentation.
|
|
9
|
+
*
|
|
10
|
+
* The item width is 168px by default as defined in the guideline. It can be adjusted through the
|
|
11
|
+
* `--mfui-application-menu-item-width` custom property (e.g. `100%` for the full-width rows above
|
|
12
|
+
* and below the divider).
|
|
13
|
+
*/
|
|
14
|
+
export declare function ApplicationMenuItem({ className, ...rest }: ApplicationMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from '../../../../styled-system/css';
|
|
4
|
+
import { applicationMenuItemSlotRecipe } from '../../../../styled-system/recipes';
|
|
5
|
+
import { DropdownMenuItem } from '../../../DropdownMenu/DropdownMenuItem';
|
|
6
|
+
/**
|
|
7
|
+
* The ApplicationMenuItem component.
|
|
8
|
+
* It is used inside the ApplicationMenu component.
|
|
9
|
+
*
|
|
10
|
+
* It renders a `DropdownMenu.Item` with its own width/layout styling, so it inherits the same
|
|
11
|
+
* focus/keyboard navigation, `disabled`, `disabledMessage` and `aria-labelledby` behavior. See
|
|
12
|
+
* `DropdownMenu.Item` for the full behavior documentation.
|
|
13
|
+
*
|
|
14
|
+
* The item width is 168px by default as defined in the guideline. It can be adjusted through the
|
|
15
|
+
* `--mfui-application-menu-item-width` custom property (e.g. `100%` for the full-width rows above
|
|
16
|
+
* and below the divider).
|
|
17
|
+
*/
|
|
18
|
+
export function ApplicationMenuItem({ className, ...rest }) {
|
|
19
|
+
const classes = applicationMenuItemSlotRecipe();
|
|
20
|
+
return _jsx(DropdownMenuItem, { ...rest, className: cx(classes.root, 'mfui-ApplicationMenuItem__root', className) });
|
|
21
|
+
}
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.types.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DropdownMenuItemProps } from '../../../DropdownMenu/DropdownMenuItem';
|
|
2
|
+
/**
|
|
3
|
+
* The props for the ApplicationMenuItem component.
|
|
4
|
+
*
|
|
5
|
+
* Identical to `DropdownMenuItemProps` — `ApplicationMenuItem` renders a `DropdownMenu.Item`
|
|
6
|
+
* under the hood with its own width/layout styling, so it supports the same `disabled`,
|
|
7
|
+
* `disabledMessage` and `aria-labelledby` / `aria-describedby` props.
|
|
8
|
+
*/
|
|
9
|
+
export type ApplicationMenuItemProps = DropdownMenuItemProps;
|
package/dist/src/GlobalHeader/ApplicationMenu/ApplicationMenuItem/ApplicationMenuItem.types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApplicationMenuItem } from './ApplicationMenuItem';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ApplicationMenu } from './ApplicationMenu';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GlobalHeaderProps } from './GlobalHeader.types';
|
|
2
|
+
import { ApplicationMenu } from './ApplicationMenu';
|
|
2
3
|
/**
|
|
3
4
|
* The global header component.
|
|
4
5
|
* The global header component is a top-level navigation component that is used to display the application's logo and navigation elements.
|
|
@@ -7,3 +8,6 @@ import { type GlobalHeaderProps } from './GlobalHeader.types';
|
|
|
7
8
|
* If you need a self-contained layout that already includes both header and navigation features, use `Sidebar` instead.
|
|
8
9
|
*/
|
|
9
10
|
export declare function GlobalHeader({ className, mainNavigationButtonProps, applicationsMenuSlot, experimentalApplicationsMenuButtonProps, logoSlot, rightPaneSlot, disableResponsive, }: GlobalHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare namespace GlobalHeader {
|
|
12
|
+
export { ApplicationMenu };
|
|
13
|
+
}
|
|
@@ -4,6 +4,7 @@ import { cx } from '../../styled-system/css';
|
|
|
4
4
|
import { globalHeaderSlotRecipe } from '../../styled-system/recipes';
|
|
5
5
|
import { IconButton } from '../IconButton';
|
|
6
6
|
import { Tooltip } from '../Tooltip';
|
|
7
|
+
import { ApplicationMenu } from './ApplicationMenu';
|
|
7
8
|
import { ApplicationsExperimentalIcon } from './ApplicationsExperimentalIcon';
|
|
8
9
|
/**
|
|
9
10
|
* The global header component.
|
|
@@ -22,5 +23,10 @@ export function GlobalHeader({ className, mainNavigationButtonProps, application
|
|
|
22
23
|
const handleClickExperimentalApplicationsMenuButton = (event) => {
|
|
23
24
|
experimentalApplicationsMenuButtonProps?.onClick?.(event);
|
|
24
25
|
};
|
|
25
|
-
return (_jsxs("header", { className: cx(classes.root, 'mfui-GlobalHeader__root', className), children: [_jsxs("div", { className: cx(classes.leftPane, 'mfui-GlobalHeader__leftPane'), children: [responsive && mainNavigationButtonProps ? (_jsx(Tooltip, { className: cx(classes.mainNavigationButton, 'mfui-GlobalHeader__mainNavigationButton'), content: mainNavigationButtonProps['aria-label'], placement: "bottomStart", children: _jsx(IconButton, { "aria-label": mainNavigationButtonProps['aria-label'], onClick: handleClickMainNavigationButton, children: _jsx(Menu, { "aria-hidden": true }) }) })) : null, experimentalApplicationsMenuButtonProps ? (_jsx("div", { className: cx(classes.applicationsMenuSlot, 'mfui-GlobalHeader__applicationsMenuSlot'), children:
|
|
26
|
+
return (_jsxs("header", { className: cx(classes.root, 'mfui-GlobalHeader__root', className), children: [_jsxs("div", { className: cx(classes.leftPane, 'mfui-GlobalHeader__leftPane'), children: [responsive && mainNavigationButtonProps ? (_jsx(Tooltip, { className: cx(classes.mainNavigationButton, 'mfui-GlobalHeader__mainNavigationButton'), content: mainNavigationButtonProps['aria-label'], placement: "bottomStart", children: _jsx(IconButton, { "aria-label": mainNavigationButtonProps['aria-label'], onClick: handleClickMainNavigationButton, children: _jsx(Menu, { "aria-hidden": true }) }) })) : null, experimentalApplicationsMenuButtonProps ? (_jsx("div", { className: cx(classes.applicationsMenuSlot, 'mfui-GlobalHeader__applicationsMenuSlot'), children: experimentalApplicationsMenuButtonProps.children != null ? (_jsx(ApplicationMenu, { label: experimentalApplicationsMenuButtonProps['aria-label'], triggerIcon: _jsx(ApplicationsExperimentalIcon, { "aria-hidden": true }), triggerProps: {
|
|
27
|
+
className: cx(classes.experimentalApplicationsMenuButton, 'mfui-GlobalHeader__experimentalApplicationsMenuButton'),
|
|
28
|
+
}, menuPopoverProps: { allowedPlacements: ['bottom-start'] }, children: experimentalApplicationsMenuButtonProps.children })) : (_jsx(Tooltip, { content: experimentalApplicationsMenuButtonProps['aria-label'], placement: "bottomStart", children: _jsx(IconButton, { className: cx(classes.experimentalApplicationsMenuButton, 'mfui-GlobalHeader__experimentalApplicationsMenuButton'), "aria-label": experimentalApplicationsMenuButtonProps['aria-label'], onClick: handleClickExperimentalApplicationsMenuButton, children: _jsx(ApplicationsExperimentalIcon, { "aria-hidden": true }) }) })) })) : applicationsMenuSlot ? (_jsx("div", { className: cx(classes.applicationsMenuSlot, 'mfui-GlobalHeader__applicationsMenuSlot'), children: applicationsMenuSlot })) : null, _jsx("div", { className: cx(classes.logo, 'mfui-GlobalHeader__logo'), children: logoSlot.base }), _jsx("div", { className: cx(classes.logoNarrowViewport, 'mfui-GlobalHeader__logoNarrowViewport'), children: logoSlot.narrowViewport ?? logoSlot.base })] }), _jsxs("div", { className: cx(classes.rightPane, 'mfui-GlobalHeader__rightPane'), children: [_jsx("div", { className: cx(classes.rightPaneSlot, 'mfui-GlobalHeader__rightPaneSlot'), children: rightPaneSlot.base }), responsive && rightPaneSlot.narrowViewport ? (_jsx("div", { className: cx(classes.rightPaneSlotNarrowViewport, 'mfui-GlobalHeader__rightPaneSlotNarrowViewport'), children: rightPaneSlot.narrowViewport })) : null] })] }));
|
|
26
29
|
}
|
|
30
|
+
// The applications dropdown menu designed for the GlobalHeader.
|
|
31
|
+
// Pass it to the `applicationsMenuSlot` prop of the GlobalHeader component.
|
|
32
|
+
GlobalHeader.ApplicationMenu = ApplicationMenu;
|
|
@@ -27,10 +27,6 @@ type MainNavigationButtonProps = {
|
|
|
27
27
|
* **EXPERIMENTAL**: This feature is experimental and may be changed or removed in the future.
|
|
28
28
|
*/
|
|
29
29
|
type ExperimentalApplicationsMenuButtonProps = {
|
|
30
|
-
/**
|
|
31
|
-
* The handler to be called when the applications menu button is clicked.
|
|
32
|
-
*/
|
|
33
|
-
onClick: IconButtonProps['onClick'];
|
|
34
30
|
/**
|
|
35
31
|
* The accessible label to specify how you want the applications menu button to be recognized and read by screen readers.
|
|
36
32
|
* This prop is required.
|
|
@@ -42,15 +38,58 @@ type ExperimentalApplicationsMenuButtonProps = {
|
|
|
42
38
|
* <GlobalHeader
|
|
43
39
|
* experimentalApplicationsMenuButtonProps={{
|
|
44
40
|
* onClick,
|
|
45
|
-
* 'aria-label': '
|
|
41
|
+
* 'aria-label': 'マネーフォワード クラウドのサービス',
|
|
46
42
|
* }}
|
|
47
43
|
* />
|
|
48
44
|
*
|
|
49
|
-
* // The button will be described as "
|
|
45
|
+
* // The button will be described as "マネーフォワード クラウドのサービス" by screen readers.
|
|
50
46
|
* ```
|
|
51
47
|
*/
|
|
52
48
|
'aria-label': IconButtonProps['aria-label'];
|
|
53
|
-
}
|
|
49
|
+
} & ({
|
|
50
|
+
/**
|
|
51
|
+
* The handler to be called when the applications menu button is clicked.
|
|
52
|
+
*/
|
|
53
|
+
onClick: IconButtonProps['onClick'];
|
|
54
|
+
/**
|
|
55
|
+
* This property is ignored if the onClick property is provided.
|
|
56
|
+
*/
|
|
57
|
+
children?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
/**
|
|
60
|
+
* The accessible label of the applications menu button.
|
|
61
|
+
* It is also shown as the tooltip content of the button.
|
|
62
|
+
*/
|
|
63
|
+
'aria-label': string;
|
|
64
|
+
/**
|
|
65
|
+
* This property is ignored if the children property is provided.
|
|
66
|
+
*/
|
|
67
|
+
onClick?: undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The content of the applications menu opened by the button.
|
|
70
|
+
*
|
|
71
|
+
* When provided, clicking the button opens the applications dropdown menu.
|
|
72
|
+
* Compose it with the `GlobalHeader.ApplicationMenu.Item` and
|
|
73
|
+
* `GlobalHeader.ApplicationMenu.Divider` components.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```jsx
|
|
77
|
+
* <GlobalHeader
|
|
78
|
+
* experimentalApplicationsMenuButtonProps={{
|
|
79
|
+
* 'aria-label': 'マネーフォワード クラウドのサービス',
|
|
80
|
+
* children: (
|
|
81
|
+
* <>
|
|
82
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">マイページ</GlobalHeader.ApplicationMenu.Item>
|
|
83
|
+
* <GlobalHeader.ApplicationMenu.Divider />
|
|
84
|
+
* <GlobalHeader.ApplicationMenu.Item href="https://example.com">サービストップへ</GlobalHeader.ApplicationMenu.Item>
|
|
85
|
+
* </>
|
|
86
|
+
* ),
|
|
87
|
+
* }}
|
|
88
|
+
* />
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
children: ReactNode;
|
|
92
|
+
});
|
|
54
93
|
export type GlobalHeaderProps = {
|
|
55
94
|
/**
|
|
56
95
|
* The class name of the global header.
|
|
@@ -67,6 +106,7 @@ export type GlobalHeaderProps = {
|
|
|
67
106
|
* This slot is displayed when the viewport width is the breakpoint or larger.
|
|
68
107
|
*
|
|
69
108
|
* This element must be an applications dropdown menu as defined in Figma.
|
|
109
|
+
* Use the `GlobalHeader.ApplicationMenu` component for this slot.
|
|
70
110
|
*/
|
|
71
111
|
applicationsMenuSlot?: ReactNode;
|
|
72
112
|
/**
|
|
@@ -48,6 +48,6 @@ placeholder, renderDisplayValue, updateSelectedValues, clearButtonProps, disable
|
|
|
48
48
|
.map((option) => option.value)
|
|
49
49
|
.filter((v) => v != null)
|
|
50
50
|
.map(String);
|
|
51
|
-
return (_jsx(FocusIndicator, { children: _jsxs("div", { ref: wrapperRef, className: cx(classes.wrapper, 'mfui-MultipleSelectBoxTrigger__wrapper', triggerWrapperProps?.className), children: [_jsx("button", { ref: mergeRefs(ref, triggerRef), type: "button", role: "combobox", "aria-controls": listBoxId, "aria-expanded": isOptionPanelOpen, "aria-haspopup": "listbox", "aria-invalid": invalid, "aria-required": required || undefined, "data-mfui-caution": caution && !invalid ? true : undefined, value: selectedValues, disabled: disabled, onKeyDown: onKeyDown, onBlur: onBlur, ...rest, ...triggerProps, className: cx(classes.trigger, 'mfui-MultipleSelectBoxTrigger__trigger', triggerProps?.className) }), _jsx("input", { type: "hidden", name: name, value: selectedValues }), _jsx("div", { className: cx(classes.displayValues, 'mfui-MultipleSelectBoxTrigger__displayValues'), "data-mfui-content": "multiple-select-box-trigger-display-values", children: renderer() }), selectedOptions.length > 0 && !disabled && !disableClearButton ? (_jsx("div", { className: cx(classes.clearButtonContainer, 'mfui-MultipleSelectBoxTrigger__clearButtonContainer'), children: _jsx(ClearButton, { size: size === 'small' ? 'small' : 'default', className: cx(classes.clearButton, 'mfui-MultipleSelectBoxTrigger__clearButton'), "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "multiple-select-box-clear-button", onClick: handleClearValue }) })) : null, _jsx("div", { className: cx(classes.dropdownIconContainer, 'mfui-MultipleSelectBoxTrigger__dropdownIconContainer'), children: _jsx(DropdownIcon, { "aria-hidden": "true", className: cx(classes.dropdownIcon, 'mfui-MultipleSelectBoxTrigger__dropdownIcon') }) })] }) }));
|
|
51
|
+
return (_jsx(FocusIndicator, { children: _jsxs("div", { ref: wrapperRef, className: cx(classes.wrapper, 'mfui-MultipleSelectBoxTrigger__wrapper', triggerWrapperProps?.className), children: [_jsx("button", { ref: mergeRefs(ref, triggerRef), type: "button", role: "combobox", "aria-controls": isOptionPanelOpen ? listBoxId : undefined, "aria-expanded": isOptionPanelOpen, "aria-haspopup": "listbox", "aria-invalid": invalid, "aria-required": required || undefined, "data-mfui-caution": caution && !invalid ? true : undefined, value: selectedValues, disabled: disabled, onKeyDown: onKeyDown, onBlur: onBlur, ...rest, ...triggerProps, className: cx(classes.trigger, 'mfui-MultipleSelectBoxTrigger__trigger', triggerProps?.className) }), _jsx("input", { type: "hidden", name: name, value: selectedValues }), _jsx("div", { className: cx(classes.displayValues, 'mfui-MultipleSelectBoxTrigger__displayValues'), "data-mfui-content": "multiple-select-box-trigger-display-values", children: renderer() }), selectedOptions.length > 0 && !disabled && !disableClearButton ? (_jsx("div", { className: cx(classes.clearButtonContainer, 'mfui-MultipleSelectBoxTrigger__clearButtonContainer'), children: _jsx(ClearButton, { size: size === 'small' ? 'small' : 'default', className: cx(classes.clearButton, 'mfui-MultipleSelectBoxTrigger__clearButton'), "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "multiple-select-box-clear-button", onClick: handleClearValue }) })) : null, _jsx("div", { className: cx(classes.dropdownIconContainer, 'mfui-MultipleSelectBoxTrigger__dropdownIconContainer'), children: _jsx(DropdownIcon, { "aria-hidden": "true", className: cx(classes.dropdownIcon, 'mfui-MultipleSelectBoxTrigger__dropdownIcon') }) })] }) }));
|
|
52
52
|
}
|
|
53
53
|
export const MultipleSelectBoxTrigger = forwardRef(MultipleSelectBoxTriggerInner);
|
|
@@ -377,7 +377,7 @@ export const SelectBox = forwardRef((props, ref) => {
|
|
|
377
377
|
const hasSelectedValue = value !== undefined || localSelectedOption !== null;
|
|
378
378
|
const showClearButton = enableClearButton && hasSelectedValue;
|
|
379
379
|
// Use Popover's centralized blur handling instead of custom logic
|
|
380
|
-
return (_jsx(Popover, { open: isOptionPanelOpen, targetDOMNode: targetDOMNode, minWidth: popoverContentProps?.minWidth, maxHeight: popoverWrapperProps?.maxHeight, allowedPlacements: popoverContentProps?.allowedPlacements, enableConstrainedContentWidth: enableConstrainedPopoverWidth, renderContent: () => (_jsx("div", { ref: optionPanelRef,
|
|
380
|
+
return (_jsx(Popover, { open: isOptionPanelOpen, targetDOMNode: targetDOMNode, minWidth: popoverContentProps?.minWidth, maxHeight: popoverWrapperProps?.maxHeight, allowedPlacements: popoverContentProps?.allowedPlacements, enableConstrainedContentWidth: enableConstrainedPopoverWidth, renderContent: () => (_jsx("div", { ref: optionPanelRef, className: cx(classes.optionPanel, 'mfui-SelectBox__optionPanel', popoverContentProps?.className), tabIndex: -1, onKeyDown: handleKeyDownMenu, children: renderPopoverContent ? (renderPopoverContent({ searchNode, optionsNode })) : (_jsxs(_Fragment, { children: [searchNode, optionsNode] })) })), renderTrigger: ({ setTriggerRef, togglePopover, handleTriggerKeyDown, handleTriggerBlur }) => (_jsxs("div", { ref: setTriggerRef, ...triggerWrapperProps, className: cx(classes.triggerWrapper, 'mfui-SelectBox__triggerWrapper', triggerWrapperProps?.className), children: [_jsx(FocusIndicator, { children: _jsxs("button", { ref: triggerRef, id: id, type: "button", role: "combobox", disabled: disabled, "aria-label": triggerProps?.['aria-label'], "aria-controls": isOptionPanelOpen ? listBoxId : undefined, "aria-describedby": triggerProps?.['aria-describedby'], "aria-expanded": isOptionPanelOpen, "aria-haspopup": "listbox", "aria-invalid": invalid, "aria-required": required, className: cx(classes.trigger, 'mfui-SelectBox__trigger', triggerProps?.className), "data-placeholder": !!placeholder && !localSelectedOption, "data-selected": !!localSelectedOption, "data-mfui-has-clear-button": showClearButton, "data-mfui-caution": caution && !invalid ? true : undefined, onClick: togglePopover, onKeyDown: (event) => {
|
|
381
381
|
handleTypeAhead(event.nativeEvent);
|
|
382
382
|
handleTriggerKeyDown(event);
|
|
383
383
|
}, onBlur: handleTriggerBlur, children: [_jsx("span", { "data-mfui-content": "select-box-trigger-display-value", children: renderTriggerLabel() }), _jsx(DropdownIcon, { "aria-hidden": "true", focusable: false }), _jsx("input", { ref: ref, type: "hidden", value: localSelectedOption?.value ?? '', name: name, disabled: disabled })] }) }), showClearButton ? (_jsx("div", { className: cx(classes.clearButtonWrapper, 'mfui-SelectBox__clearButtonWrapper'), children: _jsx(ClearButton, { size: size === 'small' ? 'small' : size === 'large' ? 'large' : 'default', "aria-label": clearButtonProps?.['aria-label'] ?? '値をクリアする', "data-mfui-content": "select-box-clear-button", onClick: (event) => {
|