-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kit):
ButtonSelect
add new directive (#8559)
Co-authored-by: taiga-family-bot <[email protected]>
- Loading branch information
1 parent
2b8cd3d
commit 6cba52c
Showing
17 changed files
with
178 additions
and
7 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
projects/addon-table/components/table/caption/caption.component.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,11 @@ | ||
import {ChangeDetectionStrategy, Component, ViewEncapsulation} from '@angular/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'caption[tuiCaption]', | ||
template: '<ng-content/>', | ||
styleUrls: ['./caption.style.less'], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiTableCaption {} |
16 changes: 16 additions & 0 deletions
16
projects/addon-table/components/table/caption/caption.style.less
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,16 @@ | ||
caption[tuiCaption] { | ||
caption-side: bottom; | ||
text-align: left; | ||
padding: 0.75rem 0; | ||
color: var(--tui-text-secondary); | ||
|
||
> *:not(:first-child) { | ||
margin-inline-start: 0.5rem; | ||
} | ||
|
||
tui-pagination:not(:first-child), | ||
tui-pager:not(:first-child) { | ||
display: inline-flex; | ||
vertical-align: middle; | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
projects/demo/src/modules/components/table/examples/7/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,38 @@ | ||
<table | ||
tuiTable | ||
[style.width.rem]="36" | ||
> | ||
<caption tuiCaption> | ||
<span>999 rows</span> | ||
<button | ||
appearance="flat" | ||
tuiButton | ||
tuiButtonSelect | ||
[(ngModel)]="size" | ||
> | ||
{{ index * size + 1 }}-{{ (index + 1) * size }} rows | ||
<tui-data-list-wrapper | ||
*tuiTextfieldDropdown | ||
[itemContent]="content" | ||
[items]="items" | ||
/> | ||
</button> | ||
<tui-pagination | ||
[length]="length" | ||
[style.float]="'right'" | ||
[(index)]="index" | ||
/> | ||
</caption> | ||
<thead> | ||
<tr tuiThGroup> | ||
<th tuiTh>Name</th> | ||
<th tuiTh>Balance</th> | ||
</tr> | ||
</thead> | ||
<tbody tuiTbody> | ||
<tr *ngFor="let item of data"> | ||
<td tuiTd>{{ item.name }}</td> | ||
<td tuiTd>{{ item.balance | tuiFormatNumber | async }}</td> | ||
</tr> | ||
</tbody> | ||
</table> |
Empty file.
48 changes: 48 additions & 0 deletions
48
projects/demo/src/modules/components/table/examples/7/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,48 @@ | ||
import {AsyncPipe, NgForOf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiTable} from '@taiga-ui/addon-table'; | ||
import type {TuiContext, TuiStringHandler} from '@taiga-ui/cdk'; | ||
import {TuiButton, TuiFormatNumberPipe, TuiTextfield} from '@taiga-ui/core'; | ||
import {TuiButtonSelect, TuiDataListWrapper, TuiPagination} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
NgForOf, | ||
AsyncPipe, | ||
FormsModule, | ||
TuiTable, | ||
TuiFormatNumberPipe, | ||
TuiButton, | ||
TuiButtonSelect, | ||
TuiPagination, | ||
TuiDataListWrapper, | ||
TuiTextfield, | ||
], | ||
templateUrl: './index.html', | ||
styleUrls: ['./index.less'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected readonly data = [ | ||
{ | ||
name: 'Alex Inkin', | ||
balance: 1323525, | ||
}, | ||
{ | ||
name: 'Roman Sedov', | ||
balance: 423242, | ||
}, | ||
] as const; | ||
|
||
protected index = 4; | ||
protected length = 10; | ||
protected size = 10; | ||
protected readonly items = [10, 50, 100]; | ||
protected readonly content: TuiStringHandler<TuiContext<number>> = ({$implicit}) => | ||
`${$implicit} items per page`; | ||
} |
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
35 changes: 35 additions & 0 deletions
35
projects/kit/directives/button-select/button-select.directive.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 {Directive} from '@angular/core'; | ||
import {TuiControl} from '@taiga-ui/cdk/classes'; | ||
import {tuiProvide} from '@taiga-ui/cdk/utils/miscellaneous'; | ||
import { | ||
TUI_DATA_LIST_HOST, | ||
type TuiDataListHost, | ||
} from '@taiga-ui/core/components/data-list'; | ||
import {TuiWithTextfieldDropdown} from '@taiga-ui/core/components/textfield'; | ||
import { | ||
TuiDropdownDirective, | ||
tuiDropdownOpen, | ||
tuiDropdownOptionsProvider, | ||
TuiWithDropdownOpen, | ||
} from '@taiga-ui/core/directives/dropdown'; | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: 'button[tuiButtonSelect]', | ||
providers: [ | ||
// TODO: Add checkmark once we properly implement new Select, then add to demo | ||
tuiProvide(TUI_DATA_LIST_HOST, TuiButtonSelect), | ||
tuiDropdownOptionsProvider({align: 'right'}), | ||
], | ||
hostDirectives: [TuiDropdownDirective, TuiWithDropdownOpen, TuiWithTextfieldDropdown], | ||
}) | ||
export class TuiButtonSelect<T> extends TuiControl<T> implements TuiDataListHost<T> { | ||
private readonly open = tuiDropdownOpen(); | ||
|
||
public readonly size = 's'; | ||
|
||
public handleOption(option: T): void { | ||
this.onChange(option); | ||
this.open.set(false); | ||
} | ||
} |
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 @@ | ||
export * from './button-select.directive'; |
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,5 @@ | ||
{ | ||
"lib": { | ||
"entryFile": "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