@progress/kendo-angular-dialog 5.2.1 → 5.2.3

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,12 +3,12 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { __decorate, __metadata, __param } from 'tslib';
6
- import { EventEmitter, TemplateRef, Input, Output, HostBinding, Component, ElementRef, InjectionToken, Inject, Optional, NgZone, ContentChildren, QueryList, ViewChildren, ViewChild, HostListener, Renderer2, ChangeDetectorRef, Injectable, isDevMode, ComponentFactoryResolver, Directive, Host, ContentChild, ViewContainerRef, forwardRef, NgModule } from '@angular/core';
6
+ import { EventEmitter, TemplateRef, Input, Output, HostBinding, Component, ElementRef, InjectionToken, Inject, Optional, NgZone, ContentChildren, QueryList, ViewChildren, ViewChild, Renderer2, ChangeDetectorRef, Injectable, isDevMode, ComponentFactoryResolver, Directive, Host, HostListener, ContentChild, ViewContainerRef, forwardRef, NgModule } from '@angular/core';
7
7
  import { trigger, state, style, transition, animate } from '@angular/animations';
8
8
  import { LocalizationService, L10N_PREFIX, RTL, MessageService, ComponentMessages } from '@progress/kendo-angular-l10n';
9
9
  import { take, filter, map, share, tap, switchMap, takeUntil } from 'rxjs/operators';
10
10
  import { validatePackage } from '@progress/kendo-licensing';
11
- import { Subject, merge, Subscription, of } from 'rxjs';
11
+ import { Subscription, Subject, merge, of } from 'rxjs';
12
12
  import { DraggableDirective, isChanged, isDocumentAvailable, DraggableModule } from '@progress/kendo-angular-common';
13
13
  import { offset, scrollPosition, positionWithScroll, getDocumentElement, getWindowViewPort } from '@progress/kendo-popup-common';
14
14
  import { Button } from '@progress/kendo-angular-buttons';
@@ -257,7 +257,7 @@ const packageMetadata = {
257
257
  name: '@progress/kendo-angular-dialog',
258
258
  productName: 'Kendo UI for Angular',
259
259
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
260
- publishDate: 1635940433,
260
+ publishDate: 1637576271,
261
261
  version: '',
262
262
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
263
263
  };
