@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,395 @@
|
|
|
1
|
+
# Paginator
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of a Paginator component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- When you have a large amount of data or content that needs to be divided into smaller, more manageable chunks for users to view sequentially.
|
|
11
|
+
- When you want to maintain performance and reduce load times by displaying only a subset of data at a time.
|
|
12
|
+
- When users need to navigate a gallery of content, such as videos.
|
|
13
|
+
|
|
14
|
+
## When to use another component
|
|
15
|
+
- If you only have a small amount of data to display, such as single page content.
|
|
16
|
+
|
|
17
|
+
```mermaid
|
|
18
|
+
graph TD
|
|
19
|
+
accDescr: Decision tree that guides on when to use the Paginator component or something else
|
|
20
|
+
A(Does the user need to sequentially navigate a large data collection?) -- Yes --- B(Paginator)
|
|
21
|
+
A -- No --- C(Does the user prefer uninterrupted scrolling through data?)
|
|
22
|
+
C -- Yes --- D(Infinite Scroll)
|
|
23
|
+
C -- No --- E(Load More Button)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Appearance
|
|
28
|
+
|
|
29
|
+
#### Grouping variants
|
|
30
|
+
Use a Paginator at the top and bottom of longer tables for improved keyboard navigation.
|
|
31
|
+
|
|
32
|
+
> Image: Illustration of a data table component utilizing both the compact and default paginator. The compact Paginator is at the top of the table, right aligned, and it includes the Page Control. The default Paginator is at the bottom of the table.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Behaviors
|
|
36
|
+
The paginator automatically indicates when users are on the first or last page by disabling the previous or next buttons as needed.
|
|
37
|
+
|
|
38
|
+
> Image: Examples illustrating the disabled and enabled states as a visual indicator for navigation controls.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Default
|
|
44
|
+
|
|
45
|
+
> Image: Example of Default Paginator, showing the first page as active.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Page Control
|
|
49
|
+
The Page Control is utilized only with the Compact variant of the Paginator component.
|
|
50
|
+
|
|
51
|
+
> Image: Example of Page Control Paginator, with the label displaying the total page number.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Page Control without a label
|
|
55
|
+
Use Page Control without a label when there's a need to save space within a page.
|
|
56
|
+
|
|
57
|
+
> Image: Example of Page Control Paginator, without the label.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Compact
|
|
61
|
+
|
|
62
|
+
> Image: Example of Compact Paginator, with the label displaying the total page number.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Compact without a label
|
|
66
|
+
|
|
67
|
+
> Image: Example of Compact Paginator, without the label.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Loading
|
|
71
|
+
Use [Wait Spinner] [1] when a page change is initiated and will only take a few seconds.
|
|
72
|
+
|
|
73
|
+
> Image: Examples illustrating the Paginator with a table and a wait spinner. The first example, marked with a heart eyes emoji, displays the paginator component with the data table and a wait spinner as the user navigates to a second page. The second example, identified by a grimacing face emoji, presents the paginator component with an empty table and no spinner as the user navigates to the second page.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### Paginator with table
|
|
77
|
+
|
|
78
|
+
The Paginator can be paired with other components, such as the [Table][2], enabling users to navigate data sets in a specific order.
|
|
79
|
+
|
|
80
|
+
> Image: An abstract illustration of a data table with a Paginator component.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Navigating galleries
|
|
84
|
+
|
|
85
|
+
The Paginator can be also utilized to navigate [Card] [3] galleries and other sequential content.
|
|
86
|
+
|
|
87
|
+
> Image: An abstract illustration with three cards in preview and a paginator.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
[1]: ./WaitSpinner
|
|
91
|
+
[2]: ./Table
|
|
92
|
+
[3]: ./Card
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Basic
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import React, { useState } from 'react';
|
|
102
|
+
|
|
103
|
+
import Paginator, { PaginatorChangeHandler } from '@splunk/react-ui/Paginator';
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
function Basic() {
|
|
107
|
+
const [pageNum, setPageNum] = useState(3);
|
|
108
|
+
|
|
109
|
+
const handleChange: PaginatorChangeHandler = (event, { page }) => {
|
|
110
|
+
setPageNum(page);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Paginator
|
|
115
|
+
onChange={handleChange}
|
|
116
|
+
current={pageNum}
|
|
117
|
+
alwaysShowLastPageLink
|
|
118
|
+
totalPages={30}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default Basic;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Labelled
|
|
129
|
+
|
|
130
|
+
When possible, a Paginator should use aria-labelledby or aria-label to provide an accessible label describing the content that is being paginated.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import React, { useState } from 'react';
|
|
134
|
+
|
|
135
|
+
import Heading from '@splunk/react-ui/Heading';
|
|
136
|
+
import Paginator, { PaginatorChangeHandler } from '@splunk/react-ui/Paginator';
|
|
137
|
+
import { createDOMID } from '@splunk/ui-utils/id';
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
function Labelled() {
|
|
141
|
+
const [pageNum, setPageNum] = useState(3);
|
|
142
|
+
|
|
143
|
+
const handleChange: PaginatorChangeHandler = (event, { page }) => {
|
|
144
|
+
setPageNum(page);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const labelId = createDOMID('labelled');
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<>
|
|
151
|
+
<Heading level={4} id={labelId} style={{ margin: 0 }}>
|
|
152
|
+
Paginated content example
|
|
153
|
+
</Heading>
|
|
154
|
+
<Paginator
|
|
155
|
+
aria-labelledby={labelId}
|
|
156
|
+
onChange={handleChange}
|
|
157
|
+
current={pageNum}
|
|
158
|
+
alwaysShowLastPageLink
|
|
159
|
+
totalPages={30}
|
|
160
|
+
/>
|
|
161
|
+
</>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export default Labelled;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
### Page control
|
|
171
|
+
|
|
172
|
+
A Paginator control that allows any page to be selected.
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import React, { useState } from 'react';
|
|
176
|
+
|
|
177
|
+
import Paginator, { PaginatorPageControlChangeHandler } from '@splunk/react-ui/Paginator';
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
function PageControl() {
|
|
181
|
+
const [pageNum, setPageNum] = useState(3);
|
|
182
|
+
|
|
183
|
+
const handleChange: PaginatorPageControlChangeHandler = (event, { page }) => {
|
|
184
|
+
setPageNum(page);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return <Paginator.PageControl onChange={handleChange} current={pageNum} totalPages={30} />;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default PageControl;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
### Custom pages
|
|
196
|
+
|
|
197
|
+
Customize Paginator's pages and Prev/Next buttons with generatePageProps.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import React, { useState } from 'react';
|
|
201
|
+
|
|
202
|
+
import Paginator, {
|
|
203
|
+
PaginatorGeneratePageProps,
|
|
204
|
+
PaginatorChangeHandler,
|
|
205
|
+
} from '@splunk/react-ui/Paginator';
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
function CustomPages() {
|
|
209
|
+
const [currentPage, setCurrentPage] = useState<number>(3);
|
|
210
|
+
|
|
211
|
+
const handleChange: PaginatorChangeHandler = (e, { page }) => {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
setCurrentPage(page);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const generatePageProps: PaginatorGeneratePageProps = ({ page }) => {
|
|
217
|
+
return {
|
|
218
|
+
to: `#page-${page}`,
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<Paginator
|
|
224
|
+
alwaysShowLastPageLink
|
|
225
|
+
generatePageProps={generatePageProps}
|
|
226
|
+
current={currentPage}
|
|
227
|
+
onChange={handleChange}
|
|
228
|
+
totalPages={30}
|
|
229
|
+
/>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export default CustomPages;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
### Compact
|
|
239
|
+
|
|
240
|
+
A Paginator control with buttons only.
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
import React, { useState } from 'react';
|
|
244
|
+
|
|
245
|
+
import Paginator, { PaginatorCompactChangeHandler } from '@splunk/react-ui/Paginator';
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
function Compact() {
|
|
249
|
+
const [pageNum, setPageNum] = useState<number | undefined>(3);
|
|
250
|
+
|
|
251
|
+
const handleChange: PaginatorCompactChangeHandler = (event, { page }) => {
|
|
252
|
+
setPageNum(page);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
return <Paginator.Compact current={pageNum} onChange={handleChange} totalPages={30} />;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export default Compact;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
### Compact with label
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import React, { useState } from 'react';
|
|
267
|
+
|
|
268
|
+
import Paginator, { PaginatorCompactChangeHandler } from '@splunk/react-ui/Paginator';
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
function CompactWithLabel() {
|
|
272
|
+
const [pageNum, setPageNum] = useState<number | undefined>(3);
|
|
273
|
+
|
|
274
|
+
const handleChange: PaginatorCompactChangeHandler = (event, { page }) => {
|
|
275
|
+
setPageNum(page);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<Paginator.Compact current={pageNum} onChange={handleChange} renderLabel totalPages={30} />
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export default CompactWithLabel;
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
### Compact with custom label
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
import React, { useState } from 'react';
|
|
292
|
+
|
|
293
|
+
import Paginator, { PaginatorCompactChangeHandler } from '@splunk/react-ui/Paginator';
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
function CompactCustomLabel() {
|
|
297
|
+
const [pageNum, setPageNum] = useState<number | undefined>(1);
|
|
298
|
+
const itemsPerPage = 50;
|
|
299
|
+
const totalItems = 300;
|
|
300
|
+
|
|
301
|
+
const handleChange: PaginatorCompactChangeHandler = (event, { page }) => {
|
|
302
|
+
setPageNum(page);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<Paginator.Compact
|
|
307
|
+
current={pageNum}
|
|
308
|
+
onChange={handleChange}
|
|
309
|
+
renderLabel={({ current }) => {
|
|
310
|
+
if (current) {
|
|
311
|
+
const pageEnd = current * itemsPerPage;
|
|
312
|
+
const pageStart = pageEnd - itemsPerPage + 1;
|
|
313
|
+
return `${pageStart}-${pageEnd} of ${totalItems}`;
|
|
314
|
+
}
|
|
315
|
+
return `0-${itemsPerPage} of ${totalItems}`;
|
|
316
|
+
}}
|
|
317
|
+
totalPages={totalItems / itemsPerPage}
|
|
318
|
+
/>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export default CompactCustomLabel;
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
## API
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
### Paginator API
|
|
332
|
+
|
|
333
|
+
#### Props
|
|
334
|
+
|
|
335
|
+
| Name | Type | Required | Default | Description |
|
|
336
|
+
|------|------|------|------|------|
|
|
337
|
+
| alwaysShowLastPageLink | boolean | no | false | Displays a link to the last page in a collection. |
|
|
338
|
+
| current | number | no | 1 | Currently selected page. |
|
|
339
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
340
|
+
| generatePageProps | PaginatorGeneratePageProps | no | | Passes props to Paginator's pages and Prev/Next buttons. Supports [Clickable](./Clickable) props (except for `onClick`) and global HTML attributes. `generatePageProps` will not differentiate between Prev/Next buttons and its corresponding page. For example, if page 5 is passed prop P and current is 6, the Prev button will also be passed prop P. |
|
|
341
|
+
| numPageLinks | number | no | 5 | Number of pages to display. If greater than `totalPages`, `totalPages` is used instead. |
|
|
342
|
+
| onChange | PaginatorChangeHandler | no | | Callback to handle page change. |
|
|
343
|
+
| totalPages | number | yes | | The total number of pages. |
|
|
344
|
+
|
|
345
|
+
#### Types
|
|
346
|
+
|
|
347
|
+
| Name | Type | Description |
|
|
348
|
+
|------|------|------|
|
|
349
|
+
| PaginatorChangeHandler | ( event: React.MouseEvent<HTMLButtonElement>, data: { page: number } ) => void | |
|
|
350
|
+
| PaginatorGeneratePageProps | ({ page, }: { page: number; }) => Partial<React.ComponentProps<typeof Clickable>> & React.ComponentProps<'a'> & React.ComponentProps<'button'> | |
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
### Page Control API
|
|
355
|
+
|
|
356
|
+
#### Props
|
|
357
|
+
|
|
358
|
+
| Name | Type | Required | Default | Description |
|
|
359
|
+
|------|------|------|------|------|
|
|
360
|
+
| current | number | no | 1 | Currently selected page. |
|
|
361
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
362
|
+
| onChange | PaginatorPageControlChangeHandler | no | | Callback to handle page change. |
|
|
363
|
+
| totalPages | number | yes | | The total number of pages. |
|
|
364
|
+
|
|
365
|
+
#### Types
|
|
366
|
+
|
|
367
|
+
| Name | Type | Description |
|
|
368
|
+
|------|------|------|
|
|
369
|
+
| PaginatorPageControlChangeHandler | ( event: React.MouseEvent<HTMLButtonElement> \| React.KeyboardEvent<HTMLInputElement>, data: { page: number } ) => void | |
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
### Compact API
|
|
374
|
+
|
|
375
|
+
#### Props
|
|
376
|
+
|
|
377
|
+
| Name | Type | Required | Default | Description |
|
|
378
|
+
|------|------|------|------|------|
|
|
379
|
+
| current | number | no | | The current page number. If not provided, the component will not keep track of the page number and will not provide it in the callback. |
|
|
380
|
+
| elementRef | React.Ref<HTMLElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
381
|
+
| onChange | PaginatorCompactChangeHandler | no | | Callback to handle page change. |
|
|
382
|
+
| renderLabel | boolean \| PaginatorCompactRenderLabelCallback | no | | If true, renders the a label for the current and total pages. Can be passed a function to render a custom label that receives an object with current and totalPages as an argument. |
|
|
383
|
+
| totalPages | number | no | | The total number of pages. If not provided, the component will operate in indeterminate mode and will not prevent the current page number from exceeding any values. |
|
|
384
|
+
|
|
385
|
+
#### Types
|
|
386
|
+
|
|
387
|
+
| Name | Type | Description |
|
|
388
|
+
|------|------|------|
|
|
389
|
+
| PaginatorCompactChangeHandler | ( event: React.MouseEvent<HTMLButtonElement> \| React.KeyboardEvent<HTMLInputElement>, data: { direction: 'prev' \| 'next'; page?: number } ) => void | |
|
|
390
|
+
| PaginatorCompactRenderLabelCallback | (data: { current?: number; totalPages?: number; }) => React.ReactNode | |
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Paragraph
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> Image: Illustration of Paragraph component.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## When to use this component
|
|
10
|
+
- To provide a structured layout for textual sentence-style information.
|
|
11
|
+
|
|
12
|
+
## When to use another component
|
|
13
|
+
- If the content involves listing or numbering items, using `List` improves readability and organization.
|
|
14
|
+
- If the content involves related data elements, using `Definition List` provides a structured visual representation for key-value pairs.
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
graph TD
|
|
18
|
+
accDescr: Decision tree that guides on when to use the Paragraph component or something else
|
|
19
|
+
A(Does the content involve listing items?) -- Yes --- B(List or Definition List)
|
|
20
|
+
A -- No --- C(Paragraph)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Check out
|
|
24
|
+
- [List][1]
|
|
25
|
+
- [Definition List][2]
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Break paragraphs into small chunks
|
|
30
|
+
Shorter paragraphs improves readability and reduces eye fatigue.
|
|
31
|
+
|
|
32
|
+
> Image: Examples of Paragraph components. In the first example with heart eyes emoji, the text is formatted into two smaller paragraphs. In the second example with grimacing emoji the text is formatted in one longer paragraph.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Avoid standalone paragraphs
|
|
36
|
+
Paragraphs should be accompanied by a header that summarizes the content, guides the user’s attention and allows screen readers to navigate to the content.
|
|
37
|
+
|
|
38
|
+
> Image: Examples of Paragraph components. In the first example with heart eyes emoji, the paragraph is accompanied by a header, while the second example with grimacing emoji is a stand alone paragraph.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Content guidelines
|
|
42
|
+
Follow writing best practices outlined in the [UI text style guidelines][3]
|
|
43
|
+
|
|
44
|
+
[1]: ./List
|
|
45
|
+
[2]: ./DefinitionList
|
|
46
|
+
[3]: https://docs.splunk.com/Documentation/StyleGuide/current/StyleGuide/UIGuidelines
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Basic
|
|
53
|
+
|
|
54
|
+
Paragraph provides default fonts, line heights, and spacing. Margins can be removed when necessary.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import React from 'react';
|
|
58
|
+
|
|
59
|
+
import Link from '@splunk/react-ui/Link';
|
|
60
|
+
import P from '@splunk/react-ui/Paragraph';
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
function Basic() {
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<P>
|
|
67
|
+
Use Splunk products to take advantage of one platform for all your security and
|
|
68
|
+
observability data needs. In an ever-changing world, Splunk delivers insights to
|
|
69
|
+
unlock innovation, enhance security and drive resilience.
|
|
70
|
+
</P>
|
|
71
|
+
<P>
|
|
72
|
+
<Link to="https://www.splunk.com/en_us/products/platform.html" openInNewContext>
|
|
73
|
+
The Splunk Platform
|
|
74
|
+
</Link>{' '}
|
|
75
|
+
allows you turn data into doing to unlock innovation, enhance security and drive
|
|
76
|
+
resilience.{' '}
|
|
77
|
+
<Link
|
|
78
|
+
to="https://www.splunk.com/en_us/products/cyber-security.html"
|
|
79
|
+
openInNewContext
|
|
80
|
+
>
|
|
81
|
+
Splunk Security
|
|
82
|
+
</Link>{' '}
|
|
83
|
+
protects your business and modernize your security operations with a best-in-class
|
|
84
|
+
data platform, advanced analytics and automated investigations and response.{' '}
|
|
85
|
+
<Link
|
|
86
|
+
to="https://www.splunk.com/en_us/products/observability.html"
|
|
87
|
+
openInNewContext
|
|
88
|
+
>
|
|
89
|
+
Splunk Observability
|
|
90
|
+
</Link>{' '}
|
|
91
|
+
solves problems in seconds with the only full-stack, analytics-powered and
|
|
92
|
+
OpenTelemetry-native observability solution.
|
|
93
|
+
</P>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default Basic;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## API
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Paragraph API
|
|
108
|
+
|
|
109
|
+
#### Props
|
|
110
|
+
|
|
111
|
+
| Name | Type | Required | Default | Description |
|
|
112
|
+
|------|------|------|------|------|
|
|
113
|
+
| children | React.ReactNode | no | | Generally text, but might also include `Link`s. |
|
|
114
|
+
| elementRef | React.Ref<HTMLParagraphElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## Accessibility
|
|
121
|
+
|
|
122
|
+
## Visual Design
|
|
123
|
+
- Color contrast ratio **MUST** be [SC 1.4.3][1]
|
|
124
|
+
- >= 4.5:1 for normal text: 14 pt (typically 18.66px) and bold or larger
|
|
125
|
+
- >= 3:1 for large text: 18 pt (typically 24px) or larger
|
|
126
|
+
- For high contrast mode, ratios **MUST** be >=7:1 for normal text and >=4.5:1 for large text [SC 1.4.6][2]
|
|
127
|
+
|
|
128
|
+
## States
|
|
129
|
+
- Color contrast guidelines do NOT apply to disabled text
|
|
130
|
+
|
|
131
|
+
## Interaction Model
|
|
132
|
+
- **MUST NOT** lose content or functionality when the user adapts [SC 1.4.12][3]
|
|
133
|
+
- Line height (line spacing) to at least 1.5 times the font size;
|
|
134
|
+
- Spacing following paragraphs to at least 2 times the font size;
|
|
135
|
+
- Letter spacing (tracking) to at least 0.12 times the font size;
|
|
136
|
+
- Word spacing to at least 0.16 times the font size
|
|
137
|
+
- Line spacing (leading) **MUST** be at least space-and-a-half within paragraphs, and paragraph spacing is at least 1.5 times larger than the line spacing [SC 1.4.8][4]
|
|
138
|
+
|
|
139
|
+
## Implementation
|
|
140
|
+
- **SHOULD** use correct [phrasing elements][5] to describe the semantics of the content
|
|
141
|
+
|
|
142
|
+
[1]: https://www.w3.org/WAI/GL/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html
|
|
143
|
+
[2]: https://www.w3.org/TR/WCAG21/#contrast-enhanced
|
|
144
|
+
[3]: https://www.w3.org/TR/WCAG21/#text-spacing
|
|
145
|
+
[4]: https://www.w3.org/TR/WCAG21/#visual-presentation
|
|
146
|
+
[5]: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#phrasing_content
|
|
147
|
+
|
|
148
|
+
|