import { KbqToastModule } from '@koobiq/components/toast';

KbqToastComponent

componentСкопировать ссылку на KbqToastComponent
@Component({ selector: 'kbq-toast' })
class KbqToastComponent {
    readonly data: KbqToastData;
    readonly hovered: Signal<boolean>;
    readonly focused: Signal<boolean>;
    id: number;
    readonly $implicit: this;
    get isFocusedOrHovered(): boolean;
    close(): void;
}
hoveredСкопировать ссылку на hoveredSignal<boolean>

Whether the pointer is over the toast.

focusedСкопировать ссылку на focusedSignal<boolean>

Whether the toast or an element inside it holds the focus.

$implicitСкопировать ссылку на $implicitthis

Context of the templates a consumer passes through KbqToastData.

KbqToastContainerComponent

componentСкопировать ссылку на KbqToastContainerComponent
@Component({ selector: 'kbq-toast-container' })
class KbqToastContainerComponent extends CdkScrollable {
    readonly service: KbqToastService<any>;
    readonly viewContainer: Signal<ViewContainerRef>;
    createToast<C>(
        data: KbqToastData,
        componentType: Type<C>,
        onTop: boolean
    ): ComponentRef<C>;
    createTemplate(
        data: KbqToastData,
        template: TemplateRef<any>,
        onTop: boolean
    ): EmbeddedViewRef<KbqToastTemplateContext>;
    remove(viewRef: ViewRef): void;
    getInjector(data: KbqToastData): Injector;
    elementScrolled(): Observable<Event>;
    getElementRef(): ElementRef<HTMLElement>;
    scrollTo(options: ExtendedScrollToOptions): void;
    measureScrollOffset(
        from: "top" | "right" | "left" | "bottom" | "start" | "end"
    ): number;
}
elementScrolled()Скопировать ссылку на elementScrolled()Observable<Event>

Returns observable that emits when a scroll event is fired on the host element.

getElementRef()Скопировать ссылку на getElementRef()ElementRef<HTMLElement>

Gets the ElementRef for the viewport.

scrollTo()Скопировать ссылку на scrollTo()void

Scrolls to the specified offsets. This is a normalized version of the browser's native scrollTo method, since browsers are not consistent about what scrollLeft means in RTL. For this method left and right always refer to the left and right side of the scrolling container irrespective of the layout direction. start and end refer to left and right in an LTR context and vice-versa in an RTL context.

Parameters
optionsExtendedScrollToOptions

specified the offsets to scroll to.

measureScrollOffset()Скопировать ссылку на measureScrollOffset()number

Measures the scroll offset relative to the specified edge of the viewport. This method can be used instead of directly checking scrollLeft or scrollTop, since browsers are not consistent about what scrollLeft means in RTL. The values returned by this method are normalized such that left and right always refer to the left and right side of the scrolling container irrespective of the layout direction. start and end refer to left and right in an LTR context and vice-versa in an RTL context.

Parameters
from"top" | "right" | "left" | "bottom" | "start" | "end"

The edge to measure from.

KbqToastCloseButton

directiveСкопировать ссылку на KbqToastCloseButton
@Directive({ selector: '[kbq-toast-close-button]' })
class KbqToastCloseButton {}

KbqToastService

serviceСкопировать ссылку на KbqToastService

Generic T is a type hint only; the runtime component comes from KBQ_TOAST_FACTORY.

@Injectable({ providedIn: 'root' })
class KbqToastService<T extends KbqToastComponent = KbqToastComponent> implements KbqToastStack {
    get toasts(): ComponentRef<T>[];
    get templates(): EmbeddedViewRef<KbqToastTemplateContext>[];
    readonly read: BehaviorSubject<KbqToastData | null>;
    readonly hovered: Signal<boolean>;
    readonly focused: Signal<boolean>;
    readonly timer: Observable<number>;
    show(
        data: KbqToastData,
        duration?: number,
        onTop?: boolean
    ): { ref: ComponentRef<T>; id: number };
    showTemplate(
        data: KbqToastData,
        template: TemplateRef<any>,
        duration?: number,
        onTop?: boolean
    ): { ref: EmbeddedViewRef<KbqToastTemplateContext>; id: number };
    hide(id: number): void;
    hideTemplate(id: number): void;
}
hoveredСкопировать ссылку на hoveredSignal<boolean>

Whether at least one toast is hovered.

focusedСкопировать ссылку на focusedSignal<boolean>

Whether at least one toast holds the focus.

timerСкопировать ссылку на timerObservable<number>

