@atlaskit/dropdown-menu 11.1.5 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 11.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`9a186cda60b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9a186cda60b) - Adds `component` prop to DropdownItem which allows overriding the item with a custom component.
8
+
9
+ ### Patch Changes
10
+
11
+ - [`484bf3e9b12`](https://bitbucket.org/atlassian/atlassian-frontend/commits/484bf3e9b12) - [ux] DSP-4539 Update wrongly used tokens for radio/checkbox icons
12
+ - Updated dependencies
13
+
3
14
  ## 11.1.5
4
15
 
5
16
  ### Patch Changes
@@ -15,11 +15,13 @@ var _react = _interopRequireDefault(require("react"));
15
15
 
16
16
  var _buttonItem = _interopRequireDefault(require("@atlaskit/menu/button-item"));
17
17
 
18
+ var _customItem = _interopRequireDefault(require("@atlaskit/menu/custom-item"));
19
+
18
20
  var _linkItem = _interopRequireDefault(require("@atlaskit/menu/link-item"));
19
21
 
20
22
  var _useRegisterItemWithFocusManager = _interopRequireDefault(require("./internal/hooks/use-register-item-with-focus-manager"));
21
23
 
22
- var _excluded = ["elemBefore", "elemAfter", "href", "shouldTitleWrap", "shouldDescriptionWrap"];
24
+ var _excluded = ["component", "elemBefore", "elemAfter", "shouldTitleWrap", "shouldDescriptionWrap"];
23
25
 
24
26
  /**
25
27
  * __Dropdown menu item__
@@ -31,9 +33,9 @@ var _excluded = ["elemBefore", "elemAfter", "href", "shouldTitleWrap", "shouldDe
31
33
  * - [Usage](https://atlassian.design/components/dropdown-item/usage)
32
34
  */
33
35
  var DropdownMenuItem = function DropdownMenuItem(props) {
34
- var elemBefore = props.elemBefore,
36
+ var component = props.component,
37
+ elemBefore = props.elemBefore,
35
38
  elemAfter = props.elemAfter,
36
- href = props.href,
37
39
  _props$shouldTitleWra = props.shouldTitleWrap,
38
40
  shouldTitleWrap = _props$shouldTitleWra === void 0 ? true : _props$shouldTitleWra,
39
41
  _props$shouldDescript = props.shouldDescriptionWrap,
@@ -41,9 +43,17 @@ var DropdownMenuItem = function DropdownMenuItem(props) {
41
43
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
42
44
  var itemRef = (0, _useRegisterItemWithFocusManager.default)();
43
45
 
44
- if (href) {
46
+ if (component) {
47
+ return /*#__PURE__*/_react.default.createElement(_customItem.default, (0, _extends2.default)({
48
+ component: component,
49
+ iconBefore: elemBefore,
50
+ iconAfter: elemAfter,
51
+ shouldTitleWrap: shouldTitleWrap,
52
+ shouldDescriptionWrap: shouldDescriptionWrap
53
+ }, rest));
54
+ } else if (props.href) {
45
55
  return /*#__PURE__*/_react.default.createElement(_linkItem.default, (0, _extends2.default)({
46
- href: href,
56
+ href: props.href,
47
57
  iconBefore: elemBefore,
48
58
  iconAfter: elemAfter,
49
59
  role: "menuitem",
@@ -11,12 +11,12 @@ var getIconColors = function getIconColors(isSelected) {
11
11
  if (isSelected) {
12
12
  return {
13
13
  primary: "var(--ds-background-brand-bold, ".concat(_colors.B400, ")"),
14
- secondary: "var(--ds-surface, ".concat(_colors.N40, ")")
14
+ secondary: "var(--ds-icon-inverse, ".concat(_colors.N40, ")")
15
15
  };
16
16
  }
17
17
 
18
18
  return {
19
- primary: "var(--ds-border, ".concat(_colors.N40, ")"),
19
+ primary: "var(--ds-background-neutral, ".concat(_colors.N40, ")"),
20
20
  secondary: "var(--ds-UNSAFE_util-transparent, ".concat(_colors.N40, ")")
21
21
  };
22
22
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.1.5",
3
+ "version": "11.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React from 'react';
3
3
  import ButtonItem from '@atlaskit/menu/button-item';
4
+ import CustomItem from '@atlaskit/menu/custom-item';
4
5
  import LinkItem from '@atlaskit/menu/link-item';
5
6
  import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-with-focus-manager';
6
7
 
@@ -15,18 +16,26 @@ import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-
15
16
  */
16
17
  const DropdownMenuItem = props => {
17
18
  const {
19
+ component,
18
20
  elemBefore,
19
21
  elemAfter,
20
- href,
21
22
  shouldTitleWrap = true,
22
23
  shouldDescriptionWrap = true,
23
24
  ...rest
24
25
  } = props;
25
26
  const itemRef = useRegisterItemWithFocusManager();
26
27
 
27
- if (href) {
28
+ if (component) {
29
+ return /*#__PURE__*/React.createElement(CustomItem, _extends({
30
+ component: component,
31
+ iconBefore: elemBefore,
32
+ iconAfter: elemAfter,
33
+ shouldTitleWrap: shouldTitleWrap,
34
+ shouldDescriptionWrap: shouldDescriptionWrap
35
+ }, rest));
36
+ } else if (props.href) {
28
37
  return /*#__PURE__*/React.createElement(LinkItem, _extends({
29
- href: href,
38
+ href: props.href,
30
39
  iconBefore: elemBefore,
31
40
  iconAfter: elemAfter,
32
41
  role: "menuitem",
@@ -4,12 +4,12 @@ const getIconColors = isSelected => {
4
4
  if (isSelected) {
5
5
  return {
6
6
  primary: `var(--ds-background-brand-bold, ${B400})`,
7
- secondary: `var(--ds-surface, ${N40})`
7
+ secondary: `var(--ds-icon-inverse, ${N40})`
8
8
  };
9
9
  }
10
10
 
11
11
  return {
12
- primary: `var(--ds-border, ${N40})`,
12
+ primary: `var(--ds-background-neutral, ${N40})`,
13
13
  secondary: `var(--ds-UNSAFE_util-transparent, ${N40})`
14
14
  };
15
15
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.1.5",
3
+ "version": "11.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["elemBefore", "elemAfter", "href", "shouldTitleWrap", "shouldDescriptionWrap"];
3
+ var _excluded = ["component", "elemBefore", "elemAfter", "shouldTitleWrap", "shouldDescriptionWrap"];
4
4
  import React from 'react';
5
5
  import ButtonItem from '@atlaskit/menu/button-item';
6
+ import CustomItem from '@atlaskit/menu/custom-item';
6
7
  import LinkItem from '@atlaskit/menu/link-item';
7
8
  import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-with-focus-manager';
8
9
 
@@ -16,9 +17,9 @@ import useRegisterItemWithFocusManager from './internal/hooks/use-register-item-
16
17
  * - [Usage](https://atlassian.design/components/dropdown-item/usage)
17
18
  */
18
19
  var DropdownMenuItem = function DropdownMenuItem(props) {
19
- var elemBefore = props.elemBefore,
20
+ var component = props.component,
21
+ elemBefore = props.elemBefore,
20
22
  elemAfter = props.elemAfter,
21
- href = props.href,
22
23
  _props$shouldTitleWra = props.shouldTitleWrap,
23
24
  shouldTitleWrap = _props$shouldTitleWra === void 0 ? true : _props$shouldTitleWra,
24
25
  _props$shouldDescript = props.shouldDescriptionWrap,
@@ -27,9 +28,17 @@ var DropdownMenuItem = function DropdownMenuItem(props) {
27
28
 
28
29
  var itemRef = useRegisterItemWithFocusManager();
29
30
 
30
- if (href) {
31
+ if (component) {
32
+ return /*#__PURE__*/React.createElement(CustomItem, _extends({
33
+ component: component,
34
+ iconBefore: elemBefore,
35
+ iconAfter: elemAfter,
36
+ shouldTitleWrap: shouldTitleWrap,
37
+ shouldDescriptionWrap: shouldDescriptionWrap
38
+ }, rest));
39
+ } else if (props.href) {
31
40
  return /*#__PURE__*/React.createElement(LinkItem, _extends({
32
- href: href,
41
+ href: props.href,
33
42
  iconBefore: elemBefore,
34
43
  iconAfter: elemAfter,
35
44
  role: "menuitem",
@@ -4,12 +4,12 @@ var getIconColors = function getIconColors(isSelected) {
4
4
  if (isSelected) {
5
5
  return {
6
6
  primary: "var(--ds-background-brand-bold, ".concat(B400, ")"),
7
- secondary: "var(--ds-surface, ".concat(N40, ")")
7
+ secondary: "var(--ds-icon-inverse, ".concat(N40, ")")
8
8
  };
9
9
  }
10
10
 
11
11
  return {
12
- primary: "var(--ds-border, ".concat(N40, ")"),
12
+ primary: "var(--ds-background-neutral, ".concat(N40, ")"),
13
13
  secondary: "var(--ds-UNSAFE_util-transparent, ".concat(N40, ")")
14
14
  };
15
15
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.1.5",
3
+ "version": "11.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
1
  declare const getIconColors: (isSelected: boolean | undefined) => {
2
2
  primary: "var(--ds-background-brand-bold)";
3
- secondary: "var(--ds-surface)";
3
+ secondary: "var(--ds-icon-inverse)";
4
4
  } | {
5
- primary: "var(--ds-border)";
5
+ primary: "var(--ds-background-neutral)";
6
6
  secondary: "var(--ds-UNSAFE_util-transparent)";
7
7
  };
8
8
  export default getIconColors;
@@ -1,5 +1,5 @@
1
1
  import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from 'react';
2
- import type { MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
2
+ import type { CustomItemProps, MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
3
3
  import type { ContentProps, TriggerProps } from '@atlaskit/popup/types';
4
4
  export declare type FocusableElement = HTMLAnchorElement | HTMLButtonElement;
5
5
  export declare type Action = 'next' | 'prev' | 'first' | 'last';
@@ -125,6 +125,10 @@ export interface DropdownItemProps {
125
125
  * Primary content for the item.
126
126
  */
127
127
  children: React.ReactNode;
128
+ /**
129
+ * Custom component to render as an item.
130
+ */
131
+ component?: CustomItemProps['component'];
128
132
  /**
129
133
  * Description of the item.
130
134
  * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.1.5",
3
+ "version": "11.2.0",
4
4
  "description": "A dropdown menu displays a list of actions or options to a user.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },
8
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
8
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
9
9
  "author": "Atlassian Pty Ltd",
10
10
  "license": "Apache-2.0",
11
11
  "main": "dist/cjs/index.js",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@atlaskit/button": "^16.3.0",
26
- "@atlaskit/codemod-utils": "^4.0.0",
26
+ "@atlaskit/codemod-utils": "^4.1.0",
27
27
  "@atlaskit/ds-lib": "^1.4.0",
28
28
  "@atlaskit/icon": "^21.10.0",
29
29
  "@atlaskit/menu": "^1.3.0",
@@ -40,7 +40,7 @@
40
40
  "react-dom": "^16.8.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@atlaskit/avatar": "^20.5.0",
43
+ "@atlaskit/avatar": "^21.0.0",
44
44
  "@atlaskit/docs": "*",
45
45
  "@atlaskit/lozenge": "11.1.11",
46
46
  "@atlaskit/modal-dialog": "^12.2.0",