@splunk/react-ui 5.7.1 → 5.8.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 (138) hide show
  1. package/Accordion.js +6 -6
  2. package/Box.js +83 -34
  3. package/CHANGELOG.md +29 -0
  4. package/CollapsiblePanel.js +11 -11
  5. package/ComboBox.js +31 -27
  6. package/ControlGroup.js +92 -91
  7. package/DefinitionList.js +9 -9
  8. package/Drawer.d.ts +2 -0
  9. package/Drawer.js +679 -0
  10. package/DualListbox.js +1 -1
  11. package/JSONTree.js +73 -72
  12. package/Link.js +2 -2
  13. package/MIGRATION.md +10 -0
  14. package/Menu.js +338 -240
  15. package/Modal.js +127 -109
  16. package/Multiselect.js +437 -351
  17. package/Paginator.js +14 -12
  18. package/Popover.js +4 -1
  19. package/README.md +11 -0
  20. package/RadioBar.js +1 -1
  21. package/Search.js +103 -88
  22. package/Select.js +42 -40
  23. package/SelectBase.js +374 -328
  24. package/SidePanel.js +346 -167
  25. package/SlidingPanels.js +11 -11
  26. package/StepBar.js +7 -7
  27. package/Switch.js +5 -5
  28. package/Text.js +24 -24
  29. package/TextArea.js +7 -7
  30. package/TransitionOpen.js +188 -169
  31. package/docs-llm/Accordion.md +267 -0
  32. package/docs-llm/Anchor Menu.md +115 -0
  33. package/docs-llm/Anchor.md +54 -0
  34. package/docs-llm/AnimationToggle.md +254 -0
  35. package/docs-llm/Avatar.md +298 -0
  36. package/docs-llm/Badge.md +212 -0
  37. package/docs-llm/Breadcrumbs.md +306 -0
  38. package/docs-llm/Button Group.md +53 -0
  39. package/docs-llm/Button.md +361 -0
  40. package/docs-llm/Card Layout.md +286 -0
  41. package/docs-llm/Card.md +619 -0
  42. package/docs-llm/Checkbox.md +218 -0
  43. package/docs-llm/Chip.md +291 -0
  44. package/docs-llm/Clickable.md +160 -0
  45. package/docs-llm/Code.md +292 -0
  46. package/docs-llm/Collapsible Panel.md +744 -0
  47. package/docs-llm/Color.md +253 -0
  48. package/docs-llm/Column Layout.md +391 -0
  49. package/docs-llm/Combo Box.md +540 -0
  50. package/docs-llm/Control Group.md +594 -0
  51. package/docs-llm/Date.md +270 -0
  52. package/docs-llm/Definition List.md +278 -0
  53. package/docs-llm/Divider.md +216 -0
  54. package/docs-llm/Drawer.md +414 -0
  55. package/docs-llm/Dropdown.md +472 -0
  56. package/docs-llm/Dual Listbox.md +325 -0
  57. package/docs-llm/File.md +653 -0
  58. package/docs-llm/Form Rows.md +374 -0
  59. package/docs-llm/Heading.md +179 -0
  60. package/docs-llm/Image.md +109 -0
  61. package/docs-llm/JSON Tree.md +260 -0
  62. package/docs-llm/Layer.md +74 -0
  63. package/docs-llm/Layout.md +50 -0
  64. package/docs-llm/Link.md +318 -0
  65. package/docs-llm/List.md +189 -0
  66. package/docs-llm/Markdown.md +179 -0
  67. package/docs-llm/Menu.md +735 -0
  68. package/docs-llm/Message Bar.md +236 -0
  69. package/docs-llm/Message.md +248 -0
  70. package/docs-llm/Modal.md +443 -0
  71. package/docs-llm/Monogram.md +159 -0
  72. package/docs-llm/Multiselect.md +937 -0
  73. package/docs-llm/Number.md +298 -0
  74. package/docs-llm/Paginator.md +395 -0
  75. package/docs-llm/Paragraph.md +148 -0
  76. package/docs-llm/Phone Number.md +254 -0
  77. package/docs-llm/Popover.md +166 -0
  78. package/docs-llm/Progress.md +141 -0
  79. package/docs-llm/Radio Bar.md +303 -0
  80. package/docs-llm/Radio List.md +350 -0
  81. package/docs-llm/Resize.md +362 -0
  82. package/docs-llm/Screen Reader Content.md +73 -0
  83. package/docs-llm/Scroll Container Context.md +155 -0
  84. package/docs-llm/Scroll.md +152 -0
  85. package/docs-llm/Search.md +381 -0
  86. package/docs-llm/Select.md +985 -0
  87. package/docs-llm/Side Panel.md +777 -0
  88. package/docs-llm/Slider.md +339 -0
  89. package/docs-llm/Sliding Panels.md +340 -0
  90. package/docs-llm/Split Button.md +295 -0
  91. package/docs-llm/Static Content.md +90 -0
  92. package/docs-llm/Step Bar.md +292 -0
  93. package/docs-llm/Switch.md +268 -0
  94. package/docs-llm/Tab Bar.md +439 -0
  95. package/docs-llm/Tab Layout.md +398 -0
  96. package/docs-llm/Table.md +2642 -0
  97. package/docs-llm/Text Area.md +253 -0
  98. package/docs-llm/Text.md +339 -0
  99. package/docs-llm/Tooltip.md +325 -0
  100. package/docs-llm/Transition Open.md +406 -0
  101. package/docs-llm/Tree.md +586 -0
  102. package/docs-llm/Typography.md +125 -0
  103. package/docs-llm/Wait Spinner.md +121 -0
  104. package/docs-llm/llms.txt +97 -0
  105. package/package.json +6 -5
  106. package/types/src/Box/Box.d.ts +2 -10
  107. package/types/src/Drawer/Body.d.ts +17 -0
  108. package/types/src/Drawer/Drawer.d.ts +114 -0
  109. package/types/src/Drawer/DrawerContext.d.ts +11 -0
  110. package/types/src/Drawer/Footer.d.ts +25 -0
  111. package/types/src/Drawer/Header.d.ts +41 -0
  112. package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
  113. package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
  114. package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
  115. package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
  116. package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
  117. package/types/src/Drawer/index.d.ts +2 -0
  118. package/types/src/JSONTree/JSONTree.d.ts +12 -5
  119. package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
  120. package/types/src/Menu/Item.d.ts +2 -1
  121. package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
  122. package/types/src/Modal/Modal.d.ts +1 -2
  123. package/types/src/Select/Option.d.ts +6 -3
  124. package/types/src/Select/Select.d.ts +8 -5
  125. package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
  126. package/types/src/SelectBase/OptionBase.d.ts +6 -3
  127. package/types/src/SelectBase/SelectBase.d.ts +8 -3
  128. package/types/src/SidePanel/SidePanel.d.ts +43 -2
  129. package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
  130. package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
  131. package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
  132. package/types/src/useKeyPress/index.d.ts +9 -2
  133. package/types/src/useOnClickOutside/index.d.ts +2 -0
  134. package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
  135. package/useKeyPress.js +23 -18
  136. package/useOnClickOutside.d.ts +2 -0
  137. package/useOnClickOutside.js +79 -0
  138. package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
