@revolist/revogrid 4.0.10 → 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.
Files changed (125) hide show
  1. package/dist/cjs/{column.service-e83d9809.js → column.service-bc269420.js} +23 -9
  2. package/dist/cjs/column.service-bc269420.js.map +1 -0
  3. package/dist/cjs/{events-7ccd6894.js → events-f8893bba.js} +15 -5
  4. package/dist/cjs/events-f8893bba.js.map +1 -0
  5. package/dist/cjs/{header-cell-renderer-8ba9b56d.js → header-cell-renderer-57acd2f7.js} +2 -2
  6. package/dist/cjs/{header-cell-renderer-8ba9b56d.js.map → header-cell-renderer-57acd2f7.js.map} +1 -1
  7. package/dist/cjs/{key.utils-dc4ac217.js → key.utils-59b9b528.js} +13 -1
  8. package/dist/cjs/key.utils-59b9b528.js.map +1 -0
  9. package/dist/cjs/revo-grid.cjs.entry.js +29 -13
  10. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  11. package/dist/cjs/revogr-attribution_6.cjs.entry.js +176 -131
  12. package/dist/cjs/revogr-attribution_6.cjs.entry.js.map +1 -1
  13. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +28 -11
  14. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  15. package/dist/cjs/revogr-data_4.cjs.entry.js +2 -2
  16. package/dist/collection/components/data/column.service.js.map +1 -1
  17. package/dist/collection/components/data/revogr-data.js +1 -1
  18. package/dist/collection/components/editors/edit.utils.js +4 -0
  19. package/dist/collection/components/editors/edit.utils.js.map +1 -1
  20. package/dist/collection/components/editors/revogr-edit.js +30 -12
  21. package/dist/collection/components/editors/revogr-edit.js.map +1 -1
  22. package/dist/collection/components/order/revogr-order-editor.js +4 -1
  23. package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
  24. package/dist/collection/components/overlay/autofill.service.js +36 -24
  25. package/dist/collection/components/overlay/autofill.service.js.map +1 -1
  26. package/dist/collection/components/overlay/keyboard.service.js +7 -7
  27. package/dist/collection/components/overlay/keyboard.service.js.map +1 -1
  28. package/dist/collection/components/overlay/revogr-overlay-selection.js +107 -59
  29. package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
  30. package/dist/collection/components/overlay/selection.utils.js +37 -9
  31. package/dist/collection/components/overlay/selection.utils.js.map +1 -1
  32. package/dist/collection/components/revoGrid/revo-grid-style.css +8 -3
  33. package/dist/collection/components/revoGrid/revo-grid.js +26 -11
  34. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  35. package/dist/collection/components/revoGrid/viewport.helpers.js +22 -8
  36. package/dist/collection/components/revoGrid/viewport.helpers.js.map +1 -1
  37. package/dist/collection/components/revoGrid/viewport.service.js +1 -0
  38. package/dist/collection/components/revoGrid/viewport.service.js.map +1 -1
  39. package/dist/collection/serve/controller.js +86 -18
  40. package/dist/collection/store/selection/index.js +0 -1
  41. package/dist/collection/store/selection/index.js.map +1 -1
  42. package/dist/collection/types/interfaces.js +4 -0
  43. package/dist/collection/types/interfaces.js.map +1 -1
  44. package/dist/collection/types/selection.js.map +1 -1
  45. package/dist/collection/utils/events.js +11 -1
  46. package/dist/collection/utils/events.js.map +1 -1
  47. package/dist/collection/utils/row-header-utils.js +2 -2
  48. package/dist/collection/utils/row-header-utils.js.map +1 -1
  49. package/dist/esm/{column.service-f4922a8d.js → column.service-195345ab.js} +23 -9
  50. package/dist/esm/column.service-195345ab.js.map +1 -0
  51. package/dist/esm/{events-3dd8ee7c.js → events-3e39de50.js} +15 -5
  52. package/dist/esm/events-3e39de50.js.map +1 -0
  53. package/dist/esm/{header-cell-renderer-ac962570.js → header-cell-renderer-7c76465d.js} +2 -2
  54. package/dist/esm/{header-cell-renderer-ac962570.js.map → header-cell-renderer-7c76465d.js.map} +1 -1
  55. package/dist/esm/{key.utils-4586a3d6.js → key.utils-2836e8ae.js} +12 -2
  56. package/dist/esm/key.utils-2836e8ae.js.map +1 -0
  57. package/dist/esm/revo-grid.entry.js +29 -13
  58. package/dist/esm/revo-grid.entry.js.map +1 -1
  59. package/dist/esm/revogr-attribution_6.entry.js +177 -132
  60. package/dist/esm/revogr-attribution_6.entry.js.map +1 -1
  61. package/dist/esm/revogr-clipboard_3.entry.js +28 -11
  62. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  63. package/dist/esm/revogr-data_4.entry.js +2 -2
  64. package/dist/revo-grid/column.service-195345ab.js +5 -0
  65. package/dist/revo-grid/column.service-195345ab.js.map +1 -0
  66. package/dist/revo-grid/{events-3dd8ee7c.js → events-3e39de50.js} +2 -2
  67. package/dist/revo-grid/events-3e39de50.js.map +1 -0
  68. package/dist/revo-grid/{header-cell-renderer-ac962570.js → header-cell-renderer-7c76465d.js} +2 -2
  69. package/dist/revo-grid/key.utils-2836e8ae.js +5 -0
  70. package/dist/revo-grid/key.utils-2836e8ae.js.map +1 -0
  71. package/dist/revo-grid/revo-grid.entry.js +1 -1
  72. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  73. package/dist/revo-grid/revogr-attribution_6.entry.js +1 -1
  74. package/dist/revo-grid/revogr-attribution_6.entry.js.map +1 -1
  75. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  76. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  77. package/dist/revo-grid/revogr-data_4.entry.js +1 -1
  78. package/dist/types/components/data/column.service.d.ts +2 -2
  79. package/dist/types/components/editors/edit.utils.d.ts +2 -0
  80. package/dist/types/components/order/revogr-order-editor.d.ts +3 -0
  81. package/dist/types/components/overlay/autofill.service.d.ts +9 -6
  82. package/dist/types/components/overlay/keyboard.service.d.ts +2 -3
  83. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +38 -15
  84. package/dist/types/components/overlay/selection.utils.d.ts +12 -4
  85. package/dist/types/components/revoGrid/revo-grid.d.ts +4 -1
  86. package/dist/types/components/revoGrid/viewport.helpers.d.ts +11 -2
  87. package/dist/types/components.d.ts +26 -2
  88. package/dist/types/store/selection/index.d.ts +0 -1
  89. package/dist/types/types/interfaces.d.ts +444 -23
  90. package/dist/types/types/selection.d.ts +1 -1
  91. package/dist/types/utils/events.d.ts +4 -1
  92. package/dist/types/utils/row-header-utils.d.ts +1 -1
  93. package/hydrate/index.js +296 -179
  94. package/package.json +5 -6
  95. package/standalone/column.service.js.map +1 -1
  96. package/standalone/revo-grid.js +28 -11
  97. package/standalone/revo-grid.js.map +1 -1
  98. package/standalone/revogr-edit2.js +37 -11
  99. package/standalone/revogr-edit2.js.map +1 -1
  100. package/standalone/revogr-focus2.js +1 -1
  101. package/standalone/revogr-order-editor2.js.map +1 -1
  102. package/standalone/revogr-overlay-selection2.js +142 -150
  103. package/standalone/revogr-overlay-selection2.js.map +1 -1
  104. package/standalone/revogr-row-headers2.js +2 -2
  105. package/standalone/revogr-row-headers2.js.map +1 -1
  106. package/standalone/revogr-temp-range2.js +1 -1
  107. package/standalone/revogr-viewport-scroll2.js +22 -8
  108. package/standalone/revogr-viewport-scroll2.js.map +1 -1
  109. package/standalone/selection.utils.js +72 -9
  110. package/standalone/selection.utils.js.map +1 -1
  111. package/dist/cjs/column.service-e83d9809.js.map +0 -1
  112. package/dist/cjs/events-7ccd6894.js.map +0 -1
  113. package/dist/cjs/key.utils-dc4ac217.js.map +0 -1
  114. package/dist/collection/store/selection/selection.store.service.js +0 -39
  115. package/dist/collection/store/selection/selection.store.service.js.map +0 -1
  116. package/dist/esm/column.service-f4922a8d.js.map +0 -1
  117. package/dist/esm/events-3dd8ee7c.js.map +0 -1
  118. package/dist/esm/key.utils-4586a3d6.js.map +0 -1
  119. package/dist/revo-grid/column.service-f4922a8d.js +0 -5
  120. package/dist/revo-grid/column.service-f4922a8d.js.map +0 -1
  121. package/dist/revo-grid/events-3dd8ee7c.js.map +0 -1
  122. package/dist/revo-grid/key.utils-4586a3d6.js +0 -5
  123. package/dist/revo-grid/key.utils-4586a3d6.js.map +0 -1
  124. package/dist/types/store/selection/selection.store.service.d.ts +0 -17
  125. /package/dist/revo-grid/{header-cell-renderer-ac962570.js.map → header-cell-renderer-7c76465d.js.map} +0 -0
