@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,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
+