• 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

9.09
/src/stepper/stepper.component.ts
1
import {
2
    Component,
3
    numberAttribute,
4
    viewChildren,
5
    output,
6
    contentChildren,
7
    input,
8
    computed,
9
    effect,
10
    ChangeDetectionStrategy,
11
    signal,
12
    untracked
13
} from '@angular/core';
14
import { ThyStep, IThyStepperComponent, THY_STEPPER_COMPONENT } from './step.component';
1✔
15
import { ThyStepHeader } from './step-header.component';
UNCOV
16
import { NgTemplateOutlet } from '@angular/common';
×
UNCOV
17
import { coerceBooleanProperty } from 'ngx-tethys/util';
×
UNCOV
18

×
UNCOV
19
/**
×
UNCOV
20
 * 步骤条组件
×
UNCOV
21
 * @name thy-stepper
×
UNCOV
22
 * @order 10
×
UNCOV
23
 */
×
UNCOV
24
@Component({
×
UNCOV
25
    selector: 'thy-stepper',
×
26
    templateUrl: 'stepper.component.html',
×
27
    providers: [{ provide: THY_STEPPER_COMPONENT, useExisting: ThyStepper }],
×
28
    imports: [ThyStepHeader, NgTemplateOutlet],
29
    changeDetection: ChangeDetectionStrategy.OnPush,
30
    host: { class: 'thy-stepper' }
UNCOV
31
})
×
UNCOV
32
export class ThyStepper implements IThyStepperComponent {
×
UNCOV
33
    /**
×
UNCOV
34
     * 当前处于激活状态的步骤 index
×
UNCOV
35
     */
×
UNCOV
36
    readonly thySelectedIndex = input<number, unknown>(0, { transform: numberAttribute });
×
UNCOV
37

×
38
    /**
39
     * 当前处于激活状态的步骤实例
40
     */
41
    readonly thySelected = input<ThyStep>();
42

43
    /**
UNCOV
44
     * 步骤条导航是否展示,默认展示
×
45
     */
×
46
    readonly thyShowStepHeader = input(true, { transform: coerceBooleanProperty });
UNCOV
47

×
UNCOV
48
    readonly selectionChange = output<any>();
×
UNCOV
49

×
UNCOV
50
    readonly steps = contentChildren(ThyStep);
×
51

52
    protected selectedIndex = signal(0);
53

54
    protected readonly selected = computed(() => this.steps()?.[this.selectedIndex()]);
55

56
    constructor() {
57
        effect(() => {
UNCOV
58
            const newIndex = this.thySelectedIndex();
×
UNCOV
59
            if (newIndex) {
×
60
                untracked(() => {
61
                    this.updateSelectedIndex(newIndex);
UNCOV
62
                });
×
63
            }
64
        });
UNCOV
65

×
66
        effect(() => {
67
            const selected = this.thySelected();
68
            if (selected) {
UNCOV
69
                untracked(() => {
×
70
                    const index = this.steps()?.indexOf(selected);
71
                    if (index > -1) {
1✔
72
                        this.updateSelectedIndex(index);
1✔
73
                    }
74
                });
75
            }
76
        });
77
    }
78

79
    private updateSelectedIndex(newIndex: number): void {
80
        if (!this.steps()?.[newIndex]) {
1✔
81
            return;
82
        }
83
        const previouslySelectedIndex = this.selectedIndex();
84
        const previouslySelectedStep = this.steps() ? this.steps()[previouslySelectedIndex] : null;
85
        this.selectedIndex.set(newIndex);
86
        this.selectionChange.emit({
87
            selectedIndex: newIndex,
88
            previouslySelectedIndex: previouslySelectedIndex,
89
            selectedStep: this.selected(),
90
            previouslySelectedStep: previouslySelectedStep
91
        });
92
    }
93

94
    updateSelected(step: ThyStep): void {
95
        const index = this.steps().indexOf(step);
96
        this.updateSelectedIndex(index);
97
    }
98

99
    to(index: number): void {
100
        this.updateSelectedIndex(Math.min(index, this.steps().length - 1));
101
    }
102

103
    next(): void {
104
        this.updateSelectedIndex(Math.min(this.selectedIndex() + 1, this.steps().length - 1));
105
    }
106

107
    /** Selects and focuses the previous step in list. */
108
    previous(): void {
109
        this.updateSelectedIndex(Math.max(this.selectedIndex() - 1, 0));
110
    }
111
}
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