react-konva-grid
Advanced tools
Comparing version 2.7.2 to 2.7.3
@@ -213,2 +213,3 @@ import React, { Key } from "react"; | ||
stage: typeof Stage | null; | ||
container: HTMLDivElement | null; | ||
resetAfterIndices: (coords: CellInterface, shouldForceUpdate?: boolean) => void; | ||
@@ -215,0 +216,0 @@ getScrollPosition: () => ScrollCoords; |
@@ -69,2 +69,3 @@ "use strict"; | ||
stage: stageRef.current, | ||
container: containerRef.current, | ||
resetAfterIndices, | ||
@@ -992,3 +993,3 @@ getScrollPosition, | ||
return (react_1.default.createElement("div", { style: { position: "relative", width: containerWidth } }, | ||
react_1.default.createElement("div", Object.assign({ onWheel: handleWheel, tabIndex: 1, ref: containerRef }, rest), | ||
react_1.default.createElement("div", Object.assign({ onWheel: handleWheel, tabIndex: 0, ref: containerRef }, rest), | ||
react_1.default.createElement(ReactKonvaCore_1.Stage, Object.assign({ width: containerWidth, height: containerHeight, ref: stageRef, listening: listenToEvents }, stageProps), wrapper(stageChildren))), | ||
@@ -995,0 +996,0 @@ showScrollbar ? (react_1.default.createElement(react_1.default.Fragment, null, |
@@ -1,2 +0,2 @@ | ||
import { ItemSizer, InstanceInterface, AreaProps, CellInterface, CellMetaData } from "./Grid"; | ||
import { ItemSizer, InstanceInterface, AreaProps, CellInterface, CellMetaData, SelectionArea } from "./Grid"; | ||
declare enum Align { | ||
@@ -73,2 +73,4 @@ start = "start", | ||
export declare function requestTimeout(callback: Function, delay: number): TimeoutID; | ||
export declare const selectionFromActiveCell: (activeCell: CellInterface | null) => SelectionArea[]; | ||
export declare const prepareClipboardData: (rows: string[][]) => [string, string]; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.requestTimeout = exports.cancelTimeout = exports.getOffsetForRowAndAlignment = exports.getOffsetForColumnAndAlignment = exports.getOffsetForIndexAndAlignment = exports.rafThrottle = exports.debounce = exports.throttle = exports.cellIndentifier = exports.getEstimatedTotalWidth = exports.getEstimatedTotalHeight = exports.getItemMetadata = exports.getColumnWidth = exports.getRowHeight = exports.getColumnOffset = exports.getRowOffset = exports.itemKey = exports.getBoundedCells = exports.getColumnStopIndexForStartIndex = exports.getColumnStartIndexForOffset = exports.getRowStopIndexForStartIndex = exports.getRowStartIndexForOffset = void 0; | ||
// type ItemType = "row" | "column"; | ||
exports.prepareClipboardData = exports.selectionFromActiveCell = exports.requestTimeout = exports.cancelTimeout = exports.getOffsetForRowAndAlignment = exports.getOffsetForColumnAndAlignment = exports.getOffsetForIndexAndAlignment = exports.rafThrottle = exports.debounce = exports.throttle = exports.cellIndentifier = exports.getEstimatedTotalWidth = exports.getEstimatedTotalHeight = exports.getItemMetadata = exports.getColumnWidth = exports.getRowHeight = exports.getColumnOffset = exports.getRowOffset = exports.itemKey = exports.getBoundedCells = exports.getColumnStopIndexForStartIndex = exports.getColumnStartIndexForOffset = exports.getRowStopIndexForStartIndex = exports.getRowStartIndexForOffset = void 0; | ||
var Align; | ||
@@ -421,9 +420,32 @@ (function (Align) { | ||
exports.requestTimeout = requestTimeout; | ||
// export function getNextCellInSelectionBounds (selections: SelectionProps, activeCell: CellInterface) { | ||
// let nextCell | ||
// for (let i = 0; i <= selections.length; i++) { | ||
// const { bounds } = selections[i] | ||
// const { top, left, right, bottom } = bounds | ||
// } | ||
// } | ||
exports.selectionFromActiveCell = (activeCell) => { | ||
if (!activeCell) | ||
return []; | ||
return [ | ||
{ | ||
bounds: { | ||
top: activeCell.rowIndex, | ||
left: activeCell.columnIndex, | ||
bottom: activeCell.rowIndex, | ||
right: activeCell.columnIndex, | ||
}, | ||
}, | ||
]; | ||
}; | ||
exports.prepareClipboardData = (rows) => { | ||
const html = ["<table>"]; | ||
const csv = []; | ||
rows.forEach((row) => { | ||
html.push("<tr>"); | ||
const csvRow = []; | ||
row.forEach((cell) => { | ||
html.push(`<td>${cell}</td>`); | ||
csvRow.push(`"${cell.replace(/"/g, '""')}"`); | ||
}); | ||
csv.push(csvRow.join(",")); | ||
html.push("</tr>"); | ||
}); | ||
html.push("</table>"); | ||
return [html.join(""), csv.join("\n")]; | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
@@ -13,2 +13,3 @@ import React from "react"; | ||
newSelection: (coords: CellInterface) => void; | ||
setSelections: (selection: SelectionArea[]) => void; | ||
setActiveCell: (coords: CellInterface | null) => void; | ||
@@ -15,0 +16,0 @@ selections: SelectionArea[]; |
@@ -277,2 +277,3 @@ "use strict"; | ||
newSelection, | ||
setSelections, | ||
setActiveCell, | ||
@@ -279,0 +280,0 @@ }; |
@@ -14,3 +14,4 @@ export declare enum KeyCodes { | ||
SPACE = 32, | ||
ALT = 18 | ||
ALT = 18, | ||
C = 67 | ||
} | ||
@@ -17,0 +18,0 @@ export declare enum Direction { |
@@ -19,2 +19,3 @@ "use strict"; | ||
KeyCodes[KeyCodes["ALT"] = 18] = "ALT"; | ||
KeyCodes[KeyCodes["C"] = 67] = "C"; | ||
})(KeyCodes = exports.KeyCodes || (exports.KeyCodes = {})); | ||
@@ -21,0 +22,0 @@ var Direction; |
{ | ||
"name": "react-konva-grid", | ||
"description": "Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets", | ||
"version": "2.7.2", | ||
"version": "2.7.3", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -8,7 +8,5 @@ // Utilities extracted from https://github.com/bvaughn/react-window | ||
CellMetaData, | ||
SelectionProps, | ||
SelectionArea, | ||
} from "./Grid"; | ||
// type ItemType = "row" | "column"; | ||
enum Align { | ||
@@ -639,8 +637,33 @@ start = "start", | ||
// export function getNextCellInSelectionBounds (selections: SelectionProps, activeCell: CellInterface) { | ||
// let nextCell | ||
// for (let i = 0; i <= selections.length; i++) { | ||
// const { bounds } = selections[i] | ||
// const { top, left, right, bottom } = bounds | ||
// } | ||
// } | ||
export const selectionFromActiveCell = ( | ||
activeCell: CellInterface | null | ||
): SelectionArea[] => { | ||
if (!activeCell) return []; | ||
return [ | ||
{ | ||
bounds: { | ||
top: activeCell.rowIndex, | ||
left: activeCell.columnIndex, | ||
bottom: activeCell.rowIndex, | ||
right: activeCell.columnIndex, | ||
}, | ||
}, | ||
]; | ||
}; | ||
export const prepareClipboardData = (rows: string[][]): [string, string] => { | ||
const html = ["<table>"]; | ||
const csv: string[] = []; | ||
rows.forEach((row) => { | ||
html.push("<tr>"); | ||
const csvRow: string[] = []; | ||
row.forEach((cell) => { | ||
html.push(`<td>${cell}</td>`); | ||
csvRow.push(`"${cell.replace(/"/g, '""')}"`); | ||
}); | ||
csv.push(csvRow.join(",")); | ||
html.push("</tr>"); | ||
}); | ||
html.push("</table>"); | ||
return [html.join(""), csv.join("\n")]; | ||
}; |
@@ -16,2 +16,3 @@ import React, { useState, useCallback, useRef } from "react"; | ||
newSelection: (coords: CellInterface) => void; | ||
setSelections: (selection: SelectionArea[]) => void; | ||
setActiveCell: (coords: CellInterface | null) => void; | ||
@@ -353,2 +354,3 @@ selections: SelectionArea[]; | ||
newSelection, | ||
setSelections, | ||
setActiveCell, | ||
@@ -355,0 +357,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
// @ts-nocheck | ||
import { renderHook, act } from "@testing-library/react-hooks"; | ||
@@ -2,0 +3,0 @@ import usePagination from "../hooks/usePagination"; |
@@ -15,3 +15,5 @@ import { renderHook, act } from "@testing-library/react-hooks"; | ||
it("picks up initialselection", () => { | ||
const initialSelections = [{ top: 0, left: 0, right: 0, bottom: 0 }]; | ||
const initialSelections = [ | ||
{ bounds: { top: 0, left: 0, right: 0, bottom: 0 } }, | ||
]; | ||
const { result } = renderHook(() => | ||
@@ -18,0 +20,0 @@ useSelection({ |
@@ -15,2 +15,3 @@ export enum KeyCodes { | ||
ALT = 18, | ||
C = 67, | ||
} | ||
@@ -17,0 +18,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
Sorry, the diff of this file is not supported yet
14802990
80
21734