@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
|
@@ -8,50 +8,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
8
8
|
const index = require('./index-84e32c2a.js');
|
|
9
9
|
const index$1 = require('./index-73c149e3.js');
|
|
10
10
|
const dimension_helpers = require('./dimension.helpers-ee39d6c4.js');
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const events = require('./events-f8893bba.js');
|
|
12
|
+
const column_service = require('./column.service-bc269420.js');
|
|
13
13
|
const key_utils = require('./key.utils-59b9b528.js');
|
|
14
|
+
const selection_store = require('./selection.store-2e110a67.js');
|
|
14
15
|
const debounce = require('./debounce-e2b7c6fb.js');
|
|
15
|
-
const events = require('./events-7ccd6894.js');
|
|
16
16
|
const throttle = require('./throttle-f7aee21b.js');
|
|
17
17
|
require('./toNumber-838e6ff5.js');
|
|
18
18
|
require('./viewport.helpers-6670177c.js');
|
|
19
19
|
|
|
20
|
-
class SelectionStoreService {
|
|
21
|
-
constructor(store, config) {
|
|
22
|
-
this.store = store;
|
|
23
|
-
this.config = config;
|
|
24
|
-
this.store = store;
|
|
25
|
-
}
|
|
26
|
-
get edited() {
|
|
27
|
-
return this.store.get('edit');
|
|
28
|
-
}
|
|
29
|
-
get focused() {
|
|
30
|
-
return this.store.get('focus');
|
|
31
|
-
}
|
|
32
|
-
get ranged() {
|
|
33
|
-
return this.store.get('range');
|
|
34
|
-
}
|
|
35
|
-
changeRange(range) {
|
|
36
|
-
return this.config.changeRange(range);
|
|
37
|
-
}
|
|
38
|
-
focus(cell, isMulti = false) {
|
|
39
|
-
if (!cell) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
let end = cell;
|
|
43
|
-
// range edit
|
|
44
|
-
if (isMulti) {
|
|
45
|
-
let start = this.store.get('focus');
|
|
46
|
-
if (start) {
|
|
47
|
-
return this.config.changeRange(selection_store.getRange(start, end));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// single focus
|
|
51
|
-
return this.config.focus(cell, end);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
20
|
const Attribution = class {
|
|
56
21
|
constructor(hostRef) {
|
|
57
22
|
index.registerInstance(this, hostRef);
|
|
@@ -61,26 +26,50 @@ const Attribution = class {
|
|
|
61
26
|
}
|
|
62
27
|
};
|
|
63
28
|
|
|
64
|
-
|
|
29
|
+
function getFocusCellBasedOnEvent(e, data) {
|
|
30
|
+
// If event default is prevented, return
|
|
31
|
+
if (e.defaultPrevented) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// Get coordinates from event object
|
|
35
|
+
const x = events.getPropertyFromEvent(e, 'clientX');
|
|
36
|
+
const y = events.getPropertyFromEvent(e, 'clientY');
|
|
37
|
+
// If coordinates are not available, return
|
|
38
|
+
if (x === null || y === null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
// Get current cell based on coordinates and data
|
|
42
|
+
const focusCell = getCurrentCell({ x, y }, data);
|
|
43
|
+
// If current cell is not available, return
|
|
44
|
+
if (isAfterLast(focusCell, data.lastCell)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return focusCell;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Calculate cell based on x, y position
|
|
51
|
+
*/
|
|
65
52
|
function getCurrentCell({ x, y }, { el, rows, cols }) {
|
|
53
|
+
// Get the bounding rectangle of the element
|
|
66
54
|
const { top, left, height, width } = el.getBoundingClientRect();
|
|
55
|
+
// Calculate the cell position relative to the element
|
|
67
56
|
let cellY = y - top;
|
|
68
|
-
|
|
57
|
+
let cellX = x - left;
|
|
58
|
+
// Limit the cell position to the element height
|
|
69
59
|
if (cellY >= height) {
|
|
70
60
|
cellY = height - 1;
|
|
71
61
|
}
|
|
72
|
-
|
|
73
|
-
// limit to element width
|
|
62
|
+
// Limit the cell position to the element width
|
|
74
63
|
if (cellX >= width) {
|
|
75
64
|
cellX = width - 1;
|
|
76
65
|
}
|
|
66
|
+
// Get the row and column items based on the cell position
|
|
77
67
|
const rgRow = dimension_helpers.getItemByPosition(rows, cellY);
|
|
78
68
|
const rgCol = dimension_helpers.getItemByPosition(cols, cellX);
|
|
79
|
-
// before first
|
|
69
|
+
// Set the row and column index to 0 if they are before the first item
|
|
80
70
|
if (rgCol.itemIndex < 0) {
|
|
81
71
|
rgCol.itemIndex = 0;
|
|
82
72
|
}
|
|
83
|
-
// before first
|
|
84
73
|
if (rgRow.itemIndex < 0) {
|
|
85
74
|
rgRow.itemIndex = 0;
|
|
86
75
|
}
|
|
@@ -102,8 +91,11 @@ function getCoordinate(range, focus, changes, isMulti = false) {
|
|
|
102
91
|
}
|
|
103
92
|
return null;
|
|
104
93
|
}
|
|
105
|
-
/**
|
|
106
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Check if the x coordinate of the cell position is after or equal to the x coordinate of the last cell position
|
|
96
|
+
* or if the y coordinate of the cell position is after or equal to the y coordinate of the last cell position
|
|
97
|
+
*/
|
|
98
|
+
function isAfterLast({ x, y }, lastCell) {
|
|
107
99
|
return x >= lastCell.x || y >= lastCell.y;
|
|
108
100
|
}
|
|
109
101
|
/** check if out of range */
|
|
@@ -244,9 +236,9 @@ class KeyboardService {
|
|
|
244
236
|
constructor(sv) {
|
|
245
237
|
this.sv = sv;
|
|
246
238
|
}
|
|
247
|
-
async keyDown(e, canRange) {
|
|
239
|
+
async keyDown(e, canRange, isEditMode, { range, focus }) {
|
|
248
240
|
// IF EDIT MODE
|
|
249
|
-
if (
|
|
241
|
+
if (isEditMode) {
|
|
250
242
|
switch (e.code) {
|
|
251
243
|
case key_utils.codesLetter.ESCAPE:
|
|
252
244
|
this.sv.cancel();
|
|
@@ -256,12 +248,12 @@ class KeyboardService {
|
|
|
256
248
|
}
|
|
257
249
|
// IF NOT EDIT MODE
|
|
258
250
|
// pressed clear key
|
|
259
|
-
if (
|
|
251
|
+
if (range && key_utils.isClear(e.code)) {
|
|
260
252
|
this.sv.clearCell();
|
|
261
253
|
return;
|
|
262
254
|
}
|
|
263
255
|
// below works with focus only
|
|
264
|
-
if (!
|
|
256
|
+
if (!focus) {
|
|
265
257
|
return;
|
|
266
258
|
}
|
|
267
259
|
// tab key means same as arrow right
|
|
@@ -337,7 +329,7 @@ class KeyboardService {
|
|
|
337
329
|
}
|
|
338
330
|
if (isMulti) {
|
|
339
331
|
const eData = this.sv.getData();
|
|
340
|
-
if (isAfterLast(data.end, eData) || isBeforeFirst(data.start)) {
|
|
332
|
+
if (isAfterLast(data.end, eData.lastCell) || isBeforeFirst(data.start)) {
|
|
341
333
|
return false;
|
|
342
334
|
}
|
|
343
335
|
const range = selection_store.getRange(data.start, data.end);
|
|
@@ -389,7 +381,10 @@ class AutoFillService {
|
|
|
389
381
|
return (index.h("div", { class: {
|
|
390
382
|
[index$1.CELL_HANDLER_CLASS]: true,
|
|
391
383
|
[index$1.MOBILE_CLASS]: true,
|
|
392
|
-
}, style: {
|
|
384
|
+
}, style: {
|
|
385
|
+
left: `${handlerStyle.right}px`,
|
|
386
|
+
top: `${handlerStyle.bottom}px`,
|
|
387
|
+
}, onMouseDown: (e) => this.autoFillHandler(e), onTouchStart: (e) => this.autoFillHandler(e) }));
|
|
393
388
|
}
|
|
394
389
|
autoFillHandler(e, type = "AutoFill" /* AutoFillType.autoFill */) {
|
|
395
390
|
let target = null;
|
|
@@ -405,7 +400,9 @@ class AutoFillService {
|
|
|
405
400
|
get isAutoFill() {
|
|
406
401
|
return !!this.autoFillType;
|
|
407
402
|
}
|
|
408
|
-
/**
|
|
403
|
+
/**
|
|
404
|
+
* Process mouse move events
|
|
405
|
+
*/
|
|
409
406
|
selectionMouseMove(e) {
|
|
410
407
|
// initiate mouse move debounce if not present
|
|
411
408
|
if (!this.onMouseMoveAutofill) {
|
|
@@ -415,9 +412,7 @@ class AutoFillService {
|
|
|
415
412
|
this.onMouseMoveAutofill(e, this.sv.getData());
|
|
416
413
|
}
|
|
417
414
|
}
|
|
418
|
-
getFocus() {
|
|
419
|
-
let focus = this.sv.selectionStoreService.focused;
|
|
420
|
-
const range = this.sv.selectionStoreService.ranged;
|
|
415
|
+
getFocus(focus, range) {
|
|
421
416
|
// there was an issue that it was taking last cell from range but focus was out
|
|
422
417
|
if (!focus && range) {
|
|
423
418
|
focus = { x: range.x, y: range.y };
|
|
@@ -433,8 +428,8 @@ class AutoFillService {
|
|
|
433
428
|
if (!this.autoFillInitial) {
|
|
434
429
|
return;
|
|
435
430
|
}
|
|
436
|
-
const x = events.
|
|
437
|
-
const y = events.
|
|
431
|
+
const x = events.getPropertyFromEvent(event, 'clientX', index$1.MOBILE_CLASS);
|
|
432
|
+
const y = events.getPropertyFromEvent(event, 'clientY', index$1.MOBILE_CLASS);
|
|
438
433
|
// skip touch
|
|
439
434
|
if (x === null || y === null) {
|
|
440
435
|
return;
|
|
@@ -447,11 +442,12 @@ class AutoFillService {
|
|
|
447
442
|
}
|
|
448
443
|
}
|
|
449
444
|
// check if not the latest, if latest - do nothing
|
|
450
|
-
if (isAfterLast(current, data)) {
|
|
445
|
+
if (isAfterLast(current, data.lastCell)) {
|
|
451
446
|
return;
|
|
452
447
|
}
|
|
453
448
|
this.autoFillLast = current;
|
|
454
|
-
const isSame = current.x === this.autoFillInitial.x &&
|
|
449
|
+
const isSame = current.x === this.autoFillInitial.x &&
|
|
450
|
+
current.y === this.autoFillInitial.y;
|
|
455
451
|
// if same as initial - clear
|
|
456
452
|
if (isSame) {
|
|
457
453
|
this.sv.setTempRange(null);
|
|
@@ -472,39 +468,48 @@ class AutoFillService {
|
|
|
472
468
|
selectionStart(target, data, type = "Selection" /* AutoFillType.selection */) {
|
|
473
469
|
/** Get cell by autofill element */
|
|
474
470
|
const { top, left } = target.getBoundingClientRect();
|
|
475
|
-
this.autoFillInitial = this.getFocus();
|
|
471
|
+
this.autoFillInitial = this.getFocus(data.focus, data.range);
|
|
476
472
|
this.autoFillType = type;
|
|
477
473
|
this.autoFillStart = getCurrentCell({ x: left, y: top }, data);
|
|
478
474
|
}
|
|
479
475
|
/**
|
|
480
|
-
* Clear current range selection
|
|
481
|
-
* on mouse up and mouse leave events
|
|
476
|
+
* Clear current range selection on mouse up and mouse leave events
|
|
482
477
|
*/
|
|
483
|
-
clearAutoFillSelection() {
|
|
484
|
-
//
|
|
478
|
+
clearAutoFillSelection(focus, oldRange) {
|
|
479
|
+
// If autofill was active, apply autofill values
|
|
485
480
|
if (this.autoFillInitial) {
|
|
486
|
-
//
|
|
487
|
-
this.autoFillInitial = this.getFocus();
|
|
488
|
-
// Apply range data if
|
|
481
|
+
// Fetch latest focus
|
|
482
|
+
this.autoFillInitial = this.getFocus(focus, oldRange);
|
|
483
|
+
// Apply range data if autofill mode is active
|
|
489
484
|
if (this.autoFillType === "AutoFill" /* AutoFillType.autoFill */) {
|
|
490
485
|
const range = selection_store.getRange(this.autoFillInitial, this.autoFillLast);
|
|
486
|
+
// If range is present, apply data
|
|
491
487
|
if (range) {
|
|
492
|
-
const { defaultPrevented: stopApply, detail: { range: newRange } } = this.sv.clearRangeDataApply({
|
|
488
|
+
const { defaultPrevented: stopApply, detail: { range: newRange }, } = this.sv.clearRangeDataApply({
|
|
493
489
|
range,
|
|
494
490
|
});
|
|
491
|
+
// If data apply was not prevented, apply new range
|
|
495
492
|
if (!stopApply) {
|
|
496
|
-
this.applyRangeWithData(newRange);
|
|
493
|
+
this.applyRangeWithData(newRange, oldRange);
|
|
497
494
|
}
|
|
498
495
|
else {
|
|
499
|
-
//
|
|
496
|
+
// If data apply was prevented, clear temporary range
|
|
500
497
|
this.sv.setTempRange(null);
|
|
501
498
|
}
|
|
502
499
|
}
|
|
503
500
|
}
|
|
504
501
|
else {
|
|
502
|
+
// If not autofill mode, apply range only
|
|
505
503
|
this.applyRangeOnly(this.autoFillInitial, this.autoFillLast);
|
|
506
504
|
}
|
|
507
505
|
}
|
|
506
|
+
// Reset autofill state
|
|
507
|
+
this.resetAutoFillState();
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Reset autofill state
|
|
511
|
+
*/
|
|
512
|
+
resetAutoFillState() {
|
|
508
513
|
this.autoFillType = null;
|
|
509
514
|
this.autoFillInitial = null;
|
|
510
515
|
this.autoFillLast = null;
|
|
@@ -524,8 +529,7 @@ class AutoFillService {
|
|
|
524
529
|
this.sv.setRange(range);
|
|
525
530
|
}
|
|
526
531
|
/** Apply range and copy data during range application */
|
|
527
|
-
applyRangeWithData(newRange) {
|
|
528
|
-
const oldRange = this.sv.selectionStoreService.ranged;
|
|
532
|
+
applyRangeWithData(newRange, oldRange) {
|
|
529
533
|
const rangeData = {
|
|
530
534
|
type: this.sv.dataStore.get('type'),
|
|
531
535
|
colType: this.sv.columnService.type,
|
|
@@ -614,44 +618,60 @@ const OverlaySelection = class {
|
|
|
614
618
|
// #endregion
|
|
615
619
|
// #region Listeners
|
|
616
620
|
onMouseMove(e) {
|
|
617
|
-
if (this.
|
|
621
|
+
if (this.selectionStore.get('focus')) {
|
|
618
622
|
this.autoFillService.selectionMouseMove(e);
|
|
619
623
|
}
|
|
620
624
|
}
|
|
621
|
-
/**
|
|
622
|
-
|
|
625
|
+
/**
|
|
626
|
+
* Action finished inside of the document.
|
|
627
|
+
* Pointer left document, clear any active operation.
|
|
628
|
+
*/
|
|
623
629
|
onMouseUp() {
|
|
624
|
-
|
|
630
|
+
// Clear auto fill selection
|
|
631
|
+
// when pointer left document,
|
|
632
|
+
// clear any active operation.
|
|
633
|
+
this.autoFillService.clearAutoFillSelection(this.selectionStore.get('focus'), this.selectionStore.get('range'));
|
|
625
634
|
}
|
|
626
|
-
/**
|
|
635
|
+
/**
|
|
636
|
+
* Row drag started.
|
|
637
|
+
* This event is fired when drag action started on cell.
|
|
638
|
+
*/
|
|
627
639
|
onCellDrag(e) {
|
|
628
640
|
var _a;
|
|
641
|
+
// Invoke drag start on order editor.
|
|
629
642
|
(_a = this.orderEditor) === null || _a === void 0 ? void 0 : _a.dragStart(e.detail);
|
|
630
643
|
}
|
|
631
|
-
/**
|
|
644
|
+
/**
|
|
645
|
+
* Get keyboard down from element.
|
|
646
|
+
* This event is fired when keyboard key is released.
|
|
647
|
+
*/
|
|
632
648
|
onKeyUp(e) {
|
|
649
|
+
// Emit before key up event.
|
|
633
650
|
this.beforeKeyUp.emit(e);
|
|
634
651
|
}
|
|
635
|
-
/**
|
|
652
|
+
/**
|
|
653
|
+
* Get keyboard down from element.
|
|
654
|
+
* This event is fired when keyboard key is pressed.
|
|
655
|
+
*/
|
|
636
656
|
onKeyDown(e) {
|
|
637
657
|
var _a;
|
|
658
|
+
// Emit before key down event and check if default prevention is set.
|
|
638
659
|
const proxy = this.beforeKeyDown.emit(e);
|
|
639
660
|
if (e.defaultPrevented || proxy.defaultPrevented) {
|
|
640
661
|
return;
|
|
641
662
|
}
|
|
642
|
-
|
|
663
|
+
// Invoke key down on keyboard service.
|
|
664
|
+
(_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyDown(e, this.range, !!this.selectionStore.get('edit'), {
|
|
665
|
+
focus: this.selectionStore.get('focus'),
|
|
666
|
+
range: this.selectionStore.get('range'),
|
|
667
|
+
});
|
|
643
668
|
}
|
|
644
669
|
// #endregion
|
|
645
670
|
/** Selection & Keyboard */
|
|
646
671
|
selectionServiceSet(s) {
|
|
647
|
-
this.selectionStoreService = new SelectionStoreService(s, {
|
|
648
|
-
changeRange: range => this.triggerRangeEvent(range),
|
|
649
|
-
focus: (focus, end) => this.doFocus(focus, end),
|
|
650
|
-
});
|
|
651
672
|
this.keyboardService = new KeyboardService({
|
|
652
|
-
selectionStoreService: this.selectionStoreService,
|
|
653
673
|
selectionStore: s,
|
|
654
|
-
range: r => this.
|
|
674
|
+
range: r => this.triggerRangeEvent(r),
|
|
655
675
|
focusNext: (f, next) => this.doFocus(f, f, next),
|
|
656
676
|
change: val => {
|
|
657
677
|
if (this.readonly) {
|
|
@@ -673,7 +693,6 @@ const OverlaySelection = class {
|
|
|
673
693
|
/** Autofill */
|
|
674
694
|
createAutoFillService() {
|
|
675
695
|
this.autoFillService = new AutoFillService({
|
|
676
|
-
selectionStoreService: this.selectionStoreService,
|
|
677
696
|
dimensionRow: this.dimensionRow,
|
|
678
697
|
dimensionCol: this.dimensionCol,
|
|
679
698
|
columnService: this.columnService,
|
|
@@ -749,10 +768,10 @@ const OverlaySelection = class {
|
|
|
749
768
|
nodes.push(editCell);
|
|
750
769
|
}
|
|
751
770
|
else {
|
|
752
|
-
const range = this.
|
|
753
|
-
const
|
|
771
|
+
const range = this.selectionStore.get('range');
|
|
772
|
+
const focus = this.selectionStore.get('focus');
|
|
754
773
|
// Clipboard
|
|
755
|
-
if ((range ||
|
|
774
|
+
if ((range || focus) && this.useClipboard) {
|
|
756
775
|
nodes.push(index.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) }));
|
|
757
776
|
}
|
|
758
777
|
// Range
|
|
@@ -760,23 +779,19 @@ const OverlaySelection = class {
|
|
|
760
779
|
nodes.push(...this.renderRange(range));
|
|
761
780
|
}
|
|
762
781
|
// Autofill
|
|
763
|
-
if (
|
|
764
|
-
nodes.push(this.autoFillService.renderAutofill(range,
|
|
782
|
+
if (focus && !this.readonly && this.range) {
|
|
783
|
+
nodes.push(this.autoFillService.renderAutofill(range, focus));
|
|
765
784
|
}
|
|
766
785
|
// Order
|
|
767
786
|
if (this.canDrag) {
|
|
768
787
|
nodes.push(index.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) }));
|
|
769
788
|
}
|
|
770
789
|
}
|
|
771
|
-
return (index.h(index.Host, { key: '
|
|
772
|
-
// Open Editor on DblClick
|
|
773
|
-
onDblClick: (e) => {
|
|
774
|
-
// DblClick prevented outside - Editor will not open
|
|
775
|
-
if (!e.defaultPrevented) {
|
|
776
|
-
this.doEdit();
|
|
777
|
-
}
|
|
778
|
-
}, onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, index.h("slot", { key: '89b9bec7824739ea11fadeecbf3908ac74e85c96', name: "data" })));
|
|
790
|
+
return (index.h(index.Host, { key: '9dbb6247aebf4ad00c1c8c78852191671be33a11', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, index.h("slot", { key: '7769092a5029c5a49da8c2d6f36eb9f17b461bc2', name: "data" })));
|
|
779
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Executes the focus operation on the specified range of cells.
|
|
794
|
+
*/
|
|
780
795
|
doFocus(focus, end, next) {
|
|
781
796
|
const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
|
|
782
797
|
if (defaultPrevented) {
|
|
@@ -810,31 +825,48 @@ const OverlaySelection = class {
|
|
|
810
825
|
}
|
|
811
826
|
return !e.defaultPrevented;
|
|
812
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Open Editor on DblClick
|
|
830
|
+
*/
|
|
831
|
+
onElementDblClick(e) {
|
|
832
|
+
// DblClick prevented outside - Editor will not open
|
|
833
|
+
// Get data from the component
|
|
834
|
+
const data = this.getData();
|
|
835
|
+
const focusCell = getFocusCellBasedOnEvent(e, data);
|
|
836
|
+
if (!focusCell) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
this.doEdit();
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Handle mouse down event on Host element
|
|
843
|
+
*/
|
|
813
844
|
onElementMouseDown(e, touch = false) {
|
|
845
|
+
// Get the target element from the event object
|
|
846
|
+
const targetElement = e.target;
|
|
814
847
|
// Ignore focus if clicked input
|
|
815
|
-
if (key_utils.isEditInput(
|
|
848
|
+
if (key_utils.isEditInput(targetElement)) {
|
|
816
849
|
return;
|
|
817
850
|
}
|
|
851
|
+
// Get data from the component
|
|
818
852
|
const data = this.getData();
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
822
|
-
const x = events.getFromEvent(e, 'clientX');
|
|
823
|
-
const y = events.getFromEvent(e, 'clientY');
|
|
824
|
-
// skip touch
|
|
825
|
-
if (x === null || y === null) {
|
|
853
|
+
const focusCell = getFocusCellBasedOnEvent(e, data);
|
|
854
|
+
if (!focusCell) {
|
|
826
855
|
return;
|
|
827
856
|
}
|
|
828
|
-
//
|
|
829
|
-
|
|
830
|
-
this.selectionStoreService.focus(focusCell, this.range && e.shiftKey);
|
|
857
|
+
// Set focus on the current cell
|
|
858
|
+
this.focus(focusCell, this.range && e.shiftKey);
|
|
831
859
|
// Initiate autofill selection
|
|
832
860
|
if (this.range) {
|
|
833
|
-
this.autoFillService.selectionStart(
|
|
861
|
+
this.autoFillService.selectionStart(targetElement, this.getData());
|
|
862
|
+
// Prevent default behavior for mouse events,
|
|
863
|
+
// but only if target element is not a mobile input
|
|
834
864
|
if (!touch) {
|
|
835
865
|
e.preventDefault();
|
|
836
866
|
}
|
|
837
867
|
else if (events.verifyTouchTarget(e.touches[0], index$1.MOBILE_CLASS)) {
|
|
868
|
+
// Prevent default behavior for touch events
|
|
869
|
+
// if target element is a mobile input
|
|
838
870
|
e.preventDefault();
|
|
839
871
|
}
|
|
840
872
|
}
|
|
@@ -845,8 +877,8 @@ const OverlaySelection = class {
|
|
|
845
877
|
doEdit(val = '') {
|
|
846
878
|
var _a;
|
|
847
879
|
if (this.canEdit()) {
|
|
848
|
-
const
|
|
849
|
-
const data = this.columnService.getSaveData(
|
|
880
|
+
const focus = this.selectionStore.get('focus');
|
|
881
|
+
const data = this.columnService.getSaveData(focus.y, focus.x);
|
|
850
882
|
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
|
|
851
883
|
}
|
|
852
884
|
}
|
|
@@ -869,8 +901,8 @@ const OverlaySelection = class {
|
|
|
869
901
|
this.cellEditApply.emit(dataToSave);
|
|
870
902
|
}
|
|
871
903
|
getRegion() {
|
|
872
|
-
const focus = this.
|
|
873
|
-
let range = this.
|
|
904
|
+
const focus = this.selectionStore.get('focus');
|
|
905
|
+
let range = this.selectionStore.get('range');
|
|
874
906
|
if (!range) {
|
|
875
907
|
range = selection_store.getRange(focus, focus);
|
|
876
908
|
}
|
|
@@ -896,8 +928,8 @@ const OverlaySelection = class {
|
|
|
896
928
|
return true;
|
|
897
929
|
}
|
|
898
930
|
onPaste(data) {
|
|
899
|
-
const focus = this.
|
|
900
|
-
const isEditing = this.
|
|
931
|
+
const focus = this.selectionStore.get('focus');
|
|
932
|
+
const isEditing = this.selectionStore.get('edit') !== null;
|
|
901
933
|
if (!focus || isEditing) {
|
|
902
934
|
return;
|
|
903
935
|
}
|
|
@@ -917,13 +949,13 @@ const OverlaySelection = class {
|
|
|
917
949
|
}
|
|
918
950
|
}
|
|
919
951
|
clearCell() {
|
|
920
|
-
if (this.
|
|
921
|
-
!selection_store.isRangeSingleCell(this.
|
|
922
|
-
const data = this.columnService.getRangeStaticData(this.
|
|
923
|
-
this.autoFillService.onRangeApply(data, this.
|
|
952
|
+
if (this.selectionStore.get('range') &&
|
|
953
|
+
!selection_store.isRangeSingleCell(this.selectionStore.get('range'))) {
|
|
954
|
+
const data = this.columnService.getRangeStaticData(this.selectionStore.get('range'), '');
|
|
955
|
+
this.autoFillService.onRangeApply(data, this.selectionStore.get('range'));
|
|
924
956
|
}
|
|
925
957
|
else if (this.canEdit()) {
|
|
926
|
-
const focused = this.
|
|
958
|
+
const focused = this.selectionStore.get('focus');
|
|
927
959
|
const cell = this.columnService.getSaveData(focused.y, focused.x);
|
|
928
960
|
this.cellEdit({
|
|
929
961
|
rgRow: focused.y,
|
|
@@ -945,8 +977,24 @@ const OverlaySelection = class {
|
|
|
945
977
|
if (this.readonly) {
|
|
946
978
|
return false;
|
|
947
979
|
}
|
|
948
|
-
const
|
|
949
|
-
return
|
|
980
|
+
const focus = this.selectionStore.get('focus');
|
|
981
|
+
return focus && !((_a = this.columnService) === null || _a === void 0 ? void 0 : _a.isReadOnly(focus.y, focus.x));
|
|
982
|
+
}
|
|
983
|
+
get edited() {
|
|
984
|
+
return this.selectionStore.get('edit');
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Sets the focus on a cell and optionally edits a range.
|
|
988
|
+
*/
|
|
989
|
+
focus(cell, isRangeEdit = false) {
|
|
990
|
+
if (!cell)
|
|
991
|
+
return false;
|
|
992
|
+
const end = cell;
|
|
993
|
+
const start = this.selectionStore.get('focus');
|
|
994
|
+
if (isRangeEdit && start) {
|
|
995
|
+
return this.triggerRangeEvent(selection_store.getRange(start, end));
|
|
996
|
+
}
|
|
997
|
+
return this.doFocus(cell, end);
|
|
950
998
|
}
|
|
951
999
|
get types() {
|
|
952
1000
|
return {
|
|
@@ -963,6 +1011,8 @@ const OverlaySelection = class {
|
|
|
963
1011
|
rows: this.dimensionRow.state,
|
|
964
1012
|
cols: this.dimensionCol.state,
|
|
965
1013
|
lastCell: this.lastCell,
|
|
1014
|
+
focus: this.selectionStore.get('focus'),
|
|
1015
|
+
range: this.selectionStore.get('range'),
|
|
966
1016
|
};
|
|
967
1017
|
}
|
|
968
1018
|
get element() { return index.getElement(this); }
|