@progress/kendo-angular-spreadsheet
Version:
A Spreadsheet Component for Angular
74 lines (73 loc) • 3.77 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Subscription } from 'rxjs';
import { ToolBarButtonComponent } from '@progress/kendo-angular-toolbar';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { SpreadsheetService } from '../../common/spreadsheet.service';
import { Directive, Inject } from '@angular/core';
import { SpreadsheetToolsService } from '../tools.service';
import { commandIcons, commandSVGIcons } from './command-icons';
import { MY_TOKEN } from './constants';
import { take } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-toolbar";
import * as i2 from "@progress/kendo-angular-l10n";
import * as i3 from "../../common/spreadsheet.service";
import * as i4 from "../tools.service";
/**
* @hidden
*/
export class SpreadsheetCommandBaseDirective {
command;
button;
localization;
spreadsheetService;
toolsService;
subs = new Subscription();
constructor(command, button, localization, spreadsheetService, toolsService) {
this.command = command;
this.button = button;
this.localization = localization;
this.spreadsheetService = spreadsheetService;
this.toolsService = toolsService;
const text = this.localization.get(this.command);
if (text) {
this.button.showText = 'menu';
this.button.showIcon = 'always';
this.button.text = text;
}
if (!this.button.toolbarOptions.icon) {
this.button.icon = commandIcons[this.command];
}
if (!this.button.toolbarOptions.svgIcon) {
this.button.svgIcon = commandSVGIcons[this.command];
}
this.button.title = text;
this.button.fillMode = 'flat';
this.subs.add(this.toolsService.stateChange.subscribe(state => {
this.toolsService.ngZone.onStable.pipe(take(1)).subscribe(() => this.button.selected = state[command]);
}));
}
ngOnInit() {
this.subs.add(this.button.click.subscribe((this.clickHandler.bind(this))));
this.subs.add(this.button.pointerdown.subscribe((this.pointerdownHandler.bind(this))));
}
ngOnDestroy() {
this.subs.unsubscribe();
}
clickHandler() { }
pointerdownHandler(_event) { }
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetCommandBaseDirective, deps: [{ token: MY_TOKEN }, { token: i1.ToolBarButtonComponent }, { token: i2.LocalizationService }, { token: i3.SpreadsheetService }, { token: i4.SpreadsheetToolsService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SpreadsheetCommandBaseDirective, selector: "[kendoSpreadsheetCommandBase]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetCommandBaseDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoSpreadsheetCommandBase]'
}]
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
type: Inject,
args: [MY_TOKEN]
}] }, { type: i1.ToolBarButtonComponent }, { type: i2.LocalizationService }, { type: i3.SpreadsheetService }, { type: i4.SpreadsheetToolsService }]; } });