@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
package/docs-llm/Date.md
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Date
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
> Image: Illustration of a Date component
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<Message appearance="fill" type="info">
|
|
11
|
+
<div>All data entry components should be wrapped in a <Link to="ControlGroup">Control Group</Link> to provide a label, error states, and help or error text, ensuring an accessible experience for all users.</div>
|
|
12
|
+
</Message>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## When to use this component
|
|
16
|
+
- When collecting date information from users like birthdays, anniversaries, or events, use a `Date` input component for a user-friendly, consistent experience.
|
|
17
|
+
- When capturing time-sensitive data such as deadlines or bookings, use a `Date` input for consistent, accurate entry.
|
|
18
|
+
- When performing calculations based on dates, such as determining the difference between two dates, `Date` will ensure a consistent format to be processed.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## When to use another component
|
|
23
|
+
- When the information being collected is not related to dates, use a different type of input component, such as a `Text` input or a `Dropdown` menu.
|
|
24
|
+
- When the date is only being displayed and not collected, use plain text instead.
|
|
25
|
+
- When non-standard date formats are required a custom date input component may be needed.
|
|
26
|
+
|
|
27
|
+
### Check out
|
|
28
|
+
- [Text][1]
|
|
29
|
+
- [Dropdown][2]
|
|
30
|
+
- [Modal] [3]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
```mermaid
|
|
34
|
+
graph TD
|
|
35
|
+
accDescr: Decision tree that guides on when to use the Date component or something else
|
|
36
|
+
A(Is the information an input?) -- Yes --- B(Is the input a date?)
|
|
37
|
+
B -- Yes --- C(Date)
|
|
38
|
+
B -- No --- D(Text, Number, other inputs)
|
|
39
|
+
A -- No --- E(Paragraph)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
### Keep input field an appropriate width
|
|
44
|
+
The `Date` input field is fixed width. Avoid resizing the field to prevent creating unnecessary space.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Content
|
|
49
|
+
|
|
50
|
+
### Set locale for regional differences
|
|
51
|
+
Utilize the locale property to specify the language and adjust the date formatting to align with the country’s conventions. The default setting is U.S. English.
|
|
52
|
+
|
|
53
|
+
### Labels
|
|
54
|
+
Keep labels brief and descriptive, using sentence-style capitalization.
|
|
55
|
+
> Image: The image shows a do-and-don’t comparison between two input field labels. The left image shows a date input field labeled
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
[1]: ./Text
|
|
59
|
+
[2]: ./Dropdown
|
|
60
|
+
[3]: ./Modal
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Controlled
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import React, { Component } from 'react';
|
|
69
|
+
|
|
70
|
+
import Date, { DateChangeHandler } from '@splunk/react-ui/Date';
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Controlled extends Component<object, { value: string }> {
|
|
74
|
+
constructor(props: object) {
|
|
75
|
+
super(props);
|
|
76
|
+
|
|
77
|
+
this.state = {
|
|
78
|
+
value: '1988-08-24',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
handleChange: DateChangeHandler = (e, { value }) => {
|
|
83
|
+
this.setState({ value });
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
render() {
|
|
87
|
+
return <Date value={this.state.value} onChange={this.handleChange} />;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default Controlled;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Uncontrolled
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import React from 'react';
|
|
100
|
+
|
|
101
|
+
import Date from '@splunk/react-ui/Date';
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
function Basic() {
|
|
105
|
+
return <Date />;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default Basic;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Locale
|
|
114
|
+
|
|
115
|
+
Setting locale is recommended. Otherwise, en_US will always be used.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import React from 'react';
|
|
119
|
+
|
|
120
|
+
import Date from '@splunk/react-ui/Date';
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
function CustomDate() {
|
|
124
|
+
return <Date defaultValue="1988-08-24" locale="ko-KR" />;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default CustomDate;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Highlight Today
|
|
133
|
+
|
|
134
|
+
Highlight today's day.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import React, { Component } from 'react';
|
|
138
|
+
|
|
139
|
+
import moment from 'moment';
|
|
140
|
+
|
|
141
|
+
import Date, { DateChangeHandler } from '@splunk/react-ui/Date';
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class HighlightToday extends Component<object, { value: string }> {
|
|
145
|
+
constructor(props: object) {
|
|
146
|
+
super(props);
|
|
147
|
+
|
|
148
|
+
const today = moment().format('YYYY-MM-DD');
|
|
149
|
+
const lastDayOfMonth = moment().endOf('month').format('YYYY-MM-DD');
|
|
150
|
+
const firstDayOfMonth = moment().startOf('month').format('YYYY-MM-DD');
|
|
151
|
+
const tomorrow = moment().add(1, 'day').format('YYYY-MM-DD');
|
|
152
|
+
|
|
153
|
+
const selectedDay = today === lastDayOfMonth ? firstDayOfMonth : tomorrow;
|
|
154
|
+
|
|
155
|
+
this.state = {
|
|
156
|
+
value: selectedDay,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handleChange: DateChangeHandler = (e, { value }) => {
|
|
161
|
+
this.setState({ value });
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
render() {
|
|
165
|
+
return <Date highlightToday value={this.state.value} onChange={this.handleChange} />;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default HighlightToday;
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### Disabled
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import React from 'react';
|
|
178
|
+
|
|
179
|
+
import Date from '@splunk/react-ui/Date';
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
function Disabled() {
|
|
183
|
+
return <Date disabled defaultValue="1988-08-24" />;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export default Disabled;
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### Error
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
import React from 'react';
|
|
195
|
+
|
|
196
|
+
import Date from '@splunk/react-ui/Date';
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
function Error() {
|
|
200
|
+
return <Date defaultValue="1988-08-24" error />;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export default Error;
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
### Without Calendar
|
|
209
|
+
|
|
210
|
+
Example with input only Date.
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import React from 'react';
|
|
214
|
+
|
|
215
|
+
import Date from '@splunk/react-ui/Date';
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
function WithoutCalendar() {
|
|
219
|
+
return <Date defaultValue="2022-08-08" inputOnly />;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default WithoutCalendar;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
## API
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
### Date API
|
|
232
|
+
|
|
233
|
+
#### Props
|
|
234
|
+
|
|
235
|
+
| Name | Type | Required | Default | Description |
|
|
236
|
+
|------|------|------|------|------|
|
|
237
|
+
| append | boolean | no | | Append removes rounded borders and the border from the right side. |
|
|
238
|
+
| canClear | boolean | no | | Include an "X" button to clear the value. |
|
|
239
|
+
| defaultValue | string | no | | Default date to display. Set this instead of value to make the Date uncontrolled. |
|
|
240
|
+
| describedBy | string | no | | The id of the description. When placed in a ControlGroup, this automatically set to the ControlGroup's help component. |
|
|
241
|
+
| disabled | boolean | no | | Add a disabled attribute and prevent clicking. |
|
|
242
|
+
| elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
243
|
+
| error | boolean | no | | Highlight the field as having an error. The border and text will turn red. |
|
|
244
|
+
| highlightToday | boolean | no | | Highlight today's day. |
|
|
245
|
+
| inline | boolean | no | true | When false, display as inline-block with the default width. |
|
|
246
|
+
| inputId | string | no | | An id for the input, which may be necessary for accessibility, such as for aria attributes. |
|
|
247
|
+
| inputOnly | boolean | no | | Whether or not to display the calendar menu. |
|
|
248
|
+
| labelledBy | string | no | | The id of the label. When placed in a ControlGroup, this automatically set to the ControlGroup's label. |
|
|
249
|
+
| locale | string | no | 'en_US' | Locale set by language and localization specifiers. |
|
|
250
|
+
| name | string | no | | The name is returned with onChange events, which can be used to identify the control when multiple controls share an onChange callback. |
|
|
251
|
+
| onBlur | DateBlurHandler | no | | A callback for when the input loses focus. |
|
|
252
|
+
| onChange | DateChangeHandler | no | | Return event and data object with date string (in YYYY-MM-DD format) when a date is selected. |
|
|
253
|
+
| onClick | React.MouseEventHandler<HTMLInputElement> | no | | |
|
|
254
|
+
| onFocus | DateFocusHandler | no | | |
|
|
255
|
+
| onKeyDown | React.KeyboardEventHandler<HTMLInputElement> | no | | |
|
|
256
|
+
| prepend | boolean | no | | Prepend removes rounded borders from the left side. |
|
|
257
|
+
| value | string | no | | Setting this value makes the property controlled. An onChange callback is required. The value must be "" or in the format 'YYYY-MM-DD'. To simplify creation of these strings, Date provides a Moment.js formatting string: ``` moment().format(Date.momentFormat); ``` |
|
|
258
|
+
|
|
259
|
+
#### Types
|
|
260
|
+
|
|
261
|
+
| Name | Type | Description |
|
|
262
|
+
|------|------|------|
|
|
263
|
+
| DateBlurHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; } ) => void | |
|
|
264
|
+
| DateChangeHandler | ( event: \| React.MouseEvent<HTMLButtonElement \| HTMLDivElement> \| React.KeyboardEvent<HTMLInputElement> \| React.KeyboardEvent<HTMLDivElement> \| KeyboardEvent \| MouseEvent \| TouchEvent \| undefined, data: { name?: string; value: string; } ) => void | |
|
|
265
|
+
| DateFocusHandler | ( event: React.FocusEvent<HTMLInputElement>, data: { name?: string; value: string; } ) => void | |
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Definition List
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a Definition List component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- The information involves a clear relationship, with pairs where each "key" has a specific "value" associated with it. This is ideal for scenarios where users need to quickly understand a direct relationship or attribute.
|
|
11
|
+
- If the user needs to see a comparison or detailed information about specific attributes, a definition list is easy to scan.
|
|
12
|
+
|
|
13
|
+
## When to use another component
|
|
14
|
+
- Use a List when dealing with multiple similar items, sequential or hierarchical data, or when the data is not paired.
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
graph TD
|
|
18
|
+
accDescr: Decision tree that guides on when to use the DefinitionList component or something else
|
|
19
|
+
A("Does your data have a clear relationship with a key (label) and value(s)?") -- Yes --- B(Definition List)
|
|
20
|
+
A -- No --- C(List or Paragraph)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Check out
|
|
24
|
+
- [List][1]
|
|
25
|
+
- [Paragraph][2]
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Clear relationships
|
|
30
|
+
Definition List is best at displaying a group of independent key-value pairs. There shouldn’t be a specific relationship between the pairs, such as sequential or hierarchical data.
|
|
31
|
+
|
|
32
|
+
> Image: Two examples of a Definition List with three key-value pairs. In the first example with heart eyes emoji, the key value pairs are
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Key-value groups
|
|
36
|
+
Key-value relationships do not have to be one-to-one. There can be multiple values for one key label.
|
|
37
|
+
|
|
38
|
+
> Image: Two examples of Definition List that illustrates key-value groups. In the first example with heart eyes emoji, there is a Definition List with the key-value pair,
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Wrap long values
|
|
42
|
+
Long strings can be wrapped to the next line to ensure users can see the whole content.
|
|
43
|
+
|
|
44
|
+
> Image: Two examples of Definition list with three key-value pairs. In both examples the Definition List has the key-value pairs,
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Content
|
|
48
|
+
- Follow writing best practices for Definitions Lists outlined in the [Splunk Style Guide][3]
|
|
49
|
+
|
|
50
|
+
### Mutually exclusive labels
|
|
51
|
+
Each key and value label should be distinct so that users can clearly differentiate between them.
|
|
52
|
+
|
|
53
|
+
> Image: Two examples that illustrate mutually exclusive labels. In the first example with heart eyes emoji, there is a Definition List with three key-value pairs,
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Be concise
|
|
57
|
+
Use sentence-style capitalization and keep labels concise.
|
|
58
|
+
|
|
59
|
+
> Image: Two examples of a Definition List with three key-value pairs. In the first example with heart eyes emoji, the key labels are
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
[1]: ./List
|
|
63
|
+
[2]: ./Paragraph
|
|
64
|
+
[3]: https://docs.splunk.com/Documentation/StyleGuide/current/StyleGuide/Definitionlists
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Basic
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import React from 'react';
|
|
73
|
+
|
|
74
|
+
import DL, { Term as DT, Description as DD } from '@splunk/react-ui/DefinitionList';
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
function Basic() {
|
|
78
|
+
return (
|
|
79
|
+
<DL layout="auto">
|
|
80
|
+
<DT>Name</DT>
|
|
81
|
+
<DD>Splunk</DD>
|
|
82
|
+
<DT>Type</DT>
|
|
83
|
+
<DD>Public</DD>
|
|
84
|
+
<DT>Founders</DT>
|
|
85
|
+
<DD>Michael Baum</DD>
|
|
86
|
+
<DD>Rob Das</DD>
|
|
87
|
+
<DD>Erik Swan</DD>
|
|
88
|
+
<DT>Headquarters</DT>
|
|
89
|
+
<DD>San Francisco, CA</DD>
|
|
90
|
+
</DL>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default Basic;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Stacked layout
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import React from 'react';
|
|
103
|
+
|
|
104
|
+
import DL from '@splunk/react-ui/DefinitionList';
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function StackedLayout() {
|
|
108
|
+
return (
|
|
109
|
+
<DL layout="stacked">
|
|
110
|
+
<DL.Term>Term</DL.Term>
|
|
111
|
+
<DL.Description>Description</DL.Description>
|
|
112
|
+
<DL.Term>This is stacked layout.</DL.Term>
|
|
113
|
+
<DL.Description>Stacked layout places each term above its description.</DL.Description>
|
|
114
|
+
</DL>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default StackedLayout;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### Customized widths
|
|
124
|
+
|
|
125
|
+
The term widths and description widths can be set to a specific pixel or string value.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import React from 'react';
|
|
129
|
+
|
|
130
|
+
import DL from '@splunk/react-ui/DefinitionList';
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
function CustomizedWidths() {
|
|
134
|
+
return (
|
|
135
|
+
<DL termWidth="200px" descriptionWidth="100px">
|
|
136
|
+
<DL.Term>Location</DL.Term>
|
|
137
|
+
<DL.Description>San Jose, CA</DL.Description>
|
|
138
|
+
<DL.Term>IP Address</DL.Term>
|
|
139
|
+
<DL.Description>123.456.0.0</DL.Description>
|
|
140
|
+
<DL.Term>Device</DL.Term>
|
|
141
|
+
<DL.Description>MacBook Pro (13-inch, 2020)</DL.Description>
|
|
142
|
+
</DL>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default CustomizedWidths;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### With separator
|
|
152
|
+
|
|
153
|
+
Sets the character used to separate key-value pair
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import React from 'react';
|
|
157
|
+
|
|
158
|
+
import DefinitionList, { Term, Description } from '@splunk/react-ui/DefinitionList';
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
function WithSeparator() {
|
|
162
|
+
return (
|
|
163
|
+
<DefinitionList layout="auto" separatorCharacter="_">
|
|
164
|
+
<Term>
|
|
165
|
+
This is an example of auto layout with a separator. The term content is
|
|
166
|
+
intentionally long to demonstrate how multi-line terms appear with a separator.
|
|
167
|
+
</Term>
|
|
168
|
+
<Description>Description</Description>
|
|
169
|
+
<Term>Name</Term>
|
|
170
|
+
<Description>Jon Doe</Description>
|
|
171
|
+
<Term>Role</Term>
|
|
172
|
+
<Description>Administrator</Description>
|
|
173
|
+
<Term>Last login</Term>
|
|
174
|
+
<Description>Aug 13 2019 5:13 PM</Description>
|
|
175
|
+
<Term>Location</Term>
|
|
176
|
+
<Description>Bend, OR</Description>
|
|
177
|
+
</DefinitionList>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default WithSeparator;
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
### Empty description
|
|
187
|
+
|
|
188
|
+
Use a character and screen reader content to indicate when a description does not have a value. When there is not a better choice based on the context, use a hyphen to indicate the missing value with corresponding screen reader content.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import React from 'react';
|
|
192
|
+
|
|
193
|
+
import DL from '@splunk/react-ui/DefinitionList';
|
|
194
|
+
import ScreenReaderContent from '@splunk/react-ui/ScreenReaderContent';
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
function EmptyDescription() {
|
|
198
|
+
return (
|
|
199
|
+
<DL>
|
|
200
|
+
<DL.Term>Name</DL.Term>
|
|
201
|
+
<DL.Description>New user</DL.Description>
|
|
202
|
+
<DL.Term>Last login</DL.Term>
|
|
203
|
+
<DL.Description>
|
|
204
|
+
<span aria-hidden="true">-</span>
|
|
205
|
+
<ScreenReaderContent>No login</ScreenReaderContent>
|
|
206
|
+
</DL.Description>
|
|
207
|
+
<DL.Term>Role</DL.Term>
|
|
208
|
+
<DL.Description>Guest</DL.Description>
|
|
209
|
+
</DL>
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export default EmptyDescription;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
## API
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### DefinitionList API
|
|
223
|
+
|
|
224
|
+
#### Props
|
|
225
|
+
|
|
226
|
+
| Name | Type | Required | Default | Description |
|
|
227
|
+
|------|------|------|------|------|
|
|
228
|
+
| children | React.ReactNode | no | | |
|
|
229
|
+
| descriptionWidth | string | no | | Defines the width of the `Description`. Can be set to a specific pixel or string value. If not specified, will fill to take up available space. This prop is ignored when `layout="stacked"`. |
|
|
230
|
+
| elementRef | React.Ref<HTMLDListElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
231
|
+
| layout | 'fixed' \| 'auto' \| 'stacked' | no | 'fixed' | Sets the layout style for the definition list. - `fixed`: The `Term` uses a fixed width. The `Description` fills remaining available space. - `auto`: Both `Term` and `Description` size proportionally based on their container, taking an equal portion of available space. - `stacked`: `Term` is displayed above the `Description`. Custom `termWidth` and `descriptionWidth` are ignored. Both `Term` and `Description` size proportionally. `fixed` layout is the current default. In the next major version, this prop will default to `auto`. |
|
|
232
|
+
| separatorCharacter | string | no | | Sets the character used to separate key-value pair. Only supported in `layout="fixed"` and `layout="auto"`. Will not be rendered in `layout="stacked"`. |
|
|
233
|
+
| termWidth | string | no | '120px' | Defines the width of the `Term`. Can be set to a specific pixel or string value. The default value is ignored when `layout="auto"`. This prop is ignored when `layout="stacked"`. |
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
### DefinitionList.Term API
|
|
238
|
+
|
|
239
|
+
Container component for a `DefinitionList` term.
|
|
240
|
+
|
|
241
|
+
#### Props
|
|
242
|
+
|
|
243
|
+
| Name | Type | Required | Default | Description |
|
|
244
|
+
|------|------|------|------|------|
|
|
245
|
+
| children | React.ReactNode | yes | | |
|
|
246
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
### DefinitionList.Description API
|
|
251
|
+
|
|
252
|
+
Container component for a `DefinitionList` description.
|
|
253
|
+
|
|
254
|
+
#### Props
|
|
255
|
+
|
|
256
|
+
| Name | Type | Required | Default | Description |
|
|
257
|
+
|------|------|------|------|------|
|
|
258
|
+
| children | React.ReactNode | yes | | |
|
|
259
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
## Accessibility
|
|
266
|
+
|
|
267
|
+
## Visual Design
|
|
268
|
+
- Color contrast ratio **MUST** be [SC 1.4.3][1]:
|
|
269
|
+
- >= 3:1 for icon and caret (>) against page background
|
|
270
|
+
- >= 4:5:1 for functional text against page background
|
|
271
|
+
|
|
272
|
+
## Implementation
|
|
273
|
+
- **MUST** use HTML semantics: `<ul>` or `<ol>` with `<li>` child elements, or `<dl>` with `<dt>` and `<dd>` child elements [SC 1.3.1][2]
|
|
274
|
+
|
|
275
|
+
[1]: https://www.w3.org/TR/WCAG21/#contrast-minimum
|
|
276
|
+
[2]: https://www.w3.org/TR/WCAG21/#info-and-relationships
|
|
277
|
+
|
|
278
|
+
|