@mantic-ui/angular
Version:
mantic UI for Angular
734 lines (718 loc) • 641 kB
JavaScript
import * as i0 from '@angular/core';
import { inject, ElementRef, Injectable, Optional, Inject, Directive, linkedSignal, signal, input, computed, effect, output, Component, contentChild, EventEmitter, Output, Input, contentChildren, model, TemplateRef, ViewContainerRef, untracked, ViewChild, ContentChild, viewChild, IterableDiffers, makeEnvironmentProviders, NgZone, viewChildren, ChangeDetectionStrategy, Pipe, HostBinding, Service, InjectionToken, Injector, NgModule, LOCALE_ID } from '@angular/core';
import { Subject, fromEvent, animationFrameScheduler, ReplaySubject, BehaviorSubject, throttleTime, delay, merge, combineLatest, distinctUntilChanged, race } from 'rxjs';
import { takeUntil, filter, map, shareReplay } from 'rxjs/operators';
import { NgClass, NgTemplateOutlet, DatePipe, AsyncPipe, NgComponentOutlet, registerLocaleData } from '@angular/common';
import * as i1 from '@fortawesome/angular-fontawesome';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import * as i1$1 from '@angular/forms';
import { FormsModule } from '@angular/forms';
import { outputFromObservable } from '@angular/core/rxjs-interop';
import * as i1$3 from '@angular/router';
import { RouterLink, UrlSegment, ActivatedRoute, Router, NavigationEnd, TitleStrategy, DefaultUrlSerializer, UrlSerializer } from '@angular/router';
import * as i1$2 from '@angular/platform-browser';
const toBoolean = (value) => {
return value === '' || value === true || value?.toString().toLowerCase() === 'true';
};
const toBooleanWithUndefined = (value) => {
return value === undefined ? undefined : toBoolean(value);
};
class SortedClassesService {
constructor() {
this.entries = new Map();
this.elementRef = inject(ElementRef);
}
/**
* Registers one or more keys. The keys will only registered if they are not already registered.
*/
registerFallback(...keys) {
for (const key of keys) {
if (this.has(key)) {
continue;
}
this.registerEntry(key);
}
return this;
}
/**
* Registers one or more keys. If they are already registered, the order will be updated.
*/
register(...keys) {
for (const key of keys) {
const existingEntry = this.getEntry(key);
if (existingEntry) {
for (let [_, entry] of this.entries) {
if (entry.order > existingEntry.order) {
entry.order--;
}
}
existingEntry.order = this.entries.size - 1;
}
else {
this.registerEntry(key);
}
}
return this;
}
registerFixed(...keys) {
for (const key of keys) {
this.registerEntry(key, { fixed: true });
}
return this;
}
unregister(...keys) {
for (const key of keys) {
this.entries.delete(key.toLocaleLowerCase());
}
return this;
}
ignore(...keys) {
for (const key of keys) {
this.registerEntry(key, { ignore: true });
}
return this;
}
registerEntry(key, options) {
if (!key) {
return;
}
if (this.has(key)) {
console.warn(`'${key}' is already registered on <${this.elementRef.nativeElement.tagName}>.`);
}
const entry = {
...options,
key: key.toLocaleLowerCase(),
value: options?.fixed ? key : options?.value ?? '',
order: this.entries.size
};
this.entries.set(entry.key, entry);
}
getEntry(key) {
key = key.toLocaleLowerCase();
return this.entries.get(key);
}
set(key, value, options) {
let entry = this.getEntry(key);
if (!entry) {
console.warn(`Set an unregistered value '${key}' on <${this.elementRef.nativeElement.tagName}> is not recommended. Call register(key) method once, before using set(...) method.`);
entry = this.register(key).getEntry(key);
}
if (!entry) {
throw new Error('Entry not found #dki3kjk');
}
if (entry.fixed) {
console.error(`Can not change an fixed value '${key} on <${this.elementRef.nativeElement.tagName}>. Use register(key) instead of registerFixed(key)`);
return this;
}
if (value === true) {
entry.value = key;
}
else if (value === false || value === undefined || value === null) {
entry.value = '';
}
else {
entry.value = value.toString();
}
if (options?.refresh !== false) {
this.updateEntry(entry);
}
return this;
}
get(key) {
return this.getEntry(key)?.value;
}
has(key) {
return !!this.getEntry(key);
}
toString() {
return Array.from(this.entries.values())
.sort(SortedClassesService.sortByOrder)
.map(entry => entry.value)
.filter(value => value)
.join(' ');
}
update() {
Array.from(this.entries.values())
.filter(entry => !entry.ignore)
.sort(SortedClassesService.sortByOrder)
.forEach(entry => this.updateEntry(entry));
}
updateEntry(entry) {
const classList = this.elementRef.nativeElement.classList;
if (entry.previous) {
classList.remove(...entry.previous);
}
const values = entry.value.split(' ').filter(x => !!x);
classList.add(...values);
entry.previous = values;
}
static sortByOrder(left, right) {
return left.order > right.order ? 1 : left.order < right.order ? -1 : 0;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: SortedClassesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: SortedClassesService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: SortedClassesService, decorators: [{
type: Injectable
}] });
class Destroyable {
constructor() {
this.destroySubject = new Subject();
/**
* An observable that emits when the component is destroyed.
*/
this.destroy = this.destroySubject.asObservable();
}
/**
* Pipe this method to a subject to take values until the component is destroyed.
* Example: `observable.pipe(this.takeUntilDestroy()).subscribe(...);`
* Equals to `observable.pipe(takeUntil(this.destroy)).subscribe(...);`.
*/
takeUntilDestroy() {
return takeUntil(this.destroy);
}
ngOnDestroy() {
this.destroySubject.next();
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: Destroyable, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: Destroyable }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: Destroyable, decorators: [{
type: Injectable
}] });
class BaseComponent extends Destroyable {
static { this.providers = [SortedClassesService]; }
get noClasses() {
return this.noClassesValue;
}
set noClasses(value) {
this.noClassesValue = value;
this.refreshClasses();
}
constructor(
// eslint-disable-next-line @angular-eslint/prefer-inject
useUiClass = true) {
super();
this.classes = inject(SortedClassesService, { self: true });
this.elementRef = inject(ElementRef);
this.noClassesValue = false;
this.initialized = false;
this.tag = this.elementRef.nativeElement.tagName.toLowerCase();
this.validateAttributes = true;
if (useUiClass) {
this.classes.registerFixed('ui');
}
this.classes.register('style');
}
ngOnInit() {
this.initialized = true;
this.readPropertiesFromAttributes();
this.refreshClasses();
}
readPropertiesFromAttributes() {
if (!this.validateAttributes) {
return;
}
for (const attribute of this.elementRef.nativeElement.attributes) {
if (attribute.name.startsWith('_ng') || attribute.name.startsWith('ng-') || attribute.name.startsWith('m-') || attribute.name === 'class' || attribute.name === 'title') {
continue;
}
if (!this.classes.has(attribute.name)) {
console.warn(`Unknown attribute '${attribute.name}' on <${this.tag}> found.`, this.elementRef.nativeElement);
}
}
}
// TODO: Check usage
refreshClasses() {
if (!this.initialized) {
return;
}
this.classes.update();
}
toBoolean(value) {
return toBoolean(value);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BaseComponent, deps: [{ token: 'none', optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.1", type: BaseComponent, isStandalone: true, providers: BaseComponent.providers, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BaseComponent, decorators: [{
type: Directive,
args: [{
providers: BaseComponent.providers
}]
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Optional
}, {
type: Inject,
args: ['none']
}] }] });
/**
* A writable signal that behaves like `model()` but supports a `transform`.
*
* `input()` and `output()` are compiler-recognised initializer APIs and must stay as direct
* class-field initializers — they cannot be created inside a helper. So declare them on the class
* and hand them to this factory, which wires up the writable state and the change emission:
*
* ```ts
* public readonly activeInput = input<boolean, BooleanLike>(false, { alias: 'active', transform: toBoolean });
* public readonly activeChange = output<boolean>();
* public readonly active = transformableModel(this.activeInput, this.activeChange, toBoolean);
* ```
*
* Read with `active()`, write with `active.set(<BooleanLike>)`. A binding on the aliased input flows
* in (already coerced by the input's own transform) and resets the value WITHOUT re-emitting; an
* imperative `set`/`update` coerces the value and emits the change output (model two-way semantics).
*/
const transformableModel = (source, change, transform) => {
const state = linkedSignal(() => source(), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
const setState = state.set.bind(state);
const model = state;
model.set = (value) => {
const next = transform(value);
if (Object.is(next, state())) {
return;
}
setState(next);
change.emit(next);
};
model.update = (updateFn) => {
const next = updateFn(state());
if (Object.is(next, state())) {
return;
}
setState(next);
change.emit(next);
};
return model;
};
class InvertibleComponent extends BaseComponent {
static { this.providers = [...BaseComponent.providers]; }
constructor(
// eslint-disable-next-line @angular-eslint/prefer-inject
useUiClass = true) {
super(useUiClass);
this.invertedDefault = signal(false, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "invertedDefault" }] : /* istanbul ignore next */ []));
this.invertedInput = input(undefined, { ...(ngDevMode ? { debugName: "invertedInput" } : /* istanbul ignore next */ {}), alias: 'inverted', transform: toBoolean });
this.inverted = computed(() => this.invertedInput() ?? this.invertedDefault(), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "inverted" }] : /* istanbul ignore next */ []));
this.classes.register('inverted');
effect(() => this.classes.set('inverted', this.inverted()));
}
refreshInverted(value) {
this.invertedDefault.set(value);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: InvertibleComponent, deps: [{ token: 'none', optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.1", type: InvertibleComponent, isStandalone: true, inputs: { invertedInput: { classPropertyName: "invertedInput", publicName: "inverted", isSignal: true, isRequired: false, transformFunction: null } }, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: InvertibleComponent, decorators: [{
type: Directive
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Optional
}, {
type: Inject,
args: ['none']
}] }], propDecorators: { invertedInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "inverted", required: false }] }] } });
class ButtonBaseComponent extends InvertibleComponent {
static { this.providers = [...InvertibleComponent.providers]; }
get attached() {
return this.attachedTop() || this.attachedBottom() || this.attachedLeft() || this.attachedRight();
}
constructor() {
super();
this.primary = input(false, { ...(ngDevMode ? { debugName: "primary" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.secondary = input(false, { ...(ngDevMode ? { debugName: "secondary" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.positive = input(false, { ...(ngDevMode ? { debugName: "positive" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.negative = input(false, { ...(ngDevMode ? { debugName: "negative" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.size = input('', /* @ts-ignore */
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
this.circular = input(false, { ...(ngDevMode ? { debugName: "circular" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedLeft = input(false, { ...(ngDevMode ? { debugName: "attachedLeft" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedTop = input(false, { ...(ngDevMode ? { debugName: "attachedTop" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedRight = input(false, { ...(ngDevMode ? { debugName: "attachedRight" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedBottom = input(false, { ...(ngDevMode ? { debugName: "attachedBottom" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.color = input(undefined, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
this.basic = input(false, { ...(ngDevMode ? { debugName: "basic" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.activeInput = input(false, { ...(ngDevMode ? { debugName: "activeInput" } : /* istanbul ignore next */ {}), alias: 'active', transform: toBoolean });
this.activeChange = output();
this.active = transformableModel(this.activeInput, this.activeChange, toBoolean);
this.elementRef.nativeElement.setAttribute('tabindex', '0');
this.classes.register('color', 'basic', 'disabled', 'loading', 'active', 'size', 'primary', 'secondary', 'positive', 'negative', 'circular', 'tabindex', 'attachedLeft', 'attachedRight', 'attachedTop', 'attachedBottom')
.registerFixed('button');
effect(() => this.classes.set('color', this.color()));
effect(() => this.classes.set('basic', this.basic()));
effect(() => this.classes.set('disabled', this.disabled()));
effect(() => this.classes.set('loading', this.loading()));
effect(() => this.classes.set('active', this.active()));
effect(() => this.classes.set('size', this.size()));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ButtonBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.1", type: ButtonBaseComponent, isStandalone: true, inputs: { primary: { classPropertyName: "primary", publicName: "primary", isSignal: true, isRequired: false, transformFunction: null }, secondary: { classPropertyName: "secondary", publicName: "secondary", isSignal: true, isRequired: false, transformFunction: null }, positive: { classPropertyName: "positive", publicName: "positive", isSignal: true, isRequired: false, transformFunction: null }, negative: { classPropertyName: "negative", publicName: "negative", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, circular: { classPropertyName: "circular", publicName: "circular", isSignal: true, isRequired: false, transformFunction: null }, attachedLeft: { classPropertyName: "attachedLeft", publicName: "attachedLeft", isSignal: true, isRequired: false, transformFunction: null }, attachedTop: { classPropertyName: "attachedTop", publicName: "attachedTop", isSignal: true, isRequired: false, transformFunction: null }, attachedRight: { classPropertyName: "attachedRight", publicName: "attachedRight", isSignal: true, isRequired: false, transformFunction: null }, attachedBottom: { classPropertyName: "attachedBottom", publicName: "attachedBottom", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, basic: { classPropertyName: "basic", publicName: "basic", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, activeInput: { classPropertyName: "activeInput", publicName: "active", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeChange: "activeChange" }, host: { properties: { "class.primary": "primary()", "class.secondary": "secondary()", "class.positive": "positive()", "class.negative": "negative()", "class.circular": "circular()", "class.left": "attachedLeft()", "class.top": "attachedTop()", "class.right": "attachedRight()", "class.bottom": "attachedBottom()", "class.attached": "attached" } }, providers: ButtonBaseComponent.providers, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ButtonBaseComponent, decorators: [{
type: Directive,
args: [{
providers: ButtonBaseComponent.providers,
host: {
'[class.primary]': 'primary()',
'[class.secondary]': 'secondary()',
'[class.positive]': 'positive()',
'[class.negative]': 'negative()',
'[class.circular]': 'circular()',
'[class.left]': 'attachedLeft()',
'[class.top]': 'attachedTop()',
'[class.right]': 'attachedRight()',
'[class.bottom]': 'attachedBottom()',
'[class.attached]': 'attached'
}
}]
}], ctorParameters: () => [], propDecorators: { primary: [{ type: i0.Input, args: [{ isSignal: true, alias: "primary", required: false }] }], secondary: [{ type: i0.Input, args: [{ isSignal: true, alias: "secondary", required: false }] }], positive: [{ type: i0.Input, args: [{ isSignal: true, alias: "positive", required: false }] }], negative: [{ type: i0.Input, args: [{ isSignal: true, alias: "negative", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], circular: [{ type: i0.Input, args: [{ isSignal: true, alias: "circular", required: false }] }], attachedLeft: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedLeft", required: false }] }], attachedTop: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedTop", required: false }] }], attachedRight: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedRight", required: false }] }], attachedBottom: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedBottom", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], basic: [{ type: i0.Input, args: [{ isSignal: true, alias: "basic", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], activeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: false }] }], activeChange: [{ type: i0.Output, args: ["activeChange"] }] } });
class BaseDirective extends Destroyable {
static { this.providers = [SortedClassesService]; }
get noClasses() {
return this.noClassesValue;
}
set noClasses(value) {
this.noClassesValue = value;
this.refreshClasses();
}
constructor(
// eslint-disable-next-line @angular-eslint/prefer-inject
useUiClass = true) {
super();
this.classes = inject(SortedClassesService, { self: true });
this.elementRef = inject(ElementRef, { self: true });
this.noClassesValue = false;
this.initialized = false;
this.validateAttributes = true;
this.tag = this.elementRef.nativeElement.tagName.toLowerCase();
if (useUiClass) {
this.classes.registerFixed('ui');
}
}
ngOnInit() {
this.initialized = true;
this.readPropertiesFromAttributes();
this.refreshClasses();
}
readPropertiesFromAttributes() {
if (!this.validateAttributes) {
return;
}
for (const attribute of this.elementRef.nativeElement.attributes) {
if (attribute.name.startsWith('_ng') || attribute.name.startsWith('ng-') || attribute.name.startsWith('m-') || attribute.name === 'class' || attribute.name === 'title') {
continue;
}
if (!this.classes.has(attribute.name)) {
console.warn(`Unknown attribute '${attribute.name}' on <${this.tag}> found.`, this.elementRef.nativeElement);
}
}
}
refreshClasses() {
if (!this.initialized) {
return;
}
this.classes.update();
}
toBoolean(value) {
return toBoolean(value);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BaseDirective, deps: [{ token: 'none', optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.1", type: BaseDirective, isStandalone: true, usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BaseDirective, decorators: [{
type: Directive
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Optional
}, {
type: Inject,
args: ['none']
}] }] });
class AnimationComponent extends BaseComponent {
constructor() {
super(false);
this.hidden = input(true, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "hidden" }] : /* istanbul ignore next */ []));
this.direction = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "direction" }] : /* istanbul ignore next */ []));
this.classes.registerFixed('content');
this.classes.register('hidden', 'direction');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AnimationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.1", type: AnimationComponent, isStandalone: true, selector: "m-animation", inputs: { hidden: { classPropertyName: "hidden", publicName: "hidden", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.hidden": "hidden()" } }, providers: [...BaseComponent.providers], usesInheritance: true, ngImport: i0, template: "<ng-content />", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: AnimationComponent, decorators: [{
type: Component,
args: [{ selector: 'm-animation', host: { '[class.hidden]': 'hidden()' }, providers: [...BaseComponent.providers], template: "<ng-content />" }]
}], ctorParameters: () => [], propDecorators: { hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }] } });
class BreadcrumbComponent extends BaseComponent {
constructor() {
super();
this.classes.registerFixed('breadcrumb');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BreadcrumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.1", type: BreadcrumbComponent, isStandalone: true, selector: "m-breadcrumb", providers: [...BaseComponent.providers], usesInheritance: true, ngImport: i0, template: "<!-- TODO: Not yet implemented -->\r\n<!-- <a class=\"section\">Home</a>-->\r\n<!-- <i class=\"right angle icon divider\"></i>-->\r\n<!-- <a class=\"section\">Store</a>-->\r\n<!-- <i class=\"right angle icon divider\"></i>-->\r\n<!-- <div class=\"active section\">T-Shirt</div>-->\r\n", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: BreadcrumbComponent, decorators: [{
type: Component,
args: [{ selector: 'm-breadcrumb', providers: [...BaseComponent.providers], template: "<!-- TODO: Not yet implemented -->\r\n<!-- <a class=\"section\">Home</a>-->\r\n<!-- <i class=\"right angle icon divider\"></i>-->\r\n<!-- <a class=\"section\">Store</a>-->\r\n<!-- <i class=\"right angle icon divider\"></i>-->\r\n<!-- <div class=\"active section\">T-Shirt</div>-->\r\n" }]
}], ctorParameters: () => [] });
class Key {
static { this.space = new Key('Space'); }
static { this.enter = new Key('Enter'); }
static { this.escape = new Key('Escape'); }
constructor(code) {
this.code = code;
}
is(event) {
return Key.is(event, this);
}
static is(event, ...keys) {
return keys.some(key => event.key === (typeof key === 'string' ? key : key.code));
}
}
class ToggleButtonComponent extends ButtonBaseComponent {
get checked() {
return this.active();
}
// Kept as accessor: assigned imperatively inside the class (check()/uncheck()) and has a paired checkedChange output; signal inputs are read-only.
set checked(value) {
this.active.set(value);
}
constructor() {
super();
this.activeTemplate = contentChild('active', /* @ts-ignore */
...(ngDevMode ? [{ debugName: "activeTemplate" }] : /* istanbul ignore next */ []));
this.checkedChange = new EventEmitter();
this.classes.register('checked')
.registerFixed('toggle');
}
toggle() {
if (this.checked) {
this.uncheck();
}
else {
this.check();
}
}
onKeyDown(event) {
if (Key.is(event, Key.space, Key.enter)) {
this.toggle();
event.preventDefault();
}
}
check() {
if (this.checked) {
return;
}
this.checked = true;
this.checkedChange.emit(this.checked);
}
uncheck() {
if (!this.checked) {
return;
}
this.checked = false;
this.checkedChange.emit(this.checked);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ToggleButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: ToggleButtonComponent, isStandalone: true, selector: "m-toggle-button", inputs: { checked: "checked" }, outputs: { checkedChange: "checkedChange" }, host: { listeners: { "click": "toggle()", "keydown": "onKeyDown($event)" }, properties: { "class.checked": "checked" } }, providers: [...ButtonBaseComponent.providers], queries: [{ propertyName: "activeTemplate", first: true, predicate: ["active"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (!active() || !activeTemplate()) {\n <ng-content></ng-content>\n} @else {\n <ng-template [ngTemplateOutlet]=\"activeTemplate()\"></ng-template>\n}\n", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ToggleButtonComponent, decorators: [{
type: Component,
args: [{ selector: 'm-toggle-button', imports: [], providers: [...ButtonBaseComponent.providers], host: {
'[class.checked]': 'checked',
'(click)': 'toggle()',
'(keydown)': 'onKeyDown($event)'
}, template: "@if (!active() || !activeTemplate()) {\n <ng-content></ng-content>\n} @else {\n <ng-template [ngTemplateOutlet]=\"activeTemplate()\"></ng-template>\n}\n" }]
}], ctorParameters: () => [], propDecorators: { activeTemplate: [{ type: i0.ContentChild, args: ['active', { isSignal: true }] }], checked: [{
type: Input
}], checkedChange: [{
type: Output
}] } });
class ButtonGroupComponent extends BaseComponent {
constructor() {
super();
this.attachedLeft = input(false, { ...(ngDevMode ? { debugName: "attachedLeft" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedTop = input(false, { ...(ngDevMode ? { debugName: "attachedTop" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedRight = input(false, { ...(ngDevMode ? { debugName: "attachedRight" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.attachedBottom = input(false, { ...(ngDevMode ? { debugName: "attachedBottom" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.color = input(undefined, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
this.toggleButtons = contentChildren(ToggleButtonComponent, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "toggleButtons" }] : /* istanbul ignore next */ []));
this.attached = computed(() => this.attachedTop() || this.attachedBottom() || this.attachedLeft() || this.attachedRight(), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "attached" }] : /* istanbul ignore next */ []));
this.classes.register('color')
.registerFixed('buttons');
effect(() => this.classes.set('color', this.color()));
effect(onCleanup => {
const subscriptions = this.toggleButtons().map(button => button.checkedChange.subscribe(value => value ? this.uncheckOthers(button) : this.keepOneChecked()));
onCleanup(() => {
for (const subscription of subscriptions) {
subscription.unsubscribe();
}
});
});
}
uncheckOthers(button) {
for (const x of this.toggleButtons().filter(x => x !== button)) {
x.uncheck();
}
}
keepOneChecked() {
const buttons = this.toggleButtons();
if (buttons.length > 0 && buttons.every(button => !button.checked)) {
buttons[0].check();
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.1", type: ButtonGroupComponent, isStandalone: true, selector: "m-button-group", inputs: { attachedLeft: { classPropertyName: "attachedLeft", publicName: "attachedLeft", isSignal: true, isRequired: false, transformFunction: null }, attachedTop: { classPropertyName: "attachedTop", publicName: "attachedTop", isSignal: true, isRequired: false, transformFunction: null }, attachedRight: { classPropertyName: "attachedRight", publicName: "attachedRight", isSignal: true, isRequired: false, transformFunction: null }, attachedBottom: { classPropertyName: "attachedBottom", publicName: "attachedBottom", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.left": "attachedLeft()", "class.top": "attachedTop()", "class.right": "attachedRight()", "class.bottom": "attachedBottom()", "class.attached": "attached()" } }, providers: [...BaseComponent.providers], queries: [{ propertyName: "toggleButtons", predicate: ToggleButtonComponent, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<ng-content />", styles: [":host{flex-wrap:wrap}\n"] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ButtonGroupComponent, decorators: [{
type: Component,
args: [{ selector: 'm-button-group', providers: [...BaseComponent.providers], host: {
'[class.left]': 'attachedLeft()',
'[class.top]': 'attachedTop()',
'[class.right]': 'attachedRight()',
'[class.bottom]': 'attachedBottom()',
'[class.attached]': 'attached()'
}, template: "<ng-content />", styles: [":host{flex-wrap:wrap}\n"] }]
}], ctorParameters: () => [], propDecorators: { attachedLeft: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedLeft", required: false }] }], attachedTop: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedTop", required: false }] }], attachedRight: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedRight", required: false }] }], attachedBottom: [{ type: i0.Input, args: [{ isSignal: true, alias: "attachedBottom", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], toggleButtons: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ToggleButtonComponent), { isSignal: true }] }] } });
class IconComponent {
constructor() {
this.icon = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
this.size = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
this.iconClass = input('icon', /* @ts-ignore */
...(ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []));
this.mIcon = computed(() => {
const icon = this.icon();
return typeof icon === 'string' ? icon : undefined;
}, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "mIcon" }] : /* istanbul ignore next */ []));
this.faIcon = computed(() => {
const icon = this.icon();
return typeof icon === 'string' ? undefined : icon;
}, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "faIcon" }] : /* istanbul ignore next */ []));
this.mappedSize = computed(() => IconComponent.mapSize(this.size()), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "mappedSize" }] : /* istanbul ignore next */ []));
this.mSize = computed(() => this.mappedSize().mSize, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "mSize" }] : /* istanbul ignore next */ []));
this.faSize = computed(() => this.mappedSize().faSize, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "faSize" }] : /* istanbul ignore next */ []));
}
static mapSize(value) {
switch (value) {
case 'mini':
case 'tiny':
case 'small':
return { mSize: value, faSize: 'xs' };
case 'large':
case 'lg':
return { mSize: 'large', faSize: 'lg' };
case 'big':
case '2x':
return { mSize: 'big', faSize: '2x' };
case 'huge':
case '4x':
return { mSize: 'huge', faSize: '4x' };
case 'massive':
case '8x':
return { mSize: 'massive', faSize: '8x' };
case 'xs':
case 'sm':
case '1x':
return { mSize: 'small', faSize: value };
case '3x':
return { mSize: 'big', faSize: value };
case '5x':
case '6x':
return { mSize: 'huge', faSize: value };
case '7x':
case '9x':
case '10x':
return { mSize: 'massive', faSize: value };
default:
return { mSize: undefined, faSize: undefined };
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IconComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: IconComponent, isStandalone: true, selector: "m-icon", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, iconClass: { classPropertyName: "iconClass", publicName: "iconClass", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@if (mIcon(); as mIcon) {\n <i class=\"{{ mIcon }} {{ mSize() }}\" [ngClass]=\"iconClass()\"></i>\n}\n@if (faIcon(); as faIcon) {\n <fa-icon [icon]=\"faIcon\" [size]=\"faSize() ?? '1x'\" [ngClass]=\"iconClass()\" />\n}\n", styles: [""], dependencies: [{ kind: "ngmodule", type: FontAwesomeModule }, { kind: "component", type: i1.FaIconComponent, selector: "fa-icon", inputs: ["icon", "title", "animation", "mask", "flip", "size", "pull", "border", "inverse", "symbol", "rotate", "fixedWidth", "transform", "a11yRole"], outputs: ["iconChange", "titleChange", "animationChange", "maskChange", "flipChange", "sizeChange", "pullChange", "borderChange", "inverseChange", "symbolChange", "rotateChange", "fixedWidthChange", "transformChange", "a11yRoleChange"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: IconComponent, decorators: [{
type: Component,
args: [{ selector: 'm-icon', imports: [FontAwesomeModule, NgClass], template: "@if (mIcon(); as mIcon) {\n <i class=\"{{ mIcon }} {{ mSize() }}\" [ngClass]=\"iconClass()\"></i>\n}\n@if (faIcon(); as faIcon) {\n <fa-icon [icon]=\"faIcon\" [size]=\"faSize() ?? '1x'\" [ngClass]=\"iconClass()\" />\n}\n" }]
}], propDecorators: { icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], iconClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconClass", required: false }] }] } });
class LabelComponent extends BaseComponent {
constructor() {
super();
this.position = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "position" }] : /* istanbul ignore next */ []));
this.pointing = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "pointing" }] : /* istanbul ignore next */ []));
this.horizontal = input(false, { ...(ngDevMode ? { debugName: "horizontal" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.basic = input(false, { ...(ngDevMode ? { debugName: "basic" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.color = input(undefined, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
this.classes.register('basic', 'color', 'pointing', 'position', 'horizontal')
.registerFixed('label');
effect(() => this.classes.set('basic', this.basic()));
effect(() => this.classes.set('color', this.color()));
effect(() => this.classes.set('pointing', this.pointing()));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LabelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.1", type: LabelComponent, isStandalone: true, selector: "m-label", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, pointing: { classPropertyName: "pointing", publicName: "pointing", isSignal: true, isRequired: false, transformFunction: null }, horizontal: { classPropertyName: "horizontal", publicName: "horizontal", isSignal: true, isRequired: false, transformFunction: null }, basic: { classPropertyName: "basic", publicName: "basic", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.horizontal": "horizontal()" } }, providers: [...BaseComponent.providers], usesInheritance: true, ngImport: i0, template: "<ng-content />", styles: [""] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LabelComponent, decorators: [{
type: Component,
args: [{ selector: 'm-label', providers: [...BaseComponent.providers], host: {
'[class.horizontal]': 'horizontal()'
}, template: "<ng-content />" }]
}], ctorParameters: () => [], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], pointing: [{ type: i0.Input, args: [{ isSignal: true, alias: "pointing", required: false }] }], horizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "horizontal", required: false }] }], basic: [{ type: i0.Input, args: [{ isSignal: true, alias: "basic", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }] } });
class ButtonComponent extends ButtonBaseComponent {
static { this.defaults = {
inverted: signal(false)
}; }
constructor() {
super();
this.animated = contentChild(AnimationComponent, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "animated" }] : /* istanbul ignore next */ []));
this.animation = computed(() => this.animated()?.direction(), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "animation" }] : /* istanbul ignore next */ []));
this.label = contentChild(LabelComponent, /* @ts-ignore */
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
this.labelPosition = computed(() => this.label()?.position(), /* @ts-ignore */
...(ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []));
this.icon = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
this.iconSize = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "iconSize" }] : /* istanbul ignore next */ []));
this.iconPosition = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "iconPosition" }] : /* istanbul ignore next */ []));
this.social = input(/* @ts-ignore */
...(ngDevMode ? [undefined, { debugName: "social" }] : /* istanbul ignore next */ []));
this.fluid = input(false, { ...(ngDevMode ? { debugName: "fluid" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.pointing = input(false, { ...(ngDevMode ? { debugName: "pointing" } : /* istanbul ignore next */ {}), transform: toBoolean });
this.classes.register('fluid', 'pointing', 'animation', 'animated', 'labelPosition', 'iconPosition', 'label', 'labeled', 'iconLabeled', 'social', 'icon');
effect(() => this.classes.set('fluid', this.fluid()));
effect(() => this.classes.set('pointing', this.pointing()));
effect(() => {
const value = this.icon();
this.classes.set('icon', !!value);
this.classes.set('iconLabeled', value ? 'labeled' : undefined);
});
effect(() => this.classes.set('iconPosition', this.iconPosition()));
effect(() => this.classes.set('social', this.social()));
effect(() => this.classes.set('labeled', !!this.label()));
effect(() => this.refreshInverted(ButtonComponent.defaults.inverted()));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: ButtonComponent, isStandalone: true, selector: "m-button", inputs: { icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, iconSize: { classPropertyName: "iconSize", publicName: "iconSize", isSignal: true, isRequired: false, transformFunction: null }, iconPosition: { classPropertyName: "iconPosition", publicName: "iconPosition", isSignal: true, isRequired: false, transformFunction: null }, social: { classPropertyName: "social", publicName: "social", isSignal: true, isRequired: false, transformFunction: null }, fluid: { classPropertyName: "fluid", publicName: "fluid", isSignal: true, isRequired: false, transformFunction: null }, pointing: { classPropertyName: "pointing", publicName: "pointing", isSignal: true, isRequired: false, transformFunction: null } }, providers: [...ButtonBaseComponent.providers], queries: [{ propertyName: "animated", first: true, predicate: AnimationComponent, descendants: true, isSignal: true }, { propertyName: "label", first: true, predicate: LabelComponent, descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@if (animated()) {\n <div class=\"visible content\">\n <ng-container [ngTemplateOutlet]=\"content\" />\n </div>\n <ng-content select=\"m-animation\" />\n}\n@if (label()) {\n @if (labelPosition() === 'left') {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n }\n <div class=\"ui\" [class.basic]=\"basic()\" [class.icon]=\"icon()\" [ngClass]=\"color()\" [class.button]=\"true\">\n <ng-container [ngTemplateOutlet]=\"content\" />\n </div>\n @if (labelPosition() !== 'left') {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n }\n <ng-template #labelTemplate>\n <ng-content select=\"m-label\" />\n </ng-template>\n}\n@if (social()) {\n <m-icon [icon]=\"social()!.toLowerCase()\" class=\"icon\" />\n {{ social() }}\n}\n@if (!animated() && !label() && !social()) {\n <ng-container [ngTemplateOutlet]=\"content\" />\n}\n<ng-template #content>\n @if (icon()) {\n <m-icon [icon]=\"icon()\" [size]=\"iconSize()\" />\n }\n <ng-content />\n</ng-template>\n", styles: [""], dependencies: [{ kind: "component", type: IconComponent, selector: "m-icon", inputs: ["icon", "size", "iconClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
}