Added npm packages for Syncfusion Angular 2 components.

Added npm packages for Syncfusion Angular 2 components.
This commit is contained in:
Abinaya Subbiah 2017-01-02 12:18:48 +05:30
Родитель 8ebad2d336
Коммит 5cdcf3908a
6 изменённых файлов: 21 добавлений и 539 удалений

Просмотреть файл

@ -58,14 +58,18 @@
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"typescript": "^2.0.2",
"typings": "^0.7.5",
"typescript": "^2.1.4",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.14.0",
"bootstrap": "^3.3.6",
"jquery": "^3.1.1",
"jsrender": "^0.9.75",
"syncfusion-javascript": "^14.3.49"
"syncfusion-javascript": "^14.3.49",
"ej-angular2": "14.4.20-beta-0.0.1",
"@types/ej.web.all": "0.0.2",
"@types/jquery": "2.0.34",
"@types/es6-shim": "0.31.32",
"@types/node": "6.0.52"
}
}
}

Просмотреть файл

@ -4,7 +4,7 @@ import { RouterModule } from '@angular/router';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { EJ_GRID_COMPONENTS } from './ej/grid.component';
import { EJAngular2Module } from 'ej-angular2';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
@ -25,10 +25,10 @@ class CustomErrorHandler implements ErrorHandler {
@NgModule({
imports: [
BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(rootRouterConfig, { useHash: true })
BrowserModule, FormsModule, HttpModule, RouterModule.forRoot(rootRouterConfig, { useHash: true }), EJAngular2Module.forRoot()
],
declarations: [
AppComponent, EJ_GRID_COMPONENTS, HomeComponent, GridComponent
AppComponent, HomeComponent, GridComponent
],
bootstrap: [AppComponent]
})

Просмотреть файл

@ -1,418 +0,0 @@
import { Provider, forwardRef, ComponentFactory, ViewContainerRef, ContentChildren,
ViewEncapsulation, EventEmitter, QueryList, Type, ContentChild,
Component, enableProdMode, Directive, ElementRef, Input, OnInit, SimpleChange, DoCheck,
ChangeDetectionStrategy, ChangeDetectorRef} from '@angular/core';
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
export {ContentChild, Type, forwardRef} from '@angular/core';
export interface IParentTag {
tags: Array<any>;
}
export interface IChildChange {
index: number;
change: any;
}
export interface IChangeSet {
[key: string]: Array<IChildChange>
}
var firstVal = {};
/** Internal Helpers */
export class Utils {
static IterateAndGetChanges(obj: IParentTag): IChangeSet {
if (ej.isNullOrUndefined(obj.tags) || obj.tags.length === 0)
return null;
var changes: Array<IChildChange>, res: IChangeSet = {};
for (var i = 0, tags = obj.tags; i < tags.length; i++) {
var tag = tags[i], tagElement = obj["_" + tag.replace(/\./g, '_')];
if (!ej.isNullOrUndefined(tagElement) && tagElement.hasChanges) {
res[tag] = tagElement.getChangesAndReset();
}
}
return res;
}
static AngularizeInputs(inputs: Array<string>, twoways: Array<string>): Array<string> {
for (var i = 0, len = inputs.length; i < len; i++) {
var element = inputs[i];
inputs[i] = "model." + element + ": " + element;
}
for (var i = 0; i < twoways.length; i++) {
var element = twoways[i];
element = "model." + element + "_two:" + element;
inputs.push(element);
}
return inputs;
}
}
export class EJComponents<W, T> implements IParentTag {
public tags: Array<any>;
public model: T = <T>{};
public widget: W;
protected outputs: Array<string>;
protected twoways: Array<string>;
protected __shadow: DocumentFragment;
protected complexProperties: Array<string>;
private _firstCheck: boolean = true;
constructor(protected name: string, protected el: ElementRef, protected cdRef: ChangeDetectorRef) {
// this.__shadow = this.dom.getShadowRoot(this.el.nativeElement);
this.createEvents(this.outputs);
this.createTwoways(this.twoways);
}
protected createEvents(events: Array<string>) {
var model = this.model, self = this;
if (events && events.length) {
for (var i = 0; i < events.length; i++) {
var event = events[i];
if (event.startsWith("model."))
continue;
self[event] = new EventEmitter(false);
}
}
var complex = this.complexProperties;
if (complex && complex.length) {
for (var i = 0; i < complex.length; i++) {
var element = complex[i];
ej.createObject(element, {}, model);
}
}
}
protected createTwoways(twoways: Array<string>) {
if (!twoways) return;
var model = this.model;
for (var i = 0; i < twoways.length; i++) {
var element = twoways[i];
if (element.indexOf(":") !== -1) {
element = element.replace(/:.+/g, "");
}
ej.createObject(element + "Change", new EventEmitter(), model);
ej.createObject(element, this.addTwoways(element), model);
}
}
protected addTwoways(prop): Function {
var self = this, model = this.model, value = firstVal;//, originalProp = prop.replace(/-/g, ".");
return function(newVal, isApp: boolean) {
if (value === firstVal) {
value = ej.getObject(prop + "_two", model);
if (value === undefined)
value = ej.getObject(prop, this === undefined || this.defaults === undefined ? {}: this.defaults);
}
if (newVal === undefined) {
return value;
}
if (value === newVal) return;
value = newVal;
if (!isApp) {
ej.createObject(prop + "_two", newVal, model);
ej.getObject<EventEmitter<any>>(prop + "Change", model).emit(newVal);
}
}
}
ngAfterContentInit() {
this._firstCheck = false;
for (var i = 0; i < this.tags.length; i++) {
var element = this.tags[i], item = this["_" + element.replace(/\./g, '_')];
if (!ej.isNullOrUndefined(item))
ej.createObject(element, item.getList(), this.model);
}
var model = this.model, self = this, events = this.outputs;
if (events) {
for (var i = 0; i < events.length; i++) {
var event = events[i];
EJComponents.bindAndRaiseEvent(this, model, event);
}
}
this.widget = $(this.el.nativeElement)["ej" + this.name](this.model)["ej" + this.name]("instance");
}
private static bindAndRaiseEvent(instance, model, event) {
if (!event.startsWith("model.")) {// && instance[event]["observers"].length > 1) {
model[event] = function(params) {
instance[event]["emit"](params);
}
}
}
ngOnChanges(changes: { [key: string]: SimpleChange }) {
if (this._firstCheck)
return;
var ngChanges = {};
for (let key in changes) {
let element = changes[key];
if (element.previousValue === element.currentValue)
break;
key = key.replace("model.", "");
if (key.endsWith("_two")) {
let oKey = key.replace("_two", ""), valFn = ej.getObject<Function>(oKey, this.widget["model"]);
valFn(element.currentValue, true);
ej.createObject(oKey, valFn, ngChanges);
}
ej.createObject(key, element.currentValue, ngChanges);
}
this.widget["setModel"](ngChanges, $.isPlainObject(ngChanges));
}
ngAfterContentChecked() {
/// TODO: ChangeDetection Third/Multi level
var changes: IChangeSet = Utils.IterateAndGetChanges(this);
for (var key in changes) {
if (changes.hasOwnProperty(key)) {
var element = changes[key];
this.widget["_" + key](element);
}
}
}
ngOnDestroy(){
this.widget['destroy']();
}
}
export class ComplexTagElement {
recentChanges: any;
hasChanges: boolean = false;
__firstChange: boolean = true;
__index: number;
__valueChange: EventEmitter<any> = new EventEmitter();
protected complexProperties: Array<string>;
property: string;
__parent: EJComponents<any, any>
tags: Array<string>;
constructor() {
var complexes = this.complexProperties;
for (var i = 0; complexes !== undefined && i < complexes.length; i++) {
var element = complexes[i];
ej.createObject(element, {}, this);
}
}
ngOnInit() {
this.__firstChange = false;
}
ensureCleanObject(){
var tags = this.tags;
for (var i = 0; i < tags.length; i++) {
var element = tags[i], tagElement = this["_"+element.replace(/\./g, '_')];
if(i === 0 && this[element]) return;
if(ej.isNullOrUndefined(tagElement)) continue;
ej.createObject(element, tagElement.getList(), this);
}
}
ngOnChanges(changes: { [key: string]: SimpleChange }) {
if (this.__firstChange)
return;
this.recentChanges = changes;
this.hasChanges = true;
}
getChangesAndReset() {
if (this.hasChanges === false)
return;
var changes = this.recentChanges || {};
for (let key in changes) {
if (changes.hasOwnProperty(key)) {
changes[key] = changes[key].currentValue;
}
}
var contentChanges = Utils.IterateAndGetChanges(this)
if (!$.isEmptyObject(contentChanges)) {
for (let key in contentChanges) {
if (contentChanges.hasOwnProperty(key)) {
var element = contentChanges[key];
//this.el.nativeElement.
this.__parent.widget["_" + this.property.replace(/\./g, '_') + "_" + key](element);
}
}
}
this.hasChanges = false;
return changes;
}
ngAfterContentChecked(){
var tags = this.tags;
for (var i = 0, len = tags.length; i < len; i++) {
var element = tags[i], tagElement = this["_" + element.replace(/\./g, '_')];
if(tagElement && tagElement.hasChanges)
this.hasChanges = true;
}
}
}
export class ArrayTagElement<T extends ComplexTagElement> {
list: Array<T>;
children: QueryList<T>;
recentChanges: Array<IChildChange>;
hasChanges: boolean = false;
constructor(public propertyName: string) {
}
// TODO: Need to consider dynamic child change
ngAfterContentInit() {
var index = 0;
this.list = this.children.map((child) => {
child.__index = index++;
child.property = this.propertyName;
return child;
});
}
ngOnChanges(changes) {
}
getList(){
var list = this.list;
for (var i = 0; i < list.length; i++) {
list[i].ensureCleanObject();
}
return list;
}
getChangesAndReset(): Array<IChildChange> {
this.hasChanges = false;
return this.recentChanges;
}
ngAfterContentChecked():void {
var changes = {}, res: Array<IChildChange> = changes[this.propertyName] = [], childChange;
for (var i = 0, list = this.list; i < list.length; i++) {
var child = list[i];
if (child.hasChanges) {
childChange = child.getChangesAndReset();
if (!ej.isNullOrUndefined(childChange)) {
res.push(<IChildChange>{
index: child.__index,
change: childChange
});
}
}
}
if (res.length > 0) {
this.recentChanges = res;
this.hasChanges = true;
}
}
}
export function CreateComplexDirective(args:{
selector: string,
inputs: Array<string>,
outputs? :Array<string>,
queries ?: { [key:string]: any }
}, ejArgs): Type<any> {
return Directive(args).Class({
extends: ComplexTagElement,
constructor: [ejArgs.type, function (widget: EJComponents<any, any>) {
this.tags = ejArgs.tags;
this.complexProperties = ejArgs.complexes;
this.__parent = widget;
ComplexTagElement.call(this);
}]
})
}
export function CreateArrayTagDirective(property: string, selector: string, type): Type<any> {
return Directive({
selector: selector,
queries: {
children: new ContentChildren(type)
}
}).Class({
extends: ArrayTagElement,
constructor:function () {
ArrayTagElement.call(this, property);
}
})
}
export function CreateComponent(name:string, componentArgs: {
selector: string,
inputs: Array<string>,
outputs: Array<string>,
template: string,
changeDetection?: any,
queries: {
[key:string]: any
}
}, ejArgs): Type<any> {
componentArgs.changeDetection = ChangeDetectionStrategy.OnPush;
var comp = Component(componentArgs);
return comp.Class({
extends: EJComponents,
constructor: [ElementRef, ChangeDetectorRef, function (el: ElementRef, cdRef: ChangeDetectorRef) {
this.tags = ejArgs.tags;
this.outputs = componentArgs.outputs;
this.twoways = ejArgs.twoways;
this.complexProperties = ejArgs.complexes;
EJComponents.call(this, name, el, cdRef);
}]
})
}
export function CreateControlValueAccessor(selector: string, component: Type<any>): Type<any> {
var EJDefaultValueAccessor;
var constAccessor ={ provide : NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => EJDefaultValueAccessor), multi: true
};
var valDirective = Directive({selector: selector,
host: { '(change)': 'onChange($event.value)', '(focusOut)': 'onTouched()' },
providers: [constAccessor]
})
EJDefaultValueAccessor = valDirective.Class({
constructor: [component, function (host) {
this.host = host;
}],
onChange : (_) => { },
onTouched : () => { },
writeValue(value: any): void {
if(this.host.widget)
this.host.widget.option("model.value", value);
else
this.host.model.value = value;
},
registerOnChange(fn: (_: any) => void): void {
this.onChange =fn;
},
registerOnTouched(fn: () => void): void {
this.onTouched = fn;
}
})
return EJDefaultValueAccessor;
}

