@coreui/angular 4.5.28 → 4.5.29

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,19 +1,19 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input, NgModule, HostBinding, Injectable, Component, EventEmitter, Output, booleanAttribute, ContentChildren, HostListener, Inject, ViewChild, forwardRef, Optional, ElementRef, ContentChild, PLATFORM_ID, TemplateRef, ViewContainerRef, numberAttribute, Pipe, ChangeDetectionStrategy, inject, DestroyRef } from '@angular/core';
2
+ import { Directive, Input, NgModule, HostBinding, Injectable, Component, EventEmitter, Output, booleanAttribute, ContentChildren, HostListener, inject, RendererFactory2, Inject, ViewChild, forwardRef, Optional, ElementRef, ContentChild, DestroyRef, signal, effect, PLATFORM_ID, TemplateRef, ViewContainerRef, numberAttribute, Pipe, ChangeDetectionStrategy } from '@angular/core';
3
3
  import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
4
4
  import * as i3$1 from '@angular/common';
5
- import { NgTemplateOutlet, NgIf, NgClass, NgForOf, AsyncPipe, DOCUMENT, isPlatformBrowser, CommonModule, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault } from '@angular/common';
5
+ import { NgTemplateOutlet, NgIf, NgClass, DOCUMENT, NgForOf, AsyncPipe, isPlatformBrowser, CommonModule, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault } from '@angular/common';
6
6
  import * as i1 from '@angular/animations';
7
7
  import { animation, animate, style, useAnimation, trigger, state, transition, group, query } from '@angular/animations';
8
+ import { Subject, BehaviorSubject, Observable, fromEvent, zipWith, withLatestFrom } from 'rxjs';
8
9
  import * as i1$1 from '@angular/router';
9
10
  import { RouterModule, NavigationEnd, RouterLink } from '@angular/router';
10
- import { BehaviorSubject, Observable, fromEvent, zipWith, withLatestFrom, Subject } from 'rxjs';
11
11
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
12
12
  import { filter, debounceTime } from 'rxjs/operators';
13
13
  import { createPopper } from '@popperjs/core';
14
14
  import * as i1$2 from '@angular/cdk/layout';
15
15
  import * as i3 from '@angular/cdk/a11y';
16
- import { A11yModule } from '@angular/cdk/a11y';
16
+ import { FocusMonitor, A11yModule } from '@angular/cdk/a11y';
17
17
  import { IconDirective } from '@coreui/icons-angular';
18
18
 
19
19
  var BreakpointInfix;
@@ -1065,6 +1065,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1065
1065
  }]
1066
1066
  }] });
1067
1067
 
1068
+ class BackdropService {
1069
+ constructor() {
1070
+ this.#backdropClick = new Subject();
1071
+ this.backdropClick$ = this.#backdropClick.asObservable();
1072
+ this.#document = inject(DOCUMENT);
1073
+ this.#rendererFactory = inject(RendererFactory2);
1074
+ this.#renderer = this.#rendererFactory.createRenderer(null, null);
1075
+ this.scrollbarWidth = this.#scrollbarWidth;
1076
+ this.#scrollBarVisible = true;
1077
+ }
1078
+ #backdropClick;
1079
+ #document;
1080
+ #rendererFactory;
1081
+ #renderer;
1082
+ #unListen;
1083
+ get #scrollbarWidth() {
1084
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
1085
+ const documentWidth = this.#document.documentElement.clientWidth;
1086
+ const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
1087
+ return `${scrollbarWidth}px`;
1088
+ }
1089
+ setBackdrop(type = 'modal') {
1090
+ const backdropElement = this.#renderer.createElement('div');
1091
+ this.#renderer.addClass(backdropElement, `${type}-backdrop`);
1092
+ this.#renderer.addClass(backdropElement, 'fade');
1093
+ this.#renderer.appendChild(this.#document.body, backdropElement);
1094
+ this.#unListen = this.#renderer.listen(backdropElement, 'click', (e) => {
1095
+ this.onClickHandler();
1096
+ });
1097
+ this.scrollbarWidth = this.#scrollbarWidth;
1098
+ setTimeout(() => {
1099
+ this.#renderer.addClass(backdropElement, 'show');
1100
+ // this.hideScrollbar();
1101
+ });
1102
+ this.activeBackdrop = backdropElement;
1103
+ return backdropElement;
1104
+ }
1105
+ clearBackdrop(backdropElement) {
1106
+ if (backdropElement) {
1107
+ this.#unListen();
1108
+ this.#renderer.removeClass(backdropElement, 'show');
1109
+ setTimeout(() => {
1110
+ this.#renderer.removeChild(this.#document.body, backdropElement);
1111
+ if (this.activeBackdrop === backdropElement) {
1112
+ this.resetScrollbar();
1113
+ }
1114
+ backdropElement = undefined;
1115
+ }, 300);
1116
+ }
1117
+ return undefined;
1118
+ }
1119
+ get #isRTL() { return this.#document.documentElement.dir === 'rtl' || this.#document.body.dir === 'rtl'; }
1120
+ #scrollBarVisible;
1121
+ hideScrollbar() {
1122
+ if (this.#scrollBarVisible) {
1123
+ this.#renderer.setStyle(this.#document.body, 'overflow', 'hidden');
1124
+ this.#renderer.setStyle(this.#document.body, `padding-${this.#isRTL ? 'left' : 'right'}`, this.scrollbarWidth);
1125
+ this.#scrollBarVisible = false;
1126
+ }
1127
+ }
1128
+ resetScrollbar() {
1129
+ this.#renderer.removeStyle(this.#document.body, 'overflow');
1130
+ this.#renderer.removeStyle(this.#document.body, `padding-${this.#isRTL ? 'left' : 'right'}`);
1131
+ this.#scrollBarVisible = true;
1132
+ }
1133
+ onClickHandler() {
1134
+ this.#backdropClick.next(true);
1135
+ }
1136
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1137
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, providedIn: 'root' }); }
1138
+ }
1139
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, decorators: [{
1140
+ type: Injectable,
1141
+ args: [{
1142
+ providedIn: 'root'
1143
+ }]
1144
+ }] });
1145
+
1068
1146
  class BreadcrumbItemComponent {
1069
1147
  get ariaCurrent() {
1070
1148
  return this.active ? 'page' : null;
@@ -5034,67 +5112,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5034
5112
  args: ['class']
5035
5113
  }] } });
