Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kit): Files add expanded input-output #4479

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export class ExampleTuiInputFilesComponent extends AbstractExampleTuiControl {
multiple = true;
showSize = true;
showDelete = true;
expanded = false;
maxFilesCount = 3;
accept = '';
acceptVariants = ['image/*', 'application/pdf', 'image/*,application/pdf'];
capture: TuiInputFilesOptions['capture'] = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
[attr.capture]="capture"
/>
</tui-input-files>
<tui-files class="tui-space_top-2">
<tui-files
class="tui-space_top-2"
[max]="maxFilesCount"
[(expanded)]="expanded"
>
<ng-container *ngIf="multiple; else single">
<ng-container *ngFor="let file of control.valueChanges | async">
<tui-file
Expand Down Expand Up @@ -196,6 +200,25 @@
</ng-template>
</tui-doc-documentation>

<tui-doc-documentation heading="TuiFiles">
<ng-template
documentationPropertyName="max"
documentationPropertyMode="input"
documentationPropertyType="number"
[(documentationPropertyValue)]="maxFilesCount"
>
Maximum number of displayed files
</ng-template>
<ng-template
documentationPropertyName="expanded"
documentationPropertyMode="input-output"
documentationPropertyType="boolean"
[(documentationPropertyValue)]="expanded"
>
Expanded/collapsed state for multiple files that are limited by the max property
</ng-template>
</tui-doc-documentation>

<tui-doc-documentation heading="TuiFile">
<ng-template
documentationPropertyName="showDelete"
Expand Down
6 changes: 3 additions & 3 deletions projects/kit/components/files/files.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ng-container>
<tui-expand
*ngIf="hasExtraItems"
[expanded]="!hidden"
[expanded]="expanded"
>
<div class="t-extra-items">
<ng-container *ngFor="let item of items; let index = index">
Expand All @@ -33,9 +33,9 @@
size="m"
type="button"
class="t-button"
[class.t-button_collapsed]="hidden"
[class.t-button_collapsed]="!expanded"
(click)="toggle()"
>
{{ (hidden ? showAllText$ : hideText$) | async }}
{{ (expanded ? hideText$ : showAllText$) | async }}
</button>
</section>
11 changes: 9 additions & 2 deletions projects/kit/components/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import {
ChangeDetectionStrategy,
Component,
ContentChildren,
EventEmitter,
Inject,
Input,
Output,
QueryList,
TemplateRef,
ViewEncapsulation,
Expand All @@ -27,7 +29,11 @@ export class TuiFilesComponent {
@tuiDefaultProp()
max = 0;

hidden = true;
@Input()
expanded = false;

@Output()
readonly expandedChange = new EventEmitter<boolean>();

constructor(
@Inject(TUI_HIDE_TEXT) readonly hideText$: Observable<string>,
Expand All @@ -39,6 +45,7 @@ export class TuiFilesComponent {
}

toggle(): void {
this.hidden = !this.hidden;
this.expanded = !this.expanded;
this.expandedChange.emit(this.expanded);
}
}