@@ -470,11 +470,11 @@ class DialogRef {
470
470
  * Represents the [Kendo UI Dialog component for Angular]({% slug overview_dialog_dialogs %}).
471
471
  */
472
472
  let DialogComponent = class DialogComponent {
473
- constructor(_elRef, _renderer, localization, cdr, zone) {
474
- this._elRef = _elRef;
475
- this._renderer = _renderer;
473
+ constructor(wrapper, renderer, localization, cdr, ngZone) {
474
+ this.wrapper = wrapper;
475
+ this.renderer = renderer;
476
476
  this.cdr = cdr;
477
- this.zone = zone;
477
+ this.ngZone = ngZone;
478
478
  /**
479
479
  * Specifies the layout of the action buttons in the Dialog.
480
480
  * This option is only applicable if the action buttons are specified through the `actions` options.
@@ -501,6 +501,7 @@ let DialogComponent = class DialogComponent {
501
501
  this.close = new EventEmitter();
502
502
  this.tabIndex = 0;
503
503
  this.subscriptions = [];
504
+ this.domSubs = new Subscription();
504
505
  validatePackage(packageMetadata);
505
506
  this.direction = localization.rtl ? 'rtl' : 'ltr';
506
507
  this.subscriptions.push(localization.changes.subscribe(({ rtl }) => (this.direction = rtl ? 'rtl' : 'ltr')));
@@ -511,8 +512,8 @@ let DialogComponent = class DialogComponent {
511
512
  * @hidden
512
513
  */
513
514
  set htmlAttributes(attributes) {
514
- setHTMLAttributes(attributes, this._renderer, this._elRef.nativeElement);
515
- const el = this._elRef.nativeElement;
515
+ setHTMLAttributes(attributes, this.renderer, this.wrapper.nativeElement);
516
+ const el = this.wrapper.nativeElement;
516
517
  const dir = el.getAttribute('dir');
517
518
  const tIndex = el.getAttribute('tabindex');
518
519
  if (this.direction !== dir) {
@@ -539,29 +540,9 @@ let DialogComponent = class DialogComponent {
539
540
  get dir() {
540
541
  return this.direction;
541
542
  }
542
- /**
543
- * @hidden
544
- */
545
- onComponentKeydown(event) {
546
- const target = event.target;
547
- const parent = target.parentElement;
548
- if (hasClasses(target, DIALOG_ELEMENTS_HANDLING_ESC_KEY) || hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ESC_KEY)) {
549
- if (event.keyCode === Keys.esc) {
550
- this.close.emit(new DialogCloseResult());
551
- }
552
- }
553
- if (hasClasses(target, 'k-button') &&
554
- hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ARROWS) &&
555
- (event.keyCode === Keys.left || event.keyCode === Keys.right)) {
556
- this.handleActionButtonFocus(parent, event.keyCode);
557
- }
558
- if (event.keyCode === Keys.tab) {
559
- this.keepFocusWithinComponent(target, event);
560
- }
561
- }
562
543
  ngAfterContentInit() {
563
544
  this.bubble('close', this.titlebarContent.first);
564
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-describedby', this.contentId);
545
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-describedby', this.contentId);
565
546
  if (this.titlebarContent.first) {
566
547
  this.titlebarContent.first.id = this.titleId;
567
548
  }
@@ -569,9 +550,9 @@ let DialogComponent = class DialogComponent {
569
550
  this.subscriptions.push(this.titlebarContent.changes.subscribe(() => {
570
551
  if (isPresent(this.titlebarContent.first)) {
571
552
  this.titlebarContent.first.id = this.titleId;
572
- this.zone.onStable.pipe(take(1)).subscribe(() => {
553
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
573
554
  this.bubble('close', this.titlebarContent.first);
574
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
555
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
575
556
  });
576
557
  }
577
558
  }));
@@ -583,47 +564,83 @@ let DialogComponent = class DialogComponent {
583
564
  this.bubble('action', this.actionsView);
584
565
  if (this.titlebarView.first || this.titlebarContent.first) {
585
566
  //Needed for Dialogs created via service
586
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
567
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
587
568
  }
588
569
  else {
589
570
  this.subscriptions.push(this.titlebarView.changes.subscribe(() => {
590
571
  if (isPresent(this.titlebarView.first)) {
591
572
  this.titlebarView.first.id = this.titleId;
592
- this.zone.onStable.pipe(take(1)).subscribe(() => {
573
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
593
574
  this.bubble('close', this.titlebarView.first);
594
- this._renderer.setAttribute(this._elRef.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
575
+ this.renderer.setAttribute(this.wrapper.nativeElement.querySelector('.k-dialog'), 'aria-labelledby', this.titleId);
595
576
  });
596
577
  }
597
578
  }));
598
579
  }
580
+ this.initDomEvents();
599
581
  }
600
582
  ngOnInit() {
601
- this._renderer.removeAttribute(this._elRef.nativeElement, 'title');
583
+ this.renderer.removeAttribute(this.wrapper.nativeElement, 'title');
602
584
  this.cdr.detectChanges();
603
585
  }
604
586
  ngOnDestroy() {
605
587
  this.subscriptions.forEach(s => s.unsubscribe());
606
588
  this.subscriptions = [];
589
+ if (this.domSubs) {
590
+ this.domSubs.unsubscribe();
591
+ }
607
592
  }
608
593
  /**
609
594
  * Focuses the wrapper of the Dialog component.
610
595
  */
611
596
  focus() {
612
- const wrapper = this._elRef.nativeElement;
597
+ const wrapper = this.wrapper.nativeElement;
613
598
  if (isPresent(wrapper)) {
614
599
  wrapper.focus();
615
600
  }
616
601
  }
602
+ initDomEvents() {
603
+ if (!this.wrapper) {
604
+ return;
605
+ }
606
+ this.ngZone.runOutsideAngular(() => {
607
+ this.domSubs.add(this.renderer.listen(this.wrapper.nativeElement, 'keydown', (ev) => {
608
+ this.onKeyDown(ev);
609
+ }));
610
+ });
611
+ }
612
+ onKeyDown(event) {
613
+ const target = event.target;
614
+ const parent = target.parentElement;
615
+ if (hasClasses(target, DIALOG_ELEMENTS_HANDLING_ESC_KEY) || hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ESC_KEY)) {
616
+ if (event.keyCode === Keys.esc) {
617
+ this.ngZone.run(() => {
618
+ this.close.emit(new DialogCloseResult());
619
+ });
620
+ }
621
+ }
622
+ if (hasClasses(target, 'k-button') && hasClasses(parent, DIALOG_ELEMENTS_HANDLING_ARROWS) &&
623
+ (event.keyCode === Keys.left || event.keyCode === Keys.right)) {
624
+ this.ngZone.run(() => {
625
+ this.handleActionButtonFocus(parent, event.keyCode);
626
+ });
627
+ }
628
+ if (event.keyCode === Keys.tab) {
629
+ this.ngZone.run(() => {
630
+ this.keepFocusWithinComponent(target, event);
631
+ });
632
+ }
633
+ }
617
634
  setServiceClasses(prevValue, value) {
618
- const el = this._elRef.nativeElement;
635
+ const el = this.wrapper.nativeElement;
619
636
  if (prevValue) {
620
637
  parseCSSClassNames(prevValue).forEach(className => {
621
- this._renderer.removeClass(el, className);
638
+ this.renderer.removeClass(el, className);
622
639
  });
623
640
  }
624
641
  if (value) {
625
642
  parseCSSClassNames(value).forEach(className => {
626
- this._renderer.addClass(el, className);
643
+ this.renderer.addClass(el, className);
627
644
  });
628
645
  }
629
646
  }
@@ -631,7 +648,7 @@ let DialogComponent = class DialogComponent {
631
648
  * @hidden
632
649
  */
633
650
  handleInitialFocus() {
634
- const wrapper = this._elRef.nativeElement;
651
+ const wrapper = this.wrapper.nativeElement;
635
652
  const primaryButton = wrapper.querySelector('.k-primary');
636
653
  if (this.autoFocusedElement) {
637
654
  const initiallyFocusedElement = wrapper.querySelector(this.autoFocusedElement);
@@ -669,7 +686,7 @@ let DialogComponent = class DialogComponent {
669
686
  * @hidden
670
687
  */
671
688
  keepFocusWithinComponent(target, event) {
672
- const wrapper = this._elRef.nativeElement;
689
+ const wrapper = this.wrapper.nativeElement;
673
690
  const [firstFocusable, lastFocusable] = this.getFirstAndLastFocusable(wrapper);
674
691
  const tabAfterLastFocusable = !event.shiftKey && target === lastFocusable;
675
692
  const shiftTabAfterFirstFocusable = event.shiftKey && target === firstFocusable;
@@ -817,12 +834,6 @@ __decorate([
817
834
  ViewChild(DialogActionsComponent, { static: false }),
818
835
  __metadata("design:type", DialogActionsComponent)
819
836
  ], DialogComponent.prototype, "actionsView", void 0);
820
- __decorate([
821
- HostListener('keydown', ['$event']),
822
- __metadata("design:type", Function),
823
- __metadata("design:paramtypes", [Object]),
824
- __metadata("design:returntype", void 0)
825
- ], DialogComponent.prototype, "onComponentKeydown", null);
826
837
  __decorate([
827
838
  HostBinding('class.k-dialog-wrapper'),
828
839
  __metadata("design:type", Boolean),
@@ -1648,8 +1659,9 @@ WindowTitleBarComponent = __decorate([
1648
1659
  * @hidden
1649
1660
  */
1650
1661
  let NavigationService = class NavigationService {
1651
- constructor(window) {
1662
+ constructor(window, ngZone) {
1652
1663
  this.window = window;
1664
+ this.ngZone = ngZone;
1653
1665
  }
1654
1666
  process(ev) {
1655
1667
  const key = ev.keyCode;
@@ -1659,11 +1671,15 @@ let NavigationService = class NavigationService {
1659
1671
  case Keys.left:
1660
1672
  case Keys.right: {
1661
1673
  ev.preventDefault();
1662
- this.handleArrow(key, ev);
1674
+ this.ngZone.run(() => {
1675
+ this.handleArrow(key, ev);
1676
+ });
1663
1677
  break;
1664
1678
  }
1665
1679
  case Keys.esc:
1666
- this.handleEscape();
1680
+ this.ngZone.run(() => {
1681
+ this.handleEscape();
1682
+ });
1667
1683
  break;
1668
1684
  default:
1669
1685
  break;
@@ -1779,7 +1795,8 @@ let NavigationService = class NavigationService {
1779
1795
  };
1780
1796
  NavigationService = __decorate([
1781
1797
  Injectable(),
1782
- __metadata("design:paramtypes", [DragResizeService])
1798
+ __metadata("design:paramtypes", [DragResizeService,
1799
+ NgZone])
1783
1800
  ], NavigationService);
1784
1801
 
1785
1802
  /**
@@ -1843,10 +1860,15 @@ let WindowComponent = class WindowComponent {
1843
1860
  * two-way binding of the `state` property.
1844
1861
  */
1845
1862
  this.stateChange = new EventEmitter();
1863
+ /**
1864
+ * @hidden
1865
+ */
1866
+ this.messages = {};
1846
1867
  this.tabIndex = 0;
1847
1868
  this.draged = false;
1848
1869
  this.resized = false;
1849
1870
  this.windowSubscription = new Subscription();
1871
+ this.domSubs = new Subscription();
1850
1872
  validatePackage(packageMetadata);
1851
1873
  this.direction = this.localization.rtl ? 'rtl' : 'ltr';
1852
1874
  this.localizationChangeSubscription = this.localization.changes
@@ -2014,6 +2036,7 @@ let WindowComponent = class WindowComponent {
2014
2036
  this.setNextZIndex();
2015
2037
  this.handleInitialFocus();
2016
2038
  this.ngZone.runOutsideAngular(() => Promise.resolve(null).then(() => this.setInitialOffset()));
2039
+ this.initDomEvents();
2017
2040
  }
2018
2041
  ngOnInit() {
2019
2042
  this.renderer.removeAttribute(this.el.nativeElement, 'title');
@@ -2048,6 +2071,9 @@ let WindowComponent = class WindowComponent {
2048
2071
  if (this.windowSubscription) {
2049
2072
  this.windowSubscription.unsubscribe();
2050
2073
  }
2074
+ if (this.domSubs) {
2075
+ this.domSubs.unsubscribe();
2076
+ }
2051
2077
  this.localizationChangeSubscription.unsubscribe();
2052
2078
  }
2053
2079
  /**
@@ -2109,14 +2135,6 @@ let WindowComponent = class WindowComponent {
2109
2135
  get wrapperMinimizedClass() {
2110
2136
  return this.state === 'minimized';
2111
2137
  }
2112
- /**
2113
- * @hidden
2114
- */
2115
- onComponentKeydown(event) {
2116
- if (hasClasses(event.target, WINDOW_CLASSES)) {
2117
- this.navigation.process(event);
2118
- }
2119
- }
2120
2138
  /**
2121
2139
  * @hidden
2122
2140
  */
@@ -2190,6 +2208,21 @@ let WindowComponent = class WindowComponent {
2190
2208
  }
2191
2209
  }));
2192
2210
  }
2211
+ initDomEvents() {
2212
+ if (!this.el) {
2213
+ return;
2214
+ }
2215
+ this.ngZone.runOutsideAngular(() => {
2216
+ this.domSubs.add(this.renderer.listen(this.el.nativeElement, 'keydown', (ev) => {
2217
+ this.onKeyDown(ev);
2218
+ }));
2219
+ });
2220
+ }
2221
+ onKeyDown(event) {
2222
+ if (hasClasses(event.target, WINDOW_CLASSES)) {
2223
+ this.navigation.process(event);
2224
+ }
2225
+ }
2193
2226
  setServiceClasses(prevValue, value) {
2194
2227
  const el = this.el.nativeElement;
2195
2228
  if (prevValue) {
@@ -2413,12 +2446,6 @@ __decorate([
2413
2446
  __metadata("design:type", Boolean),
2414
2447
  __metadata("design:paramtypes", [])
2415
2448
  ], WindowComponent.prototype, "wrapperMinimizedClass", null);
2416
- __decorate([
2417
- HostListener('keydown', ['$event']),
2418
- __metadata("design:type", Function),
2419
- __metadata("design:paramtypes", [Object]),
2420
- __metadata("design:returntype", void 0)
2421
- ], WindowComponent.prototype, "onComponentKeydown", null);
2422
2449
  __decorate([
2423
2450
  HostListener('focus'),
2424
2451
  __metadata("design:type", Function),