File

src/ui/badge/smart-badge.component.ts

Implements

ControlValueAccessor OnDestroy

Metadata

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor()

Inputs

valueList
Type : ValueList
Required :  true

Outputs

ngModelChange
Type : string | undefined

Methods

registerOnChange
registerOnChange(fn: any)

Register change callback

Parameters :
Name Type Optional
fn any No
Returns : void
registerOnTouched
registerOnTouched(fn: any)

Register touch callback

Parameters :
Name Type Optional
fn any No
Returns : void
setDisabledState
setDisabledState(isDisabled: boolean)

Set disabled state

Parameters :
Name Type Optional
isDisabled boolean No
Returns : void
writeValue
writeValue(value: string)

Write value

Parameters :
Name Type Optional
value string No
Returns : void

Properties

classList
Type : unknown
Default value : computed(() => { const overflowClass = `smart-badge--overflow-${this.overflowMode()}`; if (!this.selectedValueListItem()?.classList) { return ['smart-badge', overflowClass]; } return [ 'smart-badge', overflowClass, 'has-value', ...this.selectedValueListItem().classList ]; })

Computed property for the class list

disabled
Type : unknown
Default value : signal<boolean>(false)
overflowMode
Type : unknown
Default value : signal<SmartBadgeOverflowMode>('full')
selectedValueListItem
Type : unknown
Default value : computed(() => { if (!this.value() || !this.valueList()) { return undefined; } return this.valueList()?.[this.value()]; })
value
Type : unknown
Default value : signal<string | undefined>(undefined)
@let icon = $safeNavigationMigration(selectedValueListItem()?.icon); 
@let text = $safeNavigationMigration(selectedValueListItem()?.text); 
@if (selectedValueListItem()) {
    @if (icon) {
        <i [class]="icon + ' smart-badge-icon'"></i>
    }
    @if (text) {
        <span #badgeText class="smart-badge-text">{{ text }}</span>
    }
}

./smart-badge.component.scss

:host {
    display: block;
    max-width: 100%;
    min-width: 0;
}

.smart-badge {
    box-sizing: border-box;
    pointer-events: none;
    display: flex;
    flex-direction: row;
    max-height: 100%;
    min-height: 25px;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding: var(--kendo-spacing-1, 0.25rem) var(--kendo-spacing-2, 0.5rem);
    border: 1px solid;
    width: var(--smart-badge-width, auto);
    max-width: 100%;
    line-height: 1.2;
    height: var(--smart-badge-height, var(--smart-input-height, var(--kendo-input-height)));
    overflow: hidden;
    background-color: var(--kendo-color-surface);
    color: var(--smart-badge-text-color, var(--smart-color-on-primary, var(--kendo-color-on-primary)));
    border-color: var(--smart-badge-border-color, var(--smart-border-color, var(--kendo-color-border)));
    border-radius: var(--smart-badge-border-radius, var(--smart-border-radius, var(--kendo-border-radius-md)));

    .smart-badge-icon {
        flex: 0 0 auto;
        font-size: var(--kendo-font-size-sm);
    }

    .smart-badge-text {
        display: inline-block;
        flex: 1 1 0;
        font-size: var(--kendo-font-size-sm);
        font-weight: var(--kendo-font-weight-semibold);
        min-width: 0;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        max-width: 100%;
        user-select: none;
    }

    &.smart-badge--overflow-full {
        justify-content: center;

        .smart-badge-text {
            text-overflow: clip;
        }
    }

    &.smart-badge--overflow-truncated {
        justify-content: flex-start;

        .smart-badge-text {
            text-overflow: ellipsis;
        }
    }

    &.smart-badge--overflow-icon-only {
        justify-content: center;

        .smart-badge-text {
            display: none;
        }
    }

    &.smart-badge--overflow-measuring {
        justify-content: center;
        max-width: 100%;
        min-width: 0;
        width: 100%;

        .smart-badge-text {
            display: inline-block;
            flex: 1 1 0;
            max-width: 100%;
            overflow: hidden;
            position: static;
            text-overflow: ellipsis;
            visibility: visible;
            white-space: nowrap;
        }
    }

    &.has-value {
        background-color: var(--smart-badge-background-color, var(--smart-primary-color, var(--kendo-color-primary)));
    }

    &:not(.has-value) {
        border: none;
        background: none;
        color: var(--kendo-color-on-surface);
    }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""