uikit-react-public 0.24.5 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/MenuNew/ActionMenuItem.d.ts +7 -0
- package/dist/components/MenuNew/Menu.d.ts +16 -15
- package/dist/components/MenuNew/MenuBaseItem.d.ts +7 -0
- package/dist/components/MenuNew/MenuDivider.d.ts +6 -0
- package/dist/components/MenuNew/MenuItemText.d.ts +9 -0
- package/dist/components/MenuNew/PrimaryMenuItem.d.ts +9 -0
- package/dist/components/MenuNew/SecondaryMenuItem.d.ts +8 -0
- package/dist/components/MenuNew/index.d.ts +1 -5
- package/dist/components/Text/Text.d.ts +10 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/index.d.ts +2 -4
- package/dist/index.js +5575 -5597
- package/lib/components/MenuNew/ActionMenuItem.tsx +31 -0
- package/lib/components/MenuNew/Menu.tsx +41 -44
- package/lib/components/MenuNew/MenuBaseItem.tsx +72 -0
- package/lib/components/MenuNew/MenuDivider.tsx +25 -0
- package/lib/components/MenuNew/MenuItemText.tsx +58 -0
- package/lib/components/MenuNew/PrimaryMenuItem.tsx +60 -0
- package/lib/components/MenuNew/SecondaryMenuItem.tsx +67 -0
- package/lib/components/MenuNew/__tests__/Menu.test.tsx +138 -0
- package/lib/components/MenuNew/index.ts +8 -7
- package/lib/components/Text/Text.tsx +171 -0
- package/lib/components/Text/index.ts +2 -0
- package/lib/components/index.ts +2 -7
- package/package.json +1 -1
- package/dist/components/MenuNew/Menu.context.d.ts +0 -14
- package/dist/components/MenuNew/MenuContent.d.ts +0 -9
- package/dist/components/MenuNew/MenuItem.d.ts +0 -10
- package/dist/components/MenuNew/MenuSection.d.ts +0 -7
- package/dist/components/MenuNew/trigger/ButtonMenuTrigger.d.ts +0 -8
- package/dist/components/MenuNew/trigger/IconMenuTrigger.d.ts +0 -8
- package/dist/components/SimpleMenu/SimpleMenu.d.ts +0 -7
- package/dist/components/SimpleMenu/index.d.ts +0 -2
- package/lib/components/MenuNew/Menu.context.tsx +0 -149
- package/lib/components/MenuNew/MenuContent.tsx +0 -140
- package/lib/components/MenuNew/MenuItem.tsx +0 -101
- package/lib/components/MenuNew/MenuSection.tsx +0 -47
- package/lib/components/MenuNew/trigger/ButtonMenuTrigger.tsx +0 -42
- package/lib/components/MenuNew/trigger/IconMenuTrigger.tsx +0 -40
- package/lib/components/SimpleMenu/SimpleMenu.tsx +0 -40
- package/lib/components/SimpleMenu/__tests__/SimpleMenu.test.tsx +0 -38
- package/lib/components/SimpleMenu/index.ts +0 -2
- /package/dist/components/{SimpleMenu/__tests__/SimpleMenu.test.d.ts → MenuNew/__tests__/Menu.test.d.ts} +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
import { css, cx } from '@emotion/css';
|
|
3
|
-
import { useTheme } from '../../theme';
|
|
4
|
-
|
|
5
|
-
export const NAME = 'ucl-uikit-menu__section';
|
|
6
|
-
|
|
7
|
-
export interface MenuSectionProps extends HTMLAttributes<HTMLLIElement> {
|
|
8
|
-
testId?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const MenuSection: React.FC<MenuSectionProps> = ({
|
|
12
|
-
className,
|
|
13
|
-
children,
|
|
14
|
-
...props
|
|
15
|
-
}) => {
|
|
16
|
-
const [theme] = useTheme();
|
|
17
|
-
|
|
18
|
-
const baseStyle = css`
|
|
19
|
-
padding: 0;
|
|
20
|
-
margin-top: 0;
|
|
21
|
-
margin-bottom: ${theme.margin.m32};
|
|
22
|
-
|
|
23
|
-
&:not(:last-of-type) {
|
|
24
|
-
border-bottom: 1px solid ${theme.color.neutral.grey10};
|
|
25
|
-
}
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
const style = cx(NAME, baseStyle, className);
|
|
29
|
-
|
|
30
|
-
const listStyle = css`
|
|
31
|
-
list-style: none;
|
|
32
|
-
margin: 0;
|
|
33
|
-
padding: 0;
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<li
|
|
38
|
-
role='presentation'
|
|
39
|
-
className={style}
|
|
40
|
-
{...props}
|
|
41
|
-
>
|
|
42
|
-
<ul className={listStyle}>{children}</ul>
|
|
43
|
-
</li>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default MenuSection;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import { cx } from '@emotion/css';
|
|
3
|
-
import { IconButtonProps } from '../../IconButton';
|
|
4
|
-
import { useAppMenu } from '../Menu.context';
|
|
5
|
-
import { Button, Icon } from '../..';
|
|
6
|
-
|
|
7
|
-
export const NAME = 'ucl-uikit-menu__trigger--button';
|
|
8
|
-
export const DEFAULT_ARIA_LABEL = 'Menu button';
|
|
9
|
-
|
|
10
|
-
export interface ButtonMenuTriggerProps extends IconButtonProps {
|
|
11
|
-
ariaLabel?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const ButtonMenuTrigger = ({
|
|
15
|
-
id = 'menu-trigger',
|
|
16
|
-
ariaLabel = DEFAULT_ARIA_LABEL,
|
|
17
|
-
className,
|
|
18
|
-
...props
|
|
19
|
-
}: ButtonMenuTriggerProps) => {
|
|
20
|
-
const { toggleMenu, isOpen, triggerRef } = useAppMenu();
|
|
21
|
-
|
|
22
|
-
const style = cx(NAME, className);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Button
|
|
26
|
-
id={id}
|
|
27
|
-
ref={triggerRef}
|
|
28
|
-
className={style}
|
|
29
|
-
size='small'
|
|
30
|
-
icon={<Icon.Menu />}
|
|
31
|
-
onClick={toggleMenu}
|
|
32
|
-
aria-label={ariaLabel}
|
|
33
|
-
aria-haspopup='true'
|
|
34
|
-
aria-expanded={isOpen ? 'true' : 'false'}
|
|
35
|
-
{...props}
|
|
36
|
-
>
|
|
37
|
-
Menu
|
|
38
|
-
</Button>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default memo(ButtonMenuTrigger);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import { cx } from '@emotion/css';
|
|
3
|
-
import IconButton, { IconButtonProps } from '../../IconButton';
|
|
4
|
-
import { useAppMenu } from '../Menu.context';
|
|
5
|
-
import { Icon } from '../..';
|
|
6
|
-
|
|
7
|
-
export const NAME = 'ucl-uikit-menu__trigger--icon';
|
|
8
|
-
export const DEFAULT_ARIA_LABEL = 'Menu button';
|
|
9
|
-
|
|
10
|
-
export interface IconMenuTriggerProps extends IconButtonProps {
|
|
11
|
-
ariaLabel?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const IconMenuTrigger = ({
|
|
15
|
-
id = 'menu-trigger',
|
|
16
|
-
ariaLabel = DEFAULT_ARIA_LABEL,
|
|
17
|
-
className,
|
|
18
|
-
...props
|
|
19
|
-
}: IconMenuTriggerProps) => {
|
|
20
|
-
const { toggleMenu, isOpen, triggerRef } = useAppMenu();
|
|
21
|
-
|
|
22
|
-
const style = cx(NAME, className);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<IconButton
|
|
26
|
-
id={id}
|
|
27
|
-
ref={triggerRef}
|
|
28
|
-
className={style}
|
|
29
|
-
onClick={toggleMenu}
|
|
30
|
-
aria-label={ariaLabel}
|
|
31
|
-
aria-haspopup='true'
|
|
32
|
-
aria-expanded={isOpen ? 'true' : 'false'}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
<Icon.Menu/>
|
|
36
|
-
</IconButton>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default memo(IconMenuTrigger);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes, memo } from 'react';
|
|
2
|
-
import { css, cx } from '@emotion/css';
|
|
3
|
-
import useTheme from '../../theme/useTheme';
|
|
4
|
-
|
|
5
|
-
export const NAME = 'ucl-uikit-simple-menu';
|
|
6
|
-
|
|
7
|
-
export interface SimpleMenuProps extends HTMLAttributes<HTMLUListElement> {
|
|
8
|
-
testId?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const SimpleMenu = ({
|
|
12
|
-
testId = NAME,
|
|
13
|
-
className,
|
|
14
|
-
children,
|
|
15
|
-
...props
|
|
16
|
-
}: SimpleMenuProps) => {
|
|
17
|
-
const [theme] = useTheme();
|
|
18
|
-
|
|
19
|
-
const baseStyle = css`
|
|
20
|
-
list-style: none;
|
|
21
|
-
margin: 0;
|
|
22
|
-
padding: ${theme.padding.p8};
|
|
23
|
-
border-radius: ${theme.radius.r4};
|
|
24
|
-
`;
|
|
25
|
-
|
|
26
|
-
const style = cx(NAME, baseStyle, className);
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<ul
|
|
30
|
-
role='menu'
|
|
31
|
-
data-testid={testId}
|
|
32
|
-
className={style}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</ul>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default memo(SimpleMenu);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import SimpleMenu from '../SimpleMenu';
|
|
4
|
-
import { ThemeContextProvider } from '../../../theme/useTheme';
|
|
5
|
-
|
|
6
|
-
describe('SimpleMenu', () => {
|
|
7
|
-
test('renders with default test id', () => {
|
|
8
|
-
render(
|
|
9
|
-
<ThemeContextProvider>
|
|
10
|
-
<SimpleMenu>
|
|
11
|
-
<li role='menuitem'>Item one</li>
|
|
12
|
-
</SimpleMenu>
|
|
13
|
-
</ThemeContextProvider>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
expect(screen.getByTestId('ucl-uikit-simple-menu')).toBeInTheDocument();
|
|
17
|
-
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
18
|
-
expect(
|
|
19
|
-
screen.getByRole('menuitem', { name: 'Item one' })
|
|
20
|
-
).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('supports custom test id and className', () => {
|
|
24
|
-
render(
|
|
25
|
-
<ThemeContextProvider>
|
|
26
|
-
<SimpleMenu
|
|
27
|
-
testId='custom-simple-menu'
|
|
28
|
-
className='menu-override'
|
|
29
|
-
>
|
|
30
|
-
<li role='menuitem'>Item two</li>
|
|
31
|
-
</SimpleMenu>
|
|
32
|
-
</ThemeContextProvider>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const menu = screen.getByTestId('custom-simple-menu');
|
|
36
|
-
expect(menu).toHaveClass('menu-override');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
File without changes
|