Merge pull request #12847 from deenairn/types-2.0

angular-file-saver and handsontable updates
This commit is contained in:
Nathan Shively-Sanders
2016-11-25 09:33:28 -08:00
committed by GitHub
5 changed files with 120 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
class ExampleCtrl {
constructor(FileSaver: angular.FileSaver) {
var data = new Blob(["Hey ho lets go!"], { type: "text/plain;charset=utf-8" });
FileSaver.saveAs(data, "text.txt");
}
}
angular
.module("fileSaverExample", ["ngFileSaver"])
.controller("ExampleCtrl", ExampleCtrl);

21
angular-file-saver/index.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
// Type definitions for angular-file-saver 1.2.0
// Project: https://github.com/alferov/angular-file-saver
// Definitions by: Donald Nairn <https://github.com/deenairn/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="angular" />
declare namespace angular {
/**
* A core Angular factory proving FileSaver functionality.
*/
interface FileSaver {
/**
* Immediately starts saving a file
* @param data: a Blob instance;
* @param filename: a String custom filename (an extension is optional);
* @param disableAutoBOM : (optional) Boolean Disable automatically provided Unicode text encoding hints;
*/
saveAs(blob: Blob, fileName: string, disableBOM?: boolean): void;
}
}

View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-file-saver-tests.ts"
]
}

View File

@@ -250,7 +250,7 @@ function test_HandsontableMethods() {
hot.getRowHeight(123);
hot.getSchema();
hot.getSelected();
hot.getSelectedRange();
const range: ht.Range = hot.getSelectedRange();
hot.getSettings();
hot.getSourceData(123, 123, 123, 123);
hot.getSourceDataAtCell(123, 123);
@@ -284,4 +284,8 @@ function test_HandsontableMethods() {
hot.unlisten();
hot.updateSettings({}, true);
hot.validateCells(function() {});
Handsontable.renderers.NumericRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {});
Handsontable.renderers.TextRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {});
Handsontable.Dom.addEvent(new HTMLElement(), "eventName", () => {});
}

View File

@@ -250,7 +250,7 @@ declare namespace ht {
getRowHeight(row: number): number;
getSchema(): Object;
getSelected(): any[];
getSelectedRange(): any;
getSelectedRange(): Range;
getSettings(): Object;
getSourceData(r?: number, c?: number, r2?: number, c2?: number): any[];
getSourceDataAtCell(row: number, column: number): any;
@@ -284,11 +284,75 @@ declare namespace ht {
updateSettings(settings: Object, init: boolean): void;
validateCells(callback: Function): void;
}
interface Selection {
start: CellPosition;
end: CellPosition;
}
interface Range {
from: CellPosition;
to: CellPosition;
}
interface HandsontableRegisterer {
getInstance(id: string): Methods;
registerInstance(id: string, instance: Methods): void;
removeInstance(id: string): void;
}
interface ColumnProperties extends CellProperties {
data?: string;
editor?: string;
selectOptions?: any[];
}
interface CellProperties {
renderer?: (
instance: Methods,
td: HTMLTableDataCellElement,
row: number,
col: number,
prop: string,
value: any,
tdCellProperties: Object) => void;
type?: string;
readOnly?: boolean;
language?: string;
format?: string;
validator?: (value: string, callback: (condition: boolean) => void) => void;
}
interface CellPosition {
row: number;
col: number;
}
}
declare var Handsontable: {
new (element: Element, options: ht.Options): ht.Methods;
renderers: {
TextRenderer(
instance: any,
td: HTMLTableCellElement,
row: number,
col: number,
prop: string,
value: any,
cellProperties: any): void;
NumericRenderer(
instance: any,
td: HTMLTableCellElement,
row: number,
col: number,
prop: string,
value: any,
cellProperties: any): void;
}
Dom: {
addEvent(element: HTMLElement, eventName: string, callback: Function): void;
}
};
declare module "handsontable" {