From 15376cb21aa866868d58ff244102f6da46f4e85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Lov=C3=A1sz?= Date: Fri, 20 Dec 2024 16:30:51 +0100 Subject: [PATCH] feat(pagination): add property providers --- libs/flowbite-angular/pagination/index.ts | 8 +++ .../pagination/pagination.component.ts | 62 +++++++++++++++++-- 2 files changed, 64 insertions(+), 6 deletions(-) diff --git a/libs/flowbite-angular/pagination/index.ts b/libs/flowbite-angular/pagination/index.ts index 008ffbdf..4597b3ef 100644 --- a/libs/flowbite-angular/pagination/index.ts +++ b/libs/flowbite-angular/pagination/index.ts @@ -2,6 +2,14 @@ export { PaginationComponent, paginationDefaultValueProvider, FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE, + FLOWBITE_PAGINATION_NEXT_ICON_DEFAULT_VALUE, + FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE, + FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE, + FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE, + FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE, + FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE, + FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE, + FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE, } from './pagination.component'; export type { PaginationProperties, PaginationClass, PaginationTheme } from './pagination.theme'; export { paginationTheme } from './pagination.theme'; diff --git a/libs/flowbite-angular/pagination/pagination.component.ts b/libs/flowbite-angular/pagination/pagination.component.ts index 412fad5d..1bfbd933 100644 --- a/libs/flowbite-angular/pagination/pagination.component.ts +++ b/libs/flowbite-angular/pagination/pagination.component.ts @@ -42,6 +42,30 @@ export const FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE = new InjectionToken< TemplateRef | undefined >('FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE'); +export const FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE = new InjectionToken( + 'FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE' +); + +export const FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE = new InjectionToken( + 'FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE' +); + +export const FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE = new InjectionToken( + 'FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE' +); + +export const FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE = new InjectionToken( + 'FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE' +); + +export const FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE = new InjectionToken< + keyof PaginationNavigation +>('FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE'); + +export const FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE = new InjectionToken( + 'FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE' +); + export const paginationDefaultValueProvider = makeEnvironmentProviders([ { provide: FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE, @@ -55,6 +79,30 @@ export const paginationDefaultValueProvider = makeEnvironmentProviders([ provide: FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE, useValue: undefined, }, + { + provide: FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE, + useValue: 5, + }, + { + provide: FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE, + useValue: 25, + }, + { + provide: FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE, + useValue: true, + }, + { + provide: FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE, + useValue: true, + }, + { + provide: FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE, + useValue: 'icon', + }, + { + provide: FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE, + useValue: 'md', + }, ]); @Component({ @@ -258,37 +306,39 @@ export class PaginationComponent extends BaseComponent { * * @default 5 */ - readonly tabs = input(5); + readonly tabs = input(inject(FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE)); /** * Value of how many items are in a tab * * @default 25 */ - readonly pageSize = input(25); + readonly pageSize = input(inject(FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE)); /** * Whether to show or hide previous and next buttons * * @default true */ - readonly prevNext = input(true); + readonly prevNext = input(inject(FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE)); /** * Whether to show or hide first and last buttons * * @default true */ - readonly firstLast = input(true); + readonly firstLast = input(inject(FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE)); /** * Value of the navigation button's type * * @default icon */ - readonly navigation = input('icon'); + readonly navigation = input( + inject(FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE) + ); /** * Value of the component's size * * @default md */ - readonly size = input('md'); + readonly size = input(inject(FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE)); /** * Value of the next icon *