@atlaskit/menu 1.1.4 → 1.2.3

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 +54 -0
  2. package/dist/cjs/internal/components/menu-item-primitive.js +193 -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 +23 -7
  6. package/dist/cjs/menu-item/link-item.js +50 -45
  7. package/dist/cjs/menu-item/skeleton-heading-item.js +40 -14
  8. package/dist/cjs/menu-item/skeleton-item.js +91 -13
  9. package/dist/cjs/menu-section/menu-group.js +11 -8
  10. package/dist/cjs/menu-section/section.js +81 -29
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/internal/components/menu-item-primitive.js +174 -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 +21 -6
  16. package/dist/es2019/menu-item/link-item.js +31 -26
  17. package/dist/es2019/menu-item/skeleton-heading-item.js +36 -11
  18. package/dist/es2019/menu-item/skeleton-item.js +88 -11
  19. package/dist/es2019/menu-section/menu-group.js +12 -8
  20. package/dist/es2019/menu-section/section.js +82 -31
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/internal/components/menu-item-primitive.js +178 -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 +21 -8
  26. package/dist/esm/menu-item/link-item.js +49 -45
  27. package/dist/esm/menu-item/skeleton-heading-item.js +37 -14
  28. package/dist/esm/menu-item/skeleton-item.js +88 -13
  29. package/dist/esm/menu-section/menu-group.js +12 -8
  30. package/dist/esm/menu-section/section.js +81 -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 +8 -3
  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
@@ -1,18 +1,42 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
8
- var _react = require("react");
9
-
10
10
  var _core = require("@emotion/core");
11
11
 
12
- var _skeletonHeadingItem = require("../internal/styles/menu-item/skeleton-heading-item");
12
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
13
13
 
14
- /** @jsx jsx */
14
+ var _colors = require("@atlaskit/theme/colors");
15
15
 
16
+ var _constants = require("@atlaskit/theme/constants");
17
+
18
+ /** @jsx jsx */
19
+ var skeletonStyles = (0, _core.css)({
20
+ padding: "0 ".concat((0, _constants.gridSize)() * 2.5, "px"),
21
+ '::after': {
22
+ display: 'block',
23
+ width: '30%',
24
+ height: (0, _constants.gridSize)(),
25
+ backgroundColor: "var(--ds-background-subtleNeutral-resting, ".concat((0, _colors.skeleton)(), ")"),
26
+ borderRadius: 100,
27
+ content: '""'
28
+ }
29
+ });
30
+ var defaultWidthStyles = (0, _core.css)({
31
+ '::after': {
32
+ width: '30%'
33
+ }
34
+ });
35
+ var customWidthStyles = (0, _core.css)({
36
+ '::after': {
37
+ width: 'var(--width)'
38
+ }
39
+ });
16
40
  /**
17
41
  * __Skeleton heading item__
18
42
  *
@@ -21,20 +45,22 @@ var _skeletonHeadingItem = require("../internal/styles/menu-item/skeleton-headin
21
45
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-heading-item)
22
46
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
23
47
  */
24
- var SkeletonHeadingItem = /*#__PURE__*/(0, _react.memo)(function (_ref) {
25
- var width = _ref.width,
26
- testId = _ref.testId,
27
- isShimmering = _ref.isShimmering,
48
+
49
+ var SkeletonHeadingItem = function SkeletonHeadingItem(_ref) {
50
+ var testId = _ref.testId,
51
+ width = _ref.width,
28
52
  _ref$cssFn = _ref.cssFn,
29
- cssFn = _ref$cssFn === void 0 ? function () {
30
- return {};
31
- } : _ref$cssFn;
53
+ cssFn = _ref$cssFn === void 0 ? _noop.default : _ref$cssFn;
32
54
  return (0, _core.jsx)("div", {
33
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
34
- css: [(0, _skeletonHeadingItem.skeletonHeadingItemCSS)(width, isShimmering), cssFn(undefined)],
55
+ style: {
56
+ '--width': width
57
+ },
58
+ css: [skeletonStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
59
+ cssFn(undefined)],
35
60
  "data-ds--menu--skeleton-heading-item": true,
36
61
  "data-testid": testId
37
62
  });
38
- });
63
+ };
64
+
39
65
  var _default = SkeletonHeadingItem;
