@atlaskit/dropdown-menu 11.2.0 → 11.3.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,29 @@
1
1
  # @atlaskit/dropdown-menu
2
2
 
3
+ ## 11.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`01d80d395bc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/01d80d395bc) - pass event to onOpenChange consistently
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
13
+ ## 11.2.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
18
+
19
+ ## 11.2.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [`347fd703ce0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/347fd703ce0) - Internally shifting to using bind-event-listener for events added in effects
24
+ - [`ce9438bddd0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ce9438bddd0) - Internal TypeScript authoring improvement
25
+ - Updated dependencies
26
+
3
27
  ## 11.2.0
4
28
 
5
29
  ### Minor Changes
@@ -19,6 +19,8 @@ var _react = require("react");
19
19
 
20
20
  var _core = require("@emotion/core");
21
21
 
22
+ var _bindEventListener = require("bind-event-listener");
23
+
22
24
  var _standardButton = _interopRequireDefault(require("@atlaskit/button/standard-button"));
23
25
 
24
26
  var _keycodes = require("@atlaskit/ds-lib/keycodes");
@@ -29,8 +31,6 @@ var _useControlled = _interopRequireDefault(require("@atlaskit/ds-lib/use-contro
29
31
 
30
32
  var _useFocusEvent = _interopRequireDefault(require("@atlaskit/ds-lib/use-focus-event"));
31
33
 
32
- var _useKeydownEvent = _interopRequireDefault(require("@atlaskit/ds-lib/use-keydown-event"));
33
-
34
34
  var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
35
35
 
36
36
  var _popup = _interopRequireDefault(require("@atlaskit/popup"));
@@ -108,7 +108,12 @@ var DropdownMenu = function DropdownMenu(props) {
108
108
  isTriggeredUsingKeyboard = _useState2[0],
109
109
  setTriggeredUsingKeyboard = _useState2[1];
110
110
 
111
- var handleTriggerClicked = (0, _react.useCallback)(function (event) {
111
+ var handleTriggerClicked = (0, _react.useCallback)( // TODO: event is an `any` and is being cast incorrectly
112
+ // This means that the public type for `onOpenChange` is incorrect
113
+ // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
114
+ // correct: (event: React.MouseEvent | KeyboardEvent) => void;
115
+ // https://product-fabric.atlassian.net/browse/DSP-4692
116
+ function (event) {
112
117
  var newValue = !isLocalOpen;
113
118
  var clientX = event.clientX,
114
119
  clientY = event.clientY,
@@ -128,27 +133,44 @@ var DropdownMenu = function DropdownMenu(props) {
128
133
  event: event
129
134
  });
130
135
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
131
- var handleOnClose = (0, _react.useCallback)(function () {
136
+ var handleOnClose = (0, _react.useCallback)(function (event) {
132
137
  var newValue = false;
133
138
  setLocalIsOpen(newValue);
134
139
  onOpenChange({
135
- isOpen: newValue
140
+ isOpen: newValue,
141
+ event: event
136
142
  });
137
143
  }, [onOpenChange, setLocalIsOpen]);
138
144
 
139
145
  var _useFocus = (0, _useFocusEvent.default)(),
140
146
  isFocused = _useFocus.isFocused,
141
- bindFocus = _useFocus.bindFocus;
147
+ bindFocus = _useFocus.bindFocus; // When a trigger is focused, we want to open the dropdown if
148
+ // the user presses the DownArrow
149
+
142
150
 
143
- var handleDownArrow = function handleDownArrow(e) {
144
- if (e.key === _keycodes.KEY_DOWN) {
145
- // prevent page scroll
146
- e.preventDefault();
147
- handleTriggerClicked(e);
151
+ (0, _react.useEffect)(function () {
152
+ // Only need to listen for keydown when focused
153
+ if (!isFocused) {
154
+ return _noop.default;
155
+ } // Being safe: we don't want to open the dropdown if it is already open
156
+ // Note: This shouldn't happen as the trigger should not be able to get focus
157
+
158
+
159
+ if (isLocalOpen) {
160
+ return _noop.default;
148
161
  }
149
- };
150
162
 
151
- (0, _useKeydownEvent.default)(handleDownArrow, isFocused);
163
+ return (0, _bindEventListener.bind)(window, {
164
+ type: 'keydown',
165
+ listener: function openOnKeyDown(e) {
166
+ if (e.key === _keycodes.KEY_DOWN) {
167
+ // prevent page scroll
168
+ e.preventDefault();
169
+ handleTriggerClicked(e);
170
+ }
171
+ }
172
+ });
173
+ }, [isFocused, isLocalOpen, handleTriggerClicked]);
152
174
  var id = (0, _useGeneratedId.default)();
153
175
  return (0, _core.jsx)(_selectionStore.default, null, (0, _core.jsx)(_popup.default, {
154
176
  id: isLocalOpen ? id : undefined,
@@ -11,7 +11,9 @@ exports.default = exports.FocusManagerContext = void 0;
11
11
 
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
 
14
- var _useKeydownEvent = _interopRequireDefault(require("@atlaskit/ds-lib/use-keydown-event"));
14
+ var _bindEventListener = require("bind-event-listener");
15
+
16
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
15
17
 
16
18
  var _handleFocus = _interopRequireDefault(require("../utils/handle-focus"));
17
19
 
@@ -29,7 +31,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
29
31
  */
30
32
  var FocusManagerContext = /*#__PURE__*/(0, _react.createContext)({
31
33
  menuItemRefs: [],
32
- registerRef: function registerRef(ref) {}
34
+ registerRef: _noop.default
33
35
  });
34
36
  /**
35
37
  * Focus manager logic
@@ -44,8 +46,14 @@ var FocusManager = function FocusManager(_ref) {
44
46
  if (ref && !menuItemRefs.current.includes(ref)) {
45
47
  menuItemRefs.current.push(ref);
46
48
  }
47
- }, []);
48
- (0, _useKeydownEvent.default)((0, _handleFocus.default)(menuItemRefs.current));
49
+ }, []); // Intentionally rebinding on each render
50
+
51
+ (0, _react.useEffect)(function () {
52
+ return (0, _bindEventListener.bind)(window, {
53
+ type: 'keydown',
54
+ listener: (0, _handleFocus.default)(menuItemRefs.current)
55
+ });
56
+ });
49
57
  var contextValue = {
50
58
  menuItemRefs: menuItemRefs.current,
51
59
  registerRef: registerRef
@@ -54,7 +54,7 @@ var MenuWrapper = function MenuWrapper(_ref) {
54
54
  // select multiple items.
55
55
 
56
56
  if (isTargetMenuItemOrDecendant && onClose) {
57
- onClose();
57
+ onClose(e);
58
58
  }
59
59
  };
60
60
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,14 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
 
3
3
  /** @jsx jsx */
4
- import { useCallback, useState } from 'react';
4
+ import { useCallback, useEffect, useState } from 'react';
5
5
  import { css, jsx } from '@emotion/core';
6
+ import { bind } from 'bind-event-listener';
6
7
  import Button from '@atlaskit/button/standard-button';
7
8
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
8
9
  import noop from '@atlaskit/ds-lib/noop';
9
10
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
10
11
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
11
- import useKeydownEvent from '@atlaskit/ds-lib/use-keydown-event';
12
12
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
13
13
  import Popup from '@atlaskit/popup';
14
14
  import Spinner from '@atlaskit/spinner';
@@ -54,7 +54,12 @@ const DropdownMenu = props => {
54
54
  } = props;
55
55
  const [isLocalOpen, setLocalIsOpen] = useControlledState(isOpen, () => defaultOpen);
56
56
  const [isTriggeredUsingKeyboard, setTriggeredUsingKeyboard] = useState(false);
57
- const handleTriggerClicked = useCallback(event => {
57
+ const handleTriggerClicked = useCallback( // TODO: event is an `any` and is being cast incorrectly
58
+ // This means that the public type for `onOpenChange` is incorrect
59
+ // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
60
+ // correct: (event: React.MouseEvent | KeyboardEvent) => void;
61
+ // https://product-fabric.atlassian.net/browse/DSP-4692
62
+ event => {
58
63
  const newValue = !isLocalOpen;
59
64
  const {
60
65
  clientX,
@@ -76,27 +81,43 @@ const DropdownMenu = props => {
76
81
  event
77
82
  });
78
83
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
79
- const handleOnClose = useCallback(() => {
84
+ const handleOnClose = useCallback(event => {
80
85
  const newValue = false;
81
86
  setLocalIsOpen(newValue);
82
87
  onOpenChange({
83
- isOpen: newValue
88
+ isOpen: newValue,
89
+ event
84
90
  });
85
91
  }, [onOpenChange, setLocalIsOpen]);
86
92
  const {
87
93
  isFocused,
88
94
  bindFocus
89
- } = useFocus();
95
+ } = useFocus(); // When a trigger is focused, we want to open the dropdown if
96
+ // the user presses the DownArrow
97
+
98
+ useEffect(() => {
99
+ // Only need to listen for keydown when focused
100
+ if (!isFocused) {
101
+ return noop;
102
+ } // Being safe: we don't want to open the dropdown if it is already open
103
+ // Note: This shouldn't happen as the trigger should not be able to get focus
90
104
 
91
- const handleDownArrow = e => {
92
- if (e.key === KEY_DOWN) {
93
- // prevent page scroll
94
- e.preventDefault();
95
- handleTriggerClicked(e);
105
+
106
+ if (isLocalOpen) {
107
+ return noop;
96
108
  }
97
- };
98
109
 
99
- useKeydownEvent(handleDownArrow, isFocused);
110
+ return bind(window, {
111
+ type: 'keydown',
112
+ listener: function openOnKeyDown(e) {
113
+ if (e.key === KEY_DOWN) {
114
+ // prevent page scroll
115
+ e.preventDefault();
116
+ handleTriggerClicked(e);
117
+ }
118
+ }
119
+ });
120
+ }, [isFocused, isLocalOpen, handleTriggerClicked]);
100
121
  const id = useGeneratedId();
101
122
  return jsx(SelectionStore, null, jsx(Popup, {
102
123
  id: isLocalOpen ? id : undefined,
@@ -1,5 +1,6 @@
1
- import React, { createContext, useCallback, useRef } from 'react';
2
- import useKeydownEvent from '@atlaskit/ds-lib/use-keydown-event';
1
+ import React, { createContext, useCallback, useEffect, useRef } from 'react';
2
+ import { bind } from 'bind-event-listener';
3
+ import __noop from '@atlaskit/ds-lib/noop';
3
4
  import handleFocus from '../utils/handle-focus';
4
5
  /**
5
6
  *
@@ -12,7 +13,7 @@ import handleFocus from '../utils/handle-focus';
12
13
 
13
14
  export const FocusManagerContext = /*#__PURE__*/createContext({
14
15
  menuItemRefs: [],
15
- registerRef: ref => {}
16
+ registerRef: __noop
16
17
  });
17
18
  /**
18
19
  * Focus manager logic
@@ -26,8 +27,14 @@ const FocusManager = ({
26
27
  if (ref && !menuItemRefs.current.includes(ref)) {
27
28
  menuItemRefs.current.push(ref);
28
29
  }
29
- }, []);
30
- useKeydownEvent(handleFocus(menuItemRefs.current));
30
+ }, []); // Intentionally rebinding on each render
31
+
32
+ useEffect(() => {
33
+ return bind(window, {
34
+ type: 'keydown',
35
+ listener: handleFocus(menuItemRefs.current)
36
+ });
37
+ });
31
38
  const contextValue = {
32
39
  menuItemRefs: menuItemRefs.current,
33
40
  registerRef
@@ -31,7 +31,7 @@ const MenuWrapper = ({
31
31
  // select multiple items.
32
32
 
33
33
  if (isTargetMenuItemOrDecendant && onClose) {
34
- onClose();
34
+ onClose(e);
35
35
  }
36
36
  };
37
37
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -9,14 +9,14 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
10
 
11
11
  /** @jsx jsx */
12
- import { useCallback, useState } from 'react';
12
+ import { useCallback, useEffect, useState } from 'react';
13
13
  import { css, jsx } from '@emotion/core';
14
+ import { bind } from 'bind-event-listener';
14
15
  import Button from '@atlaskit/button/standard-button';
15
16
  import { KEY_DOWN } from '@atlaskit/ds-lib/keycodes';
16
17
  import noop from '@atlaskit/ds-lib/noop';
17
18
  import useControlledState from '@atlaskit/ds-lib/use-controlled';
18
19
  import useFocus from '@atlaskit/ds-lib/use-focus-event';
19
- import useKeydownEvent from '@atlaskit/ds-lib/use-keydown-event';
20
20
  import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
21
21
  import Popup from '@atlaskit/popup';
22
22
  import Spinner from '@atlaskit/spinner';
@@ -79,7 +79,12 @@ var DropdownMenu = function DropdownMenu(props) {
79
79
  isTriggeredUsingKeyboard = _useState2[0],
80
80
  setTriggeredUsingKeyboard = _useState2[1];
81
81
 
82
- var handleTriggerClicked = useCallback(function (event) {
82
+ var handleTriggerClicked = useCallback( // TODO: event is an `any` and is being cast incorrectly
83
+ // This means that the public type for `onOpenChange` is incorrect
84
+ // current: (event: React.MouseEvent | React.KeyboardEvent) => void;
85
+ // correct: (event: React.MouseEvent | KeyboardEvent) => void;
86
+ // https://product-fabric.atlassian.net/browse/DSP-4692
87
+ function (event) {
83
88
  var newValue = !isLocalOpen;
84
89
  var clientX = event.clientX,
85
90
  clientY = event.clientY,
@@ -99,27 +104,44 @@ var DropdownMenu = function DropdownMenu(props) {
99
104
  event: event
100
105
  });
101
106
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
102
- var handleOnClose = useCallback(function () {
107
+ var handleOnClose = useCallback(function (event) {
103
108
  var newValue = false;
104
109
  setLocalIsOpen(newValue);
105
110
  onOpenChange({
106
- isOpen: newValue
111
+ isOpen: newValue,
112
+ event: event
107
113
  });
108
114
  }, [onOpenChange, setLocalIsOpen]);
109
115
 
110
116
  var _useFocus = useFocus(),
111
117
  isFocused = _useFocus.isFocused,
112
- bindFocus = _useFocus.bindFocus;
118
+ bindFocus = _useFocus.bindFocus; // When a trigger is focused, we want to open the dropdown if
119
+ // the user presses the DownArrow
120
+
121
+
122
+ useEffect(function () {
123
+ // Only need to listen for keydown when focused
124
+ if (!isFocused) {
125
+ return noop;
126
+ } // Being safe: we don't want to open the dropdown if it is already open
127
+ // Note: This shouldn't happen as the trigger should not be able to get focus
113
128
 
114
- var handleDownArrow = function handleDownArrow(e) {
115
- if (e.key === KEY_DOWN) {
116
- // prevent page scroll
117
- e.preventDefault();
118
- handleTriggerClicked(e);
129
+
130
+ if (isLocalOpen) {
131
+ return noop;
119
132
  }
120
- };
121
133
 
122
- useKeydownEvent(handleDownArrow, isFocused);
134
+ return bind(window, {
135
+ type: 'keydown',
136
+ listener: function openOnKeyDown(e) {
137
+ if (e.key === KEY_DOWN) {
138
+ // prevent page scroll
139
+ e.preventDefault();
140
+ handleTriggerClicked(e);
141
+ }
142
+ }
143
+ });
144
+ }, [isFocused, isLocalOpen, handleTriggerClicked]);
123
145
  var id = useGeneratedId();
124
146
  return jsx(SelectionStore, null, jsx(Popup, {
125
147
  id: isLocalOpen ? id : undefined,
@@ -1,5 +1,6 @@
1
- import React, { createContext, useCallback, useRef } from 'react';
2
- import useKeydownEvent from '@atlaskit/ds-lib/use-keydown-event';
1
+ import React, { createContext, useCallback, useEffect, useRef } from 'react';
2
+ import { bind } from 'bind-event-listener';
3
+ import __noop from '@atlaskit/ds-lib/noop';
3
4
  import handleFocus from '../utils/handle-focus';
4
5
  /**
5
6
  *
@@ -12,7 +13,7 @@ import handleFocus from '../utils/handle-focus';
12
13
 
13
14
  export var FocusManagerContext = /*#__PURE__*/createContext({
14
15
  menuItemRefs: [],
15
- registerRef: function registerRef(ref) {}
16
+ registerRef: __noop
16
17
  });
17
18
  /**
18
19
  * Focus manager logic
@@ -25,8 +26,14 @@ var FocusManager = function FocusManager(_ref) {
25
26
  if (ref && !menuItemRefs.current.includes(ref)) {
26
27
  menuItemRefs.current.push(ref);
27
28
  }
28
- }, []);
29
- useKeydownEvent(handleFocus(menuItemRefs.current));
29
+ }, []); // Intentionally rebinding on each render
30
+
31
+ useEffect(function () {
32
+ return bind(window, {
33
+ type: 'keydown',
34
+ listener: handleFocus(menuItemRefs.current)
35
+ });
36
+ });
30
37
  var contextValue = {
31
38
  menuItemRefs: menuItemRefs.current,
32
39
  registerRef: registerRef
@@ -32,7 +32,7 @@ var MenuWrapper = function MenuWrapper(_ref) {
32
32
  // select multiple items.
33
33
 
34
34
  if (isTargetMenuItemOrDecendant && onClose) {
35
- onClose();
35
+ onClose(e);
36
36
  }
37
37
  };
38
38
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
- import _regeneratorRuntime from "@babel/runtime/regenerator";
2
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { getExampleUrl, loadPage } from '@atlaskit/visual-regression/helper';
4
4
  var dropdownTrigger = '[data-testid="dropdown--trigger"]';
5
5
  var dropdownContent = '[data-testid="dropdown--content"]';
@@ -41,7 +41,7 @@ export interface CustomTriggerProps extends Omit<TriggerProps, 'ref'> {
41
41
  }
42
42
  export interface OnOpenChangeArgs {
43
43
  isOpen: boolean;
44
- event?: MouseEvent | KeyboardEvent;
44
+ event: MouseEvent | KeyboardEvent;
45
45
  }
46
46
  export interface MenuWrapperProps extends MenuGroupProps {
47
47
  setInitialFocusRef?: ContentProps['setInitialFocusRef'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/dropdown-menu",
3
- "version": "11.2.0",
3
+ "version": "11.3.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/"
@@ -18,22 +18,24 @@
18
18
  "team": "Design System Team",
19
19
  "releaseModel": "scheduled",
20
20
  "website": {
21
- "name": "Dropdown menu"
21
+ "name": "Dropdown menu",
22
+ "category": "Components"
22
23
  }
23
24
  },
24
25
  "dependencies": {
25
26
  "@atlaskit/button": "^16.3.0",
26
27
  "@atlaskit/codemod-utils": "^4.1.0",
27
- "@atlaskit/ds-lib": "^1.4.0",
28
+ "@atlaskit/ds-lib": "^2.1.0",
28
29
  "@atlaskit/icon": "^21.10.0",
29
30
  "@atlaskit/menu": "^1.3.0",
30
- "@atlaskit/popup": "^1.3.0",
31
+ "@atlaskit/popup": "^1.4.0",
31
32
  "@atlaskit/spinner": "^15.0.0",
32
33
  "@atlaskit/theme": "^12.1.0",
33
34
  "@atlaskit/tokens": "^0.10.0",
34
35
  "@atlaskit/visually-hidden": "^1.0.0",
35
36
  "@babel/runtime": "^7.0.0",
36
- "@emotion/core": "^10.0.9"
37
+ "@emotion/core": "^10.0.9",
38
+ "bind-event-listener": "^2.1.1"
37
39
  },
38
40
  "peerDependencies": {
39
41
  "react": "^16.8.0",
@@ -70,6 +72,7 @@
70
72
  "import-structure": "atlassian-conventions"
71
73
  },
72
74
  "@repo/internal": {
75
+ "dom-events": "use-bind-event-listener",
73
76
  "ui-components": "lite-mode",
74
77
  "design-system": "v1",
75
78
  "styling": [
package/report.api.md ADDED
@@ -0,0 +1,393 @@
1
+ ## API Report File for "@atlaskit/dropdown-menu"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+ /// <reference types="react" />
7
+
8
+ import type { CustomItemProps } from '@atlaskit/menu/types';
9
+ import { default as DropdownItemGroup } from '@atlaskit/menu/section';
10
+ import { KeyboardEvent as KeyboardEvent_2 } from 'react';
11
+ import { MouseEvent as MouseEvent_2 } from 'react';
12
+ import { ReactElement } from 'react';
13
+ import { ReactNode } from 'react';
14
+ import { Ref } from 'react';
15
+ import type { SectionProps } from '@atlaskit/menu';
16
+ import type { SectionProps as SectionProps_2 } from '@atlaskit/menu/types';
17
+ import type { TriggerProps } from '@atlaskit/popup/types';
18
+
19
+ export declare interface CustomTriggerProps extends Omit<TriggerProps, 'ref'> {
20
+ /**
21
+ * Ref that should be applied to the trigger. This is used to calculate the menu position.
22
+ */
23
+ triggerRef: Ref<HTMLElement>;
24
+ /**
25
+ * Makes the trigger appear selected.
26
+ */
27
+ isSelected?: boolean;
28
+ /**
29
+ * Event that is triggered when the element is clicked.
30
+ */
31
+ onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
32
+ /**
33
+ * A `testId` prop is provided for specified elements, which is a unique
34
+ * string that appears as a data attribute `data-testid` in the rendered code,
35
+ * serving as a hook for automated tests.
36
+ *
37
+ * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
38
+ * - `testId--trigger` to get the menu trigger.
39
+ * - `testId--content` to get the dropdown content trigger.
40
+ */
41
+ testId?: string;
42
+ }
43
+
44
+ /**
45
+ * __Dropdown menu item__
46
+ *
47
+ * A dropdown item populates the dropdown menu with items. Every item should be inside a dropdown item group.
48
+ *
49
+ * - [Examples](https://atlassian.design/components/dropdown-item/examples)
50
+ * - [Code](https://atlassian.design/components/dropdown-item/code)
51
+ * - [Usage](https://atlassian.design/components/dropdown-item/usage)
52
+ */
53
+ export declare const DropdownItem: (props: DropdownItemProps) => JSX.Element;
54
+
55
+ /**
56
+ * __Dropdown item checkbox__
57
+ *
58
+ * A dropdown item checkbox creates groups that have multiple selections.
59
+ *
60
+ * - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/examples)
61
+ * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/code)
62
+ * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-checkbox/usage)
63
+ */
64
+ export declare const DropdownItemCheckbox: (
65
+ props: DropdownItemCheckboxProps,
66
+ ) => JSX.Element;
67
+
68
+ /**
69
+ * __Dropdown item checkbox group__
70
+ *
71
+ * A wrapping element for dropdown menu checkbox items.
72
+ *
73
+ */
74
+ export declare const DropdownItemCheckboxGroup: (
75
+ props: DropdownItemCheckboxGroupProps,
76
+ ) => JSX.Element;
77
+
78
+ declare interface DropdownItemCheckboxGroupProps extends SectionProps {
79
+ /**
80
+ * Unique identifier for the checkbox group.
81
+ */
82
+ id: string;
83
+ }
84
+
85
+ declare interface DropdownItemCheckboxProps {
86
+ /**
87
+ * Primary content for the item.
88
+ */
89
+ children: React.ReactNode;
90
+ /**
91
+ * Description of the item.
92
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
93
+ */
94
+ description?: string | JSX.Element;
95
+ /**
96
+ * Makes the checkbox appear disabled as well as removing interactivity.
97
+ */
98
+ isDisabled?: boolean;
99
+ /**
100
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
101
+ */
102
+ shouldTitleWrap?: boolean;
103
+ /**
104
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
105
+ */
106
+ shouldDescriptionWrap?: boolean;
107
+ /**
108
+ * Event that is triggered when the checkbox is clicked.
109
+ */
110
+ onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
111
+ /**
112
+ * Sets whether the checkbox is checked or unchecked.
113
+ */
114
+ isSelected?: boolean;
115
+ /**
116
+ * Sets whether the checkbox begins selected.
117
+ */
118
+ defaultSelected?: boolean;
119
+ /**
120
+ * Unique id of a checkbox
121
+ */
122
+ id: string;
123
+ /**
124
+ * Adds a title attribute to the root item element.
125
+ */
126
+ title?: string;
127
+ /**
128
+ * A `testId` prop is provided for specified elements,
129
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
130
+ * serving as a hook for automated tests.
131
+ */
132
+ testId?: string;
133
+ }
134
+
135
+ export { DropdownItemGroup };
136
+
137
+ export declare interface DropdownItemProps {
138
+ /**
139
+ * Primary content for the item.
140
+ */
141
+ children: React.ReactNode;
142
+ /**
143
+ * Custom component to render as an item.
144
+ */
145
+ component?: CustomItemProps['component'];
146
+ /**
147
+ * Description of the item.
148
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
149
+ */
150
+ description?: string | JSX.Element;
151
+ /**
152
+ * Makes the element appear disabled as well as removing interactivity.
153
+ */
154
+ isDisabled?: boolean;
155
+ /**
156
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
157
+ */
158
+ shouldTitleWrap?: boolean;
159
+ /**
160
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
161
+ */
162
+ shouldDescriptionWrap?: boolean;
163
+ /**
164
+ * Event that is triggered when the element is clicked.
165
+ */
166
+ onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
167
+ /**
168
+ * Makes the element appear selected.
169
+ */
170
+ isSelected?: boolean;
171
+ /**
172
+ * Link to another page.
173
+ */
174
+ href?: string;
175
+ /**
176
+ * Where to display the linked URL,
177
+ * see [anchor information](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) on mdn for more information.
178
+ */
179
+ target?: string;
180
+ /**
181
+ * Adds a title attribute to the root item element.
182
+ */
183
+ title?: string;
184
+ /**
185
+ * Element to render before the item text.
186
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
187
+ */
188
+ elemBefore?: React.ReactNode;
189
+ /**
190
+ * Element to render after the item text.
191
+ * Generally should be an [icon](https://atlaskit.atlassian.com/packages/design-system/icon) component.
192
+ */
193
+ elemAfter?: React.ReactNode;
194
+ /**
195
+ * The relationship of the linked URL as space-separated link types.
196
+ * Generally you'll want to set this to "noopener noreferrer" when `target` is "_blank".
197
+ */
198
+ rel?: string;
199
+ /**
200
+ * A `testId` prop is provided for specified elements,
201
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
202
+ * serving as a hook for automated tests.
203
+ */
204
+ testId?: string;
205
+ }
206
+
207
+ /**
208
+ * __Dropdown item radio__
209
+ *
210
+ * A dropdown item radio displays groups that have a single selection.
211
+ *
212
+ * - [Examples](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/examples)
213
+ * - [Code](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/code)
214
+ * - [Usage](https://atlassian.design/components/dropdown-menu/dropdown-item-radio/usage)
215
+ */
216
+ export declare const DropdownItemRadio: (
217
+ props: DropdownItemRadioProps,
218
+ ) => JSX.Element;
219
+
220
+ /**
221
+ * __Dropdown item radio group__
222
+ * Store which manages the selection state for each DropdownItemRadio
223
+ * across mount and unmounts.
224
+ *
225
+ */
226
+ export declare const DropdownItemRadioGroup: (
227
+ props: DropdownItemRadioGroupProps,
228
+ ) => JSX.Element;
229
+
230
+ declare interface DropdownItemRadioGroupProps extends SectionProps {
231
+ id: string;
232
+ }
233
+
234
+ declare interface DropdownItemRadioProps {
235
+ /**
236
+ * Primary content for the item.
237
+ */
238
+ children: React.ReactNode;
239
+ /**
240
+ * Description of the item.
241
+ * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
242
+ */
243
+ description?: string | JSX.Element;
244
+ /**
245
+ * Makes the checkbox appear disabled as well as removing interactivity.
246
+ */
247
+ isDisabled?: boolean;
248
+ /**
249
+ * When `true` the title of the item will wrap multiple lines if it's long enough.
250
+ */
251
+ shouldTitleWrap?: boolean;
252
+ /**
253
+ * When `true` the description of the item will wrap multiple lines if it's long enough.
254
+ */
255
+ shouldDescriptionWrap?: boolean;
256
+ /**
257
+ * Event that is triggered when the checkbox is clicked.
258
+ */
259
+ onClick?: (e: MouseEvent_2 | KeyboardEvent_2) => void;
260
+ /**
261
+ * Sets whether the checkbox is checked or unchecked.
262
+ */
263
+ isSelected?: boolean;
264
+ /**
265
+ * Sets whether the checkbox begins selected.
266
+ */
267
+ defaultSelected?: boolean;
268
+ /**
269
+ * Unique id of a checkbox
270
+ */
271
+ id: string;
272
+ /**
273
+ * Adds a title attribute to the root item element.
274
+ */
275
+ title?: string;
276
+ /**
277
+ * A `testId` prop is provided for specified elements,
278
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
279
+ * serving as a hook for automated tests.
280
+ */
281
+ testId?: string;
282
+ }
283
+
284
+ /**
285
+ * __Dropdown menu__
286
+ *
287
+ * A dropdown menu displays a list of actions or options to a user.
288
+ *
289
+ * - [Examples](https://atlassian.design/components/dropdown-menu/examples)
290
+ * - [Code](https://atlassian.design/components/dropdown-menu/code)
291
+ * - [Usage](https://atlassian.design/components/dropdown-menu/usage)
292
+ */
293
+ declare const DropdownMenu: (props: DropdownMenuProps) => JSX.Element;
294
+ export default DropdownMenu;
295
+
296
+ export declare interface DropdownMenuGroupProps extends SectionProps_2 {}
297
+
298
+ export declare interface DropdownMenuProps {
299
+ /**
300
+ * Controls the appearance of the menu.
301
+ * Default menu has scroll after its height exceeds the pre-defined amount.
302
+ * Tall menu has no scroll until the height exceeds the height of the viewport.
303
+ */
304
+ appearance?: 'default' | 'tall';
305
+ /**
306
+ * Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
307
+ * which traps the focus within the menu. Also, the first item gets fouced automatically
308
+ * if the menu is triggered using the keyboard.
309
+ *
310
+ */
311
+ autoFocus?: boolean;
312
+ /**
313
+ * Content that will be rendered inside the layer element. Should typically be
314
+ * `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those.
315
+ */
316
+ children?: ReactNode;
317
+ /**
318
+ * If true, a Spinner is rendered instead of the items
319
+ */
320
+ isLoading?: boolean;
321
+ /**
322
+ * Text to be used as status for assistive technologies. Defaults to "Loading".
323
+ */
324
+ statusLabel?: string;
325
+ /**
326
+ * Controls the open state of the dropdown.
327
+ */
328
+ isOpen?: boolean;
329
+ /**
330
+ * Position of the menu.
331
+ */
332
+ placement?: Placement;
333
+ /**
334
+ * Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
335
+ * fit in the viewport.
336
+ */
337
+ shouldFlip?: boolean;
338
+ /**
339
+ * Content which will trigger the dropdown menu to open and close. Use with `triggerType`
340
+ * to easily get a button trigger.
341
+ */
342
+ trigger?: string | ((triggerButtonProps: CustomTriggerProps) => ReactElement);
343
+ /**
344
+ * A `testId` prop is provided for specified elements, which is a unique
345
+ * string that appears as a data attribute `data-testid` in the rendered code,
346
+ * serving as a hook for automated tests.
347
+ *
348
+ * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
349
+ * - `testId--trigger` to get the menu trigger.
350
+ * - `testId--content` to get the dropdown content trigger.
351
+ */
352
+ testId?: string;
353
+ /**
354
+ * Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
355
+ * which means that the user is responsible for managing the open and close state of the menu.
356
+ */
357
+ defaultOpen?: boolean;
358
+ /**
359
+ * Called when the menu should be open/closed. Receives an object with `isOpen` state.
360
+ */
361
+ onOpenChange?: (args: OnOpenChangeArgs) => void;
362
+ /**
363
+ * Z-index that the popup should be displayed in.
364
+ * This is passed to the portal component.
365
+ * Defaults to `layers.modal()` from `@atlaskit/theme` which is 510.
366
+ */
367
+ zIndex?: number;
368
+ }
369
+
370
+ export declare interface OnOpenChangeArgs {
371
+ isOpen: boolean;
372
+ event?: MouseEvent_2 | KeyboardEvent_2;
373
+ }
374
+
375
+ declare type Placement =
376
+ | 'auto-start'
377
+ | 'auto'
378
+ | 'auto-end'
379
+ | 'top-start'
380
+ | 'top'
381
+ | 'top-end'
382
+ | 'right-start'
383
+ | 'right'
384
+ | 'right-end'
385
+ | 'bottom-end'
386
+ | 'bottom'
387
+ | 'bottom-start'
388
+ | 'left-end'
389
+ | 'left'
390
+ | 'left-start';
391
+
392
+ export {};
393
+ ```