@progress/kendo-angular-dialog 5.2.0-dev.202109270843 → 5.2.1-dev.202110281710

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.
@@ -2,7 +2,7 @@
2
2
  * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { AfterContentInit, AfterViewInit, EventEmitter, OnInit, OnDestroy, ElementRef, TemplateRef, Renderer2, ChangeDetectorRef, OnChanges, SimpleChanges, NgZone, QueryList } from '@angular/core';
5
+ import { AfterContentInit, AfterViewInit, EventEmitter, OnInit, OnDestroy, ElementRef, TemplateRef, Renderer2, ChangeDetectorRef, NgZone, QueryList } from '@angular/core';
6
6
  import { DialogActionsComponent } from './dialog-actions.component';
7
7
  import { DialogTitleBarComponent } from './dialog-titlebar.component';
8
8
  import { LocalizationService } from '@progress/kendo-angular-l10n';
@@ -11,7 +11,7 @@ import { DialogAction } from './dialog-settings';
11
11
  /**
12
12
  * Represents the [Kendo UI Dialog component for Angular]({% slug overview_dialog_dialogs %}).
13
13
  */
14
- export declare class DialogComponent implements AfterContentInit, AfterViewInit, OnInit, OnChanges, OnDestroy {
14
+ export declare class DialogComponent implements AfterContentInit, AfterViewInit, OnInit, OnDestroy {
15
15
  private _elRef;
16
16
  private _renderer;
17
17
  private cdr;
@@ -89,6 +89,10 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
89
89
  * @hidden
90
90
  */
91
91
  titleId: string;
92
+ /**
93
+ * @hidden
94
+ */
95
+ contentId: string;
92
96
  /**
93
97
  * @hidden
94
98
  */
@@ -99,13 +103,13 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
99
103
  */
100
104
  action: EventEmitter<DialogAction>;
101
105
  /**
102
- * Fires when the user clicks the **Close** button of the Dialog.
106
+ * Fires when the user clicks the **Close** button of the Dialog or the **ESC** key.
103
107
  */
104
108
  close: EventEmitter<any>;
105
109
  readonly dir: string;
106
110
  tabIndex: number;
107
111
  titlebarContent: QueryList<DialogTitleBarComponent>;
108
- titlebarView: DialogTitleBarComponent;
112
+ titlebarView: QueryList<DialogTitleBarComponent>;
109
113
  actionsView: DialogActionsComponent;
110
114
  private _htmlAttributes;
111
115
  private _cssClass;
@@ -117,7 +121,6 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
117
121
  */
118
122
  onComponentKeydown(event: any): void;
119
123
  ngAfterContentInit(): void;
120
- ngOnChanges(changes: SimpleChanges): void;
121
124
  ngAfterViewInit(): void;
122
125
  ngOnInit(): void;
123
126
  ngOnDestroy(): void;
@@ -149,11 +152,15 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
149
152
  /**
150
153
  * @hidden
151
154
  */
152
- private getLastFocusableElement;
155
+ private getFirstAndLastFocusable;
153
156
  /**
154
157
  * @hidden
155
158
  */
156
159
  private generateTitleId;
160
+ /**
161
+ * @hidden
162
+ */
163
+ private generateContentId;
157
164
  readonly wrapperClass: boolean;
158
165
  readonly styles: any;
159
166
  private bubble;
@@ -3,7 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import * as tslib_1 from "tslib";
6
- import { Component, EventEmitter, HostBinding, Input, ViewChild, Output, ElementRef, Renderer2, HostListener, ChangeDetectorRef, NgZone, ContentChildren, QueryList } from '@angular/core';
6
+ import { Component, EventEmitter, HostBinding, Input, ViewChild, Output, ElementRef, Renderer2, HostListener, ChangeDetectorRef, NgZone, ContentChildren, QueryList, ViewChildren } from '@angular/core';
7
7
  import { animate, state, style, transition, trigger } from '@angular/animations';
8
8
  import { DialogActionsComponent } from './dialog-actions.component';
9
9
  import { DialogTitleBarComponent } from './dialog-titlebar.component';
@@ -34,13 +34,17 @@ let DialogComponent = class DialogComponent {
34
34
  * @hidden
35
35
  */
36
36
  this.titleId = null;
37
+ /**
38
+ * @hidden
39
+ */
40
+ this.contentId = null;
37
41
  /**
38
42
  * Fires when the user clicks an action button of the Dialog.
39
43
  * The event is fired only when the action buttons are specified through the `actions` options.
40
44
  */
41
45
  this.action = new EventEmitter();
42
46
  /**
43
- * Fires when the user clicks the **Close** button of the Dialog.
47
+ * Fires when the user clicks the **Close** button of the Dialog or the **ESC** key.
44
48
  */
45
49
  this.close = new EventEmitter();
46
50
  this.tabIndex = 0;
@@ -49,6 +53,7 @@ let DialogComponent = class DialogComponent {
49
53
  this.direction = localization.rtl ? 'rtl' : 'ltr';
50
54
  this.subscriptions.push(localization.changes.subscribe(({ rtl }) => (this.direction = rtl ? 'rtl' : 'ltr')));
51
55
  this.titleId = this.generateTitleId();
56
+ this.contentId = this.generateContentId();
52
57
  }
53
58
  /**
54
59
  * @hidden
@@ -104,6 +109,7 @@ let DialogComponent = class DialogComponent {
104
109
  }
105
110
  ngAfterContentInit() {
106
111
  this.bubble('close', this.titlebarContent.first);
112
+ this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-describedby', this.contentId);
107
113
  if (this.titlebarContent.first) {
108
114
  this.titlebarContent.first.id = this.titleId;
109
115
  }
@@ -119,22 +125,25 @@ let DialogComponent = class DialogComponent {
119
125
  }));
120
126
  }
121
127
  }
122
- ngOnChanges(changes) {
123
- if (changes.title && changes.title.currentValue && !changes.title.previousValue) {
124
- this.zone.onStable.pipe(take(1)).subscribe(() => {
125
- this.bubble('close', this.titlebarView);
126
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
127
- });
128
- }
129
- }
130
128
  ngAfterViewInit() {
131
129
  this.handleInitialFocus();
132
- this.bubble('close', this.titlebarView);
130
+ this.bubble('close', this.titlebarView.first);
133
131
  this.bubble('action', this.actionsView);
134
- if (this.titlebarView || this.titlebarContent.first) {
132
+ if (this.titlebarView.first || this.titlebarContent.first) {
135
133
  //Needed for Dialogs created via service
136
134
  this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
137
135
  }
136
+ else {
137
+ this.subscriptions.push(this.titlebarView.changes.subscribe(() => {
138
+ if (isPresent(this.titlebarView.first)) {
139
+ this.titlebarView.first.id = this.titleId;
140
+ this.zone.onStable.pipe(take(1)).subscribe(() => {
141
+ this.bubble('close', this.titlebarView.first);
142
+ this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
143
+ });
144
+ }
145
+ }));
146
+ }
138
147
  }
139
148
  ngOnInit() {
140
149
  this._renderer.removeAttribute(this._elRef.nativeElement, 'title');
@@ -208,16 +217,15 @@ let DialogComponent = class DialogComponent {
208
217
  * @hidden
209
218
  */
210
219
  keepFocusWithinComponent(target, event) {
211
- const firstFocusable = this._elRef.nativeElement;
212
- const lastFocusable = this.getLastFocusableElement(firstFocusable);
213
- const tabBeforeFirstFocusable = target === firstFocusable && event.shiftKey;
214
- const tabAfterLastFocusable = !event.shiftKey && isPresent(lastFocusable) && target === lastFocusable;
215
- const tabWithNoFocusable = !isPresent(lastFocusable) && !event.shiftKey;
216
- if (tabBeforeFirstFocusable || tabWithNoFocusable) {
220
+ const wrapper = this._elRef.nativeElement;
221
+ const [firstFocusable, lastFocusable] = this.getFirstAndLastFocusable(wrapper);
222
+ const tabAfterLastFocusable = !event.shiftKey && target === lastFocusable;
223
+ const shiftTabAfterFirstFocusable = event.shiftKey && target === firstFocusable;
224
+ if (tabAfterLastFocusable) {
217
225
  event.preventDefault();
218
226
  firstFocusable.focus();
219
227
  }
220
- if (tabAfterLastFocusable) {
228
+ if (shiftTabAfterFirstFocusable) {
221
229
  event.preventDefault();
222
230
  lastFocusable.focus();
223
231
  }
@@ -237,9 +245,11 @@ let DialogComponent = class DialogComponent {
237
245
  /**
238
246
  * @hidden
239
247
  */
240
- getLastFocusableElement(parent) {
248
+ getFirstAndLastFocusable(parent) {
241
249
  const all = this.getAllFocusableChildren(parent);
242
- return all.length > 0 ? all[all.length - 1] : null;
250
+ const firstFocusable = all.length > 0 ? all[0] : parent;
251
+ const lastFocusable = all.length > 0 ? all[all.length - 1] : parent;
252
+ return [firstFocusable, lastFocusable];
243
253
  }
244
254
  /**
245
255
  * @hidden
@@ -247,6 +257,12 @@ let DialogComponent = class DialogComponent {
247
257
  generateTitleId() {
248
258
  return 'kendo-dialog-title-' + Math.ceil(Math.random() * 1000000).toString();
249
259
  }
260
+ /**
261
+ * @hidden
262
+ */
263
+ generateContentId() {
264
+ return 'kendo-dialog-content-' + Math.ceil(Math.random() * 1000000).toString();
265
+ }
250
266
  get wrapperClass() {
251
267
  return true;
252
268
  }
@@ -342,8 +358,8 @@ tslib_1.__decorate([
342
358
  tslib_1.__metadata("design:type", QueryList)
343
359
  ], DialogComponent.prototype, "titlebarContent", void 0);
344
360
  tslib_1.__decorate([
345
- ViewChild(DialogTitleBarComponent, { static: false }),
346
- tslib_1.__metadata("design:type", DialogTitleBarComponent)
361
+ ViewChildren(DialogTitleBarComponent),
362
+ tslib_1.__metadata("design:type", QueryList)
347
363
  ], DialogComponent.prototype, "titlebarView", void 0);
348
364
  tslib_1.__decorate([
349
365
  ViewChild(DialogActionsComponent, { static: false }),
@@ -393,11 +409,11 @@ DialogComponent = tslib_1.__decorate([
393
409
  >
394
410
  <div class="k-overlay" @overlayAppear></div>
395
411
 
396
- <div class="k-window k-dialog" role="dialog" [ngStyle]="styles" @dialogSlideInAppear>
412
+ <div class="k-window k-dialog" role="dialog" aria-modal="true" [ngStyle]="styles" @dialogSlideInAppear>
397
413
  <kendo-dialog-titlebar *ngIf="title" [closeTitle]="closeTitle" [id]="titleId">{{ title }}</kendo-dialog-titlebar>
398
414
  <ng-content select="kendo-dialog-titlebar" *ngIf="!title"></ng-content>
399
415
 
400
- <div class="k-content k-window-content k-dialog-content">
416
+ <div [id]="contentId" class="k-content k-window-content k-dialog-content">
401
417
  <ng-content *ngIf="!contentTemplate"></ng-content>
402
418
  <ng-template [ngTemplateOutlet]="contentTemplate" *ngIf="contentTemplate"></ng-template>
403
419
  </div>