/** * @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 { Directionality } from '@angular/cdk/bidi'; import { coerceNumberProperty } from '@angular/cdk/coercion'; import { Directive, ElementRef, Input, Optional } from '@angular/core'; import { takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { CdkTree, CdkTreeNode } from './tree'; import * as i0 from "@angular/core"; import * as i1 from "./tree"; import * as i2 from "@angular/cdk/bidi"; /** Regex used to split a string on its CSS units. */ const cssUnitPattern = /([A-Za-z%]+)$/; /** * Indent for the children tree dataNodes. * This directive will add left-padding to the node to show hierarchy. */ export class CdkTreeNodePadding { /** The level of depth of the tree node. The padding will be `level * indent` pixels. */ get level() { return this._level; } set level(value) { this._setLevelInput(value); } /** * The indent for each level. Can be a number or a CSS string. * Default number 40px from material design menu sub-menu spec. */ get indent() { return this._indent; } set indent(indent) { this._setIndentInput(indent); } constructor(_treeNode, _tree, _element, _dir) { this._treeNode = _treeNode; this._tree = _tree; this._element = _element; this._dir = _dir; /** Subject that emits when the component has been destroyed. */ this._destroyed = new Subject(); /** CSS units used for the indentation value. */ this.indentUnits = 'px'; this._indent = 40; this._setPadding(); if (_dir) { _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => this._setPadding(true)); } // In Ivy the indentation binding might be set before the tree node's data has been added, // which means that we'll miss the first render. We have to subscribe to changes in the // data to ensure that everything is up to date. _treeNode._dataChanges.subscribe(() => this._setPadding()); } ngOnDestroy() { this._destroyed.next(); this._destroyed.complete(); } /** The padding indent value for the tree node. Returns a string with px numbers if not null. */ _paddingIndent() { const nodeLevel = this._treeNode.data && this._tree.treeControl.getLevel ? this._tree.treeControl.getLevel(this._treeNode.data) : null; const level = this._level == null ? nodeLevel : this._level; return typeof level === 'number' ? `${level * this._indent}${this.indentUnits}` : null; } _setPadding(forceChange = false) { const padding = this._paddingIndent(); if (padding !== this._currentPadding || forceChange) { const element = this._element.nativeElement; const paddingProp = this._dir && this._dir.value === 'rtl' ? 'paddingRight' : 'paddingLeft'; const resetProp = paddingProp === 'paddingLeft' ? 'paddingRight' : 'paddingLeft'; element.style[paddingProp] = padding || ''; element.style[resetProp] = ''; this._currentPadding = padding; } } /** * This has been extracted to a util because of TS 4 and VE. * View Engine doesn't support property rename inheritance. * TS 4.0 doesn't allow properties to override accessors or vice-versa. * @docs-private */ _setLevelInput(value) { // Set to null as the fallback value so that _setPadding can fall back to the node level if the // consumer set the directive as `cdkTreeNodePadding=""`. We still want to take this value if // they set 0 explicitly. this._level = coerceNumberProperty(value, null); this._setPadding(); } /** * This has been extracted to a util because of TS 4 and VE. * View Engine doesn't support property rename inheritance. * TS 4.0 doesn't allow properties to override accessors or vice-versa. * @docs-private */ _setIndentInput(indent) { let value = indent; let units = 'px'; if (typeof indent === 'string') { const parts = indent.split(cssUnitPattern); value = parts[0]; units = parts[1] || units; } this.indentUnits = units; this._indent = coerceNumberProperty(value); this._setPadding(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkTreeNodePadding, deps: [{ token: i1.CdkTreeNode }, { token: i1.CdkTree }, { token: i0.ElementRef }, { token: i2.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: CdkTreeNodePadding, selector: "[cdkTreeNodePadding]", inputs: { level: ["cdkTreeNodePadding", "level"], indent: ["cdkTreeNodePaddingIndent", "indent"] }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkTreeNodePadding, decorators: [{ type: Directive, args: [{ selector: '[cdkTreeNodePadding]', }] }], ctorParameters: function () { return [{ type: i1.CdkTreeNode }, { type: i1.CdkTree }, { type: i0.ElementRef }, { type: i2.Directionality, decorators: [{ type: Optional }] }]; }, propDecorators: { level: [{ type: Input, args: ['cdkTreeNodePadding'] }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