40
66
  exports.default = _default;
@@ -1,18 +1,95 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
8
- var _react = require("react");
9
-
10
10
  var _core = require("@emotion/core");
11
11
 
12
- var _skeletonItem = require("../internal/styles/menu-item/skeleton-item");
12
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
13
13
 
14
- /** @jsx jsx */
14
+ var _colors = require("@atlaskit/theme/colors");
15
+
16
+ var _constants = require("@atlaskit/theme/constants");
15
17
 
18
+ /** @jsx jsx */
19
+ var gridSize = (0, _constants.gridSize)();
20
+ var borderRadius = (0, _constants.borderRadius)();
21
+ var itemElemSpacing = gridSize * 1.5;
22
+ var itemExpectedElemSize = gridSize * 3;
23
+ var itemMinHeight = gridSize * 5;
24
+ var itemPadding = gridSize * 2.5;
25
+ var skeletonItemElemSize = gridSize * 2.5;
26
+ var itemElemSkeletonOffset = (itemExpectedElemSize - skeletonItemElemSize) / 2;
27
+ var skeletonTextBorderRadius = 100;
28
+ var skeletonContentHeight = 9;
29
+ var skeletonColor = "var(--ds-background-subtleNeutral-resting, ".concat((0, _colors.skeleton)(), ")");
30
+ var skeletonStyles = (0, _core.css)({
31
+ display: 'flex',
32
+ minHeight: itemMinHeight,
33
+ padding: "0 ".concat(itemPadding, "px"),
34
+ alignItems: 'center',
35
+ pointerEvents: 'none',
36
+ '::after': {
37
+ height: skeletonContentHeight,
38
+ // This is a little bespoke but we need to push everything down 1px
39
+ // because the skeleton content should align to the bottom of the text.
40
+ // Confirm VR test failures before accepting a change.
41
+ marginTop: 1,
42
+ backgroundColor: skeletonColor,
43
+ borderRadius: skeletonTextBorderRadius,
44
+ content: '""'
45
+ }
46
+ });
47
+ var defaultWidthStyles = (0, _core.css)({
48
+ ':nth-of-type(1n)::after': {
49
+ flexBasis: '70%'
50
+ },
51
+ ':nth-of-type(2n)::after': {
52
+ flexBasis: '50%'
53
+ },
54
+ ':nth-of-type(3n)::after': {
55
+ flexBasis: '60%'
56
+ },
57
+ ':nth-of-type(4n)::after': {
58
+ flexBasis: '90%'
59
+ },
60
+ ':nth-of-type(5n)::after': {
61
+ flexBasis: '35%'
62
+ },
63
+ ':nth-of-type(6n)::after': {
64
+ flexBasis: '77%'
65
+ }
66
+ });
67
+ var customWidthStyles = (0, _core.css)({
68
+ '::after': {
69
+ flexBasis: 'var(--width)'
70
+ }
71
+ });
72
+ var beforeElementStyles = (0, _core.css)({
73
+ '::before': {
74
+ width: skeletonItemElemSize,
75
+ height: skeletonItemElemSize,
76
+ marginRight: itemElemSpacing + itemElemSkeletonOffset,
77
+ marginLeft: itemElemSkeletonOffset,
78
+ flexShrink: 0,
79
+ backgroundColor: skeletonColor,
80
+ content: '""'
81
+ }
82
+ });
83
+ var avatarStyles = (0, _core.css)({
84
+ '::before': {
85
+ borderRadius: '100%'
86
+ }
87
+ });
88
+ var iconStyles = (0, _core.css)({
89
+ '::before': {
90
+ borderRadius: borderRadius
91
+ }
92
+ });
16
93
  /**
17
94
  * __Skeleton item__
18
95
  *
@@ -21,22 +98,23 @@ var _skeletonItem = require("../internal/styles/menu-item/skeleton-item");
21
98
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-item)
22
99
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
23
100
  */
