• 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

3.88
/src/date-picker/lib/date/date-table.component.ts
1
import { NgClass } from '@angular/common';
2
import { ChangeDetectionStrategy, Component, EventEmitter, OnChanges, Output, inject } from '@angular/core';
3
import { TinyDate, valueFunctionProp } from 'ngx-tethys/util';
4
import { DateHelperService } from '../../date-helper.service';
5
import { ThyDatePickerConfigService } from '../../date-picker.service';
6
import { CalendarTable } from '../calendar/calendar-table.component';
7
import { DateTableCell } from './date-table-cell.component';
8
import { DateBodyRow, DateCell } from './types';
9

10
/**
11
 * @private
12
 */
13
@Component({
1✔
14
    changeDetection: ChangeDetectionStrategy.OnPush,
UNCOV
15
    // eslint-disable-next-line @angular-eslint/component-selector
×
UNCOV
16
    selector: 'date-table',
×
UNCOV
17
    exportAs: 'dateTable',
×
UNCOV
18
    templateUrl: 'date-table.component.html',
×
19
    imports: [NgClass, DateTableCell]
20
})
21
export class DateTable extends CalendarTable implements OnChanges {
UNCOV
22
    private dateHelper = inject(DateHelperService);
×
UNCOV
23
    private datePickerConfigService = inject(ThyDatePickerConfigService);
×
UNCOV
24

×
25
    @Output() readonly dayHover = new EventEmitter<TinyDate>(); // Emitted when hover on a day by mouse enter
26

UNCOV
27
    constructor() {
×
UNCOV
28
        super();
×
UNCOV
29
    }
×
UNCOV
30

×
UNCOV
31
    private chooseDate(value: TinyDate): void {
×
32
        // Only change date not change time
×
33
        const date = new TinyDate(
34
            TinyDate.createDateInTimeZone(
35
                value.getFullYear(),
36
                value.getMonth(),
37
                value.getDate(),
38
                this.activeDate?.getHours(),
39
                this.activeDate?.getMinutes(),
UNCOV
40
                this.activeDate?.getSeconds(),
×
41
                this.timeZone
42
            ),
UNCOV
43
            this.timeZone
×
UNCOV
44
        );
×
45
        this.activeDate = date.clone();
46
        this.valueChange.emit(date);
×
47
    }
48

UNCOV
49
    makeHeadRow(): DateCell[] {
×
UNCOV
50
        const weekDays: DateCell[] = [];
×
UNCOV
51
        const start = this.activeDate.calendarStart({ weekStartsOn: this.datePickerConfigService.config.weekStartsOn });
×
UNCOV
52
        for (let colIndex = 0; colIndex < this.MAX_COL; colIndex++) {
×
UNCOV
53
            const day = start.addDays(colIndex);
×
54
            weekDays[colIndex] = {
55
                title: this.dateHelper.format(day.nativeDate, this.dateHelper.relyOnDatePipe ? 'E' : 'ddd'),
56
                content: this.dateHelper.format(day.nativeDate, this.getVeryShortWeekFormat()),
57
                isSelected: false,
58
                isDisabled: false,
UNCOV
59
                onClick(): void {},
×
UNCOV
60
                onMouseEnter(): void {}
×
UNCOV
61
            };
×
UNCOV
62
        }
×
UNCOV
63
        return weekDays;
×
UNCOV
64
    }
×
65

66
    private getVeryShortWeekFormat(): string {
67
        if (this.dateHelper.relyOnDatePipe) {
68
            return this.prefixCls === 'thy-calendar-full' ? this.locale().fullWeekFormat : this.locale().weekFormat;
69
        }
70
        return 'dd';
71
    }
72

UNCOV
73
    makeBodyRows(): DateBodyRow[] {
×
74
        const dateRows: DateBodyRow[] = [];
×
75
        const firstDayOfMonth = this.activeDate.calendarStart({ weekStartsOn: this.datePickerConfigService.config.weekStartsOn });
UNCOV
76
        for (let week = 0; week < this.MAX_ROW; week++) {
×
UNCOV
77
            const weekStart = firstDayOfMonth.addDays(week * 7);
×
UNCOV
78
            const row: DateBodyRow = {
×
79
                isActive: false,
UNCOV
80
                isCurrent: false,
×
UNCOV
81
                dateCells: [],
×
UNCOV
82
                year: weekStart.getYear()
×
83
            };
UNCOV
84

×
UNCOV
85
            for (let day = 0; day < 7; day++) {
×
UNCOV
86
                const date = weekStart.addDays(day);
×
UNCOV
87
                const dateFormat = this.dateHelper.relyOnDatePipe ? 'longDate' : 'YYYY-MM-DD';
×
88
                const title = this.dateHelper.format(date.nativeDate, dateFormat);
UNCOV
89
                const label = this.dateHelper.format(date.nativeDate, this.dateHelper.relyOnDatePipe ? 'dd' : 'DD');
×
UNCOV
90

×
91
                const cell: DateCell = {
92
                    value: date.nativeDate,
UNCOV
93
                    label: label,
×
UNCOV
94
                    isSelected: false,
×
95
                    isDisabled: false,
UNCOV
96
                    isToday: false,
×
97
                    title: title,
UNCOV
98
                    dateCellRender: valueFunctionProp(this.cellRender, date),
×
99
                    content: `${date.getDate()}`,
100
                    onClick: () => this.chooseDate(date),
101
                    onMouseEnter: () => this.dayHover.emit(date)
UNCOV
102
                };
×
103
                this.addCellProperty(cell, date);
UNCOV
104

×
105
                if (this.showWeek && !row.weekNum) {
106
                    row.weekNum = this.dateHelper.getISOWeek(date.nativeDate);
UNCOV
107
                }
×
UNCOV
108

×
UNCOV
109
                if (date.isToday()) {
×
UNCOV
110
                    cell.isToday = true;
×
111
                    row.isCurrent = true;
UNCOV
112
                }
×
UNCOV
113

×
114
                if (this.selectedValue?.length > 0) {
UNCOV
115
                    const [startSelected, endSelected] = this.selectedValue;
×
UNCOV
116
                    if (date.isSameDay(startSelected)) {
×
UNCOV
117
                        row.isActive = true;
×
118
                    }
119
                    if (date.isSameDay(endSelected)) {
UNCOV
120
                        row.isActive = true;
×
121
                    }
UNCOV
122
                } else if (date.isSameDay(this.value)) {
×
UNCOV
123
                    row.isActive = true;
×
UNCOV
124
                }
×
UNCOV
125

×
UNCOV
126
                row.dateCells.push(cell);
×
127
            }
128

UNCOV
129
            row.classMap = {
×
130
                [`${this.prefixCls}-current-week`]: row.isCurrent,
131
                [`${this.prefixCls}-active-week`]: row.isActive
132
            };
133

134
            dateRows.push(row);
135
        }
136

137
        return dateRows;
138
    }
139

140
    addCellProperty(cell: DateCell, date: TinyDate): void {
141
        if (this.selectedValue?.length > 0) {
1✔
142
            const [startSelected, endSelected] = this.selectedValue;
1✔
143
            if (startSelected?.isSameDay(date)) {
144
                cell.isSelected = true;
145
            }
146
            if (endSelected?.isSameDay(date)) {
1✔
147
                cell.isSelected = true;
148
            }
149
            cell.isStartSingle = startSelected && !endSelected;
150
            cell.isEndSingle = !startSelected && !!endSelected;
151
            cell.isInRange = startSelected?.isBeforeDay(date) && date.isBeforeDay(endSelected);
152
        } else {
153
            cell.isSelected = date.isSameDay(this.value);
154
        }
155
        cell.isLastMonthCell = date.isBeforeMonth(this.activeDate);
156
        cell.isNextMonthCell = date.isAfterMonth(this.activeDate);
157
        cell.isToday = date.isToday();
158
        cell.isDisabled = !!this.disabledDate?.(date.nativeDate);
159
        cell.classMap = this.getClassMap(cell);
160
    }
161

162
    getClassMap(cell: DateCell): { [key: string]: boolean } {
163
        return {
164
            [`${this.prefixCls}-cell`]: true,
165
            [`${this.prefixCls}-today`]: cell.isToday,
166
            [`${this.prefixCls}-last-month-cell`]: cell.isLastMonthCell,
167
            [`${this.prefixCls}-next-month-btn-day`]: cell.isNextMonthCell,
168
            [`${this.prefixCls}-selected-day`]: cell.isSelected,
169
            [`${this.prefixCls}-disabled-cell`]: cell.isDisabled,
170
            [`${this.prefixCls}-selected-start-date`]: !!cell.isSelectedStartDate,
171
            [`${this.prefixCls}-selected-end-date`]: !!cell.isSelectedEndDate,
172
            [`${this.prefixCls}-in-range-cell`]: !!cell.isInRange
173
        };
174
    }
175
}
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