@coreui/angular 5.7.11 → 5.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, Directive, input, Renderer2, effect, TemplateRef, booleanAttribute, untracked, NgModule, computed, Injectable, Component, afterNextRender, linkedSignal, output, signal, contentChildren, numberAttribute, DestroyRef, DOCUMENT, PLATFORM_ID, RendererFactory2, forwardRef, NgZone, ChangeDetectorRef, contentChild, afterEveryRender, viewChild, ViewContainerRef, model, afterRenderEffect, ChangeDetectionStrategy, Pipe, Input, HostBinding, ContentChildren, HostListener, Injector, runInInjectionContext, ViewEncapsulation, MAX_ANIMATION_TIMEOUT } from '@angular/core';
2
+ import { inject, ElementRef, Directive, input, Renderer2, effect, TemplateRef, booleanAttribute, untracked, NgModule, computed, Injectable, Component, afterNextRender, linkedSignal, output, signal, contentChildren, numberAttribute, MAX_ANIMATION_TIMEOUT, DestroyRef, DOCUMENT, PLATFORM_ID, RendererFactory2, forwardRef, NgZone, ChangeDetectorRef, contentChild, afterEveryRender, viewChild, ViewContainerRef, model, afterRenderEffect, ChangeDetectionStrategy, Pipe, Input, HostBinding, ContentChildren, HostListener, Injector, runInInjectionContext, ViewEncapsulation } from '@angular/core';
3
3
  import { NgTemplateOutlet, isPlatformServer, isPlatformBrowser } from '@angular/common';
4
- import { animation, animate, style, AnimationBuilder, useAnimation, trigger, state, transition, group, query, animateChild } from '@angular/animations';
4
+ import { animation, animate, style, AnimationBuilder, useAnimation, group, query, trigger, state, transition, animateChild } from '@angular/animations';
5
5
  import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
6
6
  import { fromEvent, Subject, BehaviorSubject, merge, takeWhile, skipWhile } from 'rxjs';
7
7
  import * as i1 from '@angular/router';
@@ -699,6 +699,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
699
699
  }] });
700
700
 
701
701
  class AlertComponent {
702
+ #hostElement = inject(ElementRef);
703
+ #maxAnimationTimeout = inject(MAX_ANIMATION_TIMEOUT);
702
704
  /**
703
705
  * Sets the color context of the component to one of CoreUI’s themed colors.
704
706
  * @return Colors
@@ -720,50 +722,42 @@ class AlertComponent {
720
722
  variant = input(/* @ts-ignore */
721
723
  ...(ngDevMode ? [undefined, { debugName: "variant" }] : /* istanbul ignore next */ []));
722
724
  /**
723
- * Optionally adds a close button to alert and allow it to self dismiss.
725
+ * Optionally adds a close button to the alert and allow it to self-dismiss.
724
726
  * @return boolean
725
727
  * @default false
726
728
  */