Просмотреть файл

@ -1,105 +0,0 @@
import {CreateArrayTagDirective, CreateControlValueAccessor, CreateComplexDirective, CreateComponent, Utils, ContentChild, Type, forwardRef } from './core';
export var CommandDirective = CreateComplexDirective({
selector: "e-commands>e-command",
inputs: ["buttonOptions", "type"],
queries: {
}
}, {
tags: [ ],
type: forwardRef(() => GridComponent)
});
export var CommandsDirective = CreateArrayTagDirective("commands", 'e-columns>e-commands', CommandDirective);
export var ColumnDirective = CreateComplexDirective({
selector: "e-columns>e-column",
inputs: ["clipMode", "allowEditing", "allowFiltering", "allowGrouping", "allowSorting", "allowResizing", "commands", "cssClass", "customAttributes", "dataSource", "defaultValue", "disableHtmlEncode", "displayAsCheckBox", "editParams", "editTemplate", "editType", "field", "foreignKeyField", "foreignKeyValue", "format", "headerTemplateID", "headerText", "headerTextAlign", "isFrozen", "isIdentity", "isPrimaryKey", "priority", "showInColumnChooser", "template", "textAlign", "tooltip", "type", "validationRules", "visible", "width"],
queries: {
_commands : new ContentChild(CommandsDirective),
}
}, {
tags: ["commands" ],
type: forwardRef(() => GridComponent)
});
export var ColumnsDirective = CreateArrayTagDirective("columns", 'ej-grid>e-columns', ColumnDirective);
export var SummaryColumnDirective = CreateComplexDirective({
selector: "e-summarycolumns>e-summarycolumn",
inputs: ["customSummaryValue", "dataMember", "displayColumn", "format", "prefix", "suffix", "summaryType", "template"],
queries: {
}
}, {
tags: [ ],
type: forwardRef(() => GridComponent)
});
export var SummaryColumnsDirective = CreateArrayTagDirective("summaryColumns", 'e-summaryrows>e-summarycolumns', SummaryColumnDirective);
export var SummaryRowDirective = CreateComplexDirective({
selector: "e-summaryrows>e-summaryrow",
inputs: ["showCaptionSummary", "showGroupSummary", "showTotalSummary", "summaryColumns", "title", "titleColumn"],
queries: {
_summaryColumns : new ContentChild(SummaryColumnsDirective),
}
}, {
tags: ["summaryColumns" ],
type: forwardRef(() => GridComponent)
});
export var SummaryRowsDirective = CreateArrayTagDirective("summaryRows", 'ej-grid>e-summaryrows', SummaryRowDirective);
export var StackedHeaderColumnDirective = CreateComplexDirective({
selector: "e-stackedheadercolumns>e-stackedheadercolumn",
inputs: ["column", "cssClass", "headerText", "textAlign"],
queries: {
}
}, {
tags: [ ],
type: forwardRef(() => GridComponent)
});
export var StackedHeaderColumnsDirective = CreateArrayTagDirective("stackedHeaderColumns", 'e-stackedheaderrows>e-stackedheadercolumns', StackedHeaderColumnDirective);
export var StackedHeaderRowDirective = CreateComplexDirective({
selector: "e-stackedheaderrows>e-stackedheaderrow",
inputs: ["stackedHeaderColumns"],
queries: {
_stackedHeaderColumns : new ContentChild(StackedHeaderColumnsDirective),
}
}, {
tags: ["stackedHeaderColumns" ],
type: forwardRef(() => GridComponent)
});
export var StackedHeaderRowsDirective = CreateArrayTagDirective("stackedHeaderRows", 'ej-grid>e-stackedheaderrows', StackedHeaderRowDirective);
var Outputs = [ "actionBegin", "actionComplete", "actionFailure", "batchAdd", "batchDelete", "beforeBatchAdd", "beforeBatchDelete", "beforeBatchSave", "beginEdit", "cellEdit", "cellSave", "cellSelected", "cellSelecting", "columnDrag", "columnDragStart", "columnDrop", "rowDrag", "rowDragStart", "rowDrop", "columnSelected", "columnSelecting", "contextClick", "contextOpen", "create", "dataBound", "destroy", "detailsCollapse", "detailsDataBound", "detailsExpand", "endAdd", "endDelete", "endEdit", "load", "mergeCellInfo", "queryCellInfo", "recordClick", "recordDoubleClick", "resized", "resizeEnd", "resizeStart", "rightClick", "rowDataBound", "rowSelected", "rowSelecting", "templateRefresh", "toolBarClick" , "model.dataSourceChange: dataSourceChange", "model.pageSettings.currentPageChange: pageSettings.currentPageChange"];
var ComplexProperties = [ "contextMenuSettings", "editSettings", "filterSettings", "groupSettings", "pageSettings", "resizeSettings", "rowDropSettings", "searchSettings", "selectionSettings", "scrollSettings", "sortSettings", "textWrapSettings", "toolbarSettings" ];
var Inputs = Utils.AngularizeInputs( [ "allowCellMerging", "allowGrouping", "allowKeyboardNavigation", "allowFiltering", "allowSorting", "allowMultiSorting", "allowPaging", "allowReordering", "allowResizeToFit", "allowResizing", "allowRowDragAndDrop", "allowScrolling", "allowSearching", "allowSelection", "allowTextWrap", "allowMultipleExporting", "commonWidth", "gridLines", "childGrid", "columnLayout", "contextMenuSettings", "cssClass", "detailsTemplate", "editSettings", "enableAltRow", "enableAutoSaveOnSelectionChange", "enableHeaderHover", "enablePersistence", "enableResponsiveRow", "enableRowHover", "enableRTL", "enableTouch", "filterSettings", "groupSettings", "isResponsive", "keySettings", "locale", "minWidth", "pageSettings", "query", "resizeSettings", "rowTemplate", "rowDropSettings", "searchSettings", "selectedRecords", "selectedRowIndex", "selectionSettings", "selectionType", "scrollSettings", "showColumnChooser", "showStackedHeader", "showSummary", "sortSettings", "textWrapSettings", "toolbarSettings", "contextMenuSettings.contextMenuItems", "contextMenuSettings.customContextMenuItems", "contextMenuSettings.enableContextMenu", "contextMenuSettings.disableDefaultItems", "editSettings.allowAdding", "editSettings.allowDeleting", "editSettings.allowEditing", "editSettings.allowEditOnDblClick", "editSettings.dialogEditorTemplateID", "editSettings.editMode", "editSettings.externalFormTemplateID", "editSettings.formPosition", "editSettings.inlineFormTemplateID", "editSettings.rowPosition", "editSettings.showConfirmDialog", "editSettings.showDeleteConfirmDialog", "editSettings.titleColumn", "editSettings.showAddNewRow", "filterSettings.enableCaseSensitivity", "filterSettings.filterBarMode", "filterSettings.filterType", "filterSettings.maxFilterChoices", "filterSettings.showFilterBarMessage", "filterSettings.showPredicate", "groupSettings.captionFormat", "groupSettings.enableDropAreaAutoSizing", "groupSettings.groupedColumns", "groupSettings.showDropArea", "groupSettings.showGroupedColumn", "groupSettings.showToggleButton", "groupSettings.showUngroupButton", "pageSettings.enableQueryString", "pageSettings.enableTemplates", "pageSettings.pageCount", "pageSettings.pageSize", "pageSettings.showDefaults", "pageSettings.template", "pageSettings.totalPages", "pageSettings.totalRecordsCount", "pageSettings.printMode", "resizeSettings.resizeMode", "rowDropSettings.dropTargetID", "rowDropSettings.dragMapper", "rowDropSettings.dropMapper", "searchSettings.fields", "searchSettings.key", "searchSettings.operator", "searchSettings.ignoreCase", "selectionSettings.enableToggle", "selectionSettings.selectionMode", "scrollSettings.allowVirtualScrolling", "scrollSettings.enableTouchScroll", "scrollSettings.frozenColumns", "scrollSettings.frozenRows", "scrollSettings.height", "scrollSettings.virtualScrollMode", "scrollSettings.enableVirtualization", "scrollSettings.width", "scrollSettings.scrollOneStepBy", "textWrapSettings.wrapMode", "toolbarSettings.customToolbarItems", "toolbarSettings.showToolbar", "toolbarSettings.toolbarItems", "columns", "stackedHeaderRows", "summaryRows", "contextMenuSettings.subContextMenu", "filterSettings.filteredColumns", "sortSettings.sortedColumns" ],["dataSource", "pageSettings.currentPage" ]);
export var GridComponent = CreateComponent("Grid", {
selector: 'ej-grid',
inputs : Inputs,
outputs : Outputs,
template:"",
queries: {
_columns : new ContentChild(ColumnsDirective),
_summaryRows : new ContentChild(SummaryRowsDirective),
_stackedHeaderRows : new ContentChild(StackedHeaderRowsDirective),
}
},{
tags : ["columns", "summaryRows", "stackedHeaderRows"],
twoways : ["dataSource", "pageSettings.currentPage" ],
complexes : ComplexProperties,
});
export const EJ_GRID_COMPONENTS: Type<any>[] = [GridComponent , CommandsDirective, ColumnsDirective, SummaryColumnsDirective, SummaryRowsDirective, StackedHeaderColumnsDirective, StackedHeaderRowsDirective, CommandDirective, ColumnDirective, SummaryColumnDirective, SummaryRowDirective, StackedHeaderColumnDirective, StackedHeaderRowDirective]

Просмотреть файл

@ -8,6 +8,15 @@
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
"suppressImplicitAnyIndexErrors": true,
"typeRoots": [
"node_modules/@types/"
],
"types": [
"jquery",
"ej.web.all",
"node",
"es6-shim"
]
}
}

Просмотреть файл

@ -1,8 +0,0 @@
{
"globalDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2",
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#470954c4f427e0805a2d633636a7c6aa7170def8",
"node": "registry:dt/node#6.0.0+20160928143418",
"ej.web.all": "registry:dt/ej.web.all#0.0.0+20160930121912"
}
}