@@ -0,0 +1,325 @@
1
+ # Tooltip
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Tooltip.
7
+
8
+
9
+ ## When to use this component
10
+ - To provide non-essential supporting information for specific elements on a page.
11
+
12
+ ## When to use another component
13
+ <Message appearance="fill" type="warning">
14
+ <Message.Title>
15
+ Information directly on the page is always more inclusive.
16
+ </Message.Title>
17
+ Tooltips have low discoverability and have usability issues on devices without hover or focus interactions. A solution that is available on the page or through help text is more accessible.
18
+ </Message>
19
+
20
+ - If the content is triggered by a user action, a Message is more appropriate.
21
+ - Paragraphs or help text subcomponents remove the need for any user interaction to access the information.
22
+
23
+ ```mermaid
24
+ graph TD
25
+ accDescr: Decision tree that guides on when to use the Tooltip component or something else
26
+ A(Space for the content on the page?) -- Yes --- B(Is the content triggered by an user action?)
27
+ B -- Yes --- C(Message)
28
+ B -- No --- D(Paragraph)
29
+ A -- No --- E(Tooltip)
30
+ ```
31
+
32
+ ### Check out
33
+ - [Message][1]
34
+ - [Paragraph][2]
35
+
36
+ ## Behaviors
37
+
38
+ ### Labels
39
+ To help people understand the meaning of icon-only Buttons, set `contentRelationship="label"` to add a Tooltip.
40
+
41
+ > Image: A pencil icon Button in a hover state with a Tooltip with the label,
42
+
43
+
44
+ ### Information icon
45
+ <Message appearance="fill" type="warning">
46
+ Don't hide essential information behind an icon.
47
+ </Message>
48
+
49
+ An information icon with a hover interaction that displays the tooltip.
50
+
51
+ > Image: The text
52
+
53
+
54
+ ## Usage
55
+
56
+ ### Icon-Only Buttons
57
+ Tooltips aren’t necessary for UI elements that already have labels.
58
+
59
+ > Image: Examples of using Tooltips as labels for Buttons. There are three Buttons: an icon-text
60
+
61
+
62
+ ### Interactive elements
63
+ As tooltips can be activated by hover, additional interactions can be confusing to access.
64
+
65
+ > Image: Examples of using tooltips for an Icon-Text
66
+
67
+
68
+ ### Help text
69
+ To ensure information accessibility and convenience, it's recommended to minimize reliance on tooltips. Tooltips necessitate extra user actions, conceal crucial details, and may obstruct surrounding inputs or content. Instead, using visible help text directly is recommended for clearer and more immediate guidance.
70
+
71
+ > Image: Examples of using tooltips with a Text component. The first example with heart eyes emoji has a Text component labeled
72
+
73
+
74
+ ## Content
75
+ Follow writing best practices outlined in the [UI text style guidelines][3]
76
+
77
+ ### Concise
78
+ Keep the content of tooltips short and to the point, as they are meant to be quick references, not full explanations.
79
+
80
+ > Image: Examples of using a Tooltip as labels for icon-only
81
+
82
+
83
+
84
+ [1]: ./Message
85
+ [2]: ./Paragraph
86
+ [3]: https://docs.splunk.com/Documentation/StyleGuide/current/StyleGuide/UIGuidelines
87
+
88
+
89
+ ## Examples
90
+
91
+
92
+ ### Basic
93
+
94
+ Add additional description to a form control.
95
+
96
+ ```typescript
97
+ import React from 'react';
98
+
99
+ import Text from '@splunk/react-ui/Text';
100
+ import Tooltip from '@splunk/react-ui/Tooltip';
101
+
102
+
103
+ function Basic() {
104
+ return (
105
+ <Tooltip content="I explain the text input">
106
+ <Text />
107
+ </Tooltip>
108
+ );
109
+ }
110
+
111
+ export default Basic;
112
+ ```
113
+
114
+
115
+
116
+ ### Content Relationship
117
+
118
+ Set contentRelationship="label" for icon-only buttons.
119
+
120
+ ```typescript
121
+ import React from 'react';
122
+
123
+ import MoreVertical from '@splunk/react-icons/enterprise/MoreVertical';
124
+ import Button from '@splunk/react-ui/Button';
125
+ import Tooltip from '@splunk/react-ui/Tooltip';
126
+ import { _ } from '@splunk/ui-utils/i18n';
127
+
128
+
129
+ function ContentRelationship() {
130
+ return (
131
+ <Tooltip contentRelationship="label" content={_('Actions')} style={{ margin: '0 10px' }}>
132
+ <Button
133
+ appearance="secondary"
134
+ icon={
135
+ <MoreVertical
136
+ // screenReaderText is added by Tooltip
137
+ screenReaderText={null}
138
+ hideDefaultTooltip
139
+ />
140
+ }
141
+ />
142
+ </Tooltip>
143
+ );
144
+ }
145
+
146
+ export default ContentRelationship;
147
+ ```
148
+
149
+
150
+
151
+ ### Custom Delay
152
+
153
+ Open and close delays can be configured separately. Default delay values differ across themes.
154
+
155
+ ```typescript
156
+ import React from 'react';
157
+
158
+ import Text from '@splunk/react-ui/Text';
159
+ import Tooltip from '@splunk/react-ui/Tooltip';
160
+
161
+
162
+ function CustomDelay() {
163
+ return (
164
+ <div>
165
+ <Tooltip openDelay={1000} closeDelay={1000} content="I explain the form control.">
166
+ <Text />
167
+ </Tooltip>
168
+ </div>
169
+ );
170
+ }
171
+
172
+ export default CustomDelay;
173
+ ```
174
+
175
+
176
+
177
+ ### Controlled
178
+
179
+ Tooltips can also be controlled for more complex use cases.
180
+
181
+ ```typescript
182
+ import React, { Component } from 'react';
183
+
184
+ import P from '@splunk/react-ui/Paragraph';
185
+ import Text from '@splunk/react-ui/Text';
186
+ import Tooltip, {
187
+ TooltipRequestCloseHandler,
188
+ TooltipRequestOpenHandler,
189
+ } from '@splunk/react-ui/Tooltip';
190
+
191
+
192
+ class Controlled extends Component<object, { open: boolean; reason: string }> {
193
+ constructor(props: object) {
194
+ super(props);
195
+
196
+ this.state = {
197
+ open: false,
198
+ reason: 'none',
199
+ };
200
+ }
201
+
202
+ handleRequestOpen: TooltipRequestOpenHandler = (e, { reason }) => {
203
+ this.setState({ reason, open: true });
204
+ };
205
+
206
+ handleRequestClose: TooltipRequestCloseHandler = (e, { reason }) => {
207
+ this.setState({ reason, open: false });
208
+ };
209
+
210
+ render() {
211
+ return (
212
+ <P>
213
+ <Tooltip
214
+ content="I explain the ambiguous control."
215
+ open={this.state.open}
216
+ onRequestOpen={this.handleRequestOpen}
217
+ onRequestClose={this.handleRequestClose}
218
+ >
219
+ <Text />
220
+ </Tooltip>
221
+ <br />
222
+ Received request reason: {this.state.reason}
223
+ </P>
224
+ );
225
+ }
226
+ }
227
+
228
+ export default Controlled;
229
+ ```
230
+
231
+
232
+
233
+ ### Custom Props
234
+
235
+ Use the renderAnchor prop to customize rendering of the anchor element. Make sure that anchor element get assigned the onBlur, onFocus, onClick listeners, the describedBy or labelledBy string props and the elementRef.
236
+
237
+ ```typescript
238
+ import React, { useMemo } from 'react';
239
+
240
+ import P from '@splunk/react-ui/Paragraph';
241
+ import Text from '@splunk/react-ui/Text';
242
+ import Tooltip from '@splunk/react-ui/Tooltip';
243
+ import { createDOMID } from '@splunk/ui-utils/id';
244
+
245
+
246
+ function CustomProps() {
247
+ const descriptionId = useMemo(() => createDOMID(), []);
248
+
249
+ return (
250
+ <div>
251
+ <P id={descriptionId}>Additional explanations for the control</P>
252
+ <Tooltip
253
+ content="I explain the ambiguous control."
254
+ renderAnchor={({ describedBy, ...anchorProps }) => (
255
+ <Text {...anchorProps} describedBy={`${describedBy} ${descriptionId}`} />
256
+ )}
257
+ />
258
+ </div>
259
+ );
260
+ }
261
+
262
+ export default CustomProps;
263
+ ```
264
+
265
+
266
+
267
+ ### Toggletip
268
+
269
+ Tooltip defaults to showing an info button as an anchor to explain the surrounding context. For accessibility, please consider other ways of conveying this information before you decide to use the toggletip.
270
+
271
+ ```typescript
272
+ import React from 'react';
273
+
274
+ import Tooltip from '@splunk/react-ui/Tooltip';
275
+
276
+
277
+ function Toggletip() {
278
+ return <Tooltip content="Longer explanation of what the user is working with" />;
279
+ }
280
+
281
+ export default Toggletip;
282
+ ```
283
+
284
+
285
+
286
+
287
+ ## API
288
+
289
+
290
+ ### Tooltip API
291
+
292
+ The Tooltip component wraps arbitrary content to be displayed when the target element is hovered
293
+ or focused.
294
+
295
+ #### Props
296
+
297
+ | Name | Type | Required | Default | Description |
298
+ |------|------|------|------|------|
299
+ | children | React.ReactNode | no | | Provide a node to replace the default question mark. For accessibility, ensure that the child can take focus, and that it accepts a `describedBy` string prop which it places as `aria-describedby` on the appropriate internal element. |
300
+ | closeDelay | number | no | 300 | Milliseconds to wait before the tooltip closes. |
301
+ | content | React.ReactNode | no | | The content of the tooltip. If the content is falsy and the `open` prop is uncontrolled, the tooltip doesn't display. |
302
+ | contentRelationship | 'description' \| 'label' | no | | Tooltips can define the primary label for controls, for example buttons with only an icon, or they can provide an auxiliary description to supplement a control's primary label. This relationship is conveyed to assistive technologies with either the `aria-labelledby` or `aria-describedby` properties. By default, tooltips are a description for their control and use `aria-describedby`. Set `contentRelationship` to `label` when the Tooltip's content is a primary label for the control. |
303
+ | defaultPlacement | 'above' \| 'below' \| 'left' \| 'right' | no | 'above' | The default placement of the `Tooltip`. It might render in a different location if there is not enough space in the default direction. |
304
+ | elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
305
+ | inline | boolean | no | true | Set inline to `false` when adding a tooltip to a block element. |
306
+ | onRequestClose | TooltipRequestCloseHandler | no | | Callback function fired when the popover is requested to be closed. @param {event} event Can be `null` depending on the reason the tooltip is closing. @param {object} data @param {string} data.reason The reason for the close request. |
307
+ | onRequestOpen | TooltipRequestOpenHandler | no | | Callback function fired when the popover is requested to be opened. @param {event} event @param {object} data @param {string} data.reason The reason for the open request. |
308
+ | open | boolean | no | | Whether or not the tooltip is shown. Setting this value makes the prop controlled. The onRequestClose and onRequestOpen callbacks are usually used. |
309
+ | openDelay | 'primary' \| 'secondary' \| number | no | 'primary' | Milliseconds to wait before the tooltip opens. |
310
+ | pointTo | { x: number; y: number } | no | | Allows the `Tooltip` to point to and align with a different part of the anchor. This prop is forwarded to Popover. See `Popover`'s `pointTo` prop for more information. |
311
+ | renderAnchor | (props: AnchorProps) => React.ReactNode | no | | A function for rendering the element that the tooltip is bound to. If both `renderAnchor` and `children` are passed, `children` will be ignored. The function gets as input props object for the anchor, which contains the necessary event listeners and aria attributes. By default or if `contentRelationship` is passed as `description`, the props object contains keys `aria-describedby` and `describedBy`, but if `contentRelationship` is passed as `label`, `aria-labelledby` and `labelledBy` will be passed instead. @param {object} props @param {function} props.onFocus @param {function} props.onBlur @param {function} props.onClick @param {string} props['aria-describedby'] @param {string} props.describedBy @param {string} props['aria-labelledby'] @param {string} props.labelledBy @param {"toggle"} props.['data-test'] @param {function} props.elementRef |
312
+
313
+ #### Types
314
+
315
+ | Name | Type | Description |
316
+ |------|------|------|
317
+ | TooltipPossibleCloseReason | \| 'blurToggle' \| 'clickAway' \| 'escapeKey' \| 'mouseLeaveHitArea' \| 'mouseLeavePopover' \| 'mouseLeaveToggle' \| 'mouseStopHitArea' \| 'offScreen' \| 'tabKey' \| 'toggleClick' | |
318
+ | TooltipPossibleOpenReason | \| 'focusToggle' \| 'mouseEnterPopover' \| 'mouseEnterToggle' \| 'mouseEnterHitArea' | |
319
+ | TooltipRequestCloseHandler | ( event: React.FocusEvent<HTMLSpanElement> \| React.MouseEvent \| MouseEvent \| null, data: { reason: TooltipPossibleCloseReason } ) => void | |
320
+ | TooltipRequestOpenHandler | ( event: React.FocusEvent<HTMLSpanElement> \| MouseEvent, data: { reason: TooltipPossibleOpenReason } ) => void | |
321
+
322
+
323
+
324
+
325
+