@blueprintjs/table
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -133,3 +133,3 @@ /** | ||
Grid.prototype.getWidth = function () { | ||
return this.cumulativeColumnWidths[this.numCols - 1]; | ||
return this.numCols === 0 ? 0 : this.cumulativeColumnWidths[this.numCols - 1]; | ||
}; | ||
@@ -140,3 +140,3 @@ /** | ||
Grid.prototype.getHeight = function () { | ||
return this.cumulativeRowHeights[this.numRows - 1]; | ||
return this.numRows === 0 ? 0 : this.cumulativeRowHeights[this.numRows - 1]; | ||
}; | ||
@@ -143,0 +143,0 @@ /** |
@@ -39,2 +39,9 @@ /** | ||
/** | ||
* Used for hotkey copy, via (mod+c), as long as this property exists. | ||
* If exists, a callback that returns the data for a specific cell. This need not | ||
* match the value displayed in the `<Cell>` component. The value will be | ||
* invisibly added as `textContent` into the DOM before copying. | ||
*/ | ||
getCellClipboardData?: (row: number, col: number) => any; | ||
/** | ||
* If false, disables resizing of columns. | ||
@@ -89,2 +96,12 @@ * @default true | ||
/** | ||
* If you want to do something after the copy or if you want to notify the | ||
* user if a copy fails, you may provide this optional callback. | ||
* | ||
* Due to browser limitations, the copy can fail. This usually occurs if | ||
* the selection is too large, like 20,000+ cells. The copy will also fail | ||
* if the browser does not support the copy method (see | ||
* `Clipboard.isCopySupported`). | ||
*/ | ||
onCopy?: (success: boolean) => void; | ||
/** | ||
* Render each row's header cell | ||
@@ -215,2 +232,3 @@ */ | ||
render(): JSX.Element; | ||
renderHotkeys(): JSX.Element; | ||
/** | ||
@@ -227,2 +245,3 @@ * When the component mounts, the HTML Element refs will be available, so | ||
}): void; | ||
private handleCopy; | ||
private renderMenu(); | ||
@@ -248,2 +267,3 @@ private syncMenuWidth(); | ||
private maybeRenderRegions(getRegionStyle); | ||
private maybeRenderCopyHotkey(); | ||
private maybeRenderBodyRegions(); | ||
@@ -250,0 +270,0 @@ private maybeRenderColumnHeaderRegions(); |
@@ -10,2 +10,3 @@ /** | ||
var core_1 = require("@blueprintjs/core"); | ||
var core_2 = require("@blueprintjs/core"); | ||
var classNames = require("classnames"); | ||
@@ -15,2 +16,3 @@ var PureRender = require("pure-render-decorator"); | ||
var column_1 = require("./column"); | ||
var clipboard_1 = require("./common/clipboard"); | ||
var grid_1 = require("./common/grid"); | ||
@@ -31,2 +33,19 @@ var utils_1 = require("./common/utils"); | ||
var _this = _super.call(this, props, context) || this; | ||
_this.handleCopy = function (e) { | ||
var grid = _this.grid; | ||
var _a = _this.props, getCellClipboardData = _a.getCellClipboardData, onCopy = _a.onCopy; | ||
var selectedRegions = _this.state.selectedRegions; | ||
if (getCellClipboardData == null) { | ||
return; | ||
} | ||
// prevent "real" copy from being called | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
var cells = regions_2.Regions.enumerateUniqueCells(selectedRegions, grid.numRows, grid.numCols); | ||
var sparse = regions_2.Regions.sparseMapCells(cells, getCellClipboardData); | ||
if (sparse != null) { | ||
var success = clipboard_1.Clipboard.copyCells(sparse); | ||
core_1.Utils.safeInvoke(onCopy, success); | ||
} | ||
}; | ||
_this.columnHeaderCellRenderer = function (columnIndex) { | ||
@@ -203,2 +222,5 @@ var props = _this.getColumnProps(columnIndex); | ||
}; | ||
Table.prototype.renderHotkeys = function () { | ||
return React.createElement(core_2.Hotkeys, null, this.maybeRenderCopyHotkey()); | ||
}; | ||
/** | ||
@@ -361,2 +383,11 @@ * When the component mounts, the HTML Element refs will be available, so | ||
}; | ||
Table.prototype.maybeRenderCopyHotkey = function () { | ||
var getCellClipboardData = this.props.getCellClipboardData; | ||
if (getCellClipboardData != null) { | ||
return (React.createElement(core_2.Hotkey, { label: "Copy selected table cells", group: "Table", combo: "mod+c", onKeyDown: this.handleCopy })); | ||
} | ||
else { | ||
return undefined; | ||
} | ||
}; | ||
Table.prototype.maybeRenderBodyRegions = function () { | ||
@@ -440,3 +471,4 @@ var _this = this; | ||
Table = Table_1 = tslib_1.__decorate([ | ||
PureRender | ||
PureRender, | ||
core_2.HotkeysTarget | ||
], Table); | ||
@@ -443,0 +475,0 @@ exports.Table = Table; |
{ | ||
"name": "@blueprintjs/table", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Scalable interactive table component", | ||
@@ -22,3 +22,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@blueprintjs/core": "^1.5.0", | ||
"@blueprintjs/core": "^1.8.0", | ||
"classnames": "^2.2", | ||
@@ -25,0 +25,0 @@ "es6-shim": "^0.35", |
@@ -150,3 +150,3 @@ /** | ||
public getWidth() { | ||
return this.cumulativeColumnWidths[this.numCols - 1]; | ||
return this.numCols === 0 ? 0 : this.cumulativeColumnWidths[this.numCols - 1]; | ||
} | ||
@@ -158,3 +158,3 @@ | ||
public getHeight() { | ||
return this.cumulativeRowHeights[this.numRows - 1]; | ||
return this.numRows === 0 ? 0 : this.cumulativeRowHeights[this.numRows - 1]; | ||
} | ||
@@ -161,0 +161,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1707141
169
16111
Updated@blueprintjs/core@^1.8.0