@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.
- package/Accordion.js +6 -6
- package/Box.js +83 -34
- package/CHANGELOG.md +34 -0
- package/CollapsiblePanel.js +11 -11
- package/ComboBox.js +31 -27
- package/ControlGroup.js +92 -91
- package/DefinitionList.js +9 -9
- package/Drawer.d.ts +2 -0
- package/Drawer.js +679 -0
- package/DualListbox.js +1 -1
- package/JSONTree.js +73 -72
- package/Link.js +2 -2
- package/MIGRATION.md +10 -0
- package/Menu.js +338 -240
- package/Modal.js +127 -109
- package/Multiselect.js +437 -351
- package/Paginator.js +14 -12
- package/Popover.js +4 -1
- package/README.md +11 -0
- package/RadioBar.js +1 -1
- package/Search.js +103 -88
- package/Select.js +42 -40
- package/SelectBase.js +374 -328
- package/SidePanel.js +346 -167
- package/SlidingPanels.js +11 -11
- package/StepBar.js +7 -7
- package/Switch.js +5 -5
- package/Text.js +24 -24
- package/TextArea.js +7 -7
- package/TransitionOpen.js +204 -185
- 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 +298 -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 +937 -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 +586 -0
- package/docs-llm/Typography.md +125 -0
- package/docs-llm/Wait Spinner.md +121 -0
- package/docs-llm/llms.txt +97 -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/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
package/docs-llm/Code.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
# Code
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of the Code component displaying inline and block code examples.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- To display pieces of code, command-line instructions, or technical values in a way that visually distinguishes them from surrounding content.
|
|
11
|
+
|
|
12
|
+
## When to use another component
|
|
13
|
+
- For short, inline technical values (such as a command or variable name), consider using `Typography` with monospace styling applied.
|
|
14
|
+
|
|
15
|
+
### Check out
|
|
16
|
+
- [Typography][1]
|
|
17
|
+
|
|
18
|
+
## Behaviors
|
|
19
|
+
- Renders as a block-level element.
|
|
20
|
+
- Applies syntax highlighting based on the specified `language` prop.
|
|
21
|
+
- Preserves indentation and formatting.
|
|
22
|
+
- Optionally shows vertical indentation guides when the `showIndentGuide` prop is set to `true`. This can improve readability for deeply nested code (e.g., JSON or XML).
|
|
23
|
+
|
|
24
|
+
> Image: Example of the Code component showing JavaScript code with indentation guides.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
- Choose the appropriate language identifier to enable correct syntax highlighting.
|
|
29
|
+
|
|
30
|
+
> Image: Two examples of the Code component showing JavaScript code. The example on the left uses the correct value for the language prop. The example on the right shows the language prop incorrectly set to
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Content
|
|
34
|
+
- Use proper syntax and indentation to ensure readability and clarity.
|
|
35
|
+
- Provide a clear and meaningful code example—avoid placeholder text unless needed for layout purposes.
|
|
36
|
+
- Do not localize code content.
|
|
37
|
+
|
|
38
|
+
[1]: ./Typography
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Default Javascript
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import React from 'react';
|
|
47
|
+
|
|
48
|
+
import Code from '@splunk/react-ui/Code';
|
|
49
|
+
|
|
50
|
+
const source = `
|
|
51
|
+
function multiply(a, b) {
|
|
52
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
53
|
+
throw new TypeError('Expected two numbers');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const result = a * b;
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default multiply;
|
|
62
|
+
`.trim();
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
function Default() {
|
|
66
|
+
return <Code value={source} />;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default Default;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Customize Container
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import React from 'react';
|
|
78
|
+
|
|
79
|
+
import Code from '@splunk/react-ui/Code';
|
|
80
|
+
|
|
81
|
+
const source = `
|
|
82
|
+
function multiply(a, b) {
|
|
83
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
84
|
+
throw new TypeError('Expected two numbers');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const result = a * b;
|
|
88
|
+
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default multiply;
|
|
93
|
+
`.trim();
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
function CustomizeContainer() {
|
|
97
|
+
return <Code containerAppearance="section" value={source} />;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default CustomizeContainer;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Without indent guideline
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import React from 'react';
|
|
109
|
+
|
|
110
|
+
import Code from '@splunk/react-ui/Code';
|
|
111
|
+
|
|
112
|
+
const source = `
|
|
113
|
+
function multiply(a, b) {
|
|
114
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
115
|
+
throw new TypeError('Expected two numbers');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const result = a * b;
|
|
119
|
+
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default multiply;
|
|
124
|
+
`.trim();
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
function HideIndent() {
|
|
128
|
+
return <Code value={source} showIndentGuide={false} />;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default HideIndent;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### With line numbers
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import React from 'react';
|
|
140
|
+
|
|
141
|
+
import Code from '@splunk/react-ui/Code';
|
|
142
|
+
|
|
143
|
+
const source = `
|
|
144
|
+
function multiply(a, b) {
|
|
145
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
146
|
+
throw new TypeError('Expected two numbers');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const result = a * b;
|
|
150
|
+
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export default multiply;
|
|
155
|
+
`.trim();
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
function LineNumbers() {
|
|
159
|
+
return <Code showLineNumbers value={source} />;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default LineNumbers;
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
### With line numbers and custom start
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import React from 'react';
|
|
171
|
+
|
|
172
|
+
import Code from '@splunk/react-ui/Code';
|
|
173
|
+
|
|
174
|
+
const source = `
|
|
175
|
+
function multiply(a, b) {
|
|
176
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
177
|
+
throw new TypeError('Expected two numbers');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const result = a * b;
|
|
181
|
+
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export default multiply;
|
|
186
|
+
`.trim();
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
function LineNumbersCustomStart() {
|
|
190
|
+
return <Code showLineNumbers lineNumberStart={120} value={source} />;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export default LineNumbersCustomStart;
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### With line highlighting
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
import React from 'react';
|
|
202
|
+
|
|
203
|
+
import Code from '@splunk/react-ui/Code';
|
|
204
|
+
|
|
205
|
+
const source = `
|
|
206
|
+
function multiply(a, b) {
|
|
207
|
+
if (typeof a !== 'number' || typeof b !== 'number') {
|
|
208
|
+
throw new TypeError('Expected two numbers');
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const result = a * b;
|
|
212
|
+
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default multiply;
|
|
217
|
+
`.trim();
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
function LineHighlights() {
|
|
221
|
+
return <Code lineHighlights="2-4,6" value={source} />;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export default LineHighlights;
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
### Non-Javascript syntax highlighting
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import React from 'react';
|
|
233
|
+
|
|
234
|
+
import Code from '@splunk/react-ui/Code';
|
|
235
|
+
|
|
236
|
+
const css = `
|
|
237
|
+
/* An example of a css file */
|
|
238
|
+
|
|
239
|
+
.pre {
|
|
240
|
+
@mixin reset block;
|
|
241
|
+
|
|
242
|
+
line-height: 17px;
|
|
243
|
+
text-align: left;
|
|
244
|
+
tab-size: 4;
|
|
245
|
+
white-space: pre;
|
|
246
|
+
word-spacing: normal;
|
|
247
|
+
word-break: normal;
|
|
248
|
+
word-wrap: normal;
|
|
249
|
+
hyphens: none;
|
|
250
|
+
overflow-x: auto;
|
|
251
|
+
margin-bottom: 1.3em;
|
|
252
|
+
|
|
253
|
+
&::selection {
|
|
254
|
+
background: color($focusColor a(12%) s(100%));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
`.trim();
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
function Language() {
|
|
261
|
+
return <Code value={css} language="css" />;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export default Language;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
## API
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
### Code API
|
|
274
|
+
|
|
275
|
+
#### Props
|
|
276
|
+
|
|
277
|
+
| Name | Type | Required | Default | Description |
|
|
278
|
+
|------|------|------|------|------|
|
|
279
|
+
| containerAppearance | 'none' \| 'section' | no | 'none' | Change the style of the Code container. |
|
|
280
|
+
| elementRef | React.Ref<HTMLPreElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
281
|
+
| language | \| 'bash' \| 'c' \| 'clike' \| 'cpp' \| 'cs' \| 'csharp' \| 'css' \| 'html' \| 'javascript' \| 'js' \| 'json' \| 'jsx' \| 'markup' \| 'mathml' \| 'plain' \| 'plaintext' \| 'powershell' \| 'py' \| 'python' \| 'sh' \| 'shell' \| 'splunk-spl' \| 'sql' \| 'svg' \| 'text' \| 'ts' \| 'tsx' \| 'txt' \| 'typescript' \| 'xml' \| 'yaml' \| 'yml' | no | | Applies syntax highlighting for a specific programming language. |
|
|
282
|
+
| languageFallback | \| 'bash' \| 'c' \| 'clike' \| 'cpp' \| 'cs' \| 'csharp' \| 'css' \| 'html' \| 'javascript' \| 'js' \| 'json' \| 'jsx' \| 'markup' \| 'mathml' \| 'plain' \| 'plaintext' \| 'powershell' \| 'py' \| 'python' \| 'sh' \| 'shell' \| 'splunk-spl' \| 'sql' \| 'svg' \| 'text' \| 'ts' \| 'tsx' \| 'txt' \| 'typescript' \| 'xml' \| 'yaml' \| 'yml' | no | 'javascript' | In cases where `language` is not valid `Code` will use this value as the fallback for `language`. |
|
|
283
|
+
| lineHighlights | string | no | | Accepts a comma separated list of line numbers or line number ranges to highlight. example: `2,4-5` will highlight lines 2, 4 and 5. |
|
|
284
|
+
| lineNumberStart | number | no | | Optional start number when showLineNumbers is true. |
|
|
285
|
+
| showIndentGuide | boolean | no | true | Displays the indent guideline. |
|
|
286
|
+
| showLineNumbers | boolean | no | | Displays line numbers. |
|
|
287
|
+
| value | string | no | '' | Inserts code content into the code block. |
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|