24
- var SkeletonItem = /*#__PURE__*/(0, _react.memo)(function (_ref) {
101
+
102
+ var SkeletonItem = function SkeletonItem(_ref) {
25
103
  var hasAvatar = _ref.hasAvatar,
26
104
  hasIcon = _ref.hasIcon,
27
- width = _ref.width,
28
105
  testId = _ref.testId,
29
- isShimmering = _ref.isShimmering,
106
+ width = _ref.width,
30
107
  _ref$cssFn = _ref.cssFn,
31
- cssFn = _ref$cssFn === void 0 ? function () {
32
- return {};
33
- } : _ref$cssFn;
108
+ cssFn = _ref$cssFn === void 0 ? _noop.default : _ref$cssFn;
34
109
  return (0, _core.jsx)("div", {
35
- css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
36
- (0, _skeletonItem.skeletonItemCSS)(hasAvatar, hasIcon, width, isShimmering), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
110
+ style: {
111
+ '--width': width
112
+ },
113
+ css: [skeletonStyles, (hasAvatar || hasIcon) && beforeElementStyles, hasAvatar && avatarStyles, hasIcon && iconStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
37
114
  cssFn(undefined)],
38
115
  "data-testid": testId
39
116
  });
40
- });
117
+ };
118
+
41
119
  var _default = SkeletonItem;
42
120
  exports.default = _default;
@@ -13,10 +13,12 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
13
13
 
14
14
  var _core = require("@emotion/core");
15
15
 
16
- var _menuGroup = require("../internal/styles/menu-section/menu-group");
17
-
18
16
  /** @jsx jsx */
19
-
17
+ var groupStyles = (0, _core.css)({
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ overflow: 'auto'
21
+ });
20
22
  /**
21
23
  * __Menu group__
22
24
  *
@@ -25,6 +27,7 @@ var _menuGroup = require("../internal/styles/menu-section/menu-group");
25
27
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/menu-group)
26
28
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
27
29
  */