727
- dismissibleInput = input(false, { ...(ngDevMode ? { debugName: "dismissibleInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'dismissible' });
728
- #dismissible = linkedSignal({ ...(ngDevMode ? { debugName: "#dismissible" } : /* istanbul ignore next */ {}), source: this.dismissibleInput,
729
- computation: (value) => {
730
- return value;
731
- } });
732
- set dismissible(value) {
733
- this.#dismissible.set(value);
734
- }
735
- get dismissible() {
736
- return this.#dismissible();
737
- }
729
+ dismissible = input(false, { ...(ngDevMode ? { debugName: "dismissible" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
738
730
  /**
739
731
  * Adds animation for dismissible alert.
740
732
  * @return boolean
741
733
  */
742
734
  fade = input(false, { ...(ngDevMode ? { debugName: "fade" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
743
735
  /**
744
- * Toggle the visibility of alert component.
736
+ * Toggle the visibility of the alert component.
745
737
  * @return boolean
746
738
  */
747
739
  visibleInput = input(true, { ...(ngDevMode ? { debugName: "visibleInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'visible' });
748
- #visible = linkedSignal({ ...(ngDevMode ? { debugName: "#visible" } : /* istanbul ignore next */ {}), source: this.visibleInput,
749
- computation: (value) => {
750
- return value;
751
- } });
752
- set visible(value) {
753
- if (this.#visible() !== value) {
754
- this.#visible.set(value);
755
- this.visibleChange?.emit(value);
756
- }
757
- }
758
- get visible() {
759
- return this.#visible();
760
- }
761
- hide = signal(false, /* @ts-ignore */
762
- ...(ngDevMode ? [{ debugName: "hide" }] : /* istanbul ignore next */ []));
740
+ visible = linkedSignal(this.visibleInput, /* @ts-ignore */
741
+ ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
763
742
  /**
764
- * Event triggered on the alert dismiss.
743
+ * Event triggered on the alert visibility change.
744
+ * @return boolean
765
745
  */
766
746
  visibleChange = output();
747
+ hide = signal(false, /* @ts-ignore */
748
+ ...(ngDevMode ? [{ debugName: "hide" }] : /* istanbul ignore next */ []));
749
+ #visibleEffect = effect(() => {
750
+ const visible = this.visible();
751
+ if (visible) {
752
+ this.hide.set(false);
753
+ }
754
+ }, /* @ts-ignore */
755
+ ...(ngDevMode ? [{ debugName: "#visibleEffect" }] : /* istanbul ignore next */ []));
756
+ #hideEffect = effect(() => {
757
+ const hide = this.hide();
758
+ this.visibleChange.emit(!hide);
759
+ }, /* @ts-ignore */
760
+ ...(ngDevMode ? [{ debugName: "#hideEffect" }] : /* istanbul ignore next */ []));
767
761
  contentTemplates = contentChildren(TemplateIdDirective, { ...(ngDevMode ? { debugName: "contentTemplates" } : /* istanbul ignore next */ {}), descendants: true });
768
762
  templates = computed(() => {
769
763
  return this.contentTemplates().reduce((acc, child) => {
@@ -772,72 +766,58 @@ class AlertComponent {
772
766
  }, {});
773
767
  }, /* @ts-ignore */
774
768
  ...(ngDevMode ? [{ debugName: "templates" }] : /* istanbul ignore next */ []));
775
- get animateType() {
776
- return this.visible ? 'show' : 'hide';
777
- }
778
769
  hostClasses = computed(() => {
779
770
  const color = this.color();
780
771
  const variant = this.variant();
772
+ const visible = this.visible();
781
773
  return {
782
774
  alert: true,
783
- 'alert-dismissible': this.dismissible,
775
+ 'alert-dismissible': this.dismissible(),
784
776
  fade: this.fade(),
785
- show: !this.hide(),
777
+ show: visible,
778
+ 'd-none': this.hide() && !visible,
786
779
  [`alert-${color}`]: !!color && variant !== 'solid',
787
780
  [`bg-${color}`]: !!color && variant === 'solid',
788
781
  'text-white': !!color && variant === 'solid'
789
782
  };
790
783
  }, /* @ts-ignore */
791
784
  ...(ngDevMode ? [{ debugName: "hostClasses" }] : /* istanbul ignore next */ []));
792
- onAnimationStart($event) {
793
- this.onAnimationEvent($event);
794
- }
795
- onAnimationDone($event) {
796
- this.onAnimationEvent($event);
797
- }
798
- onAnimationEvent(event) {
799
- this.hide.set(event.phaseName === 'start' && event.toState === 'show');
800
- if (event.phaseName === 'done') {
801
- this.hide.set(event.toState === 'hide' || event.toState === 'void');
802
- if (event.toState === 'show') {
785
+ onTransitionStart($event) {
786
+ if ($event.propertyName === 'opacity') {
787
+ if (this.visible()) {
803
788
  this.hide.set(false);
804
789
  }
805
790
  }
806
791
  }
792
+ onTransitionEnd($event) {
793
+ if ($event.propertyName === 'opacity') {
794
+ this.hide.set(!this.visible());
795
+ }
796
+ }
797
+ #leavingInProgress = false;
798
+ handleLeaving($event) {
799
+ if (this.#leavingInProgress)
800
+ return;
801
+ this.#leavingInProgress = true;
802
+ this.#hostElement.nativeElement.classList.remove('show');
803
+ setTimeout(() => {
804
+ $event.animationComplete();
805
+ }, this.#maxAnimationTimeout);
806
+ }
807
807
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AlertComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
808
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: AlertComponent, isStandalone: true, selector: "c-alert", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, dismissibleInput: { classPropertyName: "dismissibleInput", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, fade: { classPropertyName: "fade", publicName: "fade", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@fadeInOut.start": "onAnimationStart($event)", "@fadeInOut.done": "onAnimationDone($event)" }, properties: { "@.disabled": "!fade()", "@fadeInOut": "animateType", "attr.role": "role()", "class": "hostClasses()" } }, queries: [{ propertyName: "contentTemplates", predicate: TemplateIdDirective, descendants: true, isSignal: true }], exportAs: ["cAlert"], ngImport: i0, template: "@if (visible || !hide()) {\n @if (dismissible) {\n <ng-container *ngTemplateOutlet=\"templates()?.['alertButtonCloseTemplate'] || defaultAlertButtonCloseTemplate\" />\n }\n <ng-content />\n}\n<ng-template #defaultAlertButtonCloseTemplate>\n <button (click)=\"visible=false\" aria-label=\"Close\" cButtonClose></button>\n</ng-template>\n", styles: [":host{display:block;overflow:hidden}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ButtonCloseDirective, selector: "[cButtonClose]", inputs: ["white"] }], animations: [
809
- trigger('fadeInOut', [
810
- state('show', style({ opacity: 1, height: '*', padding: '*', border: '*', margin: '*' })),
811
- state('hide', style({ opacity: 0, height: 0, padding: 0, border: 0, margin: 0 })),
812
- state('void', style({ opacity: 0, height: 0, padding: 0, border: 0, margin: 0 })),
813
- transition('show => hide', [animate('.3s ease-out')]),
814
- transition('hide => show', [animate('.3s ease-in')]),
815
- transition('show => void', [animate('.3s ease-out')]),
816
- transition('void => show', [animate('.3s ease-in')])
817
- ])
818
- ] });
808
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: AlertComponent, isStandalone: true, selector: "c-alert", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, fade: { classPropertyName: "fade", publicName: "fade", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "animate.leave": "handleLeaving($event)", "transitionend": "onTransitionEnd($event)", "transitionstart": "onTransitionStart($event)" }, properties: { "attr.role": "role()", "class": "hostClasses()", "attr.hidden": "hide() ? \"\" : null" } }, providers: [{ provide: MAX_ANIMATION_TIMEOUT, useValue: 300 }], queries: [{ propertyName: "contentTemplates", predicate: TemplateIdDirective, descendants: true, isSignal: true }], exportAs: ["cAlert"], ngImport: i0, template: "@if (visible() || !hide()) {\n @if (dismissible()) {\n <ng-container *ngTemplateOutlet=\"templates()?.['alertButtonCloseTemplate'] || defaultAlertButtonCloseTemplate\" />\n }\n <ng-content />\n}\n<ng-template #defaultAlertButtonCloseTemplate>\n <button (click)=\"visible.set(false)\" aria-label=\"Close\" cButtonClose></button>\n</ng-template>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ButtonCloseDirective, selector: "[cButtonClose]", inputs: ["white"] }] });
819
809
  }
820
810
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AlertComponent, decorators: [{
821
811
  type: Component,
822
- args: [{ selector: 'c-alert', exportAs: 'cAlert', imports: [NgTemplateOutlet, ButtonCloseDirective], animations: [
823
- trigger('fadeInOut', [
824
- state('show', style({ opacity: 1, height: '*', padding: '*', border: '*', margin: '*' })),
825
- state('hide', style({ opacity: 0, height: 0, padding: 0, border: 0, margin: 0 })),
826
- state('void', style({ opacity: 0, height: 0, padding: 0, border: 0, margin: 0 })),
827
- transition('show => hide', [animate('.3s ease-out')]),
828
- transition('hide => show', [animate('.3s ease-in')]),
829
- transition('show => void', [animate('.3s ease-out')]),
830
- transition('void => show', [animate('.3s ease-in')])
831
- ])
832
- ], host: {
833
- '[@.disabled]': '!fade()',
834
- '[@fadeInOut]': 'animateType',
812
+ args: [{ selector: 'c-alert', exportAs: 'cAlert', imports: [NgTemplateOutlet, ButtonCloseDirective], host: {
835
813
  '[attr.role]': 'role()',
836
814
  '[class]': 'hostClasses()',
837
- '(@fadeInOut.start)': 'onAnimationStart($event)',
838
- '(@fadeInOut.done)': 'onAnimationDone($event)'
839
- }, template: "@if (visible || !hide()) {\n @if (dismissible) {\n <ng-container *ngTemplateOutlet=\"templates()?.['alertButtonCloseTemplate'] || defaultAlertButtonCloseTemplate\" />\n }\n <ng-content />\n}\n<ng-template #defaultAlertButtonCloseTemplate>\n <button (click)=\"visible=false\" aria-label=\"Close\" cButtonClose></button>\n</ng-template>\n", styles: [":host{display:block;overflow:hidden}\n"] }]
840
- }], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], dismissibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], fade: [{ type: i0.Input, args: [{ isSignal: true, alias: "fade", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }], contentTemplates: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => TemplateIdDirective), { ...{ descendants: true }, isSignal: true }] }] } });
815
+ '(animate.leave)': 'handleLeaving($event)',
816
+ '(transitionend)': 'onTransitionEnd($event)',
817
+ '(transitionstart)': 'onTransitionStart($event)',
818
+ '[attr.hidden]': 'hide() ? "" : null'
819
+ }, providers: [{ provide: MAX_ANIMATION_TIMEOUT, useValue: 300 }], template: "@if (visible() || !hide()) {\n @if (dismissible()) {\n <ng-container *ngTemplateOutlet=\"templates()?.['alertButtonCloseTemplate'] || defaultAlertButtonCloseTemplate\" />\n }\n <ng-content />\n}\n<ng-template #defaultAlertButtonCloseTemplate>\n <button (click)=\"visible.set(false)\" aria-label=\"Close\" cButtonClose></button>\n</ng-template>\n", styles: [":host{display:block}\n"] }]
820
+ }], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], fade: [{ type: i0.Input, args: [{ isSignal: true, alias: "fade", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }], contentTemplates: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => TemplateIdDirective), { ...{ descendants: true }, isSignal: true }] }] } });
841
821
 
842
822
  class AlertModule {
843
823
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: AlertModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });