@deephaven/grid 0.6.3-beta.9 → 0.6.3
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/CellInputField.js +1 -1
- package/dist/CellInputField.js.map +1 -1
- package/dist/Grid.d.ts +13 -3
- package/dist/Grid.d.ts.map +1 -1
- package/dist/Grid.js +2 -2
- package/dist/GridMetricCalculator.d.ts +165 -448
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +122 -521
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridRange.d.ts +111 -186
- package/dist/GridRange.d.ts.map +1 -1
- package/dist/GridRange.js +87 -185
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +1 -6
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTheme.d.ts +37 -49
- package/dist/GridTheme.d.ts.map +1 -1
- package/dist/GridTheme.js +0 -8
- package/dist/GridTheme.js.map +1 -1
- package/dist/GridUtils.d.ts +97 -236
- package/dist/GridUtils.d.ts.map +1 -1
- package/dist/GridUtils.js +76 -241
- package/dist/GridUtils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +4 -4
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/GridMetrics.d.ts +0 -97
- package/dist/GridMetrics.d.ts.map +0 -1
- package/dist/GridMetrics.js +0 -2
- package/dist/GridMetrics.js.map +0 -1
package/dist/GridRange.js
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
2
|
|
|
3
|
-
// Also exported via GridRange.SELECTION_DIRECTION
|
|
4
|
-
export var SELECTION_DIRECTION;
|
|
5
|
-
|
|
6
|
-
(function (SELECTION_DIRECTION) {
|
|
7
|
-
SELECTION_DIRECTION["DOWN"] = "DOWN";
|
|
8
|
-
SELECTION_DIRECTION["UP"] = "UP";
|
|
9
|
-
SELECTION_DIRECTION["LEFT"] = "LEFT";
|
|
10
|
-
SELECTION_DIRECTION["RIGHT"] = "RIGHT";
|
|
11
|
-
})(SELECTION_DIRECTION || (SELECTION_DIRECTION = {}));
|
|
12
|
-
|
|
13
3
|
class GridRange {
|
|
14
|
-
/**
|
|
15
|
-
* Returns a normalized array of indexes ensuring left <= right and top <= bottom
|
|
16
|
-
* @param startColumn Start column index
|
|
17
|
-
* @param startRow Start row index
|
|
18
|
-
* @param endColumn End column index
|
|
19
|
-
* @param endRow End row index
|
|
20
|
-
* @returns Array containing normalized indexes [left, top, right, bottom]
|
|
21
|
-
*/
|
|
22
4
|
static normalize(startColumn, startRow, endColumn, endRow) {
|
|
23
5
|
var left = startColumn;
|
|
24
6
|
var top = startRow;
|
|
@@ -37,84 +19,43 @@ class GridRange {
|
|
|
37
19
|
|
|
38
20
|
return [left, top, right, bottom];
|
|
39
21
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Makes a GridRange ensuring startColumn <= endColumn, startRow <= endRow
|
|
42
|
-
* @param startColumn Start column index
|
|
43
|
-
* @param startRow Start row index
|
|
44
|
-
* @param endColumn End column index
|
|
45
|
-
* @param endRow End row index
|
|
46
|
-
* @returns Normalized GridRange
|
|
47
|
-
*/
|
|
22
|
+
/** Make a GridRange, but ensure startColumn <= endColumn, startRow <= endRow */
|
|
48
23
|
|
|
49
24
|
|
|
50
|
-
static makeNormalized(
|
|
51
|
-
return new GridRange(...GridRange.normalize(
|
|
25
|
+
static makeNormalized() {
|
|
26
|
+
return new GridRange(...GridRange.normalize(...arguments));
|
|
52
27
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Creates a GridRange representing a single cell
|
|
55
|
-
* @param column Column index
|
|
56
|
-
* @param row Row index
|
|
57
|
-
* @returns GridRange representing the cell
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
28
|
|
|
61
29
|
static makeCell(column, row) {
|
|
62
30
|
return new GridRange(column, row, column, row);
|
|
63
31
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Creates a GridRange representing an infinite length column
|
|
66
|
-
* @param column Column index
|
|
67
|
-
* @returns GridRange representing the column
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
32
|
|
|
71
33
|
static makeColumn(column) {
|
|
72
34
|
return new GridRange(column, null, column, null);
|
|
73
35
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Creates a GridRange representing an infinite length row
|
|
76
|
-
* @param row Row index
|
|
77
|
-
* @returns GridRange representing the row
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
36
|
|
|
81
37
|
static makeRow(row) {
|
|
82
38
|
return new GridRange(null, row, null, row);
|
|
83
39
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Returns the minimum value between 2 range indexes or null if at least 1 is null
|
|
86
|
-
* @param index1 First grid range index
|
|
87
|
-
* @param index2 Second grid range index
|
|
88
|
-
* @returns Minimum index or null if either index is null
|
|
89
|
-
*/
|
|
90
40
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (index1 == null || index2 == null) {
|
|
41
|
+
static minOrNull(value1, value2) {
|
|
42
|
+
if (value1 == null || value2 == null) {
|
|
94
43
|
return null;
|
|
95
44
|
}
|
|
96
45
|
|
|
97
|
-
return Math.min(
|
|
46
|
+
return Math.min(value1, value2);
|
|
98
47
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Returns the maximum value between 2 range indexes or null if at least 1 is null
|
|
101
|
-
* @param index1 First grid range index
|
|
102
|
-
* @param index2 Second grid range index
|
|
103
|
-
* @returns Maximum index or null if either index is null
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
48
|
|
|
107
|
-
static maxOrNull(
|
|
108
|
-
if (
|
|
49
|
+
static maxOrNull(value1, value2) {
|
|
50
|
+
if (value1 == null || value2 == null) {
|
|
109
51
|
return null;
|
|
110
52
|
}
|
|
111
53
|
|
|
112
|
-
return Math.max(
|
|
54
|
+
return Math.max(value1, value2);
|
|
113
55
|
}
|
|
114
56
|
/**
|
|
115
57
|
* Consolidate the passed in ranges to the minimum set, merging overlapping ranges.
|
|
116
|
-
* @param ranges The ranges to consolidate
|
|
117
|
-
* @returns Consolidated ranges
|
|
58
|
+
* @param {[GridRange]} ranges The ranges to consolidate
|
|
118
59
|
*/
|
|
119
60
|
|
|
120
61
|
|
|
@@ -176,65 +117,46 @@ class GridRange {
|
|
|
176
117
|
|
|
177
118
|
return result;
|
|
178
119
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Checks if the 1-D ranges between 2 index pairs overlap or are continuous.
|
|
181
|
-
* For example ranges [0, 1] and [2, 3] are continuous and will return true.
|
|
182
|
-
* [0, 1] and [1, 3] overlap and return true.
|
|
183
|
-
* [0, 1] and [3, 4] do not overlap and have a gap so this will return false.
|
|
184
|
-
* @param start1 Start of 1st range
|
|
185
|
-
* @param end1 End of 1st range
|
|
186
|
-
* @param start2 Start of 2nd range
|
|
187
|
-
* @param end2 End of 2nd range
|
|
188
|
-
* @returns True if the ranges overlap or touch, else false
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
120
|
|
|
192
|
-
static isAxisRangeTouching(
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
121
|
+
static isAxisRangeTouching(start, end, otherStart, otherEnd) {
|
|
122
|
+
if (start == null) {
|
|
123
|
+
if (end == null) {
|
|
195
124
|
return true;
|
|
196
125
|
}
|
|
197
126
|
|
|
198
|
-
if (
|
|
127
|
+
if (otherStart == null) {
|
|
199
128
|
return true;
|
|
200
129
|
}
|
|
201
130
|
|
|
202
|
-
return
|
|
131
|
+
return otherStart <= end + 1;
|
|
203
132
|
}
|
|
204
133
|
|
|
205
|
-
if (
|
|
206
|
-
if (
|
|
134
|
+
if (end == null) {
|
|
135
|
+
if (otherEnd == null) {
|
|
207
136
|
return true;
|
|
208
137
|
}
|
|
209
138
|
|
|
210
|
-
return
|
|
139
|
+
return otherEnd >= start - 1;
|
|
211
140
|
}
|
|
212
141
|
|
|
213
|
-
if (
|
|
214
|
-
if (
|
|
142
|
+
if (otherStart == null) {
|
|
143
|
+
if (otherEnd == null) {
|
|
215
144
|
return true;
|
|
216
145
|
}
|
|
217
146
|
|
|
218
|
-
return
|
|
147
|
+
return start <= otherEnd + 1;
|
|
219
148
|
}
|
|
220
149
|
|
|
221
|
-
if (
|
|
222
|
-
return
|
|
150
|
+
if (otherEnd == null) {
|
|
151
|
+
return end >= otherStart - 1;
|
|
223
152
|
}
|
|
224
153
|
|
|
225
|
-
if (
|
|
226
|
-
return
|
|
154
|
+
if (otherStart >= start - 1) {
|
|
155
|
+
return otherStart <= end + 1;
|
|
227
156
|
}
|
|
228
157
|
|
|
229
|
-
return
|
|
158
|
+
return otherEnd >= start - 1;
|
|
230
159
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Checks if 2 arrays of ranges are the same ranges
|
|
233
|
-
* @param ranges1 First array of ranges
|
|
234
|
-
* @param ranges2 Second array of ranges
|
|
235
|
-
* @returns True if the arrays contain the same ranges in the same order
|
|
236
|
-
*/
|
|
237
|
-
|
|
238
160
|
|
|
239
161
|
static rangeArraysEqual(ranges1, ranges2) {
|
|
240
162
|
if (ranges1 === ranges2) {
|
|
@@ -255,14 +177,14 @@ class GridRange {
|
|
|
255
177
|
}
|
|
256
178
|
/**
|
|
257
179
|
* Get the intersection (overlapping area) of two ranges
|
|
258
|
-
* @param range One range to check for the intersection
|
|
259
|
-
* @param otherRange The other range to check for the intersection
|
|
260
|
-
* @returns Intersection of the two ranges. If they do not intersect, returns `null`.
|
|
180
|
+
* @param {GridRange} range One range to check for the intersection
|
|
181
|
+
* @param {GridRange} otherRange The other range to check for the intersection
|
|
182
|
+
* @returns {GridRange|null} Intersection of the two ranges. If they do not intersect, returns `null`.
|
|
261
183
|
*/
|
|
262
184
|
|
|
263
185
|
|
|
264
186
|
static intersection(range, otherRange) {
|
|
265
|
-
var _startColumn2, _endColumn2, _startRow2, _endRow2
|
|
187
|
+
var _startColumn2, _endColumn2, _startRow2, _endRow2;
|
|
266
188
|
|
|
267
189
|
if (range.equals(otherRange)) {
|
|
268
190
|
return range;
|
|
@@ -279,17 +201,16 @@ class GridRange {
|
|
|
279
201
|
startRow = startRow != null && otherRange.startRow != null ? Math.max(startRow, otherRange.startRow) : (_startRow2 = startRow) !== null && _startRow2 !== void 0 ? _startRow2 : otherRange.startRow;
|
|
280
202
|
endRow = endRow != null && otherRange.endRow != null ? Math.min(endRow, otherRange.endRow) : (_endRow2 = endRow) !== null && _endRow2 !== void 0 ? _endRow2 : otherRange.endRow;
|
|
281
203
|
|
|
282
|
-
if (startColumn != null && startColumn >
|
|
204
|
+
if (startColumn != null && startColumn > endColumn || startRow != null && startRow > endRow) {
|
|
283
205
|
return null;
|
|
284
206
|
}
|
|
285
207
|
|
|
286
208
|
return new GridRange(startColumn, startRow, endColumn, endRow);
|
|
287
209
|
}
|
|
288
210
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @param
|
|
291
|
-
* @
|
|
292
|
-
* @returns The ranges needed to represent the remaining
|
|
211
|
+
* @param {GridRange} range The range to be subtracted from
|
|
212
|
+
* @param {GridRange} subtractRange The range to subtract from within this range
|
|
213
|
+
* @returns {GridRange[]} The ranges needed to represent the remaining
|
|
293
214
|
*/
|
|
294
215
|
|
|
295
216
|
|
|
@@ -327,9 +248,9 @@ class GridRange {
|
|
|
327
248
|
}
|
|
328
249
|
/**
|
|
329
250
|
* Subtract a range from multiple ranges
|
|
330
|
-
* @param ranges The ranges to be subtracted from
|
|
331
|
-
* @param subtractRange The range to subtract from within these ranges
|
|
332
|
-
* @returns The ranges needed to represent the remaining
|
|
251
|
+
* @param {GridRange[]} ranges The ranges to be subtracted from
|
|
252
|
+
* @param {GridRange} subtractRange The range to subtract from within these ranges
|
|
253
|
+
* @returns {GridRange[]} The ranges needed to represent the remaining
|
|
333
254
|
*/
|
|
334
255
|
|
|
335
256
|
|
|
@@ -344,9 +265,9 @@ class GridRange {
|
|
|
344
265
|
}
|
|
345
266
|
/**
|
|
346
267
|
* Subtract multiple ranges from multiple ranges
|
|
347
|
-
* @param ranges The ranges to be subtracted from
|
|
348
|
-
* @param subtractRanges The ranges to subtract from within these ranges
|
|
349
|
-
* @returns The ranges needed to represent the remaining
|
|
268
|
+
* @param {GridRange[]} ranges The ranges to be subtracted from
|
|
269
|
+
* @param {GridRange[]} subtractRanges The ranges to subtract from within these ranges
|
|
270
|
+
* @returns {GridRange[]} The ranges needed to represent the remaining
|
|
350
271
|
*/
|
|
351
272
|
|
|
352
273
|
|
|
@@ -365,8 +286,8 @@ class GridRange {
|
|
|
365
286
|
}
|
|
366
287
|
/**
|
|
367
288
|
* Test if a given range is bounded (all values are non-null)
|
|
368
|
-
* @param range The range to test
|
|
369
|
-
* @returns True if this range is bounded, false otherwise
|
|
289
|
+
* @param {GridRange} range The range to test
|
|
290
|
+
* @returns {boolean} True if this range is bounded, false otherwise
|
|
370
291
|
*/
|
|
371
292
|
|
|
372
293
|
|
|
@@ -377,10 +298,10 @@ class GridRange {
|
|
|
377
298
|
* Converts any GridRange passed in that is a full row or column selection to be bound
|
|
378
299
|
* to the `columnCount` and `rowCount` passed in
|
|
379
300
|
*
|
|
380
|
-
* @param range The range to get the bounded range of
|
|
381
|
-
* @param columnCount The number of columns
|
|
382
|
-
* @param rowCount The number of rows
|
|
383
|
-
* @returns The passed in GridRange with any null values filled in
|
|
301
|
+
* @param {GridRange} range The range to get the bounded range of
|
|
302
|
+
* @param {number} columnCount The number of columns
|
|
303
|
+
* @param {number} rowCount The number of rows
|
|
304
|
+
* @returns {GridRange} The passed in GridRange with any null values filled in
|
|
384
305
|
*/
|
|
385
306
|
|
|
386
307
|
|
|
@@ -396,10 +317,10 @@ class GridRange {
|
|
|
396
317
|
/**
|
|
397
318
|
* Converts the GridRanges passed in to be bound to the `columnCount` and `rowCount` passed in
|
|
398
319
|
*
|
|
399
|
-
* @param ranges The ranges to get the bounded ranges of
|
|
400
|
-
* @param columnCount The number of columns
|
|
401
|
-
* @param rowCount The number of rows
|
|
402
|
-
* @returns The passed in GridRange with any null values filled in
|
|
320
|
+
* @param {GridRange[]} ranges The ranges to get the bounded ranges of
|
|
321
|
+
* @param {number} columnCount The number of columns
|
|
322
|
+
* @param {number} rowCount The number of rows
|
|
323
|
+
* @returns {GridRange} The passed in GridRange with any null values filled in
|
|
403
324
|
*/
|
|
404
325
|
|
|
405
326
|
|
|
@@ -409,10 +330,10 @@ class GridRange {
|
|
|
409
330
|
/**
|
|
410
331
|
* Offsets a GridRange by the specified amount in the x and y directions
|
|
411
332
|
*
|
|
412
|
-
* @param range The range to offset
|
|
413
|
-
* @param columnOffset The number of columns to offset
|
|
414
|
-
* @param rowOffset The number of rows to offset
|
|
415
|
-
* @returns The new grid range offset from the original
|
|
333
|
+
* @param {GridRange} range The range to offset
|
|
334
|
+
* @param {number} columnOffset The number of columns to offset
|
|
335
|
+
* @param {number} rowOffset The number of rows to offset
|
|
336
|
+
* @returns {GridRange} The new grid range offset from the original
|
|
416
337
|
*/
|
|
417
338
|
|
|
418
339
|
|
|
@@ -421,11 +342,11 @@ class GridRange {
|
|
|
421
342
|
}
|
|
422
343
|
/**
|
|
423
344
|
* Get the next cell given the selected ranges and the current cell
|
|
424
|
-
* @param ranges The selected bounded ranges within the grid
|
|
425
|
-
* @param column The cursor column, or null if none focused
|
|
426
|
-
* @param row The cursor row, or null if none focused
|
|
427
|
-
* @param direction The direction in which to select next
|
|
428
|
-
* @returns The next cell to focus, or null if there should be no more focus
|
|
345
|
+
* @param {GridRange[]} ranges The selected bounded ranges within the grid
|
|
346
|
+
* @param {number|null} column The cursor column, or null if none focused
|
|
347
|
+
* @param {number|null} row The cursor row, or null if none focused
|
|
348
|
+
* @param {SELECTION_DIRECTION} direction The direction in which to select next
|
|
349
|
+
* @returns {Cell} The next cell to focus, or null if there should be no more focus
|
|
429
350
|
*/
|
|
430
351
|
|
|
431
352
|
|
|
@@ -478,8 +399,8 @@ class GridRange {
|
|
|
478
399
|
}
|
|
479
400
|
/**
|
|
480
401
|
* Count the number of cells in the provided grid ranges
|
|
481
|
-
* @param ranges The ranges to count the rows of
|
|
482
|
-
* @returns The number of cells in the ranges, or `NaN` if any of the ranges were unbounded
|
|
402
|
+
* @param {GridRange[]} ranges The ranges to count the rows of
|
|
403
|
+
* @returns {number|NaN} The number of cells in the ranges, or `NaN` if any of the ranges were unbounded
|
|
483
404
|
*/
|
|
484
405
|
|
|
485
406
|
|
|
@@ -492,8 +413,8 @@ class GridRange {
|
|
|
492
413
|
}
|
|
493
414
|
/**
|
|
494
415
|
* Count the number of rows in the provided grid ranges
|
|
495
|
-
* @param ranges The ranges to count the rows of
|
|
496
|
-
* @returns The number of rows in the ranges, or `NaN` if any of the ranges were unbounded
|
|
416
|
+
* @param {GridRange[]} ranges The ranges to count the rows of
|
|
417
|
+
* @returns {number|NaN} The number of rows in the ranges, or `NaN` if any of the ranges were unbounded
|
|
497
418
|
*/
|
|
498
419
|
|
|
499
420
|
|
|
@@ -506,8 +427,8 @@ class GridRange {
|
|
|
506
427
|
}
|
|
507
428
|
/**
|
|
508
429
|
* Count the number of columns in the provided grid ranges
|
|
509
|
-
* @param ranges The ranges to count the columns of
|
|
510
|
-
* @returns The number of columns in the ranges, or `NaN` if any of the ranges were unbounded
|
|
430
|
+
* @param {GridRange[]} ranges The ranges to count the columns of
|
|
431
|
+
* @returns {number|NaN} The number of columns in the ranges, or `NaN` if any of the ranges were unbounded
|
|
511
432
|
*/
|
|
512
433
|
|
|
513
434
|
|
|
@@ -520,10 +441,10 @@ class GridRange {
|
|
|
520
441
|
}
|
|
521
442
|
/**
|
|
522
443
|
* Check if the provided ranges contain the provided cell
|
|
523
|
-
* @param ranges The ranges to check
|
|
524
|
-
* @param column The column index
|
|
525
|
-
* @param row The row index
|
|
526
|
-
* @returns True if the cell is within the provided ranges, false otherwise.
|
|
444
|
+
* @param {GridRange[]} ranges The ranges to check
|
|
445
|
+
* @param {number} column The column index
|
|
446
|
+
* @param {number} row The row index
|
|
447
|
+
* @returns {boolean} True if the cell is within the provided ranges, false otherwise.
|
|
527
448
|
*/
|
|
528
449
|
|
|
529
450
|
|
|
@@ -540,7 +461,7 @@ class GridRange {
|
|
|
540
461
|
}
|
|
541
462
|
/**
|
|
542
463
|
* Iterate through each cell in the provided ranges
|
|
543
|
-
* @param ranges The ranges to iterate through
|
|
464
|
+
* @param {GridRange[]} ranges The ranges to iterate through
|
|
544
465
|
* @param {(column: number, row: number, index: number) => void} callback The callback to execute. `index` is the index within that range
|
|
545
466
|
* @param {GridRange.SELECTION_DIRECTION} direction The direction to iterate in
|
|
546
467
|
*/
|
|
@@ -555,34 +476,16 @@ class GridRange {
|
|
|
555
476
|
}
|
|
556
477
|
|
|
557
478
|
constructor(startColumn, startRow, endColumn, endRow) {
|
|
558
|
-
_defineProperty(this, "startColumn", void 0);
|
|
559
|
-
|
|
560
|
-
_defineProperty(this, "startRow", void 0);
|
|
561
|
-
|
|
562
|
-
_defineProperty(this, "endColumn", void 0);
|
|
563
|
-
|
|
564
|
-
_defineProperty(this, "endRow", void 0);
|
|
565
|
-
|
|
566
479
|
this.startColumn = startColumn;
|
|
567
480
|
this.startRow = startRow;
|
|
568
481
|
this.endColumn = endColumn;
|
|
569
482
|
this.endRow = endRow;
|
|
570
483
|
}
|
|
571
|
-
/**
|
|
572
|
-
* Checks if the provided range is equivalent to this range (same start and end column/row indexes)
|
|
573
|
-
* @param other Grid range to check against
|
|
574
|
-
* @returns True if the ranges cover the same area
|
|
575
|
-
*/
|
|
576
|
-
|
|
577
484
|
|
|
578
485
|
equals(other) {
|
|
579
486
|
return this.startColumn === other.startColumn && this.startRow === other.startRow && this.endColumn === other.endColumn && this.endRow === other.endRow;
|
|
580
487
|
}
|
|
581
|
-
/**
|
|
582
|
-
* Checks if this GridRange contains another range
|
|
583
|
-
* @param other The range to check
|
|
584
|
-
* @returns True if this GridRange completely contains `other`
|
|
585
|
-
* */
|
|
488
|
+
/** @returns {boolean} true if this GridRange completely contains `other` */
|
|
586
489
|
|
|
587
490
|
|
|
588
491
|
contains(other) {
|
|
@@ -590,9 +493,9 @@ class GridRange {
|
|
|
590
493
|
}
|
|
591
494
|
/**
|
|
592
495
|
* Check if the provided cell is in this range
|
|
593
|
-
* @param column The column to check
|
|
594
|
-
* @param row The row to check
|
|
595
|
-
* @returns True if this cell is within this range
|
|
496
|
+
* @param {number} column The column to check
|
|
497
|
+
* @param {number} row The row to check
|
|
498
|
+
* @returns {boolean} True if this cell is within this range
|
|
596
499
|
*/
|
|
597
500
|
|
|
598
501
|
|
|
@@ -603,21 +506,15 @@ class GridRange {
|
|
|
603
506
|
|
|
604
507
|
return (this.startColumn == null || this.startColumn <= column) && (this.endColumn == null || this.endColumn >= column) && (this.startRow == null || this.startRow <= row) && (this.endRow == null || this.endRow >= row);
|
|
605
508
|
}
|
|
606
|
-
/**
|
|
607
|
-
* Check if the provided range touches (or overlaps) this GridRange
|
|
608
|
-
* Effectively checks if the 2 ranges could be represented by 1 continuous range
|
|
609
|
-
* @param other The range to check
|
|
610
|
-
* @returns True if this GridRange touches `other`
|
|
611
|
-
* */
|
|
509
|
+
/** @returns {boolean} true if this GridRange touches `other` */
|
|
612
510
|
|
|
613
511
|
|
|
614
512
|
touches(other) {
|
|
615
513
|
return GridRange.isAxisRangeTouching(this.startRow, this.endRow, other.startRow, other.endRow) && GridRange.isAxisRangeTouching(this.startColumn, this.endColumn, other.startColumn, other.endColumn);
|
|
616
514
|
}
|
|
617
515
|
/**
|
|
618
|
-
*
|
|
619
|
-
* @
|
|
620
|
-
* @returns The ranges needed to represent the remaining
|
|
516
|
+
* @param {GridRange} other The range to deselect from within this range
|
|
517
|
+
* @returns {[GridRange]} The ranges needed to represent the remaining
|
|
621
518
|
*/
|
|
622
519
|
|
|
623
520
|
|
|
@@ -627,8 +524,8 @@ class GridRange {
|
|
|
627
524
|
/**
|
|
628
525
|
* Get the first cell in this range. Throws if this range is unbounded.
|
|
629
526
|
*
|
|
630
|
-
* @param direction The direction to get the starting cell in. Defaults to DOWN
|
|
631
|
-
* @returns The first cell in this range in the direction specified
|
|
527
|
+
* @param {GridRange.SELECTION_DIRECTION?} direction The direction to get the starting cell in. Defaults to DOWN
|
|
528
|
+
* @returns {{column: number, row: number}} The first cell in this range in the direction specified
|
|
632
529
|
*/
|
|
633
530
|
|
|
634
531
|
|
|
@@ -766,8 +663,8 @@ class GridRange {
|
|
|
766
663
|
}
|
|
767
664
|
/**
|
|
768
665
|
* Iterate through each cell in the range
|
|
769
|
-
* @param callback Callback to execute. `index` is the index within this range
|
|
770
|
-
* @param direction The direction to iterate in
|
|
666
|
+
* @param {(column:number, row:number, index:number) => void} callback Callback to execute. `index` is the index within this range
|
|
667
|
+
* @param {GridRange.SELECTION_DIRECTION} direction The direction to iterate in
|
|
771
668
|
*/
|
|
772
669
|
|
|
773
670
|
|
|
@@ -793,7 +690,12 @@ class GridRange {
|
|
|
793
690
|
|
|
794
691
|
}
|
|
795
692
|
|
|
796
|
-
_defineProperty(GridRange, "SELECTION_DIRECTION",
|
|
693
|
+
_defineProperty(GridRange, "SELECTION_DIRECTION", Object.freeze({
|
|
694
|
+
DOWN: 'DOWN',
|
|
695
|
+
UP: 'UP',
|
|
696
|
+
LEFT: 'LEFT',
|
|
697
|
+
RIGHT: 'RIGHT'
|
|
698
|
+
}));
|
|
797
699
|
|
|
798
700
|
export default GridRange;
|
|
799
701
|
//# sourceMappingURL=GridRange.js.map
|