@deephaven/grid 0.53.1-beta.0 → 0.53.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Grid.css +11 -0
- package/dist/Grid.css.map +1 -1
- package/dist/Grid.d.ts +4 -1
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +22 -9
- package/dist/Grid.js.map +1 -1
- package/dist/GridRenderer.d.ts.map +1 -1
- package/dist/GridRenderer.js +27 -21
- package/dist/GridRenderer.js.map +1 -1
- package/package.json +3 -3
package/dist/Grid.css
CHANGED
package/dist/Grid.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../src/Grid.scss"],"names":[],"mappings":"AAAA;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE","file":"Grid.css","sourcesContent":[".grid-canvas {\n display: block;\n}\n.grid-canvas:focus {\n outline: none;\n}\n.grid-cursor-default {\n cursor: default;\n}\n.grid-cursor-move {\n cursor: grabbing;\n}\n.grid-cursor-not-allowed {\n cursor: not-allowed;\n}\n.grid-cursor-s-resize {\n cursor: s-resize;\n}\n.grid-cursor-row-resize {\n cursor: row-resize;\n}\n.grid-cursor-e-resize {\n cursor: e-resize;\n}\n.grid-cursor-col-resize {\n cursor: col-resize;\n}\n.grid-cursor-pointer {\n cursor: pointer;\n}\n.grid-block-events {\n pointer-events: none;\n}\n"]}
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../src/Grid.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE","file":"Grid.css","sourcesContent":[".grid-wrapper {\n flex: 1 1 0;\n max-width: 100%;\n max-height: 100%;\n // min-width/height used to make sure grid shrinks properly when notification bars are added/resized\n min-width: 0;\n min-height: 0;\n position: relative;\n font: sans-serif;\n font-feature-settings: 'tnum';\n}\n\n.grid-canvas {\n display: block;\n}\n.grid-canvas:focus {\n outline: none;\n}\n.grid-cursor-default {\n cursor: default;\n}\n.grid-cursor-move {\n cursor: grabbing;\n}\n.grid-cursor-not-allowed {\n cursor: not-allowed;\n}\n.grid-cursor-s-resize {\n cursor: s-resize;\n}\n.grid-cursor-row-resize {\n cursor: row-resize;\n}\n.grid-cursor-e-resize {\n cursor: e-resize;\n}\n.grid-cursor-col-resize {\n cursor: col-resize;\n}\n.grid-cursor-pointer {\n cursor: pointer;\n}\n.grid-block-events {\n pointer-events: none;\n}\n"]}
|
package/dist/Grid.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { PureComponent, ReactNode } from 'react';
|
|
1
|
+
import React, { PureComponent, ReactNode, RefObject } from 'react';
|
|
2
2
|
import GridMetricCalculator, { GridMetricState } from './GridMetricCalculator';
|
|
3
3
|
import GridModel from './GridModel';
|
|
4
4
|
import GridMouseHandler, { GridMouseEvent, GridMouseHandlerFunctionName } from './GridMouseHandler';
|
|
@@ -13,6 +13,7 @@ import GridMetrics, { Coordinate, ModelIndex, MoveOperation, VisibleIndex } from
|
|
|
13
13
|
import { DraggingColumn } from './mouse-handlers/GridColumnMoveMouseHandler';
|
|
14
14
|
import { EditingCell, GridRenderState, EditingCellTextSelectionRange } from './GridRendererTypes';
|
|
15
15
|
export type GridProps = typeof Grid.defaultProps & {
|
|
16
|
+
children?: ReactNode;
|
|
16
17
|
canvasOptions?: CanvasRenderingContext2DSettings;
|
|
17
18
|
isStickyBottom?: boolean;
|
|
18
19
|
isStickyRight?: boolean;
|
|
@@ -202,6 +203,8 @@ declare class Grid extends PureComponent<GridProps, GridState> {
|
|
|
202
203
|
metricCalculator: GridMetricCalculator;
|
|
203
204
|
canvas: HTMLCanvasElement | null;
|
|
204
205
|
canvasContext: CanvasRenderingContext2D | null;
|
|
206
|
+
canvasWrapper: RefObject<HTMLDivElement>;
|
|
207
|
+
resizeObserver: ResizeObserver;
|
|
205
208
|
animationFrame: number | null;
|
|
206
209
|
prevMetrics: GridMetrics | null;
|
|
207
210
|
metrics: GridMetrics | null;
|
package/dist/Grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../src/Grid.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../src/Grid.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,aAAa,EACb,SAAS,EACT,SAAS,EACV,MAAM,OAAO,CAAC;AAKf,OAAO,oBAAoB,EAAE,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,gBAAgB,EAAE,EACvB,cAAc,EACd,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAkB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,SAAS,EAAE,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAkB,EAAE,SAAS,EAAe,KAAK,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAWL,aAAa,EAEd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAS7D,OAAO,WAAW,EAAE,EAClB,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACb,MAAM,eAAe,CAAC;AAUv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c7C;;;;;;OAMG;IACH,mBAAmB,CACjB,YAAY,EAAE,4BAA4B,EAC1C,KAAK,EAAE,cAAc,EACrB,iBAAiB,UAAO,EACxB,mBAAmB,UAAQ,GAC1B,IAAI;IAiCP,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI;IAa9C,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI;IAIhD,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI;IAI9C,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI;IAK/C,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAOxC,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAetC,YAAY,IAAI,IAAI;IAepB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAuLpC;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;;OAGG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAiBzC;;;;OAIG;IACH,oBAAoB,CAClB,KAAK,EAAE,MAAM,EACb,EACE,SAAoC,EACpC,SAAiB,GAClB,GAAE;QAAE,SAAS,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAO,GACtE,IAAI;IA6BP,gBAAgB,IAAI,SAAS;IA8D7B;;;OAGG;IACH,iBAAiB,IAAI,eAAe;IAwDpC,MAAM,IAAI,SAAS;CA2BpB;AAED,eAAe,IAAI,CAAC"}
|
package/dist/Grid.js
CHANGED
|
@@ -26,7 +26,6 @@ import { assertIsEditableGridModel, isEditableGridModel } from "./EditableGridMo
|
|
|
26
26
|
import { assertIsDefined } from "./errors/index.js";
|
|
27
27
|
import ThemeContext from "./ThemeContext.js";
|
|
28
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
29
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
30
29
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
30
|
/**
|
|
32
31
|
* High performance, extendible, themeable grid component.
|
|
@@ -73,7 +72,9 @@ class Grid extends PureComponent {
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
// Need to disable react/sort-comp so I can put the fields here
|
|
76
|
-
/* eslint-disable react/sort-comp */ //
|
|
75
|
+
/* eslint-disable react/sort-comp */ // The wrapper element for the canvas, used for sizing
|
|
76
|
+
// Listen for resizing of the element and update the canvas appropriately
|
|
77
|
+
// We draw the canvas on the next animation frame, keep track of the next one
|
|
77
78
|
// Keep track of previous metrics and new metrics for comparison
|
|
78
79
|
// Track the cursor that is currently added to the document
|
|
79
80
|
// Add to document so that when dragging the cursor stays, even if mouse leaves the canvas
|
|
@@ -87,6 +88,8 @@ class Grid extends PureComponent {
|
|
|
87
88
|
_defineProperty(this, "metricCalculator", void 0);
|
|
88
89
|
_defineProperty(this, "canvas", void 0);
|
|
89
90
|
_defineProperty(this, "canvasContext", void 0);
|
|
91
|
+
_defineProperty(this, "canvasWrapper", void 0);
|
|
92
|
+
_defineProperty(this, "resizeObserver", void 0);
|
|
90
93
|
_defineProperty(this, "animationFrame", void 0);
|
|
91
94
|
_defineProperty(this, "prevMetrics", void 0);
|
|
92
95
|
_defineProperty(this, "metrics", void 0);
|
|
@@ -123,6 +126,8 @@ class Grid extends PureComponent {
|
|
|
123
126
|
this.metricCalculator = metricCalculator || new GridMetricCalculator();
|
|
124
127
|
this.canvas = null;
|
|
125
128
|
this.canvasContext = null;
|
|
129
|
+
this.canvasWrapper = /*#__PURE__*/React.createRef();
|
|
130
|
+
this.resizeObserver = new window.ResizeObserver(this.handleResize);
|
|
126
131
|
this.animationFrame = null;
|
|
127
132
|
this.prevMetrics = null;
|
|
128
133
|
this.metrics = null;
|
|
@@ -195,7 +200,9 @@ class Grid extends PureComponent {
|
|
|
195
200
|
(_this$canvas = this.canvas) === null || _this$canvas === void 0 ? void 0 : _this$canvas.addEventListener('wheel', this.handleWheel, {
|
|
196
201
|
passive: false
|
|
197
202
|
});
|
|
198
|
-
|
|
203
|
+
if (this.canvasWrapper.current != null) {
|
|
204
|
+
this.resizeObserver.observe(this.canvasWrapper.current);
|
|
205
|
+
}
|
|
199
206
|
this.updateCanvas();
|
|
200
207
|
|
|
201
208
|
// apply on mount, so that it works with a static model
|
|
@@ -285,7 +292,7 @@ class Grid extends PureComponent {
|
|
|
285
292
|
(_this$canvas2 = this.canvas) === null || _this$canvas2 === void 0 ? void 0 : _this$canvas2.removeEventListener('wheel', this.handleWheel);
|
|
286
293
|
window.removeEventListener('mousemove', this.handleMouseDrag, true);
|
|
287
294
|
window.removeEventListener('mouseup', this.handleMouseUp, true);
|
|
288
|
-
|
|
295
|
+
this.resizeObserver.disconnect();
|
|
289
296
|
this.stopDragTimer();
|
|
290
297
|
}
|
|
291
298
|
getTheme() {
|
|
@@ -531,17 +538,18 @@ class Grid extends PureComponent {
|
|
|
531
538
|
updateCanvasScale() {
|
|
532
539
|
var {
|
|
533
540
|
canvas,
|
|
534
|
-
canvasContext
|
|
541
|
+
canvasContext,
|
|
542
|
+
canvasWrapper
|
|
535
543
|
} = this;
|
|
536
544
|
if (!canvas) throw new Error('canvas not set');
|
|
537
545
|
if (!canvasContext) throw new Error('canvasContext not set');
|
|
538
|
-
if (!
|
|
546
|
+
if (!canvasWrapper.current) throw new Error('canvasWrapper not set');
|
|
539
547
|
var scale = Grid.getScale(canvasContext);
|
|
540
548
|
// the parent wrapper has 100% width/height, and is used for determining size
|
|
541
549
|
// we don't want to stretch the canvas to 100%, to avoid fractional pixels.
|
|
542
550
|
// A wrapper element must be used for sizing, and canvas size must be
|
|
543
551
|
// set manually to a floored value in css and a scaled value in width/height
|
|
544
|
-
var rect =
|
|
552
|
+
var rect = canvasWrapper.current.getBoundingClientRect();
|
|
545
553
|
var width = Math.floor(rect.width);
|
|
546
554
|
var height = Math.floor(rect.height);
|
|
547
555
|
canvas.style.width = "".concat(width, "px");
|
|
@@ -1898,10 +1906,15 @@ class Grid extends PureComponent {
|
|
|
1898
1906
|
return this.renderState;
|
|
1899
1907
|
}
|
|
1900
1908
|
render() {
|
|
1909
|
+
var {
|
|
1910
|
+
children
|
|
1911
|
+
} = this.props;
|
|
1901
1912
|
var {
|
|
1902
1913
|
cursor
|
|
1903
1914
|
} = this.state;
|
|
1904
|
-
return /*#__PURE__*/_jsxs(
|
|
1915
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
1916
|
+
className: "grid-wrapper",
|
|
1917
|
+
ref: this.canvasWrapper,
|
|
1905
1918
|
children: [/*#__PURE__*/_jsx("canvas", {
|
|
1906
1919
|
className: classNames('grid-canvas', Grid.getCursorClassName(cursor)),
|
|
1907
1920
|
ref: canvas => {
|
|
@@ -1916,7 +1929,7 @@ class Grid extends PureComponent {
|
|
|
1916
1929
|
onMouseLeave: this.handleMouseLeave,
|
|
1917
1930
|
tabIndex: 0,
|
|
1918
1931
|
children: "Your browser does not support HTML canvas. Update your browser?"
|
|
1919
|
-
}), this.renderInputField()]
|
|
1932
|
+
}), this.renderInputField(), children]
|
|
1920
1933
|
});
|
|
1921
1934
|
}
|
|
1922
1935
|
}
|