diff --git a/handsontable/handsontable-tests.ts b/handsontable/handsontable-tests.ts new file mode 100644 index 000000000..88cbe587a --- /dev/null +++ b/handsontable/handsontable-tests.ts @@ -0,0 +1,190 @@ +/// + +function test_HandsontableInit() { + var elem = document.createElement('div'); + var hot = new Handsontable(elem, { + allowEmpty: true, + allowInsertColumn: true, + allowInsertRow: true, + allowInvalid: true, + allowRemoveColumn: true, + allowRemoveRow: true, + autoColumnSize: true, + autoComplete: [], + autoRowSize: true, + autoWrapCol: true, + autoWrapRow: true, + cell: [], + cells: function() {}, + checkedTemplate: true, + className: [], + colHeaders: true, + columnHeaderHeight: 123, + columns: [], + columnSorting: {}, + colWidths: 123, + commentedCellClassName: 'foo', + comments: [], + contextMenu: true, + contextMenuCopyPaste: {}, + copyable: true, + copyColsLimit: 123, + copyPaste: true, + copyRowsLimit: 123, + correctFormat: true, + currentColClassName: 'foo', + currentRowClassName: 'foo', + customBorders: true, + data: [], + dataSchema: {}, + dateFormat: 'foo', + debug: true, + defaultDate: 'foo', + disableVisualSelection: true, + editor: true, + enterBeginsEditing: true, + enterMoves: {}, + fillHandle: true, + fixedColumnsLeft: 123, + fixedRowsTop: 123, + format: 'foo', + fragmentSelection: true, + height: 123, + invalidCellClassName: 'foo', + label: {}, + language: 'foo', + manualColumnFreeze: true, + manualColumnMove: true, + manualColumnResize: true, + manualRowMove: true, + manualRowResize: true, + maxCols: 123, + maxRows: 123, + mergeCells: true, + minCols: 123, + minRows: 123, + minSpareCols: 123, + minSpareRows: 123, + multiSelect: true, + noWordWrapClassName: 'foo', + observeChanges: true, + observeDOMVisibility: true, + outsideClickDeselects: true, + pasteMode: 'foo', + persistentState: true, + placeholder: 123, + placeholderCellClassName: 'foo', + preventOverflow: true, + readOnly: true, + readOnlyCellClassName: 'foo', + renderAllRows: true, + renderer: 'foo', + rowHeaders: true, + rowHeaderWidth: 123, + rowHeights: 123, + search: true, + selectOptions: [], + skipColumnOnPaste: true, + sortFunction: function() {}, + sortIndicator: true, + source: [], + startCols: 123, + startRows: 123, + stretchH: 'foo', + strict: true, + tableClassName: 'foo', + tabMoves: {}, + title: 'foo', + trimDropdown: true, + trimWhitespace: true, + type: 'foo', + uncheckedTemplate: true, + undo: true, + validator: function() {}, + viewportColumnRenderingOffset: 123, + viewportRowRenderingOffset: 123, + visibleRows: 123, + width: 1232, + wordWrap: true, + }); +} + +function test_HandsontableMethods() { + var elem = document.createElement('div'); + var hot = new Handsontable(elem, {}); + hot.addHook('foo', []); + hot.addHookOnce('foo', []); + hot.alter('foo', 123, 123, 'foo', true); + hot.clear(); + hot.colOffset(); + hot.colToProp(123); + hot.countCols(); + hot.countEmptyCols(true); + hot.countEmptyRows(true); + hot.countRenderedCols(); + hot.countRenderedRows(); + hot.countRows(); + hot.countSourceRows(); + hot.countVisibleCols(); + hot.countVisibleRows(); + hot.deselectCell(); + hot.destroy(); + hot.destroyEditor(true); + hot.getActiveEditor(); + hot.getCell(123, 123, true); + hot.getCellEditor(123, 123); + hot.getCellMeta(123, 123); + hot.getCellRenderer(123, 123); + hot.getCellValidator(123, 123); + hot.getColHeader(123); + hot.getColWidth(123); + hot.getCoords(elem.querySelector('td')); + hot.getCopyableData(123, 123); + hot.getCopyableText(123, 123, 123, 123); + hot.getData(123, 123, 123, 123); + hot.getDataAtCell(123, 123); + hot.getDataAtCol(123); + hot.getDataAtProp(123); + hot.getDataAtRow(123); + hot.getDataAtRowProp(123, 'foo'); + hot.getDataType(123, 123, 123, 123); + hot.getInstance(); + hot.getPlugin('foo'); + hot.getRowHeader(123); + hot.getRowHeight(123); + hot.getSchema(); + hot.getSelected(); + hot.getSelectedRange(); + hot.getSettings(); + hot.getSourceData(123, 123, 123, 123); + hot.getSourceDataAtCell(123, 123); + hot.getSourceDataAtCol(123); + hot.getSourceDataAtRow(123); + hot.getValue(); + hot.hasColHeaders(); + hot.hasHook('foo'); + hot.hasRowHeaders(); + hot.isEmptyCol(123); + hot.isEmptyRow(123); + hot.isListening(); + hot.listen(); + hot.loadData([]); + hot.populateFromArray(123, 123, [], 123, 123, 'foo', 'foo', 'foo', []); + hot.propToCol('foo'); + hot.removeCellMeta(123, 123, 'foo'); + hot.removeHook('foo', function() {}); + hot.render(); + hot.rowOffset(); + hot.runHooks('foo', 123, 'foo', true, {}, [], function() {}); + hot.selectCell(123, 123, 123, 123, true, true); + hot.selectCellByProp(123, 'foo', 123, 'foo', true); + hot.setCellMeta(123, 123, 'foo', 'foo'); + hot.setCellMetaObject(123, 123, {}); + hot.setDataAtCell(123, 123, 'foo', 'foo'); + hot.setDataAtRowProp(123, 'foo', 'foo', 'foo'); + hot.spliceCol(123, 123, 123, 'foo'); + hot.spliceRow(123, 123, 123, 'foo'); + hot.unlisten(); + hot.updateSettings({}, true); + hot.validateCells(function() {}); +} diff --git a/handsontable/handsontable.d.ts b/handsontable/handsontable.d.ts new file mode 100644 index 000000000..1af41e012 --- /dev/null +++ b/handsontable/handsontable.d.ts @@ -0,0 +1,194 @@ +// Type definitions for Handsontable 0.24.1 +// Project: https://handsontable.com/ +// Definitions by: Handsoncode sp. z o.o. +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\ + +declare namespace ht { + interface Options { + allowEmpty?: boolean; + allowInsertColumn?: boolean; + allowInsertRow?: boolean; + allowInvalid?: boolean; + allowRemoveColumn?: boolean; + allowRemoveRow?: boolean; + autoColumnSize?: Object|boolean; + autoComplete?: any[]; + autoRowSize?: Object|boolean; + autoWrapCol?: boolean; + autoWrapRow?: boolean; + cell?: any[]; + cells?: Function; + checkedTemplate?: boolean|string; + className?: string|any[]; + colHeaders?: boolean|any[]|Function; + columnHeaderHeight?: number|any[]; + columns?: any[]; + columnSorting?: boolean|Object; + colWidths?: any[]|Function|number|string; + commentedCellClassName?: string; + comments?: boolean|any[]; + contextMenu?: boolean|any[]|Object; + contextMenuCopyPaste?: Object; + copyable?: boolean; + copyColsLimit?: number; + copyPaste?: boolean; + copyRowsLimit?: number; + correctFormat?: boolean; + currentColClassName?: string; + currentRowClassName?: string; + customBorders?: boolean|any[]; + data?: any[]|Function; + dataSchema?: Object; + dateFormat?: string; + debug?: boolean; + defaultDate?: string; + disableVisualSelection?: boolean|string|any[]; + editor?: string|Function|boolean; + enterBeginsEditing?: boolean; + enterMoves?: Object|Function; + fillHandle?: boolean|string|Object; + fixedColumnsLeft?: number; + fixedRowsTop?: number; + format?: string; + fragmentSelection?: boolean|string; + height?: number|Function; + invalidCellClassName?: string; + label?: Object; + language?: string; + manualColumnFreeze?: boolean; + manualColumnMove?: boolean|any[]; + manualColumnResize?: boolean|any[]; + manualRowMove?: boolean|any[]; + manualRowResize?: boolean|any[]; + maxCols?: number; + maxRows?: number; + mergeCells?: boolean|any[]; + minCols?: number; + minRows?: number; + minSpareCols?: number; + minSpareRows?: number; + multiSelect?: boolean; + noWordWrapClassName?: string; + observeChanges?: boolean; + observeDOMVisibility?: boolean; + outsideClickDeselects?: boolean; + pasteMode?: string; + persistentState?: boolean; + placeholder?: any; + placeholderCellClassName?: string; + preventOverflow?: string|boolean; + readOnly?: boolean; + readOnlyCellClassName?: string; + renderAllRows?: boolean; + renderer?: string|Function; + rowHeaders?: boolean|any[]|Function; + rowHeaderWidth?: number|any[]; + rowHeights?: any[]|Function|number|string; + search?: boolean; + selectOptions?: any[]; + skipColumnOnPaste?: boolean; + sortFunction?: Function; + sortIndicator?: boolean; + source?: any[]|Function; + startCols?: number; + startRows?: number; + stretchH?: string; + strict?: boolean; + tableClassName?: string|any[]; + tabMoves?: Object; + title?: string; + trimDropdown?: boolean; + trimWhitespace?: boolean; + type?: string; + uncheckedTemplate?: boolean|string; + undo?: boolean; + validator?: Function|RegExp; + viewportColumnRenderingOffset?: number|string; + viewportRowRenderingOffset?: number|string; + visibleRows?: number; + width?: number|Function; + wordWrap?: boolean; + isEmptyCol?: (col: number) => boolean; + isEmptyRow?: (row: number) => boolean; + } + interface Methods { + addHook(key: string, callback: Function|any[]): void; + addHookOnce(key: string, callback: Function|any[]): void; + alter(action: string, index: number, amount?: number, source?: string, keepEmptyRows?: boolean): void; + clear(): void; + colOffset(): number; + colToProp(col: number): string|number; + countCols(): number; + countEmptyCols(ending?: boolean): number; + countEmptyRows(ending?: boolean): number; + countRenderedCols(): number; + countRenderedRows(): number; + countRows(): number; + countSourceRows(): number; + countVisibleCols(): number; + countVisibleRows(): number; + deselectCell(): void; + destroy(): void; + destroyEditor(revertOriginal?: boolean): void; + getActiveEditor(): Object; + getCell(row: number, col: number, topmost?: boolean): Element; + getCellEditor(row: number, col: number): Object; + getCellMeta(row: number, col: number): Object; + getCellRenderer(row: number, col: number): Function; + getCellValidator(row: number, col: number): any; + getColHeader(col: number): any[]|string; + getColWidth(col: number): number; + getCoords(elem: Element): Object; + getCopyableData(row: number, column: number): string; + getCopyableText(startRow: number, startCol: number, endRow: number, endCol: number): string; + getData(r?: number, c?: number, r2?: number, c2?: number): any[]; + getDataAtCell(row: number, col: number): any; + getDataAtCol(col: number): any[]; + getDataAtProp(prop: string|number): any[]; + getDataAtRow(row: number): any[]; + getDataAtRowProp(row: number, prop: string): any; + getDataType(rowFrom: number, columnFrom: number, rowTo: number, columnTo: number): string; + getInstance(): any; + getPlugin(pluginName: string): any; + getRowHeader(row?: number): any[]|string; + getRowHeight(row: number): number; + getSchema(): Object; + getSelected(): any[]; + getSelectedRange(): any; + getSettings(): Object; + getSourceData(r?: number, c?: number, r2?: number, c2?: number): any[]; + getSourceDataAtCell(row: number, column: number): any; + getSourceDataAtCol(column: number): any[]; + getSourceDataAtRow(row: number): any[]|Object; + getValue(): any; + hasColHeaders(): boolean; + hasHook(key: string): boolean; + hasRowHeaders(): boolean; + isEmptyCol(col: number): boolean; + isEmptyRow(row: number): boolean; + isListening(): boolean; + listen(): void; + loadData(data: any[]): void; + populateFromArray(row: number, col: number, input: any[], endRow?: number, endCol?: number, source?: string, method?: string, direction?: string, deltas?: any[]): any; + propToCol(prop: string): number; + removeCellMeta(row: number, col: number, key: string): void; + removeHook(key: string, callback: Function): void; + render(): void; + rowOffset(): number; + runHooks(key: string, p1?: any, p2?: any, p3?: any, p4?: any, p5?: any, p6?: any): any; + selectCell(row: number, col: number, endRow?: number, endCol?: number, scrollToCell?: boolean, changeListener?: boolean): boolean; + selectCellByProp(row: number, prop: string, endRow?: number, endProp?: string, scrollToCell?: boolean): boolean; + setCellMeta(row: number, col: number, key: string, val: string): void; + setCellMetaObject(row: number, col: number, prop: Object): void; + setDataAtCell(row: number|any[], col: number, value: string, source?: string): void; + setDataAtRowProp(row: number|any[], prop: string, value: string, source?: string): void; + spliceCol(col: number, index: number, amount: number, elements?: any): void; + spliceRow(row: number, index: number, amount: number, elements?: any): void; + unlisten(): void; + updateSettings(settings: Object, init: boolean): void; + validateCells(callback: Function): void; + } +} +declare var Handsontable: { + new (element: Element, options: ht.Options): ht.Methods; +};