@splunk/react-ui 5.7.0 → 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 +34 -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 +204 -185
  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,381 @@
1
+ # Search
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Search.
7
+
8
+
9
+ ## When to use this component
10
+ Search lets users input keywords to find specific content within a system.
11
+ - When specific data needs to be quickly found within a large dataset.
12
+ - When the desired information is not readily accessible through navigation or filtering.
13
+ - When the user needs to directly find specific content by inputting keywords.
14
+ - When searching within specific components, such as a `Table`, is required.
15
+
16
+ ## When to use another component
17
+ - When you have a small or limited dataset.
18
+ - When the information is simple and easily accessible.
19
+
20
+ ```mermaid
21
+ graph TD
22
+ accDescr: Decision tree that guides on when to use the Search component or something else
23
+ A(Do you have a small or limited dataset?) -- Yes --- B(Definition List or List)
24
+ A -- No --- C(Search)
25
+ ```
26
+
27
+ ### Check out
28
+ - [Definition List][1]
29
+ - [List][2]
30
+
31
+ ## Usage
32
+
33
+ ### Search width
34
+ Adjust the width to accommodate the anticipated input length, ensuring it is sufficiently wide to support the longest expected values. Avoid extending Text across the entire width of large screens to maintain usability and readability.
35
+
36
+ > Image: Examples of Search component widths. The first example with heart eyes emoji has a Search component that is sufficiently wide enough to support the longest expected values. The second example with a grimacing face emoji has a Search component that is a smaller width than the longest expected values.
37
+
38
+
39
+ ### Quick options
40
+ Quick options provide pre-defined search terms or filters. Focus on quick options that are most frequently used or relevant to the current context. Order your list of options in a way that will make the most sense. This could be by the most commonly selected option, numerically, or alphabetical.
41
+ > Image: Examples of Search component with quick options. The first example with heart eyes emoji has a Search component that has four quick options populated below the input. The second example with a grimacing face emoji has a Search component that has twelve quick options populated below the input.
42
+
43
+
44
+ ## Content
45
+
46
+ ### Placeholder text
47
+ Provide a brief, helpful hint to guide users on what they can search for, such as "Search applications."
48
+ > Image: Examples of using placeholder text in the Search component. The first example with heart eyes emoji has a Search component with placholder text
49
+
50
+
51
+ [1]: ./DefinitionList
52
+ [2]: ./List
53
+
54
+ ## Examples
55
+
56
+
57
+ ### Controlled
58
+
59
+ The Search component can be used as both uncontrolled default variant and as a controlled variant. In this example we show the controlled variant.
60
+
61
+ ```typescript
62
+ import React, { useState } from 'react';
63
+
64
+ import Search, { SearchChangeHandler } from '@splunk/react-ui/Search';
65
+
66
+
67
+ const Controlled = () => {
68
+ const [value, setValue] = useState('');
69
+
70
+ const handleChange: SearchChangeHandler = (e, { value: searchValue }) => {
71
+ setValue(searchValue);
72
+ };
73
+
74
+ return <Search inline onChange={handleChange} value={value} />;
75
+ };
76
+
77
+ export default Controlled;
78
+ ```
79
+
80
+
81
+
82
+ ### Quick Options
83
+
84
+ The Search component can be populated with quick Options. In this example the user can select a quick Option or search via the input, but the Options are not filtered.
85
+
86
+ ```typescript
87
+ import React, { useState } from 'react';
88
+
89
+ import Search, { SearchChangeHandler } from '@splunk/react-ui/Search';
90
+
91
+
92
+ const Options = () => {
93
+ const [value, setValue] = useState('');
94
+
95
+ const handleChange: SearchChangeHandler = (e, { value: searchValue }) => {
96
+ setValue(searchValue);
97
+ };
98
+
99
+ let options;
100
+ if (!value?.length) {
101
+ options = [
102
+ <Search.Option key="line" value="Line Chart" description="Recommended" />,
103
+ <Search.Option key="area" value="Area Chart" />,
104
+ <Search.Option key="column" value="Column Chart" />,
105
+ <Search.Option key="bar" value="Bar Chart" />,
106
+ <Search.Option key="pie" value="Pie Chart" />,
107
+ <Search.Option key="scatter" value="Scatter Chart" />,
108
+ <Search.Option key="bubble" value="Bubble Chart" />,
109
+ ];
110
+ }
111
+
112
+ return (
113
+ <Search inline onChange={handleChange}>
114
+ {options}
115
+ </Search>
116
+ );
117
+ };
118
+
119
+ export default Options;
120
+ ```
121
+
122
+
123
+
124
+ ### Options as links
125
+
126
+ The option on a list of results of search can be a link redirecting to a product page
127
+
128
+ ```typescript
129
+ import React, { useState } from 'react';
130
+
131
+ import Search, { SearchChangeHandler } from '@splunk/react-ui/Search';
132
+
133
+
134
+ const OptionsLinks = () => {
135
+ const [value, setValue] = useState('');
136
+
137
+ const handleChange: SearchChangeHandler = (e, { value: searchValue }) => {
138
+ setValue(searchValue);
139
+ };
140
+
141
+ let options;
142
+ if (!value?.length) {
143
+ options = [
144
+ <Search.Option key="button" value="Button" to="./Button" description="Recommended" />,
145
+ <Search.Option
146
+ key="splunk"
147
+ value="Splunk"
148
+ to="https://www.splunk.com"
149
+ openInNewContext
150
+ />,
151
+ ];
152
+ }
153
+
154
+ return (
155
+ <Search inline onChange={handleChange}>
156
+ {options}
157
+ </Search>
158
+ );
159
+ };
160
+
161
+ export default OptionsLinks;
162
+ ```
163
+
164
+
165
+
166
+ ### Asynchronously Loaded Options
167
+
168
+ The Search component's quick Options can be loaded asynchronously. In this example we show the input paired with asycnchrously loaded and filtered Options.
169
+
170
+ ```typescript
171
+ import React, { useCallback, useEffect, useState } from 'react';
172
+
173
+ import useFetchOptions, { MovieOption } from '@splunk/react-ui/fixtures/useFetchOptions';
174
+ import Search, { SearchChangeHandler } from '@splunk/react-ui/Search';
175
+
176
+
177
+ function Loading() {
178
+
179
+ const { fetch, stop } = useFetchOptions();
180
+
181
+ const [isLoading, setIsLoading] = useState(false);
182
+ const [options, setOptions] = useState<MovieOption[]>([]);
183
+ const [value, setValue] = useState('');
184
+
185
+ const handleFetch = useCallback(
186
+ (searchValue = '') => {
187
+ setValue(searchValue);
188
+ setIsLoading(true);
189
+ fetch(searchValue)
190
+ .then((searchOptions) => {
191
+ setIsLoading(false);
192
+ setOptions(searchOptions);
193
+ })
194
+ .catch((error) => {
195
+ if (!error.isCanceled) {
196
+ throw error;
197
+ }
198
+ });
199
+ },
200
+ [fetch]
201
+ );
202
+
203
+ const generateOptions = () => {
204
+ if (isLoading) {
205
+ return null;
206
+ }
207
+
208
+ return options.map((movie) => (
209
+ <Search.Option value={movie.title} key={movie.id} matchRanges={movie.matchRanges} />
210
+ ));
211
+ };
212
+
213
+ const handleChange: SearchChangeHandler = (e, { value: searchValue }) => {
214
+ handleFetch(searchValue);
215
+ };
216
+
217
+ useEffect(() => {
218
+ handleFetch();
219
+
220
+ return () => {
221
+ stop();
222
+ };
223
+ }, [handleFetch, stop]);
224
+
225
+ const searchOptions = generateOptions();
226
+
227
+ return (
228
+ <Search value={value} inline onChange={handleChange} isLoadingOptions={isLoading}>
229
+ {searchOptions}
230
+ </Search>
231
+ );
232
+ }
233
+
234
+ export default Loading;
235
+ ```
236
+
237
+
238
+
239
+ ### Filtered Results
240
+
241
+ ```typescript
242
+ import React, { useState } from 'react';
243
+
244
+ import Card from '@splunk/react-ui/Card';
245
+ import Search, { SearchChangeHandler } from '@splunk/react-ui/Search';
246
+
247
+ const resultData = [
248
+ { value: 'line', display: 'Line Chart' },
249
+ { value: 'area', display: 'Area Chart' },
250
+ { value: 'column', display: 'Column Chart' },
251
+ { value: 'bar', display: 'Bar Chart' },
252
+ { value: 'pie', display: 'Pie Chart' },
253
+ { value: 'scatter', display: 'Scatter Chart' },
254
+ { value: 'bubble', display: 'Bubble Chart' },
255
+ ];
256
+ interface Result {
257
+ value: string;
258
+ display: string;
259
+ }
260
+
261
+ type ResultArray = Array<Result>;
262
+
263
+
264
+ const filteredResults = (results: ResultArray, filterValue: string) => {
265
+ if (!filterValue || !filterValue.length) {
266
+ return results;
267
+ }
268
+
269
+ return results.filter((result: Result) =>
270
+ result.display.toLowerCase().includes(filterValue.toLowerCase())
271
+ );
272
+ };
273
+
274
+ const cardForResult = (result: Result) => {
275
+ return (
276
+ <Card key={result.value} style={{ margin: '0 20px 20px 0' }}>
277
+ <Card.Header title={result.display} />
278
+ </Card>
279
+ );
280
+ };
281
+
282
+ const Results = () => {
283
+ const [value, setValue] = useState('');
284
+
285
+ const handleChange: SearchChangeHandler = (e, { value: searchValue }) => {
286
+ setValue(searchValue);
287
+ };
288
+
289
+ return (
290
+ <>
291
+ <Search aria-controls="example-search-results" onChange={handleChange} value={value} />
292
+ <div id="example-search-results" style={{ paddingTop: '10px' }}>
293
+ {filteredResults(resultData, value)?.map((result: Result) => {
294
+ return cardForResult(result);
295
+ })}
296
+ </div>
297
+ </>
298
+ );
299
+ };
300
+
301
+ export default Results;
302
+ ```
303
+
304
+
305
+
306
+
307
+ ## API
308
+
309
+
310
+ ### Search API
311
+
312
+ #### Props
313
+
314
+ | Name | Type | Required | Default | Description |
315
+ |------|------|------|------|------|
316
+ | animateLoading | boolean | no | false | |
317
+ | append | boolean | no | | Append removes rounded borders and the border from the right side. |
318
+ | children | React.ReactNode | no | | All children must be instances of `Search.Option`. |
319
+ | defaultPlacement | 'above' \| 'below' \| 'vertical' | no | | The default placement of the dropdown menu. It might be rendered in a different direction depending upon the space available. |
320
+ | defaultValue | string | no | | The initial value of the input. Only applicable in uncontrolled mode. |
321
+ | describedBy | string | no | | The id of the description. |
322
+ | disabled | boolean | no | false | |
323
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
324
+ | error | boolean | no | false | Highlight the field as having an error. The border and text will turn red. |
325
+ | footerMessage | React.ReactNode | no | | The footer message can show additional information, such as a truncation message. |
326
+ | inline | boolean | no | false | Make the control an inline block with variable width. |
327
+ | inputRef | React.Ref<HTMLInputElement> | no | | A React ref which is set to the input element when the component mounts and null when it unmounts. |
328
+ | isLoadingOptions | boolean | no | false | |
329
+ | labelledBy | string | no | | The id of the label. |
330
+ | loadingMessage | React.ReactNode | no | | The loading message to show when isLoadingOptions. |
331
+ | menuStyle | React.CSSProperties | no | {} | |
332
+ | name | string | no | | The name is returned with onChange events, which can be used to identify the control when multiple controls share an onChange callback. |
333
+ | noOptionsMessage | React.ReactNode | no | | The noOptionsMessage is shown when there are no children and it's not loading, such as when there are no Options matching the filter. This can be customized to the type of content, for example: "No matching dashboards". You can insert content such as an error message or communicate a minimum number of characters to enter to see results. |
334
+ | onBlur | SearchBlurHandler | no | | |
335
+ | onChange | SearchChangeHandler | no | | |
336
+ | onClose | () => void | no | | A callback function invoked when the popover closes. |
337
+ | onFocus | SearchFocusHandler | no | | |
338
+ | onKeyDown | React.KeyboardEventHandler<HTMLInputElement> | no | | |
339
+ | onOpen | () => void | no | | A callback function invoked when the popover opens. |
340
+ | onScroll | React.UIEventHandler<Element> | no | | A callback function invoked when the menu is scrolled. |
341
+ | onSelect | React.ReactEventHandler<HTMLInputElement> | no | | |
342
+ | placeholder | string | no | _('Search...') | |
343
+ | prepend | boolean | no | | Prepend removes rounded borders from the left side. |
344
+ | value | string | no | | The value of the input. Only applicable in controlled mode. |
345
+
346
+ #### Types
347
+
348
+ | Name | Type | Description |
349
+ |------|------|------|
350
+ | SearchBlurHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; } ) => void | |
351
+ | SearchChangeHandler | ( event: \| React.ChangeEvent<HTMLInputElement> \| React.MouseEvent<HTMLButtonElement \| HTMLSpanElement> \| React.KeyboardEvent<HTMLInputElement>, data: { name?: string; value: string; } ) => void | |
352
+ | SearchFocusHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; } ) => void | |
353
+
354
+
355
+
356
+ ### Search.Option API
357
+
358
+ An option within a `Search`.
359
+
360
+ #### Props
361
+
362
+ | Name | Type | Required | Default | Description |
363
+ |------|------|------|------|------|
364
+ | description | string | no | | Additional information to explain the option, such as "Recommended". |
365
+ | descriptionPosition | 'right' \| 'bottom' | no | 'bottom' | The description text may appear to the right of the label or under the label. |
366
+ | disabled | boolean | no | | If disabled=true, the option is grayed out and cannot be clicked. |
367
+ | elementRef | React.Ref<HTMLButtonElement \| HTMLAnchorElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
368
+ | endAdornment | React.ReactNode | no | | Adornment after the label. |
369
+ | label | string | no | | When provided, `label` is rendered instead of the `value`. |
370
+ | matchRanges | { start: number; end: number }[] | no | | Sections of the label string to highlight as a match. |
371
+ | onClick | ( event: React.MouseEvent<HTMLButtonElement \| HTMLAnchorElement>, data: { to?: string; value: string } ) => boolean \| void | no | | Callback for click events. Returning "false" from the callback will prevent the parent Search component from updating its value, closing the popover, or firing the `onChange` callback. |
372
+ | openInNewContext | boolean | no | | To open the link in a new window, set `openInNewContext` to `true`. An icon is added indicating the behavior. |
373
+ | startAdornment | React.ReactNode | no | | Adornment in front of the label. |
374
+ | to | string | no | | The URL or path to link to. |
375
+ | truncate | boolean | no | | When `true`, wrapping is disabled and any additional text is ellipsised. |
376
+ | value | string | yes | | The value of this option and the label shown for it. |
377
+
378
+
379
+
380
+
381
+