@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,374 @@
1
+ # Form Rows
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Basic
7
+
8
+ ```typescript
9
+ import React, { Component } from 'react';
10
+
11
+ import FormRows, {
12
+ FormRowsRequestMoveHandler,
13
+ RowRequestRemoveHandler,
14
+ } from '@splunk/react-ui/FormRows';
15
+ import Text from '@splunk/react-ui/Text';
16
+ import { createDOMID } from '@splunk/ui-utils/id';
17
+
18
+
19
+ class Basic extends Component<object, { items: React.ReactElement[] }> {
20
+ constructor(props: object) {
21
+ super(props);
22
+
23
+ const items = [
24
+ <FormRows.Row index={0} key="0" onRequestRemove={this.handleRequestRemove}>
25
+ <Text defaultValue="Just another" />
26
+ </FormRows.Row>,
27
+ <FormRows.Row index={1} key="1" onRequestRemove={this.handleRequestRemove}>
28
+ <Text defaultValue="Row in the form" />
29
+ </FormRows.Row>,
30
+ ];
31
+ this.state = {
32
+ items,
33
+ };
34
+ }
35
+
36
+ handleRequestAdd = () => {
37
+ this.setState((state) => ({
38
+ items: FormRows.addRow(
39
+ <FormRows.Row
40
+ index={state.items.length}
41
+ key={createDOMID()}
42
+ onRequestRemove={this.handleRequestRemove}
43
+ >
44
+ <Text />
45
+ </FormRows.Row>,
46
+ state.items
47
+ ),
48
+ }));
49
+ };
50
+
51
+ handleRequestMove: FormRowsRequestMoveHandler = ({ fromIndex, toIndex }) => {
52
+ this.setState((state) => ({
53
+ items: FormRows.moveRow(fromIndex, toIndex, state.items),
54
+ }));
55
+ };
56
+
57
+ handleRequestRemove: RowRequestRemoveHandler = (e, { index }) => {
58
+ this.setState((state) => ({
59
+ items: FormRows.removeRow(index, state.items),
60
+ }));
61
+ };
62
+
63
+ render() {
64
+ return (
65
+ <FormRows
66
+ onRequestAdd={this.handleRequestAdd}
67
+ onRequestMove={this.handleRequestMove}
68
+ style={{ width: 300 }}
69
+ >
70
+ {this.state.items}
71
+ </FormRows>
72
+ );
73
+ }
74
+ }
75
+
76
+ export default Basic;
77
+ ```
78
+
79
+
80
+
81
+ ### Custom Add Menu
82
+
83
+ The 'Add row' button can be replaced with a button, multiple buttons, or any other content you want to show below the Form Rows.
84
+
85
+ ```typescript
86
+ import React, { Component } from 'react';
87
+
88
+ import FormRows, {
89
+ FormRowsRequestMoveHandler,
90
+ RowRequestRemoveHandler,
91
+ } from '@splunk/react-ui/FormRows';
92
+ import Number from '@splunk/react-ui/Number';
93
+ import Select, { SelectChangeHandler } from '@splunk/react-ui/Select';
94
+ import Slider from '@splunk/react-ui/Slider';
95
+ import Text from '@splunk/react-ui/Text';
96
+ import { createDOMID } from '@splunk/ui-utils/id';
97
+
98
+
99
+ class Menu extends Component<object, { items: React.ReactElement[] }> {
100
+ constructor(props: object) {
101
+ super(props);
102
+
103
+ this.state = {
104
+ items: [],
105
+ };
106
+ }
107
+
108
+ handleRequestAdd: SelectChangeHandler = (e, data) => {
109
+ let element: React.ReactElement;
110
+ const { value } = data;
111
+ switch (value) {
112
+ case '1':
113
+ element = <Text />;
114
+ break;
115
+ case '2':
116
+ element = <Slider defaultValue={3} />;
117
+ break;
118
+ case '3':
119
+ element = <Number />;
120
+ break;
121
+ default:
122
+ break;
123
+ }
124
+ this.setState((state) => ({
125
+ items: FormRows.addRow(
126
+ <FormRows.Row
127
+ index={state.items.length}
128
+ key={createDOMID()}
129
+ onRequestRemove={this.handleRequestRemove}
130
+ >
131
+ {element}
132
+ </FormRows.Row>,
133
+ state.items
134
+ ),
135
+ }));
136
+ };
137
+
138
+ handleRequestMove: FormRowsRequestMoveHandler = ({ fromIndex, toIndex }) => {
139
+ this.setState((state) => ({
140
+ items: FormRows.moveRow(fromIndex, toIndex, state.items),
141
+ }));
142
+ };
143
+
144
+ handleRequestRemove: RowRequestRemoveHandler = (e, { index }) => {
145
+ this.setState((state) => ({
146
+ items: FormRows.removeRow(index, state.items),
147
+ }));
148
+ };
149
+
150
+ render() {
151
+ const formMenu = (
152
+ <Select
153
+ appearance="default"
154
+ onChange={this.handleRequestAdd}
155
+ placeholder="Add"
156
+ value={0}
157
+ >
158
+ <Select.Option label="Text" value="1" />
159
+ <Select.Option label="Slider" value="2" />
160
+ <Select.Option label="Number" value="3" />
161
+ </Select>
162
+ );
163
+
164
+ return (
165
+ <FormRows onRequestMove={this.handleRequestMove} menu={formMenu}>
166
+ {this.state.items}
167
+ </FormRows>
168
+ );
169
+ }
170
+ }
171
+
172
+ export default Menu;
173
+ ```
174
+
175
+
176
+
177
+ ### spanStyle
178
+
179
+ ```typescript
180
+ import React, { Component } from 'react';
181
+
182
+ import FormRows, {
183
+ FormRowsRequestMoveHandler,
184
+ RowRequestRemoveHandler,
185
+ } from '@splunk/react-ui/FormRows';
186
+ import Text from '@splunk/react-ui/Text';
187
+ import { createDOMID } from '@splunk/ui-utils/id';
188
+
189
+ const spanStyle: React.CSSProperties = {
190
+ alignSelf: 'center',
191
+ };
192
+
193
+ class Header extends Component<object, { items: React.ReactElement[] }> {
194
+ constructor(props: object) {
195
+ super(props);
196
+
197
+ const items = [
198
+ <FormRows.Row index={0} key="uniqueRowUno" onRequestRemove={this.handleRequestRemove}>
199
+ <Text defaultValue="sourceip" />
200
+ <span style={spanStyle}>=</span>
201
+ <Text defaultValue="192.168.1.1" />
202
+ </FormRows.Row>,
203
+ <FormRows.Row index={1} key="uniqueRowDos" onRequestRemove={this.handleRequestRemove}>
204
+ <Text defaultValue="uid" />
205
+ <span style={spanStyle}>=</span>
206
+ <Text defaultValue="johndoe" />
207
+ </FormRows.Row>,
208
+ ];
209
+ this.state = {
210
+ items,
211
+ };
212
+ }
213
+
214
+ handleRequestAdd = () => {
215
+ this.setState((state) => ({
216
+ items: FormRows.addRow(
217
+ <FormRows.Row
218
+ index={state.items.length}
219
+ key={createDOMID()}
220
+ onRequestRemove={this.handleRequestRemove}
221
+ >
222
+ <Text describedBy="header-key" />
223
+ <span style={spanStyle}>=</span>
224
+ <Text describedBy="header-value" />
225
+ </FormRows.Row>,
226
+ state.items
227
+ ),
228
+ }));
229
+ };
230
+
231
+ handleRequestMove: FormRowsRequestMoveHandler = ({ fromIndex, toIndex }) => {
232
+ this.setState((state) => ({
233
+ items: FormRows.moveRow(fromIndex, toIndex, state.items),
234
+ }));
235
+ };
236
+
237
+ handleRequestRemove: RowRequestRemoveHandler = (e, { index }) => {
238
+ this.setState((state) => ({
239
+ items: FormRows.removeRow(index, state.items),
240
+ }));
241
+ };
242
+
243
+ render() {
244
+ const header = (
245
+ <div>
246
+ <span
247
+ style={{
248
+ display: 'inline-block',
249
+ width: 172,
250
+ }}
251
+ id="header-key"
252
+ >
253
+ Key
254
+ </span>
255
+ <span style={{ display: 'inline-block' }} id="header-value">
256
+ Value
257
+ </span>
258
+ </div>
259
+ );
260
+ return (
261
+ <FormRows
262
+ addLabel="Add input"
263
+ header={header}
264
+ onRequestAdd={this.handleRequestAdd}
265
+ onRequestMove={this.handleRequestMove}
266
+ style={{ width: 400 }}
267
+ >
268
+ {this.state.items}
269
+ </FormRows>
270
+ );
271
+ }
272
+ }
273
+
274
+ export default Header;
275
+ ```
276
+
277
+
278
+
279
+ ### Reorder only
280
+
281
+ The add and delete functionality can be removed by not including the onRequestAdd handler on Form Rows and the onRequestRemove handler on Row. The functionality of reordering Rows will still remain intact. If users can add, they should be able to delete as well.
282
+
283
+ ```typescript
284
+ import React, { Component } from 'react';
285
+
286
+ import FormRows, { FormRowsRequestMoveHandler } from '@splunk/react-ui/FormRows';
287
+ import Text from '@splunk/react-ui/Text';
288
+
289
+
290
+ class ReorderOnly extends Component<object, { items: React.ReactElement[] }> {
291
+ constructor(props: object) {
292
+ super(props);
293
+
294
+ const items = [
295
+ <FormRows.Row index={0} key="0">
296
+ <Text inline defaultValue="You can move me" />
297
+ </FormRows.Row>,
298
+ <FormRows.Row index={1} key="1">
299
+ <Text inline defaultValue="But you can't Add/Remove me" />
300
+ </FormRows.Row>,
301
+ ];
302
+ this.state = {
303
+ items,
304
+ };
305
+ }
306
+
307
+ handleRequestMove: FormRowsRequestMoveHandler = ({ fromIndex, toIndex }) => {
308
+ this.setState((state) => ({
309
+ items: FormRows.moveRow(fromIndex, toIndex, state.items),
310
+ }));
311
+ };
312
+
313
+ render() {
314
+ return (
315
+ <FormRows onRequestMove={this.handleRequestMove} style={{ width: 300 }}>
316
+ {this.state.items}
317
+ </FormRows>
318
+ );
319
+ }
320
+ }
321
+
322
+ export default ReorderOnly;
323
+ ```
324
+
325
+
326
+
327
+
328
+ ## API
329
+
330
+
331
+ ### FormRows API
332
+
333
+ #### Props
334
+
335
+ | Name | Type | Required | Default | Description |
336
+ |------|------|------|------|------|
337
+ | addLabel | string | no | _('Add row') | Label on the Add row button. Ignored when menu prop is defined. |
338
+ | disabled | boolean | no | | Disable the Add row button, the Remove button and the sort/drag action. |
339
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts, and null when it unmounts. |
340
+ | header | React.ReactNode | no | | Header for the rows. |
341
+ | menu | React.ReactNode | no | | Replaces Add row button with custom content or controls. |
342
+ | onRequestAdd | React.MouseEventHandler<HTMLButtonElement \| HTMLAnchorElement> | no | | Callback when the Add row button is clicked. If `onRequestAdd` is defined, 'onRequestRemove' should be defined in `<FormRows.Row>`. Neither should be defined for a reorder-only variant of `<FormRows>`. |
343
+ | onRequestMove | FormRowsRequestMoveHandler | no | | Callback when sort action completes. Omit this to make rows unsortable. |
344
+
345
+ #### Types
346
+
347
+ | Name | Type | Description |
348
+ |------|------|------|
349
+ | FormRowsRequestMoveHandler | (data: { fromIndex: number; toIndex: number }) => void | |
350
+
351
+
352
+
353
+ ### FormRows.Row API
354
+
355
+ #### Props
356
+
357
+ | Name | Type | Required | Default | Description |
358
+ |------|------|------|------|------|
359
+ | children | React.ReactNode | no | | |
360
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
361
+ | index | number | no | | Index of the row. This is required if the rows are sortable. |
362
+ | onRequestRemove | RowRequestRemoveHandler | no | | Callback when Remove button is clicked. |
363
+ | value | React.ReactNode | no | | The contents of Row |
364
+
365
+ #### Types
366
+
367
+ | Name | Type | Description |
368
+ |------|------|------|
369
+ | RowRequestRemoveHandler | ( event: React.MouseEvent<HTMLButtonElement>, data: { index: number } ) => void | |
370
+
371
+
372
+
373
+
374
+
@@ -0,0 +1,179 @@
1
+ # Heading
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Heading component.
7
+
8
+
9
+
10
+ ## When to use this component
11
+ - To establish clear visual rhythm and hierarchical distinction between sections of content
12
+
13
+ ## When to use another component
14
+ - If interaction is needed between sections, components such as `Collapsible Panel` or `Tab Bar` provide a structured pattern for interacting with the content contained within.
15
+
16
+ ```mermaid
17
+ graph TD
18
+ accDescr: Decision tree that guides on when to use the Heading component or something else
19
+ A(Does the content need a structured and interactive experience?) -- No --- B(Heading)
20
+ A -- Yes --- C(Collapsible Panel or Tab Bar)
21
+ ```
22
+
23
+ ### Check out
24
+ - [Collapsible Panel][1]
25
+ - [Tab Bar][2]
26
+ - [Typography][3]
27
+
28
+ ## Usage
29
+
30
+ ### Use only one `<h1>` tag
31
+ The `<h1>` tag represents the most important idea of a page. Each page should have only one `<h1>` tag to help both search engines and users quickly understand the page.
32
+ > Image: Examples display two sections each with a heading and paragraph. In the first example with heart eyes emoji, the first section has an h1 tag while the second section has an h2 tag. In the second example with grimacing emoji both sections have the h1 tag.
33
+
34
+
35
+ ### Do not skip heading levels
36
+ Headings must follow a linear order without skipping levels.
37
+
38
+ > Image: Examples display three sections each with a heading and paragraph. In the first example with heart eyes emoji, the headings in the three sections follow the tag order of h1, h2, and h3. In the second example with grimacing emoji, there is no h2 tag, resulting in three sections having h1, h3, and h4 tag, respectively.
39
+
40
+
41
+ ### Customized visual style
42
+ The `variant` prop can be used to customize the visual style while still following the semantic structure.
43
+
44
+ > Image: Example display three sections each with a heading and paragraph. The headings follow the tag order of h1, h2, and h3, but are styled title 2, title 3, and title 4.
45
+
46
+
47
+ ### Follow the level hierarchy
48
+ The heading hierarchy is meaningful. Ordering headings according to the levels makes a page easy to scan.
49
+ > Image: Examples display three sections each with a heading and paragraph. In the first example with heart eyes emoji, the headings in the three sections follow the tag order of h1, h2, and h3. In the second example with grimacing emoji, the heading hierachy is not followed, with the three sections having h1, h3, and h2 tag, respectively.
50
+
51
+
52
+
53
+ ## Content guidelines
54
+ - Follow writing best practices outlined in the [UI text style guidelines][4]
55
+
56
+ [1]: ./CollapsiblePanel
57
+ [2]: ./TabBar
58
+ [3]: ./Typography
59
+ [4]: https://docs.splunk.com/Documentation/StyleGuide/current/StyleGuide/UIGuidelines
60
+
61
+ ## Examples
62
+
63
+
64
+ ### content
65
+
66
+ ```typescript
67
+ import React from 'react';
68
+
69
+ import Heading from '@splunk/react-ui/Heading';
70
+ import P from '@splunk/react-ui/Paragraph';
71
+ import Prose from '@splunk/react-ui/Prose';
72
+
73
+ const content = `Splunk Inc. is an American software company based in San Francisco, California, that
74
+ produces software for searching, monitoring, and analyzing machine-generated data
75
+ via a web-style interface.`;
76
+
77
+
78
+ function Basic() {
79
+ return (
80
+ <Prose>
81
+ <Heading level={1}>Heading 1</Heading>
82
+ <P>{content}</P>
83
+ <Heading level={2}>Heading 2 </Heading>
84
+ <P>{content}</P>
85
+ <Heading level={3}>Heading 3</Heading>
86
+ <P>{content}</P>
87
+ <Heading level={4}>Heading 4</Heading>
88
+ <P>{content}</P>
89
+ <Heading level={5}>Heading 5</Heading>
90
+ <P>{content}</P>
91
+ <Heading level={6}>Heading 6</Heading>
92
+ <P>{content}</P>
93
+ </Prose>
94
+ );
95
+ }
96
+
97
+ export default Basic;
98
+ ```
99
+
100
+
101
+
102
+ ### Variant
103
+
104
+ The level prop determines the <hX> HTML tag and has an associated default typography mixin style. To override this default styling, the variant prop can be used to specify a typography mixin style. For instance, it is possible for a variant to have title1 styling and be a <h2> tag as in the below example.
105
+
106
+ ```typescript
107
+ import React from 'react';
108
+
109
+ import Heading from '@splunk/react-ui/Heading';
110
+ import P from '@splunk/react-ui/Paragraph';
111
+ import Prose from '@splunk/react-ui/Prose';
112
+
113
+
114
+ function Variant() {
115
+ return (
116
+ <Prose>
117
+ <Heading level={2} variant="title1">
118
+ Heading 1
119
+ </Heading>
120
+ <P>
121
+ Splunk Inc. is an American software company based in San Francisco, California, that
122
+ produces software for searching, monitoring, and analyzing machine-generated data
123
+ via a web-style interface.
124
+ </P>
125
+ </Prose>
126
+ );
127
+ }
128
+
129
+ export default Variant;
130
+ ```
131
+
132
+
133
+
134
+
135
+ ## API
136
+
137
+
138
+ ### Heading API
139
+
140
+ #### Props
141
+
142
+ | Name | Type | Required | Default | Description |
143
+ |------|------|------|------|------|
144
+ | children | React.ReactNode | yes | | |
145
+ | elementRef | React.Ref<HTMLHeadingElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
146
+ | level | 1 \| 2 \| 3 \| 4 \| 5 \| 6 | yes | | Corresponds to the respective `<hX>` HTML tags and `typography(titleX)` `@splunk/themes` typography variant. Styles will be set corresponding to level if variant is not provided: e.g. `level=3` will default to using `title3` from `mixins`. |
147
+ | variant | TypographyTitleVariant | no | | Styles the component based on typography mixin title preset styles. If a variant is not provided, styles will be set corresponding to level: e.g. `level=3` will default to using `title3` from `mixins`. |
148
+
149
+
150
+
151
+
152
+
153
+ ## Accessibility
154
+
155
+ ## Visual Design
156
+ - Color contrast ratio **MUST** be [SC 1.4.3][1]:
157
+ - &gt= 4.5:1 for normal text: 14 pt (typically 18.66px) and bold or larger
158
+ - &gt= 3:1 for large text: 18 pt (typically 24px) or larger
159
+ - For high contrast mode, ratios **MUST** be &gt= 7:1 for normal text and &gt= 4.5:1 for large text [SC 1.4.6][2]
160
+
161
+ ## Content
162
+ - Headings within the Splunk product portfolio **SHOULD** follow:
163
+ - H1 = Splunk
164
+ - H2 = application name
165
+ - H3 = page title
166
+ - H4+ = page specific content
167
+ - **MUST** use a linear order of headings. Do not jump from 1, 3, 5, subtitles. Instead, use 1, 2, 3, etc. Screen readers allow users to navigate by headings, so headings are an effective way to bypass blocks of content. [SC 2.4.1][3]
168
+
169
+ ## States
170
+ - Headers cannot be disabled
171
+
172
+ ## Implementation
173
+ - **SHOULD** use h-tags to ensure they are not buried under divs, boxes, etc.. This makes headers easier to pick up with screen readers, making information esier to find.
174
+
175
+ [1]: https://www.w3.org/TR/WCAG21/#contrast-minimum
176
+ [2]: https://www.w3.org/TR/WCAG21/#contrast-enhanced
177
+ [3]: https://www.w3.org/TR/WCAG21/#bypass-blocks
178
+
179
+
@@ -0,0 +1,109 @@
1
+ # Image
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of an Image component.
7
+
8
+
9
+ ## When to use this component
10
+ - To allow users to upload one or more images.
11
+ - Use to present visual information that enhances understanding.
12
+ - To offer immediate feedback on image file selection and validation.
13
+
14
+ ## When to use another component
15
+ - If the user needs to upload a file that is not an image, use the File component instead.
16
+ - If the user needs to provide information that is not an image, use the appropriate data entry components instead.
17
+
18
+ ### Check out
19
+ - [File][1]
20
+
21
+ ## Usage
22
+
23
+ ### Supported file types
24
+ When possible, display a clear support message showcasing what types of image file types are supported for upload.
25
+
26
+ > Image: In the first example with a heart eyes emoji, the image component includes a supporting message providing further context on what image file types are accepted. In the second example with a grimacing emoji, no supporting message is included in the image component.
27
+
28
+
29
+ ### Error messaging
30
+ Provide specific and clear information about the cause of an error, guiding the user on how to resolve it.
31
+
32
+ > Image: In the first example with a heart eyes emoji, the user is given context on the cause and resolution of the error. In the second example with a grimacing emoji, no further context is provided.
33
+
34
+
35
+ ## Content
36
+
37
+ ### Be concise
38
+ Ensure all text and messaging, including labels and helper text, are brief and to the point.
39
+
40
+ > Image: In the first example with a heart eyes emoji, the text and messaging are brief and to the point. In the second example with a grimacing emoji the text and messaging are wordy.
41
+
42
+
43
+ [1]: ./File
44
+
45
+ ## Examples
46
+
47
+
48
+ ### Basic
49
+
50
+ ```typescript
51
+ /* eslint-disable no-console */
52
+
53
+ import React from 'react';
54
+
55
+ import Image, { ImageImageChangeHandler } from '@splunk/react-ui/Image';
56
+
57
+
58
+ function Basic() {
59
+ const handleOnImageChange: ImageImageChangeHandler = ({ filename, imageDataURI }) => {
60
+ console.log(
61
+ `Image selected: ${filename}, ${
62
+ imageDataURI !== null ? `${imageDataURI.slice(0, 50)}...` : null
63
+ }`
64
+ );
65
+ };
66
+
67
+ return (
68
+ <div style={{ maxWidth: 300 }}>
69
+ <Image onImageChange={handleOnImageChange} />
70
+ </div>
71
+ );
72
+ }
73
+
74
+ export default Basic;
75
+ ```
76
+
77
+
78
+
79
+
80
+ ## API
81
+
82
+
83
+ ### Image API
84
+
85
+ Image provides the ability to accept image files and present a preview of the image.
86
+
87
+ #### Props
88
+
89
+ | Name | Type | Required | Default | Description |
90
+ |------|------|------|------|------|
91
+ | allowExtensions | string[] | no | ['gif', 'jpeg', 'jpg', 'png'] | Specify the allowed image extensions. Should be an array of image extensions, e.g., ['gif', 'jpg', 'png']. |
92
+ | defaultFilename | string | no | | The default file name of the selected image. In order to render selected image preview, need to set valid defaultFilename (end with allowed image extensions, e.g., 'default.png') and defaultImageDataURI at the same time. |
93
+ | defaultImageDataURI | string | no | | The default selected image data (as data URI). Need to set with defaultFilename at the same time. |
94
+ | disabled | boolean | no | | Prevents user from selecting or dropping images. |
95
+ | dropAnywhere | boolean | no | | Image can be dropped anywhere on the page. |
96
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
97
+ | error | boolean | no | | Show the component in an error state. |
98
+ | onImageChange | ImageImageChangeHandler | no | | A callback for when the image changes. The function is passed an object containing two keys: `filename` and `imageDataURI`. Both are `null` if the image was removed. |
99
+
100
+ #### Types
101
+
102
+ | Name | Type | Description |
103
+ |------|------|------|
104
+ | ImageImageChangeHandler | (data: { filename: string \| null; imageDataURI: string \| null; }) => void | |
105
+
106
+
107
+
108
+
109
+