• 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.0
/src/breadcrumb/breadcrumb.component.ts
1
import { Component, ChangeDetectionStrategy, TemplateRef, numberAttribute, input, contentChild, Signal, computed } from '@angular/core';
2
import { ThyIcon } from 'ngx-tethys/icon';
3
import { NgClass, NgTemplateOutlet } from '@angular/common';
4
import { ThyBreadcrumbItem } from './breadcrumb-item.component';
5
import { SafeAny } from 'ngx-tethys/types';
6
import { ThyDropdownDirective, ThyDropdownMenuComponent, ThyDropdownMenuItemDirective } from 'ngx-tethys/dropdown';
7
import { ThyAction } from 'ngx-tethys/action';
8
import { coerceBooleanProperty } from 'ngx-tethys/util';
9

10
const THY_BREADCRUMB_ITEM_ELLIPSIS_ID = 'THY_BREADCRUMB_ITEM_ELLIPSIS_ID';
11

1✔
12
const ELLIPSIS_ITEM = { _id: THY_BREADCRUMB_ITEM_ELLIPSIS_ID };
1✔
13

14
/**
15
 * 面包屑组件
16
 * @name thy-breadcrumb
17
 * @order 10
18
 */
1✔
19
@Component({
UNCOV
20
    selector: 'thy-breadcrumb',
×
UNCOV
21
    templateUrl: './breadcrumb.component.html',
×
UNCOV
22
    exportAs: 'ThyBreadcrumb',
×
UNCOV
23
    changeDetection: ChangeDetectionStrategy.OnPush,
×
UNCOV
24
    host: {
×
UNCOV
25
        class: 'thy-breadcrumb',
×
26
        '[class.thy-breadcrumb-separator]': '!!thySeparator()',
×
27
        '[class.thy-breadcrumb-separator-slash]': 'thySeparator() === "slash"',
UNCOV
28
        '[class.thy-breadcrumb-separator-backslash]': 'thySeparator() === "backslash"',
×
29
        '[class.thy-breadcrumb-separator-vertical-line]': 'thySeparator() === "vertical-line"'
30
    },
UNCOV
31
    imports: [
×
32
        ThyIcon,
33
        NgClass,
UNCOV
34
        ThyBreadcrumbItem,
×
UNCOV
35
        NgTemplateOutlet,
×
UNCOV
36
        ThyAction,
×
UNCOV
37
        ThyDropdownDirective,
×
38
        ThyDropdownMenuItemDirective,
39
        ThyDropdownMenuComponent,
UNCOV
40
        ThyIcon
×
41
    ]
42
})
UNCOV
43
export class ThyBreadcrumb {
×
UNCOV
44
    /**
×
UNCOV
45
     * 面包屑的前缀 展示图标,如 folder-fill
×
UNCOV
46
     */
×
UNCOV
47
    readonly thyIcon = input<string>();
×
UNCOV
48

×
UNCOV
49
    iconClasses: Signal<string[]> = computed(() => {
×
UNCOV
50
        const icon = this.thyIcon();
×
UNCOV
51
        if (icon && icon.includes('wtf')) {
×
UNCOV
52
            const classes = icon.split(' ');
×
53
            if (classes.length === 1) {
UNCOV
54
                classes.unshift('wtf');
×
UNCOV
55
            }
×
UNCOV
56
            return classes;
×
UNCOV
57
        } else {
×
58
            return null;
59
        }
60
    });
61

62
    svgIconName: Signal<string> = computed(() => {
UNCOV
63
        const icon = this.thyIcon();
×
64
        if (icon && !icon.includes('wtf')) {
65
            return icon;
66
        } else {
67
            return null;
68
        }
69
    });
70

1✔
71
    /**
72
     * 面包屑的分隔符,不传值默认为 ">"
73
     * @type slash | backslash | vertical-line
74
     */
75
    readonly thySeparator = input<'slash' | 'backslash' | 'vertical-line'>();
76

77
    /**
78
     * 面包屑的每一项数据
79
     */
1✔
80
    readonly items = input<SafeAny[]>(undefined, { alias: 'thyItems' });
81

82
    /**
83
     * 最大显示数量,超出此数量后,面包屑会被省略, 0 表示不省略(仅当传入 thyItems 时有效)
84
     */
85
    readonly thyMaxCount = input(4, { transform: numberAttribute });
86

87
    /**
88
     * 是否可点击弹出已被省略的面包屑项(仅当传入 thyItems 时有效)
89
     */
90
    readonly thyExpandable = input(true, { transform: coerceBooleanProperty });
91

92
    /**
93
     * 面包屑的每一项模板(仅当传入 thyItems 时有效)
94
     */
95
    readonly itemTemplate = contentChild<TemplateRef<SafeAny>>('item');
96

97
    public ellipsisItemId = THY_BREADCRUMB_ITEM_ELLIPSIS_ID;
98

99
    public readonly processedItems: Signal<{
100
        ellipsisItems: SafeAny[];
101
        showItems: SafeAny[];
102
    }> = computed(() => {
103
        const items = this.items();
104
        if (!items?.length) {
105
            return;
106
        }
107
        const thyMaxCount = this.thyMaxCount();
108
        if (thyMaxCount && items.length > thyMaxCount) {
109
            const ellipsisIndex = items.length - thyMaxCount + 2;
110
            return {
111
                ellipsisItems: items.slice(1, ellipsisIndex),
112
                showItems: [items[0], ELLIPSIS_ITEM, ...items.slice(ellipsisIndex)]
113
            };
114
        } else {
115
            return {
116
                ellipsisItems: [],
117
                showItems: [...items]
118
            };
119
        }
120
    });
121
}
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