30
+
28
31
  var MenuGroup = function MenuGroup(_ref) {
29
32
  var maxWidth = _ref.maxWidth,
30
33
  minWidth = _ref.minWidth,
@@ -33,13 +36,13 @@ var MenuGroup = function MenuGroup(_ref) {
33
36
  testId = _ref.testId,
34
37
  rest = (0, _objectWithoutProperties2.default)(_ref, ["maxWidth", "minWidth", "minHeight", "maxHeight", "testId"]);
35
38
  return (0, _core.jsx)("div", (0, _extends2.default)({
36
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
37
- css: (0, _menuGroup.menuGroupCSS)({
38
- maxHeight: maxHeight,
39
+ style: {
40
+ minWidth: minWidth,
39
41
  maxWidth: maxWidth,
40
42
  minHeight: minHeight,
41
- minWidth: minWidth
42
- }),
43
+ maxHeight: maxHeight
44
+ },
45
+ css: groupStyles,
43
46
  "data-testid": testId
44
47
  }, rest));
45
48
  };
@@ -15,12 +15,76 @@ var _react = require("react");
15
15
 
16
16
  var _core = require("@emotion/core");
17
17
 
18
- var _section = require("../internal/styles/menu-section/section");
18
+ var _colors = require("@atlaskit/theme/colors");
19
+
20
+ var _constants = require("@atlaskit/theme/constants");
21
+
22
+ var _typography = require("@atlaskit/theme/typography");
19
23
 
20
24
  var _headingItem = _interopRequireDefault(require("../menu-item/heading-item"));
21
25
 
22
26
  /** @jsx jsx */
27
+ var gridSize = (0, _constants.gridSize)();
28
+ var itemHeadingTopMargin = gridSize * 2.5;
29
+ var itemHeadingBottomMargin = gridSize * 0.75; // Skeleton content is slightly shorter than the real content.
30
+ // Because of that we slightly increase the top margin to offset this so the
31
+ // containing size both real and skeleton always equal approx 30px.
23
32
 
33
+ var itemHeadingContentHeight = _typography.headingSizes.h100.lineHeight;
34
+ var skeletonHeadingHeight = gridSize;
35
+ var skeletonHeadingMarginOffset = 3;
36
+ var skeletonHeadingTopMargin = itemHeadingTopMargin + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset; // We want to move the entire body up by 3px without affecting the height of the skeleton container.
37
+
38
+ var skeletonHeadingBottomMargin = itemHeadingBottomMargin + skeletonHeadingMarginOffset;
39
+ var sectionPaddingTopBottom = gridSize * 0.75;
40
+ var VAR_SEPARATOR_COLOR = '--ds-menu-seperator-color';
41
+ var sectionStyles = (0, _core.css)({
42
+ '&::before, &::after': {
43
+ display: 'block',
44
+ height: sectionPaddingTopBottom,
45
+ content: '""'
46
+ },
47
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
48
+ '& [data-ds--menu--heading-item]': {
49
+ marginTop: itemHeadingTopMargin,
50
+ marginBottom: itemHeadingBottomMargin,
51
+ '&:first-of-type': {
52
+ marginTop: itemHeadingTopMargin - sectionPaddingTopBottom
53
+ }
54
+ },
55
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
56
+ '& [data-ds--menu--skeleton-heading-item]': {
57
+ marginTop: skeletonHeadingTopMargin,
58
+ marginBottom: skeletonHeadingBottomMargin,
59
+ '&:first-of-type': {
60
+ marginTop: skeletonHeadingTopMargin - sectionPaddingTopBottom
61
+ }
62
+ },
63
+ '&:focus': {
64
+ // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
65
+ // We have made a deliberate choice to leave this behaviour as is.
66
+ // This makes the outline go inside by 1px so it can actually be displayed
67
+ // else it gets cut off from the overflow: scroll from the parent menu group.
68
+ outlineOffset: -1
69
+ }
70
+ });
71
+ var scrollableStyles = (0, _core.css)({
72
+ flexShrink: 1,
73
+ overflow: 'auto'
74
+ });
75
+ var unscrollableStyles = (0, _core.css)({
76
+ flexShrink: 0
77
+ });
78
+ var separatorStyles = (0, _core.css)({
79
+ borderTop: "2px solid var(".concat(VAR_SEPARATOR_COLOR, ", ").concat("var(--ds-border-neutral, ".concat(_colors.N30A, ")"), ")")
80
+ });
81
+ var noSeparatorStyles = (0, _core.css)({
82
+ // this is to ensure that adjacent sections without separators don't get additional margins.
83
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
84
+ '[data-section] + &': {
85
+ marginTop: -6
86
+ }
87
+ });
24
88
  /**
25
89
  * __Section__
26
90
  *
@@ -29,45 +93,33 @@ var _headingItem = _interopRequireDefault(require("../menu-item/heading-item"));
29
93
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/section)
30
94
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
31
95
  */
32
- var Section = /*#__PURE__*/(0, _react.forwardRef)( // Type needed on props to extract types with extract react types.
33
- function (_ref, ref) {
96
+
97
+ var Section = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
34
98
  var children = _ref.children,
35
99
  overrides = _ref.overrides,
36
100
  title = _ref.title,
37
101
  testId = _ref.testId,
38
- rest = (0, _objectWithoutProperties2.default)(_ref, ["children", "overrides", "title", "testId"]);
39
- return title !== undefined ? (0, _core.jsx)(SectionBase, (0, _extends2.default)({}, rest, {
40
- testId: testId,
41
- ref: ref,
42
- "aria-label": title
43
- }), (0, _core.jsx)(_headingItem.default // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
102
+ isScrollable = _ref.isScrollable,
103
+ hasSeparator = _ref.hasSeparator,
104
+ id = _ref.id,
105
+ rest = (0, _objectWithoutProperties2.default)(_ref, ["children", "overrides", "title", "testId", "isScrollable", "hasSeparator", "id"]);
106
+ var childrenMarkup = title !== undefined ? (0, _core.jsx)(_react.Fragment, null, (0, _core.jsx)(_headingItem.default // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
44
107
  , {
45
108
  cssFn: overrides && overrides.HeadingItem && overrides.HeadingItem.cssFn,
46
109
  testId: testId && "".concat(testId, "--heading"),
47
110
  "aria-hidden": true
48
- }, title), children) : (0, _core.jsx)(SectionBase, (0, _extends2.default)({}, rest, {
49
- ref: ref
50
- }), children);
51
- });
52
- var SectionBase = /*#__PURE__*/(0, _react.forwardRef)( // Type needed on props to extract types with extract react types.
53
- function (_ref2, ref) {
54
- var isScrollable = _ref2.isScrollable,
55
- hasSeparator = _ref2.hasSeparator,
56
- testId = _ref2.testId,
57
- rest = (0, _objectWithoutProperties2.default)(_ref2, ["isScrollable", "hasSeparator", "testId"]);
58
- return (0, _core.jsx)("div", (0, _extends2.default)({
59
- // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
111
+ }, title), children) : children;
112
+ return (0, _core.jsx)("div", (0, _extends2.default)({}, rest, {
113
+ id: id // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
60
114
  // We have made a deliberate choice to leave this behaviour as is.
61
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
62
- css: (0, _section.sectionCSS)(isScrollable, hasSeparator),
63
- "data-testid": testId,
64
- role: "group" // this is being used to target CSS selectors
65
- // where emotion's API was falling a little short.
66
115
  ,
67
- "data-section": true
68
- }, rest, {
116
+ css: [sectionStyles, isScrollable ? scrollableStyles : unscrollableStyles, hasSeparator ? separatorStyles : noSeparatorStyles],
117
+ "aria-label": title,
118
+ "data-testid": testId,
119
+ role: "group",
120
+ "data-section": true,
69
121
  ref: ref
70
- }));
122
+ }), childrenMarkup);
71
123
  });