5036
5114
 
5037
- class BackdropService {
5038
- constructor(document, rendererFactory) {
5039
- this.document = document;
5040
- this.rendererFactory = rendererFactory;
5041
- this.backdropClick = new Subject();
5042
- this.backdropClick$ = this.backdropClick.asObservable();
5043
- this.renderer = rendererFactory.createRenderer(null, null);
5044
- }
5045
- get scrollbarWidth() {
5046
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
5047
- const documentWidth = this.document.documentElement.clientWidth;
5048
- const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
5049
- return `${scrollbarWidth}px`;
5050
- }
5051
- setBackdrop(type = 'modal') {
5052
- const backdropElement = this.renderer.createElement('div');
5053
- this.renderer.addClass(backdropElement, `${type}-backdrop`);
5054
- this.renderer.addClass(backdropElement, 'fade');
5055
- this.renderer.appendChild(this.document.body, backdropElement);
5056
- this.unListen = this.renderer.listen(backdropElement, 'click', (e) => {
5057
- this.onClickHandler();
5058
- });
5059
- setTimeout(() => {
5060
- this.renderer.addClass(backdropElement, 'show');
5061
- });
5062
- return backdropElement;
5063
- }
5064
- clearBackdrop(backdrop) {
5065
- if (backdrop) {
5066
- this.unListen();
5067
- this.renderer.removeClass(backdrop, 'show');
5068
- setTimeout(() => {
5069
- this.renderer.removeChild(this.document.body, backdrop);
5070
- backdrop = undefined;
5071
- }, 300);
5072
- }
5073
- return backdrop;
5074
- }
5075
- onClickHandler() {
5076
- this.backdropClick.next(true);
5077
- }
5078
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, deps: [{ token: DOCUMENT }, { token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable }); }
5079
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, providedIn: 'root' }); }
5080
- }
5081
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BackdropService, decorators: [{
5082
- type: Injectable,
5083
- args: [{
5084
- providedIn: 'root'
5085
- }]
5086
- }], ctorParameters: function () { return [{ type: Document, decorators: [{
5087
- type: Inject,
5088
- args: [DOCUMENT]
5089
- }] }, { type: i0.RendererFactory2 }]; } });
5090
-
5091
5115
  class ModalComponent {
5116
+ #destroyRef;
5117
+ #focusMonitor;
5092
5118
  constructor(document, renderer, hostElement, modalService, backdropService) {
5093
5119
  this.document = document;
5094
5120
  this.renderer = renderer;
5095
5121
  this.hostElement = hostElement;
5096
5122
  this.modalService = modalService;
5097
5123
  this.backdropService = backdropService;
5124
+ this.#destroyRef = inject(DestroyRef);
5125
+ this.#focusMonitor = inject(FocusMonitor);
5098
5126
  /**
5099
5127
  * Align the modal in the center or top of the screen.
5100
5128
  * @type {'top' | 'center'}
@@ -5123,46 +5151,72 @@ class ModalComponent {
5123
5151
  * @default 'dialog'
5124
5152
  */
5125
5153
  this.role = 'dialog';
5154
+ this.#ariaModal = null;
5126
5155
  /**
5127
- * Set aria-modal html attr for modal. [docs]
5156
+ * Create a scrollable modal that allows scrolling the modal body.
5128
5157
  * @type boolean
5129
- * @default true
5130
5158
  */
5131
- this.ariaModal = true;
5132
- this._scrollable = false;
5159
+ this.scrollable = false;
5160
+ this.#visible = signal(false);
5161
+ this.#activeElement = null;
5162
+ this.#visibleEffect = effect(() => {
5163
+ if (this.#visible() && this.#afterViewInit()) {
5164
+ this.#activeElement = this.document.activeElement;
5165
+ // this.#activeElement?.blur();
5166
+ setTimeout(() => {
5167
+ const focusable = this.modalContentRef.nativeElement.querySelectorAll('[tabindex]:not([tabindex="-1"]), button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled])');
5168
+ this.#focusMonitor.focusVia(focusable[0], 'keyboard');
5169
+ });
5170
+ }
5171
+ else {
5172
+ if (this.document.contains(this.#activeElement)) {
5173
+ setTimeout(() => {
5174
+ this.#activeElement?.focus();
5175
+ this.#activeElement = null;
5176
+ });
5177
+ }
5178
+ }
5179
+ });
5133
5180
  /**
5134
5181
  * Event triggered on modal dismiss.
5135
5182
  */
5136
5183
  this.visibleChange = new EventEmitter();
5137
5184
  this._show = true;
5138
5185
  this.mouseDownTarget = null;
5186
+ this.#afterViewInit = signal(false);
5139
5187
  }
