@deephaven/grid 0.5.2-beta.0 → 0.6.1-demo.8
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 +40 -88
- package/dist/CellInputField.js.map +1 -1
- package/dist/Grid.js +1449 -1484
- package/dist/Grid.js.map +1 -1
- package/dist/GridColorUtils.js +18 -51
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.d.ts +8 -1
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +1031 -994
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.d.ts +4 -1
- package/dist/GridModel.d.ts.map +1 -1
- package/dist/GridModel.js +175 -286
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.js +39 -59
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.js +572 -630
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +1650 -1564
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTestUtils.js +15 -29
- package/dist/GridTestUtils.js.map +1 -1
- package/dist/GridUtils.js +679 -717
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.js +6 -18
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridModel.js +105 -210
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.js +113 -183
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/errors/PasteError.js +5 -44
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +42 -75
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +42 -78
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +239 -229
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +42 -72
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js +4 -4
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -1
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +18 -50
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +141 -163
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +47 -86
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +145 -171
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +125 -147
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +47 -86
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +46 -76
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +31 -62
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +200 -222
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +206 -253
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +146 -172
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.js +10 -10
- package/dist/mouse-handlers/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -10
|
@@ -1,321 +1,274 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
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; }
|
|
24
2
|
|
|
25
3
|
/* eslint class-methods-use-this: "off" */
|
|
26
4
|
|
|
27
5
|
/* eslint no-unused-vars: "off" */
|
|
28
|
-
import GridMouseHandler from
|
|
6
|
+
import GridMouseHandler from "../GridMouseHandler.js";
|
|
29
7
|
var OVERRIDE_STRING = 'NEED_TO_OVERRIDE_PROPERTY';
|
|
30
8
|
/**
|
|
31
9
|
* Abstract class that should be extended for column/row behaviour
|
|
32
10
|
* Override the necessary functions/properties
|
|
33
11
|
*/
|
|
34
12
|
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
class GridSeparatorMouseHandler extends GridMouseHandler {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
37
16
|
|
|
38
|
-
|
|
17
|
+
_defineProperty(this, "draggingIndex", null);
|
|
39
18
|
|
|
40
|
-
|
|
41
|
-
var _this;
|
|
19
|
+
_defineProperty(this, "resizingItems", []);
|
|
42
20
|
|
|
43
|
-
|
|
21
|
+
_defineProperty(this, "hiddenItems", []);
|
|
44
22
|
|
|
45
|
-
|
|
46
|
-
args[_key] = arguments[_key];
|
|
47
|
-
}
|
|
23
|
+
_defineProperty(this, "targetSizes", new Map());
|
|
48
24
|
|
|
49
|
-
|
|
25
|
+
_defineProperty(this, "dragOffset", 0);
|
|
50
26
|
|
|
51
|
-
_defineProperty(
|
|
27
|
+
_defineProperty(this, "cursor", OVERRIDE_STRING);
|
|
52
28
|
|
|
53
|
-
_defineProperty(
|
|
29
|
+
_defineProperty(this, "hiddenCursor", OVERRIDE_STRING);
|
|
54
30
|
|
|
55
|
-
_defineProperty(
|
|
31
|
+
_defineProperty(this, "defaultCursor", OVERRIDE_STRING);
|
|
56
32
|
|
|
57
|
-
_defineProperty(
|
|
33
|
+
_defineProperty(this, "pointProperty", OVERRIDE_STRING);
|
|
58
34
|
|
|
59
|
-
_defineProperty(
|
|
35
|
+
_defineProperty(this, "userSizesProperty", OVERRIDE_STRING);
|
|
60
36
|
|
|
61
|
-
_defineProperty(
|
|
37
|
+
_defineProperty(this, "visibleOffsetProperty", OVERRIDE_STRING);
|
|
62
38
|
|
|
63
|
-
_defineProperty(
|
|
39
|
+
_defineProperty(this, "visibleSizesProperty", OVERRIDE_STRING);
|
|
64
40
|
|
|
65
|
-
_defineProperty(
|
|
41
|
+
_defineProperty(this, "marginProperty", OVERRIDE_STRING);
|
|
66
42
|
|
|
67
|
-
_defineProperty(
|
|
43
|
+
_defineProperty(this, "calculatedSizesProperty", OVERRIDE_STRING);
|
|
68
44
|
|
|
69
|
-
_defineProperty(
|
|
45
|
+
_defineProperty(this, "modelIndexesProperty", OVERRIDE_STRING);
|
|
70
46
|
|
|
71
|
-
_defineProperty(
|
|
47
|
+
_defineProperty(this, "firstIndexProperty", OVERRIDE_STRING);
|
|
72
48
|
|
|
73
|
-
_defineProperty(
|
|
49
|
+
_defineProperty(this, "treePaddingProperty", OVERRIDE_STRING);
|
|
50
|
+
}
|
|
74
51
|
|
|
75
|
-
|
|
52
|
+
getHiddenItems(itemIndex, metrics) {
|
|
53
|
+
throw new Error('Need to override getHiddenItems');
|
|
54
|
+
}
|
|
76
55
|
|
|
77
|
-
|
|
56
|
+
getNextShownItem(itemIndex, metrics) {
|
|
57
|
+
throw new Error('Need to override getNextShownItem');
|
|
58
|
+
} // eslint-disable-next-line no-unused-vars
|
|
78
59
|
|
|
79
|
-
_defineProperty(_assertThisInitialized(_this), "modelIndexesProperty", OVERRIDE_STRING);
|
|
80
60
|
|
|
81
|
-
|
|
61
|
+
setSize(metricCalculator, modelIndex, size) {
|
|
62
|
+
throw new Error('Need to override setSize');
|
|
63
|
+
} // eslint-disable-next-line no-unused-vars
|
|
82
64
|
|
|
83
|
-
_defineProperty(_assertThisInitialized(_this), "treePaddingProperty", OVERRIDE_STRING);
|
|
84
65
|
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
resetSize(metricCalculator, modelIndex) {
|
|
67
|
+
throw new Error('Need to override resetSize');
|
|
68
|
+
} // eslint-disable-next-line no-unused-vars
|
|
87
69
|
|
|
88
|
-
_createClass(GridSeparatorMouseHandler, [{
|
|
89
|
-
key: "getHiddenItems",
|
|
90
|
-
value: function getHiddenItems(itemIndex, metrics) {
|
|
91
|
-
throw new Error('Need to override getHiddenItems');
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "getNextShownItem",
|
|
95
|
-
value: function getNextShownItem(itemIndex, metrics) {
|
|
96
|
-
throw new Error('Need to override getNextShownItem');
|
|
97
|
-
} // eslint-disable-next-line no-unused-vars
|
|
98
|
-
|
|
99
|
-
}, {
|
|
100
|
-
key: "setSize",
|
|
101
|
-
value: function setSize(metricCalculator, modelIndex, size) {
|
|
102
|
-
throw new Error('Need to override setSize');
|
|
103
|
-
} // eslint-disable-next-line no-unused-vars
|
|
104
|
-
|
|
105
|
-
}, {
|
|
106
|
-
key: "resetSize",
|
|
107
|
-
value: function resetSize(metricCalculator, modelIndex) {
|
|
108
|
-
throw new Error('Need to override resetSize');
|
|
109
|
-
} // eslint-disable-next-line no-unused-vars
|
|
110
|
-
|
|
111
|
-
}, {
|
|
112
|
-
key: "updateSeparator",
|
|
113
|
-
value: function updateSeparator(grid, separatorIndex) {
|
|
114
|
-
throw new Error('Need to override updateSeparator');
|
|
115
|
-
} // eslint-disable-next-line no-unused-vars
|
|
116
|
-
|
|
117
|
-
}, {
|
|
118
|
-
key: "getSeparatorIndex",
|
|
119
|
-
value: function getSeparatorIndex(gridPoint, grid) {
|
|
120
|
-
var checkAllowResize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
121
|
-
throw new Error('Need to override getSeparatorIndex');
|
|
122
|
-
} // End of overrides
|
|
123
|
-
|
|
124
|
-
}, {
|
|
125
|
-
key: "onDown",
|
|
126
|
-
value: function onDown(gridPoint, grid) {
|
|
127
|
-
var separatorIndex = this.getSeparatorIndex(gridPoint, grid);
|
|
128
|
-
|
|
129
|
-
if (separatorIndex != null) {
|
|
130
|
-
var metrics = grid.metrics;
|
|
131
|
-
this.dragOffset = 0;
|
|
132
|
-
this.draggingIndex = separatorIndex;
|
|
133
|
-
this.resizingItems = [separatorIndex];
|
|
134
|
-
this.hiddenItems = this.getHiddenItems(separatorIndex, metrics).reverse();
|
|
135
|
-
this.targetSizes.clear();
|
|
136
|
-
this.addTargetSize(metrics, separatorIndex);
|
|
137
|
-
this.updateCursor(metrics, separatorIndex);
|
|
138
|
-
this.updateSeparator(grid, separatorIndex);
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
70
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
key: "onMove",
|
|
146
|
-
value: function onMove(gridPoint, grid) {
|
|
147
|
-
var separatorIndex = this.getSeparatorIndex(gridPoint, grid);
|
|
148
|
-
|
|
149
|
-
if (separatorIndex != null) {
|
|
150
|
-
var metrics = grid.metrics;
|
|
151
|
-
this.updateCursor(metrics, separatorIndex);
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
71
|
+
updateSeparator(grid, separatorIndex) {
|
|
72
|
+
throw new Error('Need to override updateSeparator');
|
|
73
|
+
} // eslint-disable-next-line no-unused-vars
|
|
154
74
|
|
|
155
|
-
|
|
75
|
+
|
|
76
|
+
getSeparatorIndex(gridPoint, grid) {
|
|
77
|
+
var checkAllowResize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
78
|
+
throw new Error('Need to override getSeparatorIndex');
|
|
79
|
+
} // End of overrides
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
onDown(gridPoint, grid) {
|
|
83
|
+
var separatorIndex = this.getSeparatorIndex(gridPoint, grid);
|
|
84
|
+
|
|
85
|
+
if (separatorIndex != null) {
|
|
86
|
+
var {
|
|
87
|
+
metrics
|
|
88
|
+
} = grid;
|
|
89
|
+
this.dragOffset = 0;
|
|
90
|
+
this.draggingIndex = separatorIndex;
|
|
91
|
+
this.resizingItems = [separatorIndex];
|
|
92
|
+
this.hiddenItems = this.getHiddenItems(separatorIndex, metrics).reverse();
|
|
93
|
+
this.targetSizes.clear();
|
|
94
|
+
this.addTargetSize(metrics, separatorIndex);
|
|
95
|
+
this.updateCursor(metrics, separatorIndex);
|
|
96
|
+
this.updateSeparator(grid, separatorIndex);
|
|
97
|
+
return true;
|
|
156
98
|
}
|
|
157
|
-
}, {
|
|
158
|
-
key: "onDrag",
|
|
159
|
-
value: function onDrag(gridPoint, grid) {
|
|
160
|
-
var _this2 = this;
|
|
161
99
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
165
102
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
metrics = grid.metrics;
|
|
169
|
-
var theme = grid.getTheme();
|
|
170
|
-
var visibleOffsets = metrics[this.visibleOffsetProperty];
|
|
171
|
-
var margin = metrics[this.marginProperty];
|
|
172
|
-
var calculatedSizes = metrics[this.calculatedSizesProperty];
|
|
173
|
-
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
174
|
-
var firstIndex = metrics[this.firstIndexProperty];
|
|
175
|
-
var treePadding = metrics[this.treePaddingProperty]; // New sizes are batched and applied after the loop to avoid updating state while calculating next step
|
|
103
|
+
onMove(gridPoint, grid) {
|
|
104
|
+
var separatorIndex = this.getSeparatorIndex(gridPoint, grid);
|
|
176
105
|
|
|
177
|
-
|
|
106
|
+
if (separatorIndex != null) {
|
|
107
|
+
var {
|
|
108
|
+
metrics
|
|
109
|
+
} = grid;
|
|
110
|
+
this.updateCursor(metrics, separatorIndex);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
178
113
|
|
|
179
|
-
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
180
116
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
var targetSize = this.targetSizes.get(modelIndex);
|
|
186
|
-
var isResizingMultiple = this.resizingItems.length > 1;
|
|
187
|
-
var hiddenIndex = this.hiddenItems.indexOf(resizeIndex);
|
|
188
|
-
var calculatedSize = calculatedSizes.get(modelIndex);
|
|
117
|
+
onDrag(gridPoint, grid) {
|
|
118
|
+
if (this.draggingIndex == null) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
189
121
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
122
|
+
var point = gridPoint[this.pointProperty];
|
|
123
|
+
var {
|
|
124
|
+
metricCalculator,
|
|
125
|
+
metrics
|
|
126
|
+
} = grid;
|
|
127
|
+
var theme = grid.getTheme();
|
|
128
|
+
var visibleOffsets = metrics[this.visibleOffsetProperty];
|
|
129
|
+
var margin = metrics[this.marginProperty];
|
|
130
|
+
var calculatedSizes = metrics[this.calculatedSizesProperty];
|
|
131
|
+
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
132
|
+
var firstIndex = metrics[this.firstIndexProperty];
|
|
133
|
+
var treePadding = metrics[this.treePaddingProperty]; // New sizes are batched and applied after the loop to avoid updating state while calculating next step
|
|
134
|
+
|
|
135
|
+
var newSizes = new Map(); // Use a loop as we may need to resize multiple items if they drag quickly
|
|
136
|
+
|
|
137
|
+
var resizeIndex = this.resizingItems[this.resizingItems.length - 1];
|
|
138
|
+
|
|
139
|
+
while (resizeIndex != null) {
|
|
140
|
+
var itemOffset = visibleOffsets.get(resizeIndex);
|
|
141
|
+
var itemSize = point - margin - itemOffset - this.dragOffset;
|
|
142
|
+
var modelIndex = modelIndexes.get(resizeIndex);
|
|
143
|
+
var targetSize = this.targetSizes.get(modelIndex);
|
|
144
|
+
var isResizingMultiple = this.resizingItems.length > 1;
|
|
145
|
+
var hiddenIndex = this.hiddenItems.indexOf(resizeIndex);
|
|
146
|
+
var calculatedSize = calculatedSizes.get(modelIndex);
|
|
147
|
+
|
|
148
|
+
if (resizeIndex === firstIndex) {
|
|
149
|
+
calculatedSize += treePadding;
|
|
150
|
+
}
|
|
193
151
|
|
|
194
|
-
|
|
152
|
+
var newSize = itemSize;
|
|
195
153
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
154
|
+
if (Math.abs(itemSize - calculatedSize) <= theme.headerResizeSnapThreshold) {
|
|
155
|
+
// Snapping behaviour to "natural" width
|
|
156
|
+
newSize = null;
|
|
157
|
+
} else if (itemSize > targetSize && (isResizingMultiple && hiddenIndex !== 0 || hiddenIndex > 0)) {
|
|
158
|
+
newSize = targetSize;
|
|
159
|
+
} else if (itemSize <= theme.headerResizeHiddenSnapThreshold) {
|
|
160
|
+
// Snapping to hidden item
|
|
161
|
+
newSize = 0;
|
|
162
|
+
}
|
|
205
163
|
|
|
206
|
-
|
|
207
|
-
|
|
164
|
+
if (newSize !== calculatedSize) {
|
|
165
|
+
newSizes.set(modelIndex, newSize);
|
|
166
|
+
} else {
|
|
167
|
+
newSizes.set(modelIndex, null);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (itemSize < -theme.headerResizeSnapThreshold && newSize === 0) {
|
|
171
|
+
if (hiddenIndex >= 0 && isResizingMultiple) {
|
|
172
|
+
this.resizingItems.pop();
|
|
173
|
+
this.removeTargetSize(metrics, resizeIndex);
|
|
174
|
+
resizeIndex = this.resizingItems[this.resizingItems.length - 1];
|
|
175
|
+
this.dragOffset -= this.targetSizes.get(modelIndexes.get(resizeIndex));
|
|
208
176
|
} else {
|
|
209
|
-
|
|
210
|
-
}
|
|
177
|
+
resizeIndex = this.getNextShownItem(resizeIndex, metrics);
|
|
211
178
|
|
|
212
|
-
|
|
213
|
-
if (hiddenIndex >= 0 && isResizingMultiple) {
|
|
214
|
-
this.resizingItems.pop();
|
|
215
|
-
this.removeTargetSize(metrics, resizeIndex);
|
|
216
|
-
resizeIndex = this.resizingItems[this.resizingItems.length - 1];
|
|
217
|
-
this.dragOffset -= this.targetSizes.get(modelIndexes.get(resizeIndex));
|
|
218
|
-
} else {
|
|
219
|
-
resizeIndex = this.getNextShownItem(resizeIndex, metrics);
|
|
220
|
-
|
|
221
|
-
if (resizeIndex != null) {
|
|
222
|
-
this.resizingItems.push(resizeIndex);
|
|
223
|
-
this.addTargetSize(metrics, resizeIndex);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
} else if (itemSize > targetSize + theme.headerResizeSnapThreshold && newSize === targetSize) {
|
|
227
|
-
if (hiddenIndex > 0) {
|
|
228
|
-
this.dragOffset += newSize;
|
|
229
|
-
resizeIndex = this.hiddenItems[hiddenIndex - 1];
|
|
179
|
+
if (resizeIndex != null) {
|
|
230
180
|
this.resizingItems.push(resizeIndex);
|
|
231
181
|
this.addTargetSize(metrics, resizeIndex);
|
|
232
|
-
} else if (isResizingMultiple) {
|
|
233
|
-
this.resizingItems.pop();
|
|
234
|
-
this.removeTargetSize(metrics, resizeIndex);
|
|
235
|
-
resizeIndex = this.resizingItems[this.resizingItems.length - 1];
|
|
236
|
-
} else {
|
|
237
|
-
resizeIndex = null;
|
|
238
182
|
}
|
|
183
|
+
}
|
|
184
|
+
} else if (itemSize > targetSize + theme.headerResizeSnapThreshold && newSize === targetSize) {
|
|
185
|
+
if (hiddenIndex > 0) {
|
|
186
|
+
this.dragOffset += newSize;
|
|
187
|
+
resizeIndex = this.hiddenItems[hiddenIndex - 1];
|
|
188
|
+
this.resizingItems.push(resizeIndex);
|
|
189
|
+
this.addTargetSize(metrics, resizeIndex);
|
|
190
|
+
} else if (isResizingMultiple) {
|
|
191
|
+
this.resizingItems.pop();
|
|
192
|
+
this.removeTargetSize(metrics, resizeIndex);
|
|
193
|
+
resizeIndex = this.resizingItems[this.resizingItems.length - 1];
|
|
239
194
|
} else {
|
|
240
195
|
resizeIndex = null;
|
|
241
196
|
}
|
|
197
|
+
} else {
|
|
198
|
+
resizeIndex = null;
|
|
242
199
|
}
|
|
243
|
-
|
|
244
|
-
newSizes.forEach(function (newSize, modelIndex) {
|
|
245
|
-
_this2.setSize(metricCalculator, modelIndex, newSize);
|
|
246
|
-
});
|
|
247
|
-
this.updateCursor(metrics, this.draggingIndex);
|
|
248
|
-
return true;
|
|
249
200
|
}
|
|
250
|
-
}, {
|
|
251
|
-
key: "onUp",
|
|
252
|
-
value: function onUp(_, grid) {
|
|
253
|
-
if (this.draggingIndex != null) {
|
|
254
|
-
this.draggingIndex = null;
|
|
255
|
-
this.resizingItems = [];
|
|
256
|
-
this.hiddenItems = [];
|
|
257
|
-
this.targetSizes.clear();
|
|
258
|
-
this.updateSeparator(grid, null);
|
|
259
|
-
}
|
|
260
201
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (separatorIndex != null) {
|
|
269
|
-
var metricCalculator = grid.metricCalculator,
|
|
270
|
-
metrics = grid.metrics;
|
|
271
|
-
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
272
|
-
var modelIndex = modelIndexes.get(separatorIndex);
|
|
273
|
-
this.resetSize(metricCalculator, modelIndex);
|
|
274
|
-
grid.forceUpdate();
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
202
|
+
newSizes.forEach((newSize, modelIndex) => {
|
|
203
|
+
this.setSize(metricCalculator, modelIndex, newSize);
|
|
204
|
+
});
|
|
205
|
+
this.updateCursor(metrics, this.draggingIndex);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
277
208
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (itemSize === 0) {
|
|
287
|
-
this.cursor = this.hiddenCursor;
|
|
288
|
-
} else {
|
|
289
|
-
this.cursor = this.defaultCursor;
|
|
290
|
-
}
|
|
209
|
+
onUp(_, grid) {
|
|
210
|
+
if (this.draggingIndex != null) {
|
|
211
|
+
this.draggingIndex = null;
|
|
212
|
+
this.resizingItems = [];
|
|
213
|
+
this.hiddenItems = [];
|
|
214
|
+
this.targetSizes.clear();
|
|
215
|
+
this.updateSeparator(grid, null);
|
|
291
216
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
217
|
+
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
onDoubleClick(gridPoint, grid) {
|
|
222
|
+
var separatorIndex = this.getSeparatorIndex(gridPoint, grid);
|
|
223
|
+
|
|
224
|
+
if (separatorIndex != null) {
|
|
225
|
+
var {
|
|
226
|
+
metricCalculator,
|
|
227
|
+
metrics
|
|
228
|
+
} = grid;
|
|
295
229
|
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
230
|
+
var modelIndex = modelIndexes.get(separatorIndex);
|
|
231
|
+
this.resetSize(metricCalculator, modelIndex);
|
|
232
|
+
grid.forceUpdate();
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
305
238
|
|
|
306
|
-
|
|
239
|
+
updateCursor(metrics, itemIndex) {
|
|
240
|
+
var visibleSizes = metrics[this.visibleSizesProperty];
|
|
241
|
+
var itemSize = visibleSizes.get(itemIndex);
|
|
242
|
+
|
|
243
|
+
if (itemSize === 0) {
|
|
244
|
+
this.cursor = this.hiddenCursor;
|
|
245
|
+
} else {
|
|
246
|
+
this.cursor = this.defaultCursor;
|
|
307
247
|
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
addTargetSize(metrics, itemIndex) {
|
|
251
|
+
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
252
|
+
var userSizes = metrics[this.userSizesProperty];
|
|
253
|
+
var calculatedSizes = metrics[this.calculatedSizesProperty];
|
|
254
|
+
var treePadding = itemIndex === 0 ? metrics[this.treePaddingProperty] : 0;
|
|
255
|
+
var modelIndex = modelIndexes.get(itemIndex);
|
|
256
|
+
var targetSize = userSizes.get(modelIndex);
|
|
257
|
+
|
|
258
|
+
if (targetSize == null || targetSize === 0) {
|
|
259
|
+
targetSize = calculatedSizes.get(modelIndex) + treePadding;
|
|
314
260
|
}
|
|
315
|
-
}]);
|
|
316
261
|
|
|
317
|
-
|
|
318
|
-
}
|
|
262
|
+
this.targetSizes.set(modelIndex, targetSize);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
removeTargetSize(metrics, itemIndex) {
|
|
266
|
+
var modelIndexes = metrics[this.modelIndexesProperty];
|
|
267
|
+
var modelIndex = modelIndexes.get(itemIndex);
|
|
268
|
+
this.targetSizes.delete(modelIndex);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
}
|
|
319
272
|
|
|
320
273
|
export default GridSeparatorMouseHandler;
|
|
321
274
|
//# sourceMappingURL=GridSeparatorMouseHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mouse-handlers/GridSeparatorMouseHandler.js"],"names":["GridMouseHandler","OVERRIDE_STRING","GridSeparatorMouseHandler","Map","itemIndex","metrics","Error","metricCalculator","modelIndex","size","grid","separatorIndex","gridPoint","checkAllowResize","getSeparatorIndex","dragOffset","draggingIndex","resizingItems","hiddenItems","getHiddenItems","reverse","targetSizes","clear","addTargetSize","updateCursor","updateSeparator","point","pointProperty","theme","getTheme","visibleOffsets","visibleOffsetProperty","margin","marginProperty","calculatedSizes","calculatedSizesProperty","modelIndexes","modelIndexesProperty","firstIndex","firstIndexProperty","treePadding","treePaddingProperty","newSizes","resizeIndex","length","itemOffset","get","itemSize","targetSize","isResizingMultiple","hiddenIndex","indexOf","calculatedSize","newSize","Math","abs","headerResizeSnapThreshold","headerResizeHiddenSnapThreshold","set","pop","removeTargetSize","getNextShownItem","push","forEach","setSize","_","resetSize","forceUpdate","visibleSizes","visibleSizesProperty","cursor","hiddenCursor","defaultCursor","userSizes","userSizesProperty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AACA,OAAOA,gBAAP,MAA6B,qBAA7B;AAEA,IAAMC,eAAe,GAAG,2BAAxB;AAEA;AACA;AACA;AACA;;IACMC,yB;;;;;;;;;;;;;;;;oEAEY,I;;oEAGA,E;;kEAGF,E;;kEAGA,IAAIC,GAAJ,E;;iEAED,C;;6DAGJF,e;;mEAEMA,e;;oEAECA,e;;oEAEAA,e;;wEAEIA,e;;4EAEIA,e;;2EAEDA,e;;qEAENA,e;;8EAESA,e;;2EAEHA,e;;yEAEFA,e;;0EAECA,e;;;;;;;WAEtB,wBAAeG,SAAf,EAA0BC,OAA1B,EAAmC;AACjC,YAAM,IAAIC,KAAJ,CAAU,iCAAV,CAAN;AACD;;;WAED,0BAAiBF,SAAjB,EAA4BC,OAA5B,EA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lQqCR,gB;;AAqQxC,eAAeE,yBAAf","sourcesContent":["/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\nimport GridMouseHandler from '../GridMouseHandler';\n\nconst OVERRIDE_STRING = 'NEED_TO_OVERRIDE_PROPERTY';\n\n/**\n * Abstract class that should be extended for column/row behaviour\n * Override the necessary functions/properties\n */\nclass GridSeparatorMouseHandler extends GridMouseHandler {\n // The index where dragging the column separator started\n draggingIndex = null;\n\n // The columns in the order they're being resized\n resizingItems = [];\n\n // Columns that were hidden under the separator when starting a drag\n hiddenItems = [];\n\n // The target width of the columns being resized\n targetSizes = new Map();\n\n dragOffset = 0;\n\n // Override/Implement these properties/functions\n cursor = OVERRIDE_STRING;\n\n hiddenCursor = OVERRIDE_STRING;\n\n defaultCursor = OVERRIDE_STRING;\n\n pointProperty = OVERRIDE_STRING;\n\n userSizesProperty = OVERRIDE_STRING;\n\n visibleOffsetProperty = OVERRIDE_STRING;\n\n visibleSizesProperty = OVERRIDE_STRING;\n\n marginProperty = OVERRIDE_STRING;\n\n calculatedSizesProperty = OVERRIDE_STRING;\n\n modelIndexesProperty = OVERRIDE_STRING;\n\n firstIndexProperty = OVERRIDE_STRING;\n\n treePaddingProperty = OVERRIDE_STRING;\n\n getHiddenItems(itemIndex, metrics) {\n throw new Error('Need to override getHiddenItems');\n }\n\n getNextShownItem(itemIndex, metrics) {\n throw new Error('Need to override getNextShownItem');\n }\n\n // eslint-disable-next-line no-unused-vars\n setSize(metricCalculator, modelIndex, size) {\n throw new Error('Need to override setSize');\n }\n\n // eslint-disable-next-line no-unused-vars\n resetSize(metricCalculator, modelIndex) {\n throw new Error('Need to override resetSize');\n }\n\n // eslint-disable-next-line no-unused-vars\n updateSeparator(grid, separatorIndex) {\n throw new Error('Need to override updateSeparator');\n }\n\n // eslint-disable-next-line no-unused-vars\n getSeparatorIndex(gridPoint, grid, checkAllowResize = true) {\n throw new Error('Need to override getSeparatorIndex');\n }\n // End of overrides\n\n onDown(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n if (separatorIndex != null) {\n const { metrics } = grid;\n\n this.dragOffset = 0;\n this.draggingIndex = separatorIndex;\n this.resizingItems = [separatorIndex];\n this.hiddenItems = this.getHiddenItems(separatorIndex, metrics).reverse();\n this.targetSizes.clear();\n\n this.addTargetSize(metrics, separatorIndex);\n\n this.updateCursor(metrics, separatorIndex);\n\n this.updateSeparator(grid, separatorIndex);\n\n return true;\n }\n return false;\n }\n\n onMove(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n if (separatorIndex != null) {\n const { metrics } = grid;\n this.updateCursor(metrics, separatorIndex);\n return true;\n }\n return false;\n }\n\n onDrag(gridPoint, grid) {\n if (this.draggingIndex == null) {\n return false;\n }\n\n const point = gridPoint[this.pointProperty];\n const { metricCalculator, metrics } = grid;\n const theme = grid.getTheme();\n\n const visibleOffsets = metrics[this.visibleOffsetProperty];\n const margin = metrics[this.marginProperty];\n const calculatedSizes = metrics[this.calculatedSizesProperty];\n const modelIndexes = metrics[this.modelIndexesProperty];\n const firstIndex = metrics[this.firstIndexProperty];\n const treePadding = metrics[this.treePaddingProperty];\n\n // New sizes are batched and applied after the loop to avoid updating state while calculating next step\n const newSizes = new Map();\n\n // Use a loop as we may need to resize multiple items if they drag quickly\n let resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n while (resizeIndex != null) {\n const itemOffset = visibleOffsets.get(resizeIndex);\n const itemSize = point - margin - itemOffset - this.dragOffset;\n const modelIndex = modelIndexes.get(resizeIndex);\n const targetSize = this.targetSizes.get(modelIndex);\n const isResizingMultiple = this.resizingItems.length > 1;\n const hiddenIndex = this.hiddenItems.indexOf(resizeIndex);\n let calculatedSize = calculatedSizes.get(modelIndex);\n if (resizeIndex === firstIndex) {\n calculatedSize += treePadding;\n }\n let newSize = itemSize;\n if (\n Math.abs(itemSize - calculatedSize) <= theme.headerResizeSnapThreshold\n ) {\n // Snapping behaviour to \"natural\" width\n newSize = null;\n } else if (\n itemSize > targetSize &&\n ((isResizingMultiple && hiddenIndex !== 0) || hiddenIndex > 0)\n ) {\n newSize = targetSize;\n } else if (itemSize <= theme.headerResizeHiddenSnapThreshold) {\n // Snapping to hidden item\n newSize = 0;\n }\n\n if (newSize !== calculatedSize) {\n newSizes.set(modelIndex, newSize);\n } else {\n newSizes.set(modelIndex, null);\n }\n\n if (itemSize < -theme.headerResizeSnapThreshold && newSize === 0) {\n if (hiddenIndex >= 0 && isResizingMultiple) {\n this.resizingItems.pop();\n this.removeTargetSize(metrics, resizeIndex);\n resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n this.dragOffset -= this.targetSizes.get(\n modelIndexes.get(resizeIndex)\n );\n } else {\n resizeIndex = this.getNextShownItem(resizeIndex, metrics);\n if (resizeIndex != null) {\n this.resizingItems.push(resizeIndex);\n this.addTargetSize(metrics, resizeIndex);\n }\n }\n } else if (\n itemSize > targetSize + theme.headerResizeSnapThreshold &&\n newSize === targetSize\n ) {\n if (hiddenIndex > 0) {\n this.dragOffset += newSize;\n resizeIndex = this.hiddenItems[hiddenIndex - 1];\n this.resizingItems.push(resizeIndex);\n this.addTargetSize(metrics, resizeIndex);\n } else if (isResizingMultiple) {\n this.resizingItems.pop();\n this.removeTargetSize(metrics, resizeIndex);\n resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n } else {\n resizeIndex = null;\n }\n } else {\n resizeIndex = null;\n }\n }\n\n newSizes.forEach((newSize, modelIndex) => {\n this.setSize(metricCalculator, modelIndex, newSize);\n });\n\n this.updateCursor(metrics, this.draggingIndex);\n\n return true;\n }\n\n onUp(_, grid) {\n if (this.draggingIndex != null) {\n this.draggingIndex = null;\n this.resizingItems = [];\n this.hiddenItems = [];\n this.targetSizes.clear();\n\n this.updateSeparator(grid, null);\n }\n\n return false;\n }\n\n onDoubleClick(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n\n if (separatorIndex != null) {\n const { metricCalculator, metrics } = grid;\n const modelIndexes = metrics[this.modelIndexesProperty];\n const modelIndex = modelIndexes.get(separatorIndex);\n\n this.resetSize(metricCalculator, modelIndex);\n\n grid.forceUpdate();\n\n return true;\n }\n return false;\n }\n\n updateCursor(metrics, itemIndex) {\n const visibleSizes = metrics[this.visibleSizesProperty];\n const itemSize = visibleSizes.get(itemIndex);\n if (itemSize === 0) {\n this.cursor = this.hiddenCursor;\n } else {\n this.cursor = this.defaultCursor;\n }\n }\n\n addTargetSize(metrics, itemIndex) {\n const modelIndexes = metrics[this.modelIndexesProperty];\n const userSizes = metrics[this.userSizesProperty];\n const calculatedSizes = metrics[this.calculatedSizesProperty];\n const treePadding = itemIndex === 0 ? metrics[this.treePaddingProperty] : 0;\n\n const modelIndex = modelIndexes.get(itemIndex);\n let targetSize = userSizes.get(modelIndex);\n if (targetSize == null || targetSize === 0) {\n targetSize = calculatedSizes.get(modelIndex) + treePadding;\n }\n this.targetSizes.set(modelIndex, targetSize);\n }\n\n removeTargetSize(metrics, itemIndex) {\n const modelIndexes = metrics[this.modelIndexesProperty];\n const modelIndex = modelIndexes.get(itemIndex);\n this.targetSizes.delete(modelIndex);\n }\n}\n\nexport default GridSeparatorMouseHandler;\n"],"file":"GridSeparatorMouseHandler.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/mouse-handlers/GridSeparatorMouseHandler.js"],"names":["GridMouseHandler","OVERRIDE_STRING","GridSeparatorMouseHandler","Map","getHiddenItems","itemIndex","metrics","Error","getNextShownItem","setSize","metricCalculator","modelIndex","size","resetSize","updateSeparator","grid","separatorIndex","getSeparatorIndex","gridPoint","checkAllowResize","onDown","dragOffset","draggingIndex","resizingItems","hiddenItems","reverse","targetSizes","clear","addTargetSize","updateCursor","onMove","onDrag","point","pointProperty","theme","getTheme","visibleOffsets","visibleOffsetProperty","margin","marginProperty","calculatedSizes","calculatedSizesProperty","modelIndexes","modelIndexesProperty","firstIndex","firstIndexProperty","treePadding","treePaddingProperty","newSizes","resizeIndex","length","itemOffset","get","itemSize","targetSize","isResizingMultiple","hiddenIndex","indexOf","calculatedSize","newSize","Math","abs","headerResizeSnapThreshold","headerResizeHiddenSnapThreshold","set","pop","removeTargetSize","push","forEach","onUp","_","onDoubleClick","forceUpdate","visibleSizes","visibleSizesProperty","cursor","hiddenCursor","defaultCursor","userSizes","userSizesProperty","delete"],"mappings":";;AAAA;;AACA;OACOA,gB;AAEP,IAAMC,eAAe,GAAG,2BAAxB;AAEA;AACA;AACA;AACA;;AACA,MAAMC,yBAAN,SAAwCF,gBAAxC,CAAyD;AAAA;AAAA;;AAAA,2CAEvC,IAFuC;;AAAA,2CAKvC,EALuC;;AAAA,yCAQzC,EARyC;;AAAA,yCAWzC,IAAIG,GAAJ,EAXyC;;AAAA,wCAa1C,CAb0C;;AAAA,oCAgB9CF,eAhB8C;;AAAA,0CAkBxCA,eAlBwC;;AAAA,2CAoBvCA,eApBuC;;AAAA,2CAsBvCA,eAtBuC;;AAAA,+CAwBnCA,eAxBmC;;AAAA,mDA0B/BA,eA1B+B;;AAAA,kDA4BhCA,eA5BgC;;AAAA,4CA8BtCA,eA9BsC;;AAAA,qDAgC7BA,eAhC6B;;AAAA,kDAkChCA,eAlCgC;;AAAA,gDAoClCA,eApCkC;;AAAA,iDAsCjCA,eAtCiC;AAAA;;AAwCvDG,EAAAA,cAAc,CAACC,SAAD,EAAYC,OAAZ,EAAqB;AACjC,UAAM,IAAIC,KAAJ,CAAU,iCAAV,CAAN;AACD;;AAEDC,EAAAA,gBAAgB,CAACH,SAAD,EAAYC,OAAZ,EAAqB;AACnC,UAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;AACD,GA9CsD,CAgDvD;;;AACAE,EAAAA,OAAO,CAACC,gBAAD,EAAmBC,UAAnB,EAA+BC,IAA/B,EAAqC;AAC1C,UAAM,IAAIL,KAAJ,CAAU,0BAAV,CAAN;AACD,GAnDsD,CAqDvD;;;AACAM,EAAAA,SAAS,CAACH,gBAAD,EAAmBC,UAAnB,EAA+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sB,MAAL,GAAc,KAAKC,YAAnB;AACD,KAFD,MAEO;AACL,WAAKD,MAAL,GAAc,KAAKE,aAAnB;AACD;AACF;;AAEDjD,EAAAA,aAAa,CAACtB,OAAD,EAAUD,SAAV,EAAqB;AAChC,QAAMqC,YAAY,GAAGpC,OAAO,CAAC,KAAKqC,oBAAN,CAA5B;AACA,QAAMmC,SAAS,GAAGxE,OAAO,CAAC,KAAKyE,iBAAN,CAAzB;AACA,QAAMvC,eAAe,GAAGlC,OAAO,CAAC,KAAKmC,uBAAN,CAA/B;AACA,QAAMK,WAAW,GAAGzC,SAAS,KAAK,CAAd,GAAkBC,OAAO,CAAC,KAAKyC,mBAAN,CAAzB,GAAsD,CAA1E;AAEA,QAAMpC,UAAU,GAAG+B,YAAY,CAACU,GAAb,CAAiB/C,SAAjB,CAAnB;AACA,QAAIiD,UAAU,GAAGwB,SAAS,CAAC1B,GAAV,CAAczC,UAAd,CAAjB;;AACA,QAAI2C,UAAU,IAAI,IAAd,IAAsBA,UAAU,KAAK,CAAzC,EAA4C;AAC1CA,MAAAA,UAAU,GAAGd,eAAe,CAACY,GAAhB,CAAoBzC,UAApB,IAAkCmC,WAA/C;AACD;;AACD,SAAKpB,WAAL,CAAiBsC,GAAjB,CAAqBrD,UAArB,EAAiC2C,UAAjC;AACD;;AAEDY,EAAAA,gBAAgB,CAAC5D,OAAD,EAAUD,SAAV,EAAqB;AACnC,QAAMqC,YAAY,GAAGpC,OAAO,CAAC,KAAKqC,oBAAN,CAA5B;AACA,QAAMhC,UAAU,GAAG+B,YAAY,CAACU,GAAb,CAAiB/C,SAAjB,CAAnB;AACA,SAAKqB,WAAL,CAAiBsD,MAAjB,CAAwBrE,UAAxB;AACD;;AAlQsD;;AAqQzD,eAAeT,yBAAf","sourcesContent":["/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\nimport GridMouseHandler from '../GridMouseHandler';\n\nconst OVERRIDE_STRING = 'NEED_TO_OVERRIDE_PROPERTY';\n\n/**\n * Abstract class that should be extended for column/row behaviour\n * Override the necessary functions/properties\n */\nclass GridSeparatorMouseHandler extends GridMouseHandler {\n // The index where dragging the column separator started\n draggingIndex = null;\n\n // The columns in the order they're being resized\n resizingItems = [];\n\n // Columns that were hidden under the separator when starting a drag\n hiddenItems = [];\n\n // The target width of the columns being resized\n targetSizes = new Map();\n\n dragOffset = 0;\n\n // Override/Implement these properties/functions\n cursor = OVERRIDE_STRING;\n\n hiddenCursor = OVERRIDE_STRING;\n\n defaultCursor = OVERRIDE_STRING;\n\n pointProperty = OVERRIDE_STRING;\n\n userSizesProperty = OVERRIDE_STRING;\n\n visibleOffsetProperty = OVERRIDE_STRING;\n\n visibleSizesProperty = OVERRIDE_STRING;\n\n marginProperty = OVERRIDE_STRING;\n\n calculatedSizesProperty = OVERRIDE_STRING;\n\n modelIndexesProperty = OVERRIDE_STRING;\n\n firstIndexProperty = OVERRIDE_STRING;\n\n treePaddingProperty = OVERRIDE_STRING;\n\n getHiddenItems(itemIndex, metrics) {\n throw new Error('Need to override getHiddenItems');\n }\n\n getNextShownItem(itemIndex, metrics) {\n throw new Error('Need to override getNextShownItem');\n }\n\n // eslint-disable-next-line no-unused-vars\n setSize(metricCalculator, modelIndex, size) {\n throw new Error('Need to override setSize');\n }\n\n // eslint-disable-next-line no-unused-vars\n resetSize(metricCalculator, modelIndex) {\n throw new Error('Need to override resetSize');\n }\n\n // eslint-disable-next-line no-unused-vars\n updateSeparator(grid, separatorIndex) {\n throw new Error('Need to override updateSeparator');\n }\n\n // eslint-disable-next-line no-unused-vars\n getSeparatorIndex(gridPoint, grid, checkAllowResize = true) {\n throw new Error('Need to override getSeparatorIndex');\n }\n // End of overrides\n\n onDown(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n if (separatorIndex != null) {\n const { metrics } = grid;\n\n this.dragOffset = 0;\n this.draggingIndex = separatorIndex;\n this.resizingItems = [separatorIndex];\n this.hiddenItems = this.getHiddenItems(separatorIndex, metrics).reverse();\n this.targetSizes.clear();\n\n this.addTargetSize(metrics, separatorIndex);\n\n this.updateCursor(metrics, separatorIndex);\n\n this.updateSeparator(grid, separatorIndex);\n\n return true;\n }\n return false;\n }\n\n onMove(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n if (separatorIndex != null) {\n const { metrics } = grid;\n this.updateCursor(metrics, separatorIndex);\n return true;\n }\n return false;\n }\n\n onDrag(gridPoint, grid) {\n if (this.draggingIndex == null) {\n return false;\n }\n\n const point = gridPoint[this.pointProperty];\n const { metricCalculator, metrics } = grid;\n const theme = grid.getTheme();\n\n const visibleOffsets = metrics[this.visibleOffsetProperty];\n const margin = metrics[this.marginProperty];\n const calculatedSizes = metrics[this.calculatedSizesProperty];\n const modelIndexes = metrics[this.modelIndexesProperty];\n const firstIndex = metrics[this.firstIndexProperty];\n const treePadding = metrics[this.treePaddingProperty];\n\n // New sizes are batched and applied after the loop to avoid updating state while calculating next step\n const newSizes = new Map();\n\n // Use a loop as we may need to resize multiple items if they drag quickly\n let resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n while (resizeIndex != null) {\n const itemOffset = visibleOffsets.get(resizeIndex);\n const itemSize = point - margin - itemOffset - this.dragOffset;\n const modelIndex = modelIndexes.get(resizeIndex);\n const targetSize = this.targetSizes.get(modelIndex);\n const isResizingMultiple = this.resizingItems.length > 1;\n const hiddenIndex = this.hiddenItems.indexOf(resizeIndex);\n let calculatedSize = calculatedSizes.get(modelIndex);\n if (resizeIndex === firstIndex) {\n calculatedSize += treePadding;\n }\n let newSize = itemSize;\n if (\n Math.abs(itemSize - calculatedSize) <= theme.headerResizeSnapThreshold\n ) {\n // Snapping behaviour to \"natural\" width\n newSize = null;\n } else if (\n itemSize > targetSize &&\n ((isResizingMultiple && hiddenIndex !== 0) || hiddenIndex > 0)\n ) {\n newSize = targetSize;\n } else if (itemSize <= theme.headerResizeHiddenSnapThreshold) {\n // Snapping to hidden item\n newSize = 0;\n }\n\n if (newSize !== calculatedSize) {\n newSizes.set(modelIndex, newSize);\n } else {\n newSizes.set(modelIndex, null);\n }\n\n if (itemSize < -theme.headerResizeSnapThreshold && newSize === 0) {\n if (hiddenIndex >= 0 && isResizingMultiple) {\n this.resizingItems.pop();\n this.removeTargetSize(metrics, resizeIndex);\n resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n this.dragOffset -= this.targetSizes.get(\n modelIndexes.get(resizeIndex)\n );\n } else {\n resizeIndex = this.getNextShownItem(resizeIndex, metrics);\n if (resizeIndex != null) {\n this.resizingItems.push(resizeIndex);\n this.addTargetSize(metrics, resizeIndex);\n }\n }\n } else if (\n itemSize > targetSize + theme.headerResizeSnapThreshold &&\n newSize === targetSize\n ) {\n if (hiddenIndex > 0) {\n this.dragOffset += newSize;\n resizeIndex = this.hiddenItems[hiddenIndex - 1];\n this.resizingItems.push(resizeIndex);\n this.addTargetSize(metrics, resizeIndex);\n } else if (isResizingMultiple) {\n this.resizingItems.pop();\n this.removeTargetSize(metrics, resizeIndex);\n resizeIndex = this.resizingItems[this.resizingItems.length - 1];\n } else {\n resizeIndex = null;\n }\n } else {\n resizeIndex = null;\n }\n }\n\n newSizes.forEach((newSize, modelIndex) => {\n this.setSize(metricCalculator, modelIndex, newSize);\n });\n\n this.updateCursor(metrics, this.draggingIndex);\n\n return true;\n }\n\n onUp(_, grid) {\n if (this.draggingIndex != null) {\n this.draggingIndex = null;\n this.resizingItems = [];\n this.hiddenItems = [];\n this.targetSizes.clear();\n\n this.updateSeparator(grid, null);\n }\n\n return false;\n }\n\n onDoubleClick(gridPoint, grid) {\n const separatorIndex = this.getSeparatorIndex(gridPoint, grid);\n\n if (separatorIndex != null) {\n const { metricCalculator, metrics } = grid;\n const modelIndexes = metrics[this.modelIndexesProperty];\n const modelIndex = modelIndexes.get(separatorIndex);\n\n this.resetSize(metricCalculator, modelIndex);\n\n grid.forceUpdate();\n\n return true;\n }\n return false;\n }\n\n updateCursor(metrics, itemIndex) {\n const visibleSizes = metrics[this.visibleSizesProperty];\n const itemSize = visibleSizes.get(itemIndex);\n if (itemSize === 0) {\n this.cursor = this.hiddenCursor;\n } else {\n this.cursor = this.defaultCursor;\n }\n }\n\n addTargetSize(metrics, itemIndex) {\n const modelIndexes = metrics[this.modelIndexesProperty];\n const userSizes = metrics[this.userSizesProperty];\n const calculatedSizes = metrics[this.calculatedSizesProperty];\n const treePadding = itemIndex === 0 ? metrics[this.treePaddingProperty] : 0;\n\n const modelIndex = modelIndexes.get(itemIndex);\n let targetSize = userSizes.get(modelIndex);\n if (targetSize == null || targetSize === 0) {\n targetSize = calculatedSizes.get(modelIndex) + treePadding;\n }\n this.targetSizes.set(modelIndex, targetSize);\n }\n\n removeTargetSize(metrics, itemIndex) {\n const modelIndexes = metrics[this.modelIndexesProperty];\n const modelIndex = modelIndexes.get(itemIndex);\n this.targetSizes.delete(modelIndex);\n }\n}\n\nexport default GridSeparatorMouseHandler;\n"],"file":"GridSeparatorMouseHandler.js"}
|