72
124
  var _default = Section;
73
125
  exports.default = _default;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/menu",
3
- "version": "1.1.4",
3
+ "version": "1.2.3",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,174 @@
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
+
9
+ const defaultRender = (Component, props) => jsx(Component, props);
10
+
11
+ const gridSize = gridSizeFn();
12
+ const fontSize = fontSizeFn();
13
+ const itemTopBottomPadding = gridSize;
14
+ const itemSidePadding = gridSize * 2.5;
15
+ const itemElemSpacing = gridSize * 1.5;
16
+ const itemDescriptionSpacing = gridSize * 0.375;
17
+ const itemMinHeight = gridSize * 5;
18
+ const beforeElementStyles = css({
19
+ display: 'flex',
20
+ marginRight: itemElemSpacing,
21
+ alignItems: 'center',
22
+ flexShrink: 0
23
+ });
24
+ const afterElementStyles = css({
25
+ display: 'flex',
26
+ marginLeft: itemElemSpacing,
27
+ alignItems: 'center',
28
+ flexShrink: 0
29
+ });
30
+ const contentStyles = css({
31
+ display: 'flex',
32
+ justifyContent: 'center',
33
+ flexDirection: 'column',
34
+ flexGrow: 1,
35
+ // Fix - avoid clipped text descenders when using standard 16px line-height
36
+ lineHeight: 1.22,
37
+ outline: 'none',
38
+ overflow: 'hidden',
39
+ textAlign: 'left'
40
+ });
41
+ const truncateStyles = css({
42
+ display: 'block',
43
+ overflow: 'hidden',
44
+ textOverflow: 'ellipsis',
45
+ whiteSpace: 'nowrap'
46
+ });
47
+ const wordBreakStyles = css({
48
+ wordBreak: 'break-word'
49
+ });
50
+ const descriptionStyles = css({
51
+ marginTop: itemDescriptionSpacing,
52
+ color: `var(--ds-text-lowEmphasis, ${N200})`,
53
+ fontSize: headingSizes.h200.size
54
+ });
55
+ const primitiveStyles = css({
56
+ display: 'flex',
57
+ boxSizing: 'border-box',
58
+ width: '100%',
59
+ minHeight: itemMinHeight,
60
+ margin: 0,
61
+ padding: `${itemTopBottomPadding}px ${itemSidePadding}px`,
62
+ alignItems: 'center',
63
+ border: 0,
64
+ fontSize: fontSize,
65
+ outline: 0,
66
+ textDecoration: 'none',
67
+ userSelect: 'none',
68
+ '::-moz-focus-inner': {
69
+ border: 0
70
+ },
71
+ ':hover': {
72
+ textDecoration: 'none'
73
+ }
74
+ });
75
+ const interactiveStyles = css({
76
+ cursor: 'pointer'
77
+ });
78
+ const unselectedStyles = css({
79
+ backgroundColor: 'transparent',
80
+ color: 'currentColor',
81
+ ':visited': {
82
+ color: 'currentColor'
83
+ },
84
+ ':hover': {
85
+ backgroundColor: `var(--ds-background-transparentNeutral-hover, ${N20})`,
86
+ color: 'currentColor'
87
+ },
88
+ ':active': {
89
+ backgroundColor: `var(--ds-background-transparentNeutral-pressed, ${N30})`,
90
+ boxShadow: 'none',
91
+ color: 'currentColor'
92
+ }
93
+ });
94
+ const disabledStyles = css({
95
+ cursor: 'not-allowed',
96
+ '&, :hover, :active': {
97
+ backgroundColor: 'transparent',
98
+ color: `var(--ds-text-disabled, ${N200})`
99
+ }
100
+ });
101
+ const selectedStyles = css({
102
+ backgroundColor: `var(--ds-background-selected-resting, ${N20})`,
103
+ // Fallback set as babel plugin inserts one otherwise
104
+ color: "var(--ds-text-selected, currentColor)",
105
+ ':visited': {
106
+ color: "var(--ds-text-selected, currentColor)"
107
+ },
108
+ ':hover': {
109
+ backgroundColor: `var(--ds-background-selected-hover, ${N20})`,
110
+ color: "var(--ds-text-selected, currentColor)"
111
+ },
112
+ ':active': {
113
+ backgroundColor: `var(--ds-background-selected-pressed, ${N30})`,
114
+ color: "var(--ds-text-selected, currentColor)"
115
+ }
116
+ });
117
+ /**
118
+ * __Menu item primitive__
119
+ *
120
+ * Menu item primitive contains all the styles for menu items,
121
+ * including support for selected, disabled, and interaction states.
122
+ *
123
+ * Using children as function prop you wire up this to your own host element.
124
+ *
125
+ * ```jsx
126
+ * <MenuItemPrimitive>
127
+ * {({ children, ...props }) => <button {...props}>{children}</button>}
128
+ * </MenuItemPrimitive>
129
+ * ```
130
+ */
131
+
132
+ const MenuItemPrimitive = ({
133
+ children,
134
+ title,
135
+ description,
136
+ iconAfter,
137
+ iconBefore,
138
+ overrides,
139
+ className,
140
+ shouldTitleWrap = false,
141
+ shouldDescriptionWrap = false,
142
+ isDisabled = false,
143
+ isSelected = false
144
+ }) => {
145
+ const renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
146
+ return jsx(ClassNames, null, ({
147
+ css: cn,
148
+ cx
149
+ }) => {
150
+ return jsx(FocusRing, {
151
+ isInset: true
152
+ }, children({
153
+ className: cx([cn([primitiveStyles, !isDisabled && !isSelected && unselectedStyles, !isDisabled && isSelected && selectedStyles, isDisabled ? disabledStyles : interactiveStyles]), className]),
154
+ children: jsx(Fragment, null, iconBefore && jsx("span", {
155
+ "data-item-elem-before": true,
156
+ css: beforeElementStyles
157
+ }, iconBefore), title && jsx("span", {
158
+ css: contentStyles
159
+ }, renderTitle('span', {
160
+ children: title,
161
+ className: cn(shouldTitleWrap ? wordBreakStyles : truncateStyles),
162
+ 'data-item-title': true
163
+ }), description && jsx("span", {
164
+ "data-item-description": true,
165
+ css: [descriptionStyles, shouldDescriptionWrap ? wordBreakStyles : truncateStyles]
166
+ }, description)), iconAfter && jsx("span", {
167
+ "data-item-elem-after": true,
168
+ css: afterElementStyles
169
+ }, iconAfter))
170
+ }));
171
+ });
172
+ };
173
+
174
+ export default MenuItemPrimitive;
@@ -3,14 +3,14 @@ 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 BaseItem from '../internal/components/base-item';
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 { buttonItemCSS } from '../internal/styles/menu-item/button-item';
9
9
 
