@atlaskit/dropdown-menu 11.14.4 → 12.0.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cjs/checkbox/dropdown-item-checkbox-group.js +21 -6
  3. package/dist/cjs/checkbox/dropdown-item-checkbox.js +27 -27
  4. package/dist/cjs/dropdown-menu-item-group.js +1 -2
  5. package/dist/cjs/dropdown-menu-item.js +51 -31
  6. package/dist/cjs/dropdown-menu.js +46 -43
  7. package/dist/cjs/internal/components/checkbox-icon.js +1 -2
  8. package/dist/cjs/internal/components/context.js +4 -7
  9. package/dist/cjs/internal/components/focus-manager.js +2 -4
  10. package/dist/cjs/internal/components/menu-wrapper.js +2 -3
  11. package/dist/cjs/internal/components/radio-icon.js +1 -2
  12. package/dist/cjs/internal/context/checkbox-group-context.js +1 -2
  13. package/dist/cjs/internal/context/selection-store.js +2 -4
  14. package/dist/cjs/internal/hooks/use-checkbox-state.js +1 -2
  15. package/dist/cjs/internal/hooks/use-radio-state.js +1 -2
  16. package/dist/cjs/internal/hooks/use-register-item-with-focus-manager.js +1 -2
  17. package/dist/cjs/internal/utils/handle-focus.js +4 -4
  18. package/dist/cjs/internal/utils/is-voice-over-supported.js +1 -2
  19. package/dist/cjs/internal/utils/reset-options-in-group.js +1 -2
  20. package/dist/cjs/internal/utils/use-generated-id.js +1 -2
  21. package/dist/cjs/radio/dropdown-item-radio-group.js +22 -8
  22. package/dist/cjs/radio/dropdown-item-radio.js +29 -27
  23. package/dist/es2019/checkbox/dropdown-item-checkbox-group.js +21 -6
  24. package/dist/es2019/checkbox/dropdown-item-checkbox.js +24 -22
  25. package/dist/es2019/dropdown-menu-item.js +49 -27
  26. package/dist/es2019/dropdown-menu.js +33 -31
  27. package/dist/es2019/radio/dropdown-item-radio-group.js +21 -6
  28. package/dist/es2019/radio/dropdown-item-radio.js +26 -22
  29. package/dist/esm/checkbox/dropdown-item-checkbox-group.js +20 -4
  30. package/dist/esm/checkbox/dropdown-item-checkbox.js +26 -25
  31. package/dist/esm/dropdown-menu-item.js +50 -29
  32. package/dist/esm/dropdown-menu.js +44 -40
  33. package/dist/esm/internal/components/menu-wrapper.js +1 -1
  34. package/dist/esm/internal/utils/handle-focus.js +4 -4
  35. package/dist/esm/radio/dropdown-item-radio-group.js +20 -4
  36. package/dist/esm/radio/dropdown-item-radio.js +28 -25
  37. package/dist/types/checkbox/dropdown-item-checkbox-group.d.ts +1 -1
  38. package/dist/types/checkbox/dropdown-item-checkbox.d.ts +1 -1
  39. package/dist/types/dropdown-menu.d.ts +1 -1
  40. package/dist/types/radio/dropdown-item-radio-group.d.ts +1 -1
  41. package/dist/types/radio/dropdown-item-radio.d.ts +1 -1
  42. package/package.json +11 -13
  43. package/report.api.md +61 -13
  44. package/dist/types-ts4.5/checkbox/dropdown-item-checkbox-group.d.ts +0 -16
  45. package/dist/types-ts4.5/checkbox/dropdown-item-checkbox.d.ts +0 -13
  46. package/dist/types-ts4.5/dropdown-menu-item-group.d.ts +0 -11
  47. package/dist/types-ts4.5/dropdown-menu-item.d.ts +0 -13
  48. package/dist/types-ts4.5/dropdown-menu.d.ts +0 -13
  49. package/dist/types-ts4.5/index.d.ts +0 -8
  50. package/dist/types-ts4.5/internal/components/checkbox-icon.d.ts +0 -12
  51. package/dist/types-ts4.5/internal/components/context.d.ts +0 -27
  52. package/dist/types-ts4.5/internal/components/focus-manager.d.ts +0 -21
  53. package/dist/types-ts4.5/internal/components/menu-wrapper.d.ts +0 -11
  54. package/dist/types-ts4.5/internal/components/radio-icon.d.ts +0 -12
  55. package/dist/types-ts4.5/internal/context/checkbox-group-context.d.ts +0 -5
  56. package/dist/types-ts4.5/internal/context/selection-store.d.ts +0 -27
  57. package/dist/types-ts4.5/internal/hooks/use-checkbox-state.d.ts +0 -17
  58. package/dist/types-ts4.5/internal/hooks/use-radio-state.d.ts +0 -12
  59. package/dist/types-ts4.5/internal/hooks/use-register-item-with-focus-manager.d.ts +0 -4
  60. package/dist/types-ts4.5/internal/utils/handle-focus.d.ts +0 -2
  61. package/dist/types-ts4.5/internal/utils/is-checkbox-item.d.ts +0 -1
  62. package/dist/types-ts4.5/internal/utils/is-radio-item.d.ts +0 -1
  63. package/dist/types-ts4.5/internal/utils/is-voice-over-supported.d.ts +0 -2
  64. package/dist/types-ts4.5/internal/utils/reset-options-in-group.d.ts +0 -4
  65. package/dist/types-ts4.5/internal/utils/use-generated-id.d.ts +0 -6
  66. package/dist/types-ts4.5/radio/dropdown-item-radio-group.d.ts +0 -25
  67. package/dist/types-ts4.5/radio/dropdown-item-radio.d.ts +0 -13
  68. package/dist/types-ts4.5/types.d.ts +0 -303
  69. package/tmp/api-report-tmp.d.ts +0 -147
