@alaarab/ogrid-mcp 2.4.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/README.md +68 -0
- package/bundled-docs/api/README.md +94 -0
- package/bundled-docs/api/column-def.mdx +379 -0
- package/bundled-docs/api/components-column-chooser.mdx +310 -0
- package/bundled-docs/api/components-column-header-filter.mdx +363 -0
- package/bundled-docs/api/components-datagrid-table.mdx +316 -0
- package/bundled-docs/api/components-pagination-controls.mdx +344 -0
- package/bundled-docs/api/components-sidebar.mdx +427 -0
- package/bundled-docs/api/components-status-bar.mdx +309 -0
- package/bundled-docs/api/grid-api.mdx +299 -0
- package/bundled-docs/api/js-api.mdx +198 -0
- package/bundled-docs/api/ogrid-props.mdx +244 -0
- package/bundled-docs/api/types.mdx +640 -0
- package/bundled-docs/features/cell-references.mdx +225 -0
- package/bundled-docs/features/column-chooser.mdx +279 -0
- package/bundled-docs/features/column-groups.mdx +290 -0
- package/bundled-docs/features/column-pinning.mdx +282 -0
- package/bundled-docs/features/column-reordering.mdx +359 -0
- package/bundled-docs/features/column-types.mdx +181 -0
- package/bundled-docs/features/context-menu.mdx +216 -0
- package/bundled-docs/features/csv-export.mdx +227 -0
- package/bundled-docs/features/editing.mdx +377 -0
- package/bundled-docs/features/filtering.mdx +330 -0
- package/bundled-docs/features/formulas.mdx +381 -0
- package/bundled-docs/features/grid-api.mdx +311 -0
- package/bundled-docs/features/keyboard-navigation.mdx +236 -0
- package/bundled-docs/features/pagination.mdx +245 -0
- package/bundled-docs/features/performance.mdx +433 -0
- package/bundled-docs/features/row-selection.mdx +256 -0
- package/bundled-docs/features/server-side-data.mdx +291 -0
- package/bundled-docs/features/sidebar.mdx +234 -0
- package/bundled-docs/features/sorting.mdx +241 -0
- package/bundled-docs/features/spreadsheet-selection.mdx +201 -0
- package/bundled-docs/features/status-bar.mdx +205 -0
- package/bundled-docs/features/toolbar.mdx +284 -0
- package/bundled-docs/features/virtual-scrolling.mdx +624 -0
- package/bundled-docs/getting-started/installation.mdx +216 -0
- package/bundled-docs/getting-started/overview.mdx +151 -0
- package/bundled-docs/getting-started/quick-start.mdx +425 -0
- package/bundled-docs/getting-started/vanilla-js.mdx +191 -0
- package/bundled-docs/guides/accessibility.mdx +550 -0
- package/bundled-docs/guides/controlled-vs-uncontrolled.mdx +153 -0
- package/bundled-docs/guides/custom-cell-editors.mdx +201 -0
- package/bundled-docs/guides/framework-showcase.mdx +200 -0
- package/bundled-docs/guides/mcp-live-testing.mdx +291 -0
- package/bundled-docs/guides/mcp.mdx +172 -0
- package/bundled-docs/guides/migration-from-ag-grid.mdx +223 -0
- package/bundled-docs/guides/theming.mdx +211 -0
- package/dist/esm/bridge-client.d.ts +87 -0
- package/dist/esm/bridge-client.js +162 -0
- package/dist/esm/index.js +1060 -0
- package/package.json +43 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 10
|
|
3
|
+
title: DataGridTable
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DataGridTable
|
|
7
|
+
|
|
8
|
+
The core data grid component that renders the table structure, headers, rows, cells, and inline editing UI. `DataGridTable` is typically used internally by `OGrid`, but can also be used standalone for custom layouts.
|
|
9
|
+
|
|
10
|
+
## Import
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<Tabs groupId="framework">
|
|
14
|
+
<TabItem value="react" label="React">
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// or
|
|
18
|
+
// or
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</TabItem>
|
|
22
|
+
<TabItem value="angular" label="Angular">
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// or
|
|
26
|
+
// or
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</TabItem>
|
|
30
|
+
<TabItem value="vue" label="Vue">
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// or
|
|
34
|
+
// or
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</TabItem>
|
|
38
|
+
<TabItem value="js" label="Vanilla JS">
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// DataGridTable is an internal component of OGrid in vanilla JS
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</TabItem>
|
|
45
|
+
</Tabs>
|
|
46
|
+
|
|
47
|
+
## Props (React)
|
|
48
|
+
|
|
49
|
+
`DataGridTable` receives `IOGridDataGridProps<T>` which includes:
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| `items` | `T[]` | **Required** | Array of data items to render (paginated subset). |
|
|
54
|
+
| `columns` | `(IColumnDef<T> \| IColumnGroupDef<T>)[]` | **Required** | Column definitions (flat or grouped). |
|
|
55
|
+
| `getRowId` | `(item: T) => RowId` | **Required** | Function to extract a unique ID from each row item. |
|
|
56
|
+
| `sortBy` | `string` | `undefined` | Currently sorted column ID. |
|
|
57
|
+
| `sortDirection` | `'asc' \| 'desc'` | `undefined` | Sort direction. |
|
|
58
|
+
| `onSortChange` | `(field: string, direction: 'asc' \| 'desc') => void` | `undefined` | Callback when user clicks a sortable column header. |
|
|
59
|
+
| `filters` | `IFilters` | `{}` | Active filter values (column ID → FilterValue). |
|
|
60
|
+
| `onFiltersChange` | `(filters: IFilters) => void` | `undefined` | Callback when filters are applied or cleared. |
|
|
61
|
+
| `visibleColumns` | `Set<string>` | All columns | Set of visible column IDs. |
|
|
62
|
+
| `onVisibilityChange` | `(columnId: string, visible: boolean) => void` | `undefined` | Callback when column visibility changes. |
|
|
63
|
+
| `onSetVisibleColumns` | `(columns: Set<string>) => void` | `undefined` | Bulk-set all visible columns (used by Select All / Clear All). |
|
|
64
|
+
| `editable` | `boolean` | `false` | Enable inline cell editing. |
|
|
65
|
+
| `cellSelection` | `boolean` | `true` | Enable spreadsheet-like cell selection (active cell, range, fill handle, clipboard). |
|
|
66
|
+
| `onCellValueChanged` | `(event: ICellValueChangedEvent<T>) => void` | `undefined` | Callback when a cell value is committed after edit. |
|
|
67
|
+
| `rowSelection` | `RowSelectionMode` | `'none'` | Row selection mode: `'none'`, `'single'`, or `'multiple'`. |
|
|
68
|
+
| `selectedRows` | `Set<RowId>` | `new Set()` | Set of selected row IDs. |
|
|
69
|
+
| `onSelectionChange` | `(event: IRowSelectionChangeEvent<T>) => void` | `undefined` | Callback when row selection changes. |
|
|
70
|
+
| `showRowNumbers` | `boolean` | `false` | Show Excel-style row numbers column at the start (1, 2, 3...). |
|
|
71
|
+
| `statusBar` | `boolean \| IStatusBarProps` | `false` | Show status bar below the grid with row counts and aggregations. |
|
|
72
|
+
| `emptyState` | `{ message?: ReactNode; render?: () => ReactNode }` | `undefined` | Custom empty state when no rows are available. |
|
|
73
|
+
| `density` | `'compact' \| 'normal' \| 'comfortable'` | `'normal'` | Cell spacing/padding preset. |
|
|
74
|
+
| `suppressHorizontalScroll` | `boolean` | `false` | Suppress horizontal scrolling (overflow-x hidden). |
|
|
75
|
+
| `virtualScroll` | `IVirtualScrollConfig` | `undefined` | Enable virtual scrolling for large datasets. |
|
|
76
|
+
| `columnReorder` | `boolean` | `false` | Enable drag-and-drop column reordering. |
|
|
77
|
+
| `dataSource` | `IDataSource<T>` | `undefined` | Server-side data source (for filter options and people search). |
|
|
78
|
+
| `onCellError` | `(error: Error, errorInfo: ErrorInfo) => void` | `undefined` | Error boundary callback for cell rendering errors. |
|
|
79
|
+
| `aria-label` | `string` | `undefined` | Accessible label for the grid. |
|
|
80
|
+
| `aria-labelledby` | `string` | `undefined` | ID of element that labels the grid. |
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
### Basic Example (React)
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
|
|
88
|
+
interface Product {
|
|
89
|
+
id: number;
|
|
90
|
+
name: string;
|
|
91
|
+
price: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const columns: IColumnDef<Product>[] = [
|
|
95
|
+
{ columnId: 'name', name: 'Product Name', type: 'text' },
|
|
96
|
+
{ columnId: 'price', name: 'Price', type: 'numeric' },
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
const data: Product[] = [
|
|
100
|
+
{ id: 1, name: 'Widget', price: 29.99 },
|
|
101
|
+
{ id: 2, name: 'Gadget', price: 49.99 },
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
function MyGrid() {
|
|
105
|
+
return (
|
|
106
|
+
<DataGridTable
|
|
107
|
+
items={data}
|
|
108
|
+
columns={columns}
|
|
109
|
+
getRowId={(item) => item.id}
|
|
110
|
+
aria-label="Product catalog"
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### With Sorting and Filtering (React)
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
|
|
120
|
+
function MyGrid() {
|
|
121
|
+
const [sortBy, setSortBy] = useState<string>('name');
|
|
122
|
+
const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc');
|
|
123
|
+
const [filters, setFilters] = useState<IFilters>({});
|
|
124
|
+
|
|
125
|
+
const handleSortChange = (field: string, direction: 'asc' | 'desc') => {
|
|
126
|
+
setSortBy(field);
|
|
127
|
+
setSortDirection(direction);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<DataGridTable
|
|
132
|
+
items={data}
|
|
133
|
+
columns={columns}
|
|
134
|
+
getRowId={(item) => item.id}
|
|
135
|
+
sortBy={sortBy}
|
|
136
|
+
sortDirection={sortDirection}
|
|
137
|
+
onSortChange={handleSortChange}
|
|
138
|
+
filters={filters}
|
|
139
|
+
onFiltersChange={setFilters}
|
|
140
|
+
/>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Angular Usage
|
|
146
|
+
|
|
147
|
+
In Angular Material/Radix packages, `DataGridTable` accepts a single `propsInput` property:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
|
|
151
|
+
@Component({
|
|
152
|
+
selector: 'app-my-grid',
|
|
153
|
+
standalone: true,
|
|
154
|
+
imports: [DataGridTableComponent],
|
|
155
|
+
template: `
|
|
156
|
+
<ogrid-datagrid-table [propsInput]="gridProps" />
|
|
157
|
+
`
|
|
158
|
+
})
|
|
159
|
+
export class MyGridComponent {
|
|
160
|
+
ogridService = new OGridService<Product>();
|
|
161
|
+
gridProps = this.ogridService.getDataGridProps();
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
In Angular PrimeNG, `DataGridTable` uses individual `@Input()` properties matching the React prop names.
|
|
166
|
+
|
|
167
|
+
## Vue Usage
|
|
168
|
+
|
|
169
|
+
In Vue Vuetify/PrimeVue packages, `DataGridTable` accepts a single `:grid-props` prop:
|
|
170
|
+
|
|
171
|
+
```vue
|
|
172
|
+
<template>
|
|
173
|
+
<DataGridTable :grid-props="gridProps" />
|
|
174
|
+
</template>
|
|
175
|
+
|
|
176
|
+
<script setup lang="ts">
|
|
177
|
+
|
|
178
|
+
const { dataGridProps: gridProps } = useOGrid({ /* ... */ });
|
|
179
|
+
</script>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
In Vue Radix, `DataGridTable` uses individual props via `defineProps<IOGridProps>()` (like React).
|
|
183
|
+
|
|
184
|
+
## Accessibility
|
|
185
|
+
|
|
186
|
+
`DataGridTable` implements WCAG 2.1 AA standards with comprehensive keyboard navigation and screen reader support.
|
|
187
|
+
|
|
188
|
+
### ARIA Attributes
|
|
189
|
+
|
|
190
|
+
The grid uses semantic HTML with proper ARIA roles:
|
|
191
|
+
|
|
192
|
+
```html
|
|
193
|
+
<div role="grid" aria-label="Product catalog" aria-rowcount="1000">
|
|
194
|
+
<table>
|
|
195
|
+
<thead>
|
|
196
|
+
<tr role="row">
|
|
197
|
+
<th role="columnheader" aria-sort="ascending" scope="col">
|
|
198
|
+
Product Name
|
|
199
|
+
</th>
|
|
200
|
+
</tr>
|
|
201
|
+
</thead>
|
|
202
|
+
<tbody>
|
|
203
|
+
<tr role="row" aria-rowindex="1">
|
|
204
|
+
<td role="gridcell" tabindex="-1">Widget</td>
|
|
205
|
+
</tr>
|
|
206
|
+
</tbody>
|
|
207
|
+
</table>
|
|
208
|
+
</div>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
| Attribute | Element | Purpose |
|
|
212
|
+
|-----------|---------|---------|
|
|
213
|
+
| `role="grid"` | Grid wrapper | Identifies the grid container for screen readers |
|
|
214
|
+
| `role="row"` | `<tr>` | Identifies table rows |
|
|
215
|
+
| `role="columnheader"` | `<th>` | Identifies column headers |
|
|
216
|
+
| `role="gridcell"` | `<td>` | Identifies data cells |
|
|
217
|
+
| `aria-label` | Grid wrapper | Provides accessible name (pass via `aria-label` prop) |
|
|
218
|
+
| `aria-rowcount` | Grid wrapper | Total number of rows in dataset (server-side pagination) |
|
|
219
|
+
| `aria-rowindex` | `<tr>` | Row's position in the full dataset (1-indexed) |
|
|
220
|
+
| `aria-sort` | `<th>` | Current sort state: `"ascending"`, `"descending"`, or `"none"` |
|
|
221
|
+
| `aria-colindex` | `<th>`, `<td>` | Column's position (1-indexed) |
|
|
222
|
+
| `tabindex="-1"` | `<td>` | Enables programmatic focus for keyboard navigation |
|
|
223
|
+
| `aria-readonly` | `<td>` | Indicates whether cell is editable (`"false"` when `editable: true`) |
|
|
224
|
+
|
|
225
|
+
### Keyboard Navigation
|
|
226
|
+
|
|
227
|
+
Complete Excel-style keyboard navigation:
|
|
228
|
+
|
|
229
|
+
**Arrow Keys:**
|
|
230
|
+
- `↑` `↓` `←` `→` — Move active cell one cell in the direction pressed
|
|
231
|
+
- `Ctrl+↑` / `Ctrl+↓` — Jump to first/last row
|
|
232
|
+
- `Ctrl+←` / `Ctrl+→` — Jump to first/last column
|
|
233
|
+
- `Home` / `End` — Jump to start/end of row
|
|
234
|
+
- `Ctrl+Home` / `Ctrl+End` — Jump to first/last cell in grid
|
|
235
|
+
|
|
236
|
+
**Selection:**
|
|
237
|
+
- `Shift+Arrows` — Extend cell selection range
|
|
238
|
+
- `Ctrl+A` — Select all cells
|
|
239
|
+
- `Space` (on checkbox column) — Toggle row selection
|
|
240
|
+
|
|
241
|
+
**Editing:**
|
|
242
|
+
- `Enter` or `F2` — Start editing active cell
|
|
243
|
+
- `Escape` — Cancel editing and revert
|
|
244
|
+
- `Enter` (while editing) — Commit and move down
|
|
245
|
+
- `Tab` (while editing) — Commit and move right
|
|
246
|
+
|
|
247
|
+
**Clipboard:**
|
|
248
|
+
- `Ctrl+C` / `Cmd+C` — Copy selected cells
|
|
249
|
+
- `Ctrl+X` / `Cmd+X` — Cut selected cells
|
|
250
|
+
- `Ctrl+V` / `Cmd+V` — Paste
|
|
251
|
+
- `Delete` — Clear selected cells
|
|
252
|
+
|
|
253
|
+
**Undo/Redo:**
|
|
254
|
+
- `Ctrl+Z` / `Cmd+Z` — Undo last edit
|
|
255
|
+
- `Ctrl+Y` / `Cmd+Shift+Z` — Redo
|
|
256
|
+
|
|
257
|
+
**Context Menu:**
|
|
258
|
+
- `Shift+F10` — Open context menu for active cell
|
|
259
|
+
|
|
260
|
+
See the [Accessibility Guide](/docs/guides/accessibility) for complete keyboard shortcuts.
|
|
261
|
+
|
|
262
|
+
### Focus Management
|
|
263
|
+
|
|
264
|
+
- **Focus visible:** `:focus-visible` styles show a 2px solid outline (`--ogrid-accent`) only when navigating via keyboard
|
|
265
|
+
- **Focus restoration:** After closing dialogs or exiting edit mode, focus returns to the active cell
|
|
266
|
+
- **Tab order:** Logical tab order through interactive elements (header buttons, editable cells)
|
|
267
|
+
|
|
268
|
+
### Screen Reader Support
|
|
269
|
+
|
|
270
|
+
Screen readers announce:
|
|
271
|
+
- **Cell navigation:** "Product Name, cell, row 1, column 2"
|
|
272
|
+
- **Sort changes:** "Sorted by Product Name, ascending"
|
|
273
|
+
- **Edit mode:** "Editing Product Name, row 1, column 2"
|
|
274
|
+
- **Value changes:** "Product Name changed from Widget to Gadget"
|
|
275
|
+
|
|
276
|
+
Tested with NVDA, JAWS, VoiceOver, and Narrator.
|
|
277
|
+
|
|
278
|
+
### High Contrast Mode
|
|
279
|
+
|
|
280
|
+
All colors use CSS custom properties with system color fallbacks for Windows High Contrast Mode:
|
|
281
|
+
- Focus indicators use system `Highlight` color
|
|
282
|
+
- Borders use system `ButtonText` color
|
|
283
|
+
- Text remains visible in all contrast themes
|
|
284
|
+
|
|
285
|
+
### Usage Example
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
|
|
289
|
+
function AccessibleGrid() {
|
|
290
|
+
return (
|
|
291
|
+
<OGrid
|
|
292
|
+
data={products}
|
|
293
|
+
columns={columns}
|
|
294
|
+
getRowId={(item) => item.id}
|
|
295
|
+
aria-label="Product catalog"
|
|
296
|
+
rowSelection="multiple"
|
|
297
|
+
editable={true}
|
|
298
|
+
/>
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
For complete accessibility documentation, see the [Accessibility Guide](/docs/guides/accessibility).
|
|
304
|
+
|
|
305
|
+
## Related Components
|
|
306
|
+
|
|
307
|
+
- [OGrid](./ogrid-props.mdx) — Top-level wrapper that includes toolbar and pagination
|
|
308
|
+
- [ColumnHeaderFilter](./components-column-header-filter.mdx) — Column filtering UI
|
|
309
|
+
- [StatusBar](./components-status-bar.mdx) — Status bar below the grid
|
|
310
|
+
- [PaginationControls](./components-pagination-controls.mdx) — Pagination UI
|
|
311
|
+
|
|
312
|
+
## See Also
|
|
313
|
+
|
|
314
|
+
- [Column Definition](./column-def.mdx) — Complete column definition reference
|
|
315
|
+
- [Grid API](./grid-api.mdx) — Imperative grid API reference
|
|
316
|
+
- [Accessibility Guide](/docs/guides/accessibility) — Complete accessibility documentation
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 13
|
|
3
|
+
title: PaginationControls
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PaginationControls
|
|
7
|
+
|
|
8
|
+
A pagination UI component that displays page navigation buttons, current page info, and a page size dropdown. Supports first/last page buttons, previous/next buttons, and numbered page buttons with ellipsis for large page counts.
|
|
9
|
+
|
|
10
|
+
## Import
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<Tabs groupId="framework">
|
|
14
|
+
<TabItem value="react" label="React">
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// or
|
|
18
|
+
// or
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
</TabItem>
|
|
22
|
+
<TabItem value="angular" label="Angular">
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// or
|
|
26
|
+
// or
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</TabItem>
|
|
30
|
+
<TabItem value="vue" label="Vue">
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
// or
|
|
34
|
+
// or
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
</TabItem>
|
|
38
|
+
<TabItem value="js" label="Vanilla JS">
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// PaginationControls is an internal component in vanilla JS
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
</TabItem>
|
|
45
|
+
</Tabs>
|
|
46
|
+
|
|
47
|
+
## Props (React)
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Default | Description |
|
|
50
|
+
|------|------|---------|-------------|
|
|
51
|
+
| `currentPage` | `number` | **Required** | Current page number (1-indexed). |
|
|
52
|
+
| `pageSize` | `number` | **Required** | Number of items per page. |
|
|
53
|
+
| `totalCount` | `number` | **Required** | Total number of items across all pages. |
|
|
54
|
+
| `onPageChange` | `(page: number) => void` | **Required** | Callback when user navigates to a different page. |
|
|
55
|
+
| `onPageSizeChange` | `(pageSize: number) => void` | **Required** | Callback when user changes the page size. |
|
|
56
|
+
| `pageSizeOptions` | `number[]` | `[10, 20, 50, 100]` | Available page size options in the dropdown. |
|
|
57
|
+
| `entityLabelPlural` | `string` | `'rows'` | Plural label for items (e.g., `'products'`, `'users'`). |
|
|
58
|
+
| `className` | `string` | `undefined` | Additional CSS class for the root element. |
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### Basic Example (React)
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
|
|
66
|
+
function MyApp() {
|
|
67
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
68
|
+
const [pageSize, setPageSize] = useState(20);
|
|
69
|
+
const totalCount = 250; // Total items
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<PaginationControls
|
|
73
|
+
currentPage={currentPage}
|
|
74
|
+
pageSize={pageSize}
|
|
75
|
+
totalCount={totalCount}
|
|
76
|
+
onPageChange={setCurrentPage}
|
|
77
|
+
onPageSizeChange={setPageSize}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Output:**
|
|
84
|
+
```
|
|
85
|
+
Showing 21 to 40 of 250 rows
|
|
86
|
+
« ‹ [1] [2] ... [13] › »
|
|
87
|
+
Page size: [20 ▼]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### With Custom Entity Label (React)
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
|
|
94
|
+
function ProductGrid() {
|
|
95
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
96
|
+
const [pageSize, setPageSize] = useState(50);
|
|
97
|
+
const totalCount = 1500;
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<PaginationControls
|
|
101
|
+
currentPage={currentPage}
|
|
102
|
+
pageSize={pageSize}
|
|
103
|
+
totalCount={totalCount}
|
|
104
|
+
onPageChange={setCurrentPage}
|
|
105
|
+
onPageSizeChange={setPageSize}
|
|
106
|
+
entityLabelPlural="products"
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Output:**
|
|
113
|
+
```
|
|
114
|
+
Showing 1 to 50 of 1,500 products
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### With Custom Page Size Options (React)
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
|
|
121
|
+
function MyApp() {
|
|
122
|
+
return (
|
|
123
|
+
<PaginationControls
|
|
124
|
+
currentPage={1}
|
|
125
|
+
pageSize={25}
|
|
126
|
+
totalCount={500}
|
|
127
|
+
onPageChange={() => {}}
|
|
128
|
+
onPageSizeChange={() => {}}
|
|
129
|
+
pageSizeOptions={[25, 50, 100, 250]}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Angular Usage
|
|
136
|
+
|
|
137
|
+
In Angular packages, the component uses `@Input()` and `@Output()` decorators:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
|
|
141
|
+
@Component({
|
|
142
|
+
selector: 'app-my-grid',
|
|
143
|
+
standalone: true,
|
|
144
|
+
imports: [PaginationControlsComponent],
|
|
145
|
+
template: `
|
|
146
|
+
<ogrid-pagination-controls
|
|
147
|
+
[currentPage]="currentPage"
|
|
148
|
+
[pageSize]="pageSize"
|
|
149
|
+
[totalCount]="totalCount"
|
|
150
|
+
(onPageChange)="handlePageChange($event)"
|
|
151
|
+
(onPageSizeChange)="handlePageSizeChange($event)"
|
|
152
|
+
[entityLabelPlural]="'users'"
|
|
153
|
+
/>
|
|
154
|
+
`
|
|
155
|
+
})
|
|
156
|
+
export class MyGridComponent {
|
|
157
|
+
currentPage = 1;
|
|
158
|
+
pageSize = 20;
|
|
159
|
+
totalCount = 500;
|
|
160
|
+
|
|
161
|
+
handlePageChange(page: number) {
|
|
162
|
+
this.currentPage = page;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
handlePageSizeChange(pageSize: number) {
|
|
166
|
+
this.pageSize = pageSize;
|
|
167
|
+
this.currentPage = 1; // Reset to first page
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Vue Usage
|
|
173
|
+
|
|
174
|
+
In Vue packages, the component accepts props via `v-bind` or shorthand `:`:
|
|
175
|
+
|
|
176
|
+
```vue
|
|
177
|
+
<template>
|
|
178
|
+
<PaginationControls
|
|
179
|
+
:current-page="currentPage"
|
|
180
|
+
:page-size="pageSize"
|
|
181
|
+
:total-count="totalCount"
|
|
182
|
+
@page-change="handlePageChange"
|
|
183
|
+
@page-size-change="handlePageSizeChange"
|
|
184
|
+
entity-label-plural="users"
|
|
185
|
+
/>
|
|
186
|
+
</template>
|
|
187
|
+
|
|
188
|
+
<script setup lang="ts">
|
|
189
|
+
|
|
190
|
+
const currentPage = ref(1);
|
|
191
|
+
const pageSize = ref(20);
|
|
192
|
+
const totalCount = ref(500);
|
|
193
|
+
|
|
194
|
+
const handlePageChange = (page: number) => {
|
|
195
|
+
currentPage.value = page;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const handlePageSizeChange = (size: number) => {
|
|
199
|
+
pageSize.value = size;
|
|
200
|
+
currentPage.value = 1; // Reset to first page
|
|
201
|
+
};
|
|
202
|
+
</script>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Behavior
|
|
206
|
+
|
|
207
|
+
### Pagination Buttons
|
|
208
|
+
|
|
209
|
+
- **« (First)** — Jump to page 1 (disabled when on page 1)
|
|
210
|
+
- **‹ (Previous)** — Go to the previous page (disabled when on page 1)
|
|
211
|
+
- **[1] [2] [3]** — Numbered page buttons (up to 7 buttons shown)
|
|
212
|
+
- **...** — Ellipsis when there are more than 7 pages
|
|
213
|
+
- **› (Next)** — Go to the next page (disabled when on last page)
|
|
214
|
+
- **» (Last)** — Jump to the last page (disabled when on last page)
|
|
215
|
+
|
|
216
|
+
### Page Number Display Logic
|
|
217
|
+
|
|
218
|
+
The component uses a smart algorithm to show a maximum of 7 page numbers with ellipsis:
|
|
219
|
+
|
|
220
|
+
- **1-7 pages:** Show all page numbers
|
|
221
|
+
- **8+ pages:**
|
|
222
|
+
- Show first and last page always
|
|
223
|
+
- Show current page and 1-2 neighbors
|
|
224
|
+
- Use ellipsis (`...`) to indicate skipped pages
|
|
225
|
+
|
|
226
|
+
**Examples:**
|
|
227
|
+
|
|
228
|
+
| Current Page | Total Pages | Displayed |
|
|
229
|
+
|--------------|-------------|-----------|
|
|
230
|
+
| 1 | 10 | `[1] 2 3 ... 10` |
|
|
231
|
+
| 5 | 10 | `1 ... 4 [5] 6 ... 10` |
|
|
232
|
+
| 10 | 10 | `1 ... 8 9 [10]` |
|
|
233
|
+
|
|
234
|
+
### Page Size Dropdown
|
|
235
|
+
|
|
236
|
+
The dropdown shows all values from `pageSizeOptions` (default: `[10, 20, 50, 100]`). When the user changes the page size:
|
|
237
|
+
1. `onPageSizeChange` is called with the new size
|
|
238
|
+
2. The parent should reset `currentPage` to 1 (recommended best practice)
|
|
239
|
+
|
|
240
|
+
### Info Text
|
|
241
|
+
|
|
242
|
+
The info text shows the range of items currently displayed:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
Showing {startItem} to {endItem} of {totalCount} {entityLabelPlural}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Example:** `Showing 21 to 40 of 250 rows`
|
|
249
|
+
|
|
250
|
+
## Accessibility
|
|
251
|
+
|
|
252
|
+
`PaginationControls` implements WCAG 2.1 AA standards with full keyboard and screen reader support.
|
|
253
|
+
|
|
254
|
+
### ARIA Attributes
|
|
255
|
+
|
|
256
|
+
```html
|
|
257
|
+
<nav role="navigation" aria-label="Pagination">
|
|
258
|
+
<button aria-label="First page" aria-disabled="true">«</button>
|
|
259
|
+
<button aria-label="Previous page" aria-disabled="true">‹</button>
|
|
260
|
+
<button aria-label="Page 1" aria-current="page">1</button>
|
|
261
|
+
<button aria-label="Page 2">2</button>
|
|
262
|
+
<button aria-label="Next page">›</button>
|
|
263
|
+
<button aria-label="Last page">»</button>
|
|
264
|
+
<label for="page-size">Page size:</label>
|
|
265
|
+
<select id="page-size" aria-label="Items per page">
|
|
266
|
+
<option>20</option>
|
|
267
|
+
</select>
|
|
268
|
+
</nav>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
| Attribute | Element | Purpose |
|
|
272
|
+
|-----------|---------|---------|
|
|
273
|
+
| `role="navigation"` | Nav wrapper | Identifies pagination controls as navigation |
|
|
274
|
+
| `aria-label="Pagination"` | Nav wrapper | Provides context for screen readers |
|
|
275
|
+
| `aria-label` (icon buttons) | `<button>` | Descriptive labels for icon-only buttons (« ‹ › ») |
|
|
276
|
+
| `aria-label` (page buttons) | `<button>` | Announces page number: "Page 1", "Page 2", etc. |
|
|
277
|
+
| `aria-current="page"` | Current page button | Identifies the active page |
|
|
278
|
+
| `aria-disabled="true"` | Disabled buttons | Indicates buttons that cannot be activated (first/prev on page 1, next/last on last page) |
|
|
279
|
+
| `id` / `for` | Select + label | Associates dropdown with its label |
|
|
280
|
+
| `aria-label` | `<select>` | Additional context: "Items per page" |
|
|
281
|
+
|
|
282
|
+
### Keyboard Navigation
|
|
283
|
+
|
|
284
|
+
- `Tab` / `Shift+Tab` — Navigate between pagination buttons and page size dropdown
|
|
285
|
+
- `Enter` / `Space` (on buttons) — Activate focused button (change page)
|
|
286
|
+
- `←` `→` (on page buttons) — Navigate between page number buttons
|
|
287
|
+
- `↑` `↓` (on dropdown) — Change page size
|
|
288
|
+
- `Enter` (on dropdown) — Confirm page size selection
|
|
289
|
+
|
|
290
|
+
### Focus Management
|
|
291
|
+
|
|
292
|
+
- **Focus visible:** `:focus-visible` styles show 2px solid outline (`--ogrid-accent`) on keyboard navigation
|
|
293
|
+
- **Focus restoration:** After page change, focus remains on pagination controls (does not jump to grid)
|
|
294
|
+
- **Disabled state:** Disabled buttons show `aria-disabled="true"` and cannot receive focus
|
|
295
|
+
|
|
296
|
+
### Screen Reader Support
|
|
297
|
+
|
|
298
|
+
Screen readers announce:
|
|
299
|
+
- **Page info:** "Showing 21 to 40 of 250 rows"
|
|
300
|
+
- **Page button:** "Page 2 button"
|
|
301
|
+
- **Current page:** "Page 1 button, current page"
|
|
302
|
+
- **Disabled buttons:** "First page button, disabled"
|
|
303
|
+
- **Page change:** "Navigated to page 3, showing 41 to 60 of 250 rows"
|
|
304
|
+
- **Page size change:** "Page size changed to 50 rows per page"
|
|
305
|
+
|
|
306
|
+
Tested with NVDA, JAWS, VoiceOver, and Narrator.
|
|
307
|
+
|
|
308
|
+
### High Contrast Mode
|
|
309
|
+
|
|
310
|
+
- Navigation buttons remain visible in high contrast mode
|
|
311
|
+
- Focus indicators use system `Highlight` color
|
|
312
|
+
- Borders use system `ButtonText` color
|
|
313
|
+
- Current page button uses system `HighlightText` color
|
|
314
|
+
|
|
315
|
+
See the [Accessibility Guide](/docs/guides/accessibility) for complete documentation.
|
|
316
|
+
|
|
317
|
+
## Styling
|
|
318
|
+
|
|
319
|
+
All UI packages provide default styles matching their design system. Styles are scoped to avoid conflicts.
|
|
320
|
+
|
|
321
|
+
**CSS custom properties** (all packages):
|
|
322
|
+
- `--ogrid-header-bg` — Background color
|
|
323
|
+
- `--ogrid-border` — Border color
|
|
324
|
+
- `--ogrid-fg` — Foreground text color
|
|
325
|
+
- `--ogrid-primary` — Primary color (current page button)
|
|
326
|
+
|
|
327
|
+
## Layout Integration
|
|
328
|
+
|
|
329
|
+
`PaginationControls` is automatically rendered in the footer strip of `OGridLayout` when pagination is enabled. The footer strip has a border-top and matches the header background color.
|
|
330
|
+
|
|
331
|
+
## No Border or Padding
|
|
332
|
+
|
|
333
|
+
The component itself has **no outer border or padding** — the parent container (footer strip in `OGridLayout`) provides these styles.
|
|
334
|
+
|
|
335
|
+
## Related Components
|
|
336
|
+
|
|
337
|
+
- [OGrid](./ogrid-props.mdx) — Top-level wrapper that includes pagination
|
|
338
|
+
- [DataGridTable](./components-datagrid-table.mdx) — Main grid component
|
|
339
|
+
- [StatusBar](./components-status-bar.mdx) — Status bar below the grid
|
|
340
|
+
|
|
341
|
+
## See Also
|
|
342
|
+
|
|
343
|
+
- [Grid API](./grid-api.mdx) — Pagination-related API methods
|
|
344
|
+
- [Pagination Feature Guide](/docs/features/pagination) — Complete pagination documentation
|