Countdown heartbeat: emits every 500 ms while the stack holds something and is not paused by the pointer or the keyboard focus. No interval runs while the stack is empty.

KbqToastData

classСкопировать ссылку на KbqToastData
class KbqToastData {
    id?: string;
    title?: string | TemplateRef<any>;
    style?: KbqToastStyle | (string & {});
    icon?: TemplateRef<any> | boolean;
    iconClass?: string;
    caption?: string | TemplateRef<any>;
    content?: string | TemplateRef<any>;
    actions?: TemplateRef<any>;
    closeButton?: TemplateRef<any> | boolean;
}
styleoptionalСкопировать ссылку на styleKbqToastStyle | (string & {})

Visual style of the toast. Styles outside KbqToastStyle render without a default icon.

KbqToastConfig

interfaceСкопировать ссылку на KbqToastConfig
interface KbqToastConfig {
    position: KbqToastPosition;
    duration: number;
    delay: number;
    onTop: boolean;
    indent: {
        vertical: number;
        horizontal: number;
    };
}
indentСкопировать ссылку на indent{ vertical: number; horizontal: number; }

Custom indentation for positioning the toast stack overlay when using GlobalPositionStrategy

indent.verticalСкопировать ссылку на indent.verticalnumber

Vertical spacing from the top or bottom of the screen.

indent.horizontalСкопировать ссылку на indent.horizontalnumber

Horizontal spacing from the left or right of the screen.

KbqToastStack

interfaceСкопировать ссылку на KbqToastStack

Narrow contract that a toast consumes from the service owning its stack.

KbqToastService implements it and provides itself under KBQ_TOAST_STACK for every toast it creates, so that a toast never has to depend on the concrete service that instantiates it.

interface KbqToastStack {
    readonly read: Subject<KbqToastData | null>;
    hide(id: number): void;
    setHovered(id: number, hovered: boolean): void;
    setFocused(id: number, origin: FocusOrigin): void;
}
readСкопировать ссылку на readSubject<KbqToastData | null>

Emits the data of a toast once the user has read it.

hide()Скопировать ссылку на hide()void

Removes the toast with the given id from the stack.

setHovered()Скопировать ссылку на setHovered()void

Reports that the pointer entered or left the toast with the given id.

setFocused()Скопировать ссылку на setFocused()void

Reports the origin the toast with the given id is focused with, or null once it loses focus.

KbqToastTemplateContext

typeСкопировать ссылку на KbqToastTemplateContext

Context of a template rendered by KbqToastService.showTemplate.

Note that it differs from the context of the slot templates passed through KbqToastData (title, caption, content, actions, icon and close button), whose $implicit is the KbqToastComponent instance.

type KbqToastTemplateContext = {
    $implicit: KbqToastData;
};

KbqToastPosition

enumСкопировать ссылку на KbqToastPosition
enum KbqToastPosition {
    TOP_RIGHT = 'top-right',
    TOP_LEFT = 'top-left',
    TOP_CENTER = 'top-center',
    BOTTOM_RIGHT = 'bottom-right',
    BOTTOM_LEFT = 'bottom-left',
    BOTTOM_CENTER = 'bottom-center',
    CENTER = 'center'
}

KbqToastStyle

enumСкопировать ссылку на KbqToastStyle
enum KbqToastStyle {
    Contrast = 'contrast',
    Success = 'success',
    Warning = 'warning',
    Error = 'error'
}

defaultToastConfig

constСкопировать ссылку на defaultToastConfig

Frozen so that the fallback every application shares cannot be reconfigured from a single consumer.

const defaultToastConfig: KbqToastConfig;

KBQ_TOAST_CONFIG

constСкопировать ссылку на KBQ_TOAST_CONFIG
const KBQ_TOAST_CONFIG: InjectionToken<KbqToastConfig>;

KBQ_TOAST_FACTORY

constСкопировать ссылку на KBQ_TOAST_FACTORY
const KBQ_TOAST_FACTORY: InjectionToken<typeof KbqToastComponent>;

KBQ_TOAST_STACK

constСкопировать ссылку на KBQ_TOAST_STACK

Stack a toast belongs to. Provided by KbqToastService for every toast it creates.

const KBQ_TOAST_STACK: InjectionToken<KbqToastStack>;

kbqToastConfigurationProvider

constСкопировать ссылку на kbqToastConfigurationProvider

Utility provider for KBQ_TOAST_CONFIG.

const kbqToastConfigurationProvider: (
    configuration: Partial<KbqToastConfig>
) => Provider;
Предложения по улучшению
Если вы нашли ошибку или хотите доработать статью, создайте запрос на GitHub.