/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { Directive, ElementRef, Inject, InjectionToken, Input, Optional, SkipSelf, } from '@angular/core'; import { Subject } from 'rxjs'; import { CDK_DRAG_PARENT } from '../drag-parent'; import { assertElementNode } from './assertions'; /** * Injection token that can be used to reference instances of `CdkDragHandle`. It serves as * alternative token to the actual `CdkDragHandle` class which could cause unnecessary * retention of the class and its directive metadata. */ export const CDK_DRAG_HANDLE = new InjectionToken('CdkDragHandle'); /** Handle that can be used to drag a CdkDrag instance. */ export class CdkDragHandle { constructor(element, parentDrag) { this.element = element; /** Emits when the state of the handle has changed. */ this._stateChanges = new Subject(); this._disabled = false; if (typeof ngDevMode === 'undefined' || ngDevMode) { assertElementNode(element.nativeElement, 'cdkDragHandle'); } this._parentDrag = parentDrag; } /** Whether starting to drag through this handle is disabled. */ get disabled() { return this._disabled; } set disabled(value) { this._disabled = coerceBooleanProperty(value); this._stateChanges.next(this); } ngOnDestroy() { this._stateChanges.complete(); } } CdkDragHandle.decorators = [ { type: Directive, args: [{ selector: '[cdkDragHandle]', host: { 'class': 'cdk-drag-handle' }, providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }], },] } ]; CdkDragHandle.ctorParameters = () => [ { type: ElementRef }, { type: undefined, decorators: [{ type: Inject, args: [CDK_DRAG_PARENT,] }, { type: Optional }, { type: SkipSelf }] } ]; CdkDragHandle.propDecorators = { disabled: [{ type: Input, args: ['cdkDragHandleDisabled',] }] }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJhZy1oYW5kbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2RyYWctZHJvcC9kaXJlY3RpdmVzL2RyYWctaGFuZGxlLnRzIl0sIm5hbWVzIj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