@revolist/revogrid 4.0.11 → 4.0.12
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/cjs/{column.service-e83d9809.js → column.service-bc269420.js} +23 -9
- package/dist/cjs/column.service-bc269420.js.map +1 -0
- package/dist/cjs/{events-7ccd6894.js → events-f8893bba.js} +15 -5
- package/dist/cjs/events-f8893bba.js.map +1 -0
- package/dist/cjs/{header-cell-renderer-8ba9b56d.js → header-cell-renderer-57acd2f7.js} +2 -2
- package/dist/cjs/{header-cell-renderer-8ba9b56d.js.map → header-cell-renderer-57acd2f7.js.map} +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +29 -13
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-attribution_6.cjs.entry.js +176 -126
- package/dist/cjs/revogr-attribution_6.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +2 -2
- package/dist/collection/components/data/column.service.js.map +1 -1
- package/dist/collection/components/data/revogr-data.js +1 -1
- package/dist/collection/components/editors/revogr-edit.js +1 -1
- package/dist/collection/components/order/revogr-order-editor.js +4 -1
- package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
- package/dist/collection/components/overlay/autofill.service.js +36 -24
- package/dist/collection/components/overlay/autofill.service.js.map +1 -1
- package/dist/collection/components/overlay/keyboard.service.js +7 -7
- package/dist/collection/components/overlay/keyboard.service.js.map +1 -1
- package/dist/collection/components/overlay/revogr-overlay-selection.js +107 -59
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
- package/dist/collection/components/overlay/selection.utils.js +37 -9
- package/dist/collection/components/overlay/selection.utils.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid-style.css +8 -3
- package/dist/collection/components/revoGrid/revo-grid.js +26 -11
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/components/revoGrid/viewport.helpers.js +22 -8
- package/dist/collection/components/revoGrid/viewport.helpers.js.map +1 -1
- package/dist/collection/components/revoGrid/viewport.service.js +1 -0
- package/dist/collection/components/revoGrid/viewport.service.js.map +1 -1
- package/dist/collection/serve/controller.js +86 -18
- package/dist/collection/store/selection/index.js +0 -1
- package/dist/collection/store/selection/index.js.map +1 -1
- package/dist/collection/types/interfaces.js +4 -0
- package/dist/collection/types/interfaces.js.map +1 -1
- package/dist/collection/utils/events.js +11 -1
- package/dist/collection/utils/events.js.map +1 -1
- package/dist/collection/utils/row-header-utils.js +2 -2
- package/dist/collection/utils/row-header-utils.js.map +1 -1
- package/dist/esm/{column.service-f4922a8d.js → column.service-195345ab.js} +23 -9
- package/dist/esm/column.service-195345ab.js.map +1 -0
- package/dist/esm/{events-3dd8ee7c.js → events-3e39de50.js} +15 -5
- package/dist/esm/events-3e39de50.js.map +1 -0
- package/dist/esm/{header-cell-renderer-ac962570.js → header-cell-renderer-7c76465d.js} +2 -2
- package/dist/esm/{header-cell-renderer-ac962570.js.map → header-cell-renderer-7c76465d.js.map} +1 -1
- package/dist/esm/revo-grid.entry.js +29 -13
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revogr-attribution_6.entry.js +176 -126
- package/dist/esm/revogr-attribution_6.entry.js.map +1 -1
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/revogr-data_4.entry.js +2 -2
- package/dist/revo-grid/column.service-195345ab.js +5 -0
- package/dist/revo-grid/column.service-195345ab.js.map +1 -0
- package/dist/revo-grid/{events-3dd8ee7c.js → events-3e39de50.js} +2 -2
- package/dist/revo-grid/events-3e39de50.js.map +1 -0
- package/dist/revo-grid/{header-cell-renderer-ac962570.js → header-cell-renderer-7c76465d.js} +2 -2
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_6.entry.js +1 -1
- package/dist/revo-grid/revogr-attribution_6.entry.js.map +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +1 -1
- package/dist/types/components/data/column.service.d.ts +2 -2
- package/dist/types/components/order/revogr-order-editor.d.ts +3 -0
- package/dist/types/components/overlay/autofill.service.d.ts +9 -6
- package/dist/types/components/overlay/keyboard.service.d.ts +2 -3
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +38 -15
- package/dist/types/components/overlay/selection.utils.d.ts +12 -4
- package/dist/types/components/revoGrid/revo-grid.d.ts +4 -1
- package/dist/types/components/revoGrid/viewport.helpers.d.ts +11 -2
- package/dist/types/components.d.ts +26 -2
- package/dist/types/store/selection/index.d.ts +0 -1
- package/dist/types/types/interfaces.d.ts +444 -23
- package/dist/types/utils/events.d.ts +4 -1
- package/dist/types/utils/row-header-utils.d.ts +1 -1
- package/hydrate/index.js +265 -169
- package/package.json +5 -6
- package/standalone/column.service.js.map +1 -1
- package/standalone/revo-grid.js +28 -11
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-focus2.js +1 -1
- package/standalone/revogr-order-editor2.js.map +1 -1
- package/standalone/revogr-overlay-selection2.js +140 -143
- package/standalone/revogr-overlay-selection2.js.map +1 -1
- package/standalone/revogr-row-headers2.js +2 -2
- package/standalone/revogr-row-headers2.js.map +1 -1
- package/standalone/revogr-temp-range2.js +1 -1
- package/standalone/revogr-viewport-scroll2.js +22 -8
- package/standalone/revogr-viewport-scroll2.js.map +1 -1
- package/standalone/selection.utils.js +72 -9
- package/standalone/selection.utils.js.map +1 -1
- package/dist/cjs/column.service-e83d9809.js.map +0 -1
- package/dist/cjs/events-7ccd6894.js.map +0 -1
- package/dist/collection/store/selection/selection.store.service.js +0 -39
- package/dist/collection/store/selection/selection.store.service.js.map +0 -1
- package/dist/esm/column.service-f4922a8d.js.map +0 -1
- package/dist/esm/events-3dd8ee7c.js.map +0 -1
- package/dist/revo-grid/column.service-f4922a8d.js +0 -5
- package/dist/revo-grid/column.service-f4922a8d.js.map +0 -1
- package/dist/revo-grid/events-3dd8ee7c.js.map +0 -1
- package/dist/types/store/selection/selection.store.service.d.ts +0 -17
- /package/dist/revo-grid/{header-cell-renderer-ac962570.js.map → header-cell-renderer-7c76465d.js.map} +0 -0
|
@@ -4,50 +4,15 @@
|
|
|
4
4
|
import { r as registerInstance, h, H as Host, c as createEvent, a as getElement } from './index-21436631.js';
|
|
5
5
|
import { F as FOCUS_CLASS, t as timeout, R as RESIZE_INTERVAL, a as CELL_HANDLER_CLASS, M as MOBILE_CLASS, S as SELECTION_BORDER_CLASS, b as ROW_HEADER_TYPE, g as getScrollbarSize, T as TMP_SELECTION_BG_CLASS } from './index-98fd0168.js';
|
|
6
6
|
import { i as getItemByPosition, j as getItemByIndex, b as getSourceItem, D as DataStore } from './dimension.helpers-a3065cb1.js';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { g as getPropertyFromEvent, v as verifyTouchTarget, V as ViewportStore, c as calculateRowHeaderSize } from './events-3e39de50.js';
|
|
8
|
+
import { n as ColumnService, H as HEADER_SLOT } from './column.service-195345ab.js';
|
|
9
9
|
import { c as codesLetter, i as isClear, a as isEnterKey, b as isCopy, d as isCut, e as isPaste, f as isAll, g as isLetterKey, h as isEditInput } from './key.utils-2836e8ae.js';
|
|
10
|
+
import { g as getRange, a as isRangeSingleCell } from './selection.store-2577ddf9.js';
|
|
10
11
|
import { d as debounce_1 } from './debounce-7781346d.js';
|
|
11
|
-
import { g as getFromEvent, v as verifyTouchTarget, V as ViewportStore, c as calculateRowHeaderSize } from './events-3dd8ee7c.js';
|
|
12
12
|
import { L as LocalScrollTimer, a as LocalScrollService, g as getContentSize, t as throttle_1 } from './throttle-cfd527d6.js';
|
|
13
13
|
import './toNumber-8de324a7.js';
|
|
14
14
|
import './viewport.helpers-6591d423.js';
|
|
15
15
|
|
|
16
|
-
class SelectionStoreService {
|
|
17
|
-
constructor(store, config) {
|
|
18
|
-
this.store = store;
|
|
19
|
-
this.config = config;
|
|
20
|
-
this.store = store;
|
|
21
|
-
}
|
|
22
|
-
get edited() {
|
|
23
|
-
return this.store.get('edit');
|
|
24
|
-
}
|
|
25
|
-
get focused() {
|
|
26
|
-
return this.store.get('focus');
|
|
27
|
-
}
|
|
28
|
-
get ranged() {
|
|
29
|
-
return this.store.get('range');
|
|
30
|
-
}
|
|
31
|
-
changeRange(range) {
|
|
32
|
-
return this.config.changeRange(range);
|
|
33
|
-
}
|
|
34
|
-
focus(cell, isMulti = false) {
|
|
35
|
-
if (!cell) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
let end = cell;
|
|
39
|
-
// range edit
|
|
40
|
-
if (isMulti) {
|
|
41
|
-
let start = this.store.get('focus');
|
|
42
|
-
if (start) {
|
|
43
|
-
return this.config.changeRange(getRange(start, end));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// single focus
|
|
47
|
-
return this.config.focus(cell, end);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
16
|
const Attribution = class {
|
|
52
17
|
constructor(hostRef) {
|
|
53
18
|
registerInstance(this, hostRef);
|
|
@@ -57,26 +22,50 @@ const Attribution = class {
|
|
|
57
22
|
}
|
|
58
23
|
};
|
|
59
24
|
|
|
60
|
-
|
|
25
|
+
function getFocusCellBasedOnEvent(e, data) {
|
|
26
|
+
// If event default is prevented, return
|
|
27
|
+
if (e.defaultPrevented) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
// Get coordinates from event object
|
|
31
|
+
const x = getPropertyFromEvent(e, 'clientX');
|
|
32
|
+
const y = getPropertyFromEvent(e, 'clientY');
|
|
33
|
+
// If coordinates are not available, return
|
|
34
|
+
if (x === null || y === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
// Get current cell based on coordinates and data
|
|
38
|
+
const focusCell = getCurrentCell({ x, y }, data);
|
|
39
|
+
// If current cell is not available, return
|
|
40
|
+
if (isAfterLast(focusCell, data.lastCell)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return focusCell;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Calculate cell based on x, y position
|
|
47
|
+
*/
|
|
61
48
|
function getCurrentCell({ x, y }, { el, rows, cols }) {
|
|
49
|
+
// Get the bounding rectangle of the element
|
|
62
50
|
const { top, left, height, width } = el.getBoundingClientRect();
|
|
51
|
+
// Calculate the cell position relative to the element
|
|
63
52
|
let cellY = y - top;
|
|
64
|
-
|
|
53
|
+
let cellX = x - left;
|
|
54
|
+
// Limit the cell position to the element height
|
|
65
55
|
if (cellY >= height) {
|
|
66
56
|
cellY = height - 1;
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
// limit to element width
|
|
58
|
+
// Limit the cell position to the element width
|
|
70
59
|
if (cellX >= width) {
|
|
71
60
|
cellX = width - 1;
|
|
72
61
|
}
|
|
62
|
+
// Get the row and column items based on the cell position
|
|
73
63
|
const rgRow = getItemByPosition(rows, cellY);
|
|
74
64
|
const rgCol = getItemByPosition(cols, cellX);
|
|
75
|
-
// before first
|
|
65
|
+
// Set the row and column index to 0 if they are before the first item
|
|
76
66
|
if (rgCol.itemIndex < 0) {
|
|
77
67
|
rgCol.itemIndex = 0;
|
|
78
68
|
}
|
|
79
|
-
// before first
|
|
80
69
|
if (rgRow.itemIndex < 0) {
|
|
81
70
|
rgRow.itemIndex = 0;
|
|
82
71
|
}
|
|
@@ -98,8 +87,11 @@ function getCoordinate(range, focus, changes, isMulti = false) {
|
|
|
98
87
|
}
|
|
99
88
|
return null;
|
|
100
89
|
}
|
|
101
|
-
/**
|
|
102
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Check if the x coordinate of the cell position is after or equal to the x coordinate of the last cell position
|
|
92
|
+
* or if the y coordinate of the cell position is after or equal to the y coordinate of the last cell position
|
|
93
|
+
*/
|
|
94
|
+
function isAfterLast({ x, y }, lastCell) {
|
|
103
95
|
return x >= lastCell.x || y >= lastCell.y;
|
|
104
96
|
}
|
|
105
97
|
/** check if out of range */
|
|
@@ -240,9 +232,9 @@ class KeyboardService {
|
|
|
240
232
|
constructor(sv) {
|
|
241
233
|
this.sv = sv;
|
|
242
234
|
}
|
|
243
|
-
async keyDown(e, canRange) {
|
|
235
|
+
async keyDown(e, canRange, isEditMode, { range, focus }) {
|
|
244
236
|
// IF EDIT MODE
|
|
245
|
-
if (
|
|
237
|
+
if (isEditMode) {
|
|
246
238
|
switch (e.code) {
|
|
247
239
|
case codesLetter.ESCAPE:
|
|
248
240
|
this.sv.cancel();
|
|
@@ -252,12 +244,12 @@ class KeyboardService {
|
|
|
252
244
|
}
|
|
253
245
|
// IF NOT EDIT MODE
|
|
254
246
|
// pressed clear key
|
|
255
|
-
if (
|
|
247
|
+
if (range && isClear(e.code)) {
|
|
256
248
|
this.sv.clearCell();
|
|
257
249
|
return;
|
|
258
250
|
}
|
|
259
251
|
// below works with focus only
|
|
260
|
-
if (!
|
|
252
|
+
if (!focus) {
|
|
261
253
|
return;
|
|
262
254
|
}
|
|
263
255
|
// tab key means same as arrow right
|
|
@@ -333,7 +325,7 @@ class KeyboardService {
|
|
|
333
325
|
}
|
|
334
326
|
if (isMulti) {
|
|
335
327
|
const eData = this.sv.getData();
|
|
336
|
-
if (isAfterLast(data.end, eData) || isBeforeFirst(data.start)) {
|
|
328
|
+
if (isAfterLast(data.end, eData.lastCell) || isBeforeFirst(data.start)) {
|
|
337
329
|
return false;
|
|
338
330
|
}
|
|
339
331
|
const range = getRange(data.start, data.end);
|
|
@@ -385,7 +377,10 @@ class AutoFillService {
|
|
|
385
377
|
return (h("div", { class: {
|
|
386
378
|
[CELL_HANDLER_CLASS]: true,
|
|
387
379
|
[MOBILE_CLASS]: true,
|
|
388
|
-
}, style: {
|
|
380
|
+
}, style: {
|
|
381
|
+
left: `${handlerStyle.right}px`,
|
|
382
|
+
top: `${handlerStyle.bottom}px`,
|
|
383
|
+
}, onMouseDown: (e) => this.autoFillHandler(e), onTouchStart: (e) => this.autoFillHandler(e) }));
|
|
389
384
|
}
|
|
390
385
|
autoFillHandler(e, type = "AutoFill" /* AutoFillType.autoFill */) {
|
|
391
386
|
let target = null;
|
|
@@ -401,7 +396,9 @@ class AutoFillService {
|
|
|
401
396
|
get isAutoFill() {
|
|
402
397
|
return !!this.autoFillType;
|
|
403
398
|
}
|
|
404
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Process mouse move events
|
|
401
|
+
*/
|
|
405
402
|
selectionMouseMove(e) {
|
|
406
403
|
// initiate mouse move debounce if not present
|
|
407
404
|
if (!this.onMouseMoveAutofill) {
|
|
@@ -411,9 +408,7 @@ class AutoFillService {
|
|
|
411
408
|
this.onMouseMoveAutofill(e, this.sv.getData());
|
|
412
409
|
}
|
|
413
410
|
}
|
|
414
|
-
getFocus() {
|
|
415
|
-
let focus = this.sv.selectionStoreService.focused;
|
|
416
|
-
const range = this.sv.selectionStoreService.ranged;
|
|
411
|
+
getFocus(focus, range) {
|
|
417
412
|
// there was an issue that it was taking last cell from range but focus was out
|
|
418
413
|
if (!focus && range) {
|
|
419
414
|
focus = { x: range.x, y: range.y };
|
|
@@ -429,8 +424,8 @@ class AutoFillService {
|
|
|
429
424
|
if (!this.autoFillInitial) {
|
|
430
425
|
return;
|
|
431
426
|
}
|
|
432
|
-
const x =
|
|
433
|
-
const y =
|
|
427
|
+
const x = getPropertyFromEvent(event, 'clientX', MOBILE_CLASS);
|
|
428
|
+
const y = getPropertyFromEvent(event, 'clientY', MOBILE_CLASS);
|
|
434
429
|
// skip touch
|
|
435
430
|
if (x === null || y === null) {
|
|
436
431
|
return;
|
|
@@ -443,11 +438,12 @@ class AutoFillService {
|
|
|
443
438
|
}
|
|
444
439
|
}
|
|
445
440
|
// check if not the latest, if latest - do nothing
|
|
446
|
-
if (isAfterLast(current, data)) {
|
|
441
|
+
if (isAfterLast(current, data.lastCell)) {
|
|
447
442
|
return;
|
|
448
443
|
}
|
|
449
444
|
this.autoFillLast = current;
|
|
450
|
-
const isSame = current.x === this.autoFillInitial.x &&
|
|
445
|
+
const isSame = current.x === this.autoFillInitial.x &&
|
|
446
|
+
current.y === this.autoFillInitial.y;
|
|
451
447
|
// if same as initial - clear
|
|
452
448
|
if (isSame) {
|
|
453
449
|
this.sv.setTempRange(null);
|
|
@@ -468,39 +464,48 @@ class AutoFillService {
|
|
|
468
464
|
selectionStart(target, data, type = "Selection" /* AutoFillType.selection */) {
|
|
469
465
|
/** Get cell by autofill element */
|
|
470
466
|
const { top, left } = target.getBoundingClientRect();
|
|
471
|
-
this.autoFillInitial = this.getFocus();
|
|
467
|
+
this.autoFillInitial = this.getFocus(data.focus, data.range);
|
|
472
468
|
this.autoFillType = type;
|
|
473
469
|
this.autoFillStart = getCurrentCell({ x: left, y: top }, data);
|
|
474
470
|
}
|
|
475
471
|
/**
|
|
476
|
-
* Clear current range selection
|
|
477
|
-
* on mouse up and mouse leave events
|
|
472
|
+
* Clear current range selection on mouse up and mouse leave events
|
|
478
473
|
*/
|
|
479
|
-
clearAutoFillSelection() {
|
|
480
|
-
//
|
|
474
|
+
clearAutoFillSelection(focus, oldRange) {
|
|
475
|
+
// If autofill was active, apply autofill values
|
|
481
476
|
if (this.autoFillInitial) {
|
|
482
|
-
//
|
|
483
|
-
this.autoFillInitial = this.getFocus();
|
|
484
|
-
// Apply range data if
|
|
477
|
+
// Fetch latest focus
|
|
478
|
+
this.autoFillInitial = this.getFocus(focus, oldRange);
|
|
479
|
+
// Apply range data if autofill mode is active
|
|
485
480
|
if (this.autoFillType === "AutoFill" /* AutoFillType.autoFill */) {
|
|
486
481
|
const range = getRange(this.autoFillInitial, this.autoFillLast);
|
|
482
|
+
// If range is present, apply data
|
|
487
483
|
if (range) {
|
|
488
|
-
const { defaultPrevented: stopApply, detail: { range: newRange } } = this.sv.clearRangeDataApply({
|
|
484
|
+
const { defaultPrevented: stopApply, detail: { range: newRange }, } = this.sv.clearRangeDataApply({
|
|
489
485
|
range,
|
|
490
486
|
});
|
|
487
|
+
// If data apply was not prevented, apply new range
|
|
491
488
|
if (!stopApply) {
|
|
492
|
-
this.applyRangeWithData(newRange);
|
|
489
|
+
this.applyRangeWithData(newRange, oldRange);
|
|
493
490
|
}
|
|
494
491
|
else {
|
|
495
|
-
//
|
|
492
|
+
// If data apply was prevented, clear temporary range
|
|
496
493
|
this.sv.setTempRange(null);
|
|
497
494
|
}
|
|
498
495
|
}
|
|
499
496
|
}
|
|
500
497
|
else {
|
|
498
|
+
// If not autofill mode, apply range only
|
|
501
499
|
this.applyRangeOnly(this.autoFillInitial, this.autoFillLast);
|
|
502
500
|
}
|
|
503
501
|
}
|
|
502
|
+
// Reset autofill state
|
|
503
|
+
this.resetAutoFillState();
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Reset autofill state
|
|
507
|
+
*/
|
|
508
|
+
resetAutoFillState() {
|
|
504
509
|
this.autoFillType = null;
|
|
505
510
|
this.autoFillInitial = null;
|
|
506
511
|
this.autoFillLast = null;
|
|
@@ -520,8 +525,7 @@ class AutoFillService {
|
|
|
520
525
|
this.sv.setRange(range);
|
|
521
526
|
}
|
|
522
527
|
/** Apply range and copy data during range application */
|
|
523
|
-
applyRangeWithData(newRange) {
|
|
524
|
-
const oldRange = this.sv.selectionStoreService.ranged;
|
|
528
|
+
applyRangeWithData(newRange, oldRange) {
|
|
525
529
|
const rangeData = {
|
|
526
530
|
type: this.sv.dataStore.get('type'),
|
|
527
531
|
colType: this.sv.columnService.type,
|
|
@@ -610,44 +614,60 @@ const OverlaySelection = class {
|
|
|
610
614
|
// #endregion
|
|
611
615
|
// #region Listeners
|
|
612
616
|
onMouseMove(e) {
|
|
613
|
-
if (this.
|
|
617
|
+
if (this.selectionStore.get('focus')) {
|
|
614
618
|
this.autoFillService.selectionMouseMove(e);
|
|
615
619
|
}
|
|
616
620
|
}
|
|
617
|
-
/**
|
|
618
|
-
|
|
621
|
+
/**
|
|
622
|
+
* Action finished inside of the document.
|
|
623
|
+
* Pointer left document, clear any active operation.
|
|
624
|
+
*/
|
|
619
625
|
onMouseUp() {
|
|
620
|
-
|
|
626
|
+
// Clear auto fill selection
|
|
627
|
+
// when pointer left document,
|
|
628
|
+
// clear any active operation.
|
|
629
|
+
this.autoFillService.clearAutoFillSelection(this.selectionStore.get('focus'), this.selectionStore.get('range'));
|
|
621
630
|
}
|
|
622
|
-
/**
|
|
631
|
+
/**
|
|
632
|
+
* Row drag started.
|
|
633
|
+
* This event is fired when drag action started on cell.
|
|
634
|
+
*/
|
|
623
635
|
onCellDrag(e) {
|
|
624
636
|
var _a;
|
|
637
|
+
// Invoke drag start on order editor.
|
|
625
638
|
(_a = this.orderEditor) === null || _a === void 0 ? void 0 : _a.dragStart(e.detail);
|
|
626
639
|
}
|
|
627
|
-
/**
|
|
640
|
+
/**
|
|
641
|
+
* Get keyboard down from element.
|
|
642
|
+
* This event is fired when keyboard key is released.
|
|
643
|
+
*/
|
|
628
644
|
onKeyUp(e) {
|
|
645
|
+
// Emit before key up event.
|
|
629
646
|
this.beforeKeyUp.emit(e);
|
|
630
647
|
}
|
|
631
|
-
/**
|
|
648
|
+
/**
|
|
649
|
+
* Get keyboard down from element.
|
|
650
|
+
* This event is fired when keyboard key is pressed.
|
|
651
|
+
*/
|
|
632
652
|
onKeyDown(e) {
|
|
633
653
|
var _a;
|
|
654
|
+
// Emit before key down event and check if default prevention is set.
|
|
634
655
|
const proxy = this.beforeKeyDown.emit(e);
|
|
635
656
|
if (e.defaultPrevented || proxy.defaultPrevented) {
|
|
636
657
|
return;
|
|
637
658
|
}
|
|
638
|
-
|
|
659
|
+
// Invoke key down on keyboard service.
|
|
660
|
+
(_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyDown(e, this.range, !!this.selectionStore.get('edit'), {
|
|
661
|
+
focus: this.selectionStore.get('focus'),
|
|
662
|
+
range: this.selectionStore.get('range'),
|
|
663
|
+
});
|
|
639
664
|
}
|
|
640
665
|
// #endregion
|
|
641
666
|
/** Selection & Keyboard */
|
|
642
667
|
selectionServiceSet(s) {
|
|
643
|
-
this.selectionStoreService = new SelectionStoreService(s, {
|
|
644
|
-
changeRange: range => this.triggerRangeEvent(range),
|
|
645
|
-
focus: (focus, end) => this.doFocus(focus, end),
|
|
646
|
-
});
|
|
647
668
|
this.keyboardService = new KeyboardService({
|
|
648
|
-
selectionStoreService: this.selectionStoreService,
|
|
649
669
|
selectionStore: s,
|
|
650
|
-
range: r => this.
|
|
670
|
+
range: r => this.triggerRangeEvent(r),
|
|
651
671
|
focusNext: (f, next) => this.doFocus(f, f, next),
|
|
652
672
|
change: val => {
|
|
653
673
|
if (this.readonly) {
|
|
@@ -669,7 +689,6 @@ const OverlaySelection = class {
|
|
|
669
689
|
/** Autofill */
|
|
670
690
|
createAutoFillService() {
|
|
671
691
|
this.autoFillService = new AutoFillService({
|
|
672
|
-
selectionStoreService: this.selectionStoreService,
|
|
673
692
|
dimensionRow: this.dimensionRow,
|
|
674
693
|
dimensionCol: this.dimensionCol,
|
|
675
694
|
columnService: this.columnService,
|
|
@@ -745,10 +764,10 @@ const OverlaySelection = class {
|
|
|
745
764
|
nodes.push(editCell);
|
|
746
765
|
}
|
|
747
766
|
else {
|
|
748
|
-
const range = this.
|
|
749
|
-
const
|
|
767
|
+
const range = this.selectionStore.get('range');
|
|
768
|
+
const focus = this.selectionStore.get('focus');
|
|
750
769
|
// Clipboard
|
|
751
|
-
if ((range ||
|
|
770
|
+
if ((range || focus) && this.useClipboard) {
|
|
752
771
|
nodes.push(h("revogr-clipboard", { readonly: this.readonly, onCopyregion: e => this.onCopy(e.detail), onClearregion: () => !this.readonly && this.clearCell(), ref: e => (this.clipboard = e), onPasteregion: e => this.onPaste(e.detail) }));
|
|
753
772
|
}
|
|
754
773
|
// Range
|
|
@@ -756,23 +775,19 @@ const OverlaySelection = class {
|
|
|
756
775
|
nodes.push(...this.renderRange(range));
|
|
757
776
|
}
|
|
758
777
|
// Autofill
|
|
759
|
-
if (
|
|
760
|
-
nodes.push(this.autoFillService.renderAutofill(range,
|
|
778
|
+
if (focus && !this.readonly && this.range) {
|
|
779
|
+
nodes.push(this.autoFillService.renderAutofill(range, focus));
|
|
761
780
|
}
|
|
762
781
|
// Order
|
|
763
782
|
if (this.canDrag) {
|
|
764
783
|
nodes.push(h("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, onRowdragstartinit: e => this.rowDragStart(e) }));
|
|
765
784
|
}
|
|
766
785
|
}
|
|
767
|
-
return (h(Host, { key: '
|
|
768
|
-
// Open Editor on DblClick
|
|
769
|
-
onDblClick: (e) => {
|
|
770
|
-
// DblClick prevented outside - Editor will not open
|
|
771
|
-
if (!e.defaultPrevented) {
|
|
772
|
-
this.doEdit();
|
|
773
|
-
}
|
|
774
|
-
}, onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, h("slot", { key: '89b9bec7824739ea11fadeecbf3908ac74e85c96', name: "data" })));
|
|
786
|
+
return (h(Host, { key: '9dbb6247aebf4ad00c1c8c78852191671be33a11', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, h("slot", { key: '7769092a5029c5a49da8c2d6f36eb9f17b461bc2', name: "data" })));
|
|
775
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* Executes the focus operation on the specified range of cells.
|
|
790
|
+
*/
|
|
776
791
|
doFocus(focus, end, next) {
|
|
777
792
|
const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
|
|
778
793
|
if (defaultPrevented) {
|
|
@@ -806,31 +821,48 @@ const OverlaySelection = class {
|
|
|
806
821
|
}
|
|
807
822
|
return !e.defaultPrevented;
|
|
808
823
|
}
|
|
824
|
+
/**
|
|
825
|
+
* Open Editor on DblClick
|
|
826
|
+
*/
|
|
827
|
+
onElementDblClick(e) {
|
|
828
|
+
// DblClick prevented outside - Editor will not open
|
|
829
|
+
// Get data from the component
|
|
830
|
+
const data = this.getData();
|
|
831
|
+
const focusCell = getFocusCellBasedOnEvent(e, data);
|
|
832
|
+
if (!focusCell) {
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
this.doEdit();
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Handle mouse down event on Host element
|
|
839
|
+
*/
|
|
809
840
|
onElementMouseDown(e, touch = false) {
|
|
841
|
+
// Get the target element from the event object
|
|
842
|
+
const targetElement = e.target;
|
|
810
843
|
// Ignore focus if clicked input
|
|
811
|
-
if (isEditInput(
|
|
844
|
+
if (isEditInput(targetElement)) {
|
|
812
845
|
return;
|
|
813
846
|
}
|
|
847
|
+
// Get data from the component
|
|
814
848
|
const data = this.getData();
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
const x = getFromEvent(e, 'clientX');
|
|
819
|
-
const y = getFromEvent(e, 'clientY');
|
|
820
|
-
// skip touch
|
|
821
|
-
if (x === null || y === null) {
|
|
849
|
+
const focusCell = getFocusCellBasedOnEvent(e, data);
|
|
850
|
+
if (!focusCell) {
|
|
822
851
|
return;
|
|
823
852
|
}
|
|
824
|
-
//
|
|
825
|
-
|
|
826
|
-
this.selectionStoreService.focus(focusCell, this.range && e.shiftKey);
|
|
853
|
+
// Set focus on the current cell
|
|
854
|
+
this.focus(focusCell, this.range && e.shiftKey);
|
|
827
855
|
// Initiate autofill selection
|
|
828
856
|
if (this.range) {
|
|
829
|
-
this.autoFillService.selectionStart(
|
|
857
|
+
this.autoFillService.selectionStart(targetElement, this.getData());
|
|
858
|
+
// Prevent default behavior for mouse events,
|
|
859
|
+
// but only if target element is not a mobile input
|
|
830
860
|
if (!touch) {
|
|
831
861
|
e.preventDefault();
|
|
832
862
|
}
|
|
833
863
|
else if (verifyTouchTarget(e.touches[0], MOBILE_CLASS)) {
|
|
864
|
+
// Prevent default behavior for touch events
|
|
865
|
+
// if target element is a mobile input
|
|
834
866
|
e.preventDefault();
|
|
835
867
|
}
|
|
836
868
|
}
|
|
@@ -841,8 +873,8 @@ const OverlaySelection = class {
|
|
|
841
873
|
doEdit(val = '') {
|
|
842
874
|
var _a;
|
|
843
875
|
if (this.canEdit()) {
|
|
844
|
-
const
|
|
845
|
-
const data = this.columnService.getSaveData(
|
|
876
|
+
const focus = this.selectionStore.get('focus');
|
|
877
|
+
const data = this.columnService.getSaveData(focus.y, focus.x);
|
|
846
878
|
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
|
|
847
879
|
}
|
|
848
880
|
}
|
|
@@ -865,8 +897,8 @@ const OverlaySelection = class {
|
|
|
865
897
|
this.cellEditApply.emit(dataToSave);
|
|
866
898
|
}
|
|
867
899
|
getRegion() {
|
|
868
|
-
const focus = this.
|
|
869
|
-
let range = this.
|
|
900
|
+
const focus = this.selectionStore.get('focus');
|
|
901
|
+
let range = this.selectionStore.get('range');
|
|
870
902
|
if (!range) {
|
|
871
903
|
range = getRange(focus, focus);
|
|
872
904
|
}
|
|
@@ -892,8 +924,8 @@ const OverlaySelection = class {
|
|
|
892
924
|
return true;
|
|
893
925
|
}
|
|
894
926
|
onPaste(data) {
|
|
895
|
-
const focus = this.
|
|
896
|
-
const isEditing = this.
|
|
927
|
+
const focus = this.selectionStore.get('focus');
|
|
928
|
+
const isEditing = this.selectionStore.get('edit') !== null;
|
|
897
929
|
if (!focus || isEditing) {
|
|
898
930
|
return;
|
|
899
931
|
}
|
|
@@ -913,13 +945,13 @@ const OverlaySelection = class {
|
|
|
913
945
|
}
|
|
914
946
|
}
|
|
915
947
|
clearCell() {
|
|
916
|
-
if (this.
|
|
917
|
-
!isRangeSingleCell(this.
|
|
918
|
-
const data = this.columnService.getRangeStaticData(this.
|
|
919
|
-
this.autoFillService.onRangeApply(data, this.
|
|
948
|
+
if (this.selectionStore.get('range') &&
|
|
949
|
+
!isRangeSingleCell(this.selectionStore.get('range'))) {
|
|
950
|
+
const data = this.columnService.getRangeStaticData(this.selectionStore.get('range'), '');
|
|
951
|
+
this.autoFillService.onRangeApply(data, this.selectionStore.get('range'));
|
|
920
952
|
}
|
|
921
953
|
else if (this.canEdit()) {
|
|
922
|
-
const focused = this.
|
|
954
|
+
const focused = this.selectionStore.get('focus');
|
|
923
955
|
const cell = this.columnService.getSaveData(focused.y, focused.x);
|
|
924
956
|
this.cellEdit({
|
|
925
957
|
rgRow: focused.y,
|
|
@@ -941,8 +973,24 @@ const OverlaySelection = class {
|
|
|
941
973
|
if (this.readonly) {
|
|
942
974
|
return false;
|
|
943
975
|
}
|
|
944
|
-
const
|
|
945
|
-
return
|
|
976
|
+
const focus = this.selectionStore.get('focus');
|
|
977
|
+
return focus && !((_a = this.columnService) === null || _a === void 0 ? void 0 : _a.isReadOnly(focus.y, focus.x));
|
|
978
|
+
}
|
|
979
|
+
get edited() {
|
|
980
|
+
return this.selectionStore.get('edit');
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Sets the focus on a cell and optionally edits a range.
|
|
984
|
+
*/
|
|
985
|
+
focus(cell, isRangeEdit = false) {
|
|
986
|
+
if (!cell)
|
|
987
|
+
return false;
|
|
988
|
+
const end = cell;
|
|
989
|
+
const start = this.selectionStore.get('focus');
|
|
990
|
+
if (isRangeEdit && start) {
|
|
991
|
+
return this.triggerRangeEvent(getRange(start, end));
|
|
992
|
+
}
|
|
993
|
+
return this.doFocus(cell, end);
|
|
946
994
|
}
|
|
947
995
|
get types() {
|
|
948
996
|
return {
|
|
@@ -959,6 +1007,8 @@ const OverlaySelection = class {
|
|
|
959
1007
|
rows: this.dimensionRow.state,
|
|
960
1008
|
cols: this.dimensionCol.state,
|
|
961
1009
|
lastCell: this.lastCell,
|
|
1010
|
+
focus: this.selectionStore.get('focus'),
|
|
1011
|
+
range: this.selectionStore.get('range'),
|
|
962
1012
|
};
|
|
963
1013
|
}
|
|
964
1014
|
get element() { return getElement(this); }
|