@fundamental-ngx/cdk 0.43.18 → 0.43.20

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.
@@ -1,16 +1,16 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject, isDevMode, inject, Directive, EventEmitter, Input, Output, HostListener, NgModule, ContentChildren, forwardRef, HostBinding, ElementRef, INJECTOR, ContentChild, NgZone, Renderer2, Self, SkipSelf, PLATFORM_ID, QueryList, ViewContainerRef, Component, Injector, NgModuleFactory, Pipe, TemplateRef, ViewChild } from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, isDevMode, inject, ElementRef, INJECTOR, Directive, EventEmitter, Input, Output, NgModule, ContentChildren, forwardRef, HostBinding, HostListener, ContentChild, NgZone, Renderer2, Self, SkipSelf, PLATFORM_ID, QueryList, ViewContainerRef, Component, Injector, NgModuleFactory, Pipe, TemplateRef, ViewChild } from '@angular/core';
3
3
  import { DOCUMENT, CommonModule, AsyncPipe } from '@angular/common';
4
- import { BehaviorSubject, Subject, ReplaySubject, Observable, fromEvent, NEVER, merge, Subscription, takeUntil as takeUntil$1, startWith as startWith$1, switchMap, combineLatest, firstValueFrom, filter as filter$1, isObservable, of, map as map$1, take as take$1 } from 'rxjs';
4
+ import { BehaviorSubject, Subject, ReplaySubject, Observable, fromEvent, NEVER, merge, switchMap, first, map as map$1, takeUntil as takeUntil$1, Subscription, startWith as startWith$1, combineLatest, firstValueFrom, filter as filter$1, isObservable, of, take as take$1 } from 'rxjs';
5
5
  import * as i2 from '@angular/platform-browser';
6
6
  import { EVENT_MANAGER_PLUGINS } from '@angular/platform-browser';
7
7
  import * as i1 from '@angular/router';
8
8
  import { takeUntil, filter, distinctUntilChanged, startWith, map, tap, take, debounceTime, mapTo, pairwise, finalize, shareReplay, switchMap as switchMap$1, delay } from 'rxjs/operators';
9
9
  import { RIGHT_ARROW, DOWN_ARROW, LEFT_ARROW, UP_ARROW, SPACE, ESCAPE, DELETE, ENTER, MAC_ENTER, TAB, HOME, END, ALT, CONTROL, META, SHIFT, BACKSPACE, A, C, V, X, PAGE_UP, PAGE_DOWN, DASH, NUMPAD_MINUS, NUMPAD_ZERO, NUMPAD_ONE, NUMPAD_TWO, NUMPAD_THREE, NUMPAD_FOUR, NUMPAD_FIVE, NUMPAD_SIX, NUMPAD_SEVEN, NUMPAD_EIGHT, NUMPAD_NINE, F2, hasModifierKey } from '@angular/cdk/keycodes';
10
- import { coerceBooleanProperty, coerceElement, coerceNumberProperty, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
10
+ import { createFocusTrap } from 'focus-trap';
11
11
  import * as i1$1 from '@angular/cdk/a11y';
12
12
  import { FocusKeyManager, LiveAnnouncer } from '@angular/cdk/a11y';
13
- import { createFocusTrap } from 'focus-trap';
13
+ import { coerceElement, coerceBooleanProperty, coerceNumberProperty, coerceArray, coerceCssPixelValue } from '@angular/cdk/coercion';
14
14
  import * as i1$2 from '@angular/cdk/observers';
15
15
  import * as i1$3 from '@angular/cdk/overlay';
16
16
  import { ViewportRuler, OverlayConfig, OverlayContainer } from '@angular/cdk/overlay';
@@ -313,638 +313,172 @@ class DeprecatedSelector {
313
313
  }
314
314
  }
315
315
 
316
- /* eslint-disable @typescript-eslint/member-ordering */
317
- class DeprecatedAutoCompleteDirective extends DeprecatedSelector {
316
+ /** Determines whether provided value is valid content density */
317
+ function isValidContentDensity(size) {
318
+ return size === 'cozy' || size === 'compact' || size === 'condensed';
318
319
  }
319
- DeprecatedAutoCompleteDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedAutoCompleteDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
320
- DeprecatedAutoCompleteDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedAutoCompleteDirective, isStandalone: true, selector: "[fdAutoComplete], [fd-auto-complete]", providers: [
321
- {
322
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
323
- useValue: getDeprecatedModel('[fdkAutoComplete]', '[fdAutoComplete], [fd-auto-complete]')
324
- }
325
- ], usesInheritance: true, ngImport: i0 });
326
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedAutoCompleteDirective, decorators: [{
327
- type: Directive,
328
- args: [{
329
- // eslint-disable-next-line @angular-eslint/directive-selector
330
- selector: '[fdAutoComplete], [fd-auto-complete]',
331
- standalone: true,
332
- providers: [
333
- {
334
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
335
- useValue: getDeprecatedModel('[fdkAutoComplete]', '[fdAutoComplete], [fd-auto-complete]')
336
- }
337
- ]
338
- }]
339
- }] });
340
- class AutoCompleteDirective {
341
- /** @hidden */
342
- constructor(_elementRef) {
343
- this._elementRef = _elementRef;
344
- /** Whether the auto complete directive should be enabled */
345
- this.enable = true;
346
- /** Matcher function for testing the str for a search term */
347
- this.matcher = (str, searchTerm) => str.startsWith(searchTerm);
348
- /** Display function. Accepts an object of the same type as the
349
- * items passed to dropdownValues as argument, and outputs a string.
350
- * An arrow function can be used to access the *this* keyword in the calling component.
351
- * See search input examples for details. */
352
- this.displayFn = this._defaultDisplay;
353
- /** Event thrown, when the auto ahead text is accepted */
354
- this.onComplete = new EventEmitter();
355
- /** @hidden */
356
- this._completeKeys = [ENTER];
357
- /** @hidden */
358
- this._fillKeys = [LEFT_ARROW, RIGHT_ARROW];
359
- /** @hidden */
360
- this._stopKeys = [BACKSPACE, DELETE, ESCAPE];
361
- }
320
+ /**
321
+ * Determines if "compact" styles should be applied based on provided content density
322
+ */
323
+ function isCompactDensity(size) {
324
+ return isValidContentDensity(size) && size !== 'cozy';
325
+ }
326
+
327
+ const DEFAULT_CONTENT_DENSITY = 'cozy';
328
+ /**
329
+ * Service taking care of ContentDensity
330
+ */
331
+ class ContentDensityService {
362
332
  /** @hidden */
363
- handleKeyboardEvent(event) {
364
- if (this.enable) {
365
- if (KeyUtil.isKeyCode(event, this._stopKeys)) {
366
- this._elementRef.nativeElement.value = this.inputText;
367
- }
368
- else if (KeyUtil.isKeyCode(event, this._completeKeys)) {
369
- this._sendCompleteEvent(true);
370
- this._moveIndicatorToLastCharacter();
371
- }
372
- else if (KeyUtil.isKeyCode(event, this._fillKeys)) {
373
- this._sendCompleteEvent(false);
374
- }
375
- else if (!this._isControlKey(event) && this.inputText) {
376
- /** Prevention from triggering typeahead, when having crtl/cmd + keys */
377
- if (!this._triggerTypeAhead()) {
378
- return;
379
- }
380
- this.oldValue = this.inputText;
381
- const item = this.options.find((option) => this.matcher(this.displayFn(option).toLocaleLowerCase(), this.inputText.toLocaleLowerCase()));
382
- if (item) {
383
- this._typeahead(this.displayFn(item));
384
- }
385
- }
333
+ constructor() {
334
+ /** Content Density BehaviourSubject */
335
+ this.contentDensity = new BehaviorSubject(DEFAULT_CONTENT_DENSITY);
336
+ if (isDevMode()) {
337
+ console.warn(`[Deprecated] ContentDensityService is deprecated and will be removed in the next major version.
338
+ Please use ContentDensityControllerService instead, or use the ContentDensityModule forRoot method.`);
386
339
  }
387
- this.lastKeyUpEvent = event;
388
340
  }
389
341
  /** @hidden */
390
- _typeahead(displayedValue) {
391
- this._elementRef.nativeElement.value = displayedValue;
392
- const selectionStartIndex = this.inputText.length;
393
- this._elementRef.nativeElement.setSelectionRange(selectionStartIndex, displayedValue.length);
342
+ get _contentDensityListener() {
343
+ return this.contentDensity.pipe(distinctUntilChanged(), startWith(this.contentDensity.getValue()));
394
344
  }
395
345
  /** @hidden */
396
- _isControlKey(event) {
397
- return KeyUtil.isKeyCode(event, CONTROL) || event.ctrlKey;
346
+ get _isCompactDensity() {
347
+ return this._contentDensityListener.pipe(map((density) => isCompactDensity(density)));
398
348
  }
349
+ }
350
+ ContentDensityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
351
+ ContentDensityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService });
352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService, decorators: [{
353
+ type: Injectable
354
+ }], ctorParameters: function () { return []; } });
355
+
356
+ class DestroyedService extends ReplaySubject {
399
357
  /** @hidden */
400
- _defaultDisplay(value) {
401
- return value;
358
+ constructor() {
359
+ super(1);
402
360
  }
403
361
  /** @hidden */
404
- _triggerTypeAhead() {
405
- if (this.lastKeyUpEvent &&
406
- KeyUtil.isKeyCode(this.lastKeyUpEvent, CONTROL) &&
407
- this.inputText === this.oldValue) {
408
- return false;
362
+ ngOnDestroy() {
363
+ this.next();
364
+ this.complete();
365
+ }
366
+ }
367
+ DestroyedService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
368
+ DestroyedService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService });
369
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService, decorators: [{
370
+ type: Injectable
371
+ }], ctorParameters: function () { return []; } });
372
+
373
+ /** Generate a UUID v4 */
374
+ function uuidv4() {
375
+ const modifier = 16;
376
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
377
+ // eslint-disable-next-line no-bitwise
378
+ const r = (Math.random() * modifier) | 0,
379
+ // eslint-disable-next-line no-bitwise
380
+ v = c === 'x' ? r : (r & 0x3) | 0x8;
381
+ return v.toString(modifier);
382
+ });
383
+ }
384
+
385
+ class FocusTrapService {
386
+ constructor() {
387
+ /** @hidden */
388
+ this._focusTrapInstances = new Map();
389
+ }
390
+ /**
391
+ * Creates focus trap instance for defined element
392
+ * @param element Container for which to create focus trap
393
+ * @param userOptions Focus-trap specific configuration
394
+ * @returns {string} Unique ID of focus trap instance
395
+ */
396
+ createFocusTrap(element, userOptions) {
397
+ const uid = uuidv4();
398
+ const trap = createFocusTrap(element, userOptions);
399
+ this._focusTrapInstances.set(uid, trap);
400
+ this.activateFocusTrap(uid);
401
+ return uid;
402
+ }
403
+ /**
404
+ * Activates focus trap for defined ID
405
+ * @param id Unique ID of focus trap instance
406
+ */
407
+ activateFocusTrap(id) {
408
+ if (!this._focusTrapExists(id)) {
409
+ return;
409
410
  }
410
- else {
411
- return true;
411
+ const trap = this.getFocusTrapInstance(id);
412
+ trap?.activate();
413
+ }
414
+ /**
415
+ * Deactivates focus trap for defined ID
416
+ * @param id Unique ID of focus trap instance
417
+ */
418
+ deactivateFocusTrap(id) {
419
+ if (!this._focusTrapExists(id)) {
420
+ return;
421
+ }
422
+ const trap = this.getFocusTrapInstance(id);
423
+ trap?.deactivate();
424
+ this._focusTrapInstances.delete(id);
425
+ }
426
+ /**
427
+ * Pauses current focus trap.
428
+ */
429
+ pauseCurrentFocusTrap() {
430
+ if (this._focusTrapInstances.size === 0) {
431
+ return;
432
+ }
433
+ const trapItem = this._getLastTrapedItem();
434
+ trapItem?.pause();
435
+ }
436
+ /**
437
+ * Unpauses current focus trap.
438
+ */
439
+ unpauseCurrentFocusTrap() {
440
+ if (this._focusTrapInstances.size === 0) {
441
+ return;
412
442
  }
443
+ const trapItem = this._getLastTrapedItem();
444
+ trapItem?.unpause();
445
+ }
446
+ /**
447
+ * Get focus trap instance by ID.
448
+ * @param id ID of the instance.
449
+ * @returns Focus trap instance if exists.
450
+ */
451
+ getFocusTrapInstance(id) {
452
+ return this._focusTrapInstances.get(id);
413
453
  }
414
454
  /** @hidden */
415
- _sendCompleteEvent(forceClose) {
416
- this.onComplete.emit({
417
- term: this._elementRef.nativeElement.value,
418
- forceClose
419
- });
455
+ _getLastTrapedItem() {
456
+ const lastItem = Array.from(this._focusTrapInstances).pop();
457
+ return lastItem ? lastItem[1] : undefined;
420
458
  }
421
459
  /** @hidden */
422
- _moveIndicatorToLastCharacter() {
423
- const inputTextLength = this.inputText?.length ?? 0;
424
- this._elementRef.nativeElement.setSelectionRange(inputTextLength, inputTextLength);
460
+ _focusTrapExists(id) {
461
+ return this._focusTrapInstances.has(id);
425
462
  }
426
463
  }
427
- AutoCompleteDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
428
- AutoCompleteDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: AutoCompleteDirective, isStandalone: true, selector: "[fdkAutoComplete], [fdAutoComplete], [fd-auto-complete]", inputs: { options: "options", inputText: "inputText", enable: "enable", matcher: "matcher", displayFn: "displayFn" }, outputs: { onComplete: "onComplete" }, host: { listeners: { "keyup": "handleKeyboardEvent($event)" } }, ngImport: i0 });
429
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteDirective, decorators: [{
430
- type: Directive,
464
+ FocusTrapService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
465
+ FocusTrapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, providedIn: 'root' });
466
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, decorators: [{
467
+ type: Injectable,
431
468
  args: [{
432
- selector: '[fdkAutoComplete], [fdAutoComplete], [fd-auto-complete]',
433
- standalone: true
469
+ providedIn: 'root'
434
470
  }]
435
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { options: [{
436
- type: Input
437
- }], inputText: [{
438
- type: Input
439
- }], enable: [{
440
- type: Input
441
- }], matcher: [{
442
- type: Input
443
- }], displayFn: [{
444
- type: Input
445
- }], onComplete: [{
446
- type: Output
447
- }], handleKeyboardEvent: [{
448
- type: HostListener,
449
- args: ['keyup', ['$event']]
450
- }] } });
471
+ }] });
451
472
 
452
- class AutoCompleteModule {
453
- }
454
- AutoCompleteModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
455
- AutoCompleteModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, imports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective], exports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective] });
456
- AutoCompleteModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule });
457
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, decorators: [{
458
- type: NgModule,
459
- args: [{
460
- imports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective],
461
- exports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective],
462
- declarations: []
463
- }]
464
- }] });
465
-
466
- const FOCUSABLE_ITEM = new InjectionToken('Focusable Option');
467
-
468
- class DeprecatedFocusKeyManagerListDirective extends DeprecatedSelector {
469
- }
470
- DeprecatedFocusKeyManagerListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerListDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
471
- DeprecatedFocusKeyManagerListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedFocusKeyManagerListDirective, isStandalone: true, selector: "[fd-focus-key-manager-list], [fdFocusKeyManagerList]", providers: [
472
- {
473
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
474
- useValue: getDeprecatedModel('[fdkFocusKeyManagerList]', '[fd-focus-key-manager-list], [fdFocusKeyManagerList]')
475
- }
476
- ], usesInheritance: true, ngImport: i0 });
477
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerListDirective, decorators: [{
478
- type: Directive,
479
- args: [{
480
- // eslint-disable-next-line @angular-eslint/directive-selector
481
- selector: '[fd-focus-key-manager-list], [fdFocusKeyManagerList]',
482
- standalone: true,
483
- providers: [
484
- {
485
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
486
- useValue: getDeprecatedModel('[fdkFocusKeyManagerList]', '[fd-focus-key-manager-list], [fdFocusKeyManagerList]')
487
- }
488
- ]
489
- }]
490
- }] });
491
- /** Directive to apply Angular Material FocusKeyManager to lists.
492
- * To be used with FocusKeyManagerItemDirective
493
- */
494
- class FocusKeyManagerListDirective {
495
- /** @hidden */
496
- get focusKeyManager() {
497
- return this._focusKeyManager;
498
- }
499
- /** @hidden */
500
- constructor(_rtlService, _cdr) {
501
- this._rtlService = _rtlService;
502
- this._cdr = _cdr;
503
- /** @hidden */
504
- this._onDestroy$ = new Subject();
505
- }
506
- /** @hidden */
507
- ngOnChanges(changes) {
508
- if (!this._focusKeyManager) {
509
- return;
510
- }
511
- if ('orientation' in changes) {
512
- this._applyOrientation();
513
- }
514
- if ('skiPredicate' in changes) {
515
- this._focusKeyManager.skipPredicate(this.skipPredicate);
516
- }
517
- }
518
- /** @hidden */
519
- ngAfterContentInit() {
520
- this._focusKeyManager = new FocusKeyManager(this._items).skipPredicate(this.skipPredicate);
521
- this._applyOrientation();
522
- this._cdr.detectChanges();
523
- this._rtlService?.rtl
524
- .pipe(filter(() => this.orientation === 'horizontal'), takeUntil(this._onDestroy$))
525
- .subscribe(() => this._applyOrientation());
526
- }
527
- /** @hidden */
528
- ngOnDestroy() {
529
- this._onDestroy$.next();
530
- this._onDestroy$.complete();
531
- this._focusKeyManager.destroy();
532
- }
533
- /** Focus certain list's item */
534
- focusItem(item) {
535
- if (typeof item === 'number') {
536
- this._focusKeyManager.setActiveItem(item);
537
- }
538
- else {
539
- this._focusKeyManager.setActiveItem(item);
540
- }
541
- }
542
- /** @hidden */
543
- _applyOrientation() {
544
- switch (this.orientation) {
545
- case 'horizontal':
546
- this._focusKeyManager.withHorizontalOrientation(this._rtlService?.rtl.value ? 'rtl' : 'ltr');
547
- break;
548
- case 'vertical':
549
- this._focusKeyManager.withVerticalOrientation(true);
550
- break;
551
- }
552
- }
553
- }
554
- FocusKeyManagerListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerListDirective, deps: [{ token: RtlService, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
555
- FocusKeyManagerListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: FocusKeyManagerListDirective, isStandalone: true, selector: "[fdkFocusKeyManagerList], [fd-focus-key-manager-list], [fdFocusKeyManagerList]", inputs: { orientation: "orientation", skipPredicate: "skipPredicate" }, queries: [{ propertyName: "_items", predicate: FOCUSABLE_ITEM }], usesOnChanges: true, ngImport: i0 });
556
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerListDirective, decorators: [{
557
- type: Directive,
558
- args: [{
559
- selector: `[fdkFocusKeyManagerList], [fd-focus-key-manager-list], [fdFocusKeyManagerList]`,
560
- standalone: true
561
- }]
562
- }], ctorParameters: function () { return [{ type: RtlService, decorators: [{
563
- type: Optional
564
- }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { orientation: [{
565
- type: Input
566
- }], skipPredicate: [{
567
- type: Input
568
- }], _items: [{
569
- type: ContentChildren,
570
- args: [FOCUSABLE_ITEM]
571
- }] } });
572
-
573
- class DeprecatedFocusKeyManagerItemDirective extends DeprecatedSelector {
574
- }
575
- DeprecatedFocusKeyManagerItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerItemDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
576
- DeprecatedFocusKeyManagerItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedFocusKeyManagerItemDirective, isStandalone: true, selector: "[fd-focus-key-manager-item], [fdFocusKeyManagerItem]", providers: [
577
- {
578
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
579
- useValue: getDeprecatedModel('[fdkFocusKeyManagerItem]', '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]')
580
- }
581
- ], usesInheritance: true, ngImport: i0 });
582
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerItemDirective, decorators: [{
583
- type: Directive,
584
- args: [{
585
- // eslint-disable-next-line @angular-eslint/directive-selector
586
- selector: '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]',
587
- standalone: true,
588
- providers: [
589
- {
590
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
591
- useValue: getDeprecatedModel('[fdkFocusKeyManagerItem]', '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]')
592
- }
593
- ]
594
- }]
595
- }] });
596
- /** Directive to apply Angular Material FocusKeyManager to lists.
597
- * To be used with FocusKeyManagerItemDirective
598
- */
599
- class FocusKeyManagerItemDirective {
600
- /** Whether item should be initially focused */
601
- set initialFocus(value) {
602
- this._initialFocus = coerceBooleanProperty(value);
603
- }
604
- /** @hidden */
605
- get _tabindex() {
606
- if (this._initialFocus) {
607
- return 0;
608
- }
609
- return this.nativeElement?.tabIndex ?? -1;
610
- }
611
- /** Native element of the item */
612
- get nativeElement() {
613
- return this._elRef?.nativeElement;
614
- }
615
- /** @hidden */
616
- get _focusKeyManager() {
617
- return this._list.focusKeyManager;
618
- }
619
- /** @hidden */
620
- constructor(_list, _elRef) {
621
- this._list = _list;
622
- this._elRef = _elRef;
623
- /** @hidden */
624
- this._initialFocus = false;
625
- }
626
- /** @hidden */
627
- _onFocus() {
628
- // For cases where initially selected item doesn't have 0 index
629
- this._focusKeyManager?.updateActiveItem(this);
630
- }
631
- /** @hidden */
632
- _onKeydown(event) {
633
- this._focusKeyManager?.onKeydown(event);
634
- }
635
- /** Focus current item native element */
636
- focus() {
637
- this._elRef?.nativeElement.focus();
638
- }
639
- }
640
- FocusKeyManagerItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerItemDirective, deps: [{ token: FocusKeyManagerListDirective }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
641
- FocusKeyManagerItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: FocusKeyManagerItemDirective, isStandalone: true, selector: "[fdkFocusKeyManagerItem], [fd-focus-key-manager-item], [fdFocusKeyManagerItem]", inputs: { initialFocus: "initialFocus", _tabindex: "_tabindex" }, host: { listeners: { "focus": "_onFocus()", "keydown": "_onKeydown($event)" }, properties: { "attr.tabindex": "this._tabindex" } }, providers: [{ provide: FOCUSABLE_ITEM, useExisting: forwardRef(() => FocusKeyManagerItemDirective) }], ngImport: i0 });
642
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerItemDirective, decorators: [{
643
- type: Directive,
644
- args: [{
645
- selector: '[fdkFocusKeyManagerItem], [fd-focus-key-manager-item], [fdFocusKeyManagerItem]',
646
- standalone: true,
647
- providers: [{ provide: FOCUSABLE_ITEM, useExisting: forwardRef(() => FocusKeyManagerItemDirective) }]
648
- }]
649
- }], ctorParameters: function () { return [{ type: FocusKeyManagerListDirective }, { type: i0.ElementRef }]; }, propDecorators: { initialFocus: [{
650
- type: Input
651
- }], _tabindex: [{
652
- type: Input
653
- }, {
654
- type: HostBinding,
655
- args: ['attr.tabindex']
656
- }], _onFocus: [{
657
- type: HostListener,
658
- args: ['focus']
659
- }], _onKeydown: [{
660
- type: HostListener,
661
- args: ['keydown', ['$event']]
662
- }] } });
663
-
664
- class FocusKeyManagerHelpersModule {
665
- }
666
- FocusKeyManagerHelpersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
667
- FocusKeyManagerHelpersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, imports: [FocusKeyManagerItemDirective,
668
- FocusKeyManagerListDirective,
669
- DeprecatedFocusKeyManagerItemDirective,
670
- DeprecatedFocusKeyManagerListDirective], exports: [FocusKeyManagerItemDirective,
671
- FocusKeyManagerListDirective,
672
- DeprecatedFocusKeyManagerItemDirective,
673
- DeprecatedFocusKeyManagerListDirective] });
674
- FocusKeyManagerHelpersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule });
675
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, decorators: [{
676
- type: NgModule,
677
- args: [{
678
- imports: [
679
- FocusKeyManagerItemDirective,
680
- FocusKeyManagerListDirective,
681
- DeprecatedFocusKeyManagerItemDirective,
682
- DeprecatedFocusKeyManagerListDirective
683
- ],
684
- exports: [
685
- FocusKeyManagerItemDirective,
686
- FocusKeyManagerListDirective,
687
- DeprecatedFocusKeyManagerItemDirective,
688
- DeprecatedFocusKeyManagerListDirective
689
- ]
690
- }]
691
- }] });
692
-
693
- const IgnoreClickOnSelectionDirectiveToken = new InjectionToken('Ignore click on selection directive');
694
-
695
- class DeprecatedIgnoreClickOnSelectionDirective extends DeprecatedSelector {
696
- }
697
- DeprecatedIgnoreClickOnSelectionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedIgnoreClickOnSelectionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
698
- DeprecatedIgnoreClickOnSelectionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedIgnoreClickOnSelectionDirective, isStandalone: true, selector: "[fdIgnoreClickOnSelection]", providers: [
699
- {
700
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
701
- useValue: getDeprecatedModel('[fdkIgnoreClickOnSelection]', '[fdIgnoreClickOnSelection]')
702
- }
703
- ], usesInheritance: true, ngImport: i0 });
704
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedIgnoreClickOnSelectionDirective, decorators: [{
705
- type: Directive,
706
- args: [{
707
- // eslint-disable-next-line @angular-eslint/directive-selector
708
- selector: '[fdIgnoreClickOnSelection]',
709
- standalone: true,
710
- providers: [
711
- {
712
- provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
713
- useValue: getDeprecatedModel('[fdkIgnoreClickOnSelection]', '[fdIgnoreClickOnSelection]')
714
- }
715
- ]
716
- }]
717
- }] });
718
- /**
719
- * Directive will stop propagation and prevent default of click, if selected area is coming from
720
- * directive's host element. This gives ability to not cancel all clicks on element, just the ones
721
- * which include selection
722
- */
723
- class IgnoreClickOnSelectionDirective {
724
- /** @hidden */
725
- constructor(document, _elementRef) {
726
- this.document = document;
727
- this._elementRef = _elementRef;
728
- }
729
- /** Host click listener. Checks for selection existence and if finds one, checks anchor */
730
- clicked($event) {
731
- const selection = this.document.getSelection();
732
- if (selection?.toString()) {
733
- if (selection.anchorNode &&
734
- (this._elementRef.nativeElement.isSameNode(selection.anchorNode) ||
735
- this._elementRef.nativeElement.isSameNode(selection.anchorNode.parentElement))) {
736
- $event.stopPropagation();
737
- $event.preventDefault();
738
- }
739
- }
740
- }
741
- }
742
- IgnoreClickOnSelectionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionDirective, deps: [{ token: DOCUMENT }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
743
- IgnoreClickOnSelectionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: IgnoreClickOnSelectionDirective, isStandalone: true, selector: "[fdkIgnoreClickOnSelection], [fdIgnoreClickOnSelection]", host: { listeners: { "click": "clicked($event)" } }, providers: [
744
- {
745
- provide: IgnoreClickOnSelectionDirectiveToken,
746
- useExisting: IgnoreClickOnSelectionDirective
747
- }
748
- ], ngImport: i0 });
749
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionDirective, decorators: [{
750
- type: Directive,
751
- args: [{
752
- selector: '[fdkIgnoreClickOnSelection], [fdIgnoreClickOnSelection]',
753
- standalone: true,
754
- providers: [
755
- {
756
- provide: IgnoreClickOnSelectionDirectiveToken,
757
- useExisting: IgnoreClickOnSelectionDirective
758
- }
759
- ]
760
- }]
761
- }], ctorParameters: function () { return [{ type: Document, decorators: [{
762
- type: Inject,
763
- args: [DOCUMENT]
764
- }] }, { type: i0.ElementRef }]; }, propDecorators: { clicked: [{
765
- type: HostListener,
766
- args: ['click', ['$event']]
767
- }] } });
768
-
769
- class IgnoreClickOnSelectionModule {
770
- }
771
- IgnoreClickOnSelectionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
772
- IgnoreClickOnSelectionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, imports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective], exports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective] });
773
- IgnoreClickOnSelectionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule });
774
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, decorators: [{
775
- type: NgModule,
776
- args: [{
777
- imports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective],
778
- exports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective]
779
- }]
780
- }] });
781
-
782
- /** Determines whether provided value is valid content density */
783
- function isValidContentDensity(size) {
784
- return size === 'cozy' || size === 'compact' || size === 'condensed';
785
- }
786
- /**
787
- * Determines if "compact" styles should be applied based on provided content density
788
- */
789
- function isCompactDensity(size) {
790
- return isValidContentDensity(size) && size !== 'cozy';
791
- }
792
-
793
- const DEFAULT_CONTENT_DENSITY = 'cozy';
794
- /**
795
- * Service taking care of ContentDensity
796
- */
797
- class ContentDensityService {
798
- /** @hidden */
799
- constructor() {
800
- /** Content Density BehaviourSubject */
801
- this.contentDensity = new BehaviorSubject(DEFAULT_CONTENT_DENSITY);
802
- if (isDevMode()) {
803
- console.warn(`[Deprecated] ContentDensityService is deprecated and will be removed in the next major version.
804
- Please use ContentDensityControllerService instead, or use the ContentDensityModule forRoot method.`);
805
- }
806
- }
807
- /** @hidden */
808
- get _contentDensityListener() {
809
- return this.contentDensity.pipe(distinctUntilChanged(), startWith(this.contentDensity.getValue()));
810
- }
811
- /** @hidden */
812
- get _isCompactDensity() {
813
- return this._contentDensityListener.pipe(map((density) => isCompactDensity(density)));
814
- }
815
- }
816
- ContentDensityService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
817
- ContentDensityService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService });
818
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContentDensityService, decorators: [{
819
- type: Injectable
820
- }], ctorParameters: function () { return []; } });
821
-
822
- class DestroyedService extends ReplaySubject {
823
- /** @hidden */
824
- constructor() {
825
- super(1);
826
- }
827
- /** @hidden */
828
- ngOnDestroy() {
829
- this.next();
830
- this.complete();
831
- }
832
- }
833
- DestroyedService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
834
- DestroyedService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService });
835
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DestroyedService, decorators: [{
836
- type: Injectable
837
- }], ctorParameters: function () { return []; } });
838
-
839
- /** Generate a UUID v4 */
840
- function uuidv4() {
841
- const modifier = 16;
842
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
843
- // eslint-disable-next-line no-bitwise
844
- const r = (Math.random() * modifier) | 0,
845
- // eslint-disable-next-line no-bitwise
846
- v = c === 'x' ? r : (r & 0x3) | 0x8;
847
- return v.toString(modifier);
848
- });
849
- }
850
-
851
- class FocusTrapService {
852
- constructor() {
853
- /** @hidden */
854
- this._focusTrapInstances = new Map();
855
- }
856
- /**
857
- * Creates focus trap instance for defined element
858
- * @param element Container for which to create focus trap
859
- * @param userOptions Focus-trap specific configuration
860
- * @returns {string} Unique ID of focus trap instance
861
- */
862
- createFocusTrap(element, userOptions) {
863
- const uid = uuidv4();
864
- const trap = createFocusTrap(element, userOptions);
865
- this._focusTrapInstances.set(uid, trap);
866
- this.activateFocusTrap(uid);
867
- return uid;
868
- }
869
- /**
870
- * Activates focus trap for defined ID
871
- * @param id Unique ID of focus trap instance
872
- */
873
- activateFocusTrap(id) {
874
- if (!this._focusTrapExists(id)) {
875
- return;
876
- }
877
- const trap = this.getFocusTrapInstance(id);
878
- trap?.activate();
879
- }
880
- /**
881
- * Deactivates focus trap for defined ID
882
- * @param id Unique ID of focus trap instance
883
- */
884
- deactivateFocusTrap(id) {
885
- if (!this._focusTrapExists(id)) {
886
- return;
887
- }
888
- const trap = this.getFocusTrapInstance(id);
889
- trap?.deactivate();
890
- this._focusTrapInstances.delete(id);
891
- }
892
- /**
893
- * Pauses current focus trap.
894
- */
895
- pauseCurrentFocusTrap() {
896
- if (this._focusTrapInstances.size === 0) {
897
- return;
898
- }
899
- const trapItem = this._getLastTrapedItem();
900
- trapItem?.pause();
901
- }
902
- /**
903
- * Unpauses current focus trap.
904
- */
905
- unpauseCurrentFocusTrap() {
906
- if (this._focusTrapInstances.size === 0) {
907
- return;
908
- }
909
- const trapItem = this._getLastTrapedItem();
910
- trapItem?.unpause();
911
- }
912
- /**
913
- * Get focus trap instance by ID.
914
- * @param id ID of the instance.
915
- * @returns Focus trap instance if exists.
916
- */
917
- getFocusTrapInstance(id) {
918
- return this._focusTrapInstances.get(id);
919
- }
920
- /** @hidden */
921
- _getLastTrapedItem() {
922
- const lastItem = Array.from(this._focusTrapInstances).pop();
923
- return lastItem ? lastItem[1] : undefined;
924
- }
925
- /** @hidden */
926
- _focusTrapExists(id) {
927
- return this._focusTrapInstances.has(id);
928
- }
929
- }
930
- FocusTrapService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
931
- FocusTrapService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, providedIn: 'root' });
932
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusTrapService, decorators: [{
933
- type: Injectable,
934
- args: [{
935
- providedIn: 'root'
936
- }]
937
- }] });
938
-
939
- const pxToNum = (pixels) => Number(pixels.replace('px', '')) || 0;
940
- const toNativeElement = (element) => element instanceof ElementRef ? element.nativeElement : element;
941
- /** Return elements capacity (width subtract by element padding)
942
- * @param element - HTMLelement or element reference
943
- * */
944
- function getElementCapacity(element) {
945
- const _element = toNativeElement(element);
946
- const computedStyle = window.getComputedStyle(_element);
947
- return pxToNum(computedStyle.width) - pxToNum(computedStyle.paddingLeft) - pxToNum(computedStyle.paddingRight);
473
+ const pxToNum = (pixels) => Number(pixels.replace('px', '')) || 0;
474
+ const toNativeElement = (element) => element instanceof ElementRef ? element.nativeElement : element;
475
+ /** Return elements capacity (width subtract by element padding)
476
+ * @param element - HTMLelement or element reference
477
+ * */
478
+ function getElementCapacity(element) {
479
+ const _element = toNativeElement(element);
480
+ const computedStyle = window.getComputedStyle(_element);
481
+ return pxToNum(computedStyle.width) - pxToNum(computedStyle.paddingLeft) - pxToNum(computedStyle.paddingRight);
948
482
  }
949
483
  /** Return elements width
950
484
  * @param element - HTMLelement or element reference
@@ -1105,340 +639,822 @@ function consumerProviderFactory(ConsumerClass, providedConfiguration) {
1105
639
  };
1106
640
  }
1107
641
 
1108
- /** Get document font size in pixels. */
1109
- function getDocumentFontSize() {
1110
- return document?.documentElement ? parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;
642
+ /** Get document font size in pixels. */
643
+ function getDocumentFontSize() {
644
+ return document?.documentElement ? parseFloat(getComputedStyle(document.documentElement).fontSize) : 16;
645
+ }
646
+
647
+ /**
648
+ * Function checks whether the passed number is odd.
649
+ * @param number number to check.
650
+ * @returns Boolean whether the number is odd.
651
+ */
652
+ function isOdd(number) {
653
+ return number % 2 === 1;
654
+ }
655
+
656
+ class KeyboardSupportService {
657
+ constructor() {
658
+ /** Subject that is thrown, when focus escapes the list */
659
+ this.focusEscapeList = new Subject();
660
+ /** An RxJS Subject that will kill the data stream upon component’s destruction (for unsubscribing) */
661
+ this._onDestroy$ = new Subject();
662
+ /** An RxJS Subject that will kill the data stream upon queryList changes (for unsubscribing) */
663
+ this._onRefresh$ = new Subject();
664
+ /** @hidden
665
+ * allow tab key navigation. default is true.
666
+ */
667
+ this._tabKeyNavigation = true;
668
+ }
669
+ /** @hidden */
670
+ get keyManager() {
671
+ return this._keyManager;
672
+ }
673
+ /** @hidden */
674
+ setKeyboardService(queryList, wrap, tabKeyNavigation = true) {
675
+ this._itemList = queryList;
676
+ this._tabKeyNavigation = tabKeyNavigation;
677
+ this._keyManager = new FocusKeyManager(queryList).withWrap(wrap).withHomeAndEnd();
678
+ queryList.changes
679
+ .pipe(takeUntil(this._onDestroy$), startWith(0))
680
+ .subscribe(() => this._refreshEscapeLogic(queryList));
681
+ }
682
+ /** @hidden */
683
+ onKeyDown(event) {
684
+ this._keyManager.onKeydown(event);
685
+ if (KeyUtil.isKeyCode(event, TAB)) {
686
+ if (KeyUtil.isKeyCode(event, TAB) && this._tabKeyNavigation) {
687
+ event.preventDefault();
688
+ hasModifierKey(event, 'shiftKey')
689
+ ? this.keyManager.setPreviousItemActive()
690
+ : this.keyManager.setNextItemActive();
691
+ }
692
+ }
693
+ }
694
+ /** Destroys KeyboardSupportService dependencies */
695
+ onDestroy() {
696
+ this._onDestroy$.next();
697
+ this._onDestroy$.complete();
698
+ this._keyManager.destroy();
699
+ }
700
+ /** @hidden */
701
+ _refreshEscapeLogic(queryList) {
702
+ const createEscapeListener = (listItem, onKeyCode, escapeDirection) => {
703
+ listItem.keyDown
704
+ .pipe(takeUntil(unsubscribe$), filter((event) => KeyUtil.isKeyCode(event, onKeyCode)), tap((event) => event.preventDefault()))
705
+ .subscribe(() => this.focusEscapeList.next(escapeDirection));
706
+ };
707
+ /** Finish all of the streams, form before */
708
+ this._onRefresh$.next();
709
+ const unsubscribe$ = merge(this._onRefresh$, this._onDestroy$);
710
+ if (queryList.length) {
711
+ createEscapeListener(queryList.last, DOWN_ARROW, 'down');
712
+ createEscapeListener(queryList.first, UP_ARROW, 'up');
713
+ }
714
+ }
715
+ }
716
+ KeyboardSupportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
717
+ KeyboardSupportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, providedIn: 'root' });
718
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, decorators: [{
719
+ type: Injectable,
720
+ args: [{ providedIn: 'root' }]
721
+ }] });
722
+
723
+ class MockStorage {
724
+ // eslint-disable-next-line
725
+ key(index) { }
726
+ clear() { }
727
+ // eslint-disable-next-line
728
+ getItem(key) { }
729
+ // eslint-disable-next-line
730
+ removeItem(key) { }
731
+ // eslint-disable-next-line
732
+ setItem(key, value) { }
733
+ }
734
+ class LocalStorageService {
735
+ /** @hidden */
736
+ constructor() {
737
+ typeof localStorage !== 'undefined' ? (this._storage = localStorage) : (this._storage = new MockStorage());
738
+ }
739
+ /** Get item from local storage. */
740
+ get(key) {
741
+ const value = this._storage.getItem(key);
742
+ if (value) {
743
+ return JSON.parse(value);
744
+ }
745
+ return null;
746
+ }
747
+ /** Set item in local storage. */
748
+ set(key, value) {
749
+ this._storage.setItem(key, JSON.stringify(value));
750
+ }
751
+ }
752
+ LocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
753
+ LocalStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
754
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, decorators: [{
755
+ type: Injectable,
756
+ args: [{ providedIn: 'root' }]
757
+ }], ctorParameters: function () { return []; } });
758
+
759
+ class ResizeObserverFactory {
760
+ /** Factory to create ResizeObserver if it's present in browser. */
761
+ create(callback) {
762
+ return typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(callback);
763
+ }
764
+ }
765
+ ResizeObserverFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
766
+ ResizeObserverFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, providedIn: 'root' });
767
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, decorators: [{
768
+ type: Injectable,
769
+ args: [{ providedIn: 'root' }]
770
+ }] });
771
+ class ResizeObserverService {
772
+ /** @hidden */
773
+ constructor(_resizeObserverFactory) {
774
+ this._resizeObserverFactory = _resizeObserverFactory;
775
+ /** @hidden */
776
+ this._observedElements = new Map();
777
+ }
778
+ /** @hidden */
779
+ ngOnDestroy() {
780
+ this._observedElements.forEach((_, element) => this._cleanupObserver(element));
781
+ }
782
+ /** Observe the given element and emit whenever its size changes. */
783
+ observe(elementOrRef) {
784
+ const element = coerceElement(elementOrRef);
785
+ return new Observable((observer) => {
786
+ const stream = this._observeElement(element);
787
+ const subscription = stream?.subscribe(observer);
788
+ return () => {
789
+ subscription?.unsubscribe();
790
+ this._unobserveElement(element);
791
+ };
792
+ });
793
+ }
794
+ /**
795
+ * Observes the given element by using the existing MutationObserver if available, or creating a
796
+ * new one if not.
797
+ */
798
+ _observeElement(element) {
799
+ let observedElement = this._observedElements.get(element);
800
+ if (!observedElement) {
801
+ const stream = new Subject();
802
+ const observer = this._resizeObserverFactory.create((mutations) => stream.next(mutations));
803
+ if (observer) {
804
+ observer.observe(element);
805
+ }
806
+ observedElement = { observer, stream, count: 0 };
807
+ this._observedElements.set(element, observedElement);
808
+ }
809
+ observedElement.count++;
810
+ return observedElement?.stream;
811
+ }
812
+ /**
813
+ * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is
814
+ * observing this element.
815
+ */
816
+ _unobserveElement(element) {
817
+ const observedElement = this._observedElements.get(element);
818
+ if (!observedElement) {
819
+ return;
820
+ }
821
+ if (--observedElement.count) {
822
+ return;
823
+ }
824
+ this._cleanupObserver(element);
825
+ }
826
+ /** Clean up the underlying MutationObserver for the specified element. */
827
+ _cleanupObserver(element) {
828
+ const observedElement = this._observedElements.get(element);
829
+ if (!observedElement) {
830
+ return;
831
+ }
832
+ const { observer, stream } = observedElement;
833
+ if (observer) {
834
+ observer.disconnect();
835
+ }
836
+ stream.complete();
837
+ this._observedElements.delete(element);
838
+ }
839
+ }
840
+ ResizeObserverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, deps: [{ token: ResizeObserverFactory }], target: i0.ɵɵFactoryTarget.Injectable });
841
+ ResizeObserverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, providedIn: 'root' });
842
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, decorators: [{
843
+ type: Injectable,
844
+ args: [{ providedIn: 'root' }]
845
+ }], ctorParameters: function () { return [{ type: ResizeObserverFactory }]; } });
846
+
847
+ class TabbableElementService {
848
+ /** @hidden */
849
+ constructor(_checker, _document) {
850
+ this._checker = _checker;
851
+ this._document = _document;
852
+ }
853
+ /** Get the first tabbable element from a DOM subtree (inclusive). */
854
+ getTabbableElement(root, focusLastElement = false, skipSelf = false) {
855
+ if (!skipSelf && this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
856
+ return root;
857
+ }
858
+ // Iterate in DOM order. Note that IE doesn't have `children` for SVG, so we fall
859
+ // back to `childNodes` which includes text nodes, comments etc.
860
+ const rootChildren = root.children || root.childNodes;
861
+ const children = focusLastElement ? Array.from(rootChildren).reverse() : rootChildren;
862
+ for (let i = 0; i < children.length; i++) {
863
+ const tabbableChild = children[i].nodeType === this._document?.ELEMENT_NODE
864
+ ? this.getTabbableElement(children[i], focusLastElement)
865
+ : null;
866
+ if (tabbableChild) {
867
+ return tabbableChild;
868
+ }
869
+ }
870
+ return null;
871
+ }
872
+ }
873
+ TabbableElementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, deps: [{ token: i1$1.InteractivityChecker }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
874
+ TabbableElementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, providedIn: 'root' });
875
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, decorators: [{
876
+ type: Injectable,
877
+ args: [{ providedIn: 'root' }]
878
+ }], ctorParameters: function () { return [{ type: i1$1.InteractivityChecker }, { type: Document, decorators: [{
879
+ type: Optional
880
+ }, {
881
+ type: Inject,
882
+ args: [DOCUMENT]
883
+ }] }]; } });
884
+
885
+ /**
886
+ * Retrieves native element from ElementRef.
887
+ */
888
+ function getNativeElement(element) {
889
+ let coercible = element;
890
+ if (hasElementRef(element)) {
891
+ coercible = element.elementRef;
892
+ }
893
+ return coerceElement(coercible);
1111
894
  }
1112
-
1113
895
  /**
1114
- * Function checks whether the passed number is odd.
1115
- * @param number number to check.
1116
- * @returns Boolean whether the number is odd.
896
+ * Checks whether object has element reference in it.
1117
897
  */
1118
- function isOdd(number) {
1119
- return number % 2 === 1;
898
+ function hasElementRef(something) {
899
+ return something && something['elementRef'] instanceof ElementRef;
1120
900
  }
1121
901
 
1122
- class KeyboardSupportService {
1123
- constructor() {
1124
- /** Subject that is thrown, when focus escapes the list */
1125
- this.focusEscapeList = new Subject();
1126
- /** An RxJS Subject that will kill the data stream upon component’s destruction (for unsubscribing) */
1127
- this._onDestroy$ = new Subject();
1128
- /** An RxJS Subject that will kill the data stream upon queryList changes (for unsubscribing) */
1129
- this._onRefresh$ = new Subject();
1130
- /** @hidden
1131
- * allow tab key navigation. default is true.
1132
- */
1133
- this._tabKeyNavigation = true;
1134
- }
902
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
903
+ class AttributeObserver {
1135
904
  /** @hidden */
1136
- get keyManager() {
1137
- return this._keyManager;
905
+ constructor(_mutationObserverFactory) {
906
+ this._mutationObserverFactory = _mutationObserverFactory;
907
+ /** @Hidden */
908
+ this._observedElements = new Map();
1138
909
  }
1139
910
  /** @hidden */
1140
- setKeyboardService(queryList, wrap, tabKeyNavigation = true) {
1141
- this._itemList = queryList;
1142
- this._tabKeyNavigation = tabKeyNavigation;
1143
- this._keyManager = new FocusKeyManager(queryList).withWrap(wrap).withHomeAndEnd();
1144
- queryList.changes
1145
- .pipe(takeUntil(this._onDestroy$), startWith(0))
1146
- .subscribe(() => this._refreshEscapeLogic(queryList));
911
+ ngOnDestroy() {
912
+ this._observedElements.forEach((_, element) => this._cleanupObserver(element));
913
+ }
914
+ /** @Hidden */
915
+ observe(elementOrRef) {
916
+ const element = getNativeElement(elementOrRef);
917
+ return new Observable((observer) => {
918
+ const stream = this._observeElement(element);
919
+ const subscription = stream.subscribe(observer);
920
+ return () => {
921
+ subscription.unsubscribe();
922
+ this._unobserveElement(element);
923
+ };
924
+ });
925
+ }
926
+ /** @Hidden */
927
+ unobserve(element) {
928
+ this._unobserveElement(getNativeElement(element));
1147
929
  }
1148
930
  /** @hidden */
1149
- onKeyDown(event) {
1150
- this._keyManager.onKeydown(event);
1151
- if (KeyUtil.isKeyCode(event, TAB)) {
1152
- if (KeyUtil.isKeyCode(event, TAB) && this._tabKeyNavigation) {
1153
- event.preventDefault();
1154
- hasModifierKey(event, 'shiftKey')
1155
- ? this.keyManager.setPreviousItemActive()
1156
- : this.keyManager.setNextItemActive();
931
+ _observeElement(element) {
932
+ if (!this._observedElements.has(element)) {
933
+ const stream = new Subject();
934
+ const observer = this._mutationObserverFactory.create((mutations) => stream.next(mutations));
935
+ if (observer) {
936
+ observer.observe(element, {
937
+ attributes: true
938
+ });
1157
939
  }
940
+ this._observedElements.set(element, { observer, stream, count: 1 });
941
+ }
942
+ else {
943
+ this._observedElements.get(element).count++;
1158
944
  }
945
+ return this._observedElements.get(element).stream;
1159
946
  }
1160
- /** Destroys KeyboardSupportService dependencies */
1161
- onDestroy() {
1162
- this._onDestroy$.next();
1163
- this._onDestroy$.complete();
1164
- this._keyManager.destroy();
947
+ /** @Hidden */
948
+ _unobserveElement(element) {
949
+ if (this._observedElements.has(element)) {
950
+ this._observedElements.get(element).count--;
951
+ if (!this._observedElements.get(element).count) {
952
+ this._cleanupObserver(element);
953
+ }
954
+ }
1165
955
  }
1166
956
  /** @hidden */
1167
- _refreshEscapeLogic(queryList) {
1168
- const createEscapeListener = (listItem, onKeyCode, escapeDirection) => {
1169
- listItem.keyDown
1170
- .pipe(takeUntil(unsubscribe$), filter((event) => KeyUtil.isKeyCode(event, onKeyCode)), tap((event) => event.preventDefault()))
1171
- .subscribe(() => this.focusEscapeList.next(escapeDirection));
1172
- };
1173
- /** Finish all of the streams, form before */
1174
- this._onRefresh$.next();
1175
- const unsubscribe$ = merge(this._onRefresh$, this._onDestroy$);
1176
- if (queryList.length) {
1177
- createEscapeListener(queryList.last, DOWN_ARROW, 'down');
1178
- createEscapeListener(queryList.first, UP_ARROW, 'up');
957
+ _cleanupObserver(element) {
958
+ if (this._observedElements.has(element)) {
959
+ const { observer, stream } = this._observedElements.get(element);
960
+ if (observer) {
961
+ observer.disconnect();
962
+ }
963
+ stream.complete();
964
+ this._observedElements.delete(element);
1179
965
  }
1180
966
  }
1181
967
  }
1182
- KeyboardSupportService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1183
- KeyboardSupportService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, providedIn: 'root' });
1184
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: KeyboardSupportService, decorators: [{
968
+ AttributeObserver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, deps: [{ token: i1$2.MutationObserverFactory }], target: i0.ɵɵFactoryTarget.Injectable });
969
+ AttributeObserver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, providedIn: 'root' });
970
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, decorators: [{
1185
971
  type: Injectable,
1186
- args: [{ providedIn: 'root' }]
1187
- }] });
972
+ args: [{
973
+ providedIn: 'root'
974
+ }]
975
+ }], ctorParameters: function () { return [{ type: i1$2.MutationObserverFactory }]; } });
1188
976
 
