@progress/kendo-angular-buttons 8.0.1-dev.202208111121 → 8.1.0

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.
@@ -10,20 +10,20 @@ import { FocusService } from './../focusable/focus.service';
10
10
  import { NavigationService } from './../navigation/navigation.service';
11
11
  import { NAVIGATION_CONFIG } from './../navigation/navigation-config';
12
12
  import { isDocumentAvailable, guid, isChanged } from '@progress/kendo-angular-common';
13
- import { isPresent, tick } from './../util';
14
- import { PreventableEvent } from '../preventable-event';
13
+ import { closest, isPresent } from './../util';
15
14
  import { Keys } from '@progress/kendo-angular-common';
16
15
  import { replaceMessagePlaceholder, getStylingClasses } from '../util';
17
- import { Subscription } from 'rxjs';
16
+ import { PopupContainerService } from '../listbutton/container.service';
18
17
  import * as i0 from "@angular/core";
19
18
  import * as i1 from "./../focusable/focus.service";
20
19
  import * as i2 from "./../navigation/navigation.service";
21
20
  import * as i3 from "@progress/kendo-angular-popup";
22
21
  import * as i4 from "@progress/kendo-angular-l10n";
23
- import * as i5 from "../listbutton/list.component";
24
- import * as i6 from "./localization/localized-messages.directive";
25
- import * as i7 from "../button/button.directive";
26
- import * as i8 from "@angular/common";
22
+ import * as i5 from "../listbutton/container.service";
23
+ import * as i6 from "../listbutton/list.component";
24
+ import * as i7 from "./localization/localized-messages.directive";
25
+ import * as i8 from "../button/button.directive";
26
+ import * as i9 from "@angular/common";
27
27
  const NAVIGATION_SETTINGS = {
28
28
  useLeftRightArrows: true
29
29
  };
