@coreui/angular-pro 4.2.27 → 4.2.28

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.
@@ -9707,6 +9707,12 @@ class BackdropService {
9707
9707
  this.backdropClick$ = this.backdropClick.asObservable();
9708
9708
  this.renderer = rendererFactory.createRenderer(null, null);
9709
9709
  }
9710
+ get scrollbarWidth() {
9711
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
9712
+ const documentWidth = this.document.documentElement.clientWidth;
9713
+ const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
9714
+ return `${scrollbarWidth}px`;
9715
+ }
9710
9716
  setBackdrop(type = 'modal') {
9711
9717
  const backdropElement = this.renderer.createElement('div');
9712
9718
  this.renderer.addClass(backdropElement, `${type}-backdrop`);
@@ -9742,7 +9748,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
9742
9748
  args: [{
9743
9749
  providedIn: 'root'
9744
9750
  }]
9745
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
9751
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
9746
9752
  type: Inject,
9747
9753
  args: [DOCUMENT]
9748
9754
  }] }, { type: i0.RendererFactory2 }]; } });
@@ -9846,14 +9852,8 @@ class ModalComponent {
9846
9852
  set show(value) {
9847
9853
  this._show = value;
9848
9854
  }
9849
- get scrollbarWidth() {
9850
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
9851
- const documentWidth = this.document.documentElement.clientWidth;
9852
- const scrollbarWidth = Math.abs((window?.innerWidth ?? documentWidth) - documentWidth);
9853
- return `${scrollbarWidth}px`;
9854
- }
9855
9855
  animateStart(event) {
9856
- const scrollbarWidth = this.scrollbarWidth;
9856
+ const scrollbarWidth = this.backdropService.scrollbarWidth;
9857
9857
  if (event.toState === 'visible') {
9858
9858
  this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
9859
9859
  this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
@@ -10121,18 +10121,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
10121
10121
  }]
10122
10122
  }], ctorParameters: function () { return []; } });
10123
10123
 
10124
+ var _OffcanvasComponent_scroll, _OffcanvasComponent_visible, _OffcanvasComponent_activeBackdrop, _OffcanvasComponent_scrollbarWidth, _OffcanvasComponent_stateToggleSubscription, _OffcanvasComponent_backdropClickSubscription, _OffcanvasComponent_layoutChangeSubscription, _OffcanvasComponent_show;
10124
10125
  let nextId = 0;
