-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addon-table): add token
TUI_TABLE_PAGINATION_OPTIONS
with prop…
…erty `sizeOptionContent`
- Loading branch information
1 parent
4a26fac
commit af590c9
Showing
11 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './table-pagination.component'; | ||
export * from './table-pagination.module'; | ||
export * from './table-pagination-options'; |
27 changes: 27 additions & 0 deletions
27
projects/addon-table/components/table-pagination/table-pagination-options.ts
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,27 @@ | ||
import {InjectionToken, ValueProvider} from '@angular/core'; | ||
import {TuiContextWithImplicit} from '@taiga-ui/cdk'; | ||
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; | ||
|
||
export interface TuiTablePaginationOptions { | ||
readonly sizeOptionContent: PolymorpheusContent< | ||
TuiContextWithImplicit<number> & {total: number} | ||
>; | ||
} | ||
|
||
export const TUI_TABLE_PAGINATION_DEFAULT_OPTIONS: TuiTablePaginationOptions = { | ||
sizeOptionContent: ({$implicit}) => $implicit, | ||
}; | ||
|
||
export const TUI_TABLE_PAGINATION_OPTIONS = new InjectionToken( | ||
'Default parameters for TablePagination component', | ||
{factory: () => TUI_TABLE_PAGINATION_DEFAULT_OPTIONS}, | ||
); | ||
|
||
export function tuiTablePaginationOptionsProvider( | ||
options: Partial<TuiTablePaginationOptions>, | ||
): ValueProvider { | ||
return { | ||
provide: TUI_TABLE_PAGINATION_OPTIONS, | ||
useValue: {...TUI_TABLE_PAGINATION_DEFAULT_OPTIONS, ...options}, | ||
}; | ||
} |
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
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
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
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
4 changes: 4 additions & 0 deletions
4
projects/demo/src/modules/tables/table-pagination/examples/2/index.html
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,4 @@ | ||
<tui-table-pagination | ||
[total]="total" | ||
[items]="sizeOptions" | ||
></tui-table-pagination> |
35 changes: 35 additions & 0 deletions
35
projects/demo/src/modules/tables/table-pagination/examples/2/index.ts
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,35 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import { | ||
TuiTablePaginationOptions, | ||
tuiTablePaginationOptionsProvider, | ||
} from '@taiga-ui/addon-table'; | ||
|
||
const customOptionContent: TuiTablePaginationOptions['sizeOptionContent'] = ({ | ||
$implicit, | ||
total, | ||
}) => { | ||
switch ($implicit) { | ||
case 10: | ||
return 'Ten'; | ||
case total: | ||
return 'Show all rows'; | ||
default: | ||
return $implicit; | ||
} | ||
}; | ||
|
||
@Component({ | ||
selector: 'tui-table-pagination-example-2', | ||
templateUrl: './index.html', | ||
providers: [ | ||
tuiTablePaginationOptionsProvider({sizeOptionContent: customOptionContent}), | ||
], | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiTablePaginationExample2 { | ||
total = 350; | ||
sizeOptions = [10, 50, 100, this.total]; | ||
} |
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
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
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