@coreui/angular 5.7.19 → 5.7.20

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.
@@ -10,6 +10,7 @@ import { createPopper } from '@popperjs/core';
10
10
  import * as i1$1 from '@angular/cdk/a11y';
11
11
  import { FocusKeyManager, FocusMonitor, A11yModule } from '@angular/cdk/a11y';
12
12
  import { BreakpointObserver } from '@angular/cdk/layout';
13
+ import { DomPortal, DomPortalOutlet } from '@angular/cdk/portal';
13
14
  import { trigger, state, style, transition, animate } from '@angular/animations';
14
15
  import { IconDirective } from '@coreui/icons-angular';
15
16
 
@@ -5493,6 +5494,14 @@ class ModalComponent {
5493
5494
  */
5494
5495
  backdrop = input(true, /* @ts-ignore */
5495
5496
  ...(ngDevMode ? [{ debugName: "backdrop" }] : /* istanbul ignore next */ []));
5497
+ /**
5498
+ * Appends the angular modal to a specific element. You can pass an HTML element or function that returns a single element. By default, `document.body`.
5499
+ * @since 5.7.20
5500
+ * @returns Element | (() => Element | null) | null
5501
+ * @default document.body
5502
+ */
5503
+ container = input(this.#document.body, /* @ts-ignore */
5504
+ ...(ngDevMode ? [{ debugName: "container" }] : /* istanbul ignore next */ []));
5496
5505
  /**
5497
5506
  * Set modal to cover the entire user viewport.
5498
5507
  * @returns {boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'}
@@ -5507,13 +5516,20 @@ class ModalComponent {
5507
5516
  */
5508
5517
  keyboard = input(true, { ...(ngDevMode ? { debugName: "keyboard" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
5509
5518
  /**
5510
- * Html id attribute, required for programmatic visibility change.
5519
+ * HTML id attribute, required for programmatic visibility change.
5511
5520
  * @returns string
5512
5521
  */
5513
5522
  attrId = input(undefined, { ...(ngDevMode ? { debugName: "attrId" } : /* istanbul ignore next */ {}), alias: 'id' });
5514
5523
  get id() {
5515
5524
  return this.attrId();
5516
5525
  }
5526
+ /**
5527
+ * Generates modal using a portal
5528
+ * @since 5.7.20
5529
+ * @returns boolean
5530
+ * @default false
5531
+ */
5532
+ portal = input(false, { ...(ngDevMode ? { debugName: "portal" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
5517
5533
  /**
5518
5534
  * Size the component small, large, or extra large.
5519
5535
  * @returns {'sm' | 'lg' | 'xl'}
@@ -5556,6 +5572,30 @@ class ModalComponent {
5556
5572
  visibleInput = input(false, { ...(ngDevMode ? { debugName: "visibleInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'visible' });
5557
5573
  visible = linkedSignal(this.visibleInput, /* @ts-ignore */
5558
5574
  ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
5575
+ domPortal = new DomPortal(this.#hostElement.nativeElement);
5576
+ domPortalOutlet;
5577
+ domPortalCleanup = () => {
5578
+ if (this.domPortalOutlet?.hasAttached()) {
5579
+ this.domPortalOutlet.detach();
5580
+ }
5581
+ };
5582
+ #portalEffect = effect(() => {
5583
+ const visible = this.visible();
5584
+ const containerInput = this.container();
5585
+ const portalEnabled = this.portal();
5586
+ untracked(() => {
5587
+ if (!visible) {
5588
+ return;
5589
+ }
5590
+ const container = typeof containerInput === 'function' ? containerInput() : containerInput;
5591
+ this.domPortalCleanup();
5592
+ if (container && portalEnabled) {
5593
+ this.domPortalOutlet = new DomPortalOutlet(container);
5594
+ this.domPortalOutlet.attach(this.domPortal);
5595
+ }
5596
+ });
5597
+ }, /* @ts-ignore */
5598
+ ...(ngDevMode ? [{ debugName: "#portalEffect" }] : /* istanbul ignore next */ []));
5559
5599
  #visibleInputEffect = effect(() => {
5560
5600
  const visible = this.visible();
5561
5601
  untracked(() => {
@@ -5600,9 +5640,6 @@ class ModalComponent {
5600
5640
  * @returns boolean
5601
5641
  */
5602
5642
  visibleChange = output();
5603
- // @ViewChild(ModalContentComponent, { read: ElementRef }) modalContent!: ElementRef;
5604
- // @ViewChild('modalContentRef', { read: ElementRef }) modalContentRef!: ElementRef;
5605
- // readonly modalContentRef = viewChild(ModalContentComponent, { read: ElementRef });
5606
5643
  modalContentRef = viewChild('modalContentRef', { ...(ngDevMode ? { debugName: "modalContentRef" } : /* istanbul ignore next */ {}), read: ElementRef });
5607
5644
  modalDialogRef = viewChild.required(ModalDialogComponent, { ...(ngDevMode ? { debugName: "modalDialogRef" } : /* istanbul ignore next */ {}), read: ElementRef });
5608
5645
  #modalDialogEffect = effect((OnCleanup) => {
@@ -5618,6 +5655,7 @@ class ModalComponent {
5618
5655
  const modalDialogElement = this.modalDialogRef().nativeElement;
5619
5656
  if (event.target === modalDialogElement && event.propertyName === 'transform') {
5620
5657
  if (!this.visible()) {
5658
+ this.domPortalCleanup();
5621
5659
  this.#renderer.setStyle(this.#hostElement.nativeElement, 'display', 'none');
5622
5660
  }
5623
5661
  }
@@ -5651,6 +5689,7 @@ class ModalComponent {
5651
5689
  }
5652
5690
  else {
5653
5691
  if (!this.transition()) {
5692
+ this.domPortalCleanup();
5654
5693
  this.#renderer.setStyle(this.#hostElement.nativeElement, 'display', 'none');
5655
5694
  }
5656
5695
  }
@@ -5698,6 +5737,7 @@ class ModalComponent {
5698
5737
  this.#modalService.toggle({ show: false, modal: this });
5699
5738
  this.#afterViewInit.set(false);
5700
5739
  this.setBackdrop(false);
5740
+ this.domPortalCleanup();
5701
5741
  }
5702
5742
  stateToggleSubscribe() {
5703
5743
  this.#modalService.modalState$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((action) => {
@@ -5739,7 +5779,7 @@ class ModalComponent {
5739
5779
  }
5740
5780
  }
5741
5781
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
5742
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.3", type: ModalComponent, isStandalone: true, selector: "c-modal", inputs: { alignment: { classPropertyName: "alignment", publicName: "alignment", isSignal: true, isRequired: false, transformFunction: null }, backdrop: { classPropertyName: "backdrop", publicName: "backdrop", isSignal: true, isRequired: false, transformFunction: null }, fullscreen: { classPropertyName: "fullscreen", publicName: "fullscreen", isSignal: true, isRequired: false, transformFunction: null }, keyboard: { classPropertyName: "keyboard", publicName: "keyboard", isSignal: true, isRequired: false, transformFunction: null }, attrId: { classPropertyName: "attrId", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, transition: { classPropertyName: "transition", publicName: "transition", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, ariaModalInput: { classPropertyName: "ariaModalInput", publicName: "ariaModal", isSignal: true, isRequired: false, transformFunction: null }, scrollable: { classPropertyName: "scrollable", publicName: "scrollable", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "mousedown": "onMouseDownHandler($event)", "click": "onClickHandler($event)", "document:keydown": "onKeyDownHandler($event)" }, properties: { "class": "hostClasses()", "attr.role": "visible() ? role() : null", "attr.inert": "ariaHidden()", "attr.id": "id", "attr.aria-modal": "ariaModal()", "attr.aria-hidden": "ariaHidden()", "attr.tabindex": "-1" }, classAttribute: "modal" }, viewQueries: [{ propertyName: "modalContentRef", first: true, predicate: ["modalContentRef"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "modalDialogRef", first: true, predicate: ModalDialogComponent, descendants: true, read: ElementRef, isSignal: true }], exportAs: ["cModal"], ngImport: i0, template: "@let isVisible = visible();\n<c-modal-dialog\n [alignment]=\"alignment()\"\n [fullscreen]=\"fullscreen()\"\n [scrollable]=\"scrollable()\"\n [size]=\"size()\">\n <c-modal-content>\n <div #modalContentRef [cdkTrapFocusAutoCapture]=\"isVisible\" [cdkTrapFocus]=\"isVisible\" style=\"display: contents;\">\n <ng-content />\n </div>\n </c-modal-content>\n</c-modal-dialog>\n", dependencies: [{ kind: "component", type: ModalDialogComponent, selector: "c-modal-dialog", inputs: ["alignment", "fullscreen", "scrollable", "size"] }, { kind: "component", type: ModalContentComponent, selector: "c-modal-content" }, { kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
5782
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.1.3", type: ModalComponent, isStandalone: true, selector: "c-modal", inputs: { alignment: { classPropertyName: "alignment", publicName: "alignment", isSignal: true, isRequired: false, transformFunction: null }, backdrop: { classPropertyName: "backdrop", publicName: "backdrop", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null }, fullscreen: { classPropertyName: "fullscreen", publicName: "fullscreen", isSignal: true, isRequired: false, transformFunction: null }, keyboard: { classPropertyName: "keyboard", publicName: "keyboard", isSignal: true, isRequired: false, transformFunction: null }, attrId: { classPropertyName: "attrId", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, portal: { classPropertyName: "portal", publicName: "portal", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, transition: { classPropertyName: "transition", publicName: "transition", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, ariaModalInput: { classPropertyName: "ariaModalInput", publicName: "ariaModal", isSignal: true, isRequired: false, transformFunction: null }, scrollable: { classPropertyName: "scrollable", publicName: "scrollable", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "mousedown": "onMouseDownHandler($event)", "click": "onClickHandler($event)", "document:keydown": "onKeyDownHandler($event)" }, properties: { "class": "hostClasses()", "attr.role": "visible() ? role() : null", "attr.inert": "ariaHidden()", "attr.id": "id", "attr.aria-modal": "ariaModal()", "attr.aria-hidden": "ariaHidden()", "attr.tabindex": "-1" }, classAttribute: "modal" }, viewQueries: [{ propertyName: "modalContentRef", first: true, predicate: ["modalContentRef"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "modalDialogRef", first: true, predicate: ModalDialogComponent, descendants: true, read: ElementRef, isSignal: true }], exportAs: ["cModal"], ngImport: i0, template: "@let isVisible = visible();\n<c-modal-dialog\n [alignment]=\"alignment()\"\n [fullscreen]=\"fullscreen()\"\n [scrollable]=\"scrollable()\"\n [size]=\"size()\">\n <c-modal-content>\n <div #modalContentRef [cdkTrapFocusAutoCapture]=\"isVisible\" [cdkTrapFocus]=\"isVisible\" style=\"display: contents;\">\n <ng-content />\n </div>\n </c-modal-content>\n</c-modal-dialog>\n", dependencies: [{ kind: "component", type: ModalDialogComponent, selector: "c-modal-dialog", inputs: ["alignment", "fullscreen", "scrollable", "size"] }, { kind: "component", type: ModalContentComponent, selector: "c-modal-content" }, { kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
5743
5783
  }
5744
5784
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ModalComponent, decorators: [{
5745
5785
  type: Component,
@@ -5756,7 +5796,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
5756
5796
  '(click)': 'onClickHandler($event)',
5757
5797
  '(document:keydown)': 'onKeyDownHandler($event)'
5758
5798
  }, template: "@let isVisible = visible();\n<c-modal-dialog\n [alignment]=\"alignment()\"\n [fullscreen]=\"fullscreen()\"\n [scrollable]=\"scrollable()\"\n [size]=\"size()\">\n <c-modal-content>\n <div #modalContentRef [cdkTrapFocusAutoCapture]=\"isVisible\" [cdkTrapFocus]=\"isVisible\" style=\"display: contents;\">\n <ng-content />\n </div>\n </c-modal-content>\n</c-modal-dialog>\n" }]
5759
- }], propDecorators: { alignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignment", required: false }] }], backdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdrop", required: false }] }], fullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "fullscreen", required: false }] }], keyboard: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboard", required: false }] }], attrId: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], transition: [{ type: i0.Input, args: [{ isSignal: true, alias: "transition", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], ariaModalInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaModal", required: false }] }], scrollable: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollable", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }], modalContentRef: [{ type: i0.ViewChild, args: ['modalContentRef', { ...{ read: ElementRef }, isSignal: true }] }], modalDialogRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ModalDialogComponent), { ...{ read: ElementRef }, isSignal: true }] }] } });
5799
+ }], propDecorators: { alignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "alignment", required: false }] }], backdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdrop", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }], fullscreen: [{ type: i0.Input, args: [{ isSignal: true, alias: "fullscreen", required: false }] }], keyboard: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboard", required: false }] }], attrId: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], portal: [{ type: i0.Input, args: [{ isSignal: true, alias: "portal", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], transition: [{ type: i0.Input, args: [{ isSignal: true, alias: "transition", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], ariaModalInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaModal", required: false }] }], scrollable: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollable", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }], modalContentRef: [{ type: i0.ViewChild, args: ['modalContentRef', { ...{ read: ElementRef }, isSignal: true }] }], modalDialogRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => ModalDialogComponent), { ...{ read: ElementRef }, isSignal: true }] }] } });
5760
5800
 
5761
5801
  class ModalModule {
5762
5802
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: ModalModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });