• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.81
/src/upload/file-select.component.ts
1
import { fromEvent, Subject } from 'rxjs';
2
import { takeUntil } from 'rxjs/operators';
3

4
import {
5
    Component,
6
    ElementRef,
7
    EventEmitter,
8
    Input,
9
    NgZone,
10
    numberAttribute,
11
    OnChanges,
12
    OnDestroy,
13
    Output,
14
    SimpleChanges,
15
    ViewChild,
1✔
16
    inject,
UNCOV
17
    Inject,
×
UNCOV
18
    viewChild,
×
UNCOV
19
    output,
×
UNCOV
20
    input,
×
UNCOV
21
    DestroyRef,
×
UNCOV
22
    effect
×
UNCOV
23
} from '@angular/core';
×
UNCOV
24
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
×
UNCOV
25
import { FileSelectBaseDirective } from './file-select-base';
×
UNCOV
26
import { THY_UPLOAD_DEFAULT_OPTIONS, ThyUploadConfig } from './upload.config';
×
27
import { mimeTypeConvert } from './util';
28
import { coerceBooleanProperty } from 'ngx-tethys/util';
UNCOV
29
import { ThyFileSelectEvent } from './types';
×
30

UNCOV
31
/**
×
UNCOV
32
 * 文件上传组件
×
UNCOV
33
 * @name thy-file-select,[thyFileSelect]
×
UNCOV
34
 * @order 10
×
UNCOV
35
 */
×
UNCOV
36
@Component({
×
37
    selector: '[thyFileSelect],thy-file-select',
38
    templateUrl: './file-select.component.html'
UNCOV
39
})
×
40
export class ThyFileSelect extends FileSelectBaseDirective {
UNCOV
41
    /**
×
UNCOV
42
     * 文件选择事件
×
43
     */
44
    readonly thyOnFileSelect = output<ThyFileSelectEvent>();
UNCOV
45

×
46
    protected readonly fileInput = viewChild<ElementRef<HTMLInputElement>>('fileInput');
47

48
    /**
49
     * 文件是否多选
UNCOV
50
     * @default false
×
UNCOV
51
     */
×
UNCOV
52
    readonly thyMultiple = input(false, { transform: coerceBooleanProperty });
×
UNCOV
53

×
54
    /**
55
     * 是否接受文件夹
56
     */
1✔
57
    readonly thyAcceptFolder = input(false, { transform: coerceBooleanProperty });
58

59
    private destroyRef = inject(DestroyRef);
60

61
    constructor(
1✔
62
        public elementRef: ElementRef,
63
        @Inject(THY_UPLOAD_DEFAULT_OPTIONS) public defaultConfig: ThyUploadConfig,
64
        private ngZone: NgZone
65
    ) {
66
        super(elementRef, defaultConfig);
67

68
        this.ngZone.runOutsideAngular(() =>
1✔
69
            fromEvent(this.elementRef.nativeElement, 'click')
70
                .pipe(takeUntilDestroyed(this.destroyRef))
71
                .subscribe(() => {
72
                    this.fileInput().nativeElement.click();
73
                })
74
        );
75

76
        effect(() => {
77
            const multiple = this.thyMultiple();
78
            const acceptFolder = this.thyAcceptFolder();
79
            const inputElement = this.fileInput().nativeElement;
80
            if (multiple) {
81
                inputElement.setAttribute('multiple', '');
82
            } else {
83
                inputElement.removeAttribute('multiple');
84
            }
85
            if (acceptFolder) {
86
                inputElement.setAttribute('webkitdirectory', '');
87
            } else {
88
                inputElement.removeAttribute('webkitdirectory');
89
            }
90
        });
91
    }
92

93
    selectFile($event: Event) {
94
        const files = this.fileInput().nativeElement.files;
95
        if (files && files.length > 0) {
96
            this.selectFiles($event, Array.from(files), this.thyOnFileSelect);
97
            this.fileInput().nativeElement.value = '';
98
        }
99
    }
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc