@atlaskit/menu 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/cjs/internal/components/menu-item-primitive.js +202 -0
  3. package/dist/cjs/menu-item/button-item.js +29 -24
  4. package/dist/cjs/menu-item/custom-item.js +29 -31
  5. package/dist/cjs/menu-item/heading-item.js +25 -7
  6. package/dist/cjs/menu-item/link-item.js +48 -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 +182 -0
  13. package/dist/es2019/menu-item/button-item.js +26 -20
  14. package/dist/es2019/menu-item/custom-item.js +30 -23
  15. package/dist/es2019/menu-item/heading-item.js +22 -6
  16. package/dist/es2019/menu-item/link-item.js +29 -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 +186 -0
  23. package/dist/esm/menu-item/button-item.js +29 -23
  24. package/dist/esm/menu-item/custom-item.js +31 -25
  25. package/dist/esm/menu-item/heading-item.js +22 -8
  26. package/dist/esm/menu-item/link-item.js +48 -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 +29 -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
@@ -1,8 +1,83 @@
1
1
  /** @jsx jsx */
2
- import { memo } from 'react';
3
- import { jsx } from '@emotion/core';
4
- import { skeletonItemCSS } from '../internal/styles/menu-item/skeleton-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 { borderRadius as borderRadiusFn, gridSize as gridSizeFn } from '@atlaskit/theme/constants';
6
+ import { token } from '@atlaskit/tokens';
7
+ var gridSize = gridSizeFn();
8
+ var borderRadius = borderRadiusFn();
9
+ var itemElemSpacing = gridSize * 1.5;
10
+ var itemExpectedElemSize = gridSize * 3;
11
+ var itemMinHeight = gridSize * 5;
12
+ var itemPadding = gridSize * 2.5;
13
+ var skeletonItemElemSize = gridSize * 2.5;
14
+ var itemElemSkeletonOffset = (itemExpectedElemSize - skeletonItemElemSize) / 2;
15
+ var skeletonTextBorderRadius = 100;
16
+ var skeletonContentHeight = 9;
17
+ var skeletonColor = token('color.background.subtleNeutral.resting', skeletonColorFn());
18
+ var skeletonStyles = css({
19
+ display: 'flex',
20
+ minHeight: itemMinHeight,
21
+ padding: "0 ".concat(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
+ var 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
+ var customWidthStyles = css({
56
+ '::after': {
57
+ flexBasis: 'var(--width)'
58
+ }
59
+ });
60
+ var 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
+ var avatarStyles = css({
72
+ '::before': {
73
+ borderRadius: '100%'
74
+ }
75
+ });
76
+ var iconStyles = css({
77
+ '::before': {
78
+ borderRadius: borderRadius
79
+ }
80
+ });
6
81
  /**
7
82
  * __Skeleton item__
8
83
  *
@@ -11,21 +86,22 @@ 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
- var SkeletonItem = /*#__PURE__*/memo(function (_ref) {
89
+
90
+ var SkeletonItem = function SkeletonItem(_ref) {
15
91
  var hasAvatar = _ref.hasAvatar,
16
92
  hasIcon = _ref.hasIcon,
17
- width = _ref.width,
18
93
  testId = _ref.testId,
19
- isShimmering = _ref.isShimmering,
94
+ width = _ref.width,
20
95
  _ref$cssFn = _ref.cssFn,
21
- cssFn = _ref$cssFn === void 0 ? function () {
22
- return {};
23
- } : _ref$cssFn;
96
+ cssFn = _ref$cssFn === void 0 ? noop : _ref$cssFn;
24
97
  return jsx("div", {
25
- css: [// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
26
- skeletonItemCSS(hasAvatar, hasIcon, width, isShimmering), // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
98
+ style: {
99
+ '--width': width
100
+ },
101
+ css: [skeletonStyles, (hasAvatar || hasIcon) && beforeElementStyles, hasAvatar && avatarStyles, hasIcon && iconStyles, width ? customWidthStyles : defaultWidthStyles, // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
27
102
  cssFn(undefined)],
28
103
  "data-testid": testId
29
104
  });
30
- });
105
+ };
106
+
31
107
  export default SkeletonItem;
@@ -2,9 +2,12 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
 
4
4
  /** @jsx jsx */
5
- import { jsx } from '@emotion/core';
6
- import { menuGroupCSS } from '../internal/styles/menu-section/menu-group';
7
-
5
+ import { css, jsx } from '@emotion/core';
6
+ var groupStyles = css({
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ overflow: 'auto'
10
+ });
8
11
  /**
9
12
  * __Menu group__
10
13
  *
@@ -13,6 +16,7 @@ import { menuGroupCSS } from '../internal/styles/menu-section/menu-group';
13
16
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/menu-group)
14
17
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
15
18
  */
19
+
16
20
  var MenuGroup = function MenuGroup(_ref) {
17
21
  var maxWidth = _ref.maxWidth,
18
22
  minWidth = _ref.minWidth,
@@ -22,13 +26,13 @@ var MenuGroup = function MenuGroup(_ref) {
22
26
  rest = _objectWithoutProperties(_ref, ["maxWidth", "minWidth", "minHeight", "maxHeight", "testId"]);
23
27
 
24
28
  return jsx("div", _extends({
25
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
26
- css: menuGroupCSS({
27
- maxHeight: maxHeight,
29
+ style: {
30
+ minWidth: minWidth,
28
31
  maxWidth: maxWidth,
29
32
  minHeight: minHeight,
30
- minWidth: minWidth
31
- }),
33
+ maxHeight: maxHeight
34
+ },
35
+ css: groupStyles,
32
36
  "data-testid": testId
33
37
  }, rest));
34
38
  };
@@ -2,11 +2,74 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
 
4
4
  /** @jsx jsx */
5
- import { forwardRef } from 'react';
6
- import { jsx } from '@emotion/core';
7
- import { sectionCSS } from '../internal/styles/menu-section/section';
5
+ import { forwardRef, Fragment } from 'react';
6
+ import { css, jsx } from '@emotion/core';
7
+ import { N30A } 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';
8
11
  import HeadingItem from '../menu-item/heading-item';
12
+ var gridSize = gridSizeFn();
13
+ var itemHeadingTopMargin = gridSize * 2.5;
14
+ var itemHeadingBottomMargin = gridSize * 0.75; // Skeleton content is slightly shorter than the real content.
15
+ // Because of that we slightly increase the top margin to offset this so the
16
+ // containing size both real and skeleton always equal approx 30px.
9
17
 
18
+ var itemHeadingContentHeight = headingSizes.h100.lineHeight;
19
+ var skeletonHeadingHeight = gridSize;
20
+ var skeletonHeadingMarginOffset = 3;
21
+ var skeletonHeadingTopMargin = itemHeadingTopMargin + (itemHeadingContentHeight - skeletonHeadingHeight) - skeletonHeadingMarginOffset; // We want to move the entire body up by 3px without affecting the height of the skeleton container.
22
+
23
+ var skeletonHeadingBottomMargin = itemHeadingBottomMargin + skeletonHeadingMarginOffset;
24
+ var sectionPaddingTopBottom = gridSize * 0.75;
25
+ var VAR_SEPARATOR_COLOR = '--ds-menu-seperator-color';
26
+ var sectionStyles = css({
27
+ '&::before, &::after': {
28
+ display: 'block',
29
+ height: sectionPaddingTopBottom,
30
+ content: '""'
31
+ },
32
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
33
+ '& [data-ds--menu--heading-item]': {
34
+ marginTop: itemHeadingTopMargin,
35
+ marginBottom: itemHeadingBottomMargin,
36
+ '&:first-of-type': {
37
+ marginTop: itemHeadingTopMargin - sectionPaddingTopBottom
38
+ }
39
+ },
40
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
41
+ '& [data-ds--menu--skeleton-heading-item]': {
42
+ marginTop: skeletonHeadingTopMargin,
43
+ marginBottom: skeletonHeadingBottomMargin,
44
+ '&:first-of-type': {
45
+ marginTop: skeletonHeadingTopMargin - sectionPaddingTopBottom
46
+ }
47
+ },
48
+ '&:focus': {
49
+ // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
50
+ // We have made a deliberate choice to leave this behaviour as is.
51
+ // This makes the outline go inside by 1px so it can actually be displayed
52
+ // else it gets cut off from the overflow: scroll from the parent menu group.
53
+ outlineOffset: -1
54
+ }
55
+ });
56
+ var scrollableStyles = css({
57
+ flexShrink: 1,
58
+ overflow: 'auto'
59
+ });
60
+ var unscrollableStyles = css({
61
+ flexShrink: 0
62
+ });
63
+ var separatorStyles = css({
64
+ borderTop: "2px solid var(".concat(VAR_SEPARATOR_COLOR, ", ").concat(token('color.border.neutral', N30A), ")")
65
+ });
66
+ var noSeparatorStyles = css({
67
+ // this is to ensure that adjacent sections without separators don't get additional margins.
68
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
69
+ '[data-section] + &': {
70
+ marginTop: -6
71
+ }
72
+ });
10
73
  /**
11
74
  * __Section__
12
75
  *
@@ -15,46 +78,33 @@ import HeadingItem from '../menu-item/heading-item';
15
78
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/section)
16
79
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
17
80
  */
18
- var Section = /*#__PURE__*/forwardRef( // Type needed on props to extract types with extract react types.
19
- function (_ref, ref) {
81
+
82
+ var Section = /*#__PURE__*/forwardRef(function (_ref, ref) {
20
83
  var children = _ref.children,
21
84
  overrides = _ref.overrides,
22
85
  title = _ref.title,
23
86
  testId = _ref.testId,
24
- rest = _objectWithoutProperties(_ref, ["children", "overrides", "title", "testId"]);
87
+ isScrollable = _ref.isScrollable,
88
+ hasSeparator = _ref.hasSeparator,
89
+ id = _ref.id,
90
+ rest = _objectWithoutProperties(_ref, ["children", "overrides", "title", "testId", "isScrollable", "hasSeparator", "id"]);
25
91
 
26
- return title !== undefined ? jsx(SectionBase, _extends({}, rest, {
27
- testId: testId,
28
- ref: ref,
29
- "aria-label": title
30
- }), jsx(HeadingItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
92
+ var childrenMarkup = title !== undefined ? jsx(Fragment, null, jsx(HeadingItem // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides
31
93
  , {
32
94
  cssFn: overrides && overrides.HeadingItem && overrides.HeadingItem.cssFn,
33
95
  testId: testId && "".concat(testId, "--heading"),
34
96
  "aria-hidden": true
35
- }, title), children) : jsx(SectionBase, _extends({}, rest, {
36
- ref: ref
37
- }), children);
38
- });
39
- var SectionBase = /*#__PURE__*/forwardRef( // Type needed on props to extract types with extract react types.
40
- function (_ref2, ref) {
41
- var isScrollable = _ref2.isScrollable,
42
- hasSeparator = _ref2.hasSeparator,
43
- testId = _ref2.testId,
44
- rest = _objectWithoutProperties(_ref2, ["isScrollable", "hasSeparator", "testId"]);
45
-
46
- return jsx("div", _extends({
47
- // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
97
+ }, title), children) : children;
98
+ return jsx("div", _extends({}, rest, {
99
+ id: id // NOTE: Firefox allows elements that have "overflow: auto" to gain focus (as if it had tab-index="0")
48
100
  // We have made a deliberate choice to leave this behaviour as is.
49
- // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
50
- css: sectionCSS(isScrollable, hasSeparator),
51
- "data-testid": testId,
52
- role: "group" // this is being used to target CSS selectors
53
- // where emotion's API was falling a little short.
54
101
  ,
55
- "data-section": true
56
- }, rest, {
102
+ css: [sectionStyles, isScrollable ? scrollableStyles : unscrollableStyles, hasSeparator ? separatorStyles : noSeparatorStyles],
103
+ "aria-label": title,
104
+ "data-testid": testId,
105
+ role: "group",
106
+ "data-section": true,
57
107
  ref: ref
58
- }));
108
+ }), childrenMarkup);
59
109
  });
60
110
  export default Section;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/menu",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "sideEffects": false
5
5
  }
@@ -7,4 +7,4 @@ export { default as SkeletonHeadingItem } from './menu-item/skeleton-heading-ite
7
7
  export { default as Section } from './menu-section/section';
8
8
  export { default as MenuGroup } from './menu-section/menu-group';
9
9
  export { default as PopupMenuGroup } from './menu-section/popup-menu-group';
10
- export type { ButtonItemProps, CSSFn, StatelessCSSFn, CustomItemComponentProps, CustomItemProps, HeadingItemProps, ItemState, LinkItemProps, MenuGroupProps, SectionProps, SkeletonHeadingItemProps, SkeletonItemProps, Dimension, BaseItemProps, Overrides, MenuGroupSizing, RenderFunction, SectionBaseProps, TitleOverrides, } from './types';
10
+ export type { ButtonItemProps, CSSFn, StatelessCSSFn, CustomItemComponentProps, CustomItemProps, HeadingItemProps, ItemState, LinkItemProps, MenuGroupProps, SectionProps, SkeletonHeadingItemProps, SkeletonItemProps, Dimension, MenuItemProps as BaseItemProps, Overrides, MenuGroupSizing, RenderFunction, SectionProps as SectionBaseProps, TitleOverrides, } from './types';
@@ -0,0 +1,17 @@
1
+ import type { MenuItemPrimitiveProps } from '../../types';
2
+ /**
3
+ * __Menu item primitive__
4
+ *
5
+ * Menu item primitive contains all the styles for menu items,
6
+ * including support for selected, disabled, and interaction states.
7
+ *
8
+ * Using children as function prop you wire up this to your own host element.
9
+ *
10
+ * ```jsx
11
+ * <MenuItemPrimitive>
12
+ * {({ children, ...props }) => <button {...props}>{children}</button>}
13
+ * </MenuItemPrimitive>
14
+ * ```
15
+ */
16
+ declare const MenuItemPrimitive: ({ children, title, description, iconAfter, iconBefore, overrides, testId, className, shouldTitleWrap, shouldDescriptionWrap, isDisabled, isSelected, }: MenuItemPrimitiveProps) => JSX.Element;
17
+ export default MenuItemPrimitive;
@@ -3,7 +3,7 @@ import type { ButtonItemProps } from '../types';
3
3
  /**
4
4
  * __Button item__
5
5
  *
6
- * A button item is used to populate a menu with items that need to be a button element.
6
+ * A button item is used to populate a menu with items that are buttons.
7
7
  *
8
8
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/button-item)
9
9
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
@@ -1,3 +1,4 @@
1
+ /** @jsx jsx */
1
2
  import type { CustomItemComponentProps, CustomItemProps } from '../types';
2
3
  interface CustomItemTypeGenericHackProps {
3
4
  <TComponentProps>(props: CustomItemProps<TComponentProps> & {
@@ -7,7 +8,7 @@ interface CustomItemTypeGenericHackProps {
7
8
  /**
8
9
  * __Custom item__
9
10
  *
10
- * A custom item is used to populate a menu with items that need to be a custom element.
11
+ * A custom item is used to populate a menu with items that can be any element.
11
12
  *
12
13
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/custom-item)
13
14
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SkeletonHeadingItemProps } from '../types';
3
2
  /**
4
3
  * __Skeleton heading item__
@@ -8,5 +7,5 @@ import type { SkeletonHeadingItemProps } from '../types';
8
7
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-heading-item)
9
8
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
10
9
  */
11
- declare const SkeletonHeadingItem: import("react").MemoExoticComponent<({ width, testId, isShimmering, cssFn, }: SkeletonHeadingItemProps) => JSX.Element>;
10
+ declare const SkeletonHeadingItem: ({ testId, width, cssFn, }: SkeletonHeadingItemProps) => JSX.Element;
12
11
  export default SkeletonHeadingItem;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { SkeletonItemProps } from '../types';
3
2
  /**
4
3
  * __Skeleton item__
@@ -8,5 +7,5 @@ import type { SkeletonItemProps } from '../types';
8
7
  * - [Examples](https://atlaskit.atlassian.com/packages/design-system/menu/docs/skeleton-item)
9
8
  * - [Code](https://atlaskit.atlassian.com/packages/design-system/menu)
10
9
  */
11
- declare const SkeletonItem: import("react").MemoExoticComponent<({ hasAvatar, hasIcon, width, testId, isShimmering, cssFn, }: SkeletonItemProps) => JSX.Element>;
10
+ declare const SkeletonItem: ({ hasAvatar, hasIcon, testId, width, cssFn, }: SkeletonItemProps) => JSX.Element;
12
11
  export default SkeletonItem;
@@ -52,7 +52,11 @@ export interface MenuGroupProps extends MenuGroupSizing {
52
52
  */
53
53
  onClick?: (event: React.MouseEvent | React.KeyboardEvent) => void;
54
54
  }
55
- export interface SectionBaseProps {
55
+ export interface SectionProps {
56
+ /**
57
+ * Unique identifier for the element.
58
+ */
59
+ id?: string;
56
60
  /**
57
61
  * Enables scrolling within the section.
58
62
  * Make sure to set `maxHeight` on the parent `MenuGroup` component else it will not work.
@@ -74,8 +78,6 @@ export interface SectionBaseProps {
74
78
  * serving as a hook for automated tests.
75
79
  */
76
80
  testId?: string;
77
- }
78
- export interface SectionProps extends SectionBaseProps {
79
81
  overrides?: {
80
82
  HeadingItem?: {
81
83
  /**
@@ -91,7 +93,25 @@ export interface SectionProps extends SectionBaseProps {
91
93
  */
92
94
  title?: string;
93
95
  }
94
- export interface BaseItemProps {
96
+ export interface MenuItemPrimitiveProps {
97
+ children: (props: {
98
+ className: string;
99
+ 'data-testid': string | undefined;
100
+ children: React.ReactNode;
101
+ }) => JSX.Element;
102
+ title: React.ReactNode | undefined;
103
+ description: React.ReactNode | undefined;
104
+ iconAfter: React.ReactNode | undefined;
105
+ iconBefore: React.ReactNode | undefined;
106
+ overrides: Overrides | undefined;
107
+ shouldTitleWrap: boolean | undefined;
108
+ shouldDescriptionWrap: boolean | undefined;
109
+ isDisabled: boolean | undefined;
110
+ isSelected: boolean | undefined;
111
+ className?: string;
112
+ testId?: string;
113
+ }
114
+ export interface MenuItemProps {
95
115
  /**
96
116
  * A function that can be used to override the styles of the component.
97
117
  * It receives the current styles and state and expects a styles object.
@@ -151,7 +171,7 @@ export interface BaseItemProps {
151
171
  */
152
172
  shouldDescriptionWrap?: boolean;
153
173
  }
154
- export interface ButtonItemProps extends BaseItemProps {
174
+ export interface ButtonItemProps extends MenuItemProps {
155
175
  /**
156
176
  * Unique identifier for the element.
157
177
  */
@@ -161,7 +181,7 @@ export interface ButtonItemProps extends BaseItemProps {
161
181
  */
162
182
  role?: string;
163
183
  }
164
- export interface LinkItemProps extends BaseItemProps {
184
+ export interface LinkItemProps extends MenuItemProps {
165
185
  /**
166
186
  * Link to another page.
167
187
  */
@@ -226,7 +246,7 @@ export interface CustomItemComponentProps {
226
246
  */
227
247
  disabled?: boolean;
228
248
  }
229
- export interface CustomItemProps<TCustomComponentProps = CustomItemComponentProps> extends BaseItemProps {
249
+ export interface CustomItemProps<TCustomComponentProps = CustomItemComponentProps> extends MenuItemProps {
230
250
  /**
231
251
  * Custom component to render as an item.
232
252
  * This can be both a functional component or a class component.
@@ -250,6 +270,7 @@ export interface SkeletonItemProps {
250
270
  */
251
271
  hasIcon?: boolean;
252
272
  /**
273
+ *
253
274
  * Width of the skeleton item.
254
275
  * Generally you don't need to specify this as it has a staggered width based on `:nth-child` by default.
255
276
  */
@@ -295,6 +316,7 @@ export interface HeadingItemProps {
295
316
  }
296
317
  export interface SkeletonHeadingItemProps {
297
318
  /**
319
+ *
298
320
  * Width of the skeleton heading item.
299
321
  * Generally you don't need to specify this as it has a staggered width based on `:nth-child` by default.
300
322
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/menu",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "A collection of composable menu components that can be used anywhere.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,8 +36,10 @@
36
36
  ".": "./src/index.tsx"
37
37
  },
38
38
  "dependencies": {
39
+ "@atlaskit/ds-lib": "^1.2.0",
40
+ "@atlaskit/focus-ring": "^0.2.4",
39
41
  "@atlaskit/theme": "^12.0.0",
40
- "@atlaskit/tokens": "^0.2.0",
42
+ "@atlaskit/tokens": "^0.3.0",
41
43
  "@babel/runtime": "^7.0.0",
42
44
  "@emotion/core": "^10.0.9"
43
45
  },
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = require("react");
9
-
10
- var _core = require("@emotion/core");
11
-
12
- var _baseItem = require("../styles/menu-item/base-item");
13
-
14
- /** @jsx jsx */
15
- var defaultRender = function defaultRender(Component, props) {
16
- return (0, _core.jsx)(Component, props);
17
- };
18
- /**
19
- * __Base item__
20
- *
21
- * A base item should be composed for all item experiences.
22
- */
23
-
24
-
25
- var BaseItem = /*#__PURE__*/(0, _react.memo)(function (_ref) {
26
- var children = _ref.children,
27
- description = _ref.description,
28
- iconAfter = _ref.iconAfter,
29
- iconBefore = _ref.iconBefore,
30
- overrides = _ref.overrides,
31
- _ref$shouldTitleWrap = _ref.shouldTitleWrap,
32
- shouldTitleWrap = _ref$shouldTitleWrap === void 0 ? false : _ref$shouldTitleWrap,
33
- _ref$shouldDescriptio = _ref.shouldDescriptionWrap,
34
- shouldDescriptionWrap = _ref$shouldDescriptio === void 0 ? false : _ref$shouldDescriptio;
35
- var renderTitle = overrides && overrides.Title && overrides.Title.render || defaultRender;
36
- return (// eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
37
- (0, _core.jsx)("div", {
38
- css: _baseItem.contentCSSWrapper
39
- }, iconBefore && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
40
- (0, _core.jsx)("span", {
41
- "data-item-elem-before": true,
42
- css: _baseItem.elemBeforeCSS
43
- }, iconBefore), children && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
44
- (0, _core.jsx)("span", {
45
- css: _baseItem.contentCSS
46
- }, (0, _core.jsx)(_core.ClassNames, null, function (_ref2) {
47
- var css = _ref2.css;
48
- return renderTitle('span', {
49
- children: children,
50
- className: css(shouldTitleWrap ? _baseItem.wrapTextCSS : _baseItem.truncateCSS),
51
- 'data-item-title': true
52
- });
53
- }), description && (0, _core.jsx)("span", {
54
- "data-item-description": true,
55
- css: // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
56
- shouldDescriptionWrap ? _baseItem.wrapDescriptionCSS : _baseItem.descriptionCSS
57
- }, description)), iconAfter && // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
58
- (0, _core.jsx)("span", {
59
- "data-item-elem-after": true,
60
- css: _baseItem.elemAfterCSS
61
- }, iconAfter))
62
- );
63
- });
64
- var _default = BaseItem;
65
- exports.default = _default;