@coreui/angular-pro 5.7.20 → 5.7.21

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.
@@ -13751,6 +13751,14 @@ class OffcanvasComponent {
13751
13751
  */
13752
13752
  backdrop = input(true, /* @ts-ignore */
13753
13753
  ...(ngDevMode ? [{ debugName: "backdrop" }] : /* istanbul ignore next */ []));
13754
+ /**
13755
+ * Appends the offcanvas to a specific element. You can pass an HTML element or function that returns a single element. By default, `document.body`.
13756
+ * @since 5.7.21
13757
+ * @returns Element | (() => Element | null) | null
13758
+ * @default document.body
13759
+ */
13760
+ container = input(this.#document.body, /* @ts-ignore */
13761
+ ...(ngDevMode ? [{ debugName: "container" }] : /* istanbul ignore next */ []));
13754
13762
  /**
13755
13763
  * Closes the offcanvas when the escape key is pressed
13756
13764
  * @returns boolean
@@ -13764,6 +13772,13 @@ class OffcanvasComponent {
13764
13772
  */
13765
13773
  placement = input('start', /* @ts-ignore */
13766
13774
  ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
13775
+ /**
13776
+ * Generates offcanvas using a portal
13777
+ * @since 5.7.21
13778
+ * @returns boolean
13779
+ * @default false
13780
+ */
13781
+ portal = input(false, { ...(ngDevMode ? { debugName: "portal" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
13767
13782
  /**
13768
13783
  * Responsive offcanvas property hides content outside the viewport from a specified breakpoint and down.
13769
13784
  * @returns boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
@@ -13794,6 +13809,8 @@ class OffcanvasComponent {
13794
13809
  #activeBackdrop;
13795
13810
  #backdropClickSubscription;
13796
13811
  #layoutChangeSubscription;
13812
+ #hideFallbackId;
13813
+ #isShown = false;
13797
13814
  /**
13798
13815
  * Allow body scrolling while offcanvas is visible.
13799
13816
  * @returns boolean
@@ -13808,6 +13825,33 @@ class OffcanvasComponent {
13808
13825
  visibleInput = input(false, { ...(ngDevMode ? { debugName: "visibleInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'visible' });
13809
13826
  visible = linkedSignal({ ...(ngDevMode ? { debugName: "visible" } : /* istanbul ignore next */ {}), source: this.visibleInput,
13810
13827
  computation: (value) => value });
13828
+ domPortal = new DomPortal(this.#hostElement.nativeElement);
13829
+ domPortalOutlet;
13830
+ domPortalCleanup = () => {
13831
+ if (this.domPortalOutlet?.hasAttached()) {
13832
+ this.domPortalOutlet.detach();
13833
+ }
13834
+ };
13835
+ #portalEffect = effect(() => {
13836
+ const visible = this.visible();
13837
+ const containerInput = this.container();
13838
+ const portalEnabled = this.portal();
13839
+ untracked(() => {
13840
+ if (!visible) {
13841
+ return;
13842
+ }
13843
+ const container = typeof containerInput === 'function' ? containerInput() : containerInput;
13844
+ this.domPortalCleanup();
13845
+ if (container && portalEnabled) {
13846
+ this.domPortalOutlet = new DomPortalOutlet(container);
13847
+ this.domPortalOutlet.attach(this.domPortal);
13848
+ // Re-inserting the host drops its computed style, so the show classes applied later in
13849
+ // this same cycle would have no starting point to animate from. Force a reflow to commit it.
13850
+ void this.#hostElement.nativeElement.offsetHeight;
13851
+ }
13852
+ });
13853
+ }, /* @ts-ignore */
13854
+ ...(ngDevMode ? [{ debugName: "#portalEffect" }] : /* istanbul ignore next */ []));
13811
13855
  visibleEffect = effect(() => {
13812
13856
  const visible = this.visible();
13813
13857
  this.animateStart(visible);
@@ -13864,6 +13908,9 @@ class OffcanvasComponent {
13864
13908
  return breakpointValue ? `${parseFloat(breakpointValue.trim()) - 0.02}px` : false;
13865
13909
  }
13866
13910
  animateStart(visible = this.visible()) {
13911
+ const wasShown = this.#isShown;
13912
+ this.#isShown = visible;
13913
+ this.#clearHideFallback();
13867
13914
  if (visible) {
13868
13915
  if (!this.scroll()) {
13869
13916
  this.#backdropService.hideScrollbar();
@@ -13874,6 +13921,9 @@ class OffcanvasComponent {
13874
13921
  else {
13875
13922
  this.#renderer.removeClass(this.#hostElement.nativeElement, 'showing');
13876
13923
  this.#renderer.addClass(this.#hostElement.nativeElement, 'hiding');
13924
+ if (wasShown) {
13925
+ this.#scheduleHideFallback();
13926
+ }
13877
13927
  }
13878
13928
  }
13879
13929
  onKeyDownHandler(event) {
@@ -13892,6 +13942,8 @@ class OffcanvasComponent {
13892
13942
  ngOnDestroy() {
13893
13943
  this.#offcanvasService.toggle({ show: false, id: this.id() });
13894
13944
  this.#removeEventListeners();
13945
+ this.#clearHideFallback();
13946
+ this.domPortalCleanup();
13895
13947
  }
13896
13948
  #removeEventListeners = () => {
13897
13949
  this.#hostElement.nativeElement.removeEventListener('transitionend', this.#handleTransitionEnd);
@@ -13903,12 +13955,30 @@ class OffcanvasComponent {
13903
13955
  this.#renderer.removeClass(offcanvasElement, 'showing');
13904
13956
  }
13905
13957
  else {
13906
- this.#renderer.removeClass(offcanvasElement, 'hiding');
13907
- this.#renderer.removeStyle(this.#document.body, 'overflow');
13908
- this.#renderer.removeStyle(this.#document.body, 'paddingRight');
13958
+ this.#completeHide();
13909
13959
  }
13910
13960
  }
13911
13961
  };
13962
+ #completeHide() {
13963
+ this.#clearHideFallback();
13964
+ this.#renderer.removeClass(this.#hostElement.nativeElement, 'hiding');
13965
+ this.#renderer.removeStyle(this.#document.body, 'overflow');
13966
+ this.#renderer.removeStyle(this.#document.body, 'paddingRight');
13967
+ this.domPortalCleanup();
13968
+ }
13969
+ // `transitionend` never fires when there is nothing to animate — reduced motion, or a responsive
13970
+ // offcanvas above its breakpoint — which would leave the body scroll-locked and the host parked
13971
+ // in the portal container.
13972
+ #scheduleHideFallback() {
13973
+ const style = this.#document.defaultView?.getComputedStyle(this.#hostElement.nativeElement);
13974
+ const duration = Number.parseFloat(style?.transitionDuration ?? '') || 0;
13975
+ const delay = Number.parseFloat(style?.transitionDelay ?? '') || 0;
13976
+ this.#hideFallbackId = setTimeout(() => this.#completeHide(), (duration + delay) * 1000 + 5);
13977
+ }
13978
+ #clearHideFallback() {
13979
+ clearTimeout(this.#hideFallbackId);
13980
+ this.#hideFallbackId = undefined;
13981
+ }
13912
13982
  setFocus() {
13913
13983
  if (isPlatformBrowser(this.#platformId)) {
13914
13984
  setTimeout(() => this.#hostElement.nativeElement.focus());
@@ -13959,12 +14029,11 @@ class OffcanvasComponent {
13959
14029
  }
13960
14030
  }
13961
14031
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
13962
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.3", type: OffcanvasComponent, isStandalone: true, selector: "c-offcanvas", inputs: { backdrop: { classPropertyName: "backdrop", publicName: "backdrop", isSignal: true, isRequired: false, transformFunction: null }, keyboard: { classPropertyName: "keyboard", publicName: "keyboard", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, responsive: { classPropertyName: "responsive", publicName: "responsive", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, ariaModal: { classPropertyName: "ariaModal", publicName: "ariaModal", isSignal: true, isRequired: false, transformFunction: null }, scroll: { classPropertyName: "scroll", publicName: "scroll", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { attributes: { "ngSkipHydration": "true" }, listeners: { "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.id": "id()", "attr.inert": "ariaHidden() || null", "attr.role": "role()", "attr.aria-modal": "ariaModal()", "attr.tabindex": "tabIndex", "class": "hostClasses()" } }, exportAs: ["cOffcanvas"], hostDirectives: [{ directive: ThemeDirective, inputs: ["dark", "dark"] }], ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content />\n</div>\n\n", styles: [":host{display:none}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1$2.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
14032
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.3", type: OffcanvasComponent, isStandalone: true, selector: "c-offcanvas", inputs: { backdrop: { classPropertyName: "backdrop", publicName: "backdrop", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "container", isSignal: true, isRequired: false, transformFunction: null }, keyboard: { classPropertyName: "keyboard", publicName: "keyboard", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, portal: { classPropertyName: "portal", publicName: "portal", isSignal: true, isRequired: false, transformFunction: null }, responsive: { classPropertyName: "responsive", publicName: "responsive", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, ariaModal: { classPropertyName: "ariaModal", publicName: "ariaModal", isSignal: true, isRequired: false, transformFunction: null }, scroll: { classPropertyName: "scroll", publicName: "scroll", isSignal: true, isRequired: false, transformFunction: null }, visibleInput: { classPropertyName: "visibleInput", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.id": "id()", "attr.inert": "ariaHidden() || null", "attr.role": "role()", "attr.aria-modal": "ariaModal()", "attr.tabindex": "tabIndex", "class": "hostClasses()" } }, exportAs: ["cOffcanvas"], hostDirectives: [{ directive: ThemeDirective, inputs: ["dark", "dark"] }], ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content />\n</div>\n\n", styles: [":host{display:none}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1$2.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
13963
14033
  }
13964
14034
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasComponent, decorators: [{
13965
14035
  type: Component,
13966
14036
  args: [{ selector: 'c-offcanvas', exportAs: 'cOffcanvas', imports: [A11yModule], hostDirectives: [{ directive: ThemeDirective, inputs: ['dark'] }], host: {
13967
- ngSkipHydration: 'true',
13968
14037
  '[attr.id]': 'id()',
13969
14038
  '[attr.inert]': 'ariaHidden() || null',
13970
14039
  '[attr.role]': 'role()',
@@ -13973,7 +14042,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
13973
14042
  '[class]': 'hostClasses()',
13974
14043
  '(document:keydown)': 'onKeyDownHandler($event)'
13975
14044
  }, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content />\n</div>\n\n", styles: [":host{display:none}\n"] }]
13976
- }], propDecorators: { backdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdrop", required: false }] }], keyboard: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboard", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], responsive: [{ type: i0.Input, args: [{ isSignal: true, alias: "responsive", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], ariaModal: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaModal", required: false }] }], scroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "scroll", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }] } });
14045
+ }], propDecorators: { backdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdrop", required: false }] }], container: [{ type: i0.Input, args: [{ isSignal: true, alias: "container", required: false }] }], keyboard: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboard", required: false }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], portal: [{ type: i0.Input, args: [{ isSignal: true, alias: "portal", required: false }] }], responsive: [{ type: i0.Input, args: [{ isSignal: true, alias: "responsive", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], ariaModal: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaModal", required: false }] }], scroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "scroll", required: false }] }], visibleInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], visibleChange: [{ type: i0.Output, args: ["visibleChange"] }] } });
13977
14046
 
13978
14047
  class OffcanvasBodyComponent {
13979
14048
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });