UNPKG

@grapecity/spread-sheets-designer-angular

Version:

SpreadJS Designer Angular Wrapper

124 lines (119 loc) 5.12 kB
import * as i0 from '@angular/core'; import { EventEmitter, Component, ViewEncapsulation, Input, Output, NgModule } from '@angular/core'; import * as GC from '@grapecity/spread-sheets'; import '@grapecity/spread-sheets-designer'; import { Observable } from 'rxjs'; import { CommonModule } from '@angular/common'; class DesignerComponent { constructor(elRef) { this.elRef = elRef; this.designerInitialized = new EventEmitter(); } ngAfterViewInit() { const dom = this.elRef.nativeElement; const { config, spreadOptions } = this.props; this.designer = new GC["default"].Spread.Sheets.Designer.Designer(dom.querySelector('div'), undefined, undefined, spreadOptions); if (config) { this.setConfig(config); } this.designer.refresh(); this.designerInitialized.emit({ designer: this.designer }); } setStyleInfo(styleinfo) { if (styleinfo instanceof Observable) { let styleObChange = styleinfo.subscribe({ next: arg => this.updateStyleInfo(arg), error: e => console.error(e), complete: () => styleObChange.unsubscribe() }); } else { this.styleInfo = styleinfo; } } setConfig(config) { if (config instanceof Observable) { let configObChange = config.subscribe({ next: arg => this.updateConfig(arg), error: e => console.error(e), complete: () => configObChange.unsubscribe() }); } else { this.designer.setConfig(config); } } updateStyleInfo(styleInfo) { this.designer.Spread.suspendPaint(); this.styleInfo = styleInfo; this.designer.refresh(); this.designer.Spread.resumePaint(); } updateConfig(config) { this.designer.Spread.suspendPaint(); this.designer.setConfig(config); this.designer.refresh(); this.designer.Spread.resumePaint(); } ngOnChanges(changes) { let property = changes.props.currentValue; if (!this.designer) { if (property.styleInfo) { this.setStyleInfo(changes.props.currentValue.styleInfo); } } else { if (property.styleInfo) { this.updateStyleInfo(changes.props.currentValue.styleInfo); } if (property.config) { this.updateConfig(changes.props.currentValue.config); } } } ngOnDestroy() { this.designer && this.designer.destroy(); } } DesignerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); DesignerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: DesignerComponent, selector: "designer", inputs: { props: "props" }, outputs: { designerInitialized: "designerInitialized" }, usesOnChanges: true, ngImport: i0, template: ` <div id= "gc-designer-container" class="designer" [style]="styleInfo"> </div> `, isInline: true, encapsulation: i0.ViewEncapsulation.None }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerComponent, decorators: [{ type: Component, args: [{ selector: 'designer', template: ` <div id= "gc-designer-container" class="designer" [style]="styleInfo"> </div> `, encapsulation: ViewEncapsulation.None }] }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { props: [{ type: Input }], designerInitialized: [{ type: Output }] } }); class DesignerModule { } DesignerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); DesignerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerModule, declarations: [DesignerComponent], imports: [CommonModule], exports: [DesignerComponent] }); DesignerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerModule, imports: [[ CommonModule ]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DesignerModule, decorators: [{ type: NgModule, args: [{ imports: [ CommonModule ], declarations: [DesignerComponent], exports: [DesignerComponent] //新添加的部分 }] }] }); /** * Generated bundle index. Do not edit. */ export { DesignerComponent, DesignerModule }; //# sourceMappingURL=grapecity-spread-sheets-designer-angular.mjs.map