@@ -75,10 +75,8 @@ const DEFAULT_FILL_MODE = 'solid';
75
75
  * ```
76
76
  */
77
77
  export class SplitButtonComponent extends ListButton {
78
- constructor(focusService, navigationService, wrapperRef, zone, popupService, elRef, localization, cdr, renderer) {
79
- super(focusService, navigationService, wrapperRef, zone, localization, cdr);
80
- this.popupService = popupService;
81
- this.elRef = elRef;
78
+ constructor(focusService, navigationService, wrapperRef, zone, popupService, elRef, localization, cdr, renderer, containerService) {
79
+ super(focusService, navigationService, wrapperRef, zone, popupService, elRef, localization, cdr, containerService);
82
80
  this.localization = localization;
83
81
  this.renderer = renderer;
84
82
  /**
@@ -218,10 +216,9 @@ export class SplitButtonComponent extends ListButton {
218
216
  this.activeArrow = false;
219
217
  this.listId = guid();
220
218
  this.buttonText = '';
221
- this.lockFocus = false;
219
+ this.arrowButtonClicked = false;
222
220
  this._rounded = DEFAULT_ROUNDED;
223
221
  this._fillMode = DEFAULT_FILL_MODE;
224
- this.popupSubs = new Subscription();
225
222
  this._itemClick = this.itemClick;
226
223
  this._blur = this.onBlur;
227
224
  }
@@ -303,31 +300,6 @@ export class SplitButtonComponent extends ListButton {
303
300
  }
304
301
  return this._data;
305
302
  }
306
- /**
307
- * @hidden
308
- */
309
- set openState(open) {
310
- if (this.disabled) {
311
- return;
312
- }
313
- const eventArgs = new PreventableEvent();
314
- if (open) {
315
- this.open.emit(eventArgs);
316
- }
317
- else {
318
- this.close.emit(eventArgs);
319
- }
320
- if (eventArgs.isDefaultPrevented()) {
321
- return;
322
- }
323
- this._toggle(open);
324
- }
325
- /**
326
- * @hidden
327
- */
328
- get openState() {
329
- return this._open;
330
- }
331
303
  /**
332
304
  * @hidden
333
305
  */
@@ -344,7 +316,7 @@ export class SplitButtonComponent extends ListButton {
344
316
  this._isFocused = value;
345
317
  }
346
318
  get isFocused() {
347
- return this._isFocused && !this._disabled;
319
+ return this._isFocused && !this._disabled && isDocumentAvailable() && this.wrapperContains(document.activeElement);
348
320
  }
349
321
  get widgetClasses() {
350
322
  return true;
@@ -362,18 +334,24 @@ export class SplitButtonComponent extends ListButton {
362
334
  /**
363
335
  * @hidden
364
336
  */
365
- onButtonFocus() {
366
- if (!this.isFocused) {
337
+ onButtonFocus(event) {
338
+ if (!this._disabled) {
339
+ // eslint-disable-next-line no-unused-expressions
340
+ !this._isFocused && this.onFocus.emit();
367
341
  this._isFocused = true;
368
- this.onFocus.emit();
342
+ this.focusService.resetFocus();
343
+ const relatedTargetInList = event.relatedTarget && closest(event.relatedTarget, '.k-popup kendo-button-list');
344
+ if (this.openState && !relatedTargetInList) {
345
+ this.focusService.focus(0);
346
+ }
369
347
  }
370
348
  }
371
349
  /**
372
350
  * @hidden
373
351
  */
374
352
  onArrowButtonClick() {
375
- this.lockFocus = true;
376
353
  this.togglePopupVisibility();
354
+ this.arrowButtonClicked = false;
377
355
  }
378
356
  /**
379
357
  * @hidden
@@ -385,23 +363,23 @@ export class SplitButtonComponent extends ListButton {
385
363
  * @hidden
386
364
  */
387
365
  toggleArrowButtonActiveState(enable) {
366
+ this.arrowButtonClicked = true;
388
367
  this.activeArrow = enable;
389
368
  }
390
369
  /**
391
370
  * @hidden
392
371
  */
393
372
  onButtonClick() {
394
- this.lockFocus = true;
373
+ // this.lockFocus = true;
395
374
  this.buttonClick.emit();
396
375
  }
397
376
  /**
398
377
  * @hidden
399
378
  */
400
379
  onButtonBlur() {
401
- if (!this.isOpen && !this.lockFocus) {
380
+ if (!this.isOpen && !this.arrowButtonClicked) {
402
381
  this.blurWrapper();
403
382
  }
404
- this.lockFocus = false;
405
383
  }
406
384
  /**
407
385
  * @hidden
@@ -412,12 +390,6 @@ export class SplitButtonComponent extends ListButton {
412
390
  this._active = true;
413
391
  }
414
392
  }
415
- /**
416
- * @hidden
417
- */
418
- keypress(event) {
419
- this.keyPressHandler(event);
420
- }
421
393
  /**
422
394
  * @hidden
423
395
  */
@@ -431,6 +403,8 @@ export class SplitButtonComponent extends ListButton {
431
403
  * @hidden
432
404
  */
433
405
  ngAfterViewInit() {
406
+ this.containerService.container = this.containerRef;
407
+ this.containerService.template = this.popupTemplate;
434
408
  this.updateButtonText();
435
409
  this.handleClasses(this.rounded, 'rounded');
436
410
  }
@@ -449,14 +423,22 @@ export class SplitButtonComponent extends ListButton {
449
423
  popup.popupAlign = this.popupAlign;
450
424
  }
451
425
  }
426
+ /**
427
+ * @hidden
428
+ */
429
+ onNavigationEnterUp(args) {
430
+ if (args.target !== this.button.nativeElement) {
431
+ super.onNavigationEnterUp();
432
+ }
433
+ }
452
434
  /**
453
435
  * @hidden
454
436
  */
455
437
  togglePopupVisibility() {
456
- super.togglePopupVisibility();
457
- if (isDocumentAvailable() && this.lockFocus) {
438
+ if (isDocumentAvailable() && this.wrapperContains(document.activeElement) && this.arrowButtonClicked) {
458
439
  this.button.nativeElement.focus();
459
440
  }
441
+ super.togglePopupVisibility();
460
442
  }
461
443
  /**
462
444
  * @hidden
@@ -501,86 +483,22 @@ export class SplitButtonComponent extends ListButton {
501
483
  this.blurWrapper();
502
484
  }
503
485
  }
504
- ngOnDestroy() {
505
- super.ngOnDestroy();
506
- this.destroyPopup();
507
- }
508
- /**
509
- * Toggles the visibility of the popup.
510
- * If the `toggle` method is used to open or close the popup, the `open` and `close` events will not be fired.
511
- *
512
- * @param open - The state of the popup.
513
- */
514
- toggle(open) {
515
- if (this.disabled) {
516
- return;
517
- }
518
- tick(() => this._toggle(open === undefined ? !this._open : open));
519
- }
520
486
  /**
521
487
  * Returns the current open state of the popup.
522
488
  */
523
489
  get isOpen() {
524
490
  return this.openState;
525
491
  }
526
- enterHandler() {
527
- if (this.disabled) {
528
- return;
529
- }
530
- if (this.openState) {
531
- let focused = this.focusService.focused;
532
- if (isPresent(focused) && focused !== -1) {
533
- this.emitItemClickHandler(focused);
534
- }
535
- }
536
- else {
537
- this.buttonClick.emit();
538
- }
539
- }
540
492
  updateButtonText() {
541
493
  if (isDocumentAvailable()) {
542
494
  let innerText = this.wrapper.innerText
543
495
  .split('\n')
544
496
  .join('')
545
497
  .trim();
546
- //setTimout is needed because of `Expression has changed after it was checked.` error;
498
+ //setTimeout is needed because of `Expression has changed after it was checked.` error;
547
499
  setTimeout(() => (this.buttonText = innerText), 0);
548
500
  }
549
501
  }
550
- get appendTo() {
551
- const { appendTo } = this.popupSettings;
552
- if (!appendTo || appendTo === 'root') {
553
- return undefined;
554
- }
555
- return appendTo === 'component' ? this.containerRef : appendTo;
556
- }
557
- _toggle(open) {
558
- this._open = open;
559
- this.destroyPopup();
560
- if (this._open) {
561
- this.createPopup();
562
- }
563
- }
564
- createPopup() {
565
- this.popupRef = this.popupService.open({
566
- anchor: this.elRef,
567
- anchorAlign: this.anchorAlign,
568
- animate: this.popupSettings.animate,
569
- appendTo: this.appendTo,
570
- content: this.popupTemplate,
571
- popupAlign: this.popupAlign,
572
- popupClass: this.popupClasses
573
- });
574
- this.popupSubs.add(this.popupRef.popupAnchorViewportLeave.subscribe(() => (this.openState = false)));
575
- this.popupSubs.add(this.popupRef.popupOpen.subscribe(this.focusFirstItem.bind(this)));
576
- }
577
- destroyPopup() {
578
- if (this.popupRef) {
579
- this.popupSubs.unsubscribe();
580
- this.popupRef.close();
581
- this.popupRef = null;
582
- }
583
- }
584
502
  handleClasses(value, input) {
585
503
  const elem = this.wrapperRef.nativeElement;
586
504
  const classes = getStylingClasses('button', input, this[input], value);
@@ -592,8 +510,8 @@ export class SplitButtonComponent extends ListButton {
592
510
  }
593
511
  }
594
512
  }
595
- SplitButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SplitButtonComponent, deps: [{ token: i1.FocusService }, { token: i2.NavigationService }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i3.PopupService }, { token: i0.ElementRef }, { token: i4.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
596
- SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SplitButtonComponent, selector: "kendo-splitbutton", inputs: { text: "text", icon: "icon", iconClass: "iconClass", type: "type", imageUrl: "imageUrl", size: "size", rounded: "rounded", fillMode: "fillMode", themeColor: "themeColor", disabled: "disabled", popupSettings: "popupSettings", tabIndex: "tabIndex", textField: "textField", data: "data", buttonClass: "buttonClass", arrowButtonClass: "arrowButtonClass", arrowButtonIcon: "arrowButtonIcon" }, outputs: { buttonClick: "buttonClick", itemClick: "itemClick", onFocus: "focus", onBlur: "blur", open: "open", close: "close" }, host: { listeners: { "keydown": "keydown($event)", "keypress": "keypress($event)", "keyup": "keyup($event)" }, properties: { "class.k-focus": "this.isFocused", "class.k-split-button": "this.widgetClasses", "class.k-button-group": "this.widgetClasses", "attr.dir": "this.dir" } }, providers: [
513
+ SplitButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SplitButtonComponent, deps: [{ token: i1.FocusService }, { token: i2.NavigationService }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i3.PopupService }, { token: i0.ElementRef }, { token: i4.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }, { token: i5.PopupContainerService }], target: i0.ɵɵFactoryTarget.Component });
514
+ SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SplitButtonComponent, selector: "kendo-splitbutton", inputs: { text: "text", icon: "icon", iconClass: "iconClass", type: "type", imageUrl: "imageUrl", size: "size", rounded: "rounded", fillMode: "fillMode", themeColor: "themeColor", disabled: "disabled", popupSettings: "popupSettings", tabIndex: "tabIndex", textField: "textField", data: "data", buttonClass: "buttonClass", arrowButtonClass: "arrowButtonClass", arrowButtonIcon: "arrowButtonIcon" }, outputs: { buttonClick: "buttonClick", itemClick: "itemClick", onFocus: "focus", onBlur: "blur", open: "open", close: "close" }, host: { listeners: { "keydown": "keydown($event)", "keyup": "keyup($event)" }, properties: { "class.k-focus": "this.isFocused", "class.k-split-button": "this.widgetClasses", "class.k-button-group": "this.widgetClasses", "attr.dir": "this.dir" } }, providers: [
597
515
  FocusService,
598
516
  NavigationService,
599
517
  NAVIGATION_SETTINGS_PROVIDER,
@@ -601,8 +519,9 @@ SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", v
601
519
  {
602
520
  provide: L10N_PREFIX,
603
521
  useValue: 'kendo.splitbutton'
604
- }
605
- ], queries: [{ propertyName: "itemTemplate", first: true, predicate: ButtonItemTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "button", first: true, predicate: ["button"], descendants: true, static: true }, { propertyName: "arrowButton", first: true, predicate: ["arrowButton"], descendants: true, read: ElementRef, static: true }, { propertyName: "popupTemplate", first: true, predicate: ["popupTemplate"], descendants: true, static: true }, { propertyName: "containerRef", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], exportAs: ["kendoSplitButton"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
522
+ },
523
+ PopupContainerService
524
+ ], queries: [{ propertyName: "itemTemplate", first: true, predicate: ButtonItemTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "button", first: true, predicate: ["button"], descendants: true }, { propertyName: "arrowButton", first: true, predicate: ["arrowButton"], descendants: true, read: ElementRef }, { propertyName: "popupTemplate", first: true, predicate: ["popupTemplate"], descendants: true }, { propertyName: "containerRef", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef }], exportAs: ["kendoSplitButton"], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
606
525
  <ng-container kendoSplitButtonLocalizedMessages
607
526
  i18n-splitButtonLabel="kendo.splitbutton.splitButtonLabel|The text for the SplitButton aria-label"
608
527
  splitButtonLabel="{{ '{buttonText} splitbutton' }}">
@@ -623,7 +542,7 @@ SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", v
623
542
  [iconClass]="iconClass"
624
543
  [imageUrl]="imageUrl"
625
544
  [ngClass]="buttonClass"
626
- (focus)="onButtonFocus()"
545
+ (focus)="onButtonFocus($event)"
627
546
  (click)="onButtonClick()"
628
547
  (blur)="onButtonBlur()"
629
548
  (mousedown)="toggleButtonActiveState(true)"
@@ -661,7 +580,6 @@ SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", v
661
580
  [itemTemplate]="itemTemplate"
662
581
  (onItemClick)="onItemClick($event)"
663
582
  (keydown)="keyDownHandler($event)"
664
- (keypress)="keyPressHandler($event)"
665
583
  (keyup)="keyUpHandler($event)"
666
584
  [attr.dir]="dir"
667
585
  [size]="size"
@@ -669,7 +587,7 @@ SplitButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", v
669
587
  </kendo-button-list>
670
588
  </ng-template>
671
589
  <ng-container #container></ng-container>
672
- `, isInline: true, components: [{ type: i5.ListComponent, selector: "kendo-button-list", inputs: ["data", "textField", "itemTemplate", "size"], outputs: ["onItemClick", "onItemBlur"] }], directives: [{ type: i6.LocalizedSplitButtonMessagesDirective, selector: "[kendoSplitButtonLocalizedMessages]" }, { type: i7.ButtonDirective, selector: "button[kendoButton], span[kendoButton]", inputs: ["toggleable", "togglable", "selected", "tabIndex", "icon", "iconClass", "imageUrl", "disabled", "size", "rounded", "fillMode", "themeColor", "role", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { type: i8.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i8.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
590
+ `, isInline: true, components: [{ type: i6.ListComponent, selector: "kendo-button-list", inputs: ["data", "textField", "itemTemplate", "size"], outputs: ["onItemClick", "onItemBlur"] }], directives: [{ type: i7.LocalizedSplitButtonMessagesDirective, selector: "[kendoSplitButtonLocalizedMessages]" }, { type: i8.ButtonDirective, selector: "button[kendoButton], span[kendoButton]", inputs: ["toggleable", "togglable", "selected", "tabIndex", "icon", "iconClass", "imageUrl", "disabled", "size", "rounded", "fillMode", "themeColor", "role", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { type: i9.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i9.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
673
591
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SplitButtonComponent, decorators: [{
674
592
  type: Component,
675
593
  args: [{
@@ -682,7 +600,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
682
600
  {
683
601
  provide: L10N_PREFIX,
684
602
  useValue: 'kendo.splitbutton'
685
- }
603
+ },
604
+ PopupContainerService
686
605
  ],
687
606
  selector: 'kendo-splitbutton',
688
607
  template: `
@@ -706,7 +625,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
706
625
  [iconClass]="iconClass"
707
626
  [imageUrl]="imageUrl"
708
627
  [ngClass]="buttonClass"
709
- (focus)="onButtonFocus()"
628
+ (focus)="onButtonFocus($event)"
710
629
  (click)="onButtonClick()"
711
630
  (blur)="onButtonBlur()"
712
631
  (mousedown)="toggleButtonActiveState(true)"
@@ -744,7 +663,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
744
663
  [itemTemplate]="itemTemplate"
745
664
  (onItemClick)="onItemClick($event)"
746
665
  (keydown)="keyDownHandler($event)"
747
- (keypress)="keyPressHandler($event)"
748
666
  (keyup)="keyUpHandler($event)"
749
667
  [attr.dir]="dir"
750
668
  [size]="size"
@@ -754,7 +672,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
754
672
  <ng-container #container></ng-container>
755
673
  `
756
674
  }]
757
- }], ctorParameters: function () { return [{ type: i1.FocusService }, { type: i2.NavigationService }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i3.PopupService }, { type: i0.ElementRef }, { type: i4.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }]; }, propDecorators: { text: [{
675
+ }], ctorParameters: function () { return [{ type: i1.FocusService }, { type: i2.NavigationService }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i3.PopupService }, { type: i0.ElementRef }, { type: i4.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }, { type: i5.PopupContainerService }]; }, propDecorators: { text: [{
758
676
  type: Input
759
677
  }], icon: [{
760
678
  type: Input
@@ -804,19 +722,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
804
722
  type: Output
805
723
  }], itemTemplate: [{
806
724
  type: ContentChild,
807
- args: [ButtonItemTemplateDirective, { static: false }]
725
+ args: [ButtonItemTemplateDirective]
808
726
  }], button: [{
809
727
  type: ViewChild,
810
- args: ['button', { static: true }]
728
+ args: ['button']
811
729
  }], arrowButton: [{
812
730
  type: ViewChild,
813
- args: ['arrowButton', { static: true, read: ElementRef }]
731
+ args: ['arrowButton', { read: ElementRef }]
814
732
  }], popupTemplate: [{
815
733
  type: ViewChild,
816
- args: ['popupTemplate', { static: true }]
734
+ args: ['popupTemplate']
817
735
  }], containerRef: [{
818
736
  type: ViewChild,
819
- args: ['container', { read: ViewContainerRef, static: true }]
737
+ args: ['container', { read: ViewContainerRef }]
820
738
  }], isFocused: [{
821
739
  type: HostBinding,
822
740
  args: ['class.k-focus']
@@ -832,9 +750,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
832
750
  }], keydown: [{
833
751
  type: HostListener,
834
752
  args: ['keydown', ['$event']]
835
- }], keypress: [{
836
- type: HostListener,
837
- args: ['keypress', ['$event']]
838
753
  }], keyup: [{
839
754
  type: HostListener,
840
755
  args: ['keyup', ['$event']]