@atlaskit/menu 2.4.0 → 2.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/CHANGELOG.md +20 -1
- package/__perf__/button.tsx +7 -9
- package/__perf__/custom.tsx +13 -17
- package/__perf__/link.tsx +6 -6
- package/__perf__/utils/example-runner.tsx +36 -41
- package/__perf__/utils/interaction-tasks.tsx +63 -86
- package/codemods/0.7.0-change-css-fn-prop.tsx +128 -156
- package/codemods/2.1.0-invalid-link-item-to-button-item.tsx +121 -145
- package/codemods/__tests__/0.7.0-change-css-fn-prop.tsx +77 -77
- package/codemods/__tests__/next-invalid-link-item-to-button-item.tsx +117 -117
- package/codemods/helpers/generic.tsx +528 -564
- package/dist/cjs/internal/components/menu-item-primitive.js +13 -2
- package/dist/cjs/internal/components/skeleton-shimmer.js +6 -0
- package/dist/cjs/menu-item/button-item.js +4 -0
- package/dist/cjs/menu-item/custom-item.js +8 -2
- package/dist/cjs/menu-item/heading-item.js +12 -2
- package/dist/cjs/menu-item/link-item.js +4 -0
- package/dist/cjs/menu-item/skeleton-heading-item.js +12 -1
- package/dist/cjs/menu-item/skeleton-item.js +25 -1
- package/dist/cjs/menu-section/menu-group.js +4 -0
- package/dist/cjs/menu-section/popup-menu-group.js +4 -0
- package/dist/cjs/menu-section/section.js +19 -4
- package/dist/es2019/internal/components/menu-item-primitive.js +13 -2
- package/dist/es2019/internal/components/skeleton-shimmer.js +5 -0
- package/dist/es2019/menu-item/button-item.js +5 -0
- package/dist/es2019/menu-item/custom-item.js +9 -2
- package/dist/es2019/menu-item/heading-item.js +13 -2
- package/dist/es2019/menu-item/link-item.js +5 -0
- package/dist/es2019/menu-item/skeleton-heading-item.js +11 -1
- package/dist/es2019/menu-item/skeleton-item.js +24 -1
- package/dist/es2019/menu-section/menu-group.js +4 -0
- package/dist/es2019/menu-section/popup-menu-group.js +4 -0
- package/dist/es2019/menu-section/section.js +20 -4
- package/dist/esm/internal/components/menu-item-primitive.js +13 -2
- package/dist/esm/internal/components/skeleton-shimmer.js +5 -0
- package/dist/esm/menu-item/button-item.js +5 -0
- package/dist/esm/menu-item/custom-item.js +9 -2
- package/dist/esm/menu-item/heading-item.js +13 -2
- package/dist/esm/menu-item/link-item.js +5 -0
- package/dist/esm/menu-item/skeleton-heading-item.js +11 -1
- package/dist/esm/menu-item/skeleton-item.js +24 -1
- package/dist/esm/menu-section/menu-group.js +4 -0
- package/dist/esm/menu-section/popup-menu-group.js +4 -0
- package/dist/esm/menu-section/section.js +20 -4
- package/dist/types/internal/components/skeleton-shimmer.d.ts +4 -1
- package/dist/types/menu-item/custom-item.d.ts +3 -0
- package/dist/types/menu-section/menu-group.d.ts +3 -0
- package/dist/types/menu-section/popup-menu-group.d.ts +3 -0
- package/dist/types-ts4.5/internal/components/skeleton-shimmer.d.ts +4 -1
- package/dist/types-ts4.5/menu-item/custom-item.d.ts +3 -0
- package/dist/types-ts4.5/menu-section/menu-group.d.ts +3 -0
- package/dist/types-ts4.5/menu-section/popup-menu-group.d.ts +3 -0
- package/package.json +133 -133
- package/report.api.md +130 -138
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/menu
|
|
2
2
|
|
|
3
|
+
## 2.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#110670](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110670)
|
|
8
|
+
[`c733254a2dd6e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c733254a2dd6e) -
|
|
9
|
+
Explicitly set jsxRuntime to classic via pragma comments in order to avoid issues where jsxRuntime
|
|
10
|
+
is implicitly set to automatic.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.4.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.4.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -39,7 +58,7 @@
|
|
|
39
58
|
|
|
40
59
|
- [#93679](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93679)
|
|
41
60
|
[`b35e71a29db0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b35e71a29db0) -
|
|
42
|
-
Add support for React 18.
|
|
61
|
+
Add support for React 18 in non-strict mode.
|
|
43
62
|
|
|
44
63
|
## 2.1.13
|
|
45
64
|
|
package/__perf__/button.tsx
CHANGED
|
@@ -5,17 +5,15 @@ import ButtonItem from '../src/menu-item/button-item';
|
|
|
5
5
|
import Example from './utils/example-runner';
|
|
6
6
|
import { interactionTasks } from './utils/interaction-tasks';
|
|
7
7
|
|
|
8
|
-
const buttonItem = () =>
|
|
9
|
-
<Example Component={ButtonItem} displayName="Button item" />
|
|
10
|
-
);
|
|
8
|
+
const buttonItem = () => <Example Component={ButtonItem} displayName="Button item" />;
|
|
11
9
|
|
|
12
10
|
buttonItem.story = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
name: 'Button Item',
|
|
12
|
+
parameters: {
|
|
13
|
+
performance: {
|
|
14
|
+
interactions: interactionTasks,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
export default buttonItem;
|
package/__perf__/custom.tsx
CHANGED
|
@@ -6,29 +6,25 @@ import type { CustomItemComponentProps, CustomItemProps } from '../src/types';
|
|
|
6
6
|
import Example from './utils/example-runner';
|
|
7
7
|
import { interactionTasks } from './utils/interaction-tasks';
|
|
8
8
|
|
|
9
|
-
const Emphasis = React.forwardRef(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
),
|
|
13
|
-
);
|
|
9
|
+
const Emphasis = React.forwardRef((props: CustomItemComponentProps, ref: Ref<HTMLElement>) => (
|
|
10
|
+
<em {...props} ref={ref} />
|
|
11
|
+
));
|
|
14
12
|
|
|
15
13
|
const CustomItemEmphasis = React.forwardRef(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
(props: CustomItemProps, ref: Ref<HTMLElement | null>) => {
|
|
15
|
+
return <CustomItem component={Emphasis} {...props} ref={ref} />;
|
|
16
|
+
},
|
|
19
17
|
);
|
|
20
18
|
|
|
21
|
-
const customItem = () =>
|
|
22
|
-
<Example Component={CustomItemEmphasis} displayName="Custom item" />
|
|
23
|
-
);
|
|
19
|
+
const customItem = () => <Example Component={CustomItemEmphasis} displayName="Custom item" />;
|
|
24
20
|
|
|
25
21
|
customItem.story = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
name: 'Custom Item',
|
|
23
|
+
parameters: {
|
|
24
|
+
performance: {
|
|
25
|
+
interactions: interactionTasks,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
32
28
|
};
|
|
33
29
|
|
|
34
30
|
export default customItem;
|
package/__perf__/link.tsx
CHANGED
|
@@ -8,12 +8,12 @@ import { interactionTasks } from './utils/interaction-tasks';
|
|
|
8
8
|
const linkItem = () => <Example Component={LinkItem} displayName="Link item" />;
|
|
9
9
|
|
|
10
10
|
linkItem.story = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
name: 'Link Item',
|
|
12
|
+
parameters: {
|
|
13
|
+
performance: {
|
|
14
|
+
interactions: interactionTasks,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export default linkItem;
|
|
@@ -3,53 +3,48 @@ import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { bindAll } from 'bind-event-listener';
|
|
4
4
|
|
|
5
5
|
type ItemComponentProps =
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
| React.ComponentType<React.AllHTMLAttributes<HTMLElement>>
|
|
7
|
+
| React.ElementType;
|
|
8
8
|
|
|
9
9
|
export default function Example({
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Component,
|
|
11
|
+
displayName,
|
|
12
12
|
}: {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Component: ItemComponentProps;
|
|
14
|
+
displayName: string;
|
|
15
15
|
}) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const [isSelected, setIsSelected] = useState<boolean>(false);
|
|
17
|
+
const [isDisabled, setIsDisabled] = useState<boolean>(false);
|
|
18
|
+
const ref = useRef<HTMLElement>(null);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
function toggleSelect() {
|
|
22
|
+
setIsSelected((value) => !value);
|
|
23
|
+
}
|
|
24
|
+
function toggleDisabled() {
|
|
25
|
+
setIsDisabled((value) => !value);
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
const el: HTMLElement | null = ref.current;
|
|
29
|
+
if (!el) {
|
|
30
|
+
throw new Error('Could not find button ref');
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
return bindAll(el, [
|
|
34
|
+
{
|
|
35
|
+
type: 'toggle-select',
|
|
36
|
+
listener: toggleSelect,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'toggle-disabled',
|
|
40
|
+
listener: toggleDisabled,
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
}, []);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isDisabled={isDisabled}
|
|
51
|
-
>
|
|
52
|
-
{displayName}
|
|
53
|
-
</Component>
|
|
54
|
-
);
|
|
45
|
+
return (
|
|
46
|
+
<Component ref={ref} testId="menu-item" isSelected={isSelected} isDisabled={isDisabled}>
|
|
47
|
+
{displayName}
|
|
48
|
+
</Component>
|
|
49
|
+
);
|
|
55
50
|
}
|
|
@@ -1,99 +1,76 @@
|
|
|
1
1
|
import { fireEvent } from '@testing-library/dom';
|
|
2
|
-
import {
|
|
3
|
-
type InteractionTaskArgs,
|
|
4
|
-
type PublicInteractionTask,
|
|
5
|
-
} from 'storybook-addon-performance';
|
|
2
|
+
import { type InteractionTaskArgs, type PublicInteractionTask } from 'storybook-addon-performance';
|
|
6
3
|
|
|
7
4
|
export const interactionTasks: PublicInteractionTask[] = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (menuItem == null) {
|
|
17
|
-
throw new Error('Could not find a menu item element');
|
|
18
|
-
}
|
|
5
|
+
{
|
|
6
|
+
name: 'Click a menu item',
|
|
7
|
+
description: 'Recording how long a mousedown + click event take to be processed',
|
|
8
|
+
run: async ({ container }: InteractionTaskArgs): Promise<void> => {
|
|
9
|
+
const menuItem: HTMLElement | null = container.querySelector('[data-testid="menu-item"]');
|
|
10
|
+
if (menuItem == null) {
|
|
11
|
+
throw new Error('Could not find a menu item element');
|
|
12
|
+
}
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'[data-testid="menu-item"]',
|
|
33
|
-
);
|
|
34
|
-
if (menuItem == null) {
|
|
35
|
-
throw new Error('Could not find a menu item element');
|
|
36
|
-
}
|
|
14
|
+
fireEvent.mouseDown(menuItem);
|
|
15
|
+
fireEvent.click(menuItem);
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'Focus on a menu item',
|
|
20
|
+
description: 'Focus on a menu item and wait for layout and paint to finish',
|
|
21
|
+
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
22
|
+
const menuItem: HTMLElement | null = container.querySelector('[data-testid="menu-item"]');
|
|
23
|
+
if (menuItem == null) {
|
|
24
|
+
throw new Error('Could not find a menu item element');
|
|
25
|
+
}
|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
controls,
|
|
50
|
-
}: InteractionTaskArgs): Promise<void> => {
|
|
51
|
-
const menuItem: HTMLElement | null = container.querySelector(
|
|
52
|
-
'[data-testid="menu-item"]',
|
|
53
|
-
);
|
|
27
|
+
await controls.time(async () => {
|
|
28
|
+
fireEvent.focus(menuItem);
|
|
29
|
+
fireEvent.blur(menuItem);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Select a menu item',
|
|
35
|
+
description: 'Trigger the selection of a menu item',
|
|
36
|
+
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
37
|
+
const menuItem: HTMLElement | null = container.querySelector('[data-testid="menu-item"]');
|
|
54
38
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
if (menuItem == null) {
|
|
40
|
+
throw new Error('Could not find a menu item element');
|
|
41
|
+
}
|
|
58
42
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'[data-testid="menu-item"]',
|
|
73
|
-
);
|
|
74
|
-
if (menuItem == null) {
|
|
75
|
-
throw new Error('Could not find a menu item element');
|
|
76
|
-
}
|
|
43
|
+
await controls.time(async () => {
|
|
44
|
+
fireEvent(menuItem, new Event('toggle-select'));
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'Disable a menu item',
|
|
50
|
+
description: 'Trigger the disabling of a menu item',
|
|
51
|
+
run: async ({ container, controls }: InteractionTaskArgs): Promise<void> => {
|
|
52
|
+
const menuItem: HTMLElement | null = container.querySelector('[data-testid="menu-item"]');
|
|
53
|
+
if (menuItem == null) {
|
|
54
|
+
throw new Error('Could not find a menu item element');
|
|
55
|
+
}
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
menuItem.getAttribute('disabled');
|
|
57
|
+
const beforeState =
|
|
58
|
+
menuItem.getAttribute('aria-disabled') || menuItem.getAttribute('disabled');
|
|
81
59
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
if (beforeState === 'true') {
|
|
61
|
+
throw new Error('Should not be disabled before the test begins');
|
|
62
|
+
}
|
|
85
63
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
await controls.time(async () => {
|
|
65
|
+
fireEvent(menuItem!, new Event('toggle-disabled'));
|
|
66
|
+
});
|
|
89
67
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
menuItem.getAttribute('disabled');
|
|
68
|
+
const afterState =
|
|
69
|
+
menuItem.getAttribute('aria-disabled') || menuItem.getAttribute('disabled');
|
|
93
70
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
if (afterState === 'false') {
|
|
72
|
+
throw new Error('Should be disabled after the test finished');
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
},
|
|
99
76
|
];
|