@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.
Files changed (79) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/cjs/internal/components/menu-item-primitive.js +200 -0
  3. package/dist/cjs/menu-item/button-item.js +31 -25
  4. package/dist/cjs/menu-item/custom-item.js +31 -32
  5. package/dist/cjs/menu-item/heading-item.js +25 -7
  6. package/dist/cjs/menu-item/link-item.js +50 -45
  7. package/dist/cjs/menu-item/skeleton-heading-item.js +42 -14
  8. package/dist/cjs/menu-item/skeleton-item.js +93 -13
  9. package/dist/cjs/menu-section/menu-group.js +11 -8
  10. package/dist/cjs/menu-section/section.js +83 -29
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/internal/components/menu-item-primitive.js +180 -0
  13. package/dist/es2019/menu-item/button-item.js +28 -21
  14. package/dist/es2019/menu-item/custom-item.js +32 -24
  15. package/dist/es2019/menu-item/heading-item.js +22 -6
  16. package/dist/es2019/menu-item/link-item.js +31 -26
  17. package/dist/es2019/menu-item/skeleton-heading-item.js +37 -11
  18. package/dist/es2019/menu-item/skeleton-item.js +89 -11
  19. package/dist/es2019/menu-section/menu-group.js +12 -8
  20. package/dist/es2019/menu-section/section.js +83 -31
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/internal/components/menu-item-primitive.js +184 -0
  23. package/dist/esm/menu-item/button-item.js +30 -24
  24. package/dist/esm/menu-item/custom-item.js +32 -26
  25. package/dist/esm/menu-item/heading-item.js +22 -8
  26. package/dist/esm/menu-item/link-item.js +49 -45
  27. package/dist/esm/menu-item/skeleton-heading-item.js +38 -14
  28. package/dist/esm/menu-item/skeleton-item.js +89 -13
  29. package/dist/esm/menu-section/menu-group.js +12 -8
  30. package/dist/esm/menu-section/section.js +82 -32
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/internal/components/menu-item-primitive.d.ts +17 -0
  34. package/dist/types/menu-item/button-item.d.ts +1 -1
  35. package/dist/types/menu-item/custom-item.d.ts +2 -1
  36. package/dist/types/menu-item/skeleton-heading-item.d.ts +1 -2
  37. package/dist/types/menu-item/skeleton-item.d.ts +1 -2
  38. package/dist/types/types.d.ts +27 -7
  39. package/package.json +4 -2
  40. package/dist/cjs/internal/components/base-item.js +0 -65
  41. package/dist/cjs/internal/styles/menu-item/base-item.js +0 -152
  42. package/dist/cjs/internal/styles/menu-item/button-item.js +0 -28
  43. package/dist/cjs/internal/styles/menu-item/custom-item.js +0 -24
  44. package/dist/cjs/internal/styles/menu-item/heading-item.js +0 -28
  45. package/dist/cjs/internal/styles/menu-item/link-item.js +0 -22
  46. package/dist/cjs/internal/styles/menu-item/skeleton-heading-item.js +0 -50
  47. package/dist/cjs/internal/styles/menu-item/skeleton-item.js +0 -98
  48. package/dist/cjs/internal/styles/menu-section/menu-group.js +0 -24
  49. package/dist/cjs/internal/styles/menu-section/section.js +0 -83
  50. package/dist/es2019/internal/components/base-item.js +0 -51
  51. package/dist/es2019/internal/styles/menu-item/base-item.js +0 -122
  52. package/dist/es2019/internal/styles/menu-item/button-item.js +0 -9
  53. package/dist/es2019/internal/styles/menu-item/custom-item.js +0 -5
  54. package/dist/es2019/internal/styles/menu-item/heading-item.js +0 -16
  55. package/dist/es2019/internal/styles/menu-item/link-item.js +0 -3
  56. package/dist/es2019/internal/styles/menu-item/skeleton-heading-item.js +0 -25
  57. package/dist/es2019/internal/styles/menu-item/skeleton-item.js +0 -75
  58. package/dist/es2019/internal/styles/menu-section/menu-group.js +0 -14
  59. package/dist/es2019/internal/styles/menu-section/section.js +0 -62
  60. package/dist/esm/internal/components/base-item.js +0 -55
  61. package/dist/esm/internal/styles/menu-item/base-item.js +0 -124
  62. package/dist/esm/internal/styles/menu-item/button-item.js +0 -16
  63. package/dist/esm/internal/styles/menu-item/custom-item.js +0 -12
  64. package/dist/esm/internal/styles/menu-item/heading-item.js +0 -16
  65. package/dist/esm/internal/styles/menu-item/link-item.js +0 -10
  66. package/dist/esm/internal/styles/menu-item/skeleton-heading-item.js +0 -33
  67. package/dist/esm/internal/styles/menu-item/skeleton-item.js +0 -81
  68. package/dist/esm/internal/styles/menu-section/menu-group.js +0 -15
  69. package/dist/esm/internal/styles/menu-section/section.js +0 -67
  70. package/dist/types/internal/components/base-item.d.ts +0 -9
  71. package/dist/types/internal/styles/menu-item/base-item.d.ts +0 -23
  72. package/dist/types/internal/styles/menu-item/button-item.d.ts +0 -2
  73. package/dist/types/internal/styles/menu-item/custom-item.d.ts +0 -2
  74. package/dist/types/internal/styles/menu-item/heading-item.d.ts +0 -2
  75. package/dist/types/internal/styles/menu-item/link-item.d.ts +0 -2
  76. package/dist/types/internal/styles/menu-item/skeleton-heading-item.d.ts +0 -2
  77. package/dist/types/internal/styles/menu-item/skeleton-item.d.ts +0 -2
  78. package/dist/types/internal/styles/menu-section/menu-group.d.ts +0 -3
  79. package/dist/types/internal/styles/menu-section/section.d.ts +0 -2
