@glideapps/glide-data-grid
Advanced tools
Comparing version 2.2.8 to 2.2.9
@@ -57,2 +57,12 @@ "use strict"; | ||
var _React$useState9 = React.useState(false), | ||
_React$useState10 = _slicedToArray(_React$useState9, 2), | ||
dragActive = _React$useState10[0], | ||
setDragActive = _React$useState10[1]; | ||
var _React$useState11 = React.useState(), | ||
_React$useState12 = _slicedToArray(_React$useState11, 2), | ||
dragStartX = _React$useState12[0], | ||
setDragStartX = _React$useState12[1]; | ||
var firstColSticky = p.firstColSticky, | ||
@@ -73,2 +83,3 @@ onColumnMoved = p.onColumnMoved, | ||
if (dragCol !== undefined && dropCol !== col && (!firstColSticky || col > 0)) { | ||
setDragActive(true); | ||
setDropCol(col); | ||
@@ -91,2 +102,3 @@ } | ||
} else if (args.kind === "header") { | ||
setDragStartX(args.bounds.x); | ||
setDragCol(col); | ||
@@ -101,2 +113,4 @@ } | ||
setDropCol(undefined); | ||
setDragStartX(undefined); | ||
setDragActive(false); | ||
setResizeCol(undefined); | ||
@@ -123,10 +137,17 @@ setResizeColStartX(undefined); | ||
var onMouseMove = React.useCallback(function (event) { | ||
if (resizeCol === undefined || resizeColStartX === undefined) return; | ||
var column = columns[resizeCol]; | ||
var newWidth = (0, _clamp.default)(event.clientX - resizeColStartX, 50, maxColumnWidthValue); | ||
onColumnResized === null || onColumnResized === void 0 ? void 0 : onColumnResized(column, newWidth); | ||
}, [resizeCol, resizeColStartX, columns, onColumnResized, maxColumnWidthValue]); | ||
if (dragCol !== undefined && dragStartX !== undefined) { | ||
var diff = Math.abs(event.clientX - dragStartX); | ||
if (diff > 20) { | ||
setDragActive(true); | ||
} | ||
} else if (resizeCol !== undefined && resizeColStartX !== undefined) { | ||
var _column = columns[resizeCol]; | ||
var newWidth = (0, _clamp.default)(event.clientX - resizeColStartX, 50, maxColumnWidthValue); | ||
onColumnResized === null || onColumnResized === void 0 ? void 0 : onColumnResized(_column, newWidth); | ||
} | ||
}, [dragCol, dragStartX, resizeCol, resizeColStartX, columns, maxColumnWidthValue, onColumnResized]); | ||
return /*#__PURE__*/React.createElement(_dataGrid.default, _extends({}, p, { | ||
isResizing: resizeCol !== undefined, | ||
isDragging: dragCol !== undefined, | ||
isDragging: dragActive, | ||
onItemHovered: onItemHoveredImpl, | ||
@@ -133,0 +154,0 @@ onMouseDown: onMouseDownImpl, |
@@ -145,2 +145,3 @@ "use strict"; | ||
uri: targetValue.data, | ||
readonly: targetValue.readonly === true, | ||
onKeyDown: onKeyDown, | ||
@@ -190,2 +191,3 @@ onChange: onStringValueChange | ||
targetRect: target, | ||
readonly: targetValue.readonly === true, | ||
markdown: targetValue.data, | ||
@@ -192,0 +194,0 @@ onKeyDown: onKeyDownMultiline, |
@@ -44,3 +44,4 @@ "use strict"; | ||
createNode = p.createNode, | ||
targetRect = p.targetRect; | ||
targetRect = p.targetRect, | ||
readonly = p.readonly; | ||
@@ -70,3 +71,3 @@ var _React$useState = React.useState(markdown === "" || forceEditMode), | ||
createNode: createNode | ||
}), /*#__PURE__*/React.createElement("div", { | ||
}), !readonly && /*#__PURE__*/React.createElement("div", { | ||
className: "edit-icon", | ||
@@ -73,0 +74,0 @@ onClick: onEditClick |
@@ -40,3 +40,4 @@ "use strict"; | ||
onKeyDown = p.onKeyDown, | ||
forceEditMode = p.forceEditMode; | ||
forceEditMode = p.forceEditMode, | ||
readonly = p.readonly; | ||
@@ -67,3 +68,3 @@ var _React$useState = React.useState(uri === "" || forceEditMode), | ||
rel: "noopener noreferrer" | ||
}, uri)), /*#__PURE__*/React.createElement("div", { | ||
}, uri)), !readonly && /*#__PURE__*/React.createElement("div", { | ||
className: "edit-icon", | ||
@@ -70,0 +71,0 @@ onClick: onEditClick |
@@ -41,3 +41,3 @@ "use strict"; | ||
if (cell.kind === GridCellKind.Text || cell.kind === GridCellKind.Number) { | ||
if (cell.kind === GridCellKind.Text || cell.kind === GridCellKind.Number || cell.kind === GridCellKind.Markdown || cell.kind === GridCellKind.Uri) { | ||
return cell.readonly !== true; | ||
@@ -44,0 +44,0 @@ } |
@@ -9,2 +9,3 @@ import * as React from "react"; | ||
readonly forceEditMode: boolean; | ||
readonly readonly: boolean; | ||
createNode?: (content: string) => DocumentFragment; | ||
@@ -11,0 +12,0 @@ } |
@@ -7,4 +7,5 @@ import * as React from "react"; | ||
readonly forceEditMode: boolean; | ||
readonly readonly: boolean; | ||
} | ||
declare const UriOverlayEditor: React.FunctionComponent<Props>; | ||
export default UriOverlayEditor; |
@@ -127,2 +127,3 @@ import { HeaderIcon } from "./data-grid-sprites"; | ||
readonly data: string; | ||
readonly readonly?: boolean; | ||
} | ||
@@ -132,3 +133,4 @@ interface UriCell extends BaseGridCell { | ||
readonly data: string; | ||
readonly readonly?: boolean; | ||
} | ||
export {}; |
{ | ||
"name": "@glideapps/glide-data-grid", | ||
"version": "2.2.8", | ||
"version": "2.2.9", | ||
"description": "Super fast, pure canvas Data Grid Editor", | ||
@@ -5,0 +5,0 @@ "main": "dist/js/index.js", |
348836
6102