@omegagrid/grid 0.2.7 → 0.2.9
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/editors/formulaEditor.d.ts.map +1 -1
- package/dist/editors/formulaEditor.js +2 -1
- package/dist/editors/formulaEditor.js.map +1 -1
- package/dist/renderers/BaseRenderer.d.ts.map +1 -1
- package/dist/renderers/BaseRenderer.js +0 -1
- package/dist/renderers/BaseRenderer.js.map +1 -1
- package/dist/ui/formulaInput.d.ts +5 -0
- package/dist/ui/formulaInput.d.ts.map +1 -1
- package/dist/ui/formulaInput.js +21 -9
- package/dist/ui/formulaInput.js.map +1 -1
- package/dist/ui/grid.d.ts.map +1 -1
- package/dist/ui/grid.events.d.ts +5 -4
- package/dist/ui/grid.events.d.ts.map +1 -1
- package/dist/ui/grid.events.js +82 -72
- package/dist/ui/grid.events.js.map +1 -1
- package/dist/ui/grid.js +19 -3
- package/dist/ui/grid.js.map +1 -1
- package/dist/ui/grid.selecting.d.ts +56 -12
- package/dist/ui/grid.selecting.d.ts.map +1 -1
- package/dist/ui/grid.selecting.js +140 -73
- package/dist/ui/grid.selecting.js.map +1 -1
- package/dist/ui/group.js +1 -1
- package/dist/ui/group.js.map +1 -1
- package/dist/ui/selector.d.ts +29 -18
- package/dist/ui/selector.d.ts.map +1 -1
- package/dist/ui/selector.js +184 -173
- package/dist/ui/selector.js.map +1 -1
- package/dist/ui/table.d.ts +4 -0
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +56 -6
- package/dist/ui/table.js.map +1 -1
- package/package.json +6 -6
package/dist/ui/selector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DiagonalDirection, Direction, DirectionalPosition } from "@omegagrid/core";
|
|
2
|
-
import {
|
|
2
|
+
import { CellRange } from "@omegagrid/grid-core";
|
|
3
3
|
import { LitElement } from 'lit';
|
|
4
4
|
import { Grid } from './grid';
|
|
5
5
|
export declare class SelectorEvent extends Event {
|
|
@@ -20,12 +20,7 @@ export declare class Selector extends LitElement {
|
|
|
20
20
|
private activeCell?;
|
|
21
21
|
private autofillSelector;
|
|
22
22
|
private moveSelector;
|
|
23
|
-
private
|
|
24
|
-
private _grid;
|
|
25
|
-
get grid(): Grid;
|
|
26
|
-
private _selection;
|
|
27
|
-
get selection(): SelectionModel;
|
|
28
|
-
get moving(): boolean;
|
|
23
|
+
private baseCell;
|
|
29
24
|
private _animationTimer;
|
|
30
25
|
private _autofillDirection;
|
|
31
26
|
get autofillDirection(): Direction;
|
|
@@ -38,6 +33,9 @@ export declare class Selector extends LitElement {
|
|
|
38
33
|
private _resizing;
|
|
39
34
|
private _resizingDirection;
|
|
40
35
|
get isResizing(): boolean;
|
|
36
|
+
private _selecting;
|
|
37
|
+
get isSelecting(): boolean;
|
|
38
|
+
get isSelectorOperationActive(): boolean;
|
|
41
39
|
get table(): import("./table").Table;
|
|
42
40
|
index: number;
|
|
43
41
|
autofill: boolean;
|
|
@@ -47,6 +45,9 @@ export declare class Selector extends LitElement {
|
|
|
47
45
|
color: string;
|
|
48
46
|
borderWidth: number;
|
|
49
47
|
animated: boolean;
|
|
48
|
+
selection: CellRange;
|
|
49
|
+
activeCellRange: CellRange;
|
|
50
|
+
grid: Grid;
|
|
50
51
|
handleElm: HTMLDivElement;
|
|
51
52
|
svgAnimation: SVGElement;
|
|
52
53
|
moveHandleLeftElm: HTMLDivElement;
|
|
@@ -59,18 +60,29 @@ export declare class Selector extends LitElement {
|
|
|
59
60
|
hide: () => void;
|
|
60
61
|
show: () => void;
|
|
61
62
|
highlightAutofillRange(): void;
|
|
62
|
-
_onHandleMouseMove: (e: MouseEvent) => void;
|
|
63
63
|
createAutofillSelector(): HTMLDivElement;
|
|
64
|
-
|
|
64
|
+
stopAutofilling(dispatchEvent?: boolean): void;
|
|
65
|
+
updateAutofilling(c: number, r: number): void;
|
|
65
66
|
getMoveSelector(): Selector;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
stopResizing(): void;
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
startMoving(baseCell: CellRange): void;
|
|
68
|
+
updateMoving(c: number, r: number): void;
|
|
69
|
+
stopMoving(dispatchEvent?: boolean): void;
|
|
70
|
+
startResizing(direction: DiagonalDirection): void;
|
|
71
|
+
updateResizing(c: number, r: number): void;
|
|
72
|
+
stopResizing(dispatchEvent?: boolean): void;
|
|
73
|
+
startSelecting(baseCell: CellRange): void;
|
|
74
|
+
select(selection: CellRange, dispatchEvent?: boolean): void;
|
|
75
|
+
stopSelecting(_dispatchEvent?: boolean): void;
|
|
76
|
+
/**
|
|
77
|
+
* Updates selector state after table moving events
|
|
78
|
+
* @param cell
|
|
79
|
+
*/
|
|
80
|
+
updateMovingOperations(c: number, r: number): void;
|
|
81
|
+
stopSelectorOperations(dispatchEvent?: boolean): void;
|
|
82
|
+
_onMoveHandleMouseDown: (e: PointerEvent, _side: DirectionalPosition) => void;
|
|
83
|
+
_onResizeHandleMouseDown: (e: PointerEvent, direction: DiagonalDirection) => void;
|
|
84
|
+
_onHandleMouseUp: (e: PointerEvent) => void;
|
|
85
|
+
_onHandleMouseDown: () => void;
|
|
74
86
|
render: () => import("lit-html").TemplateResult<1>;
|
|
75
87
|
startAnimation(): void;
|
|
76
88
|
stopAnimation(): void;
|
|
@@ -78,6 +90,5 @@ export declare class Selector extends LitElement {
|
|
|
78
90
|
willUpdate(): void;
|
|
79
91
|
updated(): void;
|
|
80
92
|
updatePosition(): void;
|
|
81
|
-
select(selection: SelectionModel, grid: Grid, dispatchEvent?: boolean): void;
|
|
82
93
|
}
|
|
83
94
|
//# sourceMappingURL=selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/ui/selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,mBAAmB,EAAO,MAAM,iBA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IAuCnC,YAAY,CAAC,aAAa,UAAO;IAWjC,cAAc,CAAC,QAAQ,EAAE,SAAS;IAMlC,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,UAAO;IAKjD,aAAa,CAAC,cAAc,UAAO;IAOnC;;;OAGG;IACH,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAM3C,sBAAsB,CAAC,aAAa,UAAO;IAO3C,sBAAsB,MAAO,YAAY,SAAS,mBAAmB,UAiBnE;IAEF,wBAAwB,MAAO,YAAY,aAAa,iBAAiB,UAGxE;IAED,gBAAgB,MAAO,YAAY,UAIlC;IAED,kBAAkB,aAKjB;IAED,MAAM,6CAsCJ;IAEF,cAAc;IAUd,aAAa;IAKb,oBAAoB;IAIpB,UAAU;IAIV,OAAO;IAMP,cAAc;CAgFd"}
|
package/dist/ui/selector.js
CHANGED
|
@@ -38,6 +38,7 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
38
38
|
this._autofilling = false;
|
|
39
39
|
this._moving = false;
|
|
40
40
|
this._resizing = false;
|
|
41
|
+
this._selecting = false;
|
|
41
42
|
this.subselector = false;
|
|
42
43
|
this.borderWidth = constants_1.default.SELECTOR_BORDER_WIDTH;
|
|
43
44
|
this.animated = false;
|
|
@@ -45,6 +46,7 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
45
46
|
this.hide = () => {
|
|
46
47
|
this._isVisible = false;
|
|
47
48
|
core_1.dom.hideElement(this);
|
|
49
|
+
this.stopSelectorOperations();
|
|
48
50
|
this.stopAnimation();
|
|
49
51
|
};
|
|
50
52
|
this.show = () => {
|
|
@@ -52,71 +54,6 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
52
54
|
core_1.dom.showElement(this);
|
|
53
55
|
this.startAnimation();
|
|
54
56
|
};
|
|
55
|
-
this._onHandleMouseMove = (e) => {
|
|
56
|
-
for (const elm of e.composedPath()) {
|
|
57
|
-
if (elm.tagName == 'TD') {
|
|
58
|
-
const td = elm;
|
|
59
|
-
const { c1, r1, c2, r2 } = this.selection.range;
|
|
60
|
-
const { r, c } = td;
|
|
61
|
-
this._autofillRange = null;
|
|
62
|
-
// down autofill
|
|
63
|
-
if (r > r2 && c - c2 <= r - r2) {
|
|
64
|
-
this._autofillDirection = 'down';
|
|
65
|
-
this._autofillRange = new grid_core_1.CellRange(c1, r2 + 1, c2, r);
|
|
66
|
-
}
|
|
67
|
-
// up autofill
|
|
68
|
-
else if (r < r1 && c1 - c <= r1 - r) {
|
|
69
|
-
this._autofillDirection = 'up';
|
|
70
|
-
this._autofillRange = new grid_core_1.CellRange(c1, r, c2, r1 - 1);
|
|
71
|
-
}
|
|
72
|
-
// right autofill
|
|
73
|
-
else if (c > c2 && c - c2 > r - r2) {
|
|
74
|
-
this._autofillDirection = 'right';
|
|
75
|
-
this._autofillRange = new grid_core_1.CellRange(c2 + 1, r1, c, r2);
|
|
76
|
-
}
|
|
77
|
-
// left autofill
|
|
78
|
-
else if (c < c1 && c1 - c > r1 - r) {
|
|
79
|
-
this._autofillDirection = 'left';
|
|
80
|
-
this._autofillRange = new grid_core_1.CellRange(c, r1, c1 - 1, r2);
|
|
81
|
-
}
|
|
82
|
-
if (this._autofillRange)
|
|
83
|
-
this.highlightAutofillRange();
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
this._onHandleMouseDown = () => {
|
|
89
|
-
var _a;
|
|
90
|
-
this._autofilling = true;
|
|
91
|
-
this.autofillSelector = (_a = this.autofillSelector) !== null && _a !== void 0 ? _a : this.createAutofillSelector();
|
|
92
|
-
core_1.dom.hideElement(this.autofillSelector);
|
|
93
|
-
core_1.dom.appendElement(this.grid.shadowRoot, this.autofillSelector);
|
|
94
|
-
this.table.addEventListener('mousemove', this._onHandleMouseMove);
|
|
95
|
-
this.table.addEventListener('mouseup', () => {
|
|
96
|
-
this._autofilling = false;
|
|
97
|
-
this.dispatchEvent(new SelectorEvent('autofill', { selector: this }));
|
|
98
|
-
//this.autofillRange = null;
|
|
99
|
-
this.autofillSelector.remove();
|
|
100
|
-
this.table.removeEventListener('mousemove', this._onHandleMouseMove);
|
|
101
|
-
}, { once: true });
|
|
102
|
-
};
|
|
103
|
-
// TODO - another mousemove event handler in grid.events.ts, should be passible to move it there
|
|
104
|
-
this._onMoveHandleMouseMove = (e) => {
|
|
105
|
-
// primary button not pressed
|
|
106
|
-
if ((e.buttons & 1) == 0) {
|
|
107
|
-
this.stopMoving();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const td = e.composedPath().find((elm) => elm.tagName == 'TD');
|
|
111
|
-
if (td) {
|
|
112
|
-
const c = this.selection.range.isRow ? 0 : td.c - this.movingBaseCell.c1;
|
|
113
|
-
const r = this.selection.range.isColumn ? 0 : td.r - this.movingBaseCell.r1;
|
|
114
|
-
const moveSelector = this.getMoveSelector();
|
|
115
|
-
moveSelector.selection.setCoords(this.selection.range.c1 + c, this.selection.range.r1 + r, this.selection.range.c2 + c, this.selection.range.r2 + r);
|
|
116
|
-
moveSelector.select(moveSelector.selection, this.grid);
|
|
117
|
-
core_1.dom.showElement(this.moveSelector);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
57
|
this._onMoveHandleMouseDown = (e, _side) => {
|
|
121
58
|
const x = e.offsetX + e.target.offsetLeft + this.offsetLeft - this.table.totalHeaderWidth;
|
|
122
59
|
const y = e.offsetY + e.target.offsetTop + this.offsetTop - this.table.thead.clientHeight;
|
|
@@ -135,61 +72,9 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
135
72
|
this.startMoving(new grid_core_1.CellRange(c, r));
|
|
136
73
|
}
|
|
137
74
|
};
|
|
138
|
-
this._onResizeHandleMouseMove = (e) => {
|
|
139
|
-
if (e.buttons != 1)
|
|
140
|
-
this.stopResizing();
|
|
141
|
-
for (const elm of e.composedPath()) {
|
|
142
|
-
if (elm.tagName == 'TD') {
|
|
143
|
-
const td = elm;
|
|
144
|
-
const { c1, r1, c2, r2 } = this.selection.range;
|
|
145
|
-
const { r, c } = td;
|
|
146
|
-
const range = this.selection.range.clone();
|
|
147
|
-
switch (this._resizingDirection) {
|
|
148
|
-
case 'nw':
|
|
149
|
-
if (r <= r2 && c <= c2) {
|
|
150
|
-
range.r1 = r;
|
|
151
|
-
range.c1 = c;
|
|
152
|
-
}
|
|
153
|
-
break;
|
|
154
|
-
case 'ne':
|
|
155
|
-
if (r <= r2 && c >= c1) {
|
|
156
|
-
range.r1 = r;
|
|
157
|
-
range.c2 = c;
|
|
158
|
-
}
|
|
159
|
-
break;
|
|
160
|
-
case 'sw':
|
|
161
|
-
if (r >= r1 && c <= c2) {
|
|
162
|
-
range.r2 = r;
|
|
163
|
-
range.c1 = c;
|
|
164
|
-
}
|
|
165
|
-
break;
|
|
166
|
-
case 'se':
|
|
167
|
-
if (r >= r1 && c >= c1) {
|
|
168
|
-
range.r2 = r;
|
|
169
|
-
range.c2 = c;
|
|
170
|
-
}
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
if (!this.selection.range.equals(range)) {
|
|
174
|
-
this.selection.setRange(range);
|
|
175
|
-
this.updatePosition();
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
75
|
this._onResizeHandleMouseDown = (e, direction) => {
|
|
182
76
|
e.stopImmediatePropagation();
|
|
183
|
-
this.
|
|
184
|
-
this._resizingDirection = direction;
|
|
185
|
-
this.table.addEventListener('mousemove', this._onResizeHandleMouseMove);
|
|
186
|
-
const _mouseUp = (e) => {
|
|
187
|
-
if (e.button != 0)
|
|
188
|
-
return;
|
|
189
|
-
this.stopResizing();
|
|
190
|
-
this.table.removeEventListener('mouseup', _mouseUp);
|
|
191
|
-
};
|
|
192
|
-
this.table.addEventListener('mouseup', _mouseUp);
|
|
77
|
+
this.startResizing(direction);
|
|
193
78
|
};
|
|
194
79
|
this._onHandleMouseUp = (e) => {
|
|
195
80
|
if (e.button != 0)
|
|
@@ -197,38 +82,45 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
197
82
|
this.stopMoving();
|
|
198
83
|
this.stopResizing();
|
|
199
84
|
};
|
|
85
|
+
this._onHandleMouseDown = () => {
|
|
86
|
+
var _a;
|
|
87
|
+
this._autofilling = true;
|
|
88
|
+
this.autofillSelector = (_a = this.autofillSelector) !== null && _a !== void 0 ? _a : this.createAutofillSelector();
|
|
89
|
+
core_1.dom.hideElement(this.autofillSelector);
|
|
90
|
+
core_1.dom.appendElement(this.grid.shadowRoot, this.autofillSelector);
|
|
91
|
+
};
|
|
200
92
|
this.render = () => (0, lit_1.html) `
|
|
201
93
|
${this.subselector ? (0, lit_1.html) `<div id="subselector"></div>` : ''}
|
|
202
94
|
${this.resizable ? (0, lit_1.html) `
|
|
203
95
|
<div id="handle-nw" class="handle-resize" style="${(0, style_map_js_1.styleMap)({ backgroundColor: this.color })}"
|
|
204
|
-
@
|
|
205
|
-
@
|
|
96
|
+
@pointerdown="${(e) => this._onResizeHandleMouseDown(e, 'nw')}"
|
|
97
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
206
98
|
<div id="handle-ne" class="handle-resize" style="${(0, style_map_js_1.styleMap)({ backgroundColor: this.color })}"
|
|
207
|
-
@
|
|
208
|
-
@
|
|
99
|
+
@pointerdown="${(e) => this._onResizeHandleMouseDown(e, 'ne')}"
|
|
100
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
209
101
|
<div id="handle-sw" class="handle-resize" style="${(0, style_map_js_1.styleMap)({ backgroundColor: this.color })}"
|
|
210
|
-
@
|
|
211
|
-
@
|
|
102
|
+
@pointerdown="${(e) => this._onResizeHandleMouseDown(e, 'sw')}"
|
|
103
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
212
104
|
<div id="handle-se" class="handle-resize" style="${(0, style_map_js_1.styleMap)({ backgroundColor: this.color })}"
|
|
213
|
-
@
|
|
214
|
-
@
|
|
105
|
+
@pointerdown="${(e) => this._onResizeHandleMouseDown(e, 'se')}"
|
|
106
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
215
107
|
` : (this.autofill ? (0, lit_1.html) `
|
|
216
|
-
<div id="handle" @
|
|
108
|
+
<div id="handle" @pointerdown="${this._onHandleMouseDown}"></div>
|
|
217
109
|
` : '')}
|
|
218
110
|
|
|
219
111
|
${this.movable ? (0, lit_1.html) `
|
|
220
112
|
<div id="handle-top" class="handle-move"
|
|
221
|
-
@
|
|
222
|
-
@
|
|
113
|
+
@pointerdown="${(e) => this._onMoveHandleMouseDown(e, 'top')}"
|
|
114
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
223
115
|
<div id="handle-right" class="handle-move"
|
|
224
|
-
@
|
|
225
|
-
@
|
|
116
|
+
@pointerdown="${(e) => this._onMoveHandleMouseDown(e, 'right')}"
|
|
117
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
226
118
|
<div id="handle-bottom" class="handle-move"
|
|
227
|
-
@
|
|
228
|
-
@
|
|
119
|
+
@pointerdown="${(e) => this._onMoveHandleMouseDown(e, 'bottom')}"
|
|
120
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
229
121
|
<div id="handle-left" class="handle-move"
|
|
230
|
-
@
|
|
231
|
-
@
|
|
122
|
+
@pointerdown="${(e) => this._onMoveHandleMouseDown(e, 'left')}"
|
|
123
|
+
@pointerup="${this._onHandleMouseUp}"></div>
|
|
232
124
|
` : ''}
|
|
233
125
|
${this.animated ? (0, lit_1.html) `
|
|
234
126
|
<svg id="svgAnimation" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -237,16 +129,16 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
237
129
|
` : ''}
|
|
238
130
|
`;
|
|
239
131
|
}
|
|
240
|
-
get grid() { return this._grid; }
|
|
241
|
-
get selection() { return this._selection; }
|
|
242
|
-
get moving() { return this._moving; }
|
|
243
132
|
get autofillDirection() { return this._autofillDirection; }
|
|
244
133
|
get autofillRange() { return this._autofillRange; }
|
|
245
134
|
get isAutofilling() { return this._autofilling; }
|
|
246
135
|
get isMoving() { return this._moving; }
|
|
247
136
|
get isResizing() { return this._resizing; }
|
|
248
|
-
get
|
|
137
|
+
get isSelecting() { return this._selecting; }
|
|
138
|
+
get isSelectorOperationActive() { return this._resizing || this._moving || this._autofilling || this._selecting; }
|
|
139
|
+
get table() { var _a; return (_a = this.grid) === null || _a === void 0 ? void 0 : _a.table; }
|
|
249
140
|
get isVisible() { return this._isVisible; }
|
|
141
|
+
// #region Autofill
|
|
250
142
|
highlightAutofillRange() {
|
|
251
143
|
const tlCell = this.table.getCellByModelIndex(this._autofillRange.c1, this._autofillRange.r1);
|
|
252
144
|
const trCell = this.table.getCellByModelIndex(this._autofillRange.c2, this._autofillRange.r1);
|
|
@@ -288,43 +180,164 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
288
180
|
selector.style.pointerEvents = 'none';
|
|
289
181
|
return selector;
|
|
290
182
|
}
|
|
183
|
+
stopAutofilling(dispatchEvent = true) {
|
|
184
|
+
if (!this.isAutofilling)
|
|
185
|
+
return;
|
|
186
|
+
this._autofilling = false;
|
|
187
|
+
if (dispatchEvent)
|
|
188
|
+
this.dispatchEvent(new SelectorEvent('autofill', { selector: this }));
|
|
189
|
+
//this.autofillRange = null;
|
|
190
|
+
this.autofillSelector.remove();
|
|
191
|
+
}
|
|
192
|
+
updateAutofilling(c, r) {
|
|
193
|
+
const { c1, r1, c2, r2 } = this.selection;
|
|
194
|
+
this._autofillRange = null;
|
|
195
|
+
// down autofill
|
|
196
|
+
if (r > r2 && c - c2 <= r - r2) {
|
|
197
|
+
this._autofillDirection = 'down';
|
|
198
|
+
this._autofillRange = new grid_core_1.CellRange(c1, r2 + 1, c2, r);
|
|
199
|
+
}
|
|
200
|
+
// up autofill
|
|
201
|
+
else if (r < r1 && c1 - c <= r1 - r) {
|
|
202
|
+
this._autofillDirection = 'up';
|
|
203
|
+
this._autofillRange = new grid_core_1.CellRange(c1, r, c2, r1 - 1);
|
|
204
|
+
}
|
|
205
|
+
// right autofill
|
|
206
|
+
else if (c > c2 && c - c2 > r - r2) {
|
|
207
|
+
this._autofillDirection = 'right';
|
|
208
|
+
this._autofillRange = new grid_core_1.CellRange(c2 + 1, r1, c, r2);
|
|
209
|
+
}
|
|
210
|
+
// left autofill
|
|
211
|
+
else if (c < c1 && c1 - c > r1 - r) {
|
|
212
|
+
this._autofillDirection = 'left';
|
|
213
|
+
this._autofillRange = new grid_core_1.CellRange(c, r1, c1 - 1, r2);
|
|
214
|
+
}
|
|
215
|
+
if (this._autofillRange)
|
|
216
|
+
this.highlightAutofillRange();
|
|
217
|
+
}
|
|
218
|
+
// #endregion
|
|
219
|
+
// #region Selector moving
|
|
291
220
|
getMoveSelector() {
|
|
292
221
|
if (!this.moveSelector) {
|
|
293
222
|
this.moveSelector = core_1.dom.createElement('og-selector', this.grid.shadowRoot);
|
|
223
|
+
this.moveSelector.grid = this.grid;
|
|
294
224
|
this.moveSelector.style.borderStyle = 'dotted';
|
|
295
225
|
this.moveSelector.subselector = false;
|
|
296
|
-
this.moveSelector.
|
|
226
|
+
this.moveSelector.selection = this.selection.clone();
|
|
297
227
|
}
|
|
298
228
|
return this.moveSelector;
|
|
299
229
|
}
|
|
300
|
-
startMoving(
|
|
301
|
-
this.
|
|
230
|
+
startMoving(baseCell) {
|
|
231
|
+
this.baseCell = baseCell;
|
|
302
232
|
this._moving = true;
|
|
303
|
-
this.table.addEventListener('mousemove', this._onMoveHandleMouseMove);
|
|
304
|
-
this.table.addEventListener('mouseup', () => this.stopMoving(), { once: true });
|
|
305
233
|
}
|
|
306
|
-
|
|
234
|
+
updateMoving(c, r) {
|
|
235
|
+
c = this.selection.isRow ? 0 : c - this.baseCell.c1;
|
|
236
|
+
r = this.selection.isColumn ? 0 : r - this.baseCell.r1;
|
|
237
|
+
const moveSelector = this.getMoveSelector();
|
|
238
|
+
moveSelector.selection.setCoords(this.selection.c1 + c, this.selection.r1 + r, this.selection.c2 + c, this.selection.r2 + r);
|
|
239
|
+
moveSelector.select(moveSelector.selection);
|
|
240
|
+
core_1.dom.showElement(this.moveSelector);
|
|
241
|
+
}
|
|
242
|
+
stopMoving(dispatchEvent = true) {
|
|
307
243
|
if (!this._moving)
|
|
308
244
|
return;
|
|
309
245
|
this._moving = false;
|
|
310
246
|
core_1.dom.hideElement(this.moveSelector);
|
|
311
|
-
this.table.removeEventListener('mousemove', this._onMoveHandleMouseMove);
|
|
312
247
|
if (this.moveSelector) {
|
|
313
|
-
const fromRange = this.selection.
|
|
314
|
-
const toRange = this.moveSelector.selection.
|
|
248
|
+
const fromRange = this.selection.clone();
|
|
249
|
+
const toRange = this.moveSelector.selection.clone();
|
|
315
250
|
if (!fromRange.equals(toRange)) {
|
|
316
|
-
this.selection
|
|
317
|
-
|
|
318
|
-
|
|
251
|
+
this.selection = toRange;
|
|
252
|
+
if (dispatchEvent)
|
|
253
|
+
this.dispatchEvent(new SelectorMoveEvent({ fromRange, toRange, selector: this }));
|
|
319
254
|
}
|
|
320
255
|
}
|
|
321
256
|
}
|
|
322
|
-
|
|
257
|
+
// #endregion
|
|
258
|
+
// #region Selector resizing
|
|
259
|
+
startResizing(direction) {
|
|
260
|
+
this._resizing = true;
|
|
261
|
+
this._resizingDirection = direction;
|
|
262
|
+
}
|
|
263
|
+
updateResizing(c, r) {
|
|
264
|
+
const { c1, r1, c2, r2 } = this.selection;
|
|
265
|
+
const range = this.selection.clone();
|
|
266
|
+
switch (this._resizingDirection) {
|
|
267
|
+
case 'nw':
|
|
268
|
+
if (r <= r2 && c <= c2) {
|
|
269
|
+
range.r1 = r;
|
|
270
|
+
range.c1 = c;
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
case 'ne':
|
|
274
|
+
if (r <= r2 && c >= c1) {
|
|
275
|
+
range.r1 = r;
|
|
276
|
+
range.c2 = c;
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
case 'sw':
|
|
280
|
+
if (r >= r1 && c <= c2) {
|
|
281
|
+
range.r2 = r;
|
|
282
|
+
range.c1 = c;
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
case 'se':
|
|
286
|
+
if (r >= r1 && c >= c1) {
|
|
287
|
+
range.r2 = r;
|
|
288
|
+
range.c2 = c;
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
if (!this.selection.equals(range)) {
|
|
293
|
+
this.selection.r1 = range.r1;
|
|
294
|
+
this.selection.r2 = range.r2;
|
|
295
|
+
this.selection.c1 = range.c1;
|
|
296
|
+
this.selection.c2 = range.c2;
|
|
297
|
+
this.updatePosition();
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
stopResizing(dispatchEvent = true) {
|
|
323
301
|
if (!this._resizing)
|
|
324
302
|
return;
|
|
325
303
|
this._resizing = false;
|
|
326
|
-
|
|
327
|
-
|
|
304
|
+
if (dispatchEvent)
|
|
305
|
+
this.dispatchEvent(new SelectorEvent('resize', { selector: this }));
|
|
306
|
+
}
|
|
307
|
+
// #endregion
|
|
308
|
+
// #region Selecting
|
|
309
|
+
startSelecting(baseCell) {
|
|
310
|
+
this.baseCell = baseCell;
|
|
311
|
+
this._selecting = true;
|
|
312
|
+
this.select(baseCell);
|
|
313
|
+
}
|
|
314
|
+
select(selection, dispatchEvent = true) {
|
|
315
|
+
this.selection = selection.clone();
|
|
316
|
+
if (dispatchEvent)
|
|
317
|
+
this.dispatchEvent(new SelectorEvent('select', { selector: this }));
|
|
318
|
+
}
|
|
319
|
+
stopSelecting(_dispatchEvent = true) {
|
|
320
|
+
this._selecting = false;
|
|
321
|
+
this.baseCell = null;
|
|
322
|
+
}
|
|
323
|
+
// #endregion
|
|
324
|
+
/**
|
|
325
|
+
* Updates selector state after table moving events
|
|
326
|
+
* @param cell
|
|
327
|
+
*/
|
|
328
|
+
updateMovingOperations(c, r) {
|
|
329
|
+
if (this.isAutofilling)
|
|
330
|
+
this.updateAutofilling(c, r);
|
|
331
|
+
if (this.isMoving)
|
|
332
|
+
this.updateMoving(c, r);
|
|
333
|
+
if (this.isResizing)
|
|
334
|
+
this.updateResizing(c, r);
|
|
335
|
+
}
|
|
336
|
+
stopSelectorOperations(dispatchEvent = true) {
|
|
337
|
+
this.stopAutofilling(dispatchEvent);
|
|
338
|
+
this.stopMoving(dispatchEvent);
|
|
339
|
+
this.stopResizing(dispatchEvent);
|
|
340
|
+
this.stopSelecting(dispatchEvent);
|
|
328
341
|
}
|
|
329
342
|
startAnimation() {
|
|
330
343
|
if (!this.animated || this._animationTimer != null || !this.isVisible)
|
|
@@ -364,11 +377,11 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
364
377
|
let top = -1000, left = -1000, width = 0, height = 0;
|
|
365
378
|
let subTop = -1000, subLeft = -1000, subWidth = 0, subHeight = 0;
|
|
366
379
|
const options = this.table.model.options;
|
|
367
|
-
if (this.selection
|
|
368
|
-
const cMin = Math.min(this.selection.
|
|
369
|
-
const cMax = Math.max(this.selection.
|
|
370
|
-
const rMin = Math.min(this.selection.
|
|
371
|
-
const rMax = Math.max(this.selection.
|
|
380
|
+
if (this.selection) {
|
|
381
|
+
const cMin = Math.min(this.selection.c1, this.selection.c2);
|
|
382
|
+
const cMax = Math.max(this.selection.c1, this.selection.c2);
|
|
383
|
+
const rMin = Math.min(this.selection.r1, this.selection.r2);
|
|
384
|
+
const rMax = Math.max(this.selection.r1, this.selection.r2);
|
|
372
385
|
this.topLeftCell = this.table.getCellByModelIndex(cMin, rMin);
|
|
373
386
|
this.topRightCell = this.table.getCellByModelIndex(cMax, rMin);
|
|
374
387
|
this.bottomLeftCell = this.table.getCellByModelIndex(cMin, rMax);
|
|
@@ -396,8 +409,8 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
396
409
|
: (cMax <= this.table.colOffset
|
|
397
410
|
? (core_1.dom.getElementOffset(this.table.getCellByGridIndex(options.freezeLeft, 0), this.table).left - left)
|
|
398
411
|
: this.table.offsetWidth - left)) + 1;
|
|
399
|
-
if (this.
|
|
400
|
-
this.activeCell = this.table.getCellByModelIndex(cMin + this.
|
|
412
|
+
if (this.activeCellRange) {
|
|
413
|
+
this.activeCell = this.table.getCellByModelIndex(cMin + this.activeCellRange.c1, rMin + this.activeCellRange.r1);
|
|
401
414
|
if (this.activeCell) {
|
|
402
415
|
const subOffset = core_1.dom.getElementOffset(this.activeCell, this.table);
|
|
403
416
|
subLeft = subOffset.left - left;
|
|
@@ -411,7 +424,7 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
411
424
|
core_1.dom.setPosition(this, { l: left * zoom, t: top * zoom });
|
|
412
425
|
core_1.dom.setSize(this, { w: width, h: height });
|
|
413
426
|
if (this.subselectorElm) {
|
|
414
|
-
if (this.
|
|
427
|
+
if (this.activeCellRange) {
|
|
415
428
|
core_1.dom.setPosition(this.subselectorElm, { l: subLeft - constants_1.default.SELECTOR_BORDER_WIDTH, t: subTop - constants_1.default.SELECTOR_BORDER_WIDTH });
|
|
416
429
|
core_1.dom.setSize(this.subselectorElm, { w: subWidth - 1, h: subHeight - 1 });
|
|
417
430
|
}
|
|
@@ -424,17 +437,6 @@ let Selector = class Selector extends lit_1.LitElement {
|
|
|
424
437
|
this.svgAnimation.setAttribute('height', (this.clientHeight + 4).toString());
|
|
425
438
|
}
|
|
426
439
|
}
|
|
427
|
-
select(selection, grid, dispatchEvent = true) {
|
|
428
|
-
if (selection) {
|
|
429
|
-
selection.activeCell.c1 = 0;
|
|
430
|
-
selection.activeCell.r1 = 0;
|
|
431
|
-
}
|
|
432
|
-
this._selection = selection;
|
|
433
|
-
this._grid = grid;
|
|
434
|
-
this.updatePosition();
|
|
435
|
-
if (dispatchEvent)
|
|
436
|
-
this.dispatchEvent(new SelectorEvent('select', { selector: this }));
|
|
437
|
-
}
|
|
438
440
|
};
|
|
439
441
|
exports.Selector = Selector;
|
|
440
442
|
Selector.styles = [selector_style_1.style];
|
|
@@ -459,6 +461,15 @@ __decorate([
|
|
|
459
461
|
__decorate([
|
|
460
462
|
(0, decorators_js_1.property)({ type: Boolean, reflect: true })
|
|
461
463
|
], Selector.prototype, "animated", void 0);
|
|
464
|
+
__decorate([
|
|
465
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
466
|
+
], Selector.prototype, "selection", void 0);
|
|
467
|
+
__decorate([
|
|
468
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
469
|
+
], Selector.prototype, "activeCellRange", void 0);
|
|
470
|
+
__decorate([
|
|
471
|
+
(0, decorators_js_1.property)({ type: Object })
|
|
472
|
+
], Selector.prototype, "grid", void 0);
|
|
462
473
|
__decorate([
|
|
463
474
|
(0, decorators_js_1.query)('#handle')
|
|
464
475
|
], Selector.prototype, "handleElm", void 0);
|