5140
5188
  /**
5141
- * Create a scrollable modal that allows scrolling the modal body.
5189
+ * Set aria-modal html attr for modal. [docs]
5142
5190
  * @type boolean
5191
+ * @default null
5143
5192
  */
5144
- set scrollable(value) {
5145
- this._scrollable = coerceBooleanProperty(value);
5193
+ set ariaModal(value) {
5194
+ this.#ariaModal = value;
5146
5195
  }
5147
- get scrollable() {
5148
- return this._scrollable;
5196
+ get ariaModal() {
5197
+ return this.visible || this.#ariaModal ? true : null;
5149
5198
  }
5199
+ ;
5200
+ #ariaModal;
5150
5201
  /**
5151
5202
  * Toggle the visibility of modal component.
5152
5203
  * @type boolean
5153
5204
  */
5154
5205
  set visible(value) {
5155
- const newValue = coerceBooleanProperty(value);
5156
- if (this._visible !== newValue) {
5157
- this._visible = newValue;
5158
- this.setBackdrop(this.backdrop !== false && newValue);
5159
- this.setBodyStyles(newValue);
5160
- this.visibleChange.emit(newValue);
5206
+ if (this.#visible() !== value) {
5207
+ this.#visible.set(value);
5208
+ this.setBackdrop(this.backdrop !== false && value);
5209
+ this.setBodyStyles(value);
5210
+ this.visibleChange.emit(value);
5161
5211
  }
5162
5212
  }
5163
5213
  get visible() {
5164
- return this._visible;
5214
+ return this.#visible();
5165
5215
  }
5216
+ #visible;
5217
+ #activeElement;
5218
+ #visibleEffect;
5219
+ #activeBackdrop;
5166
5220
  // private inBoundingClientRect!: boolean;
5167
5221
  get hostClasses() {
5168
5222
  return {
@@ -5188,10 +5242,8 @@ class ModalComponent {
5188
5242
  this._show = value;
5189
5243
  }
5190
5244
  animateStart(event) {
5191
- const scrollbarWidth = this.backdropService.scrollbarWidth;
5192
5245
  if (event.toState === 'visible') {
5193
- this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
5194
- this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
5246
+ this.backdropService.hideScrollbar();
5195
5247
  this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'block');
5196
5248
  }
5197
5249
  else {
@@ -5204,8 +5256,6 @@ class ModalComponent {
5204
5256
  setTimeout(() => {
5205
5257
  if (event.toState === 'hidden') {
5206
5258
  this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'none');
5207
- this.renderer.removeStyle(this.document.body, 'overflow');
5208
- this.renderer.removeStyle(this.document.body, 'padding-right');
5209
5259
  }
5210
5260
  });
5211
5261
  this.show = this.visible;
@@ -5240,36 +5290,32 @@ class ModalComponent {
5240
5290
  ngOnInit() {
5241
5291
  this.stateToggleSubscribe();
5242
5292
  }
5293
+ #afterViewInit;
5294
+ ngAfterViewInit() {
5295
+ this.#afterViewInit.set(true);
5296
+ }
5243
5297
  ngOnDestroy() {
5244
5298
  this.modalService.toggle({ show: false, modal: this });
5245
- this.stateToggleSubscribe(false);
5299
+ this.#afterViewInit.set(false);
5246
5300
  }
5247
- stateToggleSubscribe(subscribe = true) {
5248
- if (subscribe) {
5249
- this.stateToggleSubscription = this.modalService.modalState$.subscribe((action) => {
5250
- if (this === action.modal || this.id === action.id) {
5251
- if ('show' in action) {
5252
- this.visible = action?.show === 'toggle' ? !this.visible : action.show;
5253
- }
5301
+ stateToggleSubscribe() {
5302
+ this.modalService.modalState$
5303
+ .pipe(takeUntilDestroyed(this.#destroyRef))
5304
+ .subscribe((action) => {
5305
+ if (this === action.modal || this.id === action.id) {
5306
+ if ('show' in action) {
5307
+ this.visible = action?.show === 'toggle' ? !this.visible : action.show;
5254
5308
  }
5255
- else {
5256
- if (this.visible) {
5257
- this.visible = false;
5258
- }
5309
+ }
5310
+ else {
5311
+ if (this.visible) {
5312
+ this.visible = false;
5259
5313
  }
5260
- });
5261
- }
5262
- else {
5263
- this.stateToggleSubscription?.unsubscribe();
5264
- }
5314
+ }
5315
+ });
5265
5316
  }
5266
5317
  setBackdrop(setBackdrop) {
5267
- if (setBackdrop) {
5268
- this.activeBackdrop = this.backdropService.setBackdrop('modal');
5269
- }
5270
- else {
5271
- this.activeBackdrop = this.backdropService.clearBackdrop(this.activeBackdrop);
5272
- }
5318
+ this.#activeBackdrop = setBackdrop ? this.backdropService.setBackdrop('modal') : this.backdropService.clearBackdrop(this.#activeBackdrop);
5273
5319
  }
5274
5320
  setBodyStyles(open) {
5275
5321
  if (open) {
@@ -5292,7 +5338,7 @@ class ModalComponent {
5292
5338
  }
5293
5339
  }
5294
5340
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ModalComponent, deps: [{ token: DOCUMENT }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: ModalService }, { token: BackdropService }], target: i0.ɵɵFactoryTarget.Component }); }
5295
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ModalComponent, isStandalone: true, selector: "c-modal", inputs: { alignment: "alignment", backdrop: "backdrop", fullscreen: "fullscreen", keyboard: "keyboard", id: "id", size: "size", transition: "transition", role: "role", ariaModal: "ariaModal", scrollable: "scrollable", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@showHide.start": "animateStart($event)", "@showHide.done": "animateDone($event)", "document:keyup": "onKeyDownHandler($event)", "mousedown": "onMouseDownHandler($event)", "click": "onClickHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateTrigger" } }, viewQueries: [{ propertyName: "modalContent", first: true, predicate: ModalContentComponent, descendants: true, read: ElementRef }], exportAs: ["cModal"], ngImport: i0, template: "<c-modal-dialog\n [alignment]=\"alignment\"\n [fullscreen]=\"fullscreen\"\n [scrollable]=\"scrollable\"\n [size]=\"size\">\n <c-modal-content>\n <div [cdkTrapFocus]=\"visible\" [cdkTrapFocusAutoCapture]=\"visible\" style=\"display: contents;\">\n <ng-content></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: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5341
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "16.2.12", type: ModalComponent, isStandalone: true, selector: "c-modal", inputs: { alignment: "alignment", backdrop: "backdrop", fullscreen: "fullscreen", keyboard: ["keyboard", "keyboard", booleanAttribute], id: "id", size: "size", transition: ["transition", "transition", booleanAttribute], role: "role", ariaModal: "ariaModal", scrollable: ["scrollable", "scrollable", booleanAttribute], visible: ["visible", "visible", booleanAttribute] }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@showHide.start": "animateStart($event)", "@showHide.done": "animateDone($event)", "document:keyup": "onKeyDownHandler($event)", "mousedown": "onMouseDownHandler($event)", "click": "onClickHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateTrigger" } }, viewQueries: [{ propertyName: "modalContent", first: true, predicate: ModalContentComponent, descendants: true, read: ElementRef }, { propertyName: "modalContentRef", first: true, predicate: ["modalContentRef"], descendants: true, read: ElementRef }], exportAs: ["cModal"], ngImport: i0, template: "<c-modal-dialog\n [alignment]=\"alignment\"\n [fullscreen]=\"fullscreen\"\n [scrollable]=\"scrollable\"\n [size]=\"size\">\n <c-modal-content>\n <div [cdkTrapFocus]=\"visible\" [cdkTrapFocusAutoCapture]=\"visible\" style=\"display: contents;\" #modalContentRef>\n <ng-content></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: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5296
5342
  trigger('showHide', [
5297
5343
  state('visible', style({
5298
5344
  // display: 'block'
@@ -5300,7 +5346,7 @@ class ModalComponent {
5300
5346
  state('hidden', style({
5301
5347
  // display: 'none'
5302
5348
  })),
5303
- transition('visible <=> *', [animate('300ms')])
5349
+ transition('visible <=> *', [animate('150ms')])
5304
5350
  ])
5305
5351
  ] }); }
5306
5352
  }
@@ -5314,9 +5360,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5314
5360
  state('hidden', style({
5315
5361
  // display: 'none'
5316
5362
  })),
5317
- transition('visible <=> *', [animate('300ms')])
5363
+ transition('visible <=> *', [animate('150ms')])
5318
5364
  ])
5319
- ], exportAs: 'cModal', standalone: true, imports: [ModalDialogComponent, ModalContentComponent, A11yModule], template: "<c-modal-dialog\n [alignment]=\"alignment\"\n [fullscreen]=\"fullscreen\"\n [scrollable]=\"scrollable\"\n [size]=\"size\">\n <c-modal-content>\n <div [cdkTrapFocus]=\"visible\" [cdkTrapFocusAutoCapture]=\"visible\" style=\"display: contents;\">\n <ng-content></ng-content>\n </div>\n </c-modal-content>\n</c-modal-dialog>\n" }]
5365
+ ], exportAs: 'cModal', standalone: true, imports: [ModalDialogComponent, ModalContentComponent, A11yModule], template: "<c-modal-dialog\n [alignment]=\"alignment\"\n [fullscreen]=\"fullscreen\"\n [scrollable]=\"scrollable\"\n [size]=\"size\">\n <c-modal-content>\n <div [cdkTrapFocus]=\"visible\" [cdkTrapFocusAutoCapture]=\"visible\" style=\"display: contents;\" #modalContentRef>\n <ng-content></ng-content>\n </div>\n </c-modal-content>\n</c-modal-dialog>\n" }]
5320
5366
  }], ctorParameters: function () { return [{ type: Document, decorators: [{
5321
5367
  type: Inject,
5322
5368
  args: [DOCUMENT]
@@ -5327,13 +5373,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5327
5373
  }], fullscreen: [{
5328
5374
  type: Input
5329
5375
  }], keyboard: [{
5330
- type: Input
5376
+ type: Input,
5377
+ args: [{ transform: booleanAttribute }]
5331
5378
  }], id: [{
5332
5379
  type: Input
5333
5380
  }], size: [{
5334
5381
  type: Input
5335
5382
  }], transition: [{
5336
- type: Input
5383
+ type: Input,
5384
+ args: [{ transform: booleanAttribute }]
5337
5385
  }], role: [{
5338
5386
  type: Input
5339
5387
  }, {
@@ -5345,14 +5393,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5345
5393
  type: HostBinding,
5346
5394
  args: ['attr.aria-modal']
5347
5395
  }], scrollable: [{
5348
- type: Input
5396
+ type: Input,
5397
+ args: [{ transform: booleanAttribute }]
5349
5398
  }], visible: [{
5350
- type: Input
5399
+ type: Input,
5400
+ args: [{ transform: booleanAttribute }]
5351
5401
  }], visibleChange: [{
5352
5402
  type: Output
5353
5403
  }], modalContent: [{
5354
5404
  type: ViewChild,
5355
5405
  args: [ModalContentComponent, { read: ElementRef }]
5406
+ }], modalContentRef: [{
5407
+ type: ViewChild,
5408
+ args: ['modalContentRef', { read: ElementRef }]
5356
5409
  }], hostClasses: [{
5357
5410
  type: HostBinding,
5358
5411
  args: ['class']
@@ -5448,6 +5501,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5448
5501
 
5449
5502
  let nextId = 0;
5450
5503
  class OffcanvasComponent {
5504
+ #destroyRef;
5451
5505
  constructor(document, platformId, renderer, hostElement, offcanvasService, backdropService, breakpointObserver) {
5452
5506
  this.document = document;
5453
5507
  this.platformId = platformId;
@@ -5456,6 +5510,7 @@ class OffcanvasComponent {
5456
5510
  this.offcanvasService = offcanvasService;
5457
5511
  this.backdropService = backdropService;
5458
5512
  this.breakpointObserver = breakpointObserver;
5513
+ this.#destroyRef = inject(DestroyRef);
5459
5514
  /**
5460
5515
  * Apply a backdrop on body while offcanvas is open.
5461
5516
  * @type boolean | 'static'
@@ -5494,43 +5549,31 @@ class OffcanvasComponent {
5494
5549
  * @default true
5495
5550
  */
5496
5551
  this.ariaModal = true;
5552
+ this.#show = false;
5553
+ /**
5554
+ * Allow body scrolling while offcanvas is visible.
5555
+ * @type boolean
5556
+ * @default false
5557
+ */
5558
+ this.scroll = false;
5559
+ this.#visible = false;
5497
5560
  /**
5498
5561
  * Event triggered on visible change.
5562
+ * @type EventEmitter<boolean>
5499
5563
  */
5500
5564
  this.visibleChange = new EventEmitter();
5501
- this.#scroll = false;
5502
- this.#visible = false;
5503
- this.#show = false;
5504
5565
  }
5505
- #scroll;
5506
- #visible;
5507
5566
  #activeBackdrop;
5508
- #scrollbarWidth;
5509
- #stateToggleSubscription;
5510
5567
  #backdropClickSubscription;
5511
5568
  #layoutChangeSubscription;
5512
5569
  #show;
5513
- get scroll() {
5514
- return this.#scroll;
5515
- }
5516
- /**
5517
- * Allow body scrolling while offcanvas is visible.
5518
- * @type boolean
5519
- * @default false
5520
- */
5521
- set scroll(value) {
5522
- this.#scroll = coerceBooleanProperty(value);
5523
- }
5524
- get visible() {
5525
- return this.#visible;
5526
- }
5527
5570
  /**
5528
5571
  * Toggle the visibility of offcanvas component.
5529
5572
  * @type boolean
5530
5573
  * @default false
5531
5574
  */
5532
5575
  set visible(value) {
5533
- this.#visible = coerceBooleanProperty(value);
5576
+ this.#visible = value;
5534
5577
  if (this.#visible) {
5535
5578
  this.setBackdrop(this.backdrop);
5536
5579
  this.setFocus();
@@ -5541,6 +5584,10 @@ class OffcanvasComponent {
5541
5584
  this.layoutChangeSubscribe(this.#visible);
5542
5585
  this.visibleChange.emit(value);
5543
5586
  }
5587
+ get visible() {
5588
+ return this.#visible;
5589
+ }
5590
+ #visible;
5544
5591
  get hostClasses() {
5545
5592
  return {
5546
5593
  offcanvas: typeof this.responsive === 'boolean',
@@ -5574,11 +5621,9 @@ class OffcanvasComponent {
5574
5621
  return breakpointValue ? `${parseFloat(breakpointValue.trim()) - 0.02}px` : false;
5575
5622
  }
5576
5623
  animateStart(event) {
5577
- const scrollbarWidth = this.#scrollbarWidth;
5578
5624
  if (event.toState === 'visible') {
5579
5625
  if (!this.scroll) {
5580
- this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
5581
- this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
5626
+ this.backdropService.hideScrollbar();
5582
5627
  }
5583
5628
  this.renderer.addClass(this.hostElement.nativeElement, 'showing');
5584
5629
  }
@@ -5608,7 +5653,6 @@ class OffcanvasComponent {
5608
5653
  }
5609
5654
  }
5610
5655
  ngOnInit() {
5611
- this.#scrollbarWidth = this.backdropService.scrollbarWidth;
5612
5656
  this.stateToggleSubscribe();
5613
5657
  setTimeout(() => {
5614
5658
  // hotfix to avoid offcanvas flicker on the first render
@@ -5617,33 +5661,30 @@ class OffcanvasComponent {
5617
5661
  }
5618
5662
  ngOnDestroy() {
5619
5663
  this.offcanvasService.toggle({ show: false, id: this.id });
5620
- this.stateToggleSubscribe(false);
5621
5664
  }
5622
5665
  setFocus() {
5623
5666
  if (isPlatformBrowser(this.platformId)) {
5624
5667
  setTimeout(() => this.hostElement.nativeElement.focus());
5625
5668
  }
5626
5669
  }
5627
- stateToggleSubscribe(subscribe = true) {
5628
- if (subscribe) {
5629
- this.#stateToggleSubscription =
5630
- this.offcanvasService.offcanvasState$.subscribe((action) => {
5631
- if (this === action.offcanvas || this.id === action.id) {
5632
- if ('show' in action) {
5633
- this.visible =
5634
- action?.show === 'toggle' ? !this.visible : action.show;
5635
- }
5636
- }
5637
- });
5638
- }
5639
- else {
5640
- this.#stateToggleSubscription?.unsubscribe();
5641
- }
5670
+ stateToggleSubscribe() {
5671
+ this.offcanvasService.offcanvasState$
5672
+ .pipe(takeUntilDestroyed(this.#destroyRef))
5673
+ .subscribe((action) => {
5674
+ if (this === action.offcanvas || this.id === action.id) {
5675
+ if ('show' in action) {
5676
+ this.visible =
5677
+ action?.show === 'toggle' ? !this.visible : action.show;
5678
+ }
5679
+ }
5680
+ });
5642
5681
  }
5643
5682
  backdropClickSubscribe(subscribe = true) {
5644
5683
  if (subscribe) {
5645
5684
  this.#backdropClickSubscription =
5646
- this.backdropService.backdropClick$.subscribe((clicked) => {
5685
+ this.backdropService.backdropClick$
5686
+ .pipe(takeUntilDestroyed(this.#destroyRef))
5687
+ .subscribe((clicked) => {
5647
5688
  this.offcanvasService.toggle({ show: !clicked, id: this.id });
5648
5689
  });
5649
5690
  }
@@ -5652,7 +5693,6 @@ class OffcanvasComponent {
5652
5693
  }
5653
5694
  }
5654
5695
  setBackdrop(setBackdrop) {
5655
- this.#scrollbarWidth = this.backdropService.scrollbarWidth;
5656
5696
  this.#activeBackdrop = !!setBackdrop ? this.backdropService.setBackdrop('offcanvas')
5657
5697
  : this.backdropService.clearBackdrop(this.#activeBackdrop);
5658
5698
  setBackdrop === true ? this.backdropClickSubscribe()
@@ -5666,7 +5706,7 @@ class OffcanvasComponent {
5666
5706
  const responsiveBreakpoint = `(max-width: ${this.responsiveBreakpoint})`;
5667
5707
  const layoutChanges = this.breakpointObserver.observe([responsiveBreakpoint]);
5668
5708
  this.#layoutChangeSubscription = layoutChanges
5669
- .pipe(filter(breakpointState => !breakpointState.matches))
5709
+ .pipe(filter(breakpointState => !breakpointState.matches), takeUntilDestroyed(this.#destroyRef))
5670
5710
  .subscribe((breakpointState) => {
5671
5711
  this.visible = breakpointState.matches;
5672
5712
  });
@@ -5676,7 +5716,7 @@ class OffcanvasComponent {
5676
5716
  }
5677
5717
  }
5678
5718
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: OffcanvasComponent, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: OffcanvasService }, { token: BackdropService }, { token: i1$2.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Component }); }
5679
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: OffcanvasComponent, isStandalone: true, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: "keyboard", placement: "placement", responsive: "responsive", id: "id", role: "role", ariaModal: "ariaModal", scroll: "scroll", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@showHide.start": "animateStart($event)", "@showHide.done": "animateDone($event)", "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateTrigger" } }, exportAs: ["cOffcanvas"], ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [":host{display:none}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5719
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "16.2.12", type: OffcanvasComponent, isStandalone: true, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: ["keyboard", "keyboard", booleanAttribute], placement: "placement", responsive: "responsive", id: "id", role: "role", ariaModal: ["ariaModal", "ariaModal", booleanAttribute], scroll: ["scroll", "scroll", booleanAttribute], visible: ["visible", "visible", booleanAttribute] }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "@showHide.start": "animateStart($event)", "@showHide.done": "animateDone($event)", "document:keydown": "onKeyDownHandler($event)" }, properties: { "attr.role": "this.role", "attr.aria-modal": "this.ariaModal", "class": "this.hostClasses", "attr.aria-hidden": "this.ariaHidden", "attr.tabindex": "this.tabIndex", "@showHide": "this.animateTrigger" } }, exportAs: ["cOffcanvas"], ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [":host{display:none}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
5680
5720
  trigger('showHide', [
5681
5721
  state('visible', style({
5682
5722
  // visibility: 'visible'
@@ -5710,7 +5750,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5710
5750
  }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: OffcanvasService }, { type: BackdropService }, { type: i1$2.BreakpointObserver }]; }, propDecorators: { backdrop: [{
5711
5751
  type: Input
5712
5752
  }], keyboard: [{
5713
- type: Input
5753
+ type: Input,
5754
+ args: [{ transform: booleanAttribute }]
5714
5755
  }], placement: [{
5715
5756
  type: Input
5716
5757
  }], responsive: [{
@@ -5723,16 +5764,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
5723
5764
  type: HostBinding,
5724
5765
  args: ['attr.role']
5725
5766
  }], ariaModal: [{
5726
- type: Input
5767
+ type: Input,
5768
+ args: [{ transform: booleanAttribute }]
5727
5769
  }, {
5728
5770
  type: HostBinding,
5729
5771
  args: ['attr.aria-modal']
5730
- }], visibleChange: [{
5731
- type: Output
5732
5772
  }], scroll: [{
5733
- type: Input
5773
+ type: Input,
5774
+ args: [{ transform: booleanAttribute }]
5734
5775
  }], visible: [{
5735
- type: Input
5776
+ type: Input,
5777
+ args: [{ transform: booleanAttribute }]
5778
+ }], visibleChange: [{
5779
+ type: Output
5736
5780
  }], hostClasses: [{
5737
5781
  type: HostBinding,
5738
5782
  args: ['class']
@@ -9688,5 +9732,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
9688
9732
  * Generated bundle index. Do not edit.
9689
9733
  */
9690
9734
 
9691
- export { AccordionButtonDirective, AccordionComponent, AccordionItemComponent, AccordionModule, AlertComponent, AlertHeadingDirective, AlertLinkDirective, AlertModule, AlignDirective, AvatarComponent, AvatarModule, BadgeComponent, BadgeModule, BgColorDirective, BorderDirective, BreadcrumbComponent, BreadcrumbItemComponent, BreadcrumbModule, BreadcrumbRouterComponent, BreadcrumbRouterService, BreakpointInfix, ButtonCloseDirective, ButtonDirective, ButtonGroupComponent, ButtonGroupModule, ButtonModule, ButtonToolbarComponent, CalloutComponent, CalloutModule, CardBodyComponent, CardComponent, CardFooterComponent, CardGroupComponent, CardHeaderActionsComponent, CardHeaderComponent, CardImgDirective, CardImgOverlayComponent, CardLinkDirective, CardModule, CardSubtitleDirective, CardTextDirective, CardTitleDirective, CarouselCaptionComponent, CarouselComponent, CarouselConfig, CarouselControlComponent, CarouselIndicatorsComponent, CarouselInnerComponent, CarouselItemComponent, CarouselModule, ClassToggleService, ColComponent, ColDirective, CollapseDirective, CollapseModule, ContainerComponent, DropdownCloseDirective, DropdownComponent, DropdownDividerDirective, DropdownHeaderDirective, DropdownItemDirective, DropdownItemPlainDirective, DropdownMenuDirective, DropdownModule, DropdownService, DropdownToggleDirective, FooterComponent, FooterModule, FormCheckComponent, FormCheckInputDirective, FormCheckLabelDirective, FormControlDirective, FormDirective, FormFeedbackComponent, FormFloatingDirective, FormLabelDirective, FormModule, FormSelectDirective, FormTextDirective, GridModule, GutterDirective, HeaderBrandComponent, HeaderComponent, HeaderDividerComponent, HeaderModule, HeaderNavComponent, HeaderTextComponent, HeaderTogglerDirective, HtmlAttributesDirective, ImgDirective, ImgModule, InputGroupComponent, InputGroupTextDirective, IntersectionService, ListGroupDirective, ListGroupItemDirective, ListGroupModule, ListenersService, ModalBodyComponent, ModalComponent, ModalContentComponent, ModalDialogComponent, ModalFooterComponent, ModalHeaderComponent, ModalModule, ModalService, ModalTitleDirective, ModalToggleDirective, NavComponent, NavItemComponent, NavLinkDirective, NavModule, NavbarBrandDirective, NavbarComponent, NavbarModule, NavbarNavComponent, NavbarTextComponent, NavbarTogglerDirective, OffcanvasBodyComponent, OffcanvasComponent, OffcanvasHeaderComponent, OffcanvasModule, OffcanvasService, OffcanvasTitleDirective, OffcanvasToggleDirective, PageItemComponent, PageItemDirective, PageLinkDirective, PaginationComponent, PaginationModule, PlaceholderAnimationDirective, PlaceholderDirective, PlaceholderModule, PopoverComponent, PopoverDirective, PopoverModule, ProgressBarComponent, ProgressComponent, ProgressModule, RoundedDirective, RowComponent, RowDirective, SharedModule, SidebarBrandComponent, SidebarComponent, SidebarFooterComponent, SidebarHeaderComponent, SidebarModule, SidebarNavComponent, SidebarService, SidebarToggleDirective, SidebarTogglerComponent, SpinnerComponent, SpinnerModule, TabContentComponent, TabContentRefDirective, TabPaneComponent, TabService, TableActiveDirective, TableColorDirective, TableDirective, TableModule, TabsModule, TemplateIdDirective, TextColorDirective, ToastBodyComponent, ToastCloseDirective, ToastComponent, ToastHeaderComponent, ToastModule, ToasterComponent, ToasterHostDirective, ToasterPlacement, ToasterService, TooltipComponent, TooltipDirective, TooltipModule, UtilitiesModule, WidgetModule, WidgetStatAComponent, WidgetStatBComponent, WidgetStatCComponent, WidgetStatDComponent, WidgetStatEComponent, WidgetStatFComponent };
9735
+ export { AccordionButtonDirective, AccordionComponent, AccordionItemComponent, AccordionModule, AlertComponent, AlertHeadingDirective, AlertLinkDirective, AlertModule, AlignDirective, AvatarComponent, AvatarModule, BackdropService, BadgeComponent, BadgeModule, BgColorDirective, BorderDirective, BreadcrumbComponent, BreadcrumbItemComponent, BreadcrumbModule, BreadcrumbRouterComponent, BreadcrumbRouterService, BreakpointInfix, ButtonCloseDirective, ButtonDirective, ButtonGroupComponent, ButtonGroupModule, ButtonModule, ButtonToolbarComponent, CalloutComponent, CalloutModule, CardBodyComponent, CardComponent, CardFooterComponent, CardGroupComponent, CardHeaderActionsComponent, CardHeaderComponent, CardImgDirective, CardImgOverlayComponent, CardLinkDirective, CardModule, CardSubtitleDirective, CardTextDirective, CardTitleDirective, CarouselCaptionComponent, CarouselComponent, CarouselConfig, CarouselControlComponent, CarouselIndicatorsComponent, CarouselInnerComponent, CarouselItemComponent, CarouselModule, ClassToggleService, ColComponent, ColDirective, CollapseDirective, CollapseModule, ContainerComponent, DropdownCloseDirective, DropdownComponent, DropdownDividerDirective, DropdownHeaderDirective, DropdownItemDirective, DropdownItemPlainDirective, DropdownMenuDirective, DropdownModule, DropdownService, DropdownToggleDirective, FooterComponent, FooterModule, FormCheckComponent, FormCheckInputDirective, FormCheckLabelDirective, FormControlDirective, FormDirective, FormFeedbackComponent, FormFloatingDirective, FormLabelDirective, FormModule, FormSelectDirective, FormTextDirective, GridModule, GutterDirective, HeaderBrandComponent, HeaderComponent, HeaderDividerComponent, HeaderModule, HeaderNavComponent, HeaderTextComponent, HeaderTogglerDirective, HtmlAttributesDirective, ImgDirective, ImgModule, InputGroupComponent, InputGroupTextDirective, IntersectionService, ListGroupDirective, ListGroupItemDirective, ListGroupModule, ListenersService, ModalBodyComponent, ModalComponent, ModalContentComponent, ModalDialogComponent, ModalFooterComponent, ModalHeaderComponent, ModalModule, ModalService, ModalTitleDirective, ModalToggleDirective, NavComponent, NavItemComponent, NavLinkDirective, NavModule, NavbarBrandDirective, NavbarComponent, NavbarModule, NavbarNavComponent, NavbarTextComponent, NavbarTogglerDirective, OffcanvasBodyComponent, OffcanvasComponent, OffcanvasHeaderComponent, OffcanvasModule, OffcanvasService, OffcanvasTitleDirective, OffcanvasToggleDirective, PageItemComponent, PageItemDirective, PageLinkDirective, PaginationComponent, PaginationModule, PlaceholderAnimationDirective, PlaceholderDirective, PlaceholderModule, PopoverComponent, PopoverDirective, PopoverModule, ProgressBarComponent, ProgressComponent, ProgressModule, RoundedDirective, RowComponent, RowDirective, SharedModule, SidebarBrandComponent, SidebarComponent, SidebarFooterComponent, SidebarHeaderComponent, SidebarModule, SidebarNavComponent, SidebarService, SidebarToggleDirective, SidebarTogglerComponent, SpinnerComponent, SpinnerModule, TabContentComponent, TabContentRefDirective, TabPaneComponent, TabService, TableActiveDirective, TableColorDirective, TableDirective, TableModule, TabsModule, TemplateIdDirective, TextColorDirective, ToastBodyComponent, ToastCloseDirective, ToastComponent, ToastHeaderComponent, ToastModule, ToasterComponent, ToasterHostDirective, ToasterPlacement, ToasterService, TooltipComponent, TooltipDirective, TooltipModule, UtilitiesModule, WidgetModule, WidgetStatAComponent, WidgetStatBComponent, WidgetStatCComponent, WidgetStatDComponent, WidgetStatEComponent, WidgetStatFComponent };
9692
9736
  //# sourceMappingURL=coreui-angular.mjs.map