• 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

5.8
/src/date-picker/lib/calendar/calendar-table.component.ts
1
import { Directive, EventEmitter, Input, OnChanges, OnInit, Output, Signal, SimpleChange, SimpleChanges, TemplateRef } from '@angular/core';
2
import { injectLocale, ThyDatePickerLocale } from 'ngx-tethys/i18n';
3
import { SafeAny } from 'ngx-tethys/types';
4
import { FunctionProp, isTemplateRef, TinyDate } from 'ngx-tethys/util';
5
import { DateBodyRow, DateCell } from '../date/types';
6

7
/**
8
 * @private
1✔
9
 */
UNCOV
10
@Directive()
×
UNCOV
11
export abstract class CalendarTable implements OnInit, OnChanges {
×
UNCOV
12
    locale: Signal<ThyDatePickerLocale> = injectLocale('datePicker');
×
UNCOV
13
    isTemplateRef = isTemplateRef;
×
UNCOV
14
    headRow: DateCell[] = [];
×
UNCOV
15
    bodyRows: DateBodyRow[] = [];
×
UNCOV
16
    MAX_ROW = 6;
×
UNCOV
17
    MAX_COL = 7;
×
UNCOV
18

×
UNCOV
19
    @Input() prefixCls: string = 'thy-calendar';
×
UNCOV
20
    @Input() value: TinyDate;
×
UNCOV
21
    @Input() activeDate: TinyDate = new TinyDate();
×
UNCOV
22
    @Input() showWeek: boolean = false;
×
23
    @Input() selectedValue: TinyDate[] = []; // Range ONLY
24
    @Input() hoverValue: TinyDate[] = []; // Range ONLY
UNCOV
25
    @Input() timeZone: string;
×
UNCOV
26
    @Input() disabledDate?: (d: Date) => boolean;
×
UNCOV
27
    @Input() cellRender?: FunctionProp<TemplateRef<Date> | string>;
×
28
    @Input() fullCellRender?: FunctionProp<TemplateRef<Date> | string>;
29
    @Output() readonly valueChange = new EventEmitter<TinyDate>();
30

UNCOV
31
    @Output() readonly cellHover = new EventEmitter<TinyDate>(); // Emitted when hover on a day by mouse enter
×
32

33
    constructor() {}
UNCOV
34

×
35
    protected render(): void {
36
        if (this.activeDate) {
37
            this.headRow = this.makeHeadRow();
×
38
            this.bodyRows = this.makeBodyRows();
39
        }
UNCOV
40
    }
×
41

42
    trackByBodyRow(_index: number, item: DateBodyRow): SafeAny {
UNCOV
43
        return item.trackByIndex;
×
44
    }
×
45

UNCOV
46
    trackByBodyColumn(_index: number, item: DateCell): SafeAny {
×
47
        return item.trackByIndex;
48
    }
49

50
    hasRangeValue(): boolean {
51
        return this.selectedValue?.length > 0 || this.hoverValue?.length > 0;
52
    }
UNCOV
53

×
54
    abstract makeHeadRow(): DateCell[];
55
    abstract makeBodyRows(): DateBodyRow[];
56

UNCOV
57
    ngOnInit(): void {
×
UNCOV
58
        this.render();
×
UNCOV
59
    }
×
UNCOV
60

×
UNCOV
61
    ngOnChanges(changes: SimpleChanges): void {
×
62
        if (changes.activeDate && !changes.activeDate.currentValue) {
63
            this.activeDate = new TinyDate(undefined, this.timeZone);
64
        }
×
65

×
66
        if (
67
            changes.disabledDate ||
68
            changes.locale ||
UNCOV
69
            changes.showWeek ||
×
70
            this.isDateRealChange(changes.activeDate) ||
71
            this.isDateRealChange(changes.value) ||
UNCOV
72
            this.isDateRealChange(changes.selectedValue) ||
×
73
            this.isDateRealChange(changes.hoverValue)
74
        ) {
UNCOV
75
            this.render();
×
76
        }
77
    }
1✔
78

1✔
79
    private isDateRealChange(change: SimpleChange): boolean {
80
        if (change) {
81
            const previousValue: TinyDate | TinyDate[] = change.previousValue;
82
            const currentValue: TinyDate | TinyDate[] = change.currentValue;
83
            if (Array.isArray(currentValue)) {
84
                return (
85
                    !Array.isArray(previousValue) ||
86
                    currentValue.length !== previousValue.length ||
87
                    currentValue.some((value, index) => {
88
                        const previousCandyDate = previousValue[index];
89
                        return previousCandyDate instanceof TinyDate ? previousCandyDate.isSameDay(value) : previousCandyDate !== value;
90
                    })
91
                );
92
            } else {
93
                return !this.isSameDate(previousValue as TinyDate, currentValue);
1✔
94
            }
95
        }
96
        return false;
97
    }
98

99
    private isSameDate(left: TinyDate, right: TinyDate): boolean {
100
        return (!left && !right) || (left && right && right.isSameDay(left));
101
    }
102
}
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