@taiga-ui/kit
Version:
Taiga UI Angular main components kit
54 lines (48 loc) • 6.44 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, ChangeDetectionStrategy, Component, input, Directive } from '@angular/core';
import { WaResizeObserver } from '@ng-web-apis/resize-observer';
import { tuiInjectElement } from '@taiga-ui/cdk/utils/dom';
class TuiBadgedContentComponent {
constructor() {
this.cdr = inject(ChangeDetectorRef);
this.el = tuiInjectElement();
}
get imgTop() {
return this.resolve('.t-badge_top img');
}
get imgBottom() {
return this.resolve('.t-badge_bottom img');
}
onResize() {
this.cdr.detectChanges();
}
resolve(selector) {
return `url(${this.el.querySelector(selector)?.getAttribute('src') || ''})`;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiBadgedContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.21", type: TuiBadgedContentComponent, isStandalone: true, selector: "tui-badged-content", ngImport: i0, template: "<ng-content />\n\n<div\n #badgeTop\n class=\"t-badge t-badge_top\"\n [style.--t-badge-height.px]=\"badgeTop.offsetHeight\"\n [style.--t-img]=\"imgTop\"\n (waResizeObserver)=\"onResize()\"\n>\n <ng-content select=\"tui-badge-notification[tuiSlot='top'], img[tuiSlot='top']\" />\n <div class=\"t-border\">\n <ng-content select=\"[tuiSlot='top']\" />\n </div>\n</div>\n\n<div\n #badgeBottom\n class=\"t-badge t-badge_bottom\"\n [style.--t-badge-height.px]=\"badgeBottom.offsetHeight\"\n [style.--t-img]=\"imgBottom\"\n (waResizeObserver)=\"onResize()\"\n>\n <ng-content select=\"tui-badge-notification[tuiSlot='bottom'], img[tuiSlot='bottom']\" />\n <div class=\"t-border\">\n <ng-content select=\"[tuiSlot='bottom']\" />\n </div>\n</div>\n", styles: [":host{--tui-radius: var(--tui-radius-l);--t-badge-height: 0;--t-corner-offset: calc((var(--tui-radius) * 1.4142 - var(--tui-radius)) * 1 / 1.4142);position:relative;display:inline-block;block-size:fit-content;inline-size:max-content;color:var(--tui-background-base)}.t-badge{--t-offset: calc(var(--t-badge-height) * -.5 + var(--t-corner-offset));position:absolute;display:flex;isolation:isolate}.t-badge_top{inset-block-start:var(--t-offset);inset-inline-end:var(--t-offset)}.t-badge_bottom{inset-block-end:var(--t-offset);inset-inline-end:var(--t-offset)}.t-badge:before{inset:50% auto auto 50%;transform:translate(-50%,-50%);content:\"\";position:absolute;z-index:-1;inline-size:120%;block-size:120%;-webkit-mask-image:var(--t-img);mask-image:var(--t-img);-webkit-mask-size:100%;mask-size:100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;background-color:currentColor}.t-border:not(:empty){display:flex;border-radius:6rem;box-shadow:0 0 0 1px currentColor;background:currentColor}\n"], dependencies: [{ kind: "directive", type: WaResizeObserver, selector: "[waResizeObserver]", inputs: ["waResizeBox"], outputs: ["waResizeObserver"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiBadgedContentComponent, decorators: [{
type: Component,
args: [{ selector: 'tui-badged-content', imports: [WaResizeObserver], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-content />\n\n<div\n #badgeTop\n class=\"t-badge t-badge_top\"\n [style.--t-badge-height.px]=\"badgeTop.offsetHeight\"\n [style.--t-img]=\"imgTop\"\n (waResizeObserver)=\"onResize()\"\n>\n <ng-content select=\"tui-badge-notification[tuiSlot='top'], img[tuiSlot='top']\" />\n <div class=\"t-border\">\n <ng-content select=\"[tuiSlot='top']\" />\n </div>\n</div>\n\n<div\n #badgeBottom\n class=\"t-badge t-badge_bottom\"\n [style.--t-badge-height.px]=\"badgeBottom.offsetHeight\"\n [style.--t-img]=\"imgBottom\"\n (waResizeObserver)=\"onResize()\"\n>\n <ng-content select=\"tui-badge-notification[tuiSlot='bottom'], img[tuiSlot='bottom']\" />\n <div class=\"t-border\">\n <ng-content select=\"[tuiSlot='bottom']\" />\n </div>\n</div>\n", styles: [":host{--tui-radius: var(--tui-radius-l);--t-badge-height: 0;--t-corner-offset: calc((var(--tui-radius) * 1.4142 - var(--tui-radius)) * 1 / 1.4142);position:relative;display:inline-block;block-size:fit-content;inline-size:max-content;color:var(--tui-background-base)}.t-badge{--t-offset: calc(var(--t-badge-height) * -.5 + var(--t-corner-offset));position:absolute;display:flex;isolation:isolate}.t-badge_top{inset-block-start:var(--t-offset);inset-inline-end:var(--t-offset)}.t-badge_bottom{inset-block-end:var(--t-offset);inset-inline-end:var(--t-offset)}.t-badge:before{inset:50% auto auto 50%;transform:translate(-50%,-50%);content:\"\";position:absolute;z-index:-1;inline-size:120%;block-size:120%;-webkit-mask-image:var(--t-img);mask-image:var(--t-img);-webkit-mask-size:100%;mask-size:100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;background-color:currentColor}.t-border:not(:empty){display:flex;border-radius:6rem;box-shadow:0 0 0 1px currentColor;background:currentColor}\n"] }]
}] });
class TuiBadgedContentDirective {
constructor() {
this.tuiSlot = input('top');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiBadgedContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.21", type: TuiBadgedContentDirective, isStandalone: true, selector: "[tuiSlot]", inputs: { tuiSlot: { classPropertyName: "tuiSlot", publicName: "tuiSlot", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.21", ngImport: i0, type: TuiBadgedContentDirective, decorators: [{
type: Directive,
args: [{ selector: '[tuiSlot]' }]
}] });
const TuiBadgedContent = [
TuiBadgedContentDirective,
TuiBadgedContentComponent,
];
/**
* Generated bundle index. Do not edit.
*/
export { TuiBadgedContent, TuiBadgedContentComponent, TuiBadgedContentDirective };
//# sourceMappingURL=taiga-ui-kit-components-badged-content.mjs.map