@coreui/angular 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.
@@ -5882,6 +5882,14 @@ class OffcanvasComponent {
5882
5882
  */
5883
5883
  backdrop = input(true, /* @ts-ignore */
5884
5884
  ...(ngDevMode ? [{ debugName: "backdrop" }] : /* istanbul ignore next */ []));
5885
+ /**
5886
+ * Appends the offcanvas to a specific element. You can pass an HTML element or function that returns a single element. By default, `document.body`.
5887
+ * @since 5.7.21
5888
+ * @returns Element | (() => Element | null) | null
5889
+ * @default document.body
5890
+ */
5891
+ container = input(this.#document.body, /* @ts-ignore */
5892
+ ...(ngDevMode ? [{ debugName: "container" }] : /* istanbul ignore next */ []));
5885
5893
  /**
5886
5894
  * Closes the offcanvas when the escape key is pressed
5887
5895
  * @returns boolean
@@ -5895,6 +5903,13 @@ class OffcanvasComponent {
5895
5903
  */
5896
5904
  placement = input('start', /* @ts-ignore */
5897
5905
  ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
5906
+ /**
5907
+ * Generates offcanvas using a portal
5908
+ * @since 5.7.21
5909
+ * @returns boolean
5910
+ * @default false
5911
+ */
5912
+ portal = input(false, { ...(ngDevMode ? { debugName: "portal" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
5898
5913
  /**
5899
5914
  * Responsive offcanvas property hides content outside the viewport from a specified breakpoint and down.
5900
5915
  * @returns boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
@@ -5925,6 +5940,8 @@ class OffcanvasComponent {
5925
5940
  #activeBackdrop;
5926
5941
  #backdropClickSubscription;
5927
5942
  #layoutChangeSubscription;
5943
+ #hideFallbackId;
5944
+ #isShown = false;
5928
5945
  /**
5929
5946
  * Allow body scrolling while offcanvas is visible.
5930
5947
  * @returns boolean
@@ -5939,6 +5956,33 @@ class OffcanvasComponent {
5939
5956
  visibleInput = input(false, { ...(ngDevMode ? { debugName: "visibleInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'visible' });
5940
5957
  visible = linkedSignal({ ...(ngDevMode ? { debugName: "visible" } : /* istanbul ignore next */ {}), source: this.visibleInput,
5941
5958
  computation: (value) => value });
5959
+ domPortal = new DomPortal(this.#hostElement.nativeElement);
5960
+ domPortalOutlet;
5961
+ domPortalCleanup = () => {
5962
+ if (this.domPortalOutlet?.hasAttached()) {
5963
+ this.domPortalOutlet.detach();
5964
+ }
5965
+ };
5966
+ #portalEffect = effect(() => {
5967
+ const visible = this.visible();
5968
+ const containerInput = this.container();
5969
+ const portalEnabled = this.portal();
5970
+ untracked(() => {
5971
+ if (!visible) {
5972
+ return;
5973
+ }
5974
+ const container = typeof containerInput === 'function' ? containerInput() : containerInput;
5975
+ this.domPortalCleanup();
5976
+ if (container && portalEnabled) {
5977
+ this.domPortalOutlet = new DomPortalOutlet(container);
5978
+ this.domPortalOutlet.attach(this.domPortal);
5979
+ // Re-inserting the host drops its computed style, so the show classes applied later in
5980
+ // this same cycle would have no starting point to animate from. Force a reflow to commit it.
5981
+ void this.#hostElement.nativeElement.offsetHeight;
5982
+ }
5983
+ });
5984
+ }, /* @ts-ignore */
5985
+ ...(ngDevMode ? [{ debugName: "#portalEffect" }] : /* istanbul ignore next */ []));
5942
5986
  visibleEffect = effect(() => {
5943
5987
  const visible = this.visible();
5944
5988
  this.animateStart(visible);
@@ -5995,6 +6039,9 @@ class OffcanvasComponent {
5995
6039
  return breakpointValue ? `${parseFloat(breakpointValue.trim()) - 0.02}px` : false;
5996
6040
  }
5997
6041
  animateStart(visible = this.visible()) {
6042
+ const wasShown = this.#isShown;
6043
+ this.#isShown = visible;
6044
+ this.#clearHideFallback();
5998
6045
  if (visible) {
5999
6046
  if (!this.scroll()) {
6000
6047
  this.#backdropService.hideScrollbar();
@@ -6005,6 +6052,9 @@ class OffcanvasComponent {
6005
6052
  else {
6006
6053
  this.#renderer.removeClass(this.#hostElement.nativeElement, 'showing');
6007
6054
  this.#renderer.addClass(this.#hostElement.nativeElement, 'hiding');
6055
+ if (wasShown) {
6056
+ this.#scheduleHideFallback();
6057
+ }
6008
6058
  }
6009
6059
  }
6010
6060
  onKeyDownHandler(event) {
@@ -6023,6 +6073,8 @@ class OffcanvasComponent {
6023
6073
  ngOnDestroy() {
6024
6074
  this.#offcanvasService.toggle({ show: false, id: this.id() });
6025
6075
  this.#removeEventListeners();
6076
+ this.#clearHideFallback();
6077
+ this.domPortalCleanup();
6026
6078
  }
6027
6079
  #removeEventListeners = () => {
6028
6080
  this.#hostElement.nativeElement.removeEventListener('transitionend', this.#handleTransitionEnd);
@@ -6034,12 +6086,30 @@ class OffcanvasComponent {
6034
6086
  this.#renderer.removeClass(offcanvasElement, 'showing');
6035
6087
  }
6036
6088
  else {
6037
- this.#renderer.removeClass(offcanvasElement, 'hiding');
6038
- this.#renderer.removeStyle(this.#document.body, 'overflow');
6039
- this.#renderer.removeStyle(this.#document.body, 'paddingRight');
6089
+ this.#completeHide();
6040
6090
  }
6041
6091
  }
6042
6092
  };
6093
+ #completeHide() {
6094
+ this.#clearHideFallback();
6095
+ this.#renderer.removeClass(this.#hostElement.nativeElement, 'hiding');
6096
+ this.#renderer.removeStyle(this.#document.body, 'overflow');
6097
+ this.#renderer.removeStyle(this.#document.body, 'paddingRight');
6098
+ this.domPortalCleanup();
6099
+ }
6100
+ // `transitionend` never fires when there is nothing to animate — reduced motion, or a responsive
6101
+ // offcanvas above its breakpoint — which would leave the body scroll-locked and the host parked
6102
+ // in the portal container.
6103
+ #scheduleHideFallback() {
6104
+ const style = this.#document.defaultView?.getComputedStyle(this.#hostElement.nativeElement);
6105
+ const duration = Number.parseFloat(style?.transitionDuration ?? '') || 0;
6106
+ const delay = Number.parseFloat(style?.transitionDelay ?? '') || 0;
6107
+ this.#hideFallbackId = setTimeout(() => this.#completeHide(), (duration + delay) * 1000 + 5);
6108
+ }
6109
+ #clearHideFallback() {
6110
+ clearTimeout(this.#hideFallbackId);
6111
+ this.#hideFallbackId = undefined;
6112
+ }
6043
6113
  setFocus() {
6044
6114
  if (isPlatformBrowser(this.#platformId)) {
6045
6115
  setTimeout(() => this.#hostElement.nativeElement.focus());
@@ -6090,12 +6160,11 @@ class OffcanvasComponent {
6090
6160
  }
6091
6161
  }
6092
6162
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
6093
- 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$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
6163
+ 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$1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
6094
6164
  }
6095
6165
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasComponent, decorators: [{
6096
6166
  type: Component,
6097
6167
  args: [{ selector: 'c-offcanvas', exportAs: 'cOffcanvas', imports: [A11yModule], hostDirectives: [{ directive: ThemeDirective, inputs: ['dark'] }], host: {
6098
- ngSkipHydration: 'true',
6099
6168
  '[attr.id]': 'id()',
6100
6169
  '[attr.inert]': 'ariaHidden() || null',
6101
6170
  '[attr.role]': 'role()',
@@ -6104,7 +6173,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
6104
6173
  '[class]': 'hostClasses()',
6105
6174
  '(document:keydown)': 'onKeyDownHandler($event)'
6106
6175
  }, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content />\n</div>\n\n", styles: [":host{display:none}\n"] }]
6107
- }], 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"] }] } });
6176
+ }], 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"] }] } });
6108
6177
 
6109
6178
  class OffcanvasBodyComponent {
6110
6179
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OffcanvasBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });