@atlaskit/menu 2.12.5 → 2.12.7

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,19 @@
1
1
  # @atlaskit/menu
2
2
 
3
+ ## 2.12.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 2.12.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [#148720](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/148720)
14
+ [`fcf151627c8de`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fcf151627c8de) -
15
+ Added interactionName to components in menu and dropdownmenu
16
+
3
17
  ## 2.12.5
4
18
 
5
19
  ### Patch Changes
@@ -11,8 +11,10 @@ var _react = require("react");
11
11
  var _react2 = require("@emotion/react");
12
12
  var _deprecationWarning = require("@atlaskit/ds-lib/deprecation-warning");
13
13
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
14
+ var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
16
  var _menuItemPrimitive = _interopRequireDefault(require("../internal/components/menu-item-primitive"));
15
- var _excluded = ["component", "cssFn", "isDisabled", "isSelected", "onClick", "testId", "children", "description", "iconAfter", "iconBefore", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_isDraggable"];
17
+ var _excluded = ["component", "cssFn", "isDisabled", "isSelected", "onClick", "testId", "children", "description", "iconAfter", "iconBefore", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_isDraggable", "interactionName"];
16
18
  /**
17
19
  * @jsxRuntime classic
18
20
  * @jsx jsx
@@ -52,8 +54,14 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
52
54
  shouldDescriptionWrap = _ref.shouldDescriptionWrap,
53
55
  UNSAFE_className = _ref.className,
54
56
  UNSAFE_isDraggable = _ref.UNSAFE_isDraggable,
57
+ interactionName = _ref.interactionName,
55
58
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
56
59
  var onMouseDownHandler = onMouseDown;
60
+ var interactionContext = (0, _react.useContext)(_interactionContext.default);
61
+ var handleClick = (0, _react.useCallback)(function (e) {
62
+ interactionContext === null || interactionContext === void 0 || interactionContext.tracePress(interactionName, e.timeStamp);
63
+ onClick === null || onClick === void 0 || onClick(e);
64
+ }, [onClick, interactionContext, interactionName]);
57
65
  if (!Component) {
58
66
  return null;
59
67
  }
@@ -97,7 +105,7 @@ var CustomItem = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardR
97
105
  onDragStart: preventEvent
98
106
  }, {
99
107
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
100
- onClick: isDisabled ? preventEvent : onClick,
108
+ onClick: isDisabled ? preventEvent : (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
101
109
  tabIndex: isDisabled ? -1 : undefined,
102
110
  "aria-disabled": isDisabled
103
111
  }), children);
@@ -12,8 +12,10 @@ var _react2 = require("@emotion/react");
12
12
  var _appProvider = require("@atlaskit/app-provider");
13
13
  var _deprecationWarning = require("@atlaskit/ds-lib/deprecation-warning");
14
14
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
15
+ var _interactionContext = _interopRequireDefault(require("@atlaskit/interaction-context"));
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
17
  var _menuItemPrimitive = _interopRequireDefault(require("../internal/components/menu-item-primitive"));
16
- var _excluded = ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_shouldDisableRouterLink", "UNSAFE_isDraggable"];
18
+ var _excluded = ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_shouldDisableRouterLink", "UNSAFE_isDraggable", "interactionName"];
17
19
  /**
18
20
  * @jsxRuntime classic
19
21
  * @jsx jsx
@@ -56,9 +58,15 @@ function (props, ref) {
56
58
  UNSAFE_className = props.className,
57
59
  UNSAFE_shouldDisableRouterLink = props.UNSAFE_shouldDisableRouterLink,
58
60
  UNSAFE_isDraggable = props.UNSAFE_isDraggable,
61
+ interactionName = props.interactionName,
59
62
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
60
63
  var onMouseDownHandler = onMouseDown;
61
64
  var RouterLink = (0, _appProvider.useRouterLink)();
65
+ var interactionContext = (0, _react.useContext)(_interactionContext.default);
66
+ var handleClick = (0, _react.useCallback)(function (e) {
67
+ interactionContext === null || interactionContext === void 0 || interactionContext.tracePress(interactionName, e.timeStamp);
68
+ onClick === null || onClick === void 0 || onClick(e);
69
+ }, [onClick, interactionContext, interactionName]);
62
70
  if (!children) {
63
71
  return null;
64
72
  }
@@ -117,7 +125,7 @@ function (props, ref) {
117
125
  onDragStart: preventEvent
118
126
  }, {
119
127
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
120
- onClick: isDisabled ? preventEvent : onClick,
128
+ onClick: isDisabled ? preventEvent : (0, _platformFeatureFlags.fg)('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
121
129
  "aria-current": isSelected ? 'page' : undefined,
122
130
  "aria-disabled": isDisabled,
123
131
  ref: ref
@@ -4,12 +4,14 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
 
7
- import { forwardRef, memo } from 'react';
7
+ import { forwardRef, memo, useCallback, useContext } from 'react';
8
8
 
9
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
10
10
  import { css, jsx } from '@emotion/react';
11
11
  import { propDeprecationWarning } from '@atlaskit/ds-lib/deprecation-warning';
12
12
  import noop from '@atlaskit/ds-lib/noop';
13
+ import InteractionContext from '@atlaskit/interaction-context';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
13
15
  import MenuItemPrimitive from '../internal/components/menu-item-primitive';
14
16
  const preventEvent = e => {
15
17
  e.preventDefault();
@@ -46,9 +48,15 @@ const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
46
48
  // @ts-expect-error
47
49
  className: UNSAFE_className,
48
50
  UNSAFE_isDraggable,
51
+ interactionName,
49
52
  ...rest
50
53
  }, ref) => {
51
54
  const onMouseDownHandler = onMouseDown;
55
+ const interactionContext = useContext(InteractionContext);
56
+ const handleClick = useCallback(e => {
57
+ interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.tracePress(interactionName, e.timeStamp);
58
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
59
+ }, [onClick, interactionContext, interactionName]);
52
60
  if (!Component) {
53
61
  return null;
54
62
  }
@@ -92,7 +100,7 @@ const CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
92
100
  onDragStart: preventEvent
93
101
  }, {
94
102
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
95
- onClick: isDisabled ? preventEvent : onClick,
103
+ onClick: isDisabled ? preventEvent : fg('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
96
104
  tabIndex: isDisabled ? -1 : undefined,
97
105
  "aria-disabled": isDisabled
98
106
  }), children));
@@ -3,13 +3,15 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  * @jsxRuntime classic
4
4
  * @jsx jsx
5
5
  */
6
- import { forwardRef, memo } from 'react';
6
+ import { forwardRef, memo, useCallback, useContext } from 'react';
7
7
 
8
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
9
  import { jsx } from '@emotion/react';
10
10
  import { useRouterLink } from '@atlaskit/app-provider';
11
11
  import { propDeprecationWarning } from '@atlaskit/ds-lib/deprecation-warning';
12
12
  import noop from '@atlaskit/ds-lib/noop';
13
+ import InteractionContext from '@atlaskit/interaction-context';
14
+ import { fg } from '@atlaskit/platform-feature-flags';
13
15
  import MenuItemPrimitive from '../internal/components/menu-item-primitive';
14
16
  const IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
15
17
  const IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
@@ -50,10 +52,16 @@ const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
50
52
  className: UNSAFE_className,
51
53
  UNSAFE_shouldDisableRouterLink,
52
54
  UNSAFE_isDraggable,
55
+ interactionName,
53
56
  ...rest
54
57
  } = props;
55
58
  const onMouseDownHandler = onMouseDown;
56
59
  const RouterLink = useRouterLink();
60
+ const interactionContext = useContext(InteractionContext);
61
+ const handleClick = useCallback(e => {
62
+ interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.tracePress(interactionName, e.timeStamp);
63
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
64
+ }, [onClick, interactionContext, interactionName]);
57
65
  if (!children) {
58
66
  return null;
59
67
  }
@@ -112,7 +120,7 @@ const LinkItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(
112
120
  onDragStart: preventEvent
113
121
  }, {
114
122
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
115
- onClick: isDisabled ? preventEvent : onClick,
123
+ onClick: isDisabled ? preventEvent : fg('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
116
124
  "aria-current": isSelected ? 'page' : undefined,
117
125
  "aria-disabled": isDisabled,
118
126
  ref: ref
@@ -1,17 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["component", "cssFn", "isDisabled", "isSelected", "onClick", "testId", "children", "description", "iconAfter", "iconBefore", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_isDraggable"];
3
+ var _excluded = ["component", "cssFn", "isDisabled", "isSelected", "onClick", "testId", "children", "description", "iconAfter", "iconBefore", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_isDraggable", "interactionName"];
4
4
  /**
5
5
  * @jsxRuntime classic
6
6
  * @jsx jsx
7
7
  */
8
8
 
9
- import { forwardRef, memo } from 'react';
9
+ import { forwardRef, memo, useCallback, useContext } from 'react';
10
10
 
11
11
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
12
12
  import { css, jsx } from '@emotion/react';
13
13
  import { propDeprecationWarning } from '@atlaskit/ds-lib/deprecation-warning';
14
14
  import noop from '@atlaskit/ds-lib/noop';
15
+ import InteractionContext from '@atlaskit/interaction-context';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
15
17
  import MenuItemPrimitive from '../internal/components/menu-item-primitive';
16
18
  var preventEvent = function preventEvent(e) {
17
19
  e.preventDefault();
@@ -47,8 +49,14 @@ var CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref)
47
49
  shouldDescriptionWrap = _ref.shouldDescriptionWrap,
48
50
  UNSAFE_className = _ref.className,
49
51
  UNSAFE_isDraggable = _ref.UNSAFE_isDraggable,
52
+ interactionName = _ref.interactionName,
50
53
  rest = _objectWithoutProperties(_ref, _excluded);
51
54
  var onMouseDownHandler = onMouseDown;
55
+ var interactionContext = useContext(InteractionContext);
56
+ var handleClick = useCallback(function (e) {
57
+ interactionContext === null || interactionContext === void 0 || interactionContext.tracePress(interactionName, e.timeStamp);
58
+ onClick === null || onClick === void 0 || onClick(e);
59
+ }, [onClick, interactionContext, interactionName]);
52
60
  if (!Component) {
53
61
  return null;
54
62
  }
@@ -92,7 +100,7 @@ var CustomItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref)
92
100
  onDragStart: preventEvent
93
101
  }, {
94
102
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
95
- onClick: isDisabled ? preventEvent : onClick,
103
+ onClick: isDisabled ? preventEvent : fg('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
96
104
  tabIndex: isDisabled ? -1 : undefined,
97
105
  "aria-disabled": isDisabled
98
106
  }), children);
@@ -1,17 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_shouldDisableRouterLink", "UNSAFE_isDraggable"];
3
+ var _excluded = ["children", "href", "cssFn", "description", "iconAfter", "iconBefore", "isDisabled", "isSelected", "onClick", "testId", "overrides", "onMouseDown", "shouldTitleWrap", "shouldDescriptionWrap", "className", "UNSAFE_shouldDisableRouterLink", "UNSAFE_isDraggable", "interactionName"];
4
4
  /**
5
5
  * @jsxRuntime classic
6
6
  * @jsx jsx
7
7
  */
8
- import { forwardRef, memo } from 'react';
8
+ import { forwardRef, memo, useCallback, useContext } from 'react';
9
9
 
10
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
11
11
  import { jsx } from '@emotion/react';
12
12
  import { useRouterLink } from '@atlaskit/app-provider';
13
13
  import { propDeprecationWarning } from '@atlaskit/ds-lib/deprecation-warning';
14
14
  import noop from '@atlaskit/ds-lib/noop';
15
+ import InteractionContext from '@atlaskit/interaction-context';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
15
17
  import MenuItemPrimitive from '../internal/components/menu-item-primitive';
16
18
  var IS_EXTERNAL_LINK_REGEX = /^(?:(http|https):\/\/)/;
17
19
  var IS_NON_HTTP_BASED = /^(((mailto|tel|sms):)|(#))/;
@@ -50,9 +52,15 @@ function (props, ref) {
50
52
  UNSAFE_className = props.className,
51
53
  UNSAFE_shouldDisableRouterLink = props.UNSAFE_shouldDisableRouterLink,
52
54
  UNSAFE_isDraggable = props.UNSAFE_isDraggable,
55
+ interactionName = props.interactionName,
53
56
  rest = _objectWithoutProperties(props, _excluded);
54
57
  var onMouseDownHandler = onMouseDown;
55
58
  var RouterLink = useRouterLink();
59
+ var interactionContext = useContext(InteractionContext);
60
+ var handleClick = useCallback(function (e) {
61
+ interactionContext === null || interactionContext === void 0 || interactionContext.tracePress(interactionName, e.timeStamp);
62
+ onClick === null || onClick === void 0 || onClick(e);
63
+ }, [onClick, interactionContext, interactionName]);
56
64
  if (!children) {
57
65
  return null;
58
66
  }
@@ -111,7 +119,7 @@ function (props, ref) {
111
119
  onDragStart: preventEvent
112
120
  }, {
113
121
  onMouseDown: isDisabled ? preventEvent : onMouseDownHandler,
114
- onClick: isDisabled ? preventEvent : onClick,
122
+ onClick: isDisabled ? preventEvent : fg('platform_button_item-add-ufo-metrics') ? handleClick : onClick,
115
123
  "aria-current": isSelected ? 'page' : undefined,
116
124
  "aria-disabled": isDisabled,
117
125
  ref: ref
@@ -207,6 +207,10 @@ export interface MenuItemProps {
207
207
  * When `true`, the description of the item will wrap multiple lines if it's long enough.
208
208
  */
209
209
  shouldDescriptionWrap?: boolean;
210
+ /**
211
+ * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
212
+ */
213
+ interactionName?: string;
210
214
  }
211
215
  export interface ButtonItemProps extends MenuItemProps {
212
216
  /**
@@ -217,10 +221,6 @@ export interface ButtonItemProps extends MenuItemProps {
217
221
  * Use this to override the accessibility role for the element.
218
222
  */
219
223
  role?: string;
220
- /**
221
- * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
222
- */
223
- interactionName?: string;
224
224
  }
225
225
  export interface LinkItemProps extends MenuItemProps {
226
226
  /**
@@ -207,6 +207,10 @@ export interface MenuItemProps {
207
207
  * When `true`, the description of the item will wrap multiple lines if it's long enough.
208
208
  */
209
209
  shouldDescriptionWrap?: boolean;
210
+ /**
211
+ * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
212
+ */
213
+ interactionName?: string;
210
214
  }
211
215
  export interface ButtonItemProps extends MenuItemProps {
212
216
  /**
@@ -217,10 +221,6 @@ export interface ButtonItemProps extends MenuItemProps {
217
221
  * Use this to override the accessibility role for the element.
218
222
  */
219
223
  role?: string;
220
- /**
221
- * An optional name used to identify events for [React UFO (Unified Frontend Observability) press interactions](https://developer.atlassian.com/platform/ufo/react-ufo/react-ufo/getting-started/#quick-start--press-interactions). For more information, see [React UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
222
- */
223
- interactionName?: string;
224
224
  }
225
225
  export interface LinkItemProps extends MenuItemProps {
226
226
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/menu",
3
- "version": "2.12.5",
3
+ "version": "2.12.7",
4
4
  "description": "A list of options to help users navigate, or perform actions.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@atlaskit/app-provider": "^1.4.0",
43
- "@atlaskit/ds-lib": "^2.6.0",
43
+ "@atlaskit/ds-lib": "^3.0.0",
44
44
  "@atlaskit/focus-ring": "^1.6.0",
45
45
  "@atlaskit/interaction-context": "^2.1.0",
46
46
  "@atlaskit/platform-feature-flags": "^0.3.0",