1189
- class MockStorage {
1190
- // eslint-disable-next-line
1191
- key(index) { }
1192
- clear() { }
1193
- // eslint-disable-next-line
1194
- getItem(key) { }
1195
- // eslint-disable-next-line
1196
- removeItem(key) { }
1197
- // eslint-disable-next-line
1198
- setItem(key, value) { }
977
+ /* eslint-disable @typescript-eslint/member-ordering */
978
+ class DeprecatedAutoCompleteDirective extends DeprecatedSelector {
1199
979
  }
1200
- class LocalStorageService {
980
+ DeprecatedAutoCompleteDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedAutoCompleteDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
981
+ DeprecatedAutoCompleteDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedAutoCompleteDirective, isStandalone: true, selector: "[fdAutoComplete], [fd-auto-complete]", providers: [
982
+ DestroyedService,
983
+ {
984
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
985
+ useValue: getDeprecatedModel('[fdkAutoComplete]', '[fdAutoComplete], [fd-auto-complete]')
986
+ }
987
+ ], usesInheritance: true, ngImport: i0 });
988
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedAutoCompleteDirective, decorators: [{
989
+ type: Directive,
990
+ args: [{
991
+ // eslint-disable-next-line @angular-eslint/directive-selector
992
+ selector: '[fdAutoComplete], [fd-auto-complete]',
993
+ standalone: true,
994
+ providers: [
995
+ DestroyedService,
996
+ {
997
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
998
+ useValue: getDeprecatedModel('[fdkAutoComplete]', '[fdAutoComplete], [fd-auto-complete]')
999
+ }
1000
+ ]
1001
+ }]
1002
+ }] });
1003
+ class AutoCompleteDirective {
1201
1004
  /** @hidden */
1202
- constructor() {
1203
- typeof localStorage !== 'undefined' ? (this._storage = localStorage) : (this._storage = new MockStorage());
1005
+ // eslint-disable-next-line @typescript-eslint/member-ordering
1006
+ constructor(_elementRef, _zone, _destroy$) {
1007
+ this._elementRef = _elementRef;
1008
+ this._zone = _zone;
1009
+ this._destroy$ = _destroy$;
1010
+ /** Whether the auto complete directive should be enabled */
1011
+ this.enable = true;
1012
+ /** Matcher function for testing the str for a search term */
1013
+ this.matcher = (str, searchTerm) => str.startsWith(searchTerm);
1014
+ /** Display function. Accepts an object of the same type as the
1015
+ * items passed to dropdownValues as argument, and outputs a string.
1016
+ * An arrow function can be used to access the *this* keyword in the calling component.
1017
+ * See search input examples for details. */
1018
+ this.displayFn = this._defaultDisplay;
1019
+ /** Event thrown, when the auto ahead text is accepted */
1020
+ this.onComplete = new EventEmitter();
1021
+ /** @hidden */
1022
+ this._completeKeys = [ENTER];
1023
+ /** @hidden */
1024
+ this._fillKeys = [LEFT_ARROW, RIGHT_ARROW];
1025
+ /** @hidden */
1026
+ this._stopKeys = [BACKSPACE, DELETE, ESCAPE];
1027
+ /**
1028
+ * Fixes #10710
1029
+ * WIth chinese characters inputText property update was triggered after the keyup event trigger.
1030
+ * By ensuring that we set all properties we can proceed with stable data.
1031
+ */
1032
+ this._zone.runOutsideAngular(() => {
1033
+ const keyupEvent = fromEvent(this._elementRef.nativeElement, 'keyup');
1034
+ keyupEvent
1035
+ .pipe(switchMap((evt) => this._zone.onStable.pipe(first(), map$1(() => evt))), takeUntil$1(this._destroy$))
1036
+ .subscribe((evt) => {
1037
+ this._handleKeyboardEvent(evt);
1038
+ console.log(this.inputText);
1039
+ });
1040
+ });
1204
1041
  }
1205
- /** Get item from local storage. */
1206
- get(key) {
1207
- const value = this._storage.getItem(key);
1208
- if (value) {
1209
- return JSON.parse(value);
1042
+ /** @hidden */
1043
+ _handleKeyboardEvent(event) {
1044
+ if (this.enable) {
1045
+ if (KeyUtil.isKeyCode(event, this._stopKeys)) {
1046
+ this._elementRef.nativeElement.value = this.inputText;
1047
+ }
1048
+ else if (KeyUtil.isKeyCode(event, this._completeKeys)) {
1049
+ this._sendCompleteEvent(true);
1050
+ this._moveIndicatorToLastCharacter();
1051
+ }
1052
+ else if (KeyUtil.isKeyCode(event, this._fillKeys)) {
1053
+ this._sendCompleteEvent(false);
1054
+ }
1055
+ else if (!this._isControlKey(event) && this.inputText) {
1056
+ /** Prevention from triggering typeahead, when having crtl/cmd + keys */
1057
+ if (!this._triggerTypeAhead()) {
1058
+ return;
1059
+ }
1060
+ this.oldValue = this.inputText;
1061
+ const item = this.options.find((option) => this.matcher(this.displayFn(option).toLocaleLowerCase(), this.inputText.toLocaleLowerCase()));
1062
+ if (item) {
1063
+ this._typeahead(this.displayFn(item));
1064
+ }
1065
+ }
1066
+ }
1067
+ this.lastKeyUpEvent = event;
1068
+ }
1069
+ /** @hidden */
1070
+ _typeahead(displayedValue) {
1071
+ this._elementRef.nativeElement.value = displayedValue;
1072
+ const selectionStartIndex = this.inputText.length;
1073
+ this._elementRef.nativeElement.setSelectionRange(selectionStartIndex, displayedValue.length);
1074
+ }
1075
+ /** @hidden */
1076
+ _isControlKey(event) {
1077
+ return KeyUtil.isKeyCode(event, CONTROL) || event.ctrlKey;
1078
+ }
1079
+ /** @hidden */
1080
+ _defaultDisplay(value) {
1081
+ return value;
1082
+ }
1083
+ /** @hidden */
1084
+ _triggerTypeAhead() {
1085
+ if (this.lastKeyUpEvent &&
1086
+ KeyUtil.isKeyCode(this.lastKeyUpEvent, CONTROL) &&
1087
+ this.inputText === this.oldValue) {
1088
+ return false;
1089
+ }
1090
+ else {
1091
+ return true;
1210
1092
  }
1211
- return null;
1212
1093
  }
1213
- /** Set item in local storage. */
1214
- set(key, value) {
1215
- this._storage.setItem(key, JSON.stringify(value));
1094
+ /** @hidden */
1095
+ _sendCompleteEvent(forceClose) {
1096
+ this.onComplete.emit({
1097
+ term: this._elementRef.nativeElement.value,
1098
+ forceClose
1099
+ });
1100
+ }
1101
+ /** @hidden */
1102
+ _moveIndicatorToLastCharacter() {
1103
+ const inputTextLength = this.inputText?.length ?? 0;
1104
+ this._elementRef.nativeElement.setSelectionRange(inputTextLength, inputTextLength);
1216
1105
  }
1217
1106
  }
1218
- LocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1219
- LocalStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, providedIn: 'root' });
1220
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageService, decorators: [{
1221
- type: Injectable,
1222
- args: [{ providedIn: 'root' }]
1223
- }], ctorParameters: function () { return []; } });
1107
+ AutoCompleteDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: DestroyedService }], target: i0.ɵɵFactoryTarget.Directive });
1108
+ AutoCompleteDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: AutoCompleteDirective, isStandalone: true, selector: "[fdkAutoComplete], [fdAutoComplete], [fd-auto-complete]", inputs: { options: "options", inputText: "inputText", enable: "enable", matcher: "matcher", displayFn: "displayFn" }, outputs: { onComplete: "onComplete" }, ngImport: i0 });
1109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteDirective, decorators: [{
1110
+ type: Directive,
1111
+ args: [{
1112
+ selector: '[fdkAutoComplete], [fdAutoComplete], [fd-auto-complete]',
1113
+ standalone: true
1114
+ }]
1115
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: DestroyedService }]; }, propDecorators: { options: [{
1116
+ type: Input
1117
+ }], inputText: [{
1118
+ type: Input
1119
+ }], enable: [{
1120
+ type: Input
1121
+ }], matcher: [{
1122
+ type: Input
1123
+ }], displayFn: [{
1124
+ type: Input
1125
+ }], onComplete: [{
1126
+ type: Output
1127
+ }] } });
1224
1128
 
