@splunk/react-ui 5.7.1 → 5.9.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 (152) hide show
  1. package/Accordion.js +6 -6
  2. package/Anchor.js +2 -1
  3. package/Box.js +83 -34
  4. package/CHANGELOG.md +51 -0
  5. package/Calendar.js +134 -134
  6. package/Clickable.js +131 -94
  7. package/CollapsiblePanel.js +175 -137
  8. package/ComboBox.js +32 -27
  9. package/ControlGroup.js +92 -91
  10. package/DefinitionList.js +9 -9
  11. package/Drawer.d.ts +2 -0
  12. package/Drawer.js +679 -0
  13. package/Dropdown.js +27 -18
  14. package/DualListbox.js +1 -1
  15. package/File.js +35 -35
  16. package/JSONTree.js +73 -72
  17. package/Link.js +2 -2
  18. package/MIGRATION.md +10 -0
  19. package/Menu.js +403 -261
  20. package/Modal.js +263 -252
  21. package/Monogram.js +2 -2
  22. package/Multiselect.js +551 -385
  23. package/Number.js +2 -1
  24. package/Paginator.js +14 -12
  25. package/Popover.js +4 -1
  26. package/README.md +11 -0
  27. package/RadioBar.js +1 -1
  28. package/Search.js +111 -95
  29. package/Select.js +42 -40
  30. package/SelectBase.js +819 -715
  31. package/SidePanel.js +346 -167
  32. package/SlidingPanels.js +11 -11
  33. package/StepBar.js +7 -7
  34. package/Switch.js +5 -5
  35. package/Table.js +116 -119
  36. package/Text.js +48 -48
  37. package/TextArea.js +7 -7
  38. package/TransitionOpen.js +188 -169
  39. package/docs-llm/Accordion.md +267 -0
  40. package/docs-llm/Anchor Menu.md +115 -0
  41. package/docs-llm/Anchor.md +54 -0
  42. package/docs-llm/AnimationToggle.md +254 -0
  43. package/docs-llm/Avatar.md +292 -0
  44. package/docs-llm/Badge.md +212 -0
  45. package/docs-llm/Breadcrumbs.md +306 -0
  46. package/docs-llm/Button Group.md +53 -0
  47. package/docs-llm/Button.md +361 -0
  48. package/docs-llm/Card Layout.md +286 -0
  49. package/docs-llm/Card.md +619 -0
  50. package/docs-llm/Checkbox.md +218 -0
  51. package/docs-llm/Chip.md +291 -0
  52. package/docs-llm/Clickable.md +160 -0
  53. package/docs-llm/Code.md +292 -0
  54. package/docs-llm/Collapsible Panel.md +744 -0
  55. package/docs-llm/Color.md +253 -0
  56. package/docs-llm/Column Layout.md +391 -0
  57. package/docs-llm/Combo Box.md +540 -0
  58. package/docs-llm/Control Group.md +594 -0
  59. package/docs-llm/Date.md +270 -0
  60. package/docs-llm/Definition List.md +278 -0
  61. package/docs-llm/Divider.md +216 -0
  62. package/docs-llm/Drawer.md +414 -0
  63. package/docs-llm/Dropdown.md +472 -0
  64. package/docs-llm/Dual Listbox.md +325 -0
  65. package/docs-llm/File.md +653 -0
  66. package/docs-llm/Form Rows.md +374 -0
  67. package/docs-llm/Heading.md +179 -0
  68. package/docs-llm/Image.md +109 -0
  69. package/docs-llm/JSON Tree.md +260 -0
  70. package/docs-llm/Layer.md +74 -0
  71. package/docs-llm/Layout.md +50 -0
  72. package/docs-llm/Link.md +318 -0
  73. package/docs-llm/List.md +189 -0
  74. package/docs-llm/Markdown.md +179 -0
  75. package/docs-llm/Menu.md +735 -0
  76. package/docs-llm/Message Bar.md +236 -0
  77. package/docs-llm/Message.md +248 -0
  78. package/docs-llm/Modal.md +443 -0
  79. package/docs-llm/Monogram.md +159 -0
  80. package/docs-llm/Multiselect.md +939 -0
  81. package/docs-llm/Notifications.md +46 -0
  82. package/docs-llm/Number.md +298 -0
  83. package/docs-llm/Paginator.md +395 -0
  84. package/docs-llm/Paragraph.md +148 -0
  85. package/docs-llm/Phone Number.md +254 -0
  86. package/docs-llm/Popover.md +166 -0
  87. package/docs-llm/Progress.md +141 -0
  88. package/docs-llm/Radio Bar.md +303 -0
  89. package/docs-llm/Radio List.md +350 -0
  90. package/docs-llm/Resize.md +362 -0
  91. package/docs-llm/Screen Reader Content.md +73 -0
  92. package/docs-llm/Scroll Container Context.md +155 -0
  93. package/docs-llm/Scroll.md +152 -0
  94. package/docs-llm/Search.md +381 -0
  95. package/docs-llm/Select.md +985 -0
  96. package/docs-llm/Side Panel.md +777 -0
  97. package/docs-llm/Slider.md +339 -0
  98. package/docs-llm/Sliding Panels.md +340 -0
  99. package/docs-llm/Split Button.md +295 -0
  100. package/docs-llm/Static Content.md +90 -0
  101. package/docs-llm/Step Bar.md +292 -0
  102. package/docs-llm/Switch.md +268 -0
  103. package/docs-llm/Tab Bar.md +439 -0
  104. package/docs-llm/Tab Layout.md +398 -0
  105. package/docs-llm/Table.md +2642 -0
  106. package/docs-llm/Text Area.md +253 -0
  107. package/docs-llm/Text.md +339 -0
  108. package/docs-llm/Tooltip.md +325 -0
  109. package/docs-llm/Transition Open.md +406 -0
  110. package/docs-llm/Tree.md +591 -0
  111. package/docs-llm/Typography.md +125 -0
  112. package/docs-llm/Wait Spinner.md +121 -0
  113. package/docs-llm/llms.txt +101 -0
  114. package/package.json +6 -5
  115. package/types/src/Box/Box.d.ts +2 -10
  116. package/types/src/Drawer/Body.d.ts +17 -0
  117. package/types/src/Drawer/Drawer.d.ts +114 -0
  118. package/types/src/Drawer/DrawerContext.d.ts +11 -0
  119. package/types/src/Drawer/Footer.d.ts +25 -0
  120. package/types/src/Drawer/Header.d.ts +41 -0
  121. package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
  122. package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
  123. package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
  124. package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
  125. package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
  126. package/types/src/Drawer/index.d.ts +2 -0
  127. package/types/src/JSONTree/JSONTree.d.ts +12 -5
  128. package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
  129. package/types/src/Menu/Item.d.ts +2 -1
  130. package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
  131. package/types/src/Modal/Modal.d.ts +1 -2
  132. package/types/src/Multiselect/Compact.d.ts +8 -3
  133. package/types/src/Multiselect/Multiselect.d.ts +8 -3
  134. package/types/src/Multiselect/Normal.d.ts +8 -3
  135. package/types/src/Multiselect/Option.d.ts +6 -3
  136. package/types/src/Multiselect/docs/examples/Disabled.d.ts +1 -0
  137. package/types/src/Select/Option.d.ts +6 -3
  138. package/types/src/Select/Select.d.ts +8 -5
  139. package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
  140. package/types/src/SelectBase/OptionBase.d.ts +6 -3
  141. package/types/src/SelectBase/SelectBase.d.ts +8 -3
  142. package/types/src/SidePanel/SidePanel.d.ts +43 -2
  143. package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
  144. package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
  145. package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
  146. package/types/src/useKeyPress/index.d.ts +9 -2
  147. package/types/src/useOnClickOutside/index.d.ts +2 -0
  148. package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
  149. package/useKeyPress.js +23 -18
  150. package/useOnClickOutside.d.ts +2 -0
  151. package/useOnClickOutside.js +79 -0
  152. package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