10125
10126
  class OffcanvasComponent {
10126
- constructor(document, platformId, renderer, hostElement, offcanvasService, backdropService) {
10127
+ constructor(document, platformId, renderer, hostElement, offcanvasService, backdropService, breakpointObserver) {
10127
10128
  this.document = document;
10128
10129
  this.platformId = platformId;
10129
10130
  this.renderer = renderer;
10130
10131
  this.hostElement = hostElement;
10131
10132
  this.offcanvasService = offcanvasService;
10132
10133
  this.backdropService = backdropService;
10134
+ this.breakpointObserver = breakpointObserver;
10133
10135
  /**
10134
10136
  * Apply a backdrop on body while offcanvas is open.
10135
- * @type boolean
10137
+ * @type boolean | 'static'
10136
10138
  * @default true
10137
10139
  */
10138
10140
  this.backdrop = true;
@@ -10148,7 +10150,14 @@ class OffcanvasComponent {
10148
10150
  * @default 'start'
10149
10151
  */
10150
10152
  this.placement = 'start';
10151
- this._scroll = false;
10153
+ /**
10154
+ * Responsive offcanvas property hides content outside the viewport from a specified breakpoint and down.
10155
+ * @type boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
10156
+ * @default true
10157
+ * @since 4.3.10
10158
+ */
10159
+ this.responsive = true;
10160
+ _OffcanvasComponent_scroll.set(this, false);
10152
10161
  this.id = `offcanvas-${this.placement}-${nextId++}`;
10153
10162
  /**
10154
10163
  * Default role for offcanvas. [docs]
@@ -10162,166 +10171,220 @@ class OffcanvasComponent {
10162
10171
  * @default true
10163
10172
  */
10164
10173
  this.ariaModal = true;
10174
+ _OffcanvasComponent_visible.set(this, false);
10165
10175
  /**
10166
10176
  * Event triggered on visible change.
10167
10177
  */
10168
10178
  this.visibleChange = new EventEmitter();
10179
+ _OffcanvasComponent_activeBackdrop.set(this, void 0);
10180
+ _OffcanvasComponent_scrollbarWidth.set(this, void 0);
10181
+ _OffcanvasComponent_stateToggleSubscription.set(this, void 0);
10182
+ _OffcanvasComponent_backdropClickSubscription.set(this, void 0);
10183
+ _OffcanvasComponent_layoutChangeSubscription.set(this, void 0);
10184
+ _OffcanvasComponent_show.set(this, false);
10169
10185
  }
10170
10186
  /**
10171
10187
  * Allow body scrolling while offcanvas is visible.
10172
10188
  * @type boolean
10189
+ * @default false
10173
10190
  */
10174
10191
  set scroll(value) {
10175
- this._scroll = coerceBooleanProperty(value);
10192
+ __classPrivateFieldSet(this, _OffcanvasComponent_scroll, coerceBooleanProperty(value), "f");
10176
10193
  }
10177
- ;
10178
10194
  get scroll() {
10179
- return this._scroll;
10195
+ return __classPrivateFieldGet(this, _OffcanvasComponent_scroll, "f");
10180
10196
  }
10181
10197
  /**
10182
10198
  * Toggle the visibility of offcanvas component.
10183
10199
  * @type boolean
10200
+ * @default false
10184
10201
  */
10185
10202
  set visible(value) {
10186
- this._visible = coerceBooleanProperty(value);
10187
- if (value) {
10203
+ __classPrivateFieldSet(this, _OffcanvasComponent_visible, coerceBooleanProperty(value), "f");
10204
+ if (__classPrivateFieldGet(this, _OffcanvasComponent_visible, "f")) {
10188
10205
  this.setBackdrop(this.backdrop);
10189
10206
  this.setFocus();
10190
10207
  }
10191
10208
  else {
10192
10209
  this.setBackdrop(false);
10193
10210
  }
10194
- this.setScroll();
10211
+ this.layoutChangeSubscribe(__classPrivateFieldGet(this, _OffcanvasComponent_visible, "f"));
10195
10212
  this.visibleChange.emit(value);
10196
10213
  }
10197
10214
  get visible() {
10198
- return this._visible;
10215
+ return __classPrivateFieldGet(this, _OffcanvasComponent_visible, "f");
10199
10216
  }
10200
10217
  get hostClasses() {
10201
10218
  return {
10202
- offcanvas: true,
10219
+ offcanvas: typeof this.responsive === 'boolean',
10220
+ [`offcanvas-${this.responsive}`]: typeof this.responsive !== 'boolean',
10203
10221
  [`offcanvas-${this.placement}`]: !!this.placement,
10204
- show: this.visible,
10222
+ show: this.show
10205
10223
  };
10206
10224
  }
10207
10225
  get ariaHidden() {
10208
10226
  return this.visible ? null : true;
10209
10227
  }
10210
- ;
10211
10228
  get tabIndex() {
10212
10229
  return '-1';
10213
10230
  }
10214
- get animateType() {
10215
- return this.visible;
10231
+ get animateTrigger() {
10232
+ return this.visible ? 'visible' : 'hidden';
10233
+ }
10234
+ get show() {
10235
+ return this.visible && __classPrivateFieldGet(this, _OffcanvasComponent_show, "f");
10236
+ }
10237
+ set show(value) {
10238
+ __classPrivateFieldSet(this, _OffcanvasComponent_show, value, "f");
10239
+ }
10240
+ animateStart(event) {
10241
+ const scrollbarWidth = __classPrivateFieldGet(this, _OffcanvasComponent_scrollbarWidth, "f");
10242
+ if (event.toState === 'visible') {
10243
+ if (!this.scroll) {
10244
+ this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
10245
+ this.renderer.setStyle(this.document.body, 'padding-right', scrollbarWidth);
10246
+ }
10247
+ this.renderer.addClass(this.hostElement.nativeElement, 'showing');
10248
+ }
10249
+ else {
10250
+ this.renderer.addClass(this.hostElement.nativeElement, 'hiding');
10251
+ }
10252
+ }
10253
+ animateDone(event) {
10254
+ setTimeout(() => {
10255
+ if (event.toState === 'visible') {
10256
+ this.renderer.removeClass(this.hostElement.nativeElement, 'showing');
10257
+ }
10258
+ if (event.toState === 'hidden') {
10259
+ this.renderer.removeClass(this.hostElement.nativeElement, 'hiding');
10260
+ this.renderer.removeStyle(this.document.body, 'overflow');
10261
+ this.renderer.removeStyle(this.document.body, 'paddingRight');
10262
+ }
10263
+ });
10264
+ this.show = this.visible;
10216
10265
  }
10217
10266
  onKeyDownHandler(event) {
10218
- if (event.key === 'Escape' && this.keyboard && this.visible) {
10267
+ if (event.key === 'Escape' &&
10268
+ this.keyboard &&
10269
+ this.visible &&
10270
+ this.backdrop !== 'static') {
10219
10271
  this.offcanvasService.toggle({ show: false, id: this.id });
10220
10272
  }
10221
10273
  }
10222
10274
  ngOnInit() {
10223
- this.setScroll();
10275
+ __classPrivateFieldSet(this, _OffcanvasComponent_scrollbarWidth, this.backdropService.scrollbarWidth, "f");
10224
10276
  this.stateToggleSubscribe();
10277
+ // hotfix to avoid end offcanvas flicker on first render
10278
+ this.renderer.setStyle(this.hostElement.nativeElement, 'display', 'flex');
10225
10279
  }
10226
10280
  ngOnDestroy() {
10227
10281
  this.offcanvasService.toggle({ show: false, id: this.id });
10228
10282
  this.stateToggleSubscribe(false);
10229
10283
  }
10230
- ngOnChanges(changes) {
10231
- if (changes['scroll']) {
10232
- this.setScroll();
10233
- }
10234
- }
10235
10284
  stateToggleSubscribe(subscribe = true) {
10236
10285
  if (subscribe) {
10237
- this.stateToggleSubscription = this.offcanvasService.offcanvasState$.subscribe((action) => {
10286
+ __classPrivateFieldSet(this, _OffcanvasComponent_stateToggleSubscription, this.offcanvasService.offcanvasState$.subscribe((action) => {
10238
10287
  if (this === action.offcanvas || this.id === action.id) {
10239
10288
  if ('show' in action) {
10240
- this.visible = action?.show === 'toggle' ? !this.visible : action.show;
10289
+ this.visible =
10290
+ action?.show === 'toggle' ? !this.visible : action.show;
10241
10291
  }
10242
10292
  }
10243
- });
10293
+ }), "f");
10244
10294
  }
10245
10295
  else {
10246
- this.stateToggleSubscription.unsubscribe();
10296
+ __classPrivateFieldGet(this, _OffcanvasComponent_stateToggleSubscription, "f").unsubscribe();
10247
10297
  }
10248
10298
  }
10249
10299
  backdropClickSubscribe(subscribe = true) {
10250
10300
  if (subscribe) {
10251
- this.backdropClickSubscription = this.backdropService.backdropClick$.subscribe((clicked) => {
10301
+ __classPrivateFieldSet(this, _OffcanvasComponent_backdropClickSubscription, this.backdropService.backdropClick$.subscribe((clicked) => {
10252
10302
  this.offcanvasService.toggle({ show: !clicked, id: this.id });
10253
- });
10303
+ }), "f");
10254
10304
  }
10255
10305
  else {
10256
- this.backdropClickSubscription?.unsubscribe();
10306
+ __classPrivateFieldGet(this, _OffcanvasComponent_backdropClickSubscription, "f")?.unsubscribe();
10257
10307
  }
10258
10308
  }
10259
10309
  setBackdrop(setBackdrop) {
10260
- if (setBackdrop) {
10261
- this.activeBackdrop = this.backdropService.setBackdrop('offcanvas');
10262
- this.backdropClickSubscribe();
10263
- }
10264
- else {
10265
- this.activeBackdrop = this.backdropService.clearBackdrop(this.activeBackdrop);
10266
- this.backdropClickSubscribe(false);
10267
- }
10310
+ __classPrivateFieldSet(this, _OffcanvasComponent_scrollbarWidth, this.backdropService.scrollbarWidth, "f");
10311
+ __classPrivateFieldSet(this, _OffcanvasComponent_activeBackdrop, !!setBackdrop ? this.backdropService.setBackdrop('offcanvas')
10312
+ : this.backdropService.clearBackdrop(__classPrivateFieldGet(this, _OffcanvasComponent_activeBackdrop, "f")), "f");
10313
+ setBackdrop === true ? this.backdropClickSubscribe()
10314
+ : this.backdropClickSubscribe(false);
10268
10315
  }
10269
10316
  setFocus() {
10270
10317
  if (isPlatformBrowser(this.platformId)) {
10271
10318
  setTimeout(() => this.hostElement.nativeElement.focus());
10272
10319
  }
10273
10320
  }
10274
- setScroll() {
10275
- if (this.visible) {
10276
- if (!this.scroll) {
10277
- this.renderer.setStyle(this.document.body, 'overflow', 'hidden');
10278
- this.renderer.setStyle(this.document.body, 'paddingRight.px', '0');
10321
+ get responsiveBreakpoint() {
10322
+ if (typeof this.responsive !== 'string') {
10323
+ return false;
10324
+ }
10325
+ const element = this.document.documentElement;
10326
+ const responsiveBreakpoint = this.responsive;
10327
+ const breakpointValue = getComputedStyle(element).getPropertyValue(`--cui-breakpoint-${responsiveBreakpoint.trim()}`) || false;
10328
+ return breakpointValue ? `${parseFloat(breakpointValue.trim()) - 0.02}px` : false;
10329
+ }
10330
+ layoutChangeSubscribe(subscribe = true) {
10331
+ if (subscribe) {
10332
+ if (!this.responsiveBreakpoint) {
10333
+ return;
10279
10334
  }
10280
- return;
10335
+ const responsiveBreakpoint = `(max-width: ${this.responsiveBreakpoint})`;
10336
+ const layoutChanges = this.breakpointObserver.observe([responsiveBreakpoint]);
10337
+ __classPrivateFieldSet(this, _OffcanvasComponent_layoutChangeSubscription, layoutChanges
10338
+ .pipe(filter(breakpointState => !breakpointState.matches))
10339
+ .subscribe((breakpointState) => {
10340
+ this.visible = breakpointState.matches;
10341
+ }), "f");
10281
10342
  }
10282
- if (!this.scroll) {
10283
- this.renderer.removeStyle(this.document.body, 'overflow');
10284
- this.renderer.removeStyle(this.document.body, 'paddingRight');
10343
+ else {
10344
+ __classPrivateFieldGet(this, _OffcanvasComponent_layoutChangeSubscription, "f")?.unsubscribe();
10285
10345
  }
10286
10346
  }
10287
10347
  }
10288
- OffcanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: OffcanvasComponent, deps: [{ token: DOCUMENT }, { token: PLATFORM_ID }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: OffcanvasService }, { token: BackdropService }], target: i0.ɵɵFactoryTarget.Component });
10289
- OffcanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: OffcanvasComponent, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: "keyboard", placement: "placement", scroll: "scroll", id: "id", role: "role", ariaModal: "ariaModal", visible: "visible" }, outputs: { visibleChange: "visibleChange" }, host: { listeners: { "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.animateType" } }, exportAs: ["cOffcanvas"], usesOnChanges: true, ngImport: i0, template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [""], dependencies: [{ kind: "directive", type: i1$3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
10348
+ _OffcanvasComponent_scroll = new WeakMap(), _OffcanvasComponent_visible = new WeakMap(), _OffcanvasComponent_activeBackdrop = new WeakMap(), _OffcanvasComponent_scrollbarWidth = new WeakMap(), _OffcanvasComponent_stateToggleSubscription = new WeakMap(), _OffcanvasComponent_backdropClickSubscription = new WeakMap(), _OffcanvasComponent_layoutChangeSubscription = new WeakMap(), _OffcanvasComponent_show = new WeakMap();
10349
+ OffcanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.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 });
10350
+ OffcanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: OffcanvasComponent, selector: "c-offcanvas", inputs: { backdrop: "backdrop", keyboard: "keyboard", placement: "placement", responsive: "responsive", scroll: "scroll", id: "id", role: "role", ariaModal: "ariaModal", 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: "directive", type: i1$3.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], animations: [
10290
10351
  trigger('showHide', [
10291
- state('true', style({
10292
- visibility: 'visible',
10352
+ state('visible', style({
10353
+ // visibility: 'visible'
10293
10354
  })),
10294
- state('false', style({
10295
- visibility: 'hidden',
10355
+ state('hidden', style({
10356
+ // visibility: 'hidden'
10296
10357
  })),
10297
- transition('true => false', [animate('300ms')]),
10298
- ]),
10358
+ transition('visible <=> *', [animate('300ms')])
10359
+ ])
10299
10360
  ] });
10300
10361
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: OffcanvasComponent, decorators: [{
10301
10362
  type: Component,
10302
10363
  args: [{ selector: 'c-offcanvas', animations: [
10303
10364
  trigger('showHide', [
10304
- state('true', style({
10305
- visibility: 'visible',
10365
+ state('visible', style({
10366
+ // visibility: 'visible'
10306
10367
  })),
10307
- state('false', style({
10308
- visibility: 'hidden',
10368
+ state('hidden', style({
10369
+ // visibility: 'hidden'
10309
10370
  })),
10310
- transition('true => false', [animate('300ms')]),
10311
- ]),
10312
- ], exportAs: 'cOffcanvas', template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n" }]
10313
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
10371
+ transition('visible <=> *', [animate('300ms')])
10372
+ ])
10373
+ ], exportAs: 'cOffcanvas', template: "<div cdkTrapFocus cdkTrapFocusAutoCapture>\n <ng-content></ng-content>\n</div>\n\n", styles: [":host{display:none}\n"] }]
10374
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
10314
10375
  type: Inject,
10315
10376
  args: [DOCUMENT]
10316
10377
  }] }, { type: undefined, decorators: [{
10317
10378
  type: Inject,
10318
10379
  args: [PLATFORM_ID]
10319
- }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: OffcanvasService }, { type: BackdropService }]; }, propDecorators: { backdrop: [{
10380
+ }] }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: OffcanvasService }, { type: BackdropService }, { type: i1$2.BreakpointObserver }]; }, propDecorators: { backdrop: [{
10320
10381
  type: Input
10321
10382
  }], keyboard: [{
10322
10383
  type: Input
10323
10384
  }], placement: [{
10324
10385
  type: Input
10386
+ }], responsive: [{
10387
+ type: Input
10325
10388
  }], scroll: [{
10326
10389
  type: Input
10327
10390
  }], id: [{
@@ -10349,9 +10412,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
10349
10412
  }], tabIndex: [{
10350
10413
  type: HostBinding,
10351
10414
  args: ['attr.tabindex']
10352
- }], animateType: [{
10415
+ }], animateTrigger: [{
10353
10416
  type: HostBinding,
10354
10417
  args: ['@showHide']
10418
+ }], animateStart: [{
10419
+ type: HostListener,
10420
+ args: ['@showHide.start', ['$event']]
10421
+ }], animateDone: [{
10422
+ type: HostListener,
10423
+ args: ['@showHide.done', ['$event']]
10355
10424
  }], onKeyDownHandler: [{
10356
10425
  type: HostListener,
10357
10426
  args: ['document:keydown', ['$event']]
@@ -11515,7 +11584,7 @@ class SidebarComponent {
11515
11584
  }), "f");
11516
11585
  }
11517
11586
  else {
11518
- __classPrivateFieldGet(this, _SidebarComponent_stateToggleSubscription, "f").unsubscribe();
11587
+ __classPrivateFieldGet(this, _SidebarComponent_stateToggleSubscription, "f")?.unsubscribe();
11519
11588
  }
11520
11589
  }
11521
11590
  layoutChangeSubscribe(subscribe = true) {