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

fix(kit): InputFiles fix validity and drag states #8845

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
@@ -1,6 +1,6 @@
import {AsyncPipe, NgIf} from '@angular/common';
import {Component} from '@angular/core';
import {FormControl, ReactiveFormsModule} from '@angular/forms';
import {FormControl, ReactiveFormsModule, Validators} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import type {TuiFileLike} from '@taiga-ui/kit';
Expand All @@ -16,7 +16,11 @@ import {finalize, map, of, Subject, switchMap, timer} from 'rxjs';
changeDetection,
})
export default class Example {
protected readonly control = new FormControl<TuiFileLike | null>(null);
protected readonly control = new FormControl<TuiFileLike | null>(
null,
Validators.required,
waterplea marked this conversation as resolved.
Show resolved Hide resolved
);

protected readonly failedFiles$ = new Subject<TuiFileLike | null>();
protected readonly loadingFiles$ = new Subject<TuiFileLike | null>();
protected readonly loadedFiles$ = this.control.valueChanges.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
appearance="secondary"
src="@tui.droplet"
/>
<div>Drop it like it's hot!</div>
<div>
Drop it like it's hot!
<br />
<br />
</div>
</div>
<ng-template #base>
<div class="content">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tui-doc-page
header="InputFiles"
package="KIT"
path="kit/components/files"
type="components"
>
<ng-template pageTab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {TuiInputFilesDirective} from './input-files.directive';
'(dragover.prevent.silent)': '0',
'(drop.prevent)': 'onDropped($event)',
'(dragenter)': 'onDrag($event.dataTransfer)',
'(dragleave.self)': 'onDrag(null)',
'(dragleave)': 'onDrag(null)',
'[class._dragged]': 'fileDragged',
'(change)': 'onFilesSelected($event.target)',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {coerceArray} from '@angular/cdk/coercion';
import {Directive, forwardRef, inject, Output} from '@angular/core';
import {TuiNativeValidator} from '@taiga-ui/cdk';
import {tuiAsControl, TuiControl} from '@taiga-ui/cdk/classes';
import {EMPTY_ARRAY} from '@taiga-ui/cdk/constants';
import {tuiControlValue} from '@taiga-ui/cdk/observables';
Expand All @@ -24,6 +25,7 @@ import {TuiInputFilesValidator} from './input-files-validator.directive';
tuiAppearanceOptionsProvider(TuiInputFilesDirective),
],
hostDirectives: [
TuiNativeValidator,
TuiWithAppearance,
{
directive: TuiInputFilesValidator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ label[tuiInputFiles] {
}

[tuiAppearance][data-appearance='file'] {
.transition(background);

border-radius: inherit;
box-sizing: border-box;
border: 1px dashed var(--tui-text-action);
outline: none;

tui-root._mobile & {
border-style: solid;
Expand Down Expand Up @@ -68,4 +71,8 @@ label[tuiInputFiles] {
.appearance-focus({
border: 0.125rem solid var(--tui-border-focus);
});

&:invalid {
border-color: var(--tui-status-negative) !important;
}
}
Loading