UNPKG

@progress/kendo-angular-spreadsheet

Version:

A Spreadsheet Component for Angular

63 lines (62 loc) 3.67 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive } from '@angular/core'; import { SpreadsheetLocalizationService } from '../../localization/spreadsheet-localization.service'; import { SpreadsheetService } from '../../common/spreadsheet.service'; import { commandIcons, commandSVGIcons } from '../shared/command-icons'; import { ALIGNS } from '../shared/constants'; import { ToolBarDropDownButtonComponent } from '@progress/kendo-angular-toolbar'; import { Subscription } from 'rxjs'; import { SpreadsheetToolsService } from '../tools.service'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-toolbar"; import * as i2 from "../../localization/spreadsheet-localization.service"; import * as i3 from "../../common/spreadsheet.service"; import * as i4 from "../tools.service"; /** * @hidden */ export class SpreadsheetHorizontalTextAlignDirective { host; spreadsheetService; toolsService; commandName = 'alignHorizontal'; subs = new Subscription(); constructor(host, localization, spreadsheetService, toolsService) { this.host = host; this.spreadsheetService = spreadsheetService; this.toolsService = toolsService; host.svgIcon = commandSVGIcons[this.commandName]; host.icon = commandIcons[this.commandName]; host.arrowIcon = true; host.fillMode = 'flat'; host.data = ALIGNS.flatMap(item => item.commandName === 'textAlign' ? [{ ...item, textKey: localization.get(item.commandId) }] : []); this.subs.add(host.itemClick.subscribe((e) => this.onItemClick(e))); host.title = localization.get(this.commandName); host.textField = 'textKey'; } ngOnInit() { this.subs.add(this.toolsService.stateChange.subscribe(state => this.host.data.forEach(i => i.cssClass = i.value === state[i.commandName] ? 'k-selected' : ''))); } ngOnDestroy() { this.subs.unsubscribe(); } onItemClick(item) { const value = item.value || null; const options = { command: 'PropertyChangeCommand', options: { property: item.commandName, value } }; this.spreadsheetService.spreadsheet.executeCommand(options); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetHorizontalTextAlignDirective, deps: [{ token: i1.ToolBarDropDownButtonComponent }, { token: i2.SpreadsheetLocalizationService }, { token: i3.SpreadsheetService }, { token: i4.SpreadsheetToolsService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SpreadsheetHorizontalTextAlignDirective, isStandalone: true, selector: "[kendoSpreadsheetHorizontalTextAlign]", ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetHorizontalTextAlignDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoSpreadsheetHorizontalTextAlign]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.ToolBarDropDownButtonComponent }, { type: i2.SpreadsheetLocalizationService }, { type: i3.SpreadsheetService }, { type: i4.SpreadsheetToolsService }]; } });