From 49360853185d218f97942730a1dd5bde6c76c58b Mon Sep 17 00:00:00 2001 From: Alberto Date: Mon, 11 Dec 2017 21:42:59 +0000 Subject: [PATCH] Release 15.0.0 dist files created --- bower.json | 2 +- lib/agGridAurelia.d.ts | 34 +++++ lib/agGridAurelia.js | 149 +++++++++++++++++++++ lib/agGridColumn.d.ts | 18 +++ lib/agGridColumn.js | 150 ++++++++++++++++++++++ lib/agTemplate.d.ts | 34 +++++ lib/agTemplate.js | 144 +++++++++++++++++++++ lib/agUtils.d.ts | 2 + lib/agUtils.js | 25 ++++ lib/aureliaFrameworkComponentWrapper.d.ts | 13 ++ lib/aureliaFrameworkComponentWrapper.js | 123 ++++++++++++++++++ lib/aureliaFrameworkFactory.d.ts | 11 ++ lib/aureliaFrameworkFactory.js | 31 +++++ package.json | 4 +- 14 files changed, 737 insertions(+), 3 deletions(-) create mode 100644 lib/agGridAurelia.d.ts create mode 100644 lib/agGridAurelia.js create mode 100644 lib/agGridColumn.d.ts create mode 100644 lib/agGridColumn.js create mode 100644 lib/agTemplate.d.ts create mode 100644 lib/agTemplate.js create mode 100644 lib/agUtils.d.ts create mode 100644 lib/agUtils.js create mode 100644 lib/aureliaFrameworkComponentWrapper.d.ts create mode 100644 lib/aureliaFrameworkComponentWrapper.js create mode 100644 lib/aureliaFrameworkFactory.d.ts create mode 100644 lib/aureliaFrameworkFactory.js diff --git a/bower.json b/bower.json index b20a826..77c58fd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ag-grid-aurelia", - "version": "14.2.0", + "version": "15.0.0", "homepage": "http://www.ag-grid.com/", "authors": [ "Niall Crosby " diff --git a/lib/agGridAurelia.d.ts b/lib/agGridAurelia.d.ts new file mode 100644 index 0000000..a5ddb80 --- /dev/null +++ b/lib/agGridAurelia.d.ts @@ -0,0 +1,34 @@ +// ag-grid-aurelia v15.0.0 +import { ComponentAttached, ComponentDetached, Container, TaskQueue, ViewResources } from "aurelia-framework"; +import { ColumnApi, GridApi, GridOptions } from "ag-grid/main"; +import { AureliaFrameworkFactory } from "./aureliaFrameworkFactory"; +import { AgGridColumn } from "./agGridColumn"; +import { AgDateTemplate, AgFullWidthRowTemplate } from './agTemplate'; +import { AureliaFrameworkComponentWrapper } from "./aureliaFrameworkComponentWrapper"; +export declare class AgGridAurelia implements ComponentAttached, ComponentDetached { + private taskQueue; + private auFrameworkFactory; + private container; + private viewResources; + private aureliaFrameworkComponentWrapper; + private _nativeElement; + private _initialised; + private _destroyed; + gridOptions: GridOptions; + context: any; + private gridParams; + api: GridApi; + columnApi: ColumnApi; + columns: AgGridColumn[]; + fullWidthRowTemplate: AgFullWidthRowTemplate; + dateTemplate: AgDateTemplate; + constructor(element: Element, taskQueue: TaskQueue, auFrameworkFactory: AureliaFrameworkFactory, container: Container, viewResources: ViewResources, aureliaFrameworkComponentWrapper: AureliaFrameworkComponentWrapper); + attached(): void; + initGrid(): void; + /** + * Called by Aurelia whenever a bound property changes + */ + propertyChanged(propertyName: string, newValue: any, oldValue: any): void; + detached(): void; + private globalEventListener(eventType, event); +} diff --git a/lib/agGridAurelia.js b/lib/agGridAurelia.js new file mode 100644 index 0000000..72809d5 --- /dev/null +++ b/lib/agGridAurelia.js @@ -0,0 +1,149 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +var main_1 = require("ag-grid/main"); +var aureliaFrameworkFactory_1 = require("./aureliaFrameworkFactory"); +var agUtils_1 = require("./agUtils"); +var agTemplate_1 = require("./agTemplate"); +var aureliaFrameworkComponentWrapper_1 = require("./aureliaFrameworkComponentWrapper"); +var AgGridAurelia = /** @class */ (function () { + function AgGridAurelia(element, taskQueue, auFrameworkFactory, container, viewResources, aureliaFrameworkComponentWrapper) { + var _this = this; + this.taskQueue = taskQueue; + this.auFrameworkFactory = auFrameworkFactory; + this.container = container; + this.viewResources = viewResources; + this.aureliaFrameworkComponentWrapper = aureliaFrameworkComponentWrapper; + this._initialised = false; + this._destroyed = false; + this.columns = []; + this._nativeElement = element; + // create all the events generically. this is done generically so that + // if the list of grid events change, we don't need to change this code. + main_1.ComponentUtil.EVENTS.forEach(function (eventName) { + //create an empty event + _this[eventName] = function () { + }; + }); + } + AgGridAurelia.prototype.attached = function () { + // initialize the grid in the queue + // because of bug in @children + // https://github.com/aurelia/templating/issues/403 + this.taskQueue.queueTask(this.initGrid.bind(this)); + }; + AgGridAurelia.prototype.initGrid = function () { + this._initialised = false; + this._destroyed = false; + this.auFrameworkFactory.setContainer(this.container); + this.auFrameworkFactory.setViewResources(this.viewResources); + this.aureliaFrameworkComponentWrapper.setContainer(this.container); + this.aureliaFrameworkComponentWrapper.setViewResources(this.viewResources); + this.gridOptions = main_1.ComponentUtil.copyAttributesToGridOptions(this.gridOptions, this); + this.gridParams = { + globalEventListener: this.globalEventListener.bind(this), + frameworkFactory: this.auFrameworkFactory, + seedBeanInstances: { + frameworkComponentWrapper: this.aureliaFrameworkComponentWrapper + } + }; + if (this.columns && this.columns.length > 0) { + this.gridOptions.columnDefs = this.columns + .map(function (column) { + return column.toColDef(); + }); + } + if (this.fullWidthRowTemplate) { + this.gridOptions.fullWidthCellRendererFramework = + { template: this.fullWidthRowTemplate.template }; + } + if (this.dateTemplate) { + this.gridOptions.dateComponentFramework = + { template: this.dateTemplate.template }; + } + new main_1.Grid(this._nativeElement, this.gridOptions, this.gridParams); + this.api = this.gridOptions.api; + this.columnApi = this.gridOptions.columnApi; + this._initialised = true; + }; + /** + * Called by Aurelia whenever a bound property changes + */ + AgGridAurelia.prototype.propertyChanged = function (propertyName, newValue, oldValue) { + // emulate an Angular2 SimpleChanges Object + var changes = {}; + changes[propertyName] = { currentValue: newValue, previousValue: oldValue }; + if (this._initialised) { + main_1.ComponentUtil.processOnChange(changes, this.gridOptions, this.api, this.columnApi); + } + }; + AgGridAurelia.prototype.detached = function () { + if (this._initialised) { + // need to do this before the destroy, so we know not to emit any events + // while tearing down the grid. + this._destroyed = true; + this.api.destroy(); + } + }; + AgGridAurelia.prototype.globalEventListener = function (eventType, event) { + // if we are tearing down, don't emit events + if (this._destroyed) { + return; + } + // generically look up the eventType + var emitter = this[eventType]; + if (emitter) { + emitter(event); + } + else { + console.log('ag-Grid-aurelia: could not find EventEmitter: ' + eventType); + } + }; + __decorate([ + aurelia_framework_1.bindable(), + __metadata("design:type", Object) + ], AgGridAurelia.prototype, "gridOptions", void 0); + __decorate([ + aurelia_framework_1.bindable(), + __metadata("design:type", Object) + ], AgGridAurelia.prototype, "context", void 0); + __decorate([ + aurelia_framework_1.children('ag-grid-column'), + __metadata("design:type", Array) + ], AgGridAurelia.prototype, "columns", void 0); + __decorate([ + aurelia_framework_1.child('ag-full-width-row-template'), + __metadata("design:type", agTemplate_1.AgFullWidthRowTemplate) + ], AgGridAurelia.prototype, "fullWidthRowTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-date-template'), + __metadata("design:type", agTemplate_1.AgDateTemplate) + ], AgGridAurelia.prototype, "dateTemplate", void 0); + AgGridAurelia = __decorate([ + aurelia_framework_1.customElement('ag-grid-aurelia'), + agUtils_1.generateBindables(main_1.ComponentUtil.ALL_PROPERTIES.filter(function (property) { return property !== 'gridOptions'; })), + agUtils_1.generateBindables(main_1.ComponentUtil.EVENTS) + // is required for @children to work. https://github.com/aurelia/templating/issues/451#issuecomment-254206622 + , + aurelia_framework_1.inlineView(""), + aurelia_framework_1.autoinject(), + __metadata("design:paramtypes", [Element, + aurelia_framework_1.TaskQueue, + aureliaFrameworkFactory_1.AureliaFrameworkFactory, + aurelia_framework_1.Container, + aurelia_framework_1.ViewResources, + aureliaFrameworkComponentWrapper_1.AureliaFrameworkComponentWrapper]) + ], AgGridAurelia); + return AgGridAurelia; +}()); +exports.AgGridAurelia = AgGridAurelia; diff --git a/lib/agGridColumn.d.ts b/lib/agGridColumn.d.ts new file mode 100644 index 0000000..c27c603 --- /dev/null +++ b/lib/agGridColumn.d.ts @@ -0,0 +1,18 @@ +// ag-grid-aurelia v15.0.0 +import { ColDef } from "ag-grid/main"; +import { AgCellTemplate, AgEditorTemplate, AgFilterTemplate, AgHeaderGroupTemplate, AgHeaderTemplate, AgPinnedRowTemplate } from "./agTemplate"; +export declare class AgGridColumn { + private mappedColumnProperties; + childColumns: AgGridColumn[]; + cellTemplate: AgCellTemplate; + editorTemplate: AgEditorTemplate; + filterTemplate: AgFilterTemplate; + headerTemplate: AgHeaderTemplate; + headerGroupTemplate: AgHeaderGroupTemplate; + pinnedRowTemplate: AgPinnedRowTemplate; + constructor(); + hasChildColumns(): boolean; + toColDef(): ColDef; + private static getChildColDefs(childColumns); + private createColDefFromGridColumn(); +} diff --git a/lib/agGridColumn.js b/lib/agGridColumn.js new file mode 100644 index 0000000..f2f6cba --- /dev/null +++ b/lib/agGridColumn.js @@ -0,0 +1,150 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +var agTemplate_1 = require("./agTemplate"); +var agUtils_1 = require("./agUtils"); +var AgGridColumn = /** @class */ (function () { + function AgGridColumn() { + this.mappedColumnProperties = { + "hideCol": "hide" // hide exists in aurelia-templating-resources and will conflict + }; + this.childColumns = []; + } + AgGridColumn_1 = AgGridColumn; + AgGridColumn.prototype.hasChildColumns = function () { + return this.childColumns && this.childColumns.length > 0; + }; + AgGridColumn.prototype.toColDef = function () { + var _this = this; + var colDef = this.createColDefFromGridColumn(); + if (this.hasChildColumns()) { + colDef["children"] = AgGridColumn_1.getChildColDefs(this.childColumns); + } + var defaultAction = function (templateName) { + var self = _this; + if (self[templateName]) { + var frameworkName = templates[templateName].frameworkName; + colDef[frameworkName] = { template: self[templateName].template }; + delete colDef[templateName]; + } + }; + var editorAction = function (templateName) { + if (colDef.editable === undefined) { + colDef.editable = true; + } + defaultAction(templateName); + }; + var templates = { + cellTemplate: { + frameworkName: 'cellRendererFramework' + }, + editorTemplate: { + frameworkName: 'cellEditorFramework', + action: editorAction + }, + filterTemplate: { + frameworkName: 'filterFramework' + }, + headerTemplate: { + frameworkName: 'headerComponentFramework' + }, + headerGroupTemplate: { + frameworkName: 'headerGroupComponentFramework' + }, + pinnedRowTemplate: { + frameworkName: 'pinnedRowCellRendererFramework' + } + }; + var addTemplate = function (templateName) { + var action = templates[templateName].action ? templates[templateName].action : defaultAction; + action(templateName); + }; + Object.keys(templates) + .forEach(addTemplate); + return colDef; + }; + AgGridColumn.getChildColDefs = function (childColumns) { + return childColumns + .filter(function (column) { return !column.hasChildColumns(); }) + .map(function (column) { + return column.toColDef(); + }); + }; + ; + AgGridColumn.prototype.createColDefFromGridColumn = function () { + var colDef = {}; + for (var prop in this) { + var colDefProperty = this.mappedColumnProperties[prop] ? this.mappedColumnProperties[prop] : prop; + colDef[colDefProperty] = this[prop]; + } + delete colDef.childColumns; + return colDef; + }; + ; + __decorate([ + aurelia_framework_1.children('ag-grid-column'), + __metadata("design:type", Array) + ], AgGridColumn.prototype, "childColumns", void 0); + __decorate([ + aurelia_framework_1.child('ag-cell-template'), + __metadata("design:type", agTemplate_1.AgCellTemplate) + ], AgGridColumn.prototype, "cellTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-editor-template'), + __metadata("design:type", agTemplate_1.AgEditorTemplate) + ], AgGridColumn.prototype, "editorTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-filter-template'), + __metadata("design:type", agTemplate_1.AgFilterTemplate) + ], AgGridColumn.prototype, "filterTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-header-template'), + __metadata("design:type", agTemplate_1.AgHeaderTemplate) + ], AgGridColumn.prototype, "headerTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-header-group-template'), + __metadata("design:type", agTemplate_1.AgHeaderGroupTemplate) + ], AgGridColumn.prototype, "headerGroupTemplate", void 0); + __decorate([ + aurelia_framework_1.child('ag-pinned-row-template'), + __metadata("design:type", agTemplate_1.AgPinnedRowTemplate) + ], AgGridColumn.prototype, "pinnedRowTemplate", void 0); + AgGridColumn = AgGridColumn_1 = __decorate([ + aurelia_framework_1.customElement('ag-grid-column'), + agUtils_1.generateBindables(["colId", "sort", "sortedAt", "sortingOrder", "field", "headerValueGetter", "hideCol", "pinned", + "tooltipField", "headerTooltip", "valueGetter", "keyCreator", + "width", "minWidth", "maxWidth", "cellClass", "cellStyle", "cellRenderer", "cellRendererFramework", + "cellRendererParams", "cellEditor", "cellEditorFramework", "cellEditorParams", "floatingCellRenderer", + "floatingCellRendererFramework", "floatingCellRendererParams", "cellFormatter(", "floatingCellFormatter", + "getQuickFilterText", "aggFunc", "rowGroupIndex", "pivotIndex", "comparator", "checkboxSelection", "suppressMenu", + "suppressSorting", "suppressMovable", "suppressFilter", "unSortIcon", "suppressSizeToFit", "suppressResize", + "suppressAutoSize", "enableRowGroup", "enablePivot", "enableValue", "editable", "suppressNavigable", "newValueHandler", + "volatile", "filter", "filterFramework", "filterParams", "cellClassRules", "onCellValueChanged", "onCellClicked", + "onCellDoubleClicked", "onCellContextMenu", "icons", "enableCellChangeFlash", "headerName", "columnGroupShow", + "headerClass", "children", "groupId", "openByDefault", "marryChildren", "headerCheckboxSelection", + "headerCheckboxSelectionFilteredOnly", "type", "tooltipField", "valueSetter", "pinnedRowCellRenderer", + "pinnedRowCellRendererFramework", "pinnedRowCellRendererParams", "valueFormatter", "pinnedRowValueFormatter", + "valueParser", "allowedAggFuncs", "rowGroup", "showRowGroup", "pivot", "equals", "pivotComparator", "menuTabs", + "colSpan", "suppressPaste", "template", "templateUrl", "pivotValueColumn", "pivotTotalColumnIds", "headerComponent", + "headerComponentFramework", "headerComponentParams", "floatingFilterComponent", "floatingFilterComponentParams", + "floatingFilterComponentFramework"]) + // is required for @children to work. https://github.com/aurelia/templating/issues/451#issuecomment-254206622 + , + aurelia_framework_1.inlineView(""), + aurelia_framework_1.autoinject(), + __metadata("design:paramtypes", []) + ], AgGridColumn); + return AgGridColumn; + var AgGridColumn_1; +}()); +exports.AgGridColumn = AgGridColumn; diff --git a/lib/agTemplate.d.ts b/lib/agTemplate.d.ts new file mode 100644 index 0000000..0bae200 --- /dev/null +++ b/lib/agTemplate.d.ts @@ -0,0 +1,34 @@ +// ag-grid-aurelia v15.0.0 +import { TargetInstruction } from "aurelia-framework"; +export declare class AgCellTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgEditorTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgFilterTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgHeaderTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgHeaderGroupTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgPinnedRowTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgDateTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} +export declare class AgFullWidthRowTemplate { + template: string; + constructor(targetInstruction: TargetInstruction); +} diff --git a/lib/agTemplate.js b/lib/agTemplate.js new file mode 100644 index 0000000..fe4c3d5 --- /dev/null +++ b/lib/agTemplate.js @@ -0,0 +1,144 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +/** + * Function will move the elements innerHtml to a template property + * and then remove html from the element so that Aurelia will not render + * the template elements + * @param compiler + * @param resources + * @param element + * @param instruction + */ +function parseElement(compiler, resources, element, instruction) { + var html = element.innerHTML; + if (html !== '') { + instruction.template = html; + } + element.innerHTML = ''; +} +function getTemplate(targetInstruction) { + return ""; +} +var AgCellTemplate = /** @class */ (function () { + function AgCellTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgCellTemplate = __decorate([ + aurelia_framework_1.customElement('ag-cell-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgCellTemplate); + return AgCellTemplate; +}()); +exports.AgCellTemplate = AgCellTemplate; +var AgEditorTemplate = /** @class */ (function () { + function AgEditorTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgEditorTemplate = __decorate([ + aurelia_framework_1.customElement('ag-editor-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgEditorTemplate); + return AgEditorTemplate; +}()); +exports.AgEditorTemplate = AgEditorTemplate; +var AgFilterTemplate = /** @class */ (function () { + function AgFilterTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgFilterTemplate = __decorate([ + aurelia_framework_1.customElement('ag-filter-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgFilterTemplate); + return AgFilterTemplate; +}()); +exports.AgFilterTemplate = AgFilterTemplate; +var AgHeaderTemplate = /** @class */ (function () { + function AgHeaderTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgHeaderTemplate = __decorate([ + aurelia_framework_1.customElement('ag-header-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgHeaderTemplate); + return AgHeaderTemplate; +}()); +exports.AgHeaderTemplate = AgHeaderTemplate; +var AgHeaderGroupTemplate = /** @class */ (function () { + function AgHeaderGroupTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgHeaderGroupTemplate = __decorate([ + aurelia_framework_1.customElement('ag-header-group-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgHeaderGroupTemplate); + return AgHeaderGroupTemplate; +}()); +exports.AgHeaderGroupTemplate = AgHeaderGroupTemplate; +var AgPinnedRowTemplate = /** @class */ (function () { + function AgPinnedRowTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgPinnedRowTemplate = __decorate([ + aurelia_framework_1.customElement('ag-pinned-row-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgPinnedRowTemplate); + return AgPinnedRowTemplate; +}()); +exports.AgPinnedRowTemplate = AgPinnedRowTemplate; +var AgDateTemplate = /** @class */ (function () { + function AgDateTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgDateTemplate = __decorate([ + aurelia_framework_1.customElement('ag-date-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgDateTemplate); + return AgDateTemplate; +}()); +exports.AgDateTemplate = AgDateTemplate; +var AgFullWidthRowTemplate = /** @class */ (function () { + function AgFullWidthRowTemplate(targetInstruction) { + this.template = getTemplate(targetInstruction); + } + AgFullWidthRowTemplate = __decorate([ + aurelia_framework_1.customElement('ag-full-width-row-template'), + aurelia_framework_1.noView(), + aurelia_framework_1.autoinject(), + aurelia_framework_1.processContent(parseElement), + __metadata("design:paramtypes", [aurelia_framework_1.TargetInstruction]) + ], AgFullWidthRowTemplate); + return AgFullWidthRowTemplate; +}()); +exports.AgFullWidthRowTemplate = AgFullWidthRowTemplate; diff --git a/lib/agUtils.d.ts b/lib/agUtils.d.ts new file mode 100644 index 0000000..eb82756 --- /dev/null +++ b/lib/agUtils.d.ts @@ -0,0 +1,2 @@ +// ag-grid-aurelia v15.0.0 +export declare function generateBindables(names: string[], bindingModeToUse?: any): any; diff --git a/lib/agUtils.js b/lib/agUtils.js new file mode 100644 index 0000000..aa4aae8 --- /dev/null +++ b/lib/agUtils.js @@ -0,0 +1,25 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +function generateBindables(names, bindingModeToUse) { + return function (target, key, descriptor) { + // get or create the HtmlBehaviorResource + // on which we're going to create the BindableProperty's + var behaviorResource = aurelia_framework_1.metadata.getOrCreateOwn(aurelia_framework_1.metadata.resource, aurelia_framework_1.HtmlBehaviorResource, target); + var nameOrConfigOrTargets = names.map(function (name) { + var nameOrConfigOrTarget = { + name: name + }; + if (bindingModeToUse) { + nameOrConfigOrTarget["defaultBindingMode"] = bindingModeToUse; + } + return nameOrConfigOrTarget; + }); + nameOrConfigOrTargets.forEach(function (nameOrConfigOrTarget) { + var prop = new aurelia_framework_1.BindableProperty(nameOrConfigOrTarget); + prop.registerWith(target, behaviorResource, descriptor); + }); + }; +} +exports.generateBindables = generateBindables; diff --git a/lib/aureliaFrameworkComponentWrapper.d.ts b/lib/aureliaFrameworkComponentWrapper.d.ts new file mode 100644 index 0000000..7b18430 --- /dev/null +++ b/lib/aureliaFrameworkComponentWrapper.d.ts @@ -0,0 +1,13 @@ +// ag-grid-aurelia v15.0.0 +import { Container, TaskQueue, ViewCompiler, ViewResources } from "aurelia-framework"; +import { BaseComponentWrapper, FrameworkComponentWrapper, WrapableInterface } from 'ag-grid'; +export declare class AureliaFrameworkComponentWrapper extends BaseComponentWrapper implements FrameworkComponentWrapper { + private taskQueue; + private _viewCompiler; + private _container; + private _viewResources; + constructor(taskQueue: TaskQueue, _viewCompiler: ViewCompiler); + createWrapper(template: any): WrapableInterface; + setContainer(container: Container): void; + setViewResources(viewResources: ViewResources): void; +} diff --git a/lib/aureliaFrameworkComponentWrapper.js b/lib/aureliaFrameworkComponentWrapper.js new file mode 100644 index 0000000..108a42d --- /dev/null +++ b/lib/aureliaFrameworkComponentWrapper.js @@ -0,0 +1,123 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +var ag_grid_1 = require("ag-grid"); +var AureliaFrameworkComponentWrapper = /** @class */ (function (_super) { + __extends(AureliaFrameworkComponentWrapper, _super); + function AureliaFrameworkComponentWrapper(taskQueue, _viewCompiler) { + var _this = _super.call(this) || this; + _this.taskQueue = taskQueue; + _this._viewCompiler = _viewCompiler; + return _this; + } + AureliaFrameworkComponentWrapper.prototype.createWrapper = function (template) { + var that = this; + var DynamicComponent = /** @class */ (function (_super) { + __extends(DynamicComponent, _super); + function DynamicComponent() { + return _super.call(this, that.taskQueue, that._viewCompiler) || this; + } + DynamicComponent.prototype.init = function (params) { + _super.prototype.init.call(this, params, template.template, that._viewResources, that._container); + }; + DynamicComponent.prototype.hasMethod = function (name) { + return wrapper.getFrameworkComponentInstance()[name] != null; + }; + DynamicComponent.prototype.callMethod = function (name, args) { + var componentRef = this.getFrameworkComponentInstance(); + return wrapper.getFrameworkComponentInstance()[name].apply(componentRef, args); + }; + DynamicComponent.prototype.addMethod = function (name, callback) { + wrapper[name] = callback; + }; + return DynamicComponent; + }(BaseGuiComponent)); + var wrapper = new DynamicComponent(); + return wrapper; + }; + AureliaFrameworkComponentWrapper.prototype.setContainer = function (container) { + this._container = container; + }; + AureliaFrameworkComponentWrapper.prototype.setViewResources = function (viewResources) { + this._viewResources = viewResources; + }; + AureliaFrameworkComponentWrapper = __decorate([ + aurelia_framework_1.autoinject(), + aurelia_framework_1.transient(), + ag_grid_1.Bean("frameworkComponentWrapper"), + __metadata("design:paramtypes", [aurelia_framework_1.TaskQueue, aurelia_framework_1.ViewCompiler]) + ], AureliaFrameworkComponentWrapper); + return AureliaFrameworkComponentWrapper; +}(ag_grid_1.BaseComponentWrapper)); +exports.AureliaFrameworkComponentWrapper = AureliaFrameworkComponentWrapper; +var BaseGuiComponent = /** @class */ (function () { + function BaseGuiComponent(taskQueue, viewCompiler) { + this._taskQueue = taskQueue; + this._viewCompiler = viewCompiler; + } + BaseGuiComponent.prototype.init = function (params, template, viewResources, container) { + var _this = this; + this._params = params; + var bindingContext = { params: params }; + var viewFactory = this._viewCompiler.compile(template, viewResources); + this._view = viewFactory.create(container); + var controllers = this._view.controllers; + //initialize each controller + if (controllers && controllers.length) { + controllers.forEach(function (c) { + c.viewModel.params = params; + }); + this._view.bind(bindingContext); + //ICellRenderer doesn't have a guiAttached method so + //we call attach on the queue; + this._taskQueue.queueMicroTask(function () { return _this._view.attached(); }); + } + else { + this._view.bind(bindingContext); + } + }; + BaseGuiComponent.prototype.getGui = function () { + return this._view.fragment; + }; + BaseGuiComponent.prototype.destroy = function () { + this._view.returnToCache(); + }; + BaseGuiComponent.prototype.refresh = function (params) { + return false; + }; + BaseGuiComponent.prototype.getFrameworkComponentInstance = function () { + var controllers = this._view.controllers; + //only one controller is allowed in editor template + if (controllers && + controllers.length == 1 && + controllers[0].viewModel) { + var editorVm = controllers[0].viewModel; + //this is a 'hack' because we don't have params.bind="" in the template + //must reset params or it will be nothing + editorVm.params = this._params; + return editorVm; + } + return null; + }; + return BaseGuiComponent; +}()); diff --git a/lib/aureliaFrameworkFactory.d.ts b/lib/aureliaFrameworkFactory.d.ts new file mode 100644 index 0000000..d6f820b --- /dev/null +++ b/lib/aureliaFrameworkFactory.d.ts @@ -0,0 +1,11 @@ +// ag-grid-aurelia v15.0.0 +import { Container, ViewResources } from "aurelia-framework"; +import { IFrameworkFactory } from "ag-grid/main"; +export declare class AureliaFrameworkFactory implements IFrameworkFactory { + private _container; + private _viewResources; + private _baseFrameworkFactory; + setContainer(container: Container): void; + setViewResources(viewResources: ViewResources): void; + setTimeout(action: any, timeout?: any): void; +} diff --git a/lib/aureliaFrameworkFactory.js b/lib/aureliaFrameworkFactory.js new file mode 100644 index 0000000..9c69b11 --- /dev/null +++ b/lib/aureliaFrameworkFactory.js @@ -0,0 +1,31 @@ +// ag-grid-aurelia v15.0.0 +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var aurelia_framework_1 = require("aurelia-framework"); +var main_1 = require("ag-grid/main"); +var AureliaFrameworkFactory = /** @class */ (function () { + function AureliaFrameworkFactory() { + this._baseFrameworkFactory = new main_1.BaseFrameworkFactory(); // todo - inject this + } + AureliaFrameworkFactory.prototype.setContainer = function (container) { + this._container = container; + }; + AureliaFrameworkFactory.prototype.setViewResources = function (viewResources) { + this._viewResources = viewResources; + }; + AureliaFrameworkFactory.prototype.setTimeout = function (action, timeout) { + this._baseFrameworkFactory.setTimeout(action, timeout); + }; + AureliaFrameworkFactory = __decorate([ + aurelia_framework_1.autoinject(), + aurelia_framework_1.transient() + ], AureliaFrameworkFactory); + return AureliaFrameworkFactory; +}()); +exports.AureliaFrameworkFactory = AureliaFrameworkFactory; diff --git a/package.json b/package.json index 5156830..4edacc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ag-grid-aurelia", - "version": "14.2.0", + "version": "15.0.0", "description": "ag-Grid Aurelia Component", "main": "./main.js", "typings": "./main.d.ts", @@ -37,7 +37,7 @@ }, "peerDependencies": { "aurelia-framework": "1.x", - "ag-grid": "^14.0.0" + "ag-grid": "^15.x" }, "dependencies": {