@@ -0,0 +1,184 @@
1
+ /** @jsx jsx */
2
+ import { Fragment } from 'react';
3
+ import { ClassNames, css, jsx } from '@emotion/core';
4
+ import FocusRing from '@atlaskit/focus-ring';
5
+ import { N20, N200, N30 } from '@atlaskit/theme/colors';
6
+ import { fontSize as fontSizeFn, gridSize as gridSizeFn } from '@atlaskit/theme/constants';
7
+ import { headingSizes } from '@atlaskit/theme/typography';
8
+ import { token } from '@atlaskit/tokens';
9
+
10
+ var defaultRender = function defaultRender(Component, props) {
11
+ return jsx(Component, props);
12
+ };
13
+
14
+ var gridSize = gridSizeFn();
15
+ var fontSize = fontSizeFn();
16
+ var itemTopBottomPadding = gridSize;
17
+ var itemSidePadding = gridSize * 2.5;
18
+ var itemElemSpacing = gridSize * 1.5;
19
+ var itemDescriptionSpacing = gridSize * 0.375;
20
+ var itemMinHeight = gridSize * 5;
21
+ var beforeElementStyles = css({
22
+ display: 'flex',
23
+ marginRight: itemElemSpacing,
24
+ alignItems: 'center',
25
+ flexShrink: 0
26
+ });
27
+ var afterElementStyles = css({
28
+ display: 'flex',
29
+ marginLeft: itemElemSpacing,
30
+ alignItems: 'center',
31
+ flexShrink: 0
32
+ });
33
+ var contentStyles = css({
34
+ display: 'flex',
35
+ justifyContent: 'center',
36
+ flexDirection: 'column',
37
+ flexGrow: 1,
38
+ // Fix - avoid clipped text descenders when using standard 16px line-height
39
+ lineHeight: 1.22,
40
+ outline: 'none',
41
+ overflow: 'hidden',
42
+ textAlign: 'left'
43
+ });
44
+ var truncateStyles = css({
45
+ display: 'block',
46
+ overflow: 'hidden',
47
+ textOverflow: 'ellipsis',
48
+ whiteSpace: 'nowrap'
49
+ });
50
+ var wordBreakStyles = css({
51
+ wordBreak: 'break-word'
52
+ });
53
+ var descriptionStyles = css({
54
+ marginTop: itemDescriptionSpacing,
55
+ color: token('color.text.lowEmphasis', N200),
56
+ fontSize: headingSizes.h200.size
57
+ });
58
+ var primitiveStyles = css({
59
+ display: 'flex',
60
+ boxSizing: 'border-box',
61
+ width: '100%',
62
+ minHeight: itemMinHeight,
63
+ margin: 0,
64
+ padding: "".concat(itemTopBottomPadding, "px ").concat(itemSidePadding, "px"),
65
+ alignItems: 'center',
66
+ border: 0,
67
+ fontSize: fontSize,
68
+ outline: 0,
69
+ textDecoration: 'none',
70
+ userSelect: 'none',
71
+ '::-moz-focus-inner': {
72
+ border: 0
73
+ },
74
+ ':hover': {
75
+ textDecoration: 'none'
76
+ }
77
+ });
78
+ var interactiveStyles = css({
79
+ cursor: 'pointer'
80
+ });
81
+ var unselectedStyles = css({
82
+ backgroundColor: 'transparent',
83
+ color: 'currentColor',
84
+ ':visited': {
85
+ color: 'currentColor'
86
+ },
87
+ ':hover': {
88
+ backgroundColor: token('color.background.transparentNeutral.hover', N20),
89
+ color: 'currentColor'
90
+ },
91
+ ':active': {
92
+ backgroundColor: token('color.background.transparentNeutral.pressed', N30),
93
+ boxShadow: 'none',
94
+ color: 'currentColor'
95
+ }
96
+ });
97
+ var disabledStyles = css({
98
+ cursor: 'not-allowed',
99
+ '&, :hover, :active': {
100
+ backgroundColor: 'transparent',
101
+ color: token('color.text.disabled', N200)
102
+ }
103
+ });
104
+ var selectedStyles = css({
105
+ backgroundColor: token('color.background.selected.resting', N20),
106
+ // Suppress the need for a fallback as selected color isn't used in the non-tokens world.
107
+ // When removing fallbacks make sure to remove this supression.
108
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
109
+ color: token('color.text.selected'),
110
+ ':visited': {
111
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
112
+ color: token('color.text.selected')
113
+ },
114
+ ':hover': {
115
+ backgroundColor: token('color.background.selected.hover', N20),
116
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
117
+ color: token('color.text.selected')
118
+ },
119
+ ':active': {
120
+ backgroundColor: token('color.background.selected.pressed', N30),
121
+ // eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
122
+ color: token('color.text.selected')
123
+ }
124
+ });
125
+ /**
126
+ * __Menu item primitive__
127
+ *
128
+ * Menu item primitive contains all the styles for menu items,
129
+ * including support for selected, disabled, and interaction states.
130
+ *
131
+ * Using children as function prop you wire up this to your own host element.
132
+ *
133
+ * ```jsx
134
+ * <MenuItemPrimitive>
135
+ * {({ children, ...props }) => <button {...props}>{children}</button>}
136
+ * </MenuItemPrimitive>
137
+ * ```
138
+ */
139
+
140
+ var MenuItemPrimitive = function MenuItemPrimitive(_ref) {
141
+ var children = _ref.children,
142
+ title = _ref.title,
143
+ description = _ref.description,
144
+ iconAfter = _ref.iconAfter,
145
+ iconBefore = _ref.iconBefore,
146
+ overrides = _ref.overrides,
147
+ className = _ref.className,
148
+ _ref$shouldTitleWrap = _ref.shouldTitleWrap,
149
+ shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? false : _ref$shouldTitleWrap,
150
+ _ref$shouldDescriptio = _ref.shouldDescriptionWrap,
151
+ shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? false : _ref$shouldDescriptio,
152
+ _ref$isDisabled = _ref.isDisabled,
153
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
154
+ _ref$isSelected = _ref.isSelected,
155
+ isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
156
+ var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
157
+ return jsx(ClassNames, null, function (_ref2) {
158
+ var cn = _ref2.css,
159
+ cx = _ref2.cx;
160
+ return jsx(FocusRing, {
161
+ isInset: true
162
+ }, children({
163
+ className: cx([cn([primitiveStyles, !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
164
+ children: jsx(Fragment, null, iconBefore && jsx("span", {
165
+ "data-item-elem-before": true,
166
+ css: beforeElementStyles
167
+ }, iconBefore), title && jsx("span", {
168
+ css: contentStyles
169
+ }, renderTitle('span', {
170
+ children: title,
171
+ className: cn(shouldTitleWrap ? wordBreakStyles : truncateStyles),
172
+ 'data-item-title': true
173
+ }), description && jsx("span", {
174
+ "data-item-description": true,
175
+ css: [descriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
176
+ }, description)), iconAfter && jsx("span", {
177
+ "data-item-elem-after": true,
178
+ css: afterElementStyles
179
+ }, iconAfter))
180
+ }));
181
+ });
182
+ };
183
+
184
+ export default MenuItemPrimitive;
@@ -4,14 +4,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  /** @jsx jsx */
5
5
  import { forwardRef, memo } from 'react';
6
6
  import { jsx } from '@emotion/core';
7
- import BaseItem from '../internal/components/base-item';
7
+ import noop from '@atlaskit/ds-lib/noop';
8
+ import MenuItemPrimitive from '../internal/components/menu-item-primitive';
8
9
  import { useBlurOnMouseDown } from '../internal/hooks/use-blur-on-mouse-down';
9
- import { buttonItemCSS } from '../internal/styles/menu-item/button-item';
10
10
 
11
11
  /**
12
12
  * __Button item__
13
13
  *
14
- * A button item is used to populate a menu with items that need to be a button element.
14
+ * A button item is used to populate a menu with items that are buttons.
15
15
  *
16
16
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/button-item)
17
17
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
@@ -20,9 +20,7 @@ var ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on p
20
20
  function (props, ref) {
21
21
  var children = props.children,
22
22
  _props$cssFn = props.cssFn,
23
- cssFn = _props$cssFn === void 0 ? function () {
24
- return {};
25
- } : _props$cssFn,
23
+ cssFn = _props$cssFn === void 0 ? noop : _props$cssFn,
26
24
  description = props.description,
27
25
  iconAfter = props.iconAfter,
28
26
  iconBefore = props.iconBefore,
@@ -36,7 +34,7 @@ function (props, ref) {
36
34
  onMouseDown = props.onMouseDown,
37
35
  shouldTitleWrap = props.shouldTitleWrap,
38
36
  shouldDescriptionWrap = props.shouldDescriptionWrap,
39
- others = _objectWithoutProperties(props, ["children", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
37
+ rest = _objectWithoutProperties(props, ["children", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
40
38
 
41
39
  var onMouseDownHandler = useBlurOnMouseDown(onMouseDown);
42
40
 
@@ -44,27 +42,35 @@ function (props, ref) {
44
42
  return null;
45
43
  }
46
44
 
47
- return jsx("button", _extends({
48
- css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
49
- buttonItemCSS(isDisabled, isSelected), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
50
- cssFn({
51
- isSelected: isSelected,
52
- isDisabled: isDisabled
53
- })],
54
- type: "button",
55
- "data-testid": testId,
56
- disabled: isDisabled,
57
- onClick: onClick,
58
- onMouseDown: onMouseDownHandler,
59
- ref: ref
60
- }, others), jsx(BaseItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
61
- , {
45
+ return jsx(MenuItemPrimitive, _extends({}, rest, {
46
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
62
47
  overrides: overrides,
63
48
  iconBefore: iconBefore,
64
49
  iconAfter: iconAfter,
50
+ isDisabled: isDisabled,
51
+ isSelected: isSelected,
65
52
  description: description,
53
+ title: children,
66
54
  shouldTitleWrap: shouldTitleWrap,
67
- shouldDescriptionWrap: shouldDescriptionWrap
68
- }, children));
55
+ shouldDescriptionWrap: shouldDescriptionWrap,
56
+ css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
57
+ cssFn({
58
+ isSelected: isSelected,
59
+ isDisabled: isDisabled
60
+ })
61
+ }), function (_ref) {
62
+ var children = _ref.children,
63
+ className = _ref.className;
64
+ return jsx("button", _extends({
65
+ "data-testid": testId
66
+ }, rest, {
67
+ className: className,
68
+ ref: ref,
69
+ disabled: isDisabled,
70
+ onClick: onClick,
71
+ onMouseDown: onMouseDownHandler,
72
+ type: "button"
73
+ }), children);
74
+ });
69
75
  }));
70
76
  export default ButtonItem;
@@ -1,10 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import React, { forwardRef, memo } from 'react';
4
- import { ClassNames } from '@emotion/core';
5
- import BaseItem from '../internal/components/base-item';
3
+
4
+ /** @jsx jsx */
5
+ import { forwardRef, memo } from 'react';
6
+ import { css, jsx } from '@emotion/core';
7
+ import noop from '@atlaskit/ds-lib/noop';
8
+ import MenuItemPrimitive from '../internal/components/menu-item-primitive';
6
9
  import { useBlurOnMouseDown } from '../internal/hooks/use-blur-on-mouse-down';
7
- import { customItemCSS } from '../internal/styles/menu-item/custom-item';
8
10
 
9
11
  var preventEvent = function preventEvent(e) {
10
12
  e.preventDefault();
@@ -14,7 +16,7 @@ var preventEvent = function preventEvent(e) {
14
16
  /**
15
17
  * __Custom item__
16
18
  *
17
- * A custom item is used to populate a menu with items that need to be a custom element.
19
+ * A custom item is used to populate a menu with items that can be any element.
18
20
  *
19
21
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/custom-item)
20
22
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
@@ -22,9 +24,7 @@ var preventEvent = function preventEvent(e) {
22
24
  var CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
23
25
  var Component = _ref.component,
24
26
  _ref$cssFn = _ref.cssFn,
25
- cssFn = _ref$cssFn === void 0 ? function () {
26
- return {};
27
- } : _ref$cssFn,
27
+ cssFn = _ref$cssFn === void 0 ? noop : _ref$cssFn,
28
28
  _ref$isDisabled = _ref.isDisabled,
29
29
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
30
30
  _ref$isSelected = _ref.isSelected,
@@ -47,31 +47,37 @@ var CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref)
47
47
  return null;
48
48
  }
49
49
 
50
- return /*#__PURE__*/React.createElement(ClassNames, null, function (_ref2) {
51
- var css = _ref2.css;
52
- return /*#__PURE__*/React.createElement(Component, _extends({
50
+ return jsx(MenuItemPrimitive, _extends({}, rest, {
51
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
52
+ overrides: overrides,
53
+ description: description,
54
+ iconAfter: iconAfter,
55
+ title: children,
56
+ iconBefore: iconBefore,
57
+ isSelected: isSelected,
58
+ isDisabled: isDisabled,
59
+ shouldTitleWrap: shouldTitleWrap,
60
+ shouldDescriptionWrap: shouldDescriptionWrap // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
61
+ ,
62
+ css: css(cssFn({
63
+ isDisabled: isDisabled,
64
+ isSelected: isSelected
65
+ }))
66
+ }), function (_ref2) {
67
+ var children = _ref2.children,
68
+ className = _ref2.className;
69
+ return jsx(Component, _extends({
70
+ "data-testid": testId
71
+ }, rest, {
72
+ className: className,
53
73
  ref: ref,
54
- "data-testid": testId,
55
74
  draggable: false,
56
- className: css([customItemCSS(isDisabled, isSelected), cssFn({
57
- isDisabled: isDisabled,
58
- isSelected: isSelected
59
- })]),
60
75
  onDragStart: preventEvent,
61
76
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
62
77
  onClick: isDisabled ? preventEvent : onClick,
63
78
  tabIndex: isDisabled ? -1 : undefined,
64
79
  "aria-disabled": isDisabled
65
- }, rest), /*#__PURE__*/React.createElement(BaseItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
66
- , {
67
- overrides: overrides,
68
- children: children,
69
- description: description,
70
- iconAfter: iconAfter,
71
- iconBefore: iconBefore,
72
- shouldTitleWrap: shouldTitleWrap,
73
- shouldDescriptionWrap: shouldDescriptionWrap
74
- }));
80
+ }), children);
75
81
  });
76
82
  }) // Dirty hack to get generics working with forward ref [2/2]
77
83
  );
@@ -3,9 +3,24 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
 
4
4
  /** @jsx jsx */
5
5
  import { memo } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { headingItemCSS } from '../internal/styles/menu-item/heading-item';
8
-
6
+ import { css, jsx } from '@emotion/core';
7
+ import noop from '@atlaskit/ds-lib/noop';
8
+ import { N200 } from '@atlaskit/theme/colors';
9
+ import { gridSize as gridSizeFn } from '@atlaskit/theme/constants';
10
+ import { headingSizes } from '@atlaskit/theme/typography';
11
+ import { token } from '@atlaskit/tokens';
12
+ var gridSize = gridSizeFn();
13
+ var itemSidePadding = gridSize * 2.5;
14
+ var itemHeadingContentHeight = headingSizes.h100.lineHeight;
15
+ var itemHeadingFontSize = headingSizes.h100.size;
16
+ var headingStyles = css({
17
+ padding: "0 ".concat(itemSidePadding, "px"),
18
+ color: token('color.text.lowEmphasis', N200),
19
+ fontSize: itemHeadingFontSize,
20
+ fontWeight: 700,
21
+ lineHeight: itemHeadingContentHeight / itemHeadingFontSize,
22
+ textTransform: 'uppercase'
23
+ });
9
24
  /**
10
25
  * __Heading item__
11
26
  *
@@ -14,19 +29,18 @@ import { headingItemCSS } from '../internal/styles/menu-item/heading-item';
14
29
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/heading-item)
15
30
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
16
31
  */
32
+
17
33
  var HeadingItem = /*#__PURE__*/memo(function (_ref) {
18
34
  var children = _ref.children,
19
35
  testId = _ref.testId,
20
36
  id = _ref.id,
21
37
  _ref$cssFn = _ref.cssFn,
22
- cssFn = _ref$cssFn === void 0 ? function () {
23
- return {};
24
- } : _ref$cssFn,
38
+ cssFn = _ref$cssFn === void 0 ? noop : _ref$cssFn,
25
39
  rest = _objectWithoutProperties(_ref, ["children", "testId", "id", "cssFn"]);
26
40
 
27
41
  return jsx("div", _extends({
28
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
29
- css: [headingItemCSS, cssFn(undefined)],
42
+ css: [headingStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
43
+ cssFn(undefined)],
30
44
  "data-testid": testId,
31
45
  "data-ds--menu--heading-item": true,
32
46
  id: id
@@ -4,9 +4,9 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  /** @jsx jsx */
5
5
  import { forwardRef, memo } from 'react';
6
6
  import { jsx } from '@emotion/core';
7
- import BaseItem from '../internal/components/base-item';
7
+ import noop from '@atlaskit/ds-lib/noop';
8
+ import MenuItemPrimitive from '../internal/components/menu-item-primitive';
8
9
  import { useBlurOnMouseDown } from '../internal/hooks/use-blur-on-mouse-down';
9
- import { linkItemCSS } from '../internal/styles/menu-item/link-item';
10
10
 
11
11
  var preventEvent = function preventEvent(e) {
12
12
  e.preventDefault();
@@ -22,29 +22,25 @@ var preventEvent = function preventEvent(e) {
22
22
 
23
23
 
24
24
  var LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on props to extract types with extract react types.
25
- function (_ref, ref) {
26
- var href = _ref.href,
27
- rest = _objectWithoutProperties(_ref, ["href"]);
28
-
29
- var children = rest.children,
30
- _rest$cssFn = rest.cssFn,
31
- cssFn = _rest$cssFn === void 0 ? function () {
32
- return {};
33
- } : _rest$cssFn,
34
- description = rest.description,
35
- iconAfter = rest.iconAfter,
36
- iconBefore = rest.iconBefore,
37
- _rest$isDisabled = rest.isDisabled,
38
- isDisabled = _rest$isDisabled === void 0 ? false : _rest$isDisabled,
39
- _rest$isSelected = rest.isSelected,
40
- isSelected = _rest$isSelected === void 0 ? false : _rest$isSelected,
41
- onClick = rest.onClick,
42
- testId = rest.testId,
43
- overrides = rest.overrides,
44
- onMouseDown = rest.onMouseDown,
45
- shouldTitleWrap = rest.shouldTitleWrap,
46
- shouldDescriptionWrap = rest.shouldDescriptionWrap,
47
- others = _objectWithoutProperties(rest, ["children", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
25
+ function (props, ref) {
26
+ var children = props.children,
27
+ href = props.href,
28
+ _props$cssFn = props.cssFn,
29
+ cssFn = _props$cssFn === void 0 ? noop : _props$cssFn,
30
+ description = props.description,
31
+ iconAfter = props.iconAfter,
32
+ iconBefore = props.iconBefore,
33
+ _props$isDisabled = props.isDisabled,
34
+ isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
35
+ _props$isSelected = props.isSelected,
36
+ isSelected = _props$isSelected === void 0 ? false : _props$isSelected,
37
+ onClick = props.onClick,
38
+ testId = props.testId,
39
+ overrides = props.overrides,
40
+ onMouseDown = props.onMouseDown,
41
+ shouldTitleWrap = props.shouldTitleWrap,
42
+ shouldDescriptionWrap = props.shouldDescriptionWrap,
43
+ rest = _objectWithoutProperties(props, ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap"]);
48
44
 
49
45
  var onMouseDownHandler = useBlurOnMouseDown(onMouseDown);
50
46
 
@@ -52,30 +48,38 @@ function (_ref, ref) {
52
48
  return null;
53
49
  }
54
50
 
55
- return jsx("a", _extends({
56
- ref: ref,
57
- css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
58
- linkItemCSS(isDisabled, isSelected), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
59
- cssFn({
60
- isSelected: isSelected,
61
- isDisabled: isDisabled
62
- })],
63
- draggable: false,
64
- href: isDisabled ? undefined : href,
65
- "data-testid": testId,
66
- onDragStart: preventEvent,
67
- onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
68
- onClick: isDisabled ? preventEvent : onClick,
69
- "aria-current": isSelected ? 'page' : undefined,
70
- "aria-disabled": isDisabled
71
- }, others), jsx(BaseItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
72
- , {
51
+ return jsx(MenuItemPrimitive, _extends({}, rest, {
52
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
73
53
  overrides: overrides,
74
54
  iconBefore: iconBefore,
75
55
  iconAfter: iconAfter,
56
+ isSelected: isSelected,
57
+ isDisabled: isDisabled,
76
58
  description: description,
77
59
  shouldTitleWrap: shouldTitleWrap,
78
- shouldDescriptionWrap: shouldDescriptionWrap
79
- }, children));
60
+ shouldDescriptionWrap: shouldDescriptionWrap,
61
+ css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
62
+ cssFn({
63
+ isSelected: isSelected,
64
+ isDisabled: isDisabled
65
+ }),
66
+ title: children
67
+ }), function (_ref) {
68
+ var children = _ref.children,
69
+ className = _ref.className;
70
+ return jsx("a", _extends({
71
+ "data-testid": testId
72
+ }, rest, {
73
+ className: className,
74
+ href: isDisabled ? undefined : href,
75
+ draggable: false,
76
+ onDragStart: preventEvent,
77
+ onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
78
+ onClick: isDisabled ? preventEvent : onClick,
79
+ "aria-current": isSelected ? 'page' : undefined,
80
+ "aria-disabled": isDisabled,
81
+ ref: ref
82
+ }), children);
83
+ });
80
84
  }));
81
85
  export default LinkItem;
@@ -1,8 +1,30 @@
1
1
  /** @jsx jsx */
2
- import { memo } from 'react';
3
- import { jsx } from '@emotion/core';
4
- import { skeletonHeadingItemCSS } from '../internal/styles/menu-item/skeleton-heading-item';
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
+ var skeletonStyles = css({
8
+ padding: "0 ".concat(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
+ var defaultWidthStyles = css({
19
+ '::after': {
20
+ width: '30%'
21
+ }
22
+ });
23
+ var customWidthStyles = css({
24
+ '::after': {
25
+ width: 'var(--width)'
26
+ }
27
+ });
6
28
  /**
7
29
  * __Skeleton heading item__
8
30
  *
@@ -11,19 +33,21 @@ 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
- var SkeletonHeadingItem = /*#__PURE__*/memo(function (_ref) {
15
- var width = _ref.width,
16
- testId = _ref.testId,
17
- isShimmering = _ref.isShimmering,
36
+
37
+ var SkeletonHeadingItem = function SkeletonHeadingItem(_ref) {
38
+ var testId = _ref.testId,
39
+ width = _ref.width,
18
40
  _ref$cssFn = _ref.cssFn,
19
- cssFn = _ref$cssFn === void 0 ? function () {
20
- return {};
21
- } : _ref$cssFn;
41
+ cssFn = _ref$cssFn === void 0 ? noop : _ref$cssFn;
22
42
  return jsx("div", {
23
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
24
- css: [skeletonHeadingItemCSS(width, isShimmering), cssFn(undefined)],
43
+ style: {
44
+ '--width': width
45
+ },
46
+ css: [skeletonStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
47
+ cssFn(undefined)],
25
48
  "data-ds--menu--skeleton-heading-item": true,
26
49
  "data-testid": testId
27
50
  });
28
- });
51
+ };
52
+
29
53
  export default SkeletonHeadingItem;