-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pagination): Demo add first pagination Ex (#40)
- Loading branch information
Showing
30 changed files
with
1,300 additions
and
1,331 deletions.
There are no files selected for viewing
184 changes: 0 additions & 184 deletions
184
angular/demo/src/app/samples/pagination/config.route.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {AgnosUIAngularModule} from '@agnos-ui/angular'; | ||
import type {PaginationContext} from '@agnos-ui/angular'; | ||
import {NgIf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
|
||
const FILTER_PAG_REGEX = /[^0-9]/g; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [AgnosUIAngularModule, NgIf], | ||
template: ` | ||
<p>A pagination with customized links:</p> | ||
<nav au-pagination [collectionSize]="70" [(page)]="customPage" ariaLabel="Page navigation with customized links"> | ||
<ng-template auPaginationPrevious>Prev</ng-template> | ||
<ng-template auPaginationNext>Next</ng-template> | ||
<ng-template auPaginationNumber let-displayedPage="displayedPage">{{ getPageSymbol(displayedPage) }}</ng-template> | ||
</nav> | ||
<hr /> | ||
<p>A pagination with customized pages:</p> | ||
<nav au-pagination [collectionSize]="70" [(page)]="customPage" ariaLabel="Page navigation with customized pages"> | ||
<ng-template auPaginationPages let-widget="widget" let-state="state"> | ||
<li class="au-custom-pages-item" *ngIf="state.pages.length > 0"> | ||
<div class="mb-3 d-flex flex-nowrap px-2"> | ||
<label id="paginationInputLabel" for="paginationInput" class="col-form-label me-2 ms-1">Page</label> | ||
<input | ||
#i | ||
type="text" | ||
inputmode="numeric" | ||
pattern="[0-9]*" | ||
class="form-control custom-pages-input" | ||
id="paginationInput" | ||
[value]="state.page" | ||
(keyup.enter)="handleTheChange(i, widget)" | ||
(blur)="handleTheChange(i, widget)" | ||
(input)="formatInput(i)" | ||
aria-labelledby="paginationInputLabel paginationDescription" | ||
style="width: 2.5rem" | ||
/> | ||
<span id="paginationDescription" class="col-form-label text-nowrap px-2"> of {{ state.pages.length }}</span> | ||
</div> | ||
</li> | ||
</ng-template> | ||
</nav> | ||
`, | ||
}) | ||
export default class PaginationComponent { | ||
customPage = 4; | ||
|
||
getPageSymbol(displayedPage: number) { | ||
return ['A', 'B', 'C', 'D', 'E', 'F', 'G'][displayedPage - 1]; | ||
} | ||
|
||
formatInput(input: HTMLInputElement) { | ||
input.value = input.value.replace(FILTER_PAG_REGEX, ''); | ||
} | ||
|
||
handleTheChange(input: HTMLInputElement, widget: PaginationContext['widget']) { | ||
const value = input.value; | ||
const intValue = parseInt(value); | ||
widget.actions.select(intValue); | ||
input.value = widget.stores.page$().toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
angular/demo/src/app/samples/pagination/pagination.route.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.