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

atinc / ngx-tethys / #55

30 Jul 2025 07:08AM UTC coverage: 9.866% (-80.4%) from 90.297%
#55

push

why520crazy
feat(empty): add setMessage for update display text #TINFR-2616

92 of 6794 branches covered (1.35%)

Branch coverage included in aggregate %.

2014 of 14552 relevant lines covered (13.84%)

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

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

62
    svgIconName: Signal<string> = computed(() => {
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

© 2026 Coveralls, Inc