react-konva-grid
Advanced tools
Comparing version 2.7.8 to 2.7.9
@@ -75,2 +75,7 @@ import { ItemSizer, InstanceInterface, AreaProps, CellInterface, CellMetaData, SelectionArea } from "./Grid"; | ||
export declare const selectionFromActiveCell: (activeCell: CellInterface | null) => SelectionArea[]; | ||
/** | ||
* Converts a number to alphabet | ||
* @param i | ||
*/ | ||
export declare const numberToAlphabet: (i: number) => string; | ||
export declare const prepareClipboardData: (rows: string[][]) => [string, string]; | ||
@@ -77,0 +82,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findNextCellWithinBounds = 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 = exports.ItemType = exports.Align = void 0; | ||
exports.findNextCellWithinBounds = exports.prepareClipboardData = exports.numberToAlphabet = 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 = exports.ItemType = exports.Align = void 0; | ||
const types_1 = require("./types"); | ||
@@ -435,2 +435,10 @@ var Align; | ||
}; | ||
/** | ||
* Converts a number to alphabet | ||
* @param i | ||
*/ | ||
exports.numberToAlphabet = (i) => { | ||
return ((i >= 26 ? exports.numberToAlphabet(((i / 26) >> 0) - 1) : "") + | ||
"abcdefghijklmnopqrstuvwxyz"[i % 26 >> 0]).toUpperCase(); | ||
}; | ||
exports.prepareClipboardData = (rows) => { | ||
@@ -437,0 +445,0 @@ const html = ["<table>"]; |
@@ -28,6 +28,7 @@ import React from "react"; | ||
onSubmit?: (value: string, activeCell: CellInterface, nextActiveCell?: CellInterface | null) => void; | ||
onCancel?: (e: React.KeyboardEvent<HTMLInputElement>) => void; | ||
onCancel?: (e?: React.KeyboardEvent<HTMLInputElement>) => void; | ||
scrollPosition: ScrollCoords; | ||
position: CellPosition; | ||
activeCell: CellInterface; | ||
cell: CellInterface; | ||
nextFocusableCell: (activeCell: CellInterface, direction?: Direction) => CellInterface | null; | ||
@@ -34,0 +35,0 @@ } |
@@ -41,3 +41,3 @@ "use strict"; | ||
const DefaultEditor = (props) => { | ||
const { rowIndex, columnIndex, onChange, onSubmit, onCancel, scrollPosition, position, activeCell, nextFocusableCell } = props, rest = __rest(props, ["rowIndex", "columnIndex", "onChange", "onSubmit", "onCancel", "scrollPosition", "position", "activeCell", "nextFocusableCell"]); | ||
const { rowIndex, columnIndex, onChange, onSubmit, onCancel, scrollPosition, position, cell, nextFocusableCell } = props, rest = __rest(props, ["rowIndex", "columnIndex", "onChange", "onSubmit", "onCancel", "scrollPosition", "position", "cell", "nextFocusableCell"]); | ||
const inputRef = react_1.useRef(null); | ||
@@ -60,3 +60,3 @@ react_1.useEffect(() => { | ||
outline: "none", | ||
}, onChange: (e) => onChange(e.target.value, activeCell), onKeyDown: (e) => { | ||
}, onChange: (e) => onChange(e.target.value, cell), onKeyDown: (e) => { | ||
if (!inputRef.current) | ||
@@ -67,3 +67,3 @@ return; | ||
onSubmit && | ||
onSubmit(inputRef.current.value, activeCell, nextFocusableCell(activeCell, types_1.Direction.Down)); | ||
onSubmit(inputRef.current.value, cell, nextFocusableCell(cell, types_1.Direction.Down)); | ||
} | ||
@@ -76,3 +76,3 @@ if (e.which === types_1.KeyCodes.Escape) { | ||
onSubmit && | ||
onSubmit(inputRef.current.value, activeCell, nextFocusableCell(activeCell, types_1.Direction.Right)); | ||
onSubmit(inputRef.current.value, cell, nextFocusableCell(cell, types_1.Direction.Right)); | ||
} | ||
@@ -201,3 +201,3 @@ } }, rest))); | ||
/* Save the value */ | ||
const handleSubmit = react_1.useCallback((value, activeCell, nextActiveCell) => { | ||
const handleSubmit = react_1.useCallback((value, activeCell, nextActiveCell = nextFocusableCell(activeCell, types_1.Direction.Down)) => { | ||
/** | ||
@@ -217,3 +217,3 @@ * Hide the editor first, so that we can handle onBlur events | ||
}, []); | ||
const handleChange = react_1.useCallback((value) => { | ||
const handleChange = react_1.useCallback((value, activeCell) => { | ||
if (!activeCell) | ||
@@ -223,3 +223,3 @@ return; | ||
onChange && onChange(value, activeCell); | ||
}, [activeCell]); | ||
}, []); | ||
/* When the input is blurred out */ | ||
@@ -248,3 +248,7 @@ const handleHide = react_1.useCallback((e) => { | ||
}, [position, scrollPosition]); | ||
const editorComponent = isEditorShown && Editor ? (react_1.default.createElement(Editor, { activeCell: editingCell, value: value, selections: selections, onChange: handleChange, onSubmit: handleSubmit, onCancel: handleHide, position: cellPositon, nextFocusableCell: nextFocusableCell, onBlur: () => { | ||
const editorComponent = isEditorShown && Editor ? (react_1.default.createElement(Editor | ||
/* This is the cell that is currently being edited */ | ||
, { | ||
/* This is the cell that is currently being edited */ | ||
cell: editingCell, activeCell: activeCell, value: value, selections: selections, onChange: handleChange, onSubmit: handleSubmit, onCancel: handleHide, position: cellPositon, nextFocusableCell: nextFocusableCell, onBlur: () => { | ||
if (currentActiveCellRef.current) { | ||
@@ -251,0 +255,0 @@ handleSubmit(value, currentActiveCellRef.current); |
{ | ||
"name": "react-konva-grid", | ||
"description": "Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets", | ||
"version": "2.7.8", | ||
"version": "2.7.9", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -653,2 +653,13 @@ // Utilities extracted from https://github.com/bvaughn/react-window | ||
/** | ||
* Converts a number to alphabet | ||
* @param i | ||
*/ | ||
export const numberToAlphabet = (i: number): string => { | ||
return ( | ||
(i >= 26 ? numberToAlphabet(((i / 26) >> 0) - 1) : "") + | ||
"abcdefghijklmnopqrstuvwxyz"[i % 26 >> 0] | ||
).toUpperCase(); | ||
}; | ||
export const prepareClipboardData = (rows: string[][]): [string, string] => { | ||
@@ -655,0 +666,0 @@ const html = ["<table>"]; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14873740
82
22227