@atlaskit/dropdown-menu 11.2.2 → 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,15 @@
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
+
3
13
  ## 11.2.2
4
14
 
5
15
  ### Patch Changes
@@ -133,11 +133,12 @@ var DropdownMenu = function DropdownMenu(props) {
133
133
  event: event
134
134
  });
135
135
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
136
- var handleOnClose = (0, _react.useCallback)(function () {
136
+ var handleOnClose = (0, _react.useCallback)(function (event) {
137
137
  var newValue = false;
138
138
  setLocalIsOpen(newValue);
139
139
  onOpenChange({
140
- isOpen: newValue
140
+ isOpen: newValue,
141
+ event: event
141
142
  });
142
143
  }, [onOpenChange, setLocalIsOpen]);
143
144
 
@@ -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.2",
3
+ "version": "11.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -81,11 +81,12 @@ const DropdownMenu = props => {
81
81
  event
82
82
  });
83
83
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
84
- const handleOnClose = useCallback(() => {
84
+ const handleOnClose = useCallback(event => {
85
85
  const newValue = false;
86
86
  setLocalIsOpen(newValue);
87
87
  onOpenChange({
88
- isOpen: newValue
88
+ isOpen: newValue,
89
+ event
89
90
  });
90
91
  }, [onOpenChange, setLocalIsOpen]);
91
92
  const {
@@ -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.2",
3
+ "version": "11.3.0",
4
4
  "sideEffects": false
5
5
  }
@@ -104,11 +104,12 @@ var DropdownMenu = function DropdownMenu(props) {
104
104
  event: event
105
105
  });
106
106
  }, [onOpenChange, isLocalOpen, setLocalIsOpen]);
107
- var handleOnClose = useCallback(function () {
107
+ var handleOnClose = useCallback(function (event) {
108
108
  var newValue = false;
109
109
  setLocalIsOpen(newValue);
110
110
  onOpenChange({
111
- isOpen: newValue
111
+ isOpen: newValue,
112
+ event: event
112
113
  });
113
114
  }, [onOpenChange, setLocalIsOpen]);
114
115
 
@@ -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.2",
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.2",
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/"
@@ -25,10 +25,10 @@
25
25
  "dependencies": {
26
26
  "@atlaskit/button": "^16.3.0",
27
27
  "@atlaskit/codemod-utils": "^4.1.0",
28
- "@atlaskit/ds-lib": "^2.0.0",
28
+ "@atlaskit/ds-lib": "^2.1.0",
29
29
  "@atlaskit/icon": "^21.10.0",
30
30
  "@atlaskit/menu": "^1.3.0",
31
- "@atlaskit/popup": "^1.3.0",
31
+ "@atlaskit/popup": "^1.4.0",
32
32
  "@atlaskit/spinner": "^15.0.0",
33
33
  "@atlaskit/theme": "^12.1.0",
34
34
  "@atlaskit/tokens": "^0.10.0",
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
+ ```