@@ -0,0 +1,472 @@
1
+ # Dropdown
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Dropdown
7
+
8
+ A Dropdown can contain any content. The content must constrain its own width.
9
+
10
+ ```typescript
11
+ import React from 'react';
12
+
13
+ import Button from '@splunk/react-ui/Button';
14
+ import Dropdown from '@splunk/react-ui/Dropdown';
15
+
16
+
17
+ function Basic() {
18
+ const toggle = <Button label="Open dropdown" />;
19
+
20
+ return (
21
+ <Dropdown toggle={toggle} retainFocus>
22
+ <div style={{ padding: '20px', maxWidth: '300px' }}>
23
+ This is the content of the dropdown. You can customize it as needed.
24
+ </div>
25
+ </Dropdown>
26
+ );
27
+ }
28
+
29
+ export default Basic;
30
+ ```
31
+
32
+
33
+
34
+ ### Dropdown menu
35
+
36
+ ```typescript
37
+ import React from 'react';
38
+
39
+ import Button from '@splunk/react-ui/Button';
40
+ import Dropdown from '@splunk/react-ui/Dropdown';
41
+ import Menu from '@splunk/react-ui/Menu';
42
+
43
+
44
+ function BasicMenu() {
45
+ const toggle = <Button label="Direction" isMenu />;
46
+
47
+ return (
48
+ <Dropdown toggle={toggle}>
49
+ <Menu style={{ width: 120 }}>
50
+ <Menu.Item>Up</Menu.Item>
51
+ <Menu.Item>Down</Menu.Item>
52
+ <Menu.Item>Left</Menu.Item>
53
+ <Menu.Item>Right</Menu.Item>
54
+ <Menu.Divider />
55
+ <Menu.Item to="n">North</Menu.Item>
56
+ <Menu.Item to="s">South</Menu.Item>
57
+ <Menu.Item to="w">West</Menu.Item>
58
+ <Menu.Item to="e">East</Menu.Item>
59
+ </Menu>
60
+ </Dropdown>
61
+ );
62
+ }
63
+
64
+ export default BasicMenu;
65
+ ```
66
+
67
+
68
+
69
+ ### Dropdown submenu
70
+
71
+ ```typescript
72
+ import React from 'react';
73
+
74
+ import ChevronLeft from '@splunk/react-icons/ChevronLeft';
75
+ import EnterpriseChevronLeft from '@splunk/react-icons/enterprise/ChevronLeft';
76
+ import Button from '@splunk/react-ui/Button';
77
+ import Dropdown, { DropdownPossibleCloseReason } from '@splunk/react-ui/Dropdown';
78
+ import Menu from '@splunk/react-ui/Menu';
79
+ import SlidingPanels from '@splunk/react-ui/SlidingPanels';
80
+ import { useSplunkTheme } from '@splunk/themes';
81
+
82
+
83
+ function Submenu() {
84
+ const [transition, setTransition] = React.useState<'forward' | 'backward' | undefined>(
85
+ 'forward'
86
+ );
87
+ const [activePanelId, setActivePanelId] = React.useState('one');
88
+
89
+ const goBackward = () => {
90
+ setActivePanelId(activePanelId === 'one' ? 'two' : 'one');
91
+ setTransition('backward');
92
+ };
93
+
94
+ const goForward = () => {
95
+ setActivePanelId(activePanelId === 'one' ? 'two' : 'one');
96
+ setTransition('forward');
97
+ };
98
+
99
+ const toggle = <Button isMenu />;
100
+ const closeReasons: DropdownPossibleCloseReason[] = [
101
+ 'clickAway',
102
+ 'escapeKey',
103
+ 'offScreen',
104
+ 'toggleClick',
105
+ ];
106
+
107
+ const { isEnterprise } = useSplunkTheme();
108
+
109
+ return (
110
+ <Dropdown closeReasons={closeReasons} toggle={toggle}>
111
+ <SlidingPanels activePanelId={activePanelId} transition={transition}>
112
+ <SlidingPanels.Panel key="one" panelId="one">
113
+ <Menu style={{ width: 160 }}>
114
+ <Menu.Item hasSubmenu onClick={goForward}>
115
+ Category 1
116
+ </Menu.Item>
117
+ <Menu.Item hasSubmenu onClick={goForward}>
118
+ Category 2
119
+ </Menu.Item>
120
+ <Menu.Item hasSubmenu onClick={goForward}>
121
+ Category 3
122
+ </Menu.Item>
123
+ <Menu.Item hasSubmenu onClick={goForward}>
124
+ Category 4
125
+ </Menu.Item>
126
+ <Menu.Item hasSubmenu onClick={goForward}>
127
+ Category 5
128
+ </Menu.Item>
129
+ <Menu.Item hasSubmenu onClick={goForward}>
130
+ Category 6
131
+ </Menu.Item>
132
+ <Menu.Item hasSubmenu onClick={goForward}>
133
+ Category 7
134
+ </Menu.Item>
135
+ <Menu.Item hasSubmenu onClick={goForward}>
136
+ Category 8
137
+ </Menu.Item>
138
+ </Menu>
139
+ </SlidingPanels.Panel>
140
+ <SlidingPanels.Panel key="two" panelId="two">
141
+ <Menu style={{ width: 160 }}>
142
+ <Menu.Item
143
+ startAdornment={
144
+ isEnterprise ? (
145
+ <EnterpriseChevronLeft
146
+ screenReaderText={null}
147
+ hideDefaultTooltip
148
+ />
149
+ ) : (
150
+ <ChevronLeft />
151
+ )
152
+ }
153
+ onClick={goBackward}
154
+ >
155
+ Back
156
+ </Menu.Item>
157
+ <Menu.Divider />
158
+ <Menu.Item>Option 1</Menu.Item>
159
+ <Menu.Item>Option 2</Menu.Item>
160
+ <Menu.Item>Option 3</Menu.Item>
161
+ <Menu.Item>Option 4</Menu.Item>
162
+ <Menu.Item>Option 5</Menu.Item>
163
+ <Menu.Item>Option 6</Menu.Item>
164
+ <Menu.Item>Option 7</Menu.Item>
165
+ </Menu>
166
+ </SlidingPanels.Panel>
167
+ </SlidingPanels>
168
+ </Dropdown>
169
+ );
170
+ }
171
+
172
+ export default Submenu;
173
+ ```
174
+
175
+
176
+
177
+ ### Dropdown scrolling menu
178
+
179
+ If a Menu contains many items, you can let the Menu scroll by setting the overflowY and maxHeight style prop.
180
+
181
+ ```typescript
182
+ import React from 'react';
183
+
184
+ import Button from '@splunk/react-ui/Button';
185
+ import Dropdown from '@splunk/react-ui/Dropdown';
186
+ import Menu from '@splunk/react-ui/Menu';
187
+
188
+
189
+ function ScrollingMenu() {
190
+ const toggle = <Button label="Numbers" isMenu />;
191
+
192
+ // Creates 100 menu items from 1 - 100
193
+ const items: React.ReactElement[] = [];
194
+ for (let index = 0; index < 100; index += 1) {
195
+ items.push(<Menu.Item key={`menu-item-${index}`}>{index + 1}</Menu.Item>);
196
+ }
197
+
198
+
199
+ return (
200
+ <Dropdown toggle={toggle}>
201
+ {({ maxHeight }) => (
202
+ <Menu
203
+ stopScrollPropagation
204
+ style={{
205
+ maxHeight: maxHeight ?? undefined,
206
+ overflowY: 'auto',
207
+ }}
208
+ >
209
+ {items}
210
+ </Menu>
211
+ )}
212
+ </Dropdown>
213
+ );
214
+ }
215
+
216
+ export default ScrollingMenu;
217
+ ```
218
+
219
+
220
+
221
+ ### Dropdown dialog
222
+
223
+ By default, a Dropdown dialog box does not close on click. Set the closeReasons prop to ignore specific actions.
224
+
225
+ ```typescript
226
+ import React from 'react';
227
+
228
+ import { without } from 'lodash';
229
+
230
+ import Button from '@splunk/react-ui/Button';
231
+ import ControlGroup from '@splunk/react-ui/ControlGroup';
232
+ import Dropdown from '@splunk/react-ui/Dropdown';
233
+ import Multiselect from '@splunk/react-ui/Multiselect';
234
+ import Select from '@splunk/react-ui/Select';
235
+ import Text from '@splunk/react-ui/Text';
236
+
237
+
238
+ function Dialog() {
239
+ const toggle = <Button label="Open dropdown dialog" isMenu />;
240
+
241
+ const closeReasons = without(Dropdown.possibleCloseReasons, 'contentClick');
242
+
243
+ return (
244
+ <Dropdown toggle={toggle} retainFocus closeReasons={closeReasons}>
245
+ <div style={{ padding: 20, width: 300 }}>
246
+ <ControlGroup label="First Name">
247
+ <Text />
248
+ </ControlGroup>
249
+ <ControlGroup
250
+ label="Last Name"
251
+ controlsLayout="fillJoin"
252
+ tooltip="More information..."
253
+ >
254
+ <Text />
255
+ </ControlGroup>
256
+ <ControlGroup label="Office">
257
+ <Select defaultValue="sf">
258
+ <Select.Option label="San Francisco" value="sf" />
259
+ <Select.Option label="Cupertino" value="cu" />
260
+ </Select>
261
+ </ControlGroup>
262
+ <ControlGroup label="Office Multiselect">
263
+ <Multiselect defaultValue={['sf']}>
264
+ <Multiselect.Option label="San Francisco" value="sf" />
265
+ <Multiselect.Option label="Cupertino" value="cu" />
266
+ </Multiselect>
267
+ </ControlGroup>
268
+ </div>
269
+ </Dropdown>
270
+ );
271
+ }
272
+
273
+ export default Dialog;
274
+ ```
275
+
276
+
277
+
278
+ ### Toggle with tooltip
279
+
280
+ ```typescript
281
+ import React from 'react';
282
+
283
+ import ArrowCounterClockwise from '@splunk/react-icons/ArrowCounterClockwise';
284
+ import Button, { ButtonPropsBase } from '@splunk/react-ui/Button';
285
+ import Dropdown from '@splunk/react-ui/Dropdown';
286
+ import Menu from '@splunk/react-ui/Menu';
287
+ import Tooltip from '@splunk/react-ui/Tooltip';
288
+
289
+ const TooltipButton = React.forwardRef<HTMLButtonElement, ButtonPropsBase>(
290
+ ({ label, ...otherProps }, ref) => {
291
+ return (
292
+ <Tooltip content={label}>
293
+ <Button {...otherProps} elementRef={ref} />
294
+ </Tooltip>
295
+ );
296
+ }
297
+ );
298
+
299
+
300
+ function TooltipButtonToggle() {
301
+ const tooltipButtonToggle = (
302
+ <TooltipButton label="direction" icon={<ArrowCounterClockwise />} isMenu />
303
+ );
304
+
305
+ return (
306
+ <Dropdown toggle={tooltipButtonToggle}>
307
+ <Menu style={{ width: 120 }}>
308
+ <Menu.Item>Up</Menu.Item>
309
+ <Menu.Item>Down</Menu.Item>
310
+ <Menu.Item>Left</Menu.Item>
311
+ <Menu.Item>Right</Menu.Item>
312
+ </Menu>
313
+ </Dropdown>
314
+ );
315
+ }
316
+
317
+ export default TooltipButtonToggle;
318
+ ```
319
+
320
+
321
+
322
+ ### Customized scroll container
323
+
324
+ By default, a Dropdown moves with the window scroll. Use Scroll Container Provider when you want a Dropdown to move within a different scroll container.
325
+
326
+ ```typescript
327
+ import React, { useCallback, useState } from 'react';
328
+
329
+ import Button from '@splunk/react-ui/Button';
330
+ import Dropdown from '@splunk/react-ui/Dropdown';
331
+ import P from '@splunk/react-ui/Paragraph';
332
+ import { ScrollContainerProvider } from '@splunk/react-ui/ScrollContainerContext';
333
+
334
+
335
+ function ScrollContainer() {
336
+ const [scrollContainer, setScrollContainer] = useState<HTMLDivElement>();
337
+ const scrollContainerRef = useCallback((el: HTMLDivElement) => {
338
+ setScrollContainer(el);
339
+ }, []);
340
+
341
+ const toggle = <Button label="Open dropdown in scroll container" />;
342
+ return (
343
+ <div
344
+ ref={scrollContainerRef}
345
+ style={{
346
+ border: '1px dashed #ccc',
347
+ height: '100px',
348
+ width: '500px',
349
+ margin: '20px 20px 0px 0px',
350
+ padding: '30px 20px 10px 20px',
351
+ overflow: 'scroll',
352
+ }}
353
+ >
354
+ <ScrollContainerProvider value={scrollContainer}>
355
+ <Dropdown retainFocus toggle={toggle}>
356
+ <P style={{ padding: 20, maxWidth: 300 }}>
357
+ This dropdown moves with the custom scroll container.
358
+ </P>
359
+ </Dropdown>
360
+ <P style={{ marginTop: 20 }}>More content to demonstrate scrolling.</P>
361
+ <P>Additional content for demonstration.</P>
362
+ </ScrollContainerProvider>
363
+ </div>
364
+ );
365
+ }
366
+
367
+ export default ScrollContainer;
368
+ ```
369
+
370
+
371
+
372
+ ### Controlled
373
+
374
+ By default, Dropdown handles its own state. If you want more granular control of the events that open or close a Dropdown, use it as a [controlled component](https://reactjs.org/docs/forms.html#controlled-components). When you use Dropdown as a controlled component, the parent component manages the state of the Dropdown. Note that either the Dropdown or its parent handles its state, never both. See the onRequestClose and onRequestOpen callbacks for hooks you can use to manage state. This examples uses toggleClick and offScreen. It receives but ignores all other close actions.
375
+
376
+ ```typescript
377
+ import React, { useState } from 'react';
378
+
379
+ import Button from '@splunk/react-ui/Button';
380
+ import Dropdown, {
381
+ DropdownPossibleCloseReason,
382
+ DropdownRequestCloseHandler,
383
+ } from '@splunk/react-ui/Dropdown';
384
+ import Menu from '@splunk/react-ui/Menu';
385
+ import P from '@splunk/react-ui/Paragraph';
386
+
387
+
388
+ function ControlledDropdown() {
389
+ const [open, setOpen] = useState(false);
390
+ const [closeReason, setCloseReason] = useState<DropdownPossibleCloseReason>();
391
+
392
+ const handleRequestClose: DropdownRequestCloseHandler = ({ reason }) => {
393
+ setCloseReason(reason);
394
+ setOpen(!(reason === 'toggleClick' || reason === 'offScreen'));
395
+ };
396
+
397
+ const handleRequestOpen = () => {
398
+ setOpen(true);
399
+ };
400
+
401
+ const toggle = <Button label="Direction" isMenu />;
402
+
403
+ return (
404
+ <>
405
+ <P>
406
+ The last call to onRequestClose provided the reason:{' '}
407
+ {closeReason ?? 'No close requests yet'}
408
+ </P>
409
+ <Dropdown
410
+ open={open}
411
+ onRequestClose={handleRequestClose}
412
+ onRequestOpen={handleRequestOpen}
413
+ toggle={toggle}
414
+ >
415
+ <Menu style={{ width: 120 }}>
416
+ <Menu.Item>Up</Menu.Item>
417
+ <Menu.Item>Down</Menu.Item>
418
+ <Menu.Item>Left</Menu.Item>
419
+ <Menu.Item>Right</Menu.Item>
420
+ </Menu>
421
+ </Dropdown>
422
+ </>
423
+ );
424
+ }
425
+
426
+ export default ControlledDropdown;
427
+ ```
428
+
429
+
430
+
431
+
432
+ ## API
433
+
434
+
435
+ ### Dropdown API
436
+
437
+ #### Props
438
+
439
+ | Name | Type | Required | Default | Description |
440
+ |------|------|------|------|------|
441
+ | canCoverAnchor | boolean | no | true | Enables the `Dropdown` to be rendered over the toggle if there isn't enough room to render it in a direction. |
442
+ | children | React.ReactNode \| DropdownChildrenRenderer | no | | The content of the `Dropdown`. If a function is provided, it is invoked with an object containing `anchorHeight`, `anchorWidth`, `maxHeight`, `maxWidth`, and `placement`, and is expected to return renderable content. |
443
+ | closeReasons | DropdownPossibleCloseReason[] | no | [ 'clickAway', 'contentClick', 'escapeKey', 'offScreen', 'tabKey', 'toggleClick', ] | An array of reasons for which this `Dropdown` closes. |
444
+ | defaultPlacement | DropdownPlacement | no | 'below' | The default placement of the `Dropdown`. It might be rendered in a different direction depending on the space available and the `repositionMode`. |
445
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
446
+ | focusToggleReasons | DropdownPossibleCloseReason[] | no | [ 'contentClick', 'escapeKey', 'tabKey', 'toggleClick', ] | An array of reasons for which to set focus on the toggle. Only the subset of `closeReasons` is honored. When `Menu.Items` open a Modal or other dialog, it might be necessary to remove the 'contentClick' reason to allow focus to be passed to the dialog. |
447
+ | inputId | string | no | | An id for the input, which may be necessary for accessibility, such as for aria attributes. |
448
+ | onRequestClose | DropdownRequestCloseHandler | no | | A callback function invoked with a data object containing the event, if applicable, and a reason for the close request. |
449
+ | onRequestOpen | DropdownRequestOpenHandler | no | | A callback function invoked with a data object containing the event. |
450
+ | open | boolean | no | | If an open prop is provided, this component behaves as a [controlled component](https://reactjs.org/docs/forms.html#controlled-components). The consumer is responsible for handling the open/close state. If no open prop is provided, the component handles the open/close state internally. |
451
+ | repositionMode | 'none' \| 'flip' \| 'any' | no | 'flip' | See `repositionMode` on `Popover` for details. |
452
+ | retainFocus | boolean | no | false | Keeps focus within the Popover while open. Only use this for inputs used in a form control. Do not use this when the Dropdown contains a Menu because Menu handles its own focus. |
453
+ | takeFocus | boolean | no | true | When true, the Popover automatically takes focus when 'open' changes to `true`. Disable this for a Popover that has shows on hover, such as a tooltip. |
454
+ | toggle | DropdownToggleElement | yes | | A toggle, such as a button or equivalent component that accepts `ref`, must be passed. `aria-haspopup`, `aria-expanded`, and `aria-controls` attributes are applied to the toggle to support accessibility. The result of the `ref` placed on the toggle must be an instance of `HTMLElement`. Results that are instances of class components are not supported. Also see ["Forwarding Refs"](https://reactjs.org/docs/forwarding-refs.html). |
455
+
456
+ #### Types
457
+
458
+ | Name | Type | Description |
459
+ |------|------|------|
460
+ | DropdownChildrenRenderer | (data: { anchorHeight: number \| null; anchorWidth: number \| null; maxHeight: number \| null; maxWidth: number \| null; placement: DropdownPlacementStatus \| null; toggleId?: string; }) => React.ReactNode | |
461
+ | DropdownPlacement | 'above' \| 'below' \| 'left' \| 'right' \| 'vertical' \| 'horizontal' | |
462
+ | DropdownPlacementStatus | 'above' \| 'below' \| 'left' \| 'right' \| 'misaligned' | |
463
+ | DropdownPossibleCloseReason | \| 'clickAway' \| 'contentClick' \| 'escapeKey' \| 'offScreen' \| 'tabKey' \| 'toggleClick' | |
464
+ | DropdownPossibleOpenReason | 'toggleClick' \| 'toggleKeydown' | |
465
+ | DropdownRequestCloseHandler | (data: { event?: React.MouseEvent<HTMLElement> \| MouseEvent \| KeyboardEvent \| TouchEvent; reason: DropdownPossibleCloseReason; }) => void | |
466
+ | DropdownRequestOpenHandler | ( event: React.MouseEvent<HTMLElement> \| React.KeyboardEvent<HTMLElement>, data: { reason: DropdownPossibleOpenReason } ) => void | |
467
+ | DropdownToggleElement | React.ReactElement< React.HTMLAttributes<HTMLElement> & { 'data-test-popover-id'?: string; 'data-test'?: string; ref?: React.Ref<HTMLElement \| null>; } > | |
468
+
469
+
470
+
471
+
472
+