Skip to content

Commit

Permalink
feat(pagination): add property providers
Browse files Browse the repository at this point in the history
  • Loading branch information
bence444 committed Dec 20, 2024
1 parent c92b724 commit 15376cb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
8 changes: 8 additions & 0 deletions libs/flowbite-angular/pagination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
62 changes: 56 additions & 6 deletions libs/flowbite-angular/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,30 @@ export const FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE = new InjectionToken<
TemplateRef<unknown> | undefined
>('FLOWBITE_PAGINATION_LAST_ICON_DEFAULT_VALUE');

export const FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE = new InjectionToken<number>(
'FLOWBITE_PAGINATION_TABS_DEFAULT_VALUE'
);

export const FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE = new InjectionToken<number>(
'FLOWBITE_PAGINATION_PAGESIZE_DEFAULT_VALUE'
);

export const FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE = new InjectionToken<boolean>(
'FLOWBITE_PAGINATION_FIRSTLAST_DEFAULT_VALUE'
);

export const FLOWBITE_PAGINATION_PREVNEXT_DEFAULT_VALUE = new InjectionToken<boolean>(
'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<keyof PaginationSizes>(
'FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE'
);

export const paginationDefaultValueProvider = makeEnvironmentProviders([
{
provide: FLOWBITE_PAGINATION_CUSTOM_STYLE_DEFAULT_VALUE,
Expand All @@ -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({
Expand Down Expand Up @@ -258,37 +306,39 @@ export class PaginationComponent extends BaseComponent<PaginationClass> {
*
* @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<keyof PaginationNavigation>('icon');
readonly navigation = input<keyof PaginationNavigation>(
inject(FLOWBITE_PAGINATION_NAVIGATION_DEFAULT_VALUE)
);
/**
* Value of the component's size
*
* @default md
*/
readonly size = input<keyof PaginationSizes>('md');
readonly size = input<keyof PaginationSizes>(inject(FLOWBITE_PAGINATION_SIZE_DEFAULT_VALUE));
/**
* Value of the next icon
*
Expand Down

0 comments on commit 15376cb

Please sign in to comment.