@@ -3,81 +3,15 @@
3
3
  */
4
4
  import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
5
5
  import { g as getRange, C as ColumnService, a as isRangeSingleCell } from './column.service.js';
6
- import { c as codesLetter, i as isClear, a as isEnterKey, b as isCopy, e as isCut, f as isPaste, g as isAll, h as isLetterKey, d as defineCustomElement$2 } from './revogr-edit2.js';
7
- import { E as EDIT_INPUT_WR, R as RESIZE_INTERVAL, k as CELL_HANDLER_CLASS, l as MOBILE_CLASS, S as SELECTION_BORDER_CLASS } from './consts.js';
8
- import { a as getCoordinate, i as isAfterLast, b as isBeforeFirst, c as getCell, d as getCurrentCell, g as getElStyle } from './selection.utils.js';
6
+ import { c as codesLetter, i as isClear, a as isEnterKey, b as isCopy, e as isCut, f as isPaste, g as isAll, h as isLetterKey, j as isEditInput, d as defineCustomElement$2 } from './revogr-edit2.js';
7
+ import { R as RESIZE_INTERVAL, k as CELL_HANDLER_CLASS, l as MOBILE_CLASS, S as SELECTION_BORDER_CLASS } from './consts.js';
8
+ import { b as getCoordinate, i as isAfterLast, c as isBeforeFirst, d as getCell, g as getPropertyFromEvent, e as getCurrentCell, a as getElStyle, f as getFocusCellBasedOnEvent, v as verifyTouchTarget } from './selection.utils.js';
9
9
  import { t as timeout } from './index2.js';
