diff --git a/apps/docs/docs/components/pagination/_both.component.html b/apps/docs/docs/components/pagination/_both.component.html
index bcb9758d..de67c8ca 100644
--- a/apps/docs/docs/components/pagination/_both.component.html
+++ b/apps/docs/docs/components/pagination/_both.component.html
@@ -1,4 +1,3 @@
+ [navigationMode]="'both'" />
diff --git a/apps/docs/docs/components/pagination/_custom.component.html b/apps/docs/docs/components/pagination/_custom.component.html
index 9e5be744..19f614d8 100644
--- a/apps/docs/docs/components/pagination/_custom.component.html
+++ b/apps/docs/docs/components/pagination/_custom.component.html
@@ -2,7 +2,7 @@
[currentPage]="20"
[totalItems]="100000"
[pageSize]="50"
- [firstLast]="false"
+ [hasFirstLast]="false"
[ariaLabel]="'Custom pagination'"
[customStyle]="{
root: { base: 'flex gap-2' },
diff --git a/apps/docs/docs/components/pagination/_default.component.html b/apps/docs/docs/components/pagination/_default.component.html
index 8e8e55b6..1edfc8d3 100644
--- a/apps/docs/docs/components/pagination/_default.component.html
+++ b/apps/docs/docs/components/pagination/_default.component.html
@@ -1,14 +1 @@
-
- @for (item of testDatas().items; track $index) {
-
- | {{ item.id }} |
- {{ item.name }} |
-
- }
-
-
-
+
diff --git a/apps/docs/docs/components/pagination/_default.component.ts b/apps/docs/docs/components/pagination/_default.component.ts
index 91a1851f..3658c97a 100644
--- a/apps/docs/docs/components/pagination/_default.component.ts
+++ b/apps/docs/docs/components/pagination/_default.component.ts
@@ -1,63 +1,10 @@
import { PaginationComponent } from 'flowbite-angular/pagination';
-import { Component, signal } from '@angular/core';
+import { Component } from '@angular/core';
@Component({
- // ng-doc-ignore-line
selector: 'flowbite-demo-pagination-default',
imports: [PaginationComponent],
- // ng-doc-ignore-line
templateUrl: './_default.component.html',
})
-export class FlowbiteDefaultComponent {
- private readonly _testDatas: IdNameDto[] = [];
-
- readonly currentPage = signal(1);
- readonly pageSize = signal(10);
- readonly testDatas = signal(PagedResult.empty());
-
- constructor() {
- // fetch test datas
- for (let i = 1; i <= 105; i++) {
- this._testDatas.push({ id: i, name: 'John Doe' });
- }
-
- // simulate API call
- this.pageChangeHandler(1);
- }
-
- pageChangeHandler(page: number) {
- this.currentPage.set(page);
-
- // Call your API here
- // The following lines of code simulates a backend query
- const _items: IdNameDto[] = [];
- const _start = (this.currentPage() - 1) * this.pageSize();
- const _end = Math.min(this._testDatas.length, _start + this.pageSize());
-
- for (let i = _start; i < _end; i++) {
- _items.push({ id: i + 1, name: 'John Doe' });
- }
-
- this.testDatas.set({
- items: _items,
- totalItems: this._testDatas.length,
- });
- }
-}
-
-export interface IdNameDto {
- id: number;
- name: string;
-}
-
-export interface PagedResult {
- items: T[];
- totalItems: number;
-}
-
-export const PagedResult = {
- empty(): PagedResult {
- return { items: [], totalItems: 0 };
- },
-};
+export class FlowbiteDefaultComponent {}
diff --git a/apps/docs/docs/components/pagination/_text.component.html b/apps/docs/docs/components/pagination/_text.component.html
index 55d98d6d..1bccc97d 100644
--- a/apps/docs/docs/components/pagination/_text.component.html
+++ b/apps/docs/docs/components/pagination/_text.component.html
@@ -1,4 +1,3 @@
+ [navigationMode]="'text'" />
diff --git a/libs/flowbite-angular/pagination/index.ts b/libs/flowbite-angular/pagination/index.ts
index 8b0afc95..c4d931d4 100644
--- a/libs/flowbite-angular/pagination/index.ts
+++ b/libs/flowbite-angular/pagination/index.ts
@@ -1,6 +1,8 @@
export {
PaginationComponent,
paginationDefaultValueProvider,
+ FLOWBITE_PAGINATION_CURRENT_PAGE_DEFAULT_VALUE,
+ FLOWBITE_PAGINATION_BUTTON_PROPERTIES_DEFAULT_VALUE,
FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE,
FLOWBITE_PAGINATION_PREVIOUS_ICON_DEFAULT_VALUE,
FLOWBITE_PAGINATION_NEXT_ICON_DEFAULT_VALUE,
@@ -8,9 +10,9 @@ export {
FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE,
FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE,
FLOWBITE_PAGINATION_PAGE_SIZE_DEFAULT_VALUE,
- FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE,
- FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE,
- FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE,
+ FLOWBITE_PAGINATION_HAS_FIRST_LAST_DEFAULT_VALUE,
+ FLOWBITE_PAGINATION_HAS_PREV_NEXT_DEFAULT_VALUE,
+ FLOWBITE_PAGINATION_NAVIGATION_MODE_DEFAULT_VALUE,
FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE,
} from './pagination.component';
export type { PaginationProperties, PaginationClass, PaginationTheme } from './pagination.theme';
diff --git a/libs/flowbite-angular/pagination/pagination.component.ts b/libs/flowbite-angular/pagination/pagination.component.ts
index 2e62a5b9..40774c27 100644
--- a/libs/flowbite-angular/pagination/pagination.component.ts
+++ b/libs/flowbite-angular/pagination/pagination.component.ts
@@ -31,6 +31,10 @@ import {
} from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
+export const FLOWBITE_PAGINATION_CURRENT_PAGE_DEFAULT_VALUE = new InjectionToken(
+ 'FLOWBITE_PAGINATION_CURRENT_PAGE_DEFAULT_VALUE'
+);
+
export const FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE = new InjectionToken<
DeepPartial
>('FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE');
@@ -59,17 +63,17 @@ export const FLOWBITE_PAGINATION_PAGE_SIZE_DEFAULT_VALUE = new InjectionToken(
- 'FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE'
+export const FLOWBITE_PAGINATION_HAS_FIRST_LAST_DEFAULT_VALUE = new InjectionToken(
+ 'FLOWBITE_PAGINATION_HAS_FIRST_LAST_DEFAULT_VALUE'
);
-export const FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE = new InjectionToken(
- 'FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE'
+export const FLOWBITE_PAGINATION_HAS_PREV_NEXT_DEFAULT_VALUE = new InjectionToken(
+ 'FLOWBITE_PAGINATION_HAS_PREV_NEXT_DEFAULT_VALUE'
);
-export const FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE = new InjectionToken<
+export const FLOWBITE_PAGINATION_NAVIGATION_MODE_DEFAULT_VALUE = new InjectionToken<
keyof PaginationNavigation
->('FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE');
+>('FLOWBITE_PAGINATION_NAVIGATION_MODE_DEFAULT_VALUE');
export const FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE = new InjectionToken(
'FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE'
@@ -80,6 +84,10 @@ export const FLOWBITE_PAGINATION_BUTTON_PROPERTIES_DEFAULT_VALUE = new Injection
>('FLOWBITE_PAGINATION_BUTTON_PROPERTIES_DEFAULT_VALUE');
export const paginationDefaultValueProvider = makeEnvironmentProviders([
+ {
+ provide: FLOWBITE_PAGINATION_CURRENT_PAGE_DEFAULT_VALUE,
+ useValue: 1,
+ },
{
provide: FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE,
useValue: {},
@@ -109,15 +117,15 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
useValue: 25,
},
{
- provide: FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE,
+ provide: FLOWBITE_PAGINATION_HAS_FIRST_LAST_DEFAULT_VALUE,
useValue: true,
},
{
- provide: FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE,
+ provide: FLOWBITE_PAGINATION_HAS_PREV_NEXT_DEFAULT_VALUE,
useValue: true,
},
{
- provide: FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE,
+ provide: FLOWBITE_PAGINATION_NAVIGATION_MODE_DEFAULT_VALUE,
useValue: 'icon',
},
{
@@ -150,7 +158,7 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
standalone: true,
imports: [IconComponent, NgTemplateOutlet, ButtonComponent],
template: `
- @if (firstLast()) {
+ @if (hasFirstLast()) {
- @if (['icon', 'both'].includes(navigation())) {
+ @if (['icon', 'both'].includes(navigationMode())) {
@if (firstIcon()) {
} @else {
@@ -168,13 +176,13 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
[class]="contentClasses().iconClass" />
}
}
- @if (['text', 'both'].includes(navigation())) {
+ @if (['text', 'both'].includes(navigationMode())) {
First
}
}
- @if (prevNext()) {
+ @if (hasPrevNext()) {
- @if (['icon', 'both'].includes(navigation())) {
+ @if (['icon', 'both'].includes(navigationMode())) {
@if (previousIcon()) {
} @else {
@@ -192,7 +200,7 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
[class]="contentClasses().iconClass" />
}
}
- @if (['text', 'both'].includes(navigation())) {
+ @if (['text', 'both'].includes(navigationMode())) {
Previous
}
@@ -202,7 +210,7 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
}
- @if (prevNext()) {
+ @if (hasPrevNext()) {
- @if (['text', 'both'].includes(navigation())) {
+ @if (['text', 'both'].includes(navigationMode())) {
Next
}
- @if (['icon', 'both'].includes(navigation())) {
+ @if (['icon', 'both'].includes(navigationMode())) {
@if (lastIcon()) {
} @else {
@@ -235,7 +243,7 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([
}
- @if (firstLast()) {
+ @if (hasFirstLast()) {
- @if (['text', 'both'].includes(navigation())) {
+ @if (['text', 'both'].includes(navigationMode())) {
Last
}
- @if (['icon', 'both'].includes(navigation())) {
+ @if (['icon', 'both'].includes(navigationMode())) {
@if (lastIcon()) {
} @else {
@@ -277,17 +285,17 @@ export class PaginationComponent extends BaseComponent {
public readonly domSanitizer = inject(DomSanitizer);
/**
- * Value of the current page
+ * Value of the total items
*
* @required
*/
- public readonly currentPage = model.required();
+ public readonly totalItems = model.required();
/**
- * Value of the total items
+ * Value of the current page
*
- * @required
+ * @default 1
*/
- public readonly totalItems = model.required();
+ public readonly currentPage = model(inject(FLOWBITE_PAGINATION_CURRENT_PAGE_DEFAULT_VALUE));
/**
* Value of how many tabs are displayed
*
@@ -305,19 +313,19 @@ export class PaginationComponent extends BaseComponent {
*
* @default true
*/
- public readonly prevNext = model(inject(FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE));
+ public readonly hasPrevNext = model(inject(FLOWBITE_PAGINATION_HAS_PREV_NEXT_DEFAULT_VALUE));
/**
* Whether to show or hide first and last buttons
*
* @default true
*/
- public readonly firstLast = model(inject(FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE));
+ public readonly hasFirstLast = model(inject(FLOWBITE_PAGINATION_HAS_FIRST_LAST_DEFAULT_VALUE));
/**
* Value of the navigation button's type
*
* @default icon
*/
- public readonly navigation = model(inject(FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE));
+ public readonly navigationMode = model(inject(FLOWBITE_PAGINATION_NAVIGATION_MODE_DEFAULT_VALUE));
/**
* Value of the component's size
*
@@ -474,27 +482,27 @@ export class PaginationComponent extends BaseComponent {
//#endregion
/**
- * Sets the value of the `currentPage`
+ * Sets the value of the `currentPage` if it's between 1 and `maxPages`
* @param page number of the active page
*/
- public changePage(page: number) {
- if (this.visibleCurrentPage() === page) return;
+ public goToPage(page: number) {
+ if (page < 1 || page > this.maxPages()) return;
this.currentPage.set(page);
}
/**
- * Decreases the value of `currentPage` if it's bigger than 1
+ * Decreases the value of `currentPage` if it's more than 1
*/
public goToPreviousPage() {
- if (this.visibleCurrentPage() === 1) return;
+ if (this.visibleCurrentPage() <= 1) return;
this.currentPage.update((value) => value - 1);
}
/**
- * Increases the value of `currentPage` if it's smaller than `maxPages`
+ * Increases the value of `currentPage` if it's less than `maxPages`
*/
public goToNextPage() {
- if (this.visibleCurrentPage() === this.maxPages()) return;
+ if (this.visibleCurrentPage() >= this.maxPages()) return;
this.currentPage.update((value) => value + 1);
}
@@ -502,7 +510,6 @@ export class PaginationComponent extends BaseComponent {
* Sets the value of `currentPage` to 1
*/
public goToFirstPage() {
- if (this.currentPage() === 1) return;
this.currentPage.set(1);
}
@@ -510,7 +517,6 @@ export class PaginationComponent extends BaseComponent {
* Sets the value of `currentPage` equal to `maxPages`
*/
public goToLastPage() {
- if (this.currentPage() === this.maxPages()) return;
this.currentPage.set(this.maxPages());
}
}
diff --git a/libs/flowbite-angular/pagination/pagination.theme.ts b/libs/flowbite-angular/pagination/pagination.theme.ts
index 19a5d0bf..40749cb9 100644
--- a/libs/flowbite-angular/pagination/pagination.theme.ts
+++ b/libs/flowbite-angular/pagination/pagination.theme.ts
@@ -21,12 +21,12 @@ export interface PaginationSizes extends Pick {
* Required properties for class generation of `PaginationComponent`
*/
export interface PaginationProperties {
- customStyle: DeepPartial;
size: keyof PaginationSizes;
+ customStyle: DeepPartial;
}
/**
- * Theme definition for `NavbarComponent`
+ * Theme definition for `PaginationComponent`
*/
export interface PaginationTheme {
root: {