@atlaskit/menu 1.1.3 → 1.2.2
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 +53 -0
- package/dist/cjs/internal/components/menu-item-primitive.js +200 -0
- package/dist/cjs/menu-item/button-item.js +31 -25
- package/dist/cjs/menu-item/custom-item.js +31 -32
- package/dist/cjs/menu-item/heading-item.js +25 -7
- package/dist/cjs/menu-item/link-item.js +50 -45
- package/dist/cjs/menu-item/skeleton-heading-item.js +42 -14
- package/dist/cjs/menu-item/skeleton-item.js +93 -13
- package/dist/cjs/menu-section/menu-group.js +11 -8
- package/dist/cjs/menu-section/section.js +83 -29
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/internal/components/menu-item-primitive.js +180 -0
- package/dist/es2019/menu-item/button-item.js +28 -21
- package/dist/es2019/menu-item/custom-item.js +32 -24
- package/dist/es2019/menu-item/heading-item.js +22 -6
- package/dist/es2019/menu-item/link-item.js +31 -26
- package/dist/es2019/menu-item/skeleton-heading-item.js +37 -11
- package/dist/es2019/menu-item/skeleton-item.js +89 -11
- package/dist/es2019/menu-section/menu-group.js +12 -8
- package/dist/es2019/menu-section/section.js +83 -31
- package/dist/es2019/version.json +1 -1
- package/dist/esm/internal/components/menu-item-primitive.js +184 -0
- package/dist/esm/menu-item/button-item.js +30 -24
- package/dist/esm/menu-item/custom-item.js +32 -26
- package/dist/esm/menu-item/heading-item.js +22 -8
- package/dist/esm/menu-item/link-item.js +49 -45
- package/dist/esm/menu-item/skeleton-heading-item.js +38 -14
- package/dist/esm/menu-item/skeleton-item.js +89 -13
- package/dist/esm/menu-section/menu-group.js +12 -8
- package/dist/esm/menu-section/section.js +82 -32
- package/dist/esm/version.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/components/menu-item-primitive.d.ts +17 -0
- package/dist/types/menu-item/button-item.d.ts +1 -1
- package/dist/types/menu-item/custom-item.d.ts +2 -1
- package/dist/types/menu-item/skeleton-heading-item.d.ts +1 -2
- package/dist/types/menu-item/skeleton-item.d.ts +1 -2
- package/dist/types/types.d.ts +27 -7
- package/package.json +4 -2
- package/dist/cjs/internal/components/base-item.js +0 -65
- package/dist/cjs/internal/styles/menu-item/base-item.js +0 -152
- package/dist/cjs/internal/styles/menu-item/button-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/custom-item.js +0 -24
- package/dist/cjs/internal/styles/menu-item/heading-item.js +0 -28
- package/dist/cjs/internal/styles/menu-item/link-item.js +0 -22
- package/dist/cjs/internal/styles/menu-item/skeleton-heading-item.js +0 -50
- package/dist/cjs/internal/styles/menu-item/skeleton-item.js +0 -98
- package/dist/cjs/internal/styles/menu-section/menu-group.js +0 -24
- package/dist/cjs/internal/styles/menu-section/section.js +0 -83
- package/dist/es2019/internal/components/base-item.js +0 -51
- package/dist/es2019/internal/styles/menu-item/base-item.js +0 -122
- package/dist/es2019/internal/styles/menu-item/button-item.js +0 -9
- package/dist/es2019/internal/styles/menu-item/custom-item.js +0 -5
- package/dist/es2019/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/es2019/internal/styles/menu-item/link-item.js +0 -3
- package/dist/es2019/internal/styles/menu-item/skeleton-heading-item.js +0 -25
- package/dist/es2019/internal/styles/menu-item/skeleton-item.js +0 -75
- package/dist/es2019/internal/styles/menu-section/menu-group.js +0 -14
- package/dist/es2019/internal/styles/menu-section/section.js +0 -62
- package/dist/esm/internal/components/base-item.js +0 -55
- package/dist/esm/internal/styles/menu-item/base-item.js +0 -124
- package/dist/esm/internal/styles/menu-item/button-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/custom-item.js +0 -12
- package/dist/esm/internal/styles/menu-item/heading-item.js +0 -16
- package/dist/esm/internal/styles/menu-item/link-item.js +0 -10
- package/dist/esm/internal/styles/menu-item/skeleton-heading-item.js +0 -33
- package/dist/esm/internal/styles/menu-item/skeleton-item.js +0 -81
- package/dist/esm/internal/styles/menu-section/menu-group.js +0 -15
- package/dist/esm/internal/styles/menu-section/section.js +0 -67
- package/dist/types/internal/components/base-item.d.ts +0 -9
- package/dist/types/internal/styles/menu-item/base-item.d.ts +0 -23
- package/dist/types/internal/styles/menu-item/button-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/custom-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/link-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-heading-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-item/skeleton-item.d.ts +0 -2
- package/dist/types/internal/styles/menu-section/menu-group.d.ts +0 -3
- package/dist/types/internal/styles/menu-section/section.d.ts +0 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { forwardRef, memo } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
7
|
+
import MenuItemPrimitive from '../internal/components/menu-item-primitive';
|
|
5
8
|
import { useBlurOnMouseDown } from '../internal/hooks/use-blur-on-mouse-down';
|
|
6
|
-
import { customItemCSS } from '../internal/styles/menu-item/custom-item';
|
|
7
9
|
|
|
8
10
|
const preventEvent = e => {
|
|
9
11
|
e.preventDefault();
|
|
@@ -13,14 +15,14 @@ const preventEvent = e => {
|
|
|
13
15
|
/**
|
|
14
16
|
* __Custom item__
|
|
15
17
|
*
|
|
16
|
-
* A custom item is used to populate a menu with items that
|
|
18
|
+
* A custom item is used to populate a menu with items that can be any element.
|
|
17
19
|
*
|
|
18
20
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/custom-item)
|
|
19
21
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
20
22
|
*/
|
|
21
23
|
const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
22
24
|
component: Component,
|
|
23
|
-
cssFn =
|
|
25
|
+
cssFn = noop,
|
|
24
26
|
isDisabled = false,
|
|
25
27
|
isSelected = false,
|
|
26
28
|
onClick,
|
|
@@ -41,31 +43,37 @@ const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
return jsx(MenuItemPrimitive, _extends({}, rest, {
|
|
47
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
48
|
+
overrides: overrides,
|
|
49
|
+
description: description,
|
|
50
|
+
iconAfter: iconAfter,
|
|
51
|
+
title: children,
|
|
52
|
+
iconBefore: iconBefore,
|
|
53
|
+
isSelected: isSelected,
|
|
54
|
+
isDisabled: isDisabled,
|
|
55
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
56
|
+
shouldDescriptionWrap: shouldDescriptionWrap // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
57
|
+
,
|
|
58
|
+
css: css(cssFn({
|
|
51
59
|
isDisabled,
|
|
52
60
|
isSelected
|
|
53
|
-
})
|
|
61
|
+
}))
|
|
62
|
+
}), ({
|
|
63
|
+
children,
|
|
64
|
+
className
|
|
65
|
+
}) => jsx(Component, _extends({
|
|
66
|
+
"data-testid": testId
|
|
67
|
+
}, rest, {
|
|
68
|
+
className: className,
|
|
69
|
+
ref: ref,
|
|
70
|
+
draggable: false,
|
|
54
71
|
onDragStart: preventEvent,
|
|
55
72
|
onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
|
|
56
73
|
onClick: isDisabled ? preventEvent : onClick,
|
|
57
74
|
tabIndex: isDisabled ? -1 : undefined,
|
|
58
75
|
"aria-disabled": isDisabled
|
|
59
|
-
},
|
|
60
|
-
, {
|
|
61
|
-
overrides: overrides,
|
|
62
|
-
children: children,
|
|
63
|
-
description: description,
|
|
64
|
-
iconAfter: iconAfter,
|
|
65
|
-
iconBefore: iconBefore,
|
|
66
|
-
shouldTitleWrap: shouldTitleWrap,
|
|
67
|
-
shouldDescriptionWrap: shouldDescriptionWrap
|
|
68
|
-
})));
|
|
76
|
+
}), children));
|
|
69
77
|
}) // Dirty hack to get generics working with forward ref [2/2]
|
|
70
78
|
);
|
|
71
79
|
export default CustomItem;
|
|
@@ -2,9 +2,24 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { memo } from 'react';
|
|
5
|
-
import { jsx } from '@emotion/core';
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
7
|
+
import { N200 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
9
|
+
import { headingSizes } from '@atlaskit/theme/typography';
|
|
10
|
+
import { token } from '@atlaskit/tokens';
|
|
11
|
+
const gridSize = gridSizeFn();
|
|
12
|
+
const itemSidePadding = gridSize * 2.5;
|
|
13
|
+
const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
14
|
+
const itemHeadingFontSize = headingSizes.h100.size;
|
|
15
|
+
const headingStyles = css({
|
|
16
|
+
padding: `0 ${itemSidePadding}px`,
|
|
17
|
+
color: token('color.text.lowEmphasis', N200),
|
|
18
|
+
fontSize: itemHeadingFontSize,
|
|
19
|
+
fontWeight: 700,
|
|
20
|
+
lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
|
|
21
|
+
textTransform: 'uppercase'
|
|
22
|
+
});
|
|
8
23
|
/**
|
|
9
24
|
* __Heading item__
|
|
10
25
|
*
|
|
@@ -13,16 +28,17 @@ import { headingItemCSS } from '../internal/styles/menu-item/heading-item';
|
|
|
13
28
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/heading-item)
|
|
14
29
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
15
30
|
*/
|
|
31
|
+
|
|
16
32
|
const HeadingItem = /*#__PURE__*/memo(({
|
|
17
33
|
children,
|
|
18
34
|
testId,
|
|
19
35
|
id,
|
|
20
|
-
cssFn =
|
|
36
|
+
cssFn = noop,
|
|
21
37
|
...rest
|
|
22
38
|
}) => {
|
|
23
39
|
return jsx("div", _extends({
|
|
24
|
-
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
25
|
-
|
|
40
|
+
css: [headingStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
41
|
+
cssFn(undefined)],
|
|
26
42
|
"data-testid": testId,
|
|
27
43
|
"data-ds--menu--heading-item": true,
|
|
28
44
|
id: id
|
|
@@ -3,9 +3,9 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { forwardRef, memo } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
|
-
import
|
|
6
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
7
|
+
import MenuItemPrimitive from '../internal/components/menu-item-primitive';
|
|
7
8
|
import { useBlurOnMouseDown } from '../internal/hooks/use-blur-on-mouse-down';
|
|
8
|
-
import { linkItemCSS } from '../internal/styles/menu-item/link-item';
|
|
9
9
|
|
|
10
10
|
const preventEvent = e => {
|
|
11
11
|
e.preventDefault();
|
|
@@ -21,13 +21,11 @@ const preventEvent = e => {
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on props to extract types with extract react types.
|
|
24
|
-
({
|
|
25
|
-
href,
|
|
26
|
-
...rest
|
|
27
|
-
}, ref) => {
|
|
24
|
+
(props, ref) => {
|
|
28
25
|
const {
|
|
29
26
|
children,
|
|
30
|
-
|
|
27
|
+
href,
|
|
28
|
+
cssFn = noop,
|
|
31
29
|
description,
|
|
32
30
|
iconAfter,
|
|
33
31
|
iconBefore,
|
|
@@ -39,38 +37,45 @@ const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on p
|
|
|
39
37
|
onMouseDown,
|
|
40
38
|
shouldTitleWrap,
|
|
41
39
|
shouldDescriptionWrap,
|
|
42
|
-
...
|
|
43
|
-
} =
|
|
40
|
+
...rest
|
|
41
|
+
} = props;
|
|
44
42
|
const onMouseDownHandler = useBlurOnMouseDown(onMouseDown);
|
|
45
43
|
|
|
46
44
|
if (!children) {
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
return jsx(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
return jsx(MenuItemPrimitive, _extends({}, rest, {
|
|
49
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
50
|
+
overrides: overrides,
|
|
51
|
+
iconBefore: iconBefore,
|
|
52
|
+
iconAfter: iconAfter,
|
|
53
|
+
isSelected: isSelected,
|
|
54
|
+
isDisabled: isDisabled,
|
|
55
|
+
description: description,
|
|
56
|
+
shouldTitleWrap: shouldTitleWrap,
|
|
57
|
+
shouldDescriptionWrap: shouldDescriptionWrap,
|
|
58
|
+
css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
54
59
|
cssFn({
|
|
55
60
|
isSelected,
|
|
56
61
|
isDisabled
|
|
57
|
-
})
|
|
58
|
-
|
|
62
|
+
}),
|
|
63
|
+
title: children
|
|
64
|
+
}), ({
|
|
65
|
+
children,
|
|
66
|
+
className
|
|
67
|
+
}) => jsx("a", _extends({
|
|
68
|
+
"data-testid": testId
|
|
69
|
+
}, rest, {
|
|
70
|
+
className: className,
|
|
59
71
|
href: isDisabled ? undefined : href,
|
|
60
|
-
|
|
72
|
+
draggable: false,
|
|
61
73
|
onDragStart: preventEvent,
|
|
62
74
|
onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
|
|
63
75
|
onClick: isDisabled ? preventEvent : onClick,
|
|
64
76
|
"aria-current": isSelected ? 'page' : undefined,
|
|
65
|
-
"aria-disabled": isDisabled
|
|
66
|
-
|
|
67
|
-
,
|
|
68
|
-
overrides: overrides,
|
|
69
|
-
iconBefore: iconBefore,
|
|
70
|
-
iconAfter: iconAfter,
|
|
71
|
-
description: description,
|
|
72
|
-
shouldTitleWrap: shouldTitleWrap,
|
|
73
|
-
shouldDescriptionWrap: shouldDescriptionWrap
|
|
74
|
-
}, children));
|
|
77
|
+
"aria-disabled": isDisabled,
|
|
78
|
+
ref: ref
|
|
79
|
+
}), children));
|
|
75
80
|
}));
|
|
76
81
|
export default LinkItem;
|
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
4
|
+
import { skeleton as skeletonColorFn } from '@atlaskit/theme/colors';
|
|
5
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
const skeletonStyles = css({
|
|
8
|
+
padding: `0 ${gridSize() * 2.5}px`,
|
|
9
|
+
'::after': {
|
|
10
|
+
display: 'block',
|
|
11
|
+
width: '30%',
|
|
12
|
+
height: gridSize(),
|
|
13
|
+
backgroundColor: token('color.background.subtleNeutral.resting', skeletonColorFn()),
|
|
14
|
+
borderRadius: 100,
|
|
15
|
+
content: '""'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const defaultWidthStyles = css({
|
|
19
|
+
'::after': {
|
|
20
|
+
width: '30%'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const customWidthStyles = css({
|
|
24
|
+
'::after': {
|
|
25
|
+
width: 'var(--width)'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
6
28
|
/**
|
|
7
29
|
* __Skeleton heading item__
|
|
8
30
|
*
|
|
@@ -11,15 +33,19 @@ import { skeletonHeadingItemCSS } from '../internal/styles/menu-item/skeleton-he
|
|
|
11
33
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-heading-item)
|
|
12
34
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
13
35
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
|
|
37
|
+
const SkeletonHeadingItem = ({
|
|
16
38
|
testId,
|
|
17
|
-
|
|
18
|
-
cssFn =
|
|
39
|
+
width,
|
|
40
|
+
cssFn = noop
|
|
19
41
|
}) => jsx("div", {
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
style: {
|
|
43
|
+
'--width': width
|
|
44
|
+
},
|
|
45
|
+
css: [skeletonStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
46
|
+
cssFn(undefined)],
|
|
22
47
|
"data-ds--menu--skeleton-heading-item": true,
|
|
23
48
|
"data-testid": testId
|
|
24
|
-
})
|
|
49
|
+
});
|
|
50
|
+
|
|
25
51
|
export default SkeletonHeadingItem;
|
|
@@ -1,8 +1,83 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
4
|
+
import { skeleton as skeletonColorFn } from '@atlaskit/theme/colors';
|
|
5
|
+
import { borderRadius as borderRadiusFn, gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
6
|
+
import { token } from '@atlaskit/tokens';
|
|
7
|
+
const gridSize = gridSizeFn();
|
|
8
|
+
const borderRadius = borderRadiusFn();
|
|
9
|
+
const itemElemSpacing = gridSize * 1.5;
|
|
10
|
+
const itemExpectedElemSize = gridSize * 3;
|
|
11
|
+
const itemMinHeight = gridSize * 5;
|
|
12
|
+
const itemPadding = gridSize * 2.5;
|
|
13
|
+
const skeletonItemElemSize = gridSize * 2.5;
|
|
14
|
+
const itemElemSkeletonOffset = (itemExpectedElemSize - skeletonItemElemSize) / 2;
|
|
15
|
+
const skeletonTextBorderRadius = 100;
|
|
16
|
+
const skeletonContentHeight = 9;
|
|
17
|
+
const skeletonColor = token('color.background.subtleNeutral.resting', skeletonColorFn());
|
|
18
|
+
const skeletonStyles = css({
|
|
19
|
+
display: 'flex',
|
|
20
|
+
minHeight: itemMinHeight,
|
|
21
|
+
padding: `0 ${itemPadding}px`,
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
pointerEvents: 'none',
|
|
24
|
+
'::after': {
|
|
25
|
+
height: skeletonContentHeight,
|
|
26
|
+
// This is a little bespoke but we need to push everything down 1px
|
|
27
|
+
// because the skeleton content should align to the bottom of the text.
|
|
28
|
+
// Confirm VR test failures before accepting a change.
|
|
29
|
+
marginTop: 1,
|
|
30
|
+
backgroundColor: skeletonColor,
|
|
31
|
+
borderRadius: skeletonTextBorderRadius,
|
|
32
|
+
content: '""'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const defaultWidthStyles = css({
|
|
36
|
+
':nth-of-type(1n)::after': {
|
|
37
|
+
flexBasis: '70%'
|
|
38
|
+
},
|
|
39
|
+
':nth-of-type(2n)::after': {
|
|
40
|
+
flexBasis: '50%'
|
|
41
|
+
},
|
|
42
|
+
':nth-of-type(3n)::after': {
|
|
43
|
+
flexBasis: '60%'
|
|
44
|
+
},
|
|
45
|
+
':nth-of-type(4n)::after': {
|
|
46
|
+
flexBasis: '90%'
|
|
47
|
+
},
|
|
48
|
+
':nth-of-type(5n)::after': {
|
|
49
|
+
flexBasis: '35%'
|
|
50
|
+
},
|
|
51
|
+
':nth-of-type(6n)::after': {
|
|
52
|
+
flexBasis: '77%'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const customWidthStyles = css({
|
|
56
|
+
'::after': {
|
|
57
|
+
flexBasis: 'var(--width)'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const beforeElementStyles = css({
|
|
61
|
+
'::before': {
|
|
62
|
+
width: skeletonItemElemSize,
|
|
63
|
+
height: skeletonItemElemSize,
|
|
64
|
+
marginRight: itemElemSpacing + itemElemSkeletonOffset,
|
|
65
|
+
marginLeft: itemElemSkeletonOffset,
|
|
66
|
+
flexShrink: 0,
|
|
67
|
+
backgroundColor: skeletonColor,
|
|
68
|
+
content: '""'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const avatarStyles = css({
|
|
72
|
+
'::before': {
|
|
73
|
+
borderRadius: '100%'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const iconStyles = css({
|
|
77
|
+
'::before': {
|
|
78
|
+
borderRadius
|
|
79
|
+
}
|
|
80
|
+
});
|
|
6
81
|
/**
|
|
7
82
|
* __Skeleton item__
|
|
8
83
|
*
|
|
@@ -11,17 +86,20 @@ import { skeletonItemCSS } from '../internal/styles/menu-item/skeleton-item';
|
|
|
11
86
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-item)
|
|
12
87
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
13
88
|
*/
|
|
14
|
-
|
|
89
|
+
|
|
90
|
+
const SkeletonItem = ({
|
|
15
91
|
hasAvatar,
|
|
16
92
|
hasIcon,
|
|
17
|
-
width,
|
|
18
93
|
testId,
|
|
19
|
-
|
|
20
|
-
cssFn =
|
|
94
|
+
width,
|
|
95
|
+
cssFn = noop
|
|
21
96
|
}) => jsx("div", {
|
|
22
|
-
|
|
23
|
-
|
|
97
|
+
style: {
|
|
98
|
+
'--width': width
|
|
99
|
+
},
|
|
100
|
+
css: [skeletonStyles, (hasAvatar || hasIcon) && beforeElementStyles, hasAvatar && avatarStyles, hasIcon && iconStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
24
101
|
cssFn(undefined)],
|
|
25
102
|
"data-testid": testId
|
|
26
|
-
})
|
|
103
|
+
});
|
|
104
|
+
|
|
27
105
|
export default SkeletonItem;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { jsx } from '@emotion/core';
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
5
|
+
const groupStyles = css({
|
|
6
|
+
display: 'flex',
|
|
7
|
+
flexDirection: 'column',
|
|
8
|
+
overflow: 'auto'
|
|
9
|
+
});
|
|
7
10
|
/**
|
|
8
11
|
* __Menu group__
|
|
9
12
|
*
|
|
@@ -12,6 +15,7 @@ import { menuGroupCSS } from '../internal/styles/menu-section/menu-group';
|
|
|
12
15
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/menu-group)
|
|
13
16
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
14
17
|
*/
|
|
18
|
+
|
|
15
19
|
const MenuGroup = ({
|
|
16
20
|
maxWidth,
|
|
17
21
|
minWidth,
|
|
@@ -20,13 +24,13 @@ const MenuGroup = ({
|
|
|
20
24
|
testId,
|
|
21
25
|
...rest
|
|
22
26
|
}) => jsx("div", _extends({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
maxHeight,
|
|
27
|
+
style: {
|
|
28
|
+
minWidth,
|
|
26
29
|
maxWidth,
|
|
27
30
|
minHeight,
|
|
28
|
-
|
|
29
|
-
}
|
|
31
|
+
maxHeight
|
|
32
|
+
},
|
|
33
|
+
css: groupStyles,
|
|
30
34
|
"data-testid": testId
|
|
31
35
|
}, rest));
|
|
32
36
|
|
|
@@ -1,11 +1,74 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { forwardRef } from 'react';
|
|
5
|
-
import { jsx } from '@emotion/core';
|
|
6
|
-
import {
|
|
4
|
+
import { forwardRef, Fragment } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/core';
|
|
6
|
+
import { N30A } from '@atlaskit/theme/colors';
|
|
7
|
+
import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
|
|
8
|
+
import { headingSizes } from '@atlaskit/theme/typography';
|
|
9
|
+
import { token } from '@atlaskit/tokens';
|
|
7
10
|
import HeadingItem from '../menu-item/heading-item';
|
|
11
|
+
const gridSize = gridSizeFn();
|
|
12
|
+
const itemHeadingTopMargin = gridSize * 2.5;
|
|
13
|
+
const itemHeadingBottomMargin = gridSize * 0.75; // Skeleton content is slightly shorter than the real content.
|
|
14
|
+
// Because of that we slightly increase the top margin to offset this so the
|
|
15
|
+
// containing size both real and skeleton always equal approx 30px.
|
|
8
16
|
|
|
17
|
+
const itemHeadingContentHeight = headingSizes.h100.lineHeight;
|
|
18
|
+
const skeletonHeadingHeight = gridSize;
|
|
19
|
+
const skeletonHeadingMarginOffset = 3;
|
|
20
|
+
const skeletonHeadingTopMargin = itemHeadingTopMargin + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset; // We want to move the entire body up by 3px without affecting the height of the skeleton container.
|
|
21
|
+
|
|
22
|
+
const skeletonHeadingBottomMargin = itemHeadingBottomMargin + skeletonHeadingMarginOffset;
|
|
23
|
+
const sectionPaddingTopBottom = gridSize * 0.75;
|
|
24
|
+
const VAR_SEPARATOR_COLOR = '--ds-menu-seperator-color';
|
|
25
|
+
const sectionStyles = css({
|
|
26
|
+
'&::before, &::after': {
|
|
27
|
+
display: 'block',
|
|
28
|
+
height: sectionPaddingTopBottom,
|
|
29
|
+
content: '""'
|
|
30
|
+
},
|
|
31
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
32
|
+
'& [data-ds--menu--heading-item]': {
|
|
33
|
+
marginTop: itemHeadingTopMargin,
|
|
34
|
+
marginBottom: itemHeadingBottomMargin,
|
|
35
|
+
'&:first-of-type': {
|
|
36
|
+
marginTop: itemHeadingTopMargin - sectionPaddingTopBottom
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
40
|
+
'& [data-ds--menu--skeleton-heading-item]': {
|
|
41
|
+
marginTop: skeletonHeadingTopMargin,
|
|
42
|
+
marginBottom: skeletonHeadingBottomMargin,
|
|
43
|
+
'&:first-of-type': {
|
|
44
|
+
marginTop: skeletonHeadingTopMargin - sectionPaddingTopBottom
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
'&:focus': {
|
|
48
|
+
// NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
|
|
49
|
+
// We have made a deliberate choice to leave this behaviour as is.
|
|
50
|
+
// This makes the outline go inside by 1px so it can actually be displayed
|
|
51
|
+
// else it gets cut off from the overflow: scroll from the parent menu group.
|
|
52
|
+
outlineOffset: -1
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const scrollableStyles = css({
|
|
56
|
+
flexShrink: 1,
|
|
57
|
+
overflow: 'auto'
|
|
58
|
+
});
|
|
59
|
+
const unscrollableStyles = css({
|
|
60
|
+
flexShrink: 0
|
|
61
|
+
});
|
|
62
|
+
const separatorStyles = css({
|
|
63
|
+
borderTop: `2px solid var(${VAR_SEPARATOR_COLOR}, ${token('color.border.neutral', N30A)})`
|
|
64
|
+
});
|
|
65
|
+
const noSeparatorStyles = css({
|
|
66
|
+
// this is to ensure that adjacent sections without separators don't get additional margins.
|
|
67
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
68
|
+
'[data-section] + &': {
|
|
69
|
+
marginTop: -6
|
|
70
|
+
}
|
|
71
|
+
});
|
|
9
72
|
/**
|
|
10
73
|
* __Section__
|
|
11
74
|
*
|
|
@@ -14,44 +77,33 @@ import HeadingItem from '../menu-item/heading-item';
|
|
|
14
77
|
* - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/section)
|
|
15
78
|
* - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
|
|
16
79
|
*/
|
|
17
|
-
|
|
18
|
-
({
|
|
80
|
+
|
|
81
|
+
const Section = /*#__PURE__*/forwardRef(({
|
|
19
82
|
children,
|
|
20
83
|
overrides,
|
|
21
84
|
title,
|
|
22
85
|
testId,
|
|
86
|
+
isScrollable,
|
|
87
|
+
hasSeparator,
|
|
88
|
+
id,
|
|
23
89
|
...rest
|
|
24
90
|
}, ref) => {
|
|
25
|
-
|
|
26
|
-
testId: testId,
|
|
27
|
-
ref: ref,
|
|
28
|
-
"aria-label": title
|
|
29
|
-
}), jsx(HeadingItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
91
|
+
const childrenMarkup = title !== undefined ? jsx(Fragment, null, jsx(HeadingItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
|
|
30
92
|
, {
|
|
31
93
|
cssFn: overrides && overrides.HeadingItem && overrides.HeadingItem.cssFn,
|
|
32
94
|
testId: testId && `${testId}--heading`,
|
|
33
95
|
"aria-hidden": true
|
|
34
|
-
}, title), children) :
|
|
96
|
+
}, title), children) : children;
|
|
97
|
+
return jsx("div", _extends({}, rest, {
|
|
98
|
+
id: id // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
|
|
99
|
+
// We have made a deliberate choice to leave this behaviour as is.
|
|
100
|
+
,
|
|
101
|
+
css: [sectionStyles, isScrollable ? scrollableStyles : unscrollableStyles, hasSeparator ? separatorStyles : noSeparatorStyles],
|
|
102
|
+
"aria-label": title,
|
|
103
|
+
"data-testid": testId,
|
|
104
|
+
role: "group",
|
|
105
|
+
"data-section": true,
|
|
35
106
|
ref: ref
|
|
36
|
-
}),
|
|
107
|
+
}), childrenMarkup);
|
|
37
108
|
});
|
|
38
|
-
const SectionBase = /*#__PURE__*/forwardRef( // Type needed on props to extract types with extract react types.
|
|
39
|
-
({
|
|
40
|
-
isScrollable,
|
|
41
|
-
hasSeparator,
|
|
42
|
-
testId,
|
|
43
|
-
...rest
|
|
44
|
-
}, ref) => jsx("div", _extends({
|
|
45
|
-
// NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
|
|
46
|
-
// We have made a deliberate choice to leave this behaviour as is.
|
|
47
|
-
// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
|
|
48
|
-
css: sectionCSS(isScrollable, hasSeparator),
|
|
49
|
-
"data-testid": testId,
|
|
50
|
-
role: "group" // this is being used to target CSS selectors
|
|
51
|
-
// where emotion's API was falling a little short.
|
|
52
|
-
,
|
|
53
|
-
"data-section": true
|
|
54
|
-
}, rest, {
|
|
55
|
-
ref: ref
|
|
56
|
-
})));
|
|
57
109
|
export default Section;
|
package/dist/es2019/version.json
CHANGED