import { FocusMonitor } from '@angular/cdk/a11y' ; import { Inject , Injectable , Optional , Renderer2 , RendererFactory2 } from '@angular/core' ; import { AccessibilityOptions } from '../options/accessibility-options.interface' ; import { AccessibilityOptionsService } from '../options/accessibility-options.service' ; import { ACCESSIBILITY_OPTIONS_TOKEN } from '../options/accessibility-options.token' ; import { FocusIndicator } from './focus-indicator' ; import { FocusIndicatorOptions } from './focus-indicator-options.interface' ; import { FocusIndicatorOriginService } from './focus-indicator-origin/focus-indicator-origin.service' ; @ Injectable ( ) export class FocusIndicatorService { /** We need the renderer to add and remove classes */ private _renderer : Renderer2 ; constructor ( private _focusMonitor , private _globalOptions , private _focusIndicatorOrigin , @ Optional ( ) @ Inject ( ACCESSIBILITY_OPTIONS_TOKEN ) private _localOptions , rendererFactory ) { this . _renderer = rendererFactory . createRenderer ( null , null ) ; } /** This is essentially just a factory method to prevent the user having to pass in focus monitor, renderer and global options each time */ monitor ( element , options = { ... this . _globalOptions . options , ... this . _localOptions , checkChildren : false } ) { return new FocusIndicator ( element , this . _focusMonitor , this . _renderer , { ... this . _globalOptions . options , ... this . _localOptions , ... options } , this . _focusIndicatorOrigin ) ; } }