1225
- class ResizeObserverFactory {
1226
- /** Factory to create ResizeObserver if it's present in browser. */
1227
- create(callback) {
1228
- return typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(callback);
1229
- }
1129
+ class AutoCompleteModule {
1230
1130
  }
1231
- ResizeObserverFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1232
- ResizeObserverFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, providedIn: 'root' });
1233
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverFactory, decorators: [{
1234
- type: Injectable,
1235
- args: [{ providedIn: 'root' }]
1131
+ AutoCompleteModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1132
+ AutoCompleteModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, imports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective], exports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective] });
1133
+ AutoCompleteModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule });
1134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AutoCompleteModule, decorators: [{
1135
+ type: NgModule,
1136
+ args: [{
1137
+ imports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective],
1138
+ exports: [AutoCompleteDirective, DeprecatedAutoCompleteDirective],
1139
+ declarations: []
1140
+ }]
1236
1141
  }] });
1237
- class ResizeObserverService {
1142
+
1143
+ const FOCUSABLE_ITEM = new InjectionToken('Focusable Option');
1144
+
1145
+ class DeprecatedFocusKeyManagerListDirective extends DeprecatedSelector {
1146
+ }
1147
+ DeprecatedFocusKeyManagerListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerListDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1148
+ DeprecatedFocusKeyManagerListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedFocusKeyManagerListDirective, isStandalone: true, selector: "[fd-focus-key-manager-list], [fdFocusKeyManagerList]", providers: [
1149
+ {
1150
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1151
+ useValue: getDeprecatedModel('[fdkFocusKeyManagerList]', '[fd-focus-key-manager-list], [fdFocusKeyManagerList]')
1152
+ }
1153
+ ], usesInheritance: true, ngImport: i0 });
1154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerListDirective, decorators: [{
1155
+ type: Directive,
1156
+ args: [{
1157
+ // eslint-disable-next-line @angular-eslint/directive-selector
1158
+ selector: '[fd-focus-key-manager-list], [fdFocusKeyManagerList]',
1159
+ standalone: true,
1160
+ providers: [
1161
+ {
1162
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1163
+ useValue: getDeprecatedModel('[fdkFocusKeyManagerList]', '[fd-focus-key-manager-list], [fdFocusKeyManagerList]')
1164
+ }
1165
+ ]
1166
+ }]
1167
+ }] });
1168
+ /** Directive to apply Angular Material FocusKeyManager to lists.
1169
+ * To be used with FocusKeyManagerItemDirective
1170
+ */
1171
+ class FocusKeyManagerListDirective {
1238
1172
  /** @hidden */
1239
- constructor(_resizeObserverFactory) {
1240
- this._resizeObserverFactory = _resizeObserverFactory;
1241
- /** @hidden */
1242
- this._observedElements = new Map();
1173
+ get focusKeyManager() {
1174
+ return this._focusKeyManager;
1243
1175
  }
1244
1176
  /** @hidden */
1245
- ngOnDestroy() {
1246
- this._observedElements.forEach((_, element) => this._cleanupObserver(element));
1247
- }
1248
- /** Observe the given element and emit whenever its size changes. */
1249
- observe(elementOrRef) {
1250
- const element = coerceElement(elementOrRef);
1251
- return new Observable((observer) => {
1252
- const stream = this._observeElement(element);
1253
- const subscription = stream?.subscribe(observer);
1254
- return () => {
1255
- subscription?.unsubscribe();
1256
- this._unobserveElement(element);
1257
- };
1258
- });
1259
- }
1260
- /**
1261
- * Observes the given element by using the existing MutationObserver if available, or creating a
1262
- * new one if not.
1263
- */
1264
- _observeElement(element) {
1265
- let observedElement = this._observedElements.get(element);
1266
- if (!observedElement) {
1267
- const stream = new Subject();
1268
- const observer = this._resizeObserverFactory.create((mutations) => stream.next(mutations));
1269
- if (observer) {
1270
- observer.observe(element);
1271
- }
1272
- observedElement = { observer, stream, count: 0 };
1273
- this._observedElements.set(element, observedElement);
1274
- }
1275
- observedElement.count++;
1276
- return observedElement?.stream;
1177
+ constructor(_rtlService, _cdr) {
1178
+ this._rtlService = _rtlService;
1179
+ this._cdr = _cdr;
1180
+ /** @hidden */
1181
+ this._onDestroy$ = new Subject();
1277
1182
  }
1278
- /**
1279
- * Un-observes the given element and cleans up the underlying MutationObserver if nobody else is
1280
- * observing this element.
1281
- */
1282
- _unobserveElement(element) {
1283
- const observedElement = this._observedElements.get(element);
1284
- if (!observedElement) {
1285
- return;
1286
- }
1287
- if (--observedElement.count) {
1183
+ /** @hidden */
1184
+ ngOnChanges(changes) {
1185
+ if (!this._focusKeyManager) {
1288
1186
  return;
1289
1187
  }
1290
- this._cleanupObserver(element);
1291
- }
1292
- /** Clean up the underlying MutationObserver for the specified element. */
1293
- _cleanupObserver(element) {
1294
- const observedElement = this._observedElements.get(element);
1295
- if (!observedElement) {
1296
- return;
1188
+ if ('orientation' in changes) {
1189
+ this._applyOrientation();
1297
1190
  }
1298
- const { observer, stream } = observedElement;
1299
- if (observer) {
1300
- observer.disconnect();
1191
+ if ('skiPredicate' in changes) {
1192
+ this._focusKeyManager.skipPredicate(this.skipPredicate);
1301
1193
  }
1302
- stream.complete();
1303
- this._observedElements.delete(element);
1304
1194
  }
1305
- }
1306
- ResizeObserverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, deps: [{ token: ResizeObserverFactory }], target: i0.ɵɵFactoryTarget.Injectable });
1307
- ResizeObserverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, providedIn: 'root' });
1308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ResizeObserverService, decorators: [{
1309
- type: Injectable,
1310
- args: [{ providedIn: 'root' }]
1311
- }], ctorParameters: function () { return [{ type: ResizeObserverFactory }]; } });
1312
-
1313
- class TabbableElementService {
1314
1195
  /** @hidden */
1315
- constructor(_checker, _document) {
1316
- this._checker = _checker;
1317
- this._document = _document;
1196
+ ngAfterContentInit() {
1197
+ this._focusKeyManager = new FocusKeyManager(this._items).skipPredicate(this.skipPredicate);
1198
+ this._applyOrientation();
1199
+ this._cdr.detectChanges();
1200
+ this._rtlService?.rtl
1201
+ .pipe(filter(() => this.orientation === 'horizontal'), takeUntil(this._onDestroy$))
1202
+ .subscribe(() => this._applyOrientation());
1318
1203
  }
1319
- /** Get the first tabbable element from a DOM subtree (inclusive). */
1320
- getTabbableElement(root, focusLastElement = false, skipSelf = false) {
1321
- if (!skipSelf && this._checker.isFocusable(root) && this._checker.isTabbable(root)) {
1322
- return root;
1204
+ /** @hidden */
1205
+ ngOnDestroy() {
1206
+ this._onDestroy$.next();
1207
+ this._onDestroy$.complete();
1208
+ this._focusKeyManager.destroy();
1209
+ }
1210
+ /** Focus certain list's item */
1211
+ focusItem(item) {
1212
+ if (typeof item === 'number') {
1213
+ this._focusKeyManager.setActiveItem(item);
1323
1214
  }
1324
- // Iterate in DOM order. Note that IE doesn't have `children` for SVG, so we fall
1325
- // back to `childNodes` which includes text nodes, comments etc.
1326
- const rootChildren = root.children || root.childNodes;
1327
- const children = focusLastElement ? Array.from(rootChildren).reverse() : rootChildren;
1328
- for (let i = 0; i < children.length; i++) {
1329
- const tabbableChild = children[i].nodeType === this._document?.ELEMENT_NODE
1330
- ? this.getTabbableElement(children[i], focusLastElement)
1331
- : null;
1332
- if (tabbableChild) {
1333
- return tabbableChild;
1334
- }
1215
+ else {
1216
+ this._focusKeyManager.setActiveItem(item);
1217
+ }
1218
+ }
1219
+ /** @hidden */
1220
+ _applyOrientation() {
1221
+ switch (this.orientation) {
1222
+ case 'horizontal':
1223
+ this._focusKeyManager.withHorizontalOrientation(this._rtlService?.rtl.value ? 'rtl' : 'ltr');
1224
+ break;
1225
+ case 'vertical':
1226
+ this._focusKeyManager.withVerticalOrientation(true);
1227
+ break;
1335
1228
  }
1336
- return null;
1337
1229
  }
1338
1230
  }
1339
- TabbableElementService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, deps: [{ token: i1$1.InteractivityChecker }, { token: DOCUMENT, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1340
- TabbableElementService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, providedIn: 'root' });
1341
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TabbableElementService, decorators: [{
1342
- type: Injectable,
1343
- args: [{ providedIn: 'root' }]
1344
- }], ctorParameters: function () { return [{ type: i1$1.InteractivityChecker }, { type: Document, decorators: [{
1231
+ FocusKeyManagerListDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerListDirective, deps: [{ token: RtlService, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
1232
+ FocusKeyManagerListDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: FocusKeyManagerListDirective, isStandalone: true, selector: "[fdkFocusKeyManagerList], [fd-focus-key-manager-list], [fdFocusKeyManagerList]", inputs: { orientation: "orientation", skipPredicate: "skipPredicate" }, queries: [{ propertyName: "_items", predicate: FOCUSABLE_ITEM }], usesOnChanges: true, ngImport: i0 });
1233
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerListDirective, decorators: [{
1234
+ type: Directive,
1235
+ args: [{
1236
+ selector: `[fdkFocusKeyManagerList], [fd-focus-key-manager-list], [fdFocusKeyManagerList]`,
1237
+ standalone: true
1238
+ }]
1239
+ }], ctorParameters: function () { return [{ type: RtlService, decorators: [{
1345
1240
  type: Optional
1346
- }, {
1347
- type: Inject,
1348
- args: [DOCUMENT]
1349
- }] }]; } });
1350
-
1351
- /**
1352
- * Retrieves native element from ElementRef.
1353
- */
1354
- function getNativeElement(element) {
1355
- let coercible = element;
1356
- if (hasElementRef(element)) {
1357
- coercible = element.elementRef;
1358
- }
1359
- return coerceElement(coercible);
1241
+ }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { orientation: [{
1242
+ type: Input
1243
+ }], skipPredicate: [{
1244
+ type: Input
1245
+ }], _items: [{
1246
+ type: ContentChildren,
1247
+ args: [FOCUSABLE_ITEM]
1248
+ }] } });
1249
+
1250
+ class DeprecatedFocusKeyManagerItemDirective extends DeprecatedSelector {
1360
1251
  }
1361
- /**
1362
- * Checks whether object has element reference in it.
1252
+ DeprecatedFocusKeyManagerItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerItemDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1253
+ DeprecatedFocusKeyManagerItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedFocusKeyManagerItemDirective, isStandalone: true, selector: "[fd-focus-key-manager-item], [fdFocusKeyManagerItem]", providers: [
1254
+ {
1255
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1256
+ useValue: getDeprecatedModel('[fdkFocusKeyManagerItem]', '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]')
1257
+ }
1258
+ ], usesInheritance: true, ngImport: i0 });
1259
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedFocusKeyManagerItemDirective, decorators: [{
1260
+ type: Directive,
1261
+ args: [{
1262
+ // eslint-disable-next-line @angular-eslint/directive-selector
1263
+ selector: '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]',
1264
+ standalone: true,
1265
+ providers: [
1266
+ {
1267
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1268
+ useValue: getDeprecatedModel('[fdkFocusKeyManagerItem]', '[fd-focus-key-manager-item], [fdFocusKeyManagerItem]')
1269
+ }
1270
+ ]
1271
+ }]
1272
+ }] });
1273
+ /** Directive to apply Angular Material FocusKeyManager to lists.
1274
+ * To be used with FocusKeyManagerItemDirective
1363
1275
  */
1364
- function hasElementRef(something) {
1365
- return something && something['elementRef'] instanceof ElementRef;
1366
- }
1367
-
1368
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
1369
- class AttributeObserver {
1276
+ class FocusKeyManagerItemDirective {
1277
+ /** Whether item should be initially focused */
1278
+ set initialFocus(value) {
1279
+ this._initialFocus = coerceBooleanProperty(value);
1280
+ }
1370
1281
  /** @hidden */
1371
- constructor(_mutationObserverFactory) {
1372
- this._mutationObserverFactory = _mutationObserverFactory;
1373
- /** @Hidden */
1374
- this._observedElements = new Map();
1282
+ get _tabindex() {
1283
+ if (this._initialFocus) {
1284
+ return 0;
1285
+ }
1286
+ return this.nativeElement?.tabIndex ?? -1;
1287
+ }
1288
+ /** Native element of the item */
1289
+ get nativeElement() {
1290
+ return this._elRef?.nativeElement;
1375
1291
  }
1376
1292
  /** @hidden */
1377
- ngOnDestroy() {
1378
- this._observedElements.forEach((_, element) => this._cleanupObserver(element));
1293
+ get _focusKeyManager() {
1294
+ return this._list.focusKeyManager;
1379
1295
  }
1380
- /** @Hidden */
1381
- observe(elementOrRef) {
1382
- const element = getNativeElement(elementOrRef);
1383
- return new Observable((observer) => {
1384
- const stream = this._observeElement(element);
1385
- const subscription = stream.subscribe(observer);
1386
- return () => {
1387
- subscription.unsubscribe();
1388
- this._unobserveElement(element);
1389
- };
1390
- });
1296
+ /** @hidden */
1297
+ constructor(_list, _elRef) {
1298
+ this._list = _list;
1299
+ this._elRef = _elRef;
1300
+ /** @hidden */
1301
+ this._initialFocus = false;
1391
1302
  }
1392
- /** @Hidden */
1393
- unobserve(element) {
1394
- this._unobserveElement(getNativeElement(element));
1303
+ /** @hidden */
1304
+ _onFocus() {
1305
+ // For cases where initially selected item doesn't have 0 index
1306
+ this._focusKeyManager?.updateActiveItem(this);
1395
1307
  }
1396
1308
  /** @hidden */
1397
- _observeElement(element) {
1398
- if (!this._observedElements.has(element)) {
1399
- const stream = new Subject();
1400
- const observer = this._mutationObserverFactory.create((mutations) => stream.next(mutations));
1401
- if (observer) {
1402
- observer.observe(element, {
1403
- attributes: true
1404
- });
1405
- }
1406
- this._observedElements.set(element, { observer, stream, count: 1 });
1407
- }
1408
- else {
1409
- this._observedElements.get(element).count++;
1410
- }
1411
- return this._observedElements.get(element).stream;
1309
+ _onKeydown(event) {
1310
+ this._focusKeyManager?.onKeydown(event);
1412
1311
  }
1413
- /** @Hidden */
1414
- _unobserveElement(element) {
1415
- if (this._observedElements.has(element)) {
1416
- this._observedElements.get(element).count--;
1417
- if (!this._observedElements.get(element).count) {
1418
- this._cleanupObserver(element);
1419
- }
1420
- }
1312
+ /** Focus current item native element */
1313
+ focus() {
1314
+ this._elRef?.nativeElement.focus();
1421
1315
  }
1316
+ }
1317
+ FocusKeyManagerItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerItemDirective, deps: [{ token: FocusKeyManagerListDirective }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1318
+ FocusKeyManagerItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: FocusKeyManagerItemDirective, isStandalone: true, selector: "[fdkFocusKeyManagerItem], [fd-focus-key-manager-item], [fdFocusKeyManagerItem]", inputs: { initialFocus: "initialFocus", _tabindex: "_tabindex" }, host: { listeners: { "focus": "_onFocus()", "keydown": "_onKeydown($event)" }, properties: { "attr.tabindex": "this._tabindex" } }, providers: [{ provide: FOCUSABLE_ITEM, useExisting: forwardRef(() => FocusKeyManagerItemDirective) }], ngImport: i0 });
1319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerItemDirective, decorators: [{
1320
+ type: Directive,
1321
+ args: [{
1322
+ selector: '[fdkFocusKeyManagerItem], [fd-focus-key-manager-item], [fdFocusKeyManagerItem]',
1323
+ standalone: true,
1324
+ providers: [{ provide: FOCUSABLE_ITEM, useExisting: forwardRef(() => FocusKeyManagerItemDirective) }]
1325
+ }]
1326
+ }], ctorParameters: function () { return [{ type: FocusKeyManagerListDirective }, { type: i0.ElementRef }]; }, propDecorators: { initialFocus: [{
1327
+ type: Input
1328
+ }], _tabindex: [{
1329
+ type: Input
1330
+ }, {
1331
+ type: HostBinding,
1332
+ args: ['attr.tabindex']
1333
+ }], _onFocus: [{
1334
+ type: HostListener,
1335
+ args: ['focus']
1336
+ }], _onKeydown: [{
1337
+ type: HostListener,
1338
+ args: ['keydown', ['$event']]
1339
+ }] } });
1340
+
1341
+ class FocusKeyManagerHelpersModule {
1342
+ }
1343
+ FocusKeyManagerHelpersModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1344
+ FocusKeyManagerHelpersModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, imports: [FocusKeyManagerItemDirective,
1345
+ FocusKeyManagerListDirective,
1346
+ DeprecatedFocusKeyManagerItemDirective,
1347
+ DeprecatedFocusKeyManagerListDirective], exports: [FocusKeyManagerItemDirective,
1348
+ FocusKeyManagerListDirective,
1349
+ DeprecatedFocusKeyManagerItemDirective,
1350
+ DeprecatedFocusKeyManagerListDirective] });
1351
+ FocusKeyManagerHelpersModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule });
1352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FocusKeyManagerHelpersModule, decorators: [{
1353
+ type: NgModule,
1354
+ args: [{
1355
+ imports: [
1356
+ FocusKeyManagerItemDirective,
1357
+ FocusKeyManagerListDirective,
1358
+ DeprecatedFocusKeyManagerItemDirective,
1359
+ DeprecatedFocusKeyManagerListDirective
1360
+ ],
1361
+ exports: [
1362
+ FocusKeyManagerItemDirective,
1363
+ FocusKeyManagerListDirective,
1364
+ DeprecatedFocusKeyManagerItemDirective,
1365
+ DeprecatedFocusKeyManagerListDirective
1366
+ ]
1367
+ }]
1368
+ }] });
1369
+
1370
+ const IgnoreClickOnSelectionDirectiveToken = new InjectionToken('Ignore click on selection directive');
1371
+
1372
+ class DeprecatedIgnoreClickOnSelectionDirective extends DeprecatedSelector {
1373
+ }
1374
+ DeprecatedIgnoreClickOnSelectionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedIgnoreClickOnSelectionDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1375
+ DeprecatedIgnoreClickOnSelectionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: DeprecatedIgnoreClickOnSelectionDirective, isStandalone: true, selector: "[fdIgnoreClickOnSelection]", providers: [
1376
+ {
1377
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1378
+ useValue: getDeprecatedModel('[fdkIgnoreClickOnSelection]', '[fdIgnoreClickOnSelection]')
1379
+ }
1380
+ ], usesInheritance: true, ngImport: i0 });
1381
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DeprecatedIgnoreClickOnSelectionDirective, decorators: [{
1382
+ type: Directive,
1383
+ args: [{
1384
+ // eslint-disable-next-line @angular-eslint/directive-selector
1385
+ selector: '[fdIgnoreClickOnSelection]',
1386
+ standalone: true,
1387
+ providers: [
1388
+ {
1389
+ provide: FD_DEPRECATED_DIRECTIVE_SELECTOR,
1390
+ useValue: getDeprecatedModel('[fdkIgnoreClickOnSelection]', '[fdIgnoreClickOnSelection]')
1391
+ }
1392
+ ]
1393
+ }]
1394
+ }] });
1395
+ /**
1396
+ * Directive will stop propagation and prevent default of click, if selected area is coming from
1397
+ * directive's host element. This gives ability to not cancel all clicks on element, just the ones
1398
+ * which include selection
1399
+ */
1400
+ class IgnoreClickOnSelectionDirective {
1422
1401
  /** @hidden */
1423
- _cleanupObserver(element) {
1424
- if (this._observedElements.has(element)) {
1425
- const { observer, stream } = this._observedElements.get(element);
1426
- if (observer) {
1427
- observer.disconnect();
1402
+ constructor(document, _elementRef) {
1403
+ this.document = document;
1404
+ this._elementRef = _elementRef;
1405
+ }
1406
+ /** Host click listener. Checks for selection existence and if finds one, checks anchor */
1407
+ clicked($event) {
1408
+ const selection = this.document.getSelection();
1409
+ if (selection?.toString()) {
1410
+ if (selection.anchorNode &&
1411
+ (this._elementRef.nativeElement.isSameNode(selection.anchorNode) ||
1412
+ this._elementRef.nativeElement.isSameNode(selection.anchorNode.parentElement))) {
1413
+ $event.stopPropagation();
1414
+ $event.preventDefault();
1428
1415
  }
1429
- stream.complete();
1430
- this._observedElements.delete(element);
1431
1416
  }
1432
1417
  }
1433
1418
  }
1434
- AttributeObserver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, deps: [{ token: i1$2.MutationObserverFactory }], target: i0.ɵɵFactoryTarget.Injectable });
1435
- AttributeObserver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, providedIn: 'root' });
1436
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AttributeObserver, decorators: [{
1437
- type: Injectable,
1419
+ IgnoreClickOnSelectionDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionDirective, deps: [{ token: DOCUMENT }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
1420
+ IgnoreClickOnSelectionDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: IgnoreClickOnSelectionDirective, isStandalone: true, selector: "[fdkIgnoreClickOnSelection], [fdIgnoreClickOnSelection]", host: { listeners: { "click": "clicked($event)" } }, providers: [
1421
+ {
1422
+ provide: IgnoreClickOnSelectionDirectiveToken,
1423
+ useExisting: IgnoreClickOnSelectionDirective
1424
+ }
1425
+ ], ngImport: i0 });
1426
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionDirective, decorators: [{
1427
+ type: Directive,
1438
1428
  args: [{
1439
- providedIn: 'root'
1429
+ selector: '[fdkIgnoreClickOnSelection], [fdIgnoreClickOnSelection]',
1430
+ standalone: true,
1431
+ providers: [
1432
+ {
1433
+ provide: IgnoreClickOnSelectionDirectiveToken,
1434
+ useExisting: IgnoreClickOnSelectionDirective
1435
+ }
1436
+ ]
1440
1437
  }]
1441
- }], ctorParameters: function () { return [{ type: i1$2.MutationObserverFactory }]; } });
1438
+ }], ctorParameters: function () { return [{ type: Document, decorators: [{
1439
+ type: Inject,
1440
+ args: [DOCUMENT]
1441
+ }] }, { type: i0.ElementRef }]; }, propDecorators: { clicked: [{
1442
+ type: HostListener,
1443
+ args: ['click', ['$event']]
1444
+ }] } });
1445
+
1446
+ class IgnoreClickOnSelectionModule {
1447
+ }
1448
+ IgnoreClickOnSelectionModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1449
+ IgnoreClickOnSelectionModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, imports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective], exports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective] });
1450
+ IgnoreClickOnSelectionModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule });
1451
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IgnoreClickOnSelectionModule, decorators: [{
1452
+ type: NgModule,
1453
+ args: [{
1454
+ imports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective],
1455
+ exports: [IgnoreClickOnSelectionDirective, DeprecatedIgnoreClickOnSelectionDirective]
1456
+ }]
1457
+ }] });
1442
1458
 
1443
1459
  class DeprecatedInitialFocusDirective extends DeprecatedSelector {
1444
1460
  constructor() {