@redocly/theme 0.55.0-next.3 → 0.55.0-next.4
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.
|
@@ -66,9 +66,14 @@ function MenuItem(props) {
|
|
|
66
66
|
handleExpand();
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
+
const handleExpandOnEnter = (event) => {
|
|
70
|
+
if (event.key === 'Enter') {
|
|
71
|
+
handleOnClick();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
69
74
|
const chevron = hasChevron ? (isExpanded ? (react_1.default.createElement(ChevronDownIcon_1.ChevronDownIcon, { size: "var(--menu-item-label-chevron-size)", color: "--tree-content-color-default" })) : (react_1.default.createElement(ChevronRightIcon_1.ChevronRightIcon, { size: "var(--menu-item-label-chevron-size)", color: "--tree-content-color-default" }))) : null;
|
|
70
75
|
const httpColor = item.deprecated ? 'http-deprecated' : item.httpVerb;
|
|
71
|
-
const label = item.label && (react_1.default.createElement(MenuItemLabelWrapper, { active: item.active, deprecated: item.deprecated, depth: depth, withChevron: hasChevron, isSeparator: isSeparator, onClick: handleOnClick, ref: labelRef, role: item.link ? 'none' : 'link', "data-testid": "menu-item-label" },
|
|
76
|
+
const label = item.label && (react_1.default.createElement(MenuItemLabelWrapper, { active: item.active, deprecated: item.deprecated, depth: depth, withChevron: hasChevron, isSeparator: isSeparator, onClick: handleOnClick, onKeyDown: handleExpandOnEnter, ref: labelRef, role: item.link ? 'none' : 'link', tabIndex: !item.link ? 0 : undefined, "data-testid": "menu-item-label" },
|
|
72
77
|
hasChevron ? react_1.default.createElement(ChevronWrapper, null, chevron) : null,
|
|
73
78
|
item.icon ? react_1.default.createElement(MenuItemIcon, { src: item.icon }) : null,
|
|
74
79
|
react_1.default.createElement(MenuItemLabelTextWrapper, null,
|
|
@@ -80,7 +85,7 @@ function MenuItem(props) {
|
|
|
80
85
|
isDrilldown ? react_1.default.createElement(ArrowRightIcon_1.ArrowRightIcon, { size: "12px" }) : null,
|
|
81
86
|
hasHttpTag ? (react_1.default.createElement(HttpTag_1.HttpTag, { color: httpColor || '' }, item.httpVerb === 'hook' ? 'event' : item.httpVerb)) : null));
|
|
82
87
|
return (react_1.default.createElement(MenuItemWrapper, { "data-component-name": "Menu/MenuItem", className: generateClassName({ type, item, className }) },
|
|
83
|
-
item.link ? (react_1.default.createElement(MenuItemLink, { to: item.link, external: item.external, target: item.target, languageInsensitive: item.languageInsensitive }, label)) : (label),
|
|
88
|
+
item.link ? (react_1.default.createElement(MenuItemLink, { to: item.link, external: item.external, target: item.target, languageInsensitive: item.languageInsensitive, onKeyDown: handleExpandOnEnter }, label)) : (label),
|
|
84
89
|
isNested ? (react_1.default.createElement(MenuItemNestedWrapper, { depth: depth, ref: nestedMenuRef, style: style }, isExpanded || !canUnmount ? props.children : null)) : null,
|
|
85
90
|
item.separatorLine ? (react_1.default.createElement(MenuItemSeparatorLine, { depth: depth, linePosition: item.linePosition })) : null));
|
|
86
91
|
}
|
|
@@ -128,7 +133,6 @@ const MenuItemWrapper = styled_components_1.default.div `
|
|
|
128
133
|
}
|
|
129
134
|
`;
|
|
130
135
|
const MenuItemNestedWrapper = styled_components_1.default.div `
|
|
131
|
-
overflow: hidden;
|
|
132
136
|
order: 1;
|
|
133
137
|
position: relative;
|
|
134
138
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import type { JSX } from 'react';
|
|
5
4
|
import type { ItemState, MenuItemProps } from '@redocly/theme/core/types';
|
|
5
|
+
import type { JSX, KeyboardEvent } from 'react';
|
|
6
6
|
|
|
7
7
|
import { useNestedMenu, useThemeHooks } from '@redocly/theme/core/hooks';
|
|
8
8
|
import { LaunchIcon } from '@redocly/theme/icons/LaunchIcon/LaunchIcon';
|
|
@@ -49,6 +49,12 @@ export function MenuItem(props: React.PropsWithChildren<MenuItemProps>): JSX.Ele
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
const handleExpandOnEnter = (event: KeyboardEvent) => {
|
|
53
|
+
if (event.key === 'Enter') {
|
|
54
|
+
handleOnClick();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
52
58
|
const chevron = hasChevron ? (
|
|
53
59
|
isExpanded ? (
|
|
54
60
|
<ChevronDownIcon
|
|
@@ -64,6 +70,7 @@ export function MenuItem(props: React.PropsWithChildren<MenuItemProps>): JSX.Ele
|
|
|
64
70
|
) : null;
|
|
65
71
|
|
|
66
72
|
const httpColor = item.deprecated ? 'http-deprecated' : item.httpVerb;
|
|
73
|
+
|
|
67
74
|
const label = item.label && (
|
|
68
75
|
<MenuItemLabelWrapper
|
|
69
76
|
active={item.active}
|
|
@@ -72,8 +79,10 @@ export function MenuItem(props: React.PropsWithChildren<MenuItemProps>): JSX.Ele
|
|
|
72
79
|
withChevron={hasChevron}
|
|
73
80
|
isSeparator={isSeparator}
|
|
74
81
|
onClick={handleOnClick}
|
|
82
|
+
onKeyDown={handleExpandOnEnter}
|
|
75
83
|
ref={labelRef}
|
|
76
84
|
role={item.link ? 'none' : 'link'}
|
|
85
|
+
tabIndex={!item.link ? 0 : undefined}
|
|
77
86
|
data-testid="menu-item-label"
|
|
78
87
|
>
|
|
79
88
|
{hasChevron ? <ChevronWrapper>{chevron}</ChevronWrapper> : null}
|
|
@@ -115,6 +124,7 @@ export function MenuItem(props: React.PropsWithChildren<MenuItemProps>): JSX.Ele
|
|
|
115
124
|
external={item.external}
|
|
116
125
|
target={item.target}
|
|
117
126
|
languageInsensitive={item.languageInsensitive}
|
|
127
|
+
onKeyDown={handleExpandOnEnter}
|
|
118
128
|
>
|
|
119
129
|
{label}
|
|
120
130
|
</MenuItemLink>
|
|
@@ -194,7 +204,6 @@ const MenuItemNestedWrapper = styled.div<{
|
|
|
194
204
|
isExpanded?: boolean;
|
|
195
205
|
depth?: number;
|
|
196
206
|
}>`
|
|
197
|
-
overflow: hidden;
|
|
198
207
|
order: 1;
|
|
199
208
|
position: relative;
|
|
200
209
|
|