@progress/kendo-angular-spreadsheet
Version:
A Spreadsheet Component for Angular
66 lines (65 loc) • 3.48 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 { Directive } from '@angular/core';
import { ToolBarDropDownButtonComponent } from '@progress/kendo-angular-toolbar';
import { SpreadsheetLocalizationService } from '../localization/spreadsheet-localization.service';
import { SpreadsheetService } from '../common/spreadsheet.service';
import { commandIcons, commandSVGIcons } from './shared/command-icons';
import { FORMATS } from './shared/constants';
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 SpreadsheetFormatDirective {
host;
spreadsheetService;
toolsService;
data = FORMATS;
commandName = 'format';
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 = this.data;
this.subs.add(host.itemClick.subscribe((e) => this.onItemClick(e)));
host.title = localization.get(this.commandName);
}
ngOnInit() {
this.subs.add(this.toolsService.stateChange.subscribe(state => this.host.data.forEach(i => i.cssClass = i.value === state[this.commandName] ? 'k-selected' : '')));
}
ngOnDestroy() {
this.subs.unsubscribe();
}
/**
* @hidden
*/
onItemClick = (item) => {
const value = item.value || null;
const options = {
command: 'PropertyChangeCommand', options: { property: this.commandName, value }
};
this.spreadsheetService.spreadsheet.executeCommand(options);
};
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetFormatDirective, 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: SpreadsheetFormatDirective, isStandalone: true, selector: "[kendoSpreadsheetFormat]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetFormatDirective, decorators: [{
type: Directive,
args: [{
selector: '[kendoSpreadsheetFormat]',
standalone: true
}]
}], ctorParameters: function () { return [{ type: i1.ToolBarDropDownButtonComponent }, { type: i2.SpreadsheetLocalizationService }, { type: i3.SpreadsheetService }, { type: i4.SpreadsheetToolsService }]; } });