10
10
  import { d as debounce_1 } from './debounce.js';
11
11
  import { b as getSourceItem } from './data.store.js';
12
12
  import { d as defineCustomElement$3 } from './revogr-clipboard2.js';
13
13
  import { d as defineCustomElement$1 } from './revogr-order-editor2.js';
14
14
 
15
- class SelectionStoreService {
16
- constructor(store, config) {
17
- this.store = store;
18
- this.config = config;
19
- this.store = store;
20
- }
21
- get edited() {
22
- return this.store.get('edit');
23
- }
24
- get focused() {
25
- return this.store.get('focus');
26
- }
27
- get ranged() {
28
- return this.store.get('range');
29
- }
30
- changeRange(range) {
31
- return this.config.changeRange(range);
32
- }
33
- focus(cell, isMulti = false) {
34
- if (!cell) {
35
- return false;
36
- }
37
- let end = cell;
38
- // range edit
39
- if (isMulti) {
40
- let start = this.store.get('focus');
41
- if (start) {
42
- return this.config.changeRange(getRange(start, end));
43
- }
44
- }
45
- // single focus
46
- return this.config.focus(cell, end);
47
- }
48
- }
49
-
50
- function isTouch(e) {
51
- return !!e.touches;
52
- }
53
- function verifyTouchTarget(touchEvent, focusClass) {
54
- if (focusClass && touchEvent) {
55
- if (!(touchEvent.target instanceof Element && touchEvent.target.classList.contains(focusClass))) {
56
- return false;
57
- }
58
- }
59
- return true;
60
- }
61
- function getFromEvent(e, prop, focusClass // for touch events
62
- ) {
63
- if (isTouch(e)) {
64
- if (e.touches.length > 0) {
65
- const touchEvent = e.touches[0];
66
- if (!verifyTouchTarget(touchEvent, focusClass)) {
67
- return null;
68
- }
69
- return touchEvent[prop] || 0;
70
- }
71
- return null;
72
- }
73
- return e[prop] || 0;
74
- }
75
-
76
- // is edit input
77
- function isEditInput(el) {
78
- return !!(el === null || el === void 0 ? void 0 : el.closest(`.${EDIT_INPUT_WR}`));
79
- }
80
-
81
15
  const DIRECTION_CODES = [
82
16
  codesLetter.TAB,
83
17
  codesLetter.ARROW_UP,
@@ -89,9 +23,9 @@ class KeyboardService {
89
23
  constructor(sv) {
90
24
  this.sv = sv;
91
25
  }
92
- async keyDown(e, canRange) {
26
+ async keyDown(e, canRange, isEditMode, { range, focus }) {
93
27
  // IF EDIT MODE
94
- if (this.sv.selectionStoreService.edited) {
28
+ if (isEditMode) {
95
29
  switch (e.code) {
96
30
  case codesLetter.ESCAPE:
97
31
  this.sv.cancel();
@@ -101,12 +35,12 @@ class KeyboardService {
101
35
  }
102
36
  // IF NOT EDIT MODE
103
37
  // pressed clear key
104
- if (this.sv.selectionStoreService.ranged && isClear(e.code)) {
38
+ if (range && isClear(e.code)) {
105
39
  this.sv.clearCell();
106
40
  return;
107
41
  }
108
42
  // below works with focus only
109
- if (!this.sv.selectionStoreService.focused) {
43
+ if (!focus) {
110
44
  return;
111
45
  }
112
46
  // tab key means same as arrow right
@@ -182,7 +116,7 @@ class KeyboardService {
182
116
  }
183
117
  if (isMulti) {
184
118
  const eData = this.sv.getData();
185
- if (isAfterLast(data.end, eData) || isBeforeFirst(data.start)) {
119
+ if (isAfterLast(data.end, eData.lastCell) || isBeforeFirst(data.start)) {
186
120
  return false;
187
121
  }
188
122
  const range = getRange(data.start, data.end);
@@ -234,7 +168,10 @@ class AutoFillService {
234
168
  return (h("div", { class: {
235
169
  [CELL_HANDLER_CLASS]: true,
236
170
  [MOBILE_CLASS]: true,
237
- }, style: { left: `${handlerStyle.right}px`, top: `${handlerStyle.bottom}px` }, onMouseDown: (e) => this.autoFillHandler(e), onTouchStart: (e) => this.autoFillHandler(e) }));
171
+ }, style: {
172
+ left: `${handlerStyle.right}px`,
173
+ top: `${handlerStyle.bottom}px`,
174
+ }, onMouseDown: (e) => this.autoFillHandler(e), onTouchStart: (e) => this.autoFillHandler(e) }));
238
175
  }
239
176
  autoFillHandler(e, type = "AutoFill" /* AutoFillType.autoFill */) {
240
177
  let target = null;
@@ -250,7 +187,9 @@ class AutoFillService {
250
187
  get isAutoFill() {
251
188
  return !!this.autoFillType;
252
189
  }
253
- /** Process mouse move events */
190
+ /**
191
+ * Process mouse move events
192
+ */
254
193
  selectionMouseMove(e) {
255
194
  // initiate mouse move debounce if not present
256
195
  if (!this.onMouseMoveAutofill) {
@@ -260,9 +199,7 @@ class AutoFillService {
260
199
  this.onMouseMoveAutofill(e, this.sv.getData());
261
200
  }
262
201
  }
263
- getFocus() {
264
- let focus = this.sv.selectionStoreService.focused;
265
- const range = this.sv.selectionStoreService.ranged;
202
+ getFocus(focus, range) {
266
203
  // there was an issue that it was taking last cell from range but focus was out
267
204
  if (!focus && range) {
268
205
  focus = { x: range.x, y: range.y };
@@ -278,8 +215,8 @@ class AutoFillService {
278
215
  if (!this.autoFillInitial) {
279
216
  return;
280
217
  }
281
- const x = getFromEvent(event, 'clientX', MOBILE_CLASS);
282
- const y = getFromEvent(event, 'clientY', MOBILE_CLASS);
218
+ const x = getPropertyFromEvent(event, 'clientX', MOBILE_CLASS);
219
+ const y = getPropertyFromEvent(event, 'clientY', MOBILE_CLASS);
283
220
  // skip touch
284
221
  if (x === null || y === null) {
285
222
  return;
@@ -292,11 +229,12 @@ class AutoFillService {
292
229
  }
293
230
  }
294
231
  // check if not the latest, if latest - do nothing
295
- if (isAfterLast(current, data)) {
232
+ if (isAfterLast(current, data.lastCell)) {
296
233
  return;
297
234
  }
298
235
  this.autoFillLast = current;
299
- const isSame = current.x === this.autoFillInitial.x && current.y === this.autoFillInitial.y;
236
+ const isSame = current.x === this.autoFillInitial.x &&
237
+ current.y === this.autoFillInitial.y;
300
238
  // if same as initial - clear
301
239
  if (isSame) {
302
240
  this.sv.setTempRange(null);
@@ -317,39 +255,48 @@ class AutoFillService {
317
255
  selectionStart(target, data, type = "Selection" /* AutoFillType.selection */) {
318
256
  /** Get cell by autofill element */
319
257
  const { top, left } = target.getBoundingClientRect();
320
- this.autoFillInitial = this.getFocus();
258
+ this.autoFillInitial = this.getFocus(data.focus, data.range);
321
259
  this.autoFillType = type;
322
260
  this.autoFillStart = getCurrentCell({ x: left, y: top }, data);
323
261
  }
324
262
  /**
325
- * Clear current range selection
326
- * on mouse up and mouse leave events
263
+ * Clear current range selection on mouse up and mouse leave events
327
264
  */
328
- clearAutoFillSelection() {
329
- // Apply autofill values on mouse up if present
265
+ clearAutoFillSelection(focus, oldRange) {
266
+ // If autofill was active, apply autofill values
330
267
  if (this.autoFillInitial) {
331
- // Get latest
332
- this.autoFillInitial = this.getFocus();
333
- // Apply range data if present
268
+ // Fetch latest focus
269
+ this.autoFillInitial = this.getFocus(focus, oldRange);
270
+ // Apply range data if autofill mode is active
334
271
  if (this.autoFillType === "AutoFill" /* AutoFillType.autoFill */) {
335
272
  const range = getRange(this.autoFillInitial, this.autoFillLast);
273
+ // If range is present, apply data
336
274
  if (range) {
337
- const { defaultPrevented: stopApply, detail: { range: newRange } } = this.sv.clearRangeDataApply({
275
+ const { defaultPrevented: stopApply, detail: { range: newRange }, } = this.sv.clearRangeDataApply({
338
276
  range,
339
277
  });
278
+ // If data apply was not prevented, apply new range
340
279
  if (!stopApply) {
341
- this.applyRangeWithData(newRange);
280
+ this.applyRangeWithData(newRange, oldRange);
342
281
  }
343
282
  else {
344
- // if prevented - clear temp range
283
+ // If data apply was prevented, clear temporary range
345
284
  this.sv.setTempRange(null);
346
285
  }
347
286
  }
348
287
  }
349
288
  else {
289
+ // If not autofill mode, apply range only
350
290
  this.applyRangeOnly(this.autoFillInitial, this.autoFillLast);
351
291
  }
352
292
  }
293
+ // Reset autofill state
294
+ this.resetAutoFillState();
295
+ }
296
+ /**
297
+ * Reset autofill state
298
+ */
299
+ resetAutoFillState() {
353
300
  this.autoFillType = null;
354
301
  this.autoFillInitial = null;
355
302
  this.autoFillLast = null;
@@ -369,8 +316,7 @@ class AutoFillService {
369
316
  this.sv.setRange(range);
370
317
  }
371
318
  /** Apply range and copy data during range application */
372
- applyRangeWithData(newRange) {
373
- const oldRange = this.sv.selectionStoreService.ranged;
319
+ applyRangeWithData(newRange, oldRange) {
374
320
  const rangeData = {
375
321
  type: this.sv.dataStore.get('type'),
376
322
  colType: this.sv.columnService.type,
@@ -460,44 +406,60 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
460
406
  // #endregion
461
407
  // #region Listeners
462
408
  onMouseMove(e) {
463
- if (this.selectionStoreService.focused) {
409
+ if (this.selectionStore.get('focus')) {
464
410
  this.autoFillService.selectionMouseMove(e);
465
411
  }
466
412
  }
467
- /** Action finished inside of the document. */
468
- /** Pointer left document, clear any active operation. */
413
+ /**
414
+ * Action finished inside of the document.
415
+ * Pointer left document, clear any active operation.
416
+ */
469
417
  onMouseUp() {
470
- this.autoFillService.clearAutoFillSelection();
418
+ // Clear auto fill selection
419
+ // when pointer left document,
420
+ // clear any active operation.
421
+ this.autoFillService.clearAutoFillSelection(this.selectionStore.get('focus'), this.selectionStore.get('range'));
471
422
  }
472
- /** Row drag started. */
423
+ /**
424
+ * Row drag started.
425
+ * This event is fired when drag action started on cell.
426
+ */
473
427
  onCellDrag(e) {
474
428
  var _a;
429
+ // Invoke drag start on order editor.
475
430
  (_a = this.orderEditor) === null || _a === void 0 ? void 0 : _a.dragStart(e.detail);
476
431
  }
477
- /** Get keyboard down from element. */
432
+ /**
433
+ * Get keyboard down from element.
434
+ * This event is fired when keyboard key is released.
435
+ */
478
436
  onKeyUp(e) {
437
+ // Emit before key up event.
479
438
  this.beforeKeyUp.emit(e);
480
439
  }
481
- /** Get keyboard down from element. */
440
+ /**
441
+ * Get keyboard down from element.
442
+ * This event is fired when keyboard key is pressed.
443
+ */
482
444
  onKeyDown(e) {
483
445
  var _a;
446
+ // Emit before key down event and check if default prevention is set.
484
447
  const proxy = this.beforeKeyDown.emit(e);
485
448
  if (e.defaultPrevented || proxy.defaultPrevented) {
486
449
  return;
487
450
  }
488
- (_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyDown(e, this.range);
451
+ // Invoke key down on keyboard service.
452
+ (_a = this.keyboardService) === null || _a === void 0 ? void 0 : _a.keyDown(e, this.range, !!this.selectionStore.get('edit'), {
453
+ focus: this.selectionStore.get('focus'),
454
+ range: this.selectionStore.get('range'),
455
+ });
489
456
  }
490
457
  // #endregion
491
458
  /** Selection & Keyboard */
492
459
  selectionServiceSet(s) {
493
- this.selectionStoreService = new SelectionStoreService(s, {
494
- changeRange: range => this.triggerRangeEvent(range),
495
- focus: (focus, end) => this.doFocus(focus, end),
496
- });
497
460
  this.keyboardService = new KeyboardService({
498
- selectionStoreService: this.selectionStoreService,
499
461
  selectionStore: s,
500
- range: r => this.selectionStoreService.changeRange(r),
462
+ range: r => this.triggerRangeEvent(r),
501
463
  focusNext: (f, next) => this.doFocus(f, f, next),
502
464
  change: val => {
503
465
  if (this.readonly) {
@@ -519,7 +481,6 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
519
481
  /** Autofill */
520
482
  createAutoFillService() {
521
483
  this.autoFillService = new AutoFillService({
522
- selectionStoreService: this.selectionStoreService,
523
484
  dimensionRow: this.dimensionRow,
524
485
  dimensionCol: this.dimensionCol,
525
486
  columnService: this.columnService,
@@ -595,10 +556,10 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
595
556
  nodes.push(editCell);
596
557
  }
597
558
  else {
598
- const range = this.selectionStoreService.ranged;
599
- const selectionFocus = this.selectionStoreService.focused;
559
+ const range = this.selectionStore.get('range');
560
+ const focus = this.selectionStore.get('focus');
600
561
  // Clipboard
601
- if ((range || selectionFocus) && this.useClipboard) {
562
+ if ((range || focus) && this.useClipboard) {
602
563
  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) }));
603
564
  }
604
565
  // Range
@@ -606,23 +567,19 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
606
567
  nodes.push(...this.renderRange(range));
607
568
  }
608
569
  // Autofill
609
- if (selectionFocus && !this.readonly && this.range) {
610
- nodes.push(this.autoFillService.renderAutofill(range, selectionFocus));
570
+ if (focus && !this.readonly && this.range) {
571
+ nodes.push(this.autoFillService.renderAutofill(range, focus));
611
572
  }
612
573
  // Order
613
574
  if (this.canDrag) {
614
575
  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) }));
615
576
  }
616
577
  }
617
- return (h(Host, { key: 'd20fcf63958e3d491f4fd881a4a5dd242cfdd9ac', class: { mobile: this.isMobileDevice },
618
- // Open Editor on DblClick
619
- onDblClick: (e) => {
620
- // DblClick prevented outside - Editor will not open
621
- if (!e.defaultPrevented) {
622
- this.doEdit();
623
- }
624
- }, onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, h("slot", { key: '89b9bec7824739ea11fadeecbf3908ac74e85c96', name: "data" })));
578
+ 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" })));
625
579
  }
580
+ /**
581
+ * Executes the focus operation on the specified range of cells.
582
+ */
626
583
  doFocus(focus, end, next) {
627
584
  const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
628
585
  if (defaultPrevented) {
@@ -656,31 +613,48 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
656
613
  }
657
614
  return !e.defaultPrevented;
658
615
  }
616
+ /**
617
+ * Open Editor on DblClick
618
+ */
619
+ onElementDblClick(e) {
620
+ // DblClick prevented outside - Editor will not open
621
+ // Get data from the component
622
+ const data = this.getData();
623
+ const focusCell = getFocusCellBasedOnEvent(e, data);
624
+ if (!focusCell) {
625
+ return;
626
+ }
627
+ this.doEdit();
628
+ }
629
+ /**
630
+ * Handle mouse down event on Host element
631
+ */
659
632
  onElementMouseDown(e, touch = false) {
633
+ // Get the target element from the event object
634
+ const targetElement = e.target;
660
635
  // Ignore focus if clicked input
661
- if (isEditInput(e.target)) {
636
+ if (isEditInput(targetElement)) {
662
637
  return;
663
638
  }
639
+ // Get data from the component
664
640
  const data = this.getData();
665
- if (e.defaultPrevented) {
666
- return;
667
- }
668
- const x = getFromEvent(e, 'clientX');
669
- const y = getFromEvent(e, 'clientY');
670
- // skip touch
671
- if (x === null || y === null) {
641
+ const focusCell = getFocusCellBasedOnEvent(e, data);
642
+ if (!focusCell) {
672
643
  return;
673
644
  }
674
- // Regular cell click
675
- const focusCell = getCurrentCell({ x, y }, data);
676
- this.selectionStoreService.focus(focusCell, this.range && e.shiftKey);
645
+ // Set focus on the current cell
646
+ this.focus(focusCell, this.range && e.shiftKey);
677
647
  // Initiate autofill selection
678
648
  if (this.range) {
679
- this.autoFillService.selectionStart(e.target, data);
649
+ this.autoFillService.selectionStart(targetElement, this.getData());
650
+ // Prevent default behavior for mouse events,
651
+ // but only if target element is not a mobile input
680
652
  if (!touch) {
681
653
  e.preventDefault();
682
654
  }
683
655
  else if (verifyTouchTarget(e.touches[0], MOBILE_CLASS)) {
656
+ // Prevent default behavior for touch events
657
+ // if target element is a mobile input
684
658
  e.preventDefault();
685
659
  }
686
660
  }
@@ -691,8 +665,8 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
691
665
  doEdit(val = '') {
692
666
  var _a;
693
667
  if (this.canEdit()) {
694
- const editCell = this.selectionStore.get('focus');
695
- const data = this.columnService.getSaveData(editCell.y, editCell.x);
668
+ const focus = this.selectionStore.get('focus');
669
+ const data = this.columnService.getSaveData(focus.y, focus.x);
696
670
  (_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
697
671
  }
698
672
  }
@@ -715,8 +689,8 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
715
689
  this.cellEditApply.emit(dataToSave);
716
690
  }
717
691
  getRegion() {
718
- const focus = this.selectionStoreService.focused;
719
- let range = this.selectionStoreService.ranged;
692
+ const focus = this.selectionStore.get('focus');
693
+ let range = this.selectionStore.get('range');
720
694
  if (!range) {
721
695
  range = getRange(focus, focus);
722
696
  }
@@ -742,8 +716,8 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
742
716
  return true;
743
717
  }
744
718
  onPaste(data) {
745
- const focus = this.selectionStoreService.focused;
746
- const isEditing = this.selectionStoreService.edited !== null;
719
+ const focus = this.selectionStore.get('focus');
720
+ const isEditing = this.selectionStore.get('edit') !== null;
747
721
  if (!focus || isEditing) {
748
722
  return;
749
723
  }
@@ -763,13 +737,13 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
763
737
  }
764
738
  }
765
739
  clearCell() {
766
- if (this.selectionStoreService.ranged &&
767
- !isRangeSingleCell(this.selectionStoreService.ranged)) {
768
- const data = this.columnService.getRangeStaticData(this.selectionStoreService.ranged, '');
769
- this.autoFillService.onRangeApply(data, this.selectionStoreService.ranged);
740
+ if (this.selectionStore.get('range') &&
741
+ !isRangeSingleCell(this.selectionStore.get('range'))) {
742
+ const data = this.columnService.getRangeStaticData(this.selectionStore.get('range'), '');
743
+ this.autoFillService.onRangeApply(data, this.selectionStore.get('range'));
770
744
  }
771
745
  else if (this.canEdit()) {
772
- const focused = this.selectionStoreService.focused;
746
+ const focused = this.selectionStore.get('focus');
773
747
  const cell = this.columnService.getSaveData(focused.y, focused.x);
774
748
  this.cellEdit({
775
749
  rgRow: focused.y,
@@ -791,8 +765,24 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
791
765
  if (this.readonly) {
792
766
  return false;
793
767
  }
794
- const editCell = this.selectionStoreService.focused;
795
- return editCell && !((_a = this.columnService) === null || _a === void 0 ? void 0 : _a.isReadOnly(editCell.y, editCell.x));
768
+ const focus = this.selectionStore.get('focus');
769
+ return focus && !((_a = this.columnService) === null || _a === void 0 ? void 0 : _a.isReadOnly(focus.y, focus.x));
770
+ }
771
+ get edited() {
772
+ return this.selectionStore.get('edit');
773
+ }
774
+ /**
775
+ * Sets the focus on a cell and optionally edits a range.
776
+ */
777
+ focus(cell, isRangeEdit = false) {
778
+ if (!cell)
779
+ return false;
780
+ const end = cell;
781
+ const start = this.selectionStore.get('focus');
782
+ if (isRangeEdit && start) {
783
+ return this.triggerRangeEvent(getRange(start, end));
784
+ }
785
+ return this.doFocus(cell, end);
796
786
  }
797
787
  get types() {
798
788
  return {
@@ -809,6 +799,8 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class OverlaySelection
809
799
  rows: this.dimensionRow.state,
810
800
  cols: this.dimensionCol.state,
811
801
  lastCell: this.lastCell,
802
+ focus: this.selectionStore.get('focus'),
803
+ range: this.selectionStore.get('range'),
812
804
  };
813
805
  }
814
806
  get element() { return this; }
@@ -871,6 +863,6 @@ function defineCustomElement() {
871
863
  } });
872
864
  }
873
865
 
874
- export { OverlaySelection as O, defineCustomElement as d, getFromEvent as g };
866
+ export { OverlaySelection as O, defineCustomElement as d };
875
867
 
876
868
  //# sourceMappingURL=revogr-overlay-selection2.js.map