@progress/kendo-angular-spreadsheet
Version:
A Spreadsheet Component for Angular
62 lines (61 loc) • 2.34 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 { EventEmitter, Injectable, NgZone, Output } from '@angular/core';
import * as i0 from "@angular/core";
/**
* @hidden
*/
export class SpreadsheetToolsService {
ngZone;
stateChange = new EventEmitter();
set toolsState(state) {
this._toolsState = state;
}
get toolsState() {
return this._toolsState;
}
toolsFunctions = [
'bold',
'italic',
'underline',
'fontFamily',
'fontSize',
'color',
'background',
'textAlign',
'verticalAlign',
'wrap',
'gridLines',
'format'
];
_toolsState = {};
constructor(ngZone) {
this.ngZone = ngZone;
}
updateTools = (e) => {
this.ngZone.run(() => {
const state = {};
this.toolsFunctions.forEach(tool => {
if (typeof e.range[tool] === 'function') {
state[tool] = e.range[tool]();
}
else if (tool === 'gridLines') {
state[tool] = e.range.sheet().showGridLines();
}
});
if (this.toolsFunctions.some(k => state[k] !== this.toolsState[k])) {
this.toolsState = state;
this.stateChange.emit(state);
}
});
};
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetToolsService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetToolsService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SpreadsheetToolsService, decorators: [{
type: Injectable
}], ctorParameters: function () { return [{ type: i0.NgZone }]; }, propDecorators: { stateChange: [{
type: Output
}] } });