@@ -1,303 +0,0 @@
1
- import { KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from 'react';
2
- import type { CustomItemProps, MenuGroupProps, SectionProps } from '@atlaskit/menu/types';
3
- import type { ContentProps, TriggerProps } from '@atlaskit/popup/types';
4
- export type FocusableElement = HTMLAnchorElement | HTMLButtonElement;
5
- export type Action = 'next' | 'prev' | 'first' | 'last';
6
- export type Placement = 'auto-start' | 'auto' | 'auto-end' | 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-end' | 'bottom' | 'bottom-start' | 'left-end' | 'left' | 'left-start';
7
- export type ItemId = string;
8
- export type GroupId = string;
9
- export type CachedItem = {
10
- id: ItemId;
11
- groupId: GroupId;
12
- };
13
- export type FocusItem = {
14
- itemId: ItemId;
15
- itemNode: HTMLElement;
16
- };
17
- export type Behaviors = 'checkbox' | 'radio' | 'menuitemcheckbox' | 'menuitemradio';
18
- export interface CustomTriggerProps<TriggerElement extends HTMLElement = HTMLElement> extends Omit<TriggerProps, 'ref'> {
19
- /**
20
- * Ref that should be applied to the trigger. This is used to calculate the menu position.
21
- */
22
- triggerRef: Ref<TriggerElement>;
23
- /**
24
- * Makes the trigger appear selected.
25
- */
26
- isSelected?: boolean;
27
- /**
28
- * Event that is triggered when the element is clicked.
29
- */
30
- onClick?: (e: MouseEvent | KeyboardEvent) => void;
31
- /**
32
- * A `testId` prop is provided for specified elements, which is a unique
33
- * string that appears as a data attribute `data-testid` in the rendered code,
34
- * serving as a hook for automated tests.
35
- *
36
- * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
37
- * - `testId--trigger` to get the menu trigger.
38
- * - `testId--content` to get the dropdown content trigger.
39
- */
40
- testId?: string;
41
- }
42
- export interface OnOpenChangeArgs {
43
- isOpen: boolean;
44
- event: MouseEvent | KeyboardEvent;
45
- }
46
- export interface MenuWrapperProps extends MenuGroupProps {
47
- setInitialFocusRef?: ContentProps['setInitialFocusRef'];
48
- onClose?: ContentProps['onClose'];
49
- onUpdate: ContentProps['update'];
50
- isLoading?: DropdownMenuProps['isLoading'];
51
- statusLabel?: DropdownMenuProps['statusLabel'];
52
- }
53
- export interface DropdownMenuGroupProps extends SectionProps {
54
- }
55
- export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
56
- /**
57
- * Controls the appearance of the menu.
58
- * Default menu has scroll after its height exceeds the pre-defined amount.
59
- * Tall menu has no scroll until the height exceeds the height of the viewport.
60
- */
61
- appearance?: 'default' | 'tall';
62
- /**
63
- * Controls if the first menu item receives focus when menu is opened. Note that the menu has a focus lock
64
- * which traps the focus within the menu. Also, the first item gets fouced automatically
65
- * if the menu is triggered using the keyboard.
66
- *
67
- */
68
- autoFocus?: boolean;
69
- /**
70
- * Content that will be rendered inside the layer element. Should typically be
71
- * `DropdownItemGroup` or `DropdownItem`, or checkbox / radio variants of those.
72
- */
73
- children?: ReactNode;
74
- /**
75
- * If true, a Spinner is rendered instead of the items
76
- */
77
- isLoading?: boolean;
78
- /**
79
- * Text to be used as status for assistive technologies. Defaults to "Loading".
80
- */
81
- statusLabel?: string;
82
- /**
83
- * Controls the open state of the dropdown.
84
- */
85
- isOpen?: boolean;
86
- /**
87
- * Position of the menu.
88
- */
89
- placement?: Placement;
90
- /**
91
- * Allows the dropdown menu to be placed on the opposite side of its trigger if it does not
92
- * fit in the viewport.
93
- */
94
- shouldFlip?: boolean;
95
- /**
96
- * The root element where the DropdownMenu content should be rendered.
97
- * `true` - rendering in the DOM node closest to the trigger. `false` - rendering in React.Portal.
98
- * Defaults to `false`.
99
- */
100
- shouldRenderToParent?: boolean;
101
- /**
102
- * Controls the spacing density of the menu.
103
- */
104
- spacing?: Extract<MenuGroupProps['spacing'], 'cozy' | 'compact'>;
105
- /**
106
- * Content which will trigger the dropdown menu to open and close. Use with `triggerType`
107
- * to easily get a button trigger.
108
- */
109
- trigger?: string | ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement);
110
- /**
111
- * A `testId` prop is provided for specified elements, which is a unique
112
- * string that appears as a data attribute `data-testid` in the rendered code,
113
- * serving as a hook for automated tests.
114
- *
115
- * As dropdown-menu is composed of different components, we passed down the testId to the sub component you want to test:
116
- * - `testId--trigger` to get the menu trigger.
117
- * - `testId--content` to get the dropdown content trigger.
118
- */
119
- testId?: string;
120
- /**
121
- * Controls the initial open state of the dropdown. If provided, the component is considered to be controlled
122
- * which means that the user is responsible for managing the open and close state of the menu.
123
- */
124
- defaultOpen?: boolean;
125
- /**
126
- * Called when the menu should be open/closed. Receives an object with `isOpen` state.
127
- */
128
- onOpenChange?: (args: OnOpenChangeArgs) => void;
129
- /**
130
- * Z-index that the popup should be displayed in.
131
- * This is passed to the portal component.
132
- * Defaults to `layers.modal()` from `@atlaskit/theme` which is 510.
133
- */
134
- zIndex?: number;
135
- }
136
- export interface DropdownItemProps {
137
- /**
138
- * Primary content for the item.
139
- */
140
- children: React.ReactNode;
141
- /**
142
- * Custom component to render as an item.
143
- * Should be wrapped in `forwardRef` to avoid accessibility issues when controlling keyboard focus.
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 | KeyboardEvent) => 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
- export interface DropdownItemCheckboxProps {
207
- /**
208
- * Primary content for the item.
209
- */
210
- children: React.ReactNode;
211
- /**
212
- * Description of the item.
213
- * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
214
- */
215
- description?: string | JSX.Element;
216
- /**
217
- * Makes the checkbox appear disabled as well as removing interactivity.
218
- */
219
- isDisabled?: boolean;
220
- /**
221
- * When `true` the title of the item will wrap multiple lines if it's long enough.
222
- */
223
- shouldTitleWrap?: boolean;
224
- /**
225
- * When `true` the description of the item will wrap multiple lines if it's long enough.
226
- */
227
- shouldDescriptionWrap?: boolean;
228
- /**
229
- * Event that is triggered when the checkbox is clicked.
230
- */
231
- onClick?: (e: MouseEvent | KeyboardEvent) => void;
232
- /**
233
- * Sets whether the checkbox is checked or unchecked.
234
- */
235
- isSelected?: boolean;
236
- /**
237
- * Sets whether the checkbox begins selected.
238
- */
239
- defaultSelected?: boolean;
240
- /**
241
- * Unique id of a checkbox
242
- */
243
- id: string;
244
- /**
245
- * Adds a title attribute to the root item element.
246
- */
247
- title?: string;
248
- /**
249
- * A `testId` prop is provided for specified elements,
250
- * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
251
- * serving as a hook for automated tests.
252
- */
253
- testId?: string;
254
- }
255
- export interface DropdownItemRadioProps {
256
- /**
257
- * Primary content for the item.
258
- */
259
- children: React.ReactNode;
260
- /**
261
- * Description of the item.
262
- * This will render smaller text below the primary text of the item as well as slightly increasing the height of the item.
263
- */
264
- description?: string | JSX.Element;
265
- /**
266
- * Makes the checkbox appear disabled as well as removing interactivity.
267
- */
268
- isDisabled?: boolean;
269
- /**
270
- * When `true` the title of the item will wrap multiple lines if it's long enough.
271
- */
272
- shouldTitleWrap?: boolean;
273
- /**
274
- * When `true` the description of the item will wrap multiple lines if it's long enough.
275
- */
276
- shouldDescriptionWrap?: boolean;
277
- /**
278
- * Event that is triggered when the checkbox is clicked.
279
- */
280
- onClick?: (e: MouseEvent | KeyboardEvent) => void;
281
- /**
282
- * Sets whether the checkbox is checked or unchecked.
283
- */
284
- isSelected?: boolean;
285
- /**
286
- * Sets whether the checkbox begins selected.
287
- */
288
- defaultSelected?: boolean;
289
- /**
290
- * Unique id of a checkbox
291
- */
292
- id: string;
293
- /**
294
- * Adds a title attribute to the root item element.
295
- */
296
- title?: string;
297
- /**
298
- * A `testId` prop is provided for specified elements,
299
- * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
300
- * serving as a hook for automated tests.
301
- */
302
- testId?: string;
303
- }
@@ -1,147 +0,0 @@
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
-
7
- /// <reference types="react" />
8
-
9
- import type { CustomItemProps } from '@atlaskit/menu/types';
10
- import { default as DropdownItemGroup } from '@atlaskit/menu/section';
11
- import { KeyboardEvent as KeyboardEvent_2 } from 'react';
12
- import type { MenuGroupProps } from '@atlaskit/menu/types';
13
- import { MouseEvent as MouseEvent_2 } from 'react';
14
- import { default as React_2 } from 'react';
15
- import { ReactElement } from 'react';
16
- import { ReactNode } from 'react';
17
- import { Ref } from 'react';
18
- import type { SectionProps } from '@atlaskit/menu';
19
- import type { SectionProps as SectionProps_2 } from '@atlaskit/menu/types';
20
- import type { TriggerProps } from '@atlaskit/popup/types';
21
-
22
- // @public (undocumented)
23
- export interface CustomTriggerProps<TriggerElement extends HTMLElement = HTMLElement> extends Omit<TriggerProps, 'ref'> {
24
- isSelected?: boolean;
25
- onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
26
- testId?: string;
27
- triggerRef: Ref<TriggerElement>;
28
- }
29
-
30
- // @public
31
- export const DropdownItem: React_2.ForwardRefExoticComponent<DropdownItemProps & React_2.RefAttributes<HTMLElement>>;
32
-
33
- // @public
34
- export const DropdownItemCheckbox: (props: DropdownItemCheckboxProps) => JSX.Element;
35
-
36
- // @public
37
- export const DropdownItemCheckboxGroup: (props: DropdownItemCheckboxGroupProps) => JSX.Element;
38
-
39
- // @public (undocumented)
40
- interface DropdownItemCheckboxGroupProps extends SectionProps {
41
- id: string;
42
- }
43
-
44
- // @public (undocumented)
45
- interface DropdownItemCheckboxProps {
46
- children: React.ReactNode;
47
- defaultSelected?: boolean;
48
- description?: JSX.Element | string;
49
- id: string;
50
- isDisabled?: boolean;
51
- isSelected?: boolean;
52
- onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
53
- shouldDescriptionWrap?: boolean;
54
- shouldTitleWrap?: boolean;
55
- testId?: string;
56
- title?: string;
57
- }
58
-
59
- export { DropdownItemGroup }
60
-
61
- // @public (undocumented)
62
- export interface DropdownItemProps {
63
- children: React.ReactNode;
64
- component?: CustomItemProps['component'];
65
- description?: JSX.Element | string;
66
- elemAfter?: React.ReactNode;
67
- elemBefore?: React.ReactNode;
68
- href?: string;
69
- isDisabled?: boolean;
70
- isSelected?: boolean;
71
- onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
72
- rel?: string;
73
- shouldDescriptionWrap?: boolean;
74
- shouldTitleWrap?: boolean;
75
- target?: string;
76
- testId?: string;
77
- title?: string;
78
- }
79
-
80
- // @public
81
- export const DropdownItemRadio: (props: DropdownItemRadioProps) => JSX.Element;
82
-
83
- // @public
84
- export const DropdownItemRadioGroup: (props: DropdownItemRadioGroupProps) => JSX.Element;
85
-
86
- // @public (undocumented)
87
- interface DropdownItemRadioGroupProps extends SectionProps {
88
- // (undocumented)
89
- id: string;
90
- }
91
-
92
- // @public (undocumented)
93
- interface DropdownItemRadioProps {
94
- children: React.ReactNode;
95
- defaultSelected?: boolean;
96
- description?: JSX.Element | string;
97
- id: string;
98
- isDisabled?: boolean;
99
- isSelected?: boolean;
100
- onClick?: (e: KeyboardEvent_2 | MouseEvent_2) => void;
101
- shouldDescriptionWrap?: boolean;
102
- shouldTitleWrap?: boolean;
103
- testId?: string;
104
- title?: string;
105
- }
106
-
107
- // @public
108
- const DropdownMenu: <T extends HTMLElement = HTMLElement>(props: DropdownMenuProps<T>) => JSX.Element;
109
- export default DropdownMenu;
110
-
111
- // @public (undocumented)
112
- export interface DropdownMenuGroupProps extends SectionProps_2 {
113
- }
114
-
115
- // @public (undocumented)
116
- export interface DropdownMenuProps<TriggerElement extends HTMLElement = HTMLElement> {
117
- appearance?: 'default' | 'tall';
118
- autoFocus?: boolean;
119
- children?: ReactNode;
120
- defaultOpen?: boolean;
121
- isLoading?: boolean;
122
- isOpen?: boolean;
123
- onOpenChange?: (args: OnOpenChangeArgs) => void;
124
- placement?: Placement;
125
- shouldFlip?: boolean;
126
- shouldRenderToParent?: boolean;
127
- spacing?: Extract<MenuGroupProps['spacing'], 'compact' | 'cozy'>;
128
- statusLabel?: string;
129
- testId?: string;
130
- trigger?: ((triggerButtonProps: CustomTriggerProps<TriggerElement>) => ReactElement) | string;
131
- zIndex?: number;
132
- }
133
-
134
- // @public (undocumented)
135
- export interface OnOpenChangeArgs {
136
- // (undocumented)
137
- event: KeyboardEvent_2 | MouseEvent_2;
138
- // (undocumented)
139
- isOpen: boolean;
140
- }
141
-
142
- // @public (undocumented)
143
- type Placement = 'auto' | 'auto-end' | 'auto-start' | 'bottom' | 'bottom-end' | 'bottom-start' | 'left' | 'left-end' | 'left-start' | 'right' | 'right-end' | 'right-start' | 'top' | 'top-end' | 'top-start';
144
-
145
- // (No @packageDocumentation comment for this package)
146
-
147
- ```