10
10
  /**
11
11
  * __Button item__
12
12
  *
13
- * A button item is used to populate a menu with items that need to be a button element.
13
+ * A button item is used to populate a menu with items that are buttons.
14
14
  *
15
15
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/button-item)
16
16
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
@@ -19,7 +19,7 @@ const ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on
19
19
  (props, ref) => {
20
20
  const {
21
21
  children,
22
- cssFn = () => ({}),
22
+ cssFn = noop,
23
23
  description,
24
24
  iconAfter,
25
25
  iconBefore,
@@ -31,7 +31,7 @@ const ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on
31
31
  onMouseDown,
32
32
  shouldTitleWrap,
33
33
  shouldDescriptionWrap,
34
- ...others
34
+ ...rest
35
35
  } = props;
36
36
  const onMouseDownHandler = useBlurOnMouseDown(onMouseDown);
37
37
 
@@ -39,27 +39,34 @@ const ButtonItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef( // Type needed on
39
39
  return null;
40
40
  }
41
41
 
42
- return jsx("button", _extends({
43
- css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
44
- buttonItemCSS(isDisabled, isSelected), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
42
+ return jsx(MenuItemPrimitive, _extends({}, rest, {
43
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
44
+ overrides: overrides,
45
+ iconBefore: iconBefore,
46
+ iconAfter: iconAfter,
47
+ isDisabled: isDisabled,
48
+ isSelected: isSelected,
49
+ description: description,
50
+ title: children,
51
+ shouldTitleWrap: shouldTitleWrap,
52
+ shouldDescriptionWrap: shouldDescriptionWrap,
53
+ css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
45
54
  cssFn({
46
55
  isSelected,
47
56
  isDisabled
48
- })],
49
- type: "button",
50
- "data-testid": testId,
57
+ })
58
+ }), ({
59
+ children,
60
+ className
61
+ }) => jsx("button", _extends({
62
+ "data-testid": testId
63
+ }, rest, {
64
+ className: className,
65
+ ref: ref,
51
66
  disabled: isDisabled,
52
67
  onClick: onClick,
53
68
  onMouseDown: onMouseDownHandler,
54
- ref: ref
55
- }, others), jsx(BaseItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
56
- , {
57
- overrides: overrides,
58
- iconBefore: iconBefore,
59
- iconAfter: iconAfter,
60
- description: description,
61
- shouldTitleWrap: shouldTitleWrap,
62
- shouldDescriptionWrap: shouldDescriptionWrap
63
- }, children));
69
+ type: "button"
70
+ }), children));
64
71
  }));
65
72
  export default ButtonItem;