@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.
- package/Accordion.js +6 -6
- package/Anchor.js +2 -1
- package/Box.js +83 -34
- package/CHANGELOG.md +51 -0
- package/Calendar.js +134 -134
- package/Clickable.js +131 -94
- package/CollapsiblePanel.js +175 -137
- package/ComboBox.js +32 -27
- package/ControlGroup.js +92 -91
- package/DefinitionList.js +9 -9
- package/Drawer.d.ts +2 -0
- package/Drawer.js +679 -0
- package/Dropdown.js +27 -18
- package/DualListbox.js +1 -1
- package/File.js +35 -35
- package/JSONTree.js +73 -72
- package/Link.js +2 -2
- package/MIGRATION.md +10 -0
- package/Menu.js +403 -261
- package/Modal.js +263 -252
- package/Monogram.js +2 -2
- package/Multiselect.js +551 -385
- package/Number.js +2 -1
- package/Paginator.js +14 -12
- package/Popover.js +4 -1
- package/README.md +11 -0
- package/RadioBar.js +1 -1
- package/Search.js +111 -95
- package/Select.js +42 -40
- package/SelectBase.js +819 -715
- package/SidePanel.js +346 -167
- package/SlidingPanels.js +11 -11
- package/StepBar.js +7 -7
- package/Switch.js +5 -5
- package/Table.js +116 -119
- package/Text.js +48 -48
- package/TextArea.js +7 -7
- package/TransitionOpen.js +188 -169
- package/docs-llm/Accordion.md +267 -0
- package/docs-llm/Anchor Menu.md +115 -0
- package/docs-llm/Anchor.md +54 -0
- package/docs-llm/AnimationToggle.md +254 -0
- package/docs-llm/Avatar.md +292 -0
- package/docs-llm/Badge.md +212 -0
- package/docs-llm/Breadcrumbs.md +306 -0
- package/docs-llm/Button Group.md +53 -0
- package/docs-llm/Button.md +361 -0
- package/docs-llm/Card Layout.md +286 -0
- package/docs-llm/Card.md +619 -0
- package/docs-llm/Checkbox.md +218 -0
- package/docs-llm/Chip.md +291 -0
- package/docs-llm/Clickable.md +160 -0
- package/docs-llm/Code.md +292 -0
- package/docs-llm/Collapsible Panel.md +744 -0
- package/docs-llm/Color.md +253 -0
- package/docs-llm/Column Layout.md +391 -0
- package/docs-llm/Combo Box.md +540 -0
- package/docs-llm/Control Group.md +594 -0
- package/docs-llm/Date.md +270 -0
- package/docs-llm/Definition List.md +278 -0
- package/docs-llm/Divider.md +216 -0
- package/docs-llm/Drawer.md +414 -0
- package/docs-llm/Dropdown.md +472 -0
- package/docs-llm/Dual Listbox.md +325 -0
- package/docs-llm/File.md +653 -0
- package/docs-llm/Form Rows.md +374 -0
- package/docs-llm/Heading.md +179 -0
- package/docs-llm/Image.md +109 -0
- package/docs-llm/JSON Tree.md +260 -0
- package/docs-llm/Layer.md +74 -0
- package/docs-llm/Layout.md +50 -0
- package/docs-llm/Link.md +318 -0
- package/docs-llm/List.md +189 -0
- package/docs-llm/Markdown.md +179 -0
- package/docs-llm/Menu.md +735 -0
- package/docs-llm/Message Bar.md +236 -0
- package/docs-llm/Message.md +248 -0
- package/docs-llm/Modal.md +443 -0
- package/docs-llm/Monogram.md +159 -0
- package/docs-llm/Multiselect.md +939 -0
- package/docs-llm/Notifications.md +46 -0
- package/docs-llm/Number.md +298 -0
- package/docs-llm/Paginator.md +395 -0
- package/docs-llm/Paragraph.md +148 -0
- package/docs-llm/Phone Number.md +254 -0
- package/docs-llm/Popover.md +166 -0
- package/docs-llm/Progress.md +141 -0
- package/docs-llm/Radio Bar.md +303 -0
- package/docs-llm/Radio List.md +350 -0
- package/docs-llm/Resize.md +362 -0
- package/docs-llm/Screen Reader Content.md +73 -0
- package/docs-llm/Scroll Container Context.md +155 -0
- package/docs-llm/Scroll.md +152 -0
- package/docs-llm/Search.md +381 -0
- package/docs-llm/Select.md +985 -0
- package/docs-llm/Side Panel.md +777 -0
- package/docs-llm/Slider.md +339 -0
- package/docs-llm/Sliding Panels.md +340 -0
- package/docs-llm/Split Button.md +295 -0
- package/docs-llm/Static Content.md +90 -0
- package/docs-llm/Step Bar.md +292 -0
- package/docs-llm/Switch.md +268 -0
- package/docs-llm/Tab Bar.md +439 -0
- package/docs-llm/Tab Layout.md +398 -0
- package/docs-llm/Table.md +2642 -0
- package/docs-llm/Text Area.md +253 -0
- package/docs-llm/Text.md +339 -0
- package/docs-llm/Tooltip.md +325 -0
- package/docs-llm/Transition Open.md +406 -0
- package/docs-llm/Tree.md +591 -0
- package/docs-llm/Typography.md +125 -0
- package/docs-llm/Wait Spinner.md +121 -0
- package/docs-llm/llms.txt +101 -0
- package/package.json +6 -5
- package/types/src/Box/Box.d.ts +2 -10
- package/types/src/Drawer/Body.d.ts +17 -0
- package/types/src/Drawer/Drawer.d.ts +114 -0
- package/types/src/Drawer/DrawerContext.d.ts +11 -0
- package/types/src/Drawer/Footer.d.ts +25 -0
- package/types/src/Drawer/Header.d.ts +41 -0
- package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
- package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
- package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
- package/types/src/Drawer/index.d.ts +2 -0
- package/types/src/JSONTree/JSONTree.d.ts +12 -5
- package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
- package/types/src/Menu/Item.d.ts +2 -1
- package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
- package/types/src/Modal/Modal.d.ts +1 -2
- package/types/src/Multiselect/Compact.d.ts +8 -3
- package/types/src/Multiselect/Multiselect.d.ts +8 -3
- package/types/src/Multiselect/Normal.d.ts +8 -3
- package/types/src/Multiselect/Option.d.ts +6 -3
- package/types/src/Multiselect/docs/examples/Disabled.d.ts +1 -0
- package/types/src/Select/Option.d.ts +6 -3
- package/types/src/Select/Select.d.ts +8 -5
- package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
- package/types/src/SelectBase/OptionBase.d.ts +6 -3
- package/types/src/SelectBase/SelectBase.d.ts +8 -3
- package/types/src/SidePanel/SidePanel.d.ts +43 -2
- package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
- package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
- package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
- package/types/src/useKeyPress/index.d.ts +9 -2
- package/types/src/useOnClickOutside/index.d.ts +2 -0
- package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
- package/useKeyPress.js +23 -18
- package/useOnClickOutside.d.ts +2 -0
- package/useOnClickOutside.js +79 -0
- package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# JSON Tree
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of the JSON Tree component displaying structured data in a collapsible tree format.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- To display structured data in a collapsible tree format.
|
|
11
|
+
|
|
12
|
+
## When to use another component
|
|
13
|
+
- For displaying pieces of code, command-line instructions, or technical values that need to be visually distinguished from surrounding content, consider using `Code`.
|
|
14
|
+
|
|
15
|
+
### Check out:
|
|
16
|
+
- [Code][1]
|
|
17
|
+
|
|
18
|
+
## Behaviors
|
|
19
|
+
|
|
20
|
+
### Data types
|
|
21
|
+
- Values are visually distinguished by their data type (e.g., string, number, boolean, null, object, array).
|
|
22
|
+
|
|
23
|
+
> Image: A display of a JSON object showing various data types like numbers, strings, booleans, null, and nested objects/arrays, with different colors indicating types.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Expanding content
|
|
27
|
+
- Users can expand and collapse individual nodes (objects or arrays) to reveal or hide their contents. You can set the `defaultExpanded` prop to have it expanded by default.
|
|
28
|
+
|
|
29
|
+
> Image: A display illustrating the expandable and collapsible nature of a JSON tree, showing a collapsed object on the left and its expanded view revealing nested structures on the right.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Expand all
|
|
33
|
+
- `Shift + Click` or `Shift + Enter` to expand all child nodes at once.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
- The JSON Tree component accepts a JSON object or array as its primary data input.
|
|
37
|
+
|
|
38
|
+
## Content
|
|
39
|
+
- Use proper syntax and indentation to ensure readability and clarity.
|
|
40
|
+
|
|
41
|
+
[1]: ./Code
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### obj
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import React from 'react';
|
|
50
|
+
|
|
51
|
+
import JSONTree from '@splunk/react-ui/JSONTree';
|
|
52
|
+
|
|
53
|
+
const obj = {
|
|
54
|
+
menu: {
|
|
55
|
+
id: 8989,
|
|
56
|
+
value: 'File',
|
|
57
|
+
property: {},
|
|
58
|
+
items: [],
|
|
59
|
+
popup: {
|
|
60
|
+
menuitem: [
|
|
61
|
+
{
|
|
62
|
+
value: 'New',
|
|
63
|
+
onclick: 'CreateNewDoc()',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: null,
|
|
67
|
+
onclick: false,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: 'Close',
|
|
71
|
+
onclick: 'CloseDoc()',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export default function Basic() {
|
|
80
|
+
return <JSONTree json={obj} defaultExpanded />;
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Expand Children On Shift Key
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import React from 'react';
|
|
90
|
+
|
|
91
|
+
import JSONTree from '@splunk/react-ui/JSONTree';
|
|
92
|
+
|
|
93
|
+
const obj = {
|
|
94
|
+
menu: {
|
|
95
|
+
id: 8989,
|
|
96
|
+
value: 'File',
|
|
97
|
+
property: {},
|
|
98
|
+
items: [],
|
|
99
|
+
popup: {
|
|
100
|
+
menuitem: [
|
|
101
|
+
{
|
|
102
|
+
value: 'New',
|
|
103
|
+
onclick: 'CreateNewDoc()',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: null,
|
|
107
|
+
onclick: false,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
value: 'Close',
|
|
111
|
+
onclick: 'CloseDoc()',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
export default function ExpandChildrenOnShiftKey() {
|
|
120
|
+
return <JSONTree json={obj} expandChildrenOnShiftKey />;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
### Click Events
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import React, { Component } from 'react';
|
|
130
|
+
|
|
131
|
+
import DL, { Term as DT, Description as DD } from '@splunk/react-ui/DefinitionList';
|
|
132
|
+
import JSONTree, {
|
|
133
|
+
JSONTreeClickValueHandler,
|
|
134
|
+
JSONTreeClickKeyHandler,
|
|
135
|
+
} from '@splunk/react-ui/JSONTree';
|
|
136
|
+
import P from '@splunk/react-ui/Paragraph';
|
|
137
|
+
|
|
138
|
+
const json = {
|
|
139
|
+
glossary: {
|
|
140
|
+
title: 'example glossary',
|
|
141
|
+
description: [],
|
|
142
|
+
GlossDiv: {
|
|
143
|
+
title: 'S',
|
|
144
|
+
GlossList: {
|
|
145
|
+
GlossEntry: {
|
|
146
|
+
ID: 'SGML',
|
|
147
|
+
SortAs: 'SGML',
|
|
148
|
+
GlossTerm: 'Standard Generalized Markup Language',
|
|
149
|
+
Acronym: 'SGML',
|
|
150
|
+
Abbrev: 'ISO 8879:1986',
|
|
151
|
+
GlossDef: {
|
|
152
|
+
para: 'Used to create markup languages such as DocBook.',
|
|
153
|
+
GlossSeeAlso: ['GML', null, 1, true],
|
|
154
|
+
},
|
|
155
|
+
GlossSee: {},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class Events extends Component<
|
|
164
|
+
object,
|
|
165
|
+
{ key: string; keyPath?: (string | number)[]; value: string }
|
|
166
|
+
> {
|
|
167
|
+
constructor(props: object) {
|
|
168
|
+
super(props);
|
|
169
|
+
this.state = {
|
|
170
|
+
key: '',
|
|
171
|
+
value: '',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
onClickJSONValue: JSONTreeClickValueHandler = (e, { key, keyPath, value }) => {
|
|
176
|
+
this.setState({ key, keyPath, value });
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
onClickJSONKey: JSONTreeClickKeyHandler = (e, { key, keyPath }) => {
|
|
180
|
+
this.setState({ key, keyPath, value: '' });
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
render() {
|
|
184
|
+
const { key, keyPath, value } = this.state;
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div>
|
|
188
|
+
<JSONTree
|
|
189
|
+
json={json}
|
|
190
|
+
onClickValue={this.onClickJSONValue}
|
|
191
|
+
onClickKey={this.onClickJSONKey}
|
|
192
|
+
/>
|
|
193
|
+
<aside style={{ marginTop: 20 }} aria-live="polite" aria-relevant="text">
|
|
194
|
+
<P>Click a key or value to see the returned data</P>
|
|
195
|
+
<DL>
|
|
196
|
+
{value ? (
|
|
197
|
+
<div style={{ overflow: 'scroll' }}>
|
|
198
|
+
<DT>Clicked value:</DT>
|
|
199
|
+
<DD>
|
|
200
|
+
<code>{value}</code>
|
|
201
|
+
</DD>
|
|
202
|
+
</div>
|
|
203
|
+
) : null}
|
|
204
|
+
{key ? (
|
|
205
|
+
<div style={{ overflow: 'scroll', marginBottom: 10 }}>
|
|
206
|
+
<DT>With key:</DT>
|
|
207
|
+
<DD>
|
|
208
|
+
<code>{key}</code>
|
|
209
|
+
</DD>
|
|
210
|
+
<DT>With keyPath:</DT>
|
|
211
|
+
<DD>
|
|
212
|
+
<code>{keyPath !== undefined && `[${keyPath}]`}</code>
|
|
213
|
+
</DD>
|
|
214
|
+
</div>
|
|
215
|
+
) : null}
|
|
216
|
+
</DL>
|
|
217
|
+
</aside>
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default Events;
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
## API
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
### JSONTree API
|
|
233
|
+
|
|
234
|
+
Used to visualize a JSON string.
|
|
235
|
+
|
|
236
|
+
#### Props
|
|
237
|
+
|
|
238
|
+
| Name | Type | Required | Default | Description |
|
|
239
|
+
|------|------|------|------|------|
|
|
240
|
+
| defaultExpanded | boolean | no | false | If set to `true`, `defaultExpanded` will expand all nodes on initial render. The default is `false`, which expands only the first level of properties. |
|
|
241
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
242
|
+
| expandChildrenOnShiftKey | boolean | no | true | If set to `true`, using `shift + click` or `shift + enter` will expand all descendant nodes of the tree at once. A tooltip is added to the expand all / collapse all button to indicate that this feature is enabled. Defaults to `true`. |
|
|
243
|
+
| indent | number | no | 4 | Number of space characters per level of indentation. |
|
|
244
|
+
| json | string \| JSONElement | yes | | The JSON string to visualize. Alternatively, this prop also accepts objects and other possible return types of `JSON.parse`. `JSONTree` doesn't perform any runtime type validation. If the passed value contains circular dependencies or types not representable in JSON like functions and symbols, the component behavior is unspecified. |
|
|
245
|
+
| onClickKey | JSONTreeClickKeyHandler | no | | Optional event handler to call if keys are clicked on. The function signature is `onClickKey({path, keyPath, value})`, where `path` is the property path , `.a.b`; and keyPath is an array of that property path, `['a', 'b']. |
|
|
246
|
+
| onClickValue | JSONTreeClickValueHandler | no | | Optional event handler to call if values are clicked on. The function signature is `onClickValue({path, keyPath, value})`, where `path` is the property path , `.a.b`; keyPath is an array of that property path, `['a', 'b']; and `value` is the value that was clicked. |
|
|
247
|
+
| overflow | 'wrap' \| 'scroll' | no | 'scroll' | Handles overflow by wrapping values or by enabling scrolling. |
|
|
248
|
+
|
|
249
|
+
#### Types
|
|
250
|
+
|
|
251
|
+
| Name | Type | Description |
|
|
252
|
+
|------|------|------|
|
|
253
|
+
| JSONElement | string \| { [x: string]: JSONElement } \| number \| boolean \| null \| JSONElement[] | |
|
|
254
|
+
| JSONTreeClickKeyHandler | ( event: React.MouseEvent<HTMLButtonElement>, data: { key: string; keyPath: (string \| number)[]; } ) => void | |
|
|
255
|
+
| JSONTreeClickValueHandler | ( event: React.MouseEvent<HTMLButtonElement>, data: { key: string; keyPath: (string \| number)[]; value: string; } ) => void | |
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Layer
|
|
2
|
+
|
|
3
|
+
## Examples
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Basic
|
|
7
|
+
|
|
8
|
+
This example shows a simple overlay that can be dismissed by pressing the Escape key.
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import React, { useState } from 'react';
|
|
12
|
+
|
|
13
|
+
import Button from '@splunk/react-ui/Button';
|
|
14
|
+
import Layer from '@splunk/react-ui/Layer';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function Basic() {
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const handleOpen = () => setOpen(true);
|
|
20
|
+
const handleClose = () => setOpen(false);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<Button onClick={handleOpen} label="Open" />
|
|
25
|
+
<Layer closeReasons={['escapeKey']} open={open} onRequestClose={handleClose}>
|
|
26
|
+
<div
|
|
27
|
+
style={{
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
bottom: '5%',
|
|
30
|
+
right: '5%',
|
|
31
|
+
width: '300px',
|
|
32
|
+
height: '100px',
|
|
33
|
+
backgroundColor: 'crimson',
|
|
34
|
+
borderRadius: '3px',
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</Layer>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default Basic;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
import React from 'react';
|
|
51
|
+
|
|
52
|
+
import ComponentAPI from '@splunk/react-docs/ComponentAPI';
|
|
53
|
+
import UtilAPI from '@splunk/react-docs/UtilAPI';
|
|
54
|
+
|
|
55
|
+
import layerStackUtilDocs from '!!@splunk/jsdoc-loader!@splunk/react-ui/Layer/LayerStack';
|
|
56
|
+
import allLayerDocs from '@splunk/react-ui/Layer/Layer?parseDocs';
|
|
57
|
+
import allLayerStackDocs from '@splunk/react-ui/Layer/LayerStack?parseDocs';
|
|
58
|
+
|
|
59
|
+
const layerDocs = allLayerDocs.find((doc) => doc.displayName === 'Layer');
|
|
60
|
+
const layerStackDocs = allLayerStackDocs.find(
|
|
61
|
+
(doc) => doc.displayName === 'LayerStackGlobalProvider'
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
function DevelopSection() {
|
|
65
|
+
return [
|
|
66
|
+
<ComponentAPI docs={layerDocs} title="Layer" key="layer" />,
|
|
67
|
+
<ComponentAPI docs={layerStackDocs} title="LayerStackGlobalProvider" key="layerstack" />,
|
|
68
|
+
<UtilAPI key="layerstackutils" docs={layerStackUtilDocs} />,
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default DevelopSection;
|
|
73
|
+
|
|
74
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Layout
|
|
2
|
+
|
|
3
|
+
## Examples
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Basic
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
import React from 'react';
|
|
10
|
+
|
|
11
|
+
import Button from '@splunk/react-ui/Button';
|
|
12
|
+
import Layout from '@splunk/react-ui/Layout';
|
|
13
|
+
import Search from '@splunk/react-ui/Search';
|
|
14
|
+
import Switch from '@splunk/react-ui/Switch';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
function Basic() {
|
|
18
|
+
return (
|
|
19
|
+
<Layout>
|
|
20
|
+
<Button label="Button" />
|
|
21
|
+
<Search inline />
|
|
22
|
+
<Switch />
|
|
23
|
+
</Layout>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default Basic;
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Layout API
|
|
37
|
+
|
|
38
|
+
Renders a container to layout children using standard spacing values.
|
|
39
|
+
|
|
40
|
+
#### Props
|
|
41
|
+
|
|
42
|
+
| Name | Type | Required | Default | Description |
|
|
43
|
+
|------|------|------|------|------|
|
|
44
|
+
| children | React.ReactNode | no | | |
|
|
45
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts, and null when it unmounts. |
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
package/docs-llm/Link.md
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# Link
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a paragraph of text with a link component at the end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- When you want to navigate users to a different page within your application
|
|
11
|
+
- When you want to direct users to a location on the same page
|
|
12
|
+
- When you want to navigate users to an external site
|
|
13
|
+
|
|
14
|
+
## When to use another component
|
|
15
|
+
- If the text is not relevant or important enough to warrant additional information, do not use a link.
|
|
16
|
+
- If the content will change the data on the current page or need action from the user, use a `Button`.
|
|
17
|
+
- For revealing large amounts of information, use an `Accordion` or `Collapsible panel`.
|
|
18
|
+
|
|
19
|
+
```mermaid
|
|
20
|
+
graph TD
|
|
21
|
+
accDescr: Decision tree that guides on when to use the Link component or something else
|
|
22
|
+
A(Is the text important enough to warrant additional information?) -- Yes --- B(Will the content change data on the current page, or need action from the user?)
|
|
23
|
+
B -- Yes --- C(Button)
|
|
24
|
+
B -- No --- D(Link)
|
|
25
|
+
A -- No --- E(Do not use a link)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Check out
|
|
29
|
+
- [Button][1]
|
|
30
|
+
- [Accordion][2]
|
|
31
|
+
- [Collapsible panel][3]
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Standalone links
|
|
36
|
+
Are used on their own and should not be used within or paired with other text content. Standalone links that open in a new window are exempt from this requirement as they use an icon by default.
|
|
37
|
+
|
|
38
|
+
> Image: Example of correct and incorrect styles for standalone links. On the left is the correct example with a heart-eye emoji of a blue standalone link with no additional decorations or text. On the right is the incorrect example with a grimacing emoji with a standalone link with addition text next to it.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Limit the number of links
|
|
42
|
+
Make sure each link is necessary. Using too many links can create a “sea of blue”.
|
|
43
|
+
|
|
44
|
+
> Image: Example with heart eyes showing a small amount of links in a body of text next to a grimacing face example with too many link in a body of text.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Group links when possible
|
|
48
|
+
For multiple links on the same page, grouping the links as a bulleted list or under a suitable title like “Resources”, will help users navigate.
|
|
49
|
+
|
|
50
|
+
> Image: Illustration with two examples. First example with heart eyes has a group of links, the second example with a grimace has links scattered.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Be concise
|
|
54
|
+
Keep the link text brief while still providing enough context to convey where the link takes the user.
|
|
55
|
+
|
|
56
|
+
> Image: Illustration with two examples. The first example with heart eyes with brief link text that has enough context to convey where the link goes. The second example with grimace face has link text that is too long and not clear.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Content guidelines
|
|
60
|
+
A user should never be surprised about where a link takes them. Use descriptive labels for links so users know where they’re going and what they’ll find if they select the link.
|
|
61
|
+
|
|
62
|
+
- Keep the link text brief while still providing enough context to convey where the link takes the user.
|
|
63
|
+
- Don’t use phrases like “click here” or “here” as link text.
|
|
64
|
+
- Links should be understandable out of context. This way, they are more informative of the destination and convenient targets for pressing.
|
|
65
|
+
- Link judiciously. Too many links are a distraction.
|
|
66
|
+
|
|
67
|
+
### Links that guide you to documentation
|
|
68
|
+
The standard for writing the link text for links to Splunk documentation is to create a synopsis of the doc page title and add the word "documentation" at the end using this format: [doc page title synopsis] documentation
|
|
69
|
+
|
|
70
|
+
For example, for a doc page with the title “Configure single sign-on with SAML” you could create a link called “SAML SSO documentation”.
|
|
71
|
+
- For more detailed guidance and examples, see the [UI text style guidelines][4] in the Splunk Style Guide.
|
|
72
|
+
|
|
73
|
+
> Image: Two examples. The first with heart eyes has a modal with a link in the body with the correct formatting: Automatic UI updates documentation. The second example with a grimace has a modal with a link in the body with incorrect formatting: learn more.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Links in a sentence
|
|
77
|
+
- When multiple links are present in a single sentence, consider grouping them for better scannability and usability. This will also make it easier for screen reader users to digest additional aria-labels associated with links.
|
|
78
|
+
- Don’t link the entire sentence, only the text that describes the action or where the user goes when they select the link. If it’s a very short sentence that only describes the action, it’s okay to link the entire sentence.
|
|
79
|
+
- Avoid links breaking onto a new line.
|
|
80
|
+
- Don’t add links to Splunk product documentation in a sentence. Review "Links that guide you to documentation” section for more details.
|
|
81
|
+
|
|
82
|
+
> Image: Guidelines is a two-column chart contrasting
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
### Standalone links
|
|
86
|
+
A standalone link is a link that is not part of a sentence.
|
|
87
|
+
- Use a standalone link with the external link icon for links that navigate outside of the application.
|
|
88
|
+
- Don't use punctuation.
|
|
89
|
+
- Don’t add links to Splunk product documentation in a sentence. Review “Links that guide you to documentation” section for more details.
|
|
90
|
+
|
|
91
|
+
> Image: Guidelines for creating standalone links, which are links not part of a sentence and a chart divided into two sections labeled
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
[1]: ./Button
|
|
95
|
+
[2]: ./Accordion
|
|
96
|
+
[3]: ./CollapsiblePanel
|
|
97
|
+
[4]: https://docs.splunk.com/Documentation/StyleGuide/current/StyleGuide/UIGuidelines#Links_to_Splunk_product_documentation
|
|
98
|
+
|
|
99
|
+
## Examples
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Basic
|
|
103
|
+
|
|
104
|
+
Use the Link component instead of an <a> tag, by default it is displayed inline.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import React from 'react';
|
|
108
|
+
|
|
109
|
+
import Link from '@splunk/react-ui/Link';
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
function Basic() {
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
Use Splunk products to take advantage of one platform for all your security and
|
|
116
|
+
observability data needs. In an ever-changing world, Splunk delivers insights to unlock
|
|
117
|
+
innovation, enhance security and drive resilience.{' '}
|
|
118
|
+
<Link to="https://www.splunk.com/en_us/products/platform.html">
|
|
119
|
+
The Splunk Platform
|
|
120
|
+
</Link>{' '}
|
|
121
|
+
allows you turn data into doing to unlock innovation, enhance security and drive
|
|
122
|
+
resilience.
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default Basic;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Standalone
|
|
133
|
+
|
|
134
|
+
Use appearance="standalone" when using Link on its own without other text content.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import React from 'react';
|
|
138
|
+
|
|
139
|
+
import Link from '@splunk/react-ui/Link';
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
function Standalone() {
|
|
143
|
+
return (
|
|
144
|
+
<Link appearance="standalone" to="https://www.splunk.com/en_us/products/observability.html">
|
|
145
|
+
Splunk Observability
|
|
146
|
+
</Link>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default Standalone;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
### New Window
|
|
156
|
+
|
|
157
|
+
openInNewContext=true adds an icon and sets target to _blank. A message indicates the behavior for screen reader users. The default message, '(Opens new window)', can be customized by by passing a string to openInNewContext.
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import React from 'react';
|
|
161
|
+
|
|
162
|
+
import Link from '@splunk/react-ui/Link';
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
function NewWindow() {
|
|
166
|
+
return (
|
|
167
|
+
<Link
|
|
168
|
+
appearance="standalone"
|
|
169
|
+
to="https://www.splunk.com/en_us/products/observability.html"
|
|
170
|
+
openInNewContext
|
|
171
|
+
>
|
|
172
|
+
Splunk Observability
|
|
173
|
+
</Link>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default NewWindow;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### Disabled
|
|
183
|
+
|
|
184
|
+
Links can be disabled. The href is then removed from the markup.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import React from 'react';
|
|
188
|
+
|
|
189
|
+
import Link from '@splunk/react-ui/Link';
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
function Disabled() {
|
|
193
|
+
return (
|
|
194
|
+
<Link
|
|
195
|
+
appearance="standalone"
|
|
196
|
+
to="https://www.splunk.com/en_us/products/observability.html"
|
|
197
|
+
disabled
|
|
198
|
+
>
|
|
199
|
+
Splunk Observability
|
|
200
|
+
</Link>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default Disabled;
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
### Visited
|
|
210
|
+
|
|
211
|
+
Enable visited link styling using the LinkProvider.
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import React from 'react';
|
|
215
|
+
|
|
216
|
+
import Link, { LinkProvider } from '@splunk/react-ui/Link';
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
const Visited = () => (
|
|
220
|
+
<LinkProvider enableVisitedStyling>
|
|
221
|
+
<p>After visiting the link below, its color will change.</p>
|
|
222
|
+
<Link to="https://www.splunk.com" openInNewContext>
|
|
223
|
+
Splunk.com
|
|
224
|
+
</Link>
|
|
225
|
+
</LinkProvider>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
export default Visited;
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
## API
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
### Link API
|
|
238
|
+
|
|
239
|
+
`Link` is a simple method for configuring `Button` for inline links. For more complex behaviors,
|
|
240
|
+
see the `Button` documentation.
|
|
241
|
+
|
|
242
|
+
#### Props
|
|
243
|
+
|
|
244
|
+
| Name | Type | Required | Default | Description |
|
|
245
|
+
|------|------|------|------|------|
|
|
246
|
+
| appearance | 'inline' \| 'standalone' | no | 'inline' | Changes the style of the link. |
|
|
247
|
+
| children | React.ReactNode | no | | |
|
|
248
|
+
| disabled | boolean | no | false | Adds an aria-disabled attribute and prevents clicking. |
|
|
249
|
+
| 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. |
|
|
250
|
+
| onClick | React.MouseEventHandler<HTMLButtonElement \| HTMLAnchorElement> | no | | The onClick event handler is ignored if Ctrl or meta keys are pressed, which allows the link to open in a new context. |
|
|
251
|
+
| openInNewContext | boolean \| string | no | false | Open the "to" link in a new context, which is usually a new tab or window based on browser settings. An icon and a screen reader message is added to indicate this behavior to users. The default message is "(Opens new window)"; this can be customized by passing a string instead of boolean to `openInNewContext`. |
|
|
252
|
+
| to | string | no | | The URL or path to link to. |
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
## Accessibility
|
|
259
|
+
|
|
260
|
+
A link enables a user to navigate through an app. If you are providing an action, use a [button][1].
|
|
261
|
+
|
|
262
|
+
## Visual Design
|
|
263
|
+
|
|
264
|
+
- **MUST** have a visual distinction beyond color, such as underline, bold, or an icon [SC 1.4.1][2]
|
|
265
|
+
|
|
266
|
+
- Color contrast ratio **MUST** be, in active, hover, and selected states:
|
|
267
|
+
- >=4.5:1 between text and background of [SC 1.4.3][3]
|
|
268
|
+
- >=3:1 between button outline color to background OR icon color to background [SC 1.4.11][4]
|
|
269
|
+
- Focus State: if the focus ring has a radius of [SC 1.4.11][4]
|
|
270
|
+
- < 3px: >=4.5.1 between button <> focus <> background
|
|
271
|
+
- > 3px: >=3.1 between button <> focus <> background
|
|
272
|
+
- Visited links **SHOULD** have a different color applied that satisfies
|
|
273
|
+
color contrast guidelines
|
|
274
|
+
|
|
275
|
+
- **MUST** have a visual element present for a link that opens a [SC 3.2][5]
|
|
276
|
+
- new tab or window non-HTML document (doc, excel spreedsheet, ppt, plain text, etc.)
|
|
277
|
+
- non-HTML document doc, excel spreedsheet, ppt, plain text, etc.
|
|
278
|
+
- new application
|
|
279
|
+
|
|
280
|
+
## States
|
|
281
|
+
|
|
282
|
+
- In-line links **SHOULD** use underline, not a focus state. This is to preserve zoom/magnification and prevent a split focus ring.
|
|
283
|
+
|
|
284
|
+
- **MUST** avoid vague or generic language such as "click here" or "read more", or acronyms that are not widely know to users [SC 2.4.4][6]
|
|
285
|
+
- **SHOULD** avoid linking entire sentences.
|
|
286
|
+
|
|
287
|
+
## Interaction Design
|
|
288
|
+
|
|
289
|
+
- **MUST** have keyboard navigation [SC 2.1][7]
|
|
290
|
+
- <kbd>Enter/Space</kbd> to execute the action for link
|
|
291
|
+
- <kbd>Tab</kbd> to move focus to next interactive element
|
|
292
|
+
- <kbd>Shift</kbd>+<kbd>Tab</kbd> to move the focus to the previous interactive element
|
|
293
|
+
|
|
294
|
+
## Implementation
|
|
295
|
+
|
|
296
|
+
- **MUST** have a visible focus border [SC 2.4.7][8]
|
|
297
|
+
- Exception is an in-line link, which **SHOULD** use an underline to preserve zoom/magnification and prevent a split focus ring
|
|
298
|
+
- **MUST** use `<a>` element with a valid href value. In rare problematic cases, setting `role="link"` (and adding all other aspects of link functionality) may be acceptable [SC 4.1.2][9]
|
|
299
|
+
- **Focus Management:** if button activation closes the containing entity or launches another
|
|
300
|
+
entity, then focus moves to the newly opened entity. If activitating a button results in the
|
|
301
|
+
control being disabled, focus should move to the next active element in the tab order.
|
|
302
|
+
- **Screen reader announcements** for when a link opens a [SC 3.2][10]:
|
|
303
|
+
- new tab or window
|
|
304
|
+
- non-HTML document (doc, excel, spreadsheet, ppt, plain text, etc)
|
|
305
|
+
- new application
|
|
306
|
+
|
|
307
|
+
[1]: https://splunkui.splunkeng.com/Packages/react-ui/Button
|
|
308
|
+
[2]: https://www.w3.org/TR/WCAG21/#use-of-color
|
|
309
|
+
[3]: https://www.w3.org/TR/WCAG21/#contrast-minimum
|
|
310
|
+
[4]: https://www.w3.org/TR/WCAG21/#non-text-contrast
|
|
311
|
+
[5]: https://www.w3.org/TR/WCAG20-TECHS/G201.html
|
|
312
|
+
[6]: https://www.w3.org/TR/WCAG21/#link-purpose-in-context%5C
|
|
313
|
+
[7]: https://www.w3.org/TR/WCAG21/#keyboard-accessible
|
|
314
|
+
[8]: https://www.w3.org/TR/WCAG21/#focus-visible
|
|
315
|
+
[9]: https://www.w3.org/TR/WCAG21/#name-role-value
|
|
316
|
+
[10]: https://www.w3.org/TR/WCAG20-TECHS/G201.html
|
|
317
|
+
|
|
318
|
+
|