@progress/kendo-angular-dialog 5.2.0 → 5.2.2

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.
@@ -3,17 +3,19 @@
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 { Injectable } from "@angular/core";
6
+ import { Injectable, NgZone } from "@angular/core";
7
7
  import { DragResizeService } from './drag-resize.service';
8
8
  import { isPresent, OFFSET_STYLES, Keys } from '../common/util';
9
9
  /**
10
10
  * @hidden
11
11
  */
12
12
  var NavigationService = /** @class */ (function () {
13
- function NavigationService(window) {
13
+ function NavigationService(window, ngZone) {
14
14
  this.window = window;
15
+ this.ngZone = ngZone;
15
16
  }
16
17
  NavigationService.prototype.process = function (ev) {
18
+ var _this = this;
17
19
  var key = ev.keyCode;
18
20
  switch (key) {
19
21
  case Keys.up:
@@ -21,11 +23,15 @@ var NavigationService = /** @class */ (function () {
21
23
  case Keys.left:
22
24
  case Keys.right: {
23
25
  ev.preventDefault();
24
- this.handleArrow(key, ev);
26
+ this.ngZone.run(function () {
27
+ _this.handleArrow(key, ev);
28
+ });
25
29
  break;
26
30
  }
27
31
  case Keys.esc:
28
- this.handleEscape();
32
+ this.ngZone.run(function () {
33
+ _this.handleEscape();
34
+ });
29
35
  break;
30
36
  default:
31
37
  break;
@@ -141,7 +147,8 @@ var NavigationService = /** @class */ (function () {
141
147
  };
142
148
  NavigationService = tslib_1.__decorate([
143
149
  Injectable(),
144
- tslib_1.__metadata("design:paramtypes", [DragResizeService])
150
+ tslib_1.__metadata("design:paramtypes", [DragResizeService,
151
+ NgZone])
145
152
  ], NavigationService);
146
153
  return NavigationService;
147
154
  }());
@@ -81,6 +81,7 @@ var WindowComponent = /** @class */ (function () {
81
81
  this.draged = false;
82
82
  this.resized = false;
83
83
  this.windowSubscription = new Subscription();
84
+ this.domSubs = new Subscription();
84
85
  validatePackage(packageMetadata);
85
86
  this.direction = this.localization.rtl ? 'rtl' : 'ltr';
86
87
  this.localizationChangeSubscription = this.localization.changes
@@ -322,6 +323,7 @@ var WindowComponent = /** @class */ (function () {
322
323
  this.ngZone.runOutsideAngular(function () {
323
324
  return Promise.resolve(null).then(function () { return _this.setInitialOffset(); });
324
325
  });
326
+ this.initDomEvents();
325
327
  };
326
328
  WindowComponent.prototype.ngOnInit = function () {
327
329
  this.renderer.removeAttribute(this.el.nativeElement, 'title');
@@ -357,6 +359,9 @@ var WindowComponent = /** @class */ (function () {
357
359
  if (this.windowSubscription) {
358
360
  this.windowSubscription.unsubscribe();
359
361
  }
362
+ if (this.domSubs) {
363
+ this.domSubs.unsubscribe();
364
+ }
360
365
  this.localizationChangeSubscription.unsubscribe();
361
366
  };
362
367
  /**
@@ -442,14 +447,6 @@ var WindowComponent = /** @class */ (function () {
442
447
  enumerable: true,
443
448
  configurable: true
444
449
  });
445
- /**
446
- * @hidden
447
- */
448
- WindowComponent.prototype.onComponentKeydown = function (event) {
449
- if (hasClasses(event.target, WINDOW_CLASSES)) {
450
- this.navigation.process(event);
451
- }
452
- };
453
450
  /**
454
451
  * @hidden
455
452
  */
@@ -524,6 +521,22 @@ var WindowComponent = /** @class */ (function () {
524
521
  }
525
522
  }));
526
523
  };
524
+ WindowComponent.prototype.initDomEvents = function () {
525
+ var _this = this;
526
+ if (!this.el) {
527
+ return;
528
+ }
529
+ this.ngZone.runOutsideAngular(function () {
530
+ _this.domSubs.add(_this.renderer.listen(_this.el.nativeElement, 'keydown', function (ev) {
531
+ _this.onKeyDown(ev);
532
+ }));
533
+ });
534
+ };
535
+ WindowComponent.prototype.onKeyDown = function (event) {
536
+ if (hasClasses(event.target, WINDOW_CLASSES)) {
537
+ this.navigation.process(event);
538
+ }
539
+ };
527
540
  WindowComponent.prototype.setServiceClasses = function (prevValue, value) {
528
541
  var _this = this;
529
542
  var el = this.el.nativeElement;
@@ -752,12 +765,6 @@ var WindowComponent = /** @class */ (function () {
752
765
  tslib_1.__metadata("design:type", Boolean),
753
766
  tslib_1.__metadata("design:paramtypes", [])
754
767
  ], WindowComponent.prototype, "wrapperMinimizedClass", null);
755
- tslib_1.__decorate([
756
- HostListener('keydown', ['$event']),
757
- tslib_1.__metadata("design:type", Function),
758
- tslib_1.__metadata("design:paramtypes", [Object]),
759
- tslib_1.__metadata("design:returntype", void 0)
760
- ], WindowComponent.prototype, "onComponentKeydown", null);
761
768
  tslib_1.__decorate([
762
769
  HostListener('focus'),
763
770
  tslib_1.__metadata("design:type", Function),
@@ -12,10 +12,10 @@ import { DialogAction } from './dialog-settings';
12
12
  * Represents the [Kendo UI Dialog component for Angular]({% slug overview_dialog_dialogs %}).
13
13
  */
14
14
  export declare class DialogComponent implements AfterContentInit, AfterViewInit, OnInit, OnDestroy {
15
- private _elRef;
16
- private _renderer;
15
+ private wrapper;
16
+ private renderer;
17
17
  private cdr;
18
- private zone;
18
+ private ngZone;
19
19
  /**
20
20
  * Specifies the action buttons that will be rendered.
21
21
  */
@@ -115,11 +115,8 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
115
115
  private _cssClass;
116
116
  private direction;
117
117
  private subscriptions;
118
- constructor(_elRef: ElementRef, _renderer: Renderer2, localization: LocalizationService, cdr: ChangeDetectorRef, zone: NgZone);
119
- /**
120
- * @hidden
121
- */
122
- onComponentKeydown(event: any): void;
118
+ private domSubs;
119
+ constructor(wrapper: ElementRef, renderer: Renderer2, localization: LocalizationService, cdr: ChangeDetectorRef, ngZone: NgZone);
123
120
  ngAfterContentInit(): void;
124
121
  ngAfterViewInit(): void;
125
122
  ngOnInit(): void;
@@ -128,6 +125,8 @@ export declare class DialogComponent implements AfterContentInit, AfterViewInit,
128
125
  * Focuses the wrapper of the Dialog component.
129
126
  */
130
127
  focus(): void;
128
+ private initDomEvents;
129
+ private onKeyDown;
131
130
  private setServiceClasses;
132
131
  /**
133
132
  * @hidden
@@ -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, ViewChildren } from '@angular/core';
6
+ import { Component, EventEmitter, HostBinding, Input, ViewChild, Output, ElementRef, Renderer2, 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';
@@ -14,15 +14,16 @@ import { hasClasses, Keys, isPresent, focusableSelector, isFocusable, DIALOG_ELE
14
14
  import { DialogCloseResult } from './dialog-settings';
15
15
  import { DIALOG_LOCALIZATION_SERVICE } from './../localization/dialog-localization.service';
16
16
  import { take } from 'rxjs/operators';
17
+ import { Subscription } from 'rxjs';
17
18
  /**
18
19
  * Represents the [Kendo UI Dialog component for Angular]({% slug overview_dialog_dialogs %}).
19
20
  */
20
21
  let DialogComponent = class DialogComponent {
21
- constructor(_elRef, _renderer, localization, cdr, zone) {
22
- this._elRef = _elRef;
23
- this._renderer = _renderer;
22
+ constructor(wrapper, renderer, localization, cdr, ngZone) {
23
+ this.wrapper = wrapper;
24
+ this.renderer = renderer;
24
25
  this.cdr = cdr;
25
- this.zone = zone;
26
+ this.ngZone = ngZone;
26
27
  /**
27
28
  * Specifies the layout of the action buttons in the Dialog.
28
29
  * This option is only applicable if the action buttons are specified through the `actions` options.
@@ -49,6 +50,7 @@ let DialogComponent = class DialogComponent {
49
50
  this.close = new EventEmitter();
50
51
  this.tabIndex = 0;
51
52
  this.subscriptions = [];
53
+ this.domSubs = new Subscription();
52
54
  validatePackage(packageMetadata);
53
55
  this.direction = localization.rtl ? 'rtl' : 'ltr';
54
56
  this.subscriptions.push(localization.changes.subscribe(({ rtl }) => (this.direction = rtl ? 'rtl' : 'ltr')));
@@ -59,8 +61,8 @@ let DialogComponent = class DialogComponent {
59
61
  * @hidden
60
62
  */
61
63
  set htmlAttributes(attributes) {
62
- setHTMLAttributes(attributes, this._renderer, this._elRef.nativeElement);
63
- const el = this._elRef.nativeElement;
64
+ setHTMLAttributes(attributes, this.renderer, this.wrapper.nativeElement);
65
+ const el = this.wrapper.nativeElement;
64
66
  const dir = el.getAttribute('dir');
65
67
  const tIndex = el.getAttribute('tabindex');
66
68
  if (this.direction !== dir) {
@@ -87,29 +89,9 @@ let DialogComponent = class DialogComponent {
87
89
  get dir() {
88
90
  return this.direction;
89
91
  }
90
- /**
91
- * @hidden
92
- */
93
- onComponentKeydown(event) {
94
- const target = event.target;
95
- const parent = target.parentElement;
96
- if (hasClasses(target, DIALOG_ELEMENTS_HANDLING_ESC_KEY) || hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ESC_KEY)) {
97
- if (event.keyCode === Keys.esc) {
98
- this.close.emit(new DialogCloseResult());
99
- }
100
- }
101
- if (hasClasses(target, 'k-button') &&
102
- hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ARROWS) &&
103
- (event.keyCode === Keys.left || event.keyCode === Keys.right)) {
104
- this.handleActionButtonFocus(parent, event.keyCode);
105
- }
106
- if (event.keyCode === Keys.tab) {
107
- this.keepFocusWithinComponent(target, event);
108
- }
109
- }
110
92
  ngAfterContentInit() {
111
93
  this.bubble('close', this.titlebarContent.first);
112
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-describedby', this.contentId);
94
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-describedby', this.contentId);
113
95
  if (this.titlebarContent.first) {
114
96
  this.titlebarContent.first.id = this.titleId;
115
97
  }
@@ -117,9 +99,9 @@ let DialogComponent = class DialogComponent {
117
99
  this.subscriptions.push(this.titlebarContent.changes.subscribe(() => {
118
100
  if (isPresent(this.titlebarContent.first)) {
119
101
  this.titlebarContent.first.id = this.titleId;
120
- this.zone.onStable.pipe(take(1)).subscribe(() => {
102
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
121
103
  this.bubble('close', this.titlebarContent.first);
122
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
104
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
123
105
  });
124
106
  }
125
107
  }));
@@ -131,47 +113,83 @@ let DialogComponent = class DialogComponent {
131
113
  this.bubble('action', this.actionsView);
132
114
  if (this.titlebarView.first || this.titlebarContent.first) {
133
115
  //Needed for Dialogs created via service
134
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
116
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
135
117
  }
136
118
  else {
137
119
  this.subscriptions.push(this.titlebarView.changes.subscribe(() => {
138
120
  if (isPresent(this.titlebarView.first)) {
139
121
  this.titlebarView.first.id = this.titleId;
140
- this.zone.onStable.pipe(take(1)).subscribe(() => {
122
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
141
123
  this.bubble('close', this.titlebarView.first);
142
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
124
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
143
125
  });
144
126
  }
145
127
  }));
146
128
  }
129
+ this.initDomEvents();
147
130
  }
148
131
  ngOnInit() {
149
- this._renderer.removeAttribute(this._elRef.nativeElement, 'title');
132
+ this.renderer.removeAttribute(this.wrapper.nativeElement, 'title');
150
133
  this.cdr.detectChanges();
151
134
  }
152
135
  ngOnDestroy() {
153
136
  this.subscriptions.forEach(s => s.unsubscribe());
154
137
  this.subscriptions = [];
138
+ if (this.domSubs) {
139
+ this.domSubs.unsubscribe();
140
+ }
155
141
  }
156
142
  /**
157
143
  * Focuses the wrapper of the Dialog component.
158
144
  */
159
145
  focus() {
160
- const wrapper = this._elRef.nativeElement;
146
+ const wrapper = this.wrapper.nativeElement;
161
147
  if (isPresent(wrapper)) {
162
148
  wrapper.focus();
163
149
  }
164
150
  }
151
+ initDomEvents() {
152
+ if (!this.wrapper) {
153
+ return;
154
+ }
155
+ this.ngZone.runOutsideAngular(() => {
156
+ this.domSubs.add(this.renderer.listen(this.wrapper.nativeElement, 'keydown', (ev) => {
157
+ this.onKeyDown(ev);
158
+ }));
159
+ });
160
+ }
161
+ onKeyDown(event) {
162
+ const target = event.target;
163
+ const parent = target.parentElement;
164
+ if (hasClasses(target, DIALOG_ELEMENTS_HANDLING_ESC_KEY) || hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ESC_KEY)) {
165
+ if (event.keyCode === Keys.esc) {
166
+ this.ngZone.run(() => {
167
+ this.close.emit(new DialogCloseResult());
168
+ });
169
+ }
170
+ }
171
+ if (hasClasses(target, 'k-button') && hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ARROWS) &&
172
+ (event.keyCode === Keys.left || event.keyCode === Keys.right)) {
173
+ this.ngZone.run(() => {
174
+ this.handleActionButtonFocus(parent, event.keyCode);
175
+ });
176
+ }
177
+ if (event.keyCode === Keys.tab) {
178
+ this.ngZone.run(() => {
179
+ this.keepFocusWithinComponent(target, event);
180
+ });
181
+ }
182
+ }
165
183
  setServiceClasses(prevValue, value) {
166
- const el = this._elRef.nativeElement;
184
+ const el = this.wrapper.nativeElement;
167
185
  if (prevValue) {
168
186
  parseCSSClassNames(prevValue).forEach(className => {
169
- this._renderer.removeClass(el, className);
187
+ this.renderer.removeClass(el, className);
170
188
  });
171
189
  }
172
190
  if (value) {
173
191
  parseCSSClassNames(value).forEach(className => {
174
- this._renderer.addClass(el, className);
192
+ this.renderer.addClass(el, className);
175
193
  });
176
194
  }
177
195
  }
@@ -179,7 +197,7 @@ let DialogComponent = class DialogComponent {
179
197
  * @hidden
180
198
  */
181
199
  handleInitialFocus() {
182
- const wrapper = this._elRef.nativeElement;
200
+ const wrapper = this.wrapper.nativeElement;
183
201
  const primaryButton = wrapper.querySelector('.k-primary');
184
202
  if (this.autoFocusedElement) {
185
203
  const initiallyFocusedElement = wrapper.querySelector(this.autoFocusedElement);
@@ -217,7 +235,7 @@ let DialogComponent = class DialogComponent {
217
235
  * @hidden
218
236
  */
219
237
  keepFocusWithinComponent(target, event) {
220
- const wrapper = this._elRef.nativeElement;
238
+ const wrapper = this.wrapper.nativeElement;
221
239
  const [firstFocusable, lastFocusable] = this.getFirstAndLastFocusable(wrapper);
222
240
  const tabAfterLastFocusable = !event.shiftKey && target === lastFocusable;
223
241
  const shiftTabAfterFirstFocusable = event.shiftKey && target === firstFocusable;
@@ -365,12 +383,6 @@ tslib_1.__decorate([
365
383
  ViewChild(DialogActionsComponent, { static: false }),
366
384
  tslib_1.__metadata("design:type", DialogActionsComponent)
367
385
  ], DialogComponent.prototype, "actionsView", void 0);
368
- tslib_1.__decorate([
369
- HostListener('keydown', ['$event']),
370
- tslib_1.__metadata("design:type", Function),
371
- tslib_1.__metadata("design:paramtypes", [Object]),
372
- tslib_1.__metadata("design:returntype", void 0)
373
- ], DialogComponent.prototype, "onComponentKeydown", null);
374
386
  tslib_1.__decorate([
375
387
  HostBinding('class.k-dialog-wrapper'),
376
388
  tslib_1.__metadata("design:type", Boolean),