react-konva-grid
Advanced tools
Comparing version 2.7.20 to 2.8.0
import { ItemSizer, InstanceInterface, AreaProps, CellInterface, CellMetaData, SelectionArea } from "./Grid"; | ||
import { Movement } from "./types"; | ||
import { Direction } from "./types"; | ||
export declare enum Align { | ||
@@ -96,3 +96,3 @@ start = "start", | ||
*/ | ||
export declare const findNextCellWithinBounds: (activeCellBounds: AreaProps, selectionBounds: AreaProps, direction?: Movement) => CellInterface | null; | ||
export declare const findNextCellWithinBounds: (activeCellBounds: AreaProps, selectionBounds: AreaProps, direction?: Direction) => CellInterface | null; | ||
/** | ||
@@ -99,0 +99,0 @@ * Get maximum bound of an area, caters to merged cells |
@@ -474,6 +474,6 @@ "use strict"; | ||
*/ | ||
exports.findNextCellWithinBounds = (activeCellBounds, selectionBounds, direction = types_1.Movement.forwards) => { | ||
exports.findNextCellWithinBounds = (activeCellBounds, selectionBounds, direction = types_1.Direction.Right) => { | ||
let rowIndex, columnIndex; | ||
let nextActiveCell = null; | ||
if (direction === types_1.Movement.forwards) { | ||
if (direction === types_1.Direction.Right) { | ||
rowIndex = activeCellBounds.top; | ||
@@ -490,3 +490,3 @@ columnIndex = activeCellBounds.left + 1; | ||
} | ||
if (direction === types_1.Movement.backwards) { | ||
if (direction === types_1.Direction.Left) { | ||
rowIndex = activeCellBounds.bottom; | ||
@@ -503,3 +503,3 @@ columnIndex = activeCellBounds.left - 1; | ||
} | ||
if (direction === types_1.Movement.downwards) { | ||
if (direction === types_1.Direction.Down) { | ||
rowIndex = activeCellBounds.bottom + 1; | ||
@@ -516,2 +516,14 @@ columnIndex = activeCellBounds.left; | ||
} | ||
if (direction === types_1.Direction.Up) { | ||
rowIndex = activeCellBounds.top - 1; | ||
columnIndex = activeCellBounds.left; | ||
if (rowIndex < selectionBounds.top) { | ||
columnIndex = activeCellBounds.left - 1; | ||
rowIndex = selectionBounds.bottom; | ||
if (columnIndex < selectionBounds.left) { | ||
columnIndex = selectionBounds.right; | ||
} | ||
} | ||
nextActiveCell = { rowIndex, columnIndex }; | ||
} | ||
return nextActiveCell; | ||
@@ -518,0 +530,0 @@ }; |
@@ -198,3 +198,3 @@ "use strict"; | ||
} | ||
if (direction === types_1.Direction.Down) { | ||
if (direction === types_1.Direction.Down || direction === types_1.Direction.Up) { | ||
/* Move to the next row + cell */ | ||
@@ -206,3 +206,3 @@ initialActiveCell.current = undefined; | ||
const activeCellBounds = gridRef.current.getCellBounds(currentCell); | ||
const nextCell = helpers_1.findNextCellWithinBounds(activeCellBounds, bounds, types_1.Movement.downwards); | ||
const nextCell = helpers_1.findNextCellWithinBounds(activeCellBounds, bounds, direction); | ||
if (nextCell) | ||
@@ -209,0 +209,0 @@ nextActiveCell = nextCell; |
@@ -469,5 +469,3 @@ "use strict"; | ||
const activeCellBounds = gridRef.current.getCellBounds(activeCell); | ||
const direction = isShiftKey | ||
? types_1.Movement.backwards | ||
: types_1.Movement.forwards; | ||
const direction = isShiftKey ? types_1.Direction.Left : types_1.Direction.Right; | ||
const nextCell = helpers_1.findNextCellWithinBounds(activeCellBounds, bounds, direction); | ||
@@ -474,0 +472,0 @@ if (nextCell) |
@@ -27,7 +27,2 @@ export declare enum KeyCodes { | ||
} | ||
export declare enum Movement { | ||
forwards = "forwards", | ||
backwards = "backwards", | ||
downwards = "downwards" | ||
} | ||
export declare enum MimeType { | ||
@@ -34,0 +29,0 @@ html = "text/html", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MouseButtonCodes = exports.MimeType = exports.Movement = exports.Direction = exports.KeyCodes = void 0; | ||
exports.MouseButtonCodes = exports.MimeType = exports.Direction = exports.KeyCodes = void 0; | ||
var KeyCodes; | ||
@@ -32,8 +32,2 @@ (function (KeyCodes) { | ||
})(Direction = exports.Direction || (exports.Direction = {})); | ||
var Movement; | ||
(function (Movement) { | ||
Movement["forwards"] = "forwards"; | ||
Movement["backwards"] = "backwards"; | ||
Movement["downwards"] = "downwards"; | ||
})(Movement = exports.Movement || (exports.Movement = {})); | ||
var MimeType; | ||
@@ -40,0 +34,0 @@ (function (MimeType) { |
{ | ||
"name": "react-konva-grid", | ||
"description": "Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets", | ||
"version": "2.7.20", | ||
"version": "2.8.0", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -10,3 +10,3 @@ // Utilities extracted from https://github.com/bvaughn/react-window | ||
} from "./Grid"; | ||
import { Movement } from "./types"; | ||
import { Direction } from "./types"; | ||
@@ -700,7 +700,7 @@ export enum Align { | ||
selectionBounds: AreaProps, | ||
direction: Movement = Movement.forwards | ||
direction: Direction = Direction.Right | ||
): CellInterface | null => { | ||
let rowIndex, columnIndex; | ||
let nextActiveCell: CellInterface | null = null; | ||
if (direction === Movement.forwards) { | ||
if (direction === Direction.Right) { | ||
rowIndex = activeCellBounds.top; | ||
@@ -717,3 +717,3 @@ columnIndex = activeCellBounds.left + 1; | ||
} | ||
if (direction === Movement.backwards) { | ||
if (direction === Direction.Left) { | ||
rowIndex = activeCellBounds.bottom; | ||
@@ -731,3 +731,3 @@ columnIndex = activeCellBounds.left - 1; | ||
if (direction === Movement.downwards) { | ||
if (direction === Direction.Down) { | ||
rowIndex = activeCellBounds.bottom + 1; | ||
@@ -745,2 +745,15 @@ columnIndex = activeCellBounds.left; | ||
if (direction === Direction.Up) { | ||
rowIndex = activeCellBounds.top - 1; | ||
columnIndex = activeCellBounds.left; | ||
if (rowIndex < selectionBounds.top) { | ||
columnIndex = activeCellBounds.left - 1; | ||
rowIndex = selectionBounds.bottom; | ||
if (columnIndex < selectionBounds.left) { | ||
columnIndex = selectionBounds.right; | ||
} | ||
} | ||
nextActiveCell = { rowIndex, columnIndex }; | ||
} | ||
return nextActiveCell; | ||
@@ -747,0 +760,0 @@ }; |
@@ -10,3 +10,3 @@ import React, { useState, useCallback, useRef, useEffect } from "react"; | ||
} from "./../helpers"; | ||
import { KeyCodes, Direction, Movement, MouseButtonCodes } from "./../types"; | ||
import { KeyCodes, Direction, MouseButtonCodes } from "./../types"; | ||
@@ -629,5 +629,3 @@ export interface UseSelectionOptions { | ||
const activeCellBounds = gridRef.current.getCellBounds(activeCell); | ||
const direction = isShiftKey | ||
? Movement.backwards | ||
: Movement.forwards; | ||
const direction = isShiftKey ? Direction.Left : Direction.Right; | ||
const nextCell = findNextCellWithinBounds( | ||
@@ -634,0 +632,0 @@ activeCellBounds, |
@@ -29,8 +29,2 @@ export enum KeyCodes { | ||
export enum Movement { | ||
forwards = "forwards", | ||
backwards = "backwards", | ||
downwards = "downwards", | ||
} | ||
export enum MimeType { | ||
@@ -37,0 +31,0 @@ html = "text/html", |
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
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
16863696
25792