@reliability-design/web 1.0.2 → 1.0.6
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/dist/components/rel-accordion/README.md +132 -0
- package/dist/components/rel-accordion/rel-accordion.ts +61 -29
- package/dist/components/rel-alert/README.md +141 -0
- package/dist/components/rel-alert/rel-alert.ts +110 -67
- package/dist/components/rel-avatar/README.md +119 -0
- package/dist/components/rel-avatar/rel-avatar.ts +8 -15
- package/dist/components/rel-badge/README.md +86 -0
- package/dist/components/rel-badge/rel-badge.ts +28 -21
- package/dist/components/rel-breadcrumb/README.md +102 -0
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +24 -18
- package/dist/components/rel-button/README.md +130 -0
- package/dist/components/rel-button/rel-button.ts +39 -59
- package/dist/components/rel-calendar/README.md +109 -0
- package/dist/components/rel-calendar/index.ts +1 -0
- package/dist/components/rel-calendar/rel-calendar.ts +467 -0
- package/dist/components/rel-card/README.md +94 -0
- package/dist/components/rel-card/rel-card.ts +21 -11
- package/dist/components/rel-cardmedia/README.md +127 -0
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +22 -18
- package/dist/components/rel-carousel/README.md +166 -0
- package/dist/components/rel-carousel/index.ts +1 -0
- package/dist/components/rel-carousel/rel-carousel.ts +469 -0
- package/dist/components/rel-chart/README.md +286 -0
- package/dist/components/rel-chart/index.ts +1 -0
- package/dist/components/rel-chart/rel-chart.ts +736 -0
- package/dist/components/rel-checkbox/README.md +77 -0
- package/dist/components/rel-checkbox/rel-checkbox.ts +36 -45
- package/dist/components/rel-chip/README.md +114 -0
- package/dist/components/rel-chip/rel-chip.ts +47 -122
- package/dist/components/rel-container/README.md +99 -0
- package/dist/components/rel-container/rel-container.ts +1 -6
- package/dist/components/rel-date-picker/README.md +253 -0
- package/dist/components/rel-date-picker/index.ts +1 -0
- package/dist/components/rel-date-picker/rel-date-picker.ts +916 -0
- package/dist/components/rel-divider/README.md +100 -0
- package/dist/components/rel-divider/rel-divider.ts +37 -37
- package/dist/components/rel-drawer/README.md +200 -0
- package/dist/components/rel-drawer/index.ts +1 -0
- package/dist/components/rel-drawer/rel-drawer.ts +621 -0
- package/dist/components/rel-kbd/README.md +151 -0
- package/dist/components/rel-kbd/rel-kbd.ts +118 -0
- package/dist/components/rel-layout/README.md +88 -0
- package/dist/components/rel-layout/rel-layout.ts +12 -14
- package/dist/components/rel-menu/README.md +151 -0
- package/dist/components/rel-menu/rel-menu.ts +18 -10
- package/dist/components/rel-menubar/README.md +329 -0
- package/dist/components/rel-menubar/index.ts +2 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +16 -0
- package/dist/components/rel-menubar/rel-menubar.ts +576 -0
- package/dist/components/rel-nav-menu/README.md +289 -0
- package/dist/components/rel-nav-menu/index.ts +3 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +143 -0
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +53 -0
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +331 -0
- package/dist/components/rel-navbar/README.md +126 -0
- package/dist/components/rel-navbar/rel-navbar.ts +91 -0
- package/dist/components/rel-otp/README.md +440 -0
- package/dist/components/rel-otp/index.ts +1 -0
- package/dist/components/rel-otp/rel-otp.ts +504 -0
- package/dist/components/rel-pagination/README.md +410 -0
- package/dist/components/rel-pagination/index.ts +1 -0
- package/dist/components/rel-pagination/rel-pagination.ts +376 -0
- package/dist/components/rel-popover/README.md +568 -0
- package/dist/components/rel-popover/index.ts +2 -0
- package/dist/components/rel-popover/rel-popover-content.ts +55 -0
- package/dist/components/rel-popover/rel-popover.ts +327 -0
- package/dist/components/rel-progress/README.md +110 -0
- package/dist/components/rel-progress/rel-progress.ts +58 -20
- package/dist/components/rel-quote-page/README.md +166 -0
- package/dist/components/rel-quote-page/rel-quote-page.ts +816 -0
- package/dist/components/rel-radio/README.md +120 -0
- package/dist/components/rel-radio/rel-radio.ts +41 -73
- package/dist/components/rel-resizable/README.md +140 -0
- package/dist/components/rel-resizable/index.ts +3 -0
- package/dist/components/rel-resizable/rel-resizable-group.ts +374 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +149 -0
- package/dist/components/rel-resizable/rel-resizable-panel.ts +47 -0
- package/dist/components/rel-segmented-button/README.md +141 -0
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +18 -13
- package/dist/components/rel-select/README.md +107 -0
- package/dist/components/rel-select/rel-select.ts +14 -14
- package/dist/components/rel-sheet/README.md +224 -0
- package/dist/components/rel-sheet/rel-sheet.ts +683 -0
- package/dist/components/rel-sidebar/README.md +209 -0
- package/dist/components/rel-sidebar/rel-sidebar.ts +1158 -0
- package/dist/components/rel-slider/README.md +135 -0
- package/dist/components/rel-slider/rel-slider.ts +19 -7
- package/dist/components/rel-snackbar/README.md +134 -0
- package/dist/components/rel-snackbar/rel-snackbar.ts +73 -2
- package/dist/components/rel-stepper/README.md +160 -0
- package/dist/components/rel-stepper/rel-stepper.ts +29 -8
- package/dist/components/rel-switch/README.md +102 -0
- package/dist/components/rel-switch/rel-switch.ts +22 -11
- package/dist/components/rel-tab/README.md +163 -0
- package/dist/components/rel-tab/rel-tab.ts +46 -22
- package/dist/components/rel-table/README.md +178 -0
- package/dist/components/rel-table/rel-table-body.ts +16 -0
- package/dist/components/rel-table/rel-table-caption.ts +22 -0
- package/dist/components/rel-table/rel-table-cell.ts +49 -0
- package/dist/components/rel-table/rel-table-footer.ts +18 -0
- package/dist/components/rel-table/rel-table-head.ts +33 -0
- package/dist/components/rel-table/rel-table-header.ts +16 -0
- package/dist/components/rel-table/rel-table-row.ts +32 -0
- package/dist/components/rel-table/rel-table.ts +47 -0
- package/dist/components/rel-textfield/README.md +90 -0
- package/dist/components/rel-textfield/rel-textfield.ts +37 -21
- package/dist/components/rel-toast/README.md +148 -0
- package/dist/components/rel-toast/rel-toast.ts +32 -14
- package/dist/components/rel-tooltip/README.md +103 -0
- package/dist/components/rel-tooltip/rel-tooltip.ts +9 -9
- package/dist/index.d.mts +846 -7
- package/dist/index.d.ts +846 -7
- package/dist/index.js +10860 -1803
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10820 -1809
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +293 -183
- package/dist/vars-ITL2K3KO.css +294 -0
- package/package.json +2 -2
- package/dist/components/rel-accordion/rel-accordion.stories.ts +0 -313
- package/dist/components/rel-alert/rel-alert.stories.ts +0 -412
- package/dist/components/rel-avatar/rel-avatar.stories.ts +0 -327
- package/dist/components/rel-badge/rel-badge.stories.ts +0 -350
- package/dist/components/rel-breadcrumb/rel-breadcrumb.stories.ts +0 -306
- package/dist/components/rel-button/rel-button.stories.ts +0 -356
- package/dist/components/rel-card/rel-card.stories.ts +0 -299
- package/dist/components/rel-cardmedia/rel-cardmedia.stories.ts +0 -368
- package/dist/components/rel-checkbox/rel-checkbox.stories.ts +0 -414
- package/dist/components/rel-chip/rel-chip.stories.ts +0 -552
- package/dist/components/rel-container/rel-container.stories.ts +0 -239
- package/dist/components/rel-divider/rel-divider.stories.ts +0 -229
- package/dist/components/rel-layout/rel-layout.stories.ts +0 -713
- package/dist/components/rel-menu/rel-menu.stories.ts +0 -910
- package/dist/components/rel-progress/rel-progress.stories.ts +0 -817
- package/dist/components/rel-radio/rel-radio.stories.ts +0 -1048
- package/dist/components/rel-segmented-button/rel-segmented-button.stories.ts +0 -1079
- package/dist/components/rel-select/rel-select.stories.ts +0 -1201
- package/dist/components/rel-slider/rel-slider.stories.ts +0 -730
- package/dist/components/rel-snackbar/rel-snackbar.stories.ts +0 -808
- package/dist/components/rel-stepper/rel-stepper.stories.ts +0 -752
- package/dist/components/rel-switch/rel-switch.stories.ts +0 -441
- package/dist/components/rel-tab/rel-tab.stories.ts +0 -492
- package/dist/components/rel-textfield/rel-textfield.stories.ts +0 -710
- package/dist/components/rel-toast/rel-toast.stories.ts +0 -394
- package/dist/components/rel-tooltip/rel-tooltip.stories.ts +0 -364
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# rel-pagination
|
|
2
|
+
|
|
3
|
+
A flexible pagination component with smart ellipsis rendering, keyboard navigation, and support for both controlled and uncontrolled modes.
|
|
4
|
+
|
|
5
|
+
## What It Is
|
|
6
|
+
|
|
7
|
+
The pagination component provides navigation through multiple pages of content. It intelligently renders page numbers with ellipsis to handle large page counts, supports Previous/Next controls, and can render either as buttons or links.
|
|
8
|
+
|
|
9
|
+
## Basic Usage
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<!-- Uncontrolled mode (manages its own state) -->
|
|
13
|
+
<rel-pagination totalPages="10" defaultPage="1"></rel-pagination>
|
|
14
|
+
|
|
15
|
+
<!-- Controlled mode (external state management) -->
|
|
16
|
+
<rel-pagination totalPages="10" page="5"></rel-pagination>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API Reference
|
|
20
|
+
|
|
21
|
+
### Attributes / Properties
|
|
22
|
+
|
|
23
|
+
| Attribute | Type | Default | Description |
|
|
24
|
+
|-----------|------|---------|-------------|
|
|
25
|
+
| `page` | number | undefined | Current page (1-based). When set, enables controlled mode |
|
|
26
|
+
| `defaultPage` | number | 1 | Initial page for uncontrolled mode |
|
|
27
|
+
| `totalPages` | number | required | Total number of pages |
|
|
28
|
+
| `siblingCount` | number | 1 | Number of pages to show around current page |
|
|
29
|
+
| `boundaryCount` | number | 1 | Number of pages to show at start/end |
|
|
30
|
+
| `disabled` | boolean | false | Disables all interactions |
|
|
31
|
+
| `density` | "comfortable" \| "compact" | "comfortable" | Spacing density |
|
|
32
|
+
| `variant` | "default" \| "icons" | "default" | Controls visual style |
|
|
33
|
+
| `hrefTemplate` | string | "" | Template for href links (e.g., "/page/{page}") |
|
|
34
|
+
| `ariaLabel` | string | "Pagination" | ARIA label for the nav element |
|
|
35
|
+
|
|
36
|
+
### Events
|
|
37
|
+
|
|
38
|
+
**rel-change**
|
|
39
|
+
|
|
40
|
+
Emitted when user selects a new page.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
detail: { page: number }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Example:**
|
|
47
|
+
```javascript
|
|
48
|
+
const pagination = document.querySelector('rel-pagination');
|
|
49
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
50
|
+
console.log('New page:', e.detail.page);
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Controlled vs Uncontrolled
|
|
55
|
+
|
|
56
|
+
### Uncontrolled Mode
|
|
57
|
+
|
|
58
|
+
Component manages its own internal state. Use `defaultPage` to set initial page.
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<rel-pagination totalPages="10" defaultPage="2"></rel-pagination>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
66
|
+
// Component has already updated its internal page
|
|
67
|
+
console.log('Changed to page:', e.detail.page);
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Controlled Mode
|
|
72
|
+
|
|
73
|
+
External code manages the page state. Set the `page` attribute.
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<rel-pagination id="controlled-pagination" totalPages="10" page="5"></rel-pagination>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
let currentPage = 5;
|
|
81
|
+
const pagination = document.getElementById('controlled-pagination');
|
|
82
|
+
|
|
83
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
84
|
+
// Update your external state
|
|
85
|
+
currentPage = e.detail.page;
|
|
86
|
+
// Update the component
|
|
87
|
+
pagination.page = currentPage;
|
|
88
|
+
|
|
89
|
+
// Fetch new data, etc.
|
|
90
|
+
fetchData(currentPage);
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Ellipsis Logic
|
|
95
|
+
|
|
96
|
+
The component intelligently renders page numbers with ellipsis based on `siblingCount` and `boundaryCount`:
|
|
97
|
+
|
|
98
|
+
### Examples
|
|
99
|
+
|
|
100
|
+
**totalPages=10, page=5, siblingCount=1, boundaryCount=1:**
|
|
101
|
+
```
|
|
102
|
+
1 … 4 5 6 … 10
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**totalPages=10, page=2, siblingCount=1, boundaryCount=1:**
|
|
106
|
+
```
|
|
107
|
+
1 2 3 … 10
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**totalPages=10, page=9, siblingCount=1, boundaryCount=1:**
|
|
111
|
+
```
|
|
112
|
+
1 … 8 9 10
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**totalPages=5, page=3 (no ellipsis needed):**
|
|
116
|
+
```
|
|
117
|
+
1 2 3 4 5
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### How It Works
|
|
121
|
+
|
|
122
|
+
1. **Boundary Pages**: Always shows `boundaryCount` pages at start and end
|
|
123
|
+
2. **Sibling Pages**: Shows `siblingCount` pages on each side of current page
|
|
124
|
+
3. **Ellipsis**: Inserted when there's a gap between visible page ranges
|
|
125
|
+
|
|
126
|
+
## Variants
|
|
127
|
+
|
|
128
|
+
### Default Variant
|
|
129
|
+
|
|
130
|
+
Shows text labels for Previous/Next buttons.
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<rel-pagination totalPages="10" variant="default"></rel-pagination>
|
|
134
|
+
<!-- Renders: [Previous] [1] [2] ... [10] [Next] -->
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Icons Variant
|
|
138
|
+
|
|
139
|
+
Shows chevron icons instead of text labels.
|
|
140
|
+
|
|
141
|
+
```html
|
|
142
|
+
<rel-pagination totalPages="10" variant="icons"></rel-pagination>
|
|
143
|
+
<!-- Renders: [<] [1] [2] ... [10] [>] -->
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Density
|
|
147
|
+
|
|
148
|
+
### Comfortable (Default)
|
|
149
|
+
|
|
150
|
+
Standard spacing with larger touch targets.
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<rel-pagination totalPages="10" density="comfortable"></rel-pagination>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- Height: 40px
|
|
157
|
+
- Font size: sm
|
|
158
|
+
- Padding: sm
|
|
159
|
+
|
|
160
|
+
### Compact
|
|
161
|
+
|
|
162
|
+
Tighter spacing for dense layouts.
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<rel-pagination totalPages="10" density="compact"></rel-pagination>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- Height: 32px
|
|
169
|
+
- Font size: xs
|
|
170
|
+
- Padding: xs
|
|
171
|
+
|
|
172
|
+
## Link Mode
|
|
173
|
+
|
|
174
|
+
Instead of buttons, render page items as links by providing an `hrefTemplate`.
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<rel-pagination
|
|
178
|
+
totalPages="10"
|
|
179
|
+
page="3"
|
|
180
|
+
hrefTemplate="/docs?page={page}">
|
|
181
|
+
</rel-pagination>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The `{page}` placeholder is replaced with the page number:
|
|
185
|
+
- Page 1 → `/docs?page=1`
|
|
186
|
+
- Page 5 → `/docs?page=5`
|
|
187
|
+
|
|
188
|
+
**Note**: Click events still emit `rel-change` events and prevent default navigation, allowing you to handle routing in JavaScript.
|
|
189
|
+
|
|
190
|
+
## Keyboard Navigation
|
|
191
|
+
|
|
192
|
+
Full keyboard accessibility:
|
|
193
|
+
|
|
194
|
+
| Key | Action |
|
|
195
|
+
|-----|--------|
|
|
196
|
+
| `Tab` / `Shift+Tab` | Navigate through page buttons and controls |
|
|
197
|
+
| `Enter` | Activate focused button/link |
|
|
198
|
+
| `Space` | Activate focused button/link |
|
|
199
|
+
|
|
200
|
+
## Accessibility
|
|
201
|
+
|
|
202
|
+
The component follows ARIA best practices:
|
|
203
|
+
|
|
204
|
+
### Semantic HTML
|
|
205
|
+
- Wrapped in `<nav>` with `role="navigation"`
|
|
206
|
+
- Configurable `aria-label` (default: "Pagination")
|
|
207
|
+
|
|
208
|
+
### Page Buttons
|
|
209
|
+
- Current page has `aria-current="page"`
|
|
210
|
+
- Each button has descriptive `aria-label`:
|
|
211
|
+
- "Go to page 1"
|
|
212
|
+
- "Go to page 2"
|
|
213
|
+
- etc.
|
|
214
|
+
|
|
215
|
+
### Controls
|
|
216
|
+
- Previous button: `aria-label="Go to previous page"`
|
|
217
|
+
- Next button: `aria-label="Go to next page"`
|
|
218
|
+
- Disabled state reflected with `disabled` attribute or `aria-disabled`
|
|
219
|
+
|
|
220
|
+
### Focus Management
|
|
221
|
+
- Visible focus indicators using focus-visible
|
|
222
|
+
- Proper tab order through page numbers
|
|
223
|
+
|
|
224
|
+
## Styling Tokens
|
|
225
|
+
|
|
226
|
+
The component uses design tokens from the Reliability Design System:
|
|
227
|
+
|
|
228
|
+
### Colors
|
|
229
|
+
- `--rel-colors-white` - Button/link background
|
|
230
|
+
- `--rel-colors-gray-heading` - Text color and active page background
|
|
231
|
+
- `--rel-colors-gray-border` - Border color
|
|
232
|
+
- `--rel-colors-gray-primary` - Hover border color
|
|
233
|
+
- `--rel-colors-gray-background` - Hover background
|
|
234
|
+
- `--rel-colors-gray-placeholder` - Ellipsis color
|
|
235
|
+
- `--rel-colors-blue-primary` - Focus outline
|
|
236
|
+
|
|
237
|
+
### Typography
|
|
238
|
+
- `--rel-fontFamilies-primary` - Font family (Poppins)
|
|
239
|
+
- `--rel-fontWeights-medium` - Default text weight
|
|
240
|
+
- `--rel-fontWeights-semibold` - Active page weight
|
|
241
|
+
- `--rel-fontSizes-sm` - Comfortable mode font size
|
|
242
|
+
- `--rel-fontSizes-xs` - Compact mode font size
|
|
243
|
+
|
|
244
|
+
### Spacing
|
|
245
|
+
- `--rel-spacing-space-3xs` (2px) - Compact gap
|
|
246
|
+
- `--rel-spacing-space-2xs` (4px) - Comfortable gap
|
|
247
|
+
- `--rel-spacing-space-xs` (8px) - Compact padding
|
|
248
|
+
- `--rel-spacing-space-sm` (12px) - Comfortable padding
|
|
249
|
+
|
|
250
|
+
### Borders
|
|
251
|
+
- `--rel-borders-width-stroke-100` (1px) - Border width
|
|
252
|
+
- `--rel-borders-radius-border-radius-200` (8px) - Border radius
|
|
253
|
+
|
|
254
|
+
## Complete Examples
|
|
255
|
+
|
|
256
|
+
### Simple Pagination
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<rel-pagination totalPages="10" defaultPage="1"></rel-pagination>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### With Event Handling
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<rel-pagination id="my-pagination" totalPages="50" defaultPage="1"></rel-pagination>
|
|
266
|
+
|
|
267
|
+
<script>
|
|
268
|
+
const pagination = document.getElementById('my-pagination');
|
|
269
|
+
|
|
270
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
271
|
+
console.log('Loading page:', e.detail.page);
|
|
272
|
+
fetchPageData(e.detail.page);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
function fetchPageData(page) {
|
|
276
|
+
// Your data fetching logic
|
|
277
|
+
}
|
|
278
|
+
</script>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Controlled with More Siblings
|
|
282
|
+
|
|
283
|
+
```html
|
|
284
|
+
<rel-pagination
|
|
285
|
+
id="controlled"
|
|
286
|
+
totalPages="100"
|
|
287
|
+
page="50"
|
|
288
|
+
siblingCount="2"
|
|
289
|
+
boundaryCount="2">
|
|
290
|
+
</rel-pagination>
|
|
291
|
+
|
|
292
|
+
<script>
|
|
293
|
+
let currentPage = 50;
|
|
294
|
+
const pagination = document.getElementById('controlled');
|
|
295
|
+
|
|
296
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
297
|
+
currentPage = e.detail.page;
|
|
298
|
+
pagination.page = currentPage;
|
|
299
|
+
updateContent(currentPage);
|
|
300
|
+
});
|
|
301
|
+
</script>
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Compact with Icons
|
|
305
|
+
|
|
306
|
+
```html
|
|
307
|
+
<rel-pagination
|
|
308
|
+
totalPages="25"
|
|
309
|
+
defaultPage="1"
|
|
310
|
+
density="compact"
|
|
311
|
+
variant="icons"
|
|
312
|
+
siblingCount="1"
|
|
313
|
+
boundaryCount="1">
|
|
314
|
+
</rel-pagination>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Link Mode for SEO
|
|
318
|
+
|
|
319
|
+
```html
|
|
320
|
+
<rel-pagination
|
|
321
|
+
totalPages="20"
|
|
322
|
+
page="5"
|
|
323
|
+
hrefTemplate="/products?page={page}"
|
|
324
|
+
siblingCount="1">
|
|
325
|
+
</rel-pagination>
|
|
326
|
+
|
|
327
|
+
<script>
|
|
328
|
+
const pagination = document.querySelector('rel-pagination');
|
|
329
|
+
|
|
330
|
+
pagination.addEventListener('rel-change', (e) => {
|
|
331
|
+
// Handle client-side navigation
|
|
332
|
+
navigateToPage(e.detail.page);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
function navigateToPage(page) {
|
|
336
|
+
// Your routing logic (e.g., History API)
|
|
337
|
+
history.pushState({}, '', `/products?page=${page}`);
|
|
338
|
+
loadPageData(page);
|
|
339
|
+
}
|
|
340
|
+
</script>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Edge Cases
|
|
344
|
+
|
|
345
|
+
### Few Pages (No Ellipsis)
|
|
346
|
+
|
|
347
|
+
When total pages is small, all pages are shown:
|
|
348
|
+
|
|
349
|
+
```html
|
|
350
|
+
<rel-pagination totalPages="5" page="3"></rel-pagination>
|
|
351
|
+
<!-- Renders: [Previous] [1] [2] [3] [4] [5] [Next] -->
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### First Page
|
|
355
|
+
|
|
356
|
+
Previous button is disabled:
|
|
357
|
+
|
|
358
|
+
```html
|
|
359
|
+
<rel-pagination totalPages="10" page="1"></rel-pagination>
|
|
360
|
+
<!-- [Previous - disabled] [1] [2] [3] ... [10] [Next] -->
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### Last Page
|
|
364
|
+
|
|
365
|
+
Next button is disabled:
|
|
366
|
+
|
|
367
|
+
```html
|
|
368
|
+
<rel-pagination totalPages="10" page="10"></rel-pagination>
|
|
369
|
+
<!-- [Previous] [1] ... [8] [9] [10] [Next - disabled] -->
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Disabled State
|
|
373
|
+
|
|
374
|
+
All interactions disabled:
|
|
375
|
+
|
|
376
|
+
```html
|
|
377
|
+
<rel-pagination totalPages="10" page="5" disabled></rel-pagination>
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Browser Support
|
|
381
|
+
|
|
382
|
+
Compatible with all modern browsers supporting:
|
|
383
|
+
- Web Components (Custom Elements v1)
|
|
384
|
+
- Shadow DOM
|
|
385
|
+
- ES2020+ features
|
|
386
|
+
|
|
387
|
+
## Framework Integration
|
|
388
|
+
|
|
389
|
+
Works seamlessly with:
|
|
390
|
+
- Vanilla JavaScript
|
|
391
|
+
- Angular
|
|
392
|
+
- React (via wrapper)
|
|
393
|
+
- Vue
|
|
394
|
+
- Any framework supporting Web Components
|
|
395
|
+
|
|
396
|
+
## Best Practices
|
|
397
|
+
|
|
398
|
+
1. **Use controlled mode** for complex state management (Redux, Vuex, etc.)
|
|
399
|
+
2. **Use uncontrolled mode** for simple cases where component can manage its own state
|
|
400
|
+
3. **Adjust siblingCount** based on available space (mobile: 0-1, desktop: 1-2)
|
|
401
|
+
4. **Use compact density** on mobile or in sidebars
|
|
402
|
+
5. **Use link mode** when SEO matters (server-rendered pagination)
|
|
403
|
+
6. **Always handle rel-change events** to update your data/UI
|
|
404
|
+
|
|
405
|
+
## Performance Notes
|
|
406
|
+
|
|
407
|
+
- Ellipsis calculation is optimized and runs only when page/total changes
|
|
408
|
+
- No unnecessary re-renders in controlled mode
|
|
409
|
+
- Minimal DOM elements (only visible pages + controls)
|
|
410
|
+
- Efficient event handling with no memory leaks
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./rel-pagination";
|