@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,254 @@
1
+ # Phone Number
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Phone Number component.
7
+
8
+
9
+ <Message appearance="fill" type="info">
10
+ <div>All data entry components should be wrapped in a [Control Group](ControlGroup) to provide a label, error states, and help or error text, ensuring an accessible experience for all users.</div>
11
+ </Message>
12
+
13
+ ## When to use this component
14
+ - When collecting phone numbers from users
15
+ - When forms or pages require a validated phone number input
16
+
17
+ ## When to use another component
18
+ - If the input doesn't require formatting, a country code, or is not specifically for phone numbers, consider using Text
19
+
20
+ ```mermaid
21
+ graph TD
22
+ accDescr: Decision tree that guides on when to use the Phone Number component or something else
23
+ A(Do you need to collect a phone number?) -- Yes --- B(Use Phone Number)
24
+ A -- No --- C(Is the input freeform text?)
25
+ C -- Yes --- D(Use Text)
26
+ C -- No --- E(Use Select)
27
+ ```
28
+
29
+ ### Check out
30
+ - [Select][1]
31
+ - [Text][2]
32
+
33
+ ## Behaviors
34
+
35
+ ### Validation
36
+ Validates phone number format and length based on the selected country.
37
+ Use <Link to="ControlGroup">Control Group</Link> to display validation results.
38
+ > Image: Example of phone number validation.
39
+
40
+
41
+ ### Locale
42
+ Defaults the country code and formatting based on the user’s locale.
43
+ > Image: Example of locale-based default.
44
+
45
+
46
+ ### Searchable dropdown
47
+ Allows users to filter the country code list by typing either a country name or a dial code.
48
+ > Image: Examples of filtering country codes in the dropdown.
49
+
50
+
51
+ ## Usage
52
+
53
+ ### Use clear and visible labels
54
+ Use a visible label like “Phone Number” to clearly describe the input. Avoid using placeholder phone numbers as a substitute for labeling to maintain accessibility.
55
+ > Image: Examples of Phone Number labeling. The first example with heart eyes shows a clearly labeled input. The second example with a grimacing face shows a placeholder used instead of a label, reducing accessibility.
56
+
57
+
58
+ ### Match input width to phone number length
59
+ Match the width of the input to the expected phone number length. Avoid stretching the component across the full page or making it too short to view the full value at a glance.
60
+ > Image: Examples of Phone Number input width. The first example with heart eyes shows a field sized to match a typical phone number. The second example with a grimacing face shows an overly wide field that reduces readability.
61
+
62
+
63
+ [1]: ./Select
64
+ [2]: ./Text
65
+
66
+
67
+
68
+ ## Examples
69
+
70
+
71
+ ### Controlled
72
+
73
+ Phone Number requires a `value` prop and an `onChange` callback to update the value prop for most use cases.
74
+
75
+ ```typescript
76
+ import React, { useState } from 'react';
77
+
78
+ import PhoneNumber, { PhoneNumberChangeHandler } from '@splunk/react-ui/PhoneNumber';
79
+
80
+
81
+ const Controlled = () => {
82
+ const [value, setValue] = useState('2345678910');
83
+
84
+ const handleChange: PhoneNumberChangeHandler = (e, { value: newValue }) => {
85
+ setValue(newValue);
86
+ };
87
+
88
+ return <PhoneNumber value={value} onChange={handleChange} />;
89
+ };
90
+
91
+ export default Controlled;
92
+ ```
93
+
94
+
95
+
96
+ ### Uncontrolled
97
+
98
+ Alternatively, Phone Number can be uncontrolled and optionally provided a `defaultValue`. The `onChange` callback still fires. The `value` prop cannot be set or updated externally.
99
+
100
+ ```typescript
101
+ import React from 'react';
102
+
103
+ import PhoneNumber from '@splunk/react-ui/PhoneNumber';
104
+
105
+
106
+ function Uncontrolled() {
107
+ return <PhoneNumber defaultValue="2345678910" />;
108
+ }
109
+
110
+ export default Uncontrolled;
111
+ ```
112
+
113
+
114
+
115
+ ### Default Country
116
+
117
+ Phone Number can have a different default country set.
118
+
119
+ ```typescript
120
+ import React, { useState } from 'react';
121
+
122
+ import PhoneNumber, { PhoneNumberChangeHandler } from '@splunk/react-ui/PhoneNumber';
123
+
124
+
125
+ const DefaultCountry = () => {
126
+ const [value, setValue] = useState('2345678910');
127
+
128
+ const handleChange: PhoneNumberChangeHandler = (e, { value: newValue }) => {
129
+ setValue(newValue);
130
+ };
131
+
132
+ return <PhoneNumber defaultCountry="CA" value={value} onChange={handleChange} />;
133
+ };
134
+
135
+ export default DefaultCountry;
136
+ ```
137
+
138
+
139
+
140
+ ### Inline
141
+
142
+ The `inline` prop will render the component inline at a consistent width with other inputs.
143
+
144
+ ```typescript
145
+ import React, { useState } from 'react';
146
+
147
+ import PhoneNumber, { PhoneNumberChangeHandler } from '@splunk/react-ui/PhoneNumber';
148
+
149
+
150
+ const Inline = () => {
151
+ const [value, setValue] = useState('2345678910');
152
+
153
+ const handleChange: PhoneNumberChangeHandler = (e, { value: newValue }) => {
154
+ setValue(newValue);
155
+ };
156
+
157
+ return <PhoneNumber inline value={value} onChange={handleChange} />;
158
+ };
159
+
160
+ export default Inline;
161
+ ```
162
+
163
+
164
+
165
+ ### Error
166
+
167
+ ```typescript
168
+ import React, { useState } from 'react';
169
+
170
+ import PhoneNumber, { PhoneNumberChangeHandler } from '@splunk/react-ui/PhoneNumber';
171
+
172
+
173
+ const Error = () => {
174
+ const [value, setValue] = useState('2345678910');
175
+
176
+ const handleChange: PhoneNumberChangeHandler = (e, { value: newValue }) => {
177
+ setValue(newValue);
178
+ };
179
+
180
+ return <PhoneNumber error value={value} onChange={handleChange} />;
181
+ };
182
+
183
+ export default Error;
184
+ ```
185
+
186
+
187
+
188
+ ### Disabled
189
+
190
+ ```typescript
191
+ import React, { useState } from 'react';
192
+
193
+ import PhoneNumber, { PhoneNumberChangeHandler } from '@splunk/react-ui/PhoneNumber';
194
+
195
+
196
+ const Disabled = () => {
197
+ const [value, setValue] = useState('2345678910');
198
+
199
+ const handleChange: PhoneNumberChangeHandler = (e, { value: newValue }) => {
200
+ setValue(newValue);
201
+ };
202
+
203
+ return <PhoneNumber disabled value={value} onChange={handleChange} />;
204
+ };
205
+
206
+ export default Disabled;
207
+ ```
208
+
209
+
210
+
211
+
212
+ ## API
213
+
214
+
215
+ ### PhoneNumber API
216
+
217
+ #### Props
218
+
219
+ | Name | Type | Required | Default | Description |
220
+ |------|------|------|------|------|
221
+ | append | boolean | no | | Append removes rounded corners and the border from the right side. |
222
+ | canClear | boolean | no | true | Include an "X" button to clear the value. |
223
+ | defaultCountry | string | no | | The iso2 country code to use for the phone number input. |
224
+ | defaultValue | string | no | | Set this property instead of value to make the value uncontrolled. |
225
+ | describedBy | string | no | | The id of the description. When placed in a ControlGroup, this is automatically set to the ControlGroup's help component. |
226
+ | disabled | boolean | no | | Determines whether or not the input is disabled. |
227
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts, and null when it unmounts. |
228
+ | error | boolean | no | | Highlight the field as having an error. |
229
+ | inline | boolean | no | | When true, displays inline with a default width. |
230
+ | inputId | string | no | | An id for the text input. |
231
+ | inputRef | React.Ref<HTMLInputElement> | no | | A React ref which is set to the text input element when the component mounts, and null when it unmounts. |
232
+ | labelledBy | string | no | | The id of the label. When placed in a ControlGroup, this is automatically set to the ControlGroup's label. |
233
+ | name | string | no | | |
234
+ | onBlur | PhoneNumberBlurHandler | no | | A callback for when the input loses focus. |
235
+ | onChange | PhoneNumberChangeHandler | no | | Called whenever the value changes. If the value prop is set, this callback is required. |
236
+ | onClick | React.MouseEventHandler<HTMLInputElement> | no | | A callback for when the input is clicked. |
237
+ | onFocus | PhoneNumberFocusHandler | no | | A callback for when the input takes focus. |
238
+ | onSelect | React.ReactEventHandler<HTMLInputElement> | no | | A callback for when the user selects text. |
239
+ | prepend | boolean | no | | Prepend removes rounded borders from the left side. |
240
+ | toggleRef | React.Ref<HTMLButtonElement> | no | | A React ref which is set to the dropdown toggle when the component mounts and null when it unmounts. |
241
+ | value | string | no | | The contents of the input. Setting this value makes the input controlled. A callback is required. |
242
+
243
+ #### Types
244
+
245
+ | Name | Type | Description |
246
+ |------|------|------|
247
+ | PhoneNumberBlurHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; } ) => void | |
248
+ | PhoneNumberChangeHandler | ( event: \| React.ChangeEvent<HTMLInputElement> \| React.KeyboardEvent<HTMLInputElement> \| React.MouseEvent<HTMLButtonElement \| HTMLSpanElement>, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; } ) => void | |
249
+ | PhoneNumberFocusHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; displayValue: string; country?: string; isPossibleNumber: boolean; isValidNumber: boolean; internationalFormat: string; } ) => void | |
250
+
251
+
252
+
253
+
254
+
@@ -0,0 +1,166 @@
1
+ # Popover
2
+
3
+ ## Overview
4
+
5
+
6
+
7
+ > Image: Illustration of a popover component.
8
+
9
+
10
+
11
+ ## When to use this component
12
+ - Use a Popover for brief, persistent hints tied to an element.
13
+ - To provide non-essential supporting information for specific elements on a page.
14
+ - To provide additional interactions with the supporting information.
15
+
16
+ ## When to use another component
17
+ - When you have multiple steps that the user needs to go through, implement a [Modal][2].
18
+ - If the content is critical and should always be visible, keep the content visible on a page.
19
+ - If the content is critical or must remain visible use [Message][4] or [Message Bar][5].
20
+
21
+ ```mermaid
22
+ graph TD
23
+ accDescr: Decision tree that guides on when to use the Popover component or something else
24
+ A(Is the content secondary and shown on demand?) -- Yes --- B(Does the content include interactive elements?)
25
+ B -- Yes --- C(Does the user need to select an option from a list?)
26
+ C -- Yes --- D(Select, Multiselect, or Radio List)
27
+ C -- No --- E(Popover)
28
+ B -- No --- F(Tooltip)
29
+ A -- No --- G(Keep the content visible on the page)
30
+ ```
31
+
32
+ ### Check out
33
+ - [Tooltip][1]
34
+ - [Modal] [2]
35
+ - [Dropdown][3]
36
+ - [Message][4]
37
+ - [Message Bar][5]
38
+
39
+ ## Behaviors
40
+
41
+ ### Interactive
42
+ Popovers include interactive content, and must be activated on click rather than hover.
43
+
44
+ > Image: Illustration of two Popovers. The first example with heart eyes emoji shows a Popover with multiple interactive elements that is activated on click. The second example with grimacing emoji shows a Popover with multiple interactive elements that is activated on hover.
45
+
46
+
47
+ ## Usage
48
+
49
+ ### Limit content
50
+ Use Popover for brief, task-related content like definitions or quick actions. Avoid long text, complex interactions, or stacking Popovers.
51
+
52
+ > Image: Illustration of two Popovers. The first example with heart eyes emoji shows a Popover announcing a new feature, and a single call-to-action labeled as ‘Continue’. The second example with grimacing emoji shows two stacked Popovers with multiple interactive elements.
53
+
54
+
55
+ ### Supplemental
56
+ Supports content that is nonessential to the primary task.
57
+ > Image: Illustration of two Popovers. The first example with heart eyes emoji shows a Popover in a focus state with the header ‘New Feature Available’. The second example with grimacing emoji shows a Popover opening on hover with buttons and multiple steps.
58
+
59
+
60
+
61
+ [1]: ./Tooltip
62
+ [2]: ./Modal
63
+ [3]: ./Dropdown
64
+ [4]: ./Message
65
+ [5]: ./MessageBar
66
+
67
+
68
+
69
+ ## Examples
70
+
71
+
72
+ ### Basic
73
+
74
+ Click the button to view the Popover.
75
+
76
+ ```typescript
77
+ import React, { useState, useCallback } from 'react';
78
+
79
+ import Button from '@splunk/react-ui/Button';
80
+ import Popover from '@splunk/react-ui/Popover';
81
+
82
+
83
+ function Example() {
84
+ const [open, setOpen] = useState(false);
85
+ const [anchor, setAnchor] = useState<HTMLButtonElement>();
86
+
87
+ const anchorRef = useCallback((el: HTMLButtonElement) => setAnchor(el), []);
88
+ const handleOpen = useCallback(() => setOpen(true), []);
89
+ const handleRequestClose = useCallback(() => setOpen(false), []);
90
+
91
+ return (
92
+ <>
93
+ <Button onClick={handleOpen} elementRef={anchorRef} label="Click me" />
94
+ <Popover open={open} anchor={anchor} onRequestClose={handleRequestClose}>
95
+ <div style={{ padding: '20px', width: '300px' }}>
96
+ This is the content of the popover. You can place any information here.
97
+ </div>
98
+ </Popover>
99
+ </>
100
+ );
101
+ }
102
+
103
+ export default Example;
104
+ ```
105
+
106
+
107
+
108
+
109
+ ## API
110
+
111
+
112
+ ### Popover API
113
+
114
+ `Popover` is used to create layovers such as dropdowns, contextual menus, or tooltips. Use
115
+ this only when the other components don't provide sufficient functionality or control. A controlled
116
+ `Dropdown` covers use cases where you might consider using `Popover` directly.
117
+
118
+ #### Props
119
+
120
+ | Name | Type | Required | Default | Description |
121
+ |------|------|------|------|------|
122
+ | anchor | HTMLElement \| null | no | | The element used to set the position of the `Popover`. It is required when the `Popover` is open and must be mounted. |
123
+ | animation | boolean | no | true | If `true`, the popover applies transitions when it is added to the DOM. |
124
+ | appearance | 'normal' \| 'inverted' \| 'none' | no | 'normal' | **DEPRECATED**: Value 'inverted' `'normal'` is the default appearance.`'none'` is a transparent box. The 'inverted' value is deprecated and will be removed in a future major version. |
125
+ | autoCloseWhenOffScreen | boolean | no | true | If `true`, the `Popover` hides when the anchor is scrolled off the screen. |
126
+ | canCoverAnchor | boolean | no | | If there isn't enough room to render the `Popover` in a direction, this option enables it to be rendered over the anchor. |
127
+ | children | React.ReactNode \| PopoverChildrenRenderer | no | | The content of the `Popover`. 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. |
128
+ | closeReasons | PopoverPossibleCloseReason[] | no | [ 'clickAway', 'escapeKey', 'offScreen', 'tabKey', ] | An array of reasons for which this `Popover` should close. |
129
+ | defaultPlacement | PopoverPlacement | no | 'below' | The default placement of the `Popover`. It might be rendered in a different direction depending upon the space available and the `repositionMode`. |
130
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
131
+ | hideArrow | boolean | no | | Whether or not to hide the arrow pointing to the anchor. The arrow is always hidden when `appearance="none"`. |
132
+ | onRequestClose | PopoverRequestCloseHandler | no | | Callback function fired when the popover is requested to be closed. |
133
+ | open | boolean | no | | If `true`, the `Popover` is visible. |
134
+ | pointTo | { x?: number; y?: number } | no | | Allows the `Popover` to point to and align with a different part of the anchor. The x and y values are relative to the upper left corner of the anchor. This property overides `align`. When positioned above or below, only `x` is used. When positioned left or right, `y` is used. |
135
+ | repositionMode | 'none' \| 'flip' \| 'any' | no | 'flip' | If the `Popover` doesn't fit in the `defaultPlacement`, `repositionMode` determines if and how the `Popover` repositions itself to fit on the page. `none` doesn't reposition the `Popover`. It always renders in the `defaultPlacement` direction. `flip` allows the `Popover` to reposition to the opposite of the `defaultPlacement` if it can fit there and not in the `defaultPlacement`. `any` allows the `Popover` to reposition in any direction if it can fit on the page. |
136
+ | retainFocus | boolean | no | true | Keeps focus within the `Popover` while open. |
137
+ | splunkTheme | | no | | |
138
+ | takeFocus | boolean | no | | 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. |
139
+
140
+ #### Types
141
+
142
+ | Name | Type | Description |
143
+ |------|------|------|
144
+ | PopoverChildrenRenderer | (data: { anchorHeight: number \| null; anchorWidth: number \| null; maxHeight: number \| null; maxWidth: number \| null; placement: PopoverPlacementStatus \| null; toggleId?: string; }) => React.ReactNode | |
145
+ | PopoverPlacement | 'above' \| 'below' \| 'left' \| 'right' \| 'vertical' \| 'horizontal' | |
146
+ | PopoverPlacementStatus | 'above' \| 'below' \| 'left' \| 'right' \| 'misaligned' | |
147
+ | PopoverPossibleCloseReason | 'clickAway' \| 'escapeKey' \| 'offScreen' \| 'tabKey' | |
148
+ | PopoverRequestCloseHandler | (data: { event?: MouseEvent \| KeyboardEvent \| TouchEvent; reason: PopoverPossibleCloseReason; }) => void | |
149
+
150
+
151
+
152
+ ### PopoverProvider API
153
+
154
+ Provides a method for controlling certain `Popover` props in components that use `Popover`.
155
+
156
+ #### Props
157
+
158
+ | Name | Type | Required | Default | Description |
159
+ |------|------|------|------|------|
160
+ | children | React.ReactNode | no | | |
161
+ | hideArrow | boolean | no | | Whether or not to hide the arrow pointing to the `Popover` anchor. `Popover`'s `hideArrow` prop takes priority over this. |
162
+
163
+
164
+
165
+
166
+
@@ -0,0 +1,141 @@
1
+ # Progress
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Progress component.
7
+
8
+
9
+ ## When to use this component
10
+ - When users need feedback on the status of an ongoing task.
11
+ - To show the length of a process and track its progression toward completion.
12
+ - When the process is complex and has a long wait time.
13
+ - When the percentage of the completed process can be determined.
14
+ - To convey that data is being requested, transferred, or processed.
15
+
16
+ ## When to use another component
17
+ - For short wait times, use a Wait Spinner.
18
+ - For related tasks that need to be completed in a linear sequence, use a Step Bar.
19
+
20
+ ```mermaid
21
+ graph TD
22
+ accDescr: Decision tree that guides on when to use the Progress component or something else
23
+ A(Is the task expected to take less than a few seconds?) -- Yes --- B(Wait Spinner)
24
+ A -- No --- C(Are the tasks sequential and related?)
25
+ C -- Yes --- D(Step Bar)
26
+ C -- No --- E(Progress)
27
+ ```
28
+
29
+ ### Check out
30
+ - [Wait Spinner][1]
31
+ - [Step Bar][2]
32
+
33
+ ## Usage
34
+
35
+ ### Grouping
36
+ Display overall progress of a group rather than the progress of each item in the group.
37
+
38
+ > Image: Example showing grouping of content while using the progress component. The first example with the heart eyes emoji displays the progress component at the top of the page, loading for all the contents on the page, whereas the second example with the grimacing emoji displays the progress component loading for all content sections individually.
39
+
40
+
41
+ ### Labels
42
+ Labels should always be placed below the progress bar contained in a tooltip for accessibility. Avoid placing text inside the progress bar, this could cause clutter and poor text readability.
43
+
44
+ > Image: Example showing how labels should appear while using the progress component. The first example with the heart eyes emoji displays the context label (percentage complete) inside a tool tip under the progress component, whereas the second example with the grimacing emoji displays the context label inside the progress component.
45
+
46
+
47
+ ### Screen real estate
48
+ Avoid using the progress component in small spaces such as within a button.
49
+
50
+ > Image: Example showing appropriate screen realestate for the progress component. The first example with the heart eyes emoji displays the progress component at the top of the screen, taking up a good amount of screen real estate, whereas the second example with the grimacing emoji displays the progress component cramped inside a button component.
51
+
52
+
53
+ ### Quantifiable processes
54
+ Use a progress bar for processes that can be quantified, such as displaying a percentage (e.g., file upload). Avoid using it for stepped progress determined by user actions.
55
+
56
+ > Image: Example showing what processes the label component should be used for. The first example with the heart eyes emoji displays the progress component used to showcase upload time within a table, whereas the second example with the grimacing emoji displays the progress component used to determine a user
57
+
58
+
59
+ [1]: ./WaitSpinner
60
+ [2]: ./StepBar
61
+
62
+ ## Examples
63
+
64
+
65
+ ### Basic
66
+
67
+ ```typescript
68
+ import React, { useState, useEffect } from 'react';
69
+
70
+ import Progress from '@splunk/react-ui/Progress';
71
+
72
+
73
+ function Example() {
74
+ const [percentage, setPercentage] = useState(0);
75
+
76
+ useEffect(() => {
77
+ const timer = window.setInterval(() => {
78
+ setPercentage((currentPercentage) => {
79
+ if (currentPercentage >= 100) {
80
+ return 0;
81
+ }
82
+ return currentPercentage + 5;
83
+ });
84
+ }, 1000);
85
+ return () => {
86
+ window.clearInterval(timer);
87
+ };
88
+ }, []);
89
+
90
+ return <Progress percentage={percentage} tooltip={`${percentage}% uploaded`} />;
91
+ }
92
+
93
+ export default Example;
94
+ ```
95
+
96
+
97
+
98
+ ### Type
99
+
100
+ ```typescript
101
+ import React from 'react';
102
+
103
+ import Progress from '@splunk/react-ui/Progress';
104
+
105
+
106
+ function Type() {
107
+ return (
108
+ <>
109
+ <Progress type="info" percentage={30} />
110
+ <br />
111
+ <Progress type="success" percentage={60} />
112
+ <br />
113
+ <Progress type="error" percentage={100} />
114
+ </>
115
+ );
116
+ }
117
+
118
+ export default Type;
119
+ ```
120
+
121
+
122
+
123
+
124
+ ## API
125
+
126
+
127
+ ### Progress API
128
+
129
+ #### Props
130
+
131
+ | Name | Type | Required | Default | Description |
132
+ |------|------|------|------|------|
133
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
134
+ | percentage | number | no | | The percentage complete. If unset, no progress bar is shown. Percentage must be a number from 0-100. |
135
+ | tooltip | React.ReactNode | no | | Tooltip defaults to the percentage complete. |
136
+ | type | 'info' \| 'success' \| 'error' | no | 'info' | Sets the appearance of the `Progress` component. Note: `success` and `error` types are not animated. |
137
+
138
+
139
+
140
+
141
+