@revolist/revogrid 4.23.19 → 4.23.20

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.
@@ -929,13 +929,13 @@ const OverlaySelection = class {
929
929
  /**
930
930
  * Executes the focus operation on the specified range of cells.
931
931
  */
932
- doFocus(focus, end, changes) {
932
+ doFocus(focus, end, changes, originalEvent) {
933
933
  // 1. Trigger beforeFocus event
934
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
934
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
935
935
  if (defaultPrevented) {
936
936
  return false;
937
937
  }
938
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
938
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
939
939
  // 2. Trigger apply focus event
940
940
  const applyEvent = this.applyFocus.emit(evData);
941
941
  if (applyEvent.defaultPrevented) {
@@ -951,10 +951,10 @@ const OverlaySelection = class {
951
951
  y: range.y1,
952
952
  } }, applyEvent.detail)).defaultPrevented;
953
953
  }
954
- triggerRangeEvent(range) {
954
+ triggerRangeEvent(range, originalEvent) {
955
955
  const type = this.types.rowType;
956
956
  // 1. Apply range
957
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
957
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
958
958
  if (applyEvent.defaultPrevented) {
959
959
  return false;
960
960
  }
@@ -1005,7 +1005,7 @@ const OverlaySelection = class {
1005
1005
  return;
1006
1006
  }
1007
1007
  // Set focus on the current cell
1008
- this.focus(focusCell, this.range && e.shiftKey);
1008
+ this.focus(focusCell, this.range && e.shiftKey, e);
1009
1009
  // Initiate autofill selection
1010
1010
  if (this.range) {
1011
1011
  targetElement &&
@@ -1159,7 +1159,7 @@ const OverlaySelection = class {
1159
1159
  /**
1160
1160
  * Sets the focus on a cell and optionally edits a range.
1161
1161
  */
1162
- focus(cell, isRangeEdit = false) {
1162
+ focus(cell, isRangeEdit = false, originalEvent) {
1163
1163
  if (!cell)
1164
1164
  return false;
1165
1165
  const end = cell;
@@ -1167,10 +1167,10 @@ const OverlaySelection = class {
1167
1167
  if (isRangeEdit && start) {
1168
1168
  const range = column_service.getRange(start, end);
1169
1169
  if (range) {
1170
- return this.triggerRangeEvent(range);
1170
+ return this.triggerRangeEvent(range, originalEvent);
1171
1171
  }
1172
1172
  }
1173
- return this.doFocus(cell, end);
1173
+ return this.doFocus(cell, end, undefined, originalEvent);
1174
1174
  }
1175
1175
  get types() {
1176
1176
  return {
@@ -241,13 +241,13 @@ export class OverlaySelection {
241
241
  /**
242
242
  * Executes the focus operation on the specified range of cells.
243
243
  */
244
- doFocus(focus, end, changes) {
244
+ doFocus(focus, end, changes, originalEvent) {
245
245
  // 1. Trigger beforeFocus event
246
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
246
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
247
247
  if (defaultPrevented) {
248
248
  return false;
249
249
  }
250
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
250
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
251
251
  // 2. Trigger apply focus event
252
252
  const applyEvent = this.applyFocus.emit(evData);
253
253
  if (applyEvent.defaultPrevented) {
@@ -263,10 +263,10 @@ export class OverlaySelection {
263
263
  y: range.y1,
264
264
  } }, applyEvent.detail)).defaultPrevented;
265
265
  }
266
- triggerRangeEvent(range) {
266
+ triggerRangeEvent(range, originalEvent) {
267
267
  const type = this.types.rowType;
268
268
  // 1. Apply range
269
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
269
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
270
270
  if (applyEvent.defaultPrevented) {
271
271
  return false;
272
272
  }
@@ -317,7 +317,7 @@ export class OverlaySelection {
317
317
  return;
318
318
  }
319
319
  // Set focus on the current cell
320
- this.focus(focusCell, this.range && e.shiftKey);
320
+ this.focus(focusCell, this.range && e.shiftKey, e);
321
321
  // Initiate autofill selection
322
322
  if (this.range) {
323
323
  targetElement &&
@@ -471,7 +471,7 @@ export class OverlaySelection {
471
471
  /**
472
472
  * Sets the focus on a cell and optionally edits a range.
473
473
  */
474
- focus(cell, isRangeEdit = false) {
474
+ focus(cell, isRangeEdit = false, originalEvent) {
475
475
  if (!cell)
476
476
  return false;
477
477
  const end = cell;
@@ -479,10 +479,10 @@ export class OverlaySelection {
479
479
  if (isRangeEdit && start) {
480
480
  const range = getRange(start, end);
481
481
  if (range) {
482
- return this.triggerRangeEvent(range);
482
+ return this.triggerRangeEvent(range, originalEvent);
483
483
  }
484
484
  }
485
- return this.doFocus(cell, end);
485
+ return this.doFocus(cell, end, undefined, originalEvent);
486
486
  }
487
487
  get types() {
488
488
  return {
@@ -927,13 +927,13 @@ const OverlaySelection = class {
927
927
  /**
928
928
  * Executes the focus operation on the specified range of cells.
929
929
  */
930
- doFocus(focus, end, changes) {
930
+ doFocus(focus, end, changes, originalEvent) {
931
931
  // 1. Trigger beforeFocus event
932
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
932
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
933
933
  if (defaultPrevented) {
934
934
  return false;
935
935
  }
936
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
936
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
937
937
  // 2. Trigger apply focus event
938
938
  const applyEvent = this.applyFocus.emit(evData);
939
939
  if (applyEvent.defaultPrevented) {
@@ -949,10 +949,10 @@ const OverlaySelection = class {
949
949
  y: range.y1,
950
950
  } }, applyEvent.detail)).defaultPrevented;
951
951
  }
952
- triggerRangeEvent(range) {
952
+ triggerRangeEvent(range, originalEvent) {
953
953
  const type = this.types.rowType;
954
954
  // 1. Apply range
955
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
955
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
956
956
  if (applyEvent.defaultPrevented) {
957
957
  return false;
958
958
  }
@@ -1003,7 +1003,7 @@ const OverlaySelection = class {
1003
1003
  return;
1004
1004
  }
1005
1005
  // Set focus on the current cell
1006
- this.focus(focusCell, this.range && e.shiftKey);
1006
+ this.focus(focusCell, this.range && e.shiftKey, e);
1007
1007
  // Initiate autofill selection
1008
1008
  if (this.range) {
1009
1009
  targetElement &&
@@ -1157,7 +1157,7 @@ const OverlaySelection = class {
1157
1157
  /**
1158
1158
  * Sets the focus on a cell and optionally edits a range.
1159
1159
  */
1160
- focus(cell, isRangeEdit = false) {
1160
+ focus(cell, isRangeEdit = false, originalEvent) {
1161
1161
  if (!cell)
1162
1162
  return false;
1163
1163
  const end = cell;
@@ -1165,10 +1165,10 @@ const OverlaySelection = class {
1165
1165
  if (isRangeEdit && start) {
1166
1166
  const range = getRange(start, end);
1167
1167
  if (range) {
1168
- return this.triggerRangeEvent(range);
1168
+ return this.triggerRangeEvent(range, originalEvent);
1169
1169
  }
1170
1170
  }
1171
- return this.doFocus(cell, end);
1171
+ return this.doFocus(cell, end, undefined, originalEvent);
1172
1172
  }
1173
1173
  get types() {
1174
1174
  return {
@@ -927,13 +927,13 @@ const OverlaySelection = class {
927
927
  /**
928
928
  * Executes the focus operation on the specified range of cells.
929
929
  */
930
- doFocus(focus, end, changes) {
930
+ doFocus(focus, end, changes, originalEvent) {
931
931
  // 1. Trigger beforeFocus event
932
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
932
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
933
933
  if (defaultPrevented) {
934
934
  return false;
935
935
  }
936
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
936
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
937
937
  // 2. Trigger apply focus event
938
938
  const applyEvent = this.applyFocus.emit(evData);
939
939
  if (applyEvent.defaultPrevented) {
@@ -949,10 +949,10 @@ const OverlaySelection = class {
949
949
  y: range.y1,
950
950
  } }, applyEvent.detail)).defaultPrevented;
951
951
  }
952
- triggerRangeEvent(range) {
952
+ triggerRangeEvent(range, originalEvent) {
953
953
  const type = this.types.rowType;
954
954
  // 1. Apply range
955
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
955
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
956
956
  if (applyEvent.defaultPrevented) {
957
957
  return false;
958
958
  }
@@ -1003,7 +1003,7 @@ const OverlaySelection = class {
1003
1003
  return;
1004
1004
  }
1005
1005
  // Set focus on the current cell
1006
- this.focus(focusCell, this.range && e.shiftKey);
1006
+ this.focus(focusCell, this.range && e.shiftKey, e);
1007
1007
  // Initiate autofill selection
1008
1008
  if (this.range) {
1009
1009
  targetElement &&
@@ -1157,7 +1157,7 @@ const OverlaySelection = class {
1157
1157
  /**
1158
1158
  * Sets the focus on a cell and optionally edits a range.
1159
1159
  */
1160
- focus(cell, isRangeEdit = false) {
1160
+ focus(cell, isRangeEdit = false, originalEvent) {
1161
1161
  if (!cell)
1162
1162
  return false;
1163
1163
  const end = cell;
@@ -1165,10 +1165,10 @@ const OverlaySelection = class {
1165
1165
  if (isRangeEdit && start) {
1166
1166
  const range = getRange(start, end);
1167
1167
  if (range) {
1168
- return this.triggerRangeEvent(range);
1168
+ return this.triggerRangeEvent(range, originalEvent);
1169
1169
  }
1170
1170
  }
1171
- return this.doFocus(cell, end);
1171
+ return this.doFocus(cell, end, undefined, originalEvent);
1172
1172
  }
1173
1173
  get types() {
1174
1174
  return {
@@ -268,7 +268,7 @@ export declare class OverlaySelection {
268
268
  /**
269
269
  * Sets the focus on a cell and optionally edits a range.
270
270
  */
271
- focus(cell?: Cell, isRangeEdit?: boolean): boolean;
271
+ focus(cell?: Cell, isRangeEdit?: boolean, originalEvent?: MouseEvent | TouchEvent | KeyboardEvent): boolean;
272
272
  get types(): AllDimensionType;
273
273
  /**
274
274
  * Collect data
@@ -742,6 +742,10 @@ export interface FocusRenderEvent extends AllDimensionType {
742
742
  * Changes for the next cell to focus. @example { y: -1 }
743
743
  */
744
744
  next?: Partial<Cell>;
745
+ /**
746
+ * Original user input event that initiated the focus/range change, when available.
747
+ */
748
+ originalEvent?: MouseEvent | TouchEvent | KeyboardEvent;
745
749
  }
746
750
  export interface FocusAfterRenderEvent<TModel extends DataType = DataType> extends AllDimensionType {
747
751
  model?: TModel;
@@ -117,6 +117,10 @@ export interface BeforeSaveDataDetails<TModel extends DataType = DataType, TColu
117
117
  * Value from editor to save, not part of the model value yet
118
118
  */
119
119
  val?: any;
120
+ /**
121
+ * Original user input event that initiated the save/focus flow, when available.
122
+ */
123
+ originalEvent?: MouseEvent | TouchEvent | KeyboardEvent;
120
124
  }
121
125
  export type BeforeRangeSaveDataDetails<TModel extends DataType = DataType> = {
122
126
  data: {
package/hydrate/index.js CHANGED
@@ -14270,13 +14270,13 @@ class OverlaySelection {
14270
14270
  /**
14271
14271
  * Executes the focus operation on the specified range of cells.
14272
14272
  */
14273
- doFocus(focus, end, changes) {
14273
+ doFocus(focus, end, changes, originalEvent) {
14274
14274
  // 1. Trigger beforeFocus event
14275
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
14275
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
14276
14276
  if (defaultPrevented) {
14277
14277
  return false;
14278
14278
  }
14279
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
14279
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
14280
14280
  // 2. Trigger apply focus event
14281
14281
  const applyEvent = this.applyFocus.emit(evData);
14282
14282
  if (applyEvent.defaultPrevented) {
@@ -14292,10 +14292,10 @@ class OverlaySelection {
14292
14292
  y: range.y1,
14293
14293
  } }, applyEvent.detail)).defaultPrevented;
14294
14294
  }
14295
- triggerRangeEvent(range) {
14295
+ triggerRangeEvent(range, originalEvent) {
14296
14296
  const type = this.types.rowType;
14297
14297
  // 1. Apply range
14298
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
14298
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
14299
14299
  if (applyEvent.defaultPrevented) {
14300
14300
  return false;
14301
14301
  }
@@ -14346,7 +14346,7 @@ class OverlaySelection {
14346
14346
  return;
14347
14347
  }
14348
14348
  // Set focus on the current cell
14349
- this.focus(focusCell, this.range && e.shiftKey);
14349
+ this.focus(focusCell, this.range && e.shiftKey, e);
14350
14350
  // Initiate autofill selection
14351
14351
  if (this.range) {
14352
14352
  targetElement &&
@@ -14500,7 +14500,7 @@ class OverlaySelection {
14500
14500
  /**
14501
14501
  * Sets the focus on a cell and optionally edits a range.
14502
14502
  */
14503
- focus(cell, isRangeEdit = false) {
14503
+ focus(cell, isRangeEdit = false, originalEvent) {
14504
14504
  if (!cell)
14505
14505
  return false;
14506
14506
  const end = cell;
@@ -14508,10 +14508,10 @@ class OverlaySelection {
14508
14508
  if (isRangeEdit && start) {
14509
14509
  const range = getRange(start, end);
14510
14510
  if (range) {
14511
- return this.triggerRangeEvent(range);
14511
+ return this.triggerRangeEvent(range, originalEvent);
14512
14512
  }
14513
14513
  }
14514
- return this.doFocus(cell, end);
14514
+ return this.doFocus(cell, end, undefined, originalEvent);
14515
14515
  }
14516
14516
  get types() {
14517
14517
  return {
package/hydrate/index.mjs CHANGED
@@ -14268,13 +14268,13 @@ class OverlaySelection {
14268
14268
  /**
14269
14269
  * Executes the focus operation on the specified range of cells.
14270
14270
  */
14271
- doFocus(focus, end, changes) {
14271
+ doFocus(focus, end, changes, originalEvent) {
14272
14272
  // 1. Trigger beforeFocus event
14273
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
14273
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
14274
14274
  if (defaultPrevented) {
14275
14275
  return false;
14276
14276
  }
14277
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
14277
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
14278
14278
  // 2. Trigger apply focus event
14279
14279
  const applyEvent = this.applyFocus.emit(evData);
14280
14280
  if (applyEvent.defaultPrevented) {
@@ -14290,10 +14290,10 @@ class OverlaySelection {
14290
14290
  y: range.y1,
14291
14291
  } }, applyEvent.detail)).defaultPrevented;
14292
14292
  }
14293
- triggerRangeEvent(range) {
14293
+ triggerRangeEvent(range, originalEvent) {
14294
14294
  const type = this.types.rowType;
14295
14295
  // 1. Apply range
14296
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
14296
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
14297
14297
  if (applyEvent.defaultPrevented) {
14298
14298
  return false;
14299
14299
  }
@@ -14344,7 +14344,7 @@ class OverlaySelection {
14344
14344
  return;
14345
14345
  }
14346
14346
  // Set focus on the current cell
14347
- this.focus(focusCell, this.range && e.shiftKey);
14347
+ this.focus(focusCell, this.range && e.shiftKey, e);
14348
14348
  // Initiate autofill selection
14349
14349
  if (this.range) {
14350
14350
  targetElement &&
@@ -14498,7 +14498,7 @@ class OverlaySelection {
14498
14498
  /**
14499
14499
  * Sets the focus on a cell and optionally edits a range.
14500
14500
  */
14501
- focus(cell, isRangeEdit = false) {
14501
+ focus(cell, isRangeEdit = false, originalEvent) {
14502
14502
  if (!cell)
14503
14503
  return false;
14504
14504
  const end = cell;
@@ -14506,10 +14506,10 @@ class OverlaySelection {
14506
14506
  if (isRangeEdit && start) {
14507
14507
  const range = getRange(start, end);
14508
14508
  if (range) {
14509
- return this.triggerRangeEvent(range);
14509
+ return this.triggerRangeEvent(range, originalEvent);
14510
14510
  }
14511
14511
  }
14512
- return this.doFocus(cell, end);
14512
+ return this.doFocus(cell, end, undefined, originalEvent);
14513
14513
  }
14514
14514
  get types() {
14515
14515
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolist/revogrid",
3
- "version": "4.23.19",
3
+ "version": "4.23.20",
4
4
  "type": "module",
5
5
  "description": "Virtual reactive data grid spreadsheet component - RevoGrid.",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import{h as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,Host as o,transformTag as n}from"@stencil/core/internal/client";import{g as r,M as a,z as l,N as h,b as c}from"./column.service.js";import{c as d}from"./platform.js";import{R as u,i as g,j as p,S as v}from"./consts.js";import{b as f,i as b,c as m,a as y,g as x,d as w,e as j,s as O,f as S,v as D}from"./selection.utils.js";import{l as C,m as M,c as R,d as k,f as E,h as A,g as F,j as T,k as P,o as z}from"./revogr-edit2.js";import{t as K}from"./index2.js";import{d as U}from"./debounce.js";import{d as X}from"./revogr-clipboard2.js";import{d as $}from"./revogr-order-editor2.js";const H=[d.TAB,d.ARROW_UP,d.ARROW_DOWN,d.ARROW_LEFT,d.ARROW_RIGHT];class L{constructor(t){this.sv=t}appendPendingEditValue(t){if(C(t)||1!==t.key.length||t.target instanceof HTMLElement&&M(t.target))return!1;const e=this.sv.selectionStore.get("edit");return"string"==typeof(null==e?void 0:e.val)&&(this.sv.selectionStore.set("edit",Object.assign(Object.assign({},e),{val:`${e.val}${t.key}`})),!0)}async keyDown(t,e,i,{range:s,focus:o}){if(i){if(this.appendPendingEditValue(t))return;switch(t.code){case d.ESCAPE:this.sv.cancel();break;case d.TAB:this.keyChangeSelection(t,e)}}else s&&R(t.code)?this.sv.clearCell():o&&(k(t.code)?this.keyChangeSelection(t,e):E(t.key)?this.sv.change():A(t)||F(t)||(T(t)?this.sv.internalPaste():P(t)?e&&this.selectAll(t):C(t)||1!==t.key.length?await this.keyChangeSelection(t,e):this.sv.change(t.key)))}selectAll(t){const e=this.sv.selectionStore.get("range"),i=this.sv.selectionStore.get("focus");e&&i&&(t.preventDefault(),this.sv.selectAll())}async keyChangeSelection(t,e){const i=this.changeDirectionKey(t,e);if(!i)return!1;await K(u+30);const s=this.sv.selectionStore.get("range"),o=this.sv.selectionStore.get("focus");return this.keyPositionChange(i.changes,s,o,i.isMulti)}keyPositionChange(t,e,i,s=!1){if(!e||!i)return!1;const o=f(e,i,t,s);if(!o)return!1;const n=this.sv.getData();if(s){if([o.start,o.end].some((t=>b(t,n.lastCell)||m(t))))return!1;const t=r(o.start,o.end);return this.sv.range(t)}return this.sv.focus(o.start,t,b(o.start,n.lastCell)?1:m(o.start)?-1:0)}changeDirectionKey(t,e){const i=e&&t.shiftKey;if(H.includes(t.code)&&t.preventDefault(),t.shiftKey&&t.code===d.TAB)return{changes:{x:-1},isMulti:!1};switch(t.code){case d.ARROW_UP:return{changes:{y:-1},isMulti:i};case d.ARROW_DOWN:return{changes:{y:1},isMulti:i};case d.ARROW_LEFT:return{changes:{x:-1},isMulti:i};case d.TAB:case d.ARROW_RIGHT:return{changes:{x:1},isMulti:i}}}}class N{constructor(t){this.sv=t,this.autoFillType=null,this.autoFillInitial=null,this.autoFillStart=null,this.autoFillLast=null}renderAutofill(e,i,s=!1){let o;return o=y(e||Object.assign(Object.assign({},i),{x1:i.x,y1:i.y}),this.sv.dimensionRow.state,this.sv.dimensionCol.state),t("div",{class:{[p]:!0,[g]:s},style:{left:`${o.right}px`,top:`${o.bottom}px`},onMouseDown:t=>this.autoFillHandler(t),onTouchStart:t=>this.autoFillHandler(t)})}autoFillHandler(t,e="AutoFill"){let i=null;t.target instanceof Element&&(i=t.target),i&&(this.selectionStart(i,this.sv.getData(),e),t.preventDefault())}get isAutoFill(){return!!this.autoFillType}selectionMouseMove(t){this.onMouseMoveAutofill||(this.onMouseMoveAutofill=U(((t,e)=>this.doAutofillMouseMove(t,e)),5)),this.isAutoFill&&this.onMouseMoveAutofill(t,this.sv.getData())}getFocus(t,e){return!t&&e&&(t={x:e.x,y:e.y}),t||null}doAutofillMouseMove(t,e){if(!this.autoFillInitial)return;const i=x(t,"clientX",g),s=x(t,"clientY",g);if(null===i||null===s)return;const o=w({x:i,y:s},e);if(this.autoFillLast||this.autoFillLast||(this.autoFillLast=this.autoFillStart),!b(o,e.lastCell))if(this.autoFillLast=o,o.x===this.autoFillInitial.x&&o.y===this.autoFillInitial.y)this.sv.setTempRange(null);else{const t=r(this.autoFillInitial,this.autoFillLast);this.sv.setTempRange({area:t,type:this.autoFillType})}}selectionStart(t,e,i="Selection"){const{top:s,left:o}=t.getBoundingClientRect();this.autoFillInitial=this.getFocus(e.focus,e.range),this.autoFillType=i,this.autoFillStart=w({x:o,y:s},e)}clearAutoFillSelection(t,e){if(this.autoFillInitial)if(this.autoFillInitial=this.getFocus(t,e),"AutoFill"===this.autoFillType){const t=r(this.autoFillInitial,this.autoFillLast);if(t){const{defaultPrevented:i,detail:{range:s}}=this.sv.clearRangeDataApply({range:t});!i&&e?this.applyRangeWithData(s,e):this.sv.setTempRange(null)}}else this.applyRangeOnly(this.autoFillInitial,this.autoFillLast);this.resetAutoFillState()}resetAutoFillState(){this.autoFillType=null,this.autoFillInitial=null,this.autoFillLast=null,this.autoFillStart=null}onRangeApply(t,e,i){this.sv.rangeDataApply({data:t,models:j(t,this.sv.dataStore),type:this.sv.dataStore.get("type"),oldRange:i,newRange:e}),this.sv.setRange(e)}applyRangeWithData(t,e){const i={type:this.sv.dataStore.get("type"),colType:this.sv.columnService.type,newData:{},mapping:{},newRange:t,oldRange:e},{mapping:s,changed:o}=this.sv.columnService.getRangeData(i,this.sv.columnService.columns);i.newData=o,i.mapping=s;let n=this.sv.selectionChanged(i);n.defaultPrevented?this.sv.setTempRange(null):(n=this.sv.rangeCopy(i),n.defaultPrevented?this.sv.setRange(t):this.onRangeApply(i.newData,t,e))}applyRangeOnly(t,e){if(!t||!e)return;const i=r(t,e);this.sv.setRange(i)}}const W=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.beforeCopyRegion=s(this,"beforecopyregion",7),this.beforeRegionPaste=s(this,"beforepasteregion",7),this.cellEditApply=s(this,"celleditapply",7),this.beforeFocusCell=s(this,"beforecellfocusinit",7),this.beforeNextViewportFocus=s(this,"beforenextvpfocus",7),this.setEdit=s(this,"setedit",7),this.beforeApplyRange=s(this,"beforeapplyrange",7),this.beforeSetRange=s(this,"beforesetrange",7),this.setRange=s(this,"setrange",7),this.beforeEditRender=s(this,"beforeeditrender",7),this.selectAll=s(this,"selectall",7),this.cancelEdit=s(this,"canceledit",7),this.setTempRange=s(this,"settemprange",7),this.beforeSetTempRange=s(this,"beforesettemprange",7),this.applyFocus=s(this,"applyfocus",7),this.focusCell=s(this,"focuscell",7),this.beforeRangeDataApply=s(this,"beforerangedataapply",7),this.selectionChange=s(this,"selectionchangeinit",7),this.beforeRangeCopyApply=s(this,"beforerangecopyapply",7),this.rangeEditApply=s(this,"rangeeditapply",7),this.rangeClipboardCopy=s(this,"clipboardrangecopy",7),this.rangeClipboardPaste=s(this,"clipboardrangepaste",7),this.beforeKeyDown=s(this,"beforekeydown",7),this.beforeKeyUp=s(this,"beforekeyup",7),this.beforeCellSave=s(this,"beforecellsave",7),this.cellEditDone=s(this,"celledit",7),this.applyChangesOnClose=!1,this.keyboardService=null,this.autoFillService=null,this.unsubscribeSelectionStore=[]}onMouseMove(t){var e;this.selectionStore.get("focus")&&(null===(e=this.autoFillService)||void 0===e||e.selectionMouseMove(t))}onMouseUp(){var t;null===(t=this.autoFillService)||void 0===t||t.clearAutoFillSelection(this.selectionStore.get("focus"),this.selectionStore.get("range"))}onCellDrag(t){var e;null===(e=this.orderEditor)||void 0===e||e.dragStart(t.detail)}onKeyUp(t){this.beforeKeyUp.emit(Object.assign({original:t},this.getData()))}onKeyDown(t){var e;const i=this.beforeKeyDown.emit(Object.assign({original:t},this.getData()));t.defaultPrevented||i.defaultPrevented||null===(e=this.keyboardService)||void 0===e||e.keyDown(t,this.range,!!this.selectionStore.get("edit"),{focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range")})}selectionServiceSet(t){this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,this.unsubscribeSelectionStore.push(t.onChange("nextFocus",(t=>t&&this.doFocus(t,t)))),this.keyboardService=new L({selectionStore:t,range:t=>!!t&&this.triggerRangeEvent(t),focus:(t,e,i)=>i?(this.beforeNextViewportFocus.emit(t),!1):this.doFocus(t,t,e),change:t=>{this.readonly||this.doEdit(t)},cancel:async()=>{var t;await(null===(t=this.revogrEdit)||void 0===t?void 0:t.cancelChanges()),this.closeEdit()},clearCell:()=>!this.readonly&&this.clearCell(),internalPaste:()=>!this.readonly&&this.beforeRegionPaste.emit(),getData:()=>this.getData(),selectAll:()=>this.selectAll.emit()}),this.createAutoFillService()}createAutoFillService(){this.autoFillService=new N({dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,columnService:this.columnService,dataStore:this.dataStore,clearRangeDataApply:t=>this.beforeRangeDataApply.emit(Object.assign(Object.assign(Object.assign({},t),this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)})),setTempRange:t=>{const e=this.beforeSetTempRange.emit(Object.assign(Object.assign({tempRange:t},this.getData()),this.types));return e.defaultPrevented?null:this.setTempRange.emit(e.detail.tempRange)},selectionChanged:t=>this.selectionChange.emit(t),rangeCopy:t=>this.beforeRangeCopyApply.emit(t),rangeDataApply:t=>this.rangeEditApply.emit(t),setRange:t=>!!t&&this.triggerRangeEvent(t),getData:()=>this.getData()})}columnServiceSet(){var t;null===(t=this.columnService)||void 0===t||t.destroy(),this.columnService=new a(this.dataStore,this.colData),this.createAutoFillService()}connectedCallback(){this.columnServiceSet(),this.selectionServiceSet(this.selectionStore)}disconnectedCallback(){var t;this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,null===(t=this.columnService)||void 0===t||t.destroy()}async componentWillRender(){var t,e;this.selectionStore.get("edit")||await(null===(e=null===(t=this.revogrEdit)||void 0===t?void 0:t.beforeDisconnect)||void 0===e?void 0:e.call(t))}renderRange(e){const i=y(e,this.dimensionRow.state,this.dimensionCol.state),s=O(i);return[t("div",{class:v,style:s},this.isMobileDevice&&t("div",{class:"range-handlers"},t("span",{class:g}),t("span",{class:g})))]}renderEditor(){const e=this.selectionStore.get("edit");if(this.readonly||!e)return null;const i=e.val||l(this.columnService.rowDataModel(e.y,e.x).value),s=Object.assign(Object.assign({},e),this.columnService.getSaveData(e.y,e.x,i)),o=this.beforeEditRender.emit(Object.assign(Object.assign({range:Object.assign(Object.assign({},e),{x1:e.x,y1:e.y})},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}));if(o.defaultPrevented)return null;const n=y(o.detail.range,o.detail.rowDimension,o.detail.colDimension),r=O(n);return t("revogr-edit",{style:r,ref:t=>this.revogrEdit=t,additionalData:this.additionalData,editCell:s,saveOnClose:this.applyChangesOnClose,onCelleditinit:t=>{this.cellEditDone.emit(t.detail)},column:this.columnService.rowDataModel(e.y,e.x),editor:h(this.columnService.columns[e.x],this.editors)})}onEditCell(t){if(t.defaultPrevented)return;const e=this.beforeCellSave.emit(t.detail);e.defaultPrevented||this.cellEdit(e.detail),e.detail.preventFocus||this.focusNext()}render(){var e;const i=[],s=this.renderEditor();if(s)i.push(s);else{const s=this.selectionStore.get("range"),o=this.selectionStore.get("focus");(s||o)&&this.useClipboard&&i.push(t("revogr-clipboard",{readonly:this.readonly,onCopyregion:t=>this.onCopy(t.detail),onClearregion:()=>!this.readonly&&this.clearCell(),ref:t=>this.clipboard=t,onPasteregion:t=>this.onPaste(t.detail)})),s&&i.push(...this.renderRange(s)),o&&!this.readonly&&this.range&&i.push(null===(e=this.autoFillService)||void 0===e?void 0:e.renderAutofill(s,o,this.isMobileDevice)),this.canDrag&&i.push(t("revogr-order-editor",{ref:t=>this.orderEditor=t,dataStore:this.dataStore,dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,parent:this.element,rowType:this.types.rowType,onRowdragstartinit:t=>this.rowDragStart(t)}))}return t(o,{key:"ff303c39d59e4ef217421fa11b9a80de07311b07",class:{mobile:this.isMobileDevice},onDblClick:t=>this.onElementDblClick(t),onMouseDown:t=>this.onElementMouseDown(t),onTouchStart:t=>this.onElementMouseDown(t,!0),onCloseedit:t=>this.closeEdit(t),onCelledit:t=>this.onEditCell(t)},i,t("slot",{key:"3cbe4c3ad7d447f779e9e20f73eec2e3107275e0",name:"data"}))}doFocus(t,e,i){const{defaultPrevented:s}=this.beforeFocusCell.emit(this.columnService.getSaveData(t.y,t.x));if(s)return!1;const o=Object.assign(Object.assign({range:Object.assign(Object.assign({},t),{x1:e.x,y1:e.y}),next:i},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}),n=this.applyFocus.emit(o);if(n.defaultPrevented)return!1;const{range:r}=n.detail;return!this.focusCell.emit(Object.assign({focus:{x:r.x,y:r.y},end:{x:r.x1,y:r.y1}},n.detail)).defaultPrevented}triggerRangeEvent(t){const e=this.types.rowType,i=this.beforeApplyRange.emit(Object.assign(Object.assign({range:Object.assign({},t)},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}));if(i.defaultPrevented)return!1;const s=this.columnService.getRangeTransformedToProps(i.detail.range,this.dataStore);let o=this.beforeSetRange.emit(s);return!o.defaultPrevented&&(o=this.setRange.emit(Object.assign(Object.assign({},i.detail.range),{type:e})),!o.defaultPrevented&&!o.defaultPrevented)}onElementDblClick(t){if(t.defaultPrevented)return;const e=this.getData();S(t,e)&&this.doEdit()}onElementMouseDown(t,e=!1){var i;const s=t.target;if(M(s)||t.defaultPrevented)return;const o=this.getData(),n=S(t,o);n&&(this.focus(n,this.range&&t.shiftKey),this.range&&(s&&(null===(i=this.autoFillService)||void 0===i||i.selectionStart(s,this.getData())),e?D(t.touches[0],g)&&t.preventDefault():t.preventDefault()))}doEdit(t=""){var e;if(this.canEdit()){const i=this.selectionStore.get("focus");if(!i)return;const s=this.columnService.getSaveData(i.y,i.x);null===(e=this.setEdit)||void 0===e||e.emit(Object.assign(Object.assign({},s),{val:t}))}}async closeEdit(t){this.cancelEdit.emit(),(null==t?void 0:t.detail)&&await this.focusNext()}cellEdit(t){const e=this.columnService.getSaveData(t.rgRow,t.rgCol,t.val);this.cellEditApply.emit(e)}getRegion(){const t=this.selectionStore.get("focus");let e=this.selectionStore.get("range");return e||(e=r(t,t)),e}onCopy(t){var e;const i=this.getRegion();if(this.beforeCopyRegion.emit(i).defaultPrevented)return!1;let s;if(i){const{data:t,mapping:e}=this.columnService.copyRangeArray(i,this.dataStore),o=this.rangeClipboardCopy.emit(Object.assign({range:i,data:t,mapping:e},this.types));o.defaultPrevented||(s=o.detail.data)}return null===(e=this.clipboard)||void 0===e||e.doCopy(t,s),!0}onPaste(t){var e;const i=this.selectionStore.get("focus"),s=null!==this.selectionStore.get("edit");if(!i||s)return;const o=function(t,e){var i;if(!function(t){return"object"==typeof t&&!0===t.rangeFill}(e))return null;const s=function(t){const e=[...t];for(;e.length>1&&(!(i=e[e.length-1])||i.every((t=>""===t)));)e.pop();var i;return e}(t);return 1===s.length&&1===(null===(i=s[0])||void 0===i?void 0:i.length)?s:null}(t,this.useClipboard),n=o?this.getClipboardPasteTargetRange():null;let{changed:r,range:a}=this.columnService.getTransformedDataToApply({start:i,data:o||t,targetRange:n});const{defaultPrevented:l}=this.rangeClipboardPaste.emit(Object.assign({data:r,models:j(r,this.dataStore),range:a},this.types));l||null===(e=this.autoFillService)||void 0===e||e.onRangeApply(r,a,a)}getClipboardPasteTargetRange(){const t=this.selectionStore.get("range");return t&&!c(t)?t:null}async focusNext(){var t;await(null===(t=this.keyboardService)||void 0===t?void 0:t.keyChangeSelection(new KeyboardEvent("keydown",{code:d.ARROW_DOWN}),this.range))||this.closeEdit()}clearCell(){var t;const e=this.selectionStore.get("range");if(e&&!c(e)){const i=this.columnService.getRangeStaticData(e,"");null===(t=this.autoFillService)||void 0===t||t.onRangeApply(i,e,e)}else if(this.canEdit()){const t=this.selectionStore.get("focus");if(!t)return;const e=this.columnService.getSaveData(t.y,t.x);this.cellEdit({rgRow:t.y,rgCol:t.x,val:"",type:e.type,prop:e.prop})}}rowDragStart({detail:t}){t.text=l(this.columnService.rowDataModel(t.cell.y,t.cell.x).value)}canEdit(){var t;if(this.readonly)return!1;const e=this.selectionStore.get("focus");return e&&!(null===(t=this.columnService)||void 0===t?void 0:t.isReadOnly(e.y,e.x))}get edited(){return this.selectionStore.get("edit")}focus(t,e=!1){if(!t)return!1;const i=t,s=this.selectionStore.get("focus");if(e&&s){const t=r(s,i);if(t)return this.triggerRangeEvent(t)}return this.doFocus(t,i)}get types(){return{rowType:this.dataStore.get("type"),colType:this.columnService.type}}getData(){return{el:this.element,rows:this.dimensionRow.state,cols:this.dimensionCol.state,lastCell:this.lastCell,focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range"),edit:this.selectionStore.get("edit")}}get element(){return this}static get watchers(){return{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}}static get style(){return'revogr-overlay-selection{display:block;position:relative;width:100%}revogr-overlay-selection .autofill-handle{position:absolute;width:14px;height:14px;margin-left:-13px;margin-top:-13px;z-index:10;cursor:crosshair}revogr-overlay-selection .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection.mobile .autofill-handle{position:absolute;width:30px;height:30px;margin-left:-29px;margin-top:-29px;z-index:10;cursor:crosshair}revogr-overlay-selection.mobile .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:12px;height:12px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9;box-shadow:-1px 0 0 #0d63e8 inset, 1px 0 0 #0d63e8 inset, 0 -1px 0 #0d63e8 inset, 0 1px 0 #0d63e8 inset}revogr-overlay-selection .selection-border-range .range-handlers{height:100%;background-color:transparent;width:75%;max-width:50px;min-width:20px;left:50%;transform:translateX(-50%);position:absolute}revogr-overlay-selection .selection-border-range .range-handlers>span{pointer-events:auto;height:20px;width:20px;position:absolute;left:50%;transform:translateX(-50%)}revogr-overlay-selection .selection-border-range .range-handlers>span:before,revogr-overlay-selection .selection-border-range .range-handlers>span:after{position:absolute;border-radius:5px;width:15px;height:5px;left:50%;transform:translateX(-50%);background-color:rgba(0, 0, 0, 0.2)}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child{top:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child:before{content:"";top:0}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child{bottom:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child:after{content:"";bottom:0}revogr-overlay-selection revogr-edit{z-index:10}'}},[260,"revogr-overlay-selection",{readonly:[4],range:[4],canDrag:[4,"can-drag"],useClipboard:[4,"use-clipboard"],selectionStore:[16],dimensionRow:[16],dimensionCol:[16],dataStore:[16],colData:[16],lastCell:[16],editors:[16],applyChangesOnClose:[4,"apply-changes-on-close"],additionalData:[8,"additional-data"],isMobileDevice:[4,"is-mobile-device"]},[[5,"touchmove","onMouseMove"],[5,"mousemove","onMouseMove"],[5,"touchend","onMouseUp"],[5,"mouseup","onMouseUp"],[5,"mouseleave","onMouseUp"],[0,"dragstartcell","onCellDrag"],[4,"keyup","onKeyUp"],[4,"keydown","onKeyDown"]],{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}]);function V(){"undefined"!=typeof customElements&&["revogr-overlay-selection","revogr-clipboard","revogr-edit","revogr-order-editor"].forEach((t=>{switch(t){case"revogr-overlay-selection":customElements.get(n(t))||customElements.define(n(t),W);break;case"revogr-clipboard":customElements.get(n(t))||X();break;case"revogr-edit":customElements.get(n(t))||z();break;case"revogr-order-editor":customElements.get(n(t))||$()}}))}export{W as O,V as d}
4
+ import{h as t,proxyCustomElement as e,HTMLElement as i,createEvent as s,Host as o,transformTag as n}from"@stencil/core/internal/client";import{g as r,M as a,z as l,N as h,b as c}from"./column.service.js";import{c as d}from"./platform.js";import{R as u,i as g,j as p,S as v}from"./consts.js";import{b as f,i as b,c as m,a as y,g as x,d as w,e as j,s as O,f as S,v as D}from"./selection.utils.js";import{l as C,m as M,c as R,d as k,f as E,h as A,g as F,j as T,k as P,o as z}from"./revogr-edit2.js";import{t as K}from"./index2.js";import{d as U}from"./debounce.js";import{d as X}from"./revogr-clipboard2.js";import{d as $}from"./revogr-order-editor2.js";const H=[d.TAB,d.ARROW_UP,d.ARROW_DOWN,d.ARROW_LEFT,d.ARROW_RIGHT];class L{constructor(t){this.sv=t}appendPendingEditValue(t){if(C(t)||1!==t.key.length||t.target instanceof HTMLElement&&M(t.target))return!1;const e=this.sv.selectionStore.get("edit");return"string"==typeof(null==e?void 0:e.val)&&(this.sv.selectionStore.set("edit",Object.assign(Object.assign({},e),{val:`${e.val}${t.key}`})),!0)}async keyDown(t,e,i,{range:s,focus:o}){if(i){if(this.appendPendingEditValue(t))return;switch(t.code){case d.ESCAPE:this.sv.cancel();break;case d.TAB:this.keyChangeSelection(t,e)}}else s&&R(t.code)?this.sv.clearCell():o&&(k(t.code)?this.keyChangeSelection(t,e):E(t.key)?this.sv.change():A(t)||F(t)||(T(t)?this.sv.internalPaste():P(t)?e&&this.selectAll(t):C(t)||1!==t.key.length?await this.keyChangeSelection(t,e):this.sv.change(t.key)))}selectAll(t){const e=this.sv.selectionStore.get("range"),i=this.sv.selectionStore.get("focus");e&&i&&(t.preventDefault(),this.sv.selectAll())}async keyChangeSelection(t,e){const i=this.changeDirectionKey(t,e);if(!i)return!1;await K(u+30);const s=this.sv.selectionStore.get("range"),o=this.sv.selectionStore.get("focus");return this.keyPositionChange(i.changes,s,o,i.isMulti)}keyPositionChange(t,e,i,s=!1){if(!e||!i)return!1;const o=f(e,i,t,s);if(!o)return!1;const n=this.sv.getData();if(s){if([o.start,o.end].some((t=>b(t,n.lastCell)||m(t))))return!1;const t=r(o.start,o.end);return this.sv.range(t)}return this.sv.focus(o.start,t,b(o.start,n.lastCell)?1:m(o.start)?-1:0)}changeDirectionKey(t,e){const i=e&&t.shiftKey;if(H.includes(t.code)&&t.preventDefault(),t.shiftKey&&t.code===d.TAB)return{changes:{x:-1},isMulti:!1};switch(t.code){case d.ARROW_UP:return{changes:{y:-1},isMulti:i};case d.ARROW_DOWN:return{changes:{y:1},isMulti:i};case d.ARROW_LEFT:return{changes:{x:-1},isMulti:i};case d.TAB:case d.ARROW_RIGHT:return{changes:{x:1},isMulti:i}}}}class N{constructor(t){this.sv=t,this.autoFillType=null,this.autoFillInitial=null,this.autoFillStart=null,this.autoFillLast=null}renderAutofill(e,i,s=!1){let o;return o=y(e||Object.assign(Object.assign({},i),{x1:i.x,y1:i.y}),this.sv.dimensionRow.state,this.sv.dimensionCol.state),t("div",{class:{[p]:!0,[g]:s},style:{left:`${o.right}px`,top:`${o.bottom}px`},onMouseDown:t=>this.autoFillHandler(t),onTouchStart:t=>this.autoFillHandler(t)})}autoFillHandler(t,e="AutoFill"){let i=null;t.target instanceof Element&&(i=t.target),i&&(this.selectionStart(i,this.sv.getData(),e),t.preventDefault())}get isAutoFill(){return!!this.autoFillType}selectionMouseMove(t){this.onMouseMoveAutofill||(this.onMouseMoveAutofill=U(((t,e)=>this.doAutofillMouseMove(t,e)),5)),this.isAutoFill&&this.onMouseMoveAutofill(t,this.sv.getData())}getFocus(t,e){return!t&&e&&(t={x:e.x,y:e.y}),t||null}doAutofillMouseMove(t,e){if(!this.autoFillInitial)return;const i=x(t,"clientX",g),s=x(t,"clientY",g);if(null===i||null===s)return;const o=w({x:i,y:s},e);if(this.autoFillLast||this.autoFillLast||(this.autoFillLast=this.autoFillStart),!b(o,e.lastCell))if(this.autoFillLast=o,o.x===this.autoFillInitial.x&&o.y===this.autoFillInitial.y)this.sv.setTempRange(null);else{const t=r(this.autoFillInitial,this.autoFillLast);this.sv.setTempRange({area:t,type:this.autoFillType})}}selectionStart(t,e,i="Selection"){const{top:s,left:o}=t.getBoundingClientRect();this.autoFillInitial=this.getFocus(e.focus,e.range),this.autoFillType=i,this.autoFillStart=w({x:o,y:s},e)}clearAutoFillSelection(t,e){if(this.autoFillInitial)if(this.autoFillInitial=this.getFocus(t,e),"AutoFill"===this.autoFillType){const t=r(this.autoFillInitial,this.autoFillLast);if(t){const{defaultPrevented:i,detail:{range:s}}=this.sv.clearRangeDataApply({range:t});!i&&e?this.applyRangeWithData(s,e):this.sv.setTempRange(null)}}else this.applyRangeOnly(this.autoFillInitial,this.autoFillLast);this.resetAutoFillState()}resetAutoFillState(){this.autoFillType=null,this.autoFillInitial=null,this.autoFillLast=null,this.autoFillStart=null}onRangeApply(t,e,i){this.sv.rangeDataApply({data:t,models:j(t,this.sv.dataStore),type:this.sv.dataStore.get("type"),oldRange:i,newRange:e}),this.sv.setRange(e)}applyRangeWithData(t,e){const i={type:this.sv.dataStore.get("type"),colType:this.sv.columnService.type,newData:{},mapping:{},newRange:t,oldRange:e},{mapping:s,changed:o}=this.sv.columnService.getRangeData(i,this.sv.columnService.columns);i.newData=o,i.mapping=s;let n=this.sv.selectionChanged(i);n.defaultPrevented?this.sv.setTempRange(null):(n=this.sv.rangeCopy(i),n.defaultPrevented?this.sv.setRange(t):this.onRangeApply(i.newData,t,e))}applyRangeOnly(t,e){if(!t||!e)return;const i=r(t,e);this.sv.setRange(i)}}const W=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.beforeCopyRegion=s(this,"beforecopyregion",7),this.beforeRegionPaste=s(this,"beforepasteregion",7),this.cellEditApply=s(this,"celleditapply",7),this.beforeFocusCell=s(this,"beforecellfocusinit",7),this.beforeNextViewportFocus=s(this,"beforenextvpfocus",7),this.setEdit=s(this,"setedit",7),this.beforeApplyRange=s(this,"beforeapplyrange",7),this.beforeSetRange=s(this,"beforesetrange",7),this.setRange=s(this,"setrange",7),this.beforeEditRender=s(this,"beforeeditrender",7),this.selectAll=s(this,"selectall",7),this.cancelEdit=s(this,"canceledit",7),this.setTempRange=s(this,"settemprange",7),this.beforeSetTempRange=s(this,"beforesettemprange",7),this.applyFocus=s(this,"applyfocus",7),this.focusCell=s(this,"focuscell",7),this.beforeRangeDataApply=s(this,"beforerangedataapply",7),this.selectionChange=s(this,"selectionchangeinit",7),this.beforeRangeCopyApply=s(this,"beforerangecopyapply",7),this.rangeEditApply=s(this,"rangeeditapply",7),this.rangeClipboardCopy=s(this,"clipboardrangecopy",7),this.rangeClipboardPaste=s(this,"clipboardrangepaste",7),this.beforeKeyDown=s(this,"beforekeydown",7),this.beforeKeyUp=s(this,"beforekeyup",7),this.beforeCellSave=s(this,"beforecellsave",7),this.cellEditDone=s(this,"celledit",7),this.applyChangesOnClose=!1,this.keyboardService=null,this.autoFillService=null,this.unsubscribeSelectionStore=[]}onMouseMove(t){var e;this.selectionStore.get("focus")&&(null===(e=this.autoFillService)||void 0===e||e.selectionMouseMove(t))}onMouseUp(){var t;null===(t=this.autoFillService)||void 0===t||t.clearAutoFillSelection(this.selectionStore.get("focus"),this.selectionStore.get("range"))}onCellDrag(t){var e;null===(e=this.orderEditor)||void 0===e||e.dragStart(t.detail)}onKeyUp(t){this.beforeKeyUp.emit(Object.assign({original:t},this.getData()))}onKeyDown(t){var e;const i=this.beforeKeyDown.emit(Object.assign({original:t},this.getData()));t.defaultPrevented||i.defaultPrevented||null===(e=this.keyboardService)||void 0===e||e.keyDown(t,this.range,!!this.selectionStore.get("edit"),{focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range")})}selectionServiceSet(t){this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,this.unsubscribeSelectionStore.push(t.onChange("nextFocus",(t=>t&&this.doFocus(t,t)))),this.keyboardService=new L({selectionStore:t,range:t=>!!t&&this.triggerRangeEvent(t),focus:(t,e,i)=>i?(this.beforeNextViewportFocus.emit(t),!1):this.doFocus(t,t,e),change:t=>{this.readonly||this.doEdit(t)},cancel:async()=>{var t;await(null===(t=this.revogrEdit)||void 0===t?void 0:t.cancelChanges()),this.closeEdit()},clearCell:()=>!this.readonly&&this.clearCell(),internalPaste:()=>!this.readonly&&this.beforeRegionPaste.emit(),getData:()=>this.getData(),selectAll:()=>this.selectAll.emit()}),this.createAutoFillService()}createAutoFillService(){this.autoFillService=new N({dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,columnService:this.columnService,dataStore:this.dataStore,clearRangeDataApply:t=>this.beforeRangeDataApply.emit(Object.assign(Object.assign(Object.assign({},t),this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)})),setTempRange:t=>{const e=this.beforeSetTempRange.emit(Object.assign(Object.assign({tempRange:t},this.getData()),this.types));return e.defaultPrevented?null:this.setTempRange.emit(e.detail.tempRange)},selectionChanged:t=>this.selectionChange.emit(t),rangeCopy:t=>this.beforeRangeCopyApply.emit(t),rangeDataApply:t=>this.rangeEditApply.emit(t),setRange:t=>!!t&&this.triggerRangeEvent(t),getData:()=>this.getData()})}columnServiceSet(){var t;null===(t=this.columnService)||void 0===t||t.destroy(),this.columnService=new a(this.dataStore,this.colData),this.createAutoFillService()}connectedCallback(){this.columnServiceSet(),this.selectionServiceSet(this.selectionStore)}disconnectedCallback(){var t;this.unsubscribeSelectionStore.forEach((t=>t())),this.unsubscribeSelectionStore.length=0,null===(t=this.columnService)||void 0===t||t.destroy()}async componentWillRender(){var t,e;this.selectionStore.get("edit")||await(null===(e=null===(t=this.revogrEdit)||void 0===t?void 0:t.beforeDisconnect)||void 0===e?void 0:e.call(t))}renderRange(e){const i=y(e,this.dimensionRow.state,this.dimensionCol.state),s=O(i);return[t("div",{class:v,style:s},this.isMobileDevice&&t("div",{class:"range-handlers"},t("span",{class:g}),t("span",{class:g})))]}renderEditor(){const e=this.selectionStore.get("edit");if(this.readonly||!e)return null;const i=e.val||l(this.columnService.rowDataModel(e.y,e.x).value),s=Object.assign(Object.assign({},e),this.columnService.getSaveData(e.y,e.x,i)),o=this.beforeEditRender.emit(Object.assign(Object.assign({range:Object.assign(Object.assign({},e),{x1:e.x,y1:e.y})},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state)}));if(o.defaultPrevented)return null;const n=y(o.detail.range,o.detail.rowDimension,o.detail.colDimension),r=O(n);return t("revogr-edit",{style:r,ref:t=>this.revogrEdit=t,additionalData:this.additionalData,editCell:s,saveOnClose:this.applyChangesOnClose,onCelleditinit:t=>{this.cellEditDone.emit(t.detail)},column:this.columnService.rowDataModel(e.y,e.x),editor:h(this.columnService.columns[e.x],this.editors)})}onEditCell(t){if(t.defaultPrevented)return;const e=this.beforeCellSave.emit(t.detail);e.defaultPrevented||this.cellEdit(e.detail),e.detail.preventFocus||this.focusNext()}render(){var e;const i=[],s=this.renderEditor();if(s)i.push(s);else{const s=this.selectionStore.get("range"),o=this.selectionStore.get("focus");(s||o)&&this.useClipboard&&i.push(t("revogr-clipboard",{readonly:this.readonly,onCopyregion:t=>this.onCopy(t.detail),onClearregion:()=>!this.readonly&&this.clearCell(),ref:t=>this.clipboard=t,onPasteregion:t=>this.onPaste(t.detail)})),s&&i.push(...this.renderRange(s)),o&&!this.readonly&&this.range&&i.push(null===(e=this.autoFillService)||void 0===e?void 0:e.renderAutofill(s,o,this.isMobileDevice)),this.canDrag&&i.push(t("revogr-order-editor",{ref:t=>this.orderEditor=t,dataStore:this.dataStore,dimensionRow:this.dimensionRow,dimensionCol:this.dimensionCol,parent:this.element,rowType:this.types.rowType,onRowdragstartinit:t=>this.rowDragStart(t)}))}return t(o,{key:"ff303c39d59e4ef217421fa11b9a80de07311b07",class:{mobile:this.isMobileDevice},onDblClick:t=>this.onElementDblClick(t),onMouseDown:t=>this.onElementMouseDown(t),onTouchStart:t=>this.onElementMouseDown(t,!0),onCloseedit:t=>this.closeEdit(t),onCelledit:t=>this.onEditCell(t)},i,t("slot",{key:"3cbe4c3ad7d447f779e9e20f73eec2e3107275e0",name:"data"}))}doFocus(t,e,i,s){const{defaultPrevented:o}=this.beforeFocusCell.emit(Object.assign(Object.assign({},this.columnService.getSaveData(t.y,t.x)),{originalEvent:s}));if(o)return!1;const n=Object.assign(Object.assign({range:Object.assign(Object.assign({},t),{x1:e.x,y1:e.y}),next:i},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state),originalEvent:s}),r=this.applyFocus.emit(n);if(r.defaultPrevented)return!1;const{range:a}=r.detail;return!this.focusCell.emit(Object.assign({focus:{x:a.x,y:a.y},end:{x:a.x1,y:a.y1}},r.detail)).defaultPrevented}triggerRangeEvent(t,e){const i=this.types.rowType,s=this.beforeApplyRange.emit(Object.assign(Object.assign({range:Object.assign({},t)},this.types),{rowDimension:Object.assign({},this.dimensionRow.state),colDimension:Object.assign({},this.dimensionCol.state),originalEvent:e}));if(s.defaultPrevented)return!1;const o=this.columnService.getRangeTransformedToProps(s.detail.range,this.dataStore);let n=this.beforeSetRange.emit(o);return!n.defaultPrevented&&(n=this.setRange.emit(Object.assign(Object.assign({},s.detail.range),{type:i})),!n.defaultPrevented&&!n.defaultPrevented)}onElementDblClick(t){if(t.defaultPrevented)return;const e=this.getData();S(t,e)&&this.doEdit()}onElementMouseDown(t,e=!1){var i;const s=t.target;if(M(s)||t.defaultPrevented)return;const o=this.getData(),n=S(t,o);n&&(this.focus(n,this.range&&t.shiftKey,t),this.range&&(s&&(null===(i=this.autoFillService)||void 0===i||i.selectionStart(s,this.getData())),e?D(t.touches[0],g)&&t.preventDefault():t.preventDefault()))}doEdit(t=""){var e;if(this.canEdit()){const i=this.selectionStore.get("focus");if(!i)return;const s=this.columnService.getSaveData(i.y,i.x);null===(e=this.setEdit)||void 0===e||e.emit(Object.assign(Object.assign({},s),{val:t}))}}async closeEdit(t){this.cancelEdit.emit(),(null==t?void 0:t.detail)&&await this.focusNext()}cellEdit(t){const e=this.columnService.getSaveData(t.rgRow,t.rgCol,t.val);this.cellEditApply.emit(e)}getRegion(){const t=this.selectionStore.get("focus");let e=this.selectionStore.get("range");return e||(e=r(t,t)),e}onCopy(t){var e;const i=this.getRegion();if(this.beforeCopyRegion.emit(i).defaultPrevented)return!1;let s;if(i){const{data:t,mapping:e}=this.columnService.copyRangeArray(i,this.dataStore),o=this.rangeClipboardCopy.emit(Object.assign({range:i,data:t,mapping:e},this.types));o.defaultPrevented||(s=o.detail.data)}return null===(e=this.clipboard)||void 0===e||e.doCopy(t,s),!0}onPaste(t){var e;const i=this.selectionStore.get("focus"),s=null!==this.selectionStore.get("edit");if(!i||s)return;const o=function(t,e){var i;if(!function(t){return"object"==typeof t&&!0===t.rangeFill}(e))return null;const s=function(t){const e=[...t];for(;e.length>1&&(!(i=e[e.length-1])||i.every((t=>""===t)));)e.pop();var i;return e}(t);return 1===s.length&&1===(null===(i=s[0])||void 0===i?void 0:i.length)?s:null}(t,this.useClipboard),n=o?this.getClipboardPasteTargetRange():null;let{changed:r,range:a}=this.columnService.getTransformedDataToApply({start:i,data:o||t,targetRange:n});const{defaultPrevented:l}=this.rangeClipboardPaste.emit(Object.assign({data:r,models:j(r,this.dataStore),range:a},this.types));l||null===(e=this.autoFillService)||void 0===e||e.onRangeApply(r,a,a)}getClipboardPasteTargetRange(){const t=this.selectionStore.get("range");return t&&!c(t)?t:null}async focusNext(){var t;await(null===(t=this.keyboardService)||void 0===t?void 0:t.keyChangeSelection(new KeyboardEvent("keydown",{code:d.ARROW_DOWN}),this.range))||this.closeEdit()}clearCell(){var t;const e=this.selectionStore.get("range");if(e&&!c(e)){const i=this.columnService.getRangeStaticData(e,"");null===(t=this.autoFillService)||void 0===t||t.onRangeApply(i,e,e)}else if(this.canEdit()){const t=this.selectionStore.get("focus");if(!t)return;const e=this.columnService.getSaveData(t.y,t.x);this.cellEdit({rgRow:t.y,rgCol:t.x,val:"",type:e.type,prop:e.prop})}}rowDragStart({detail:t}){t.text=l(this.columnService.rowDataModel(t.cell.y,t.cell.x).value)}canEdit(){var t;if(this.readonly)return!1;const e=this.selectionStore.get("focus");return e&&!(null===(t=this.columnService)||void 0===t?void 0:t.isReadOnly(e.y,e.x))}get edited(){return this.selectionStore.get("edit")}focus(t,e=!1,i){if(!t)return!1;const s=t,o=this.selectionStore.get("focus");if(e&&o){const t=r(o,s);if(t)return this.triggerRangeEvent(t,i)}return this.doFocus(t,s,void 0,i)}get types(){return{rowType:this.dataStore.get("type"),colType:this.columnService.type}}getData(){return{el:this.element,rows:this.dimensionRow.state,cols:this.dimensionCol.state,lastCell:this.lastCell,focus:this.selectionStore.get("focus"),range:this.selectionStore.get("range"),edit:this.selectionStore.get("edit")}}get element(){return this}static get watchers(){return{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}}static get style(){return'revogr-overlay-selection{display:block;position:relative;width:100%}revogr-overlay-selection .autofill-handle{position:absolute;width:14px;height:14px;margin-left:-13px;margin-top:-13px;z-index:10;cursor:crosshair}revogr-overlay-selection .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection.mobile .autofill-handle{position:absolute;width:30px;height:30px;margin-left:-29px;margin-top:-29px;z-index:10;cursor:crosshair}revogr-overlay-selection.mobile .autofill-handle::before{content:"";position:absolute;right:0;bottom:0;width:12px;height:12px;background:#0d63e8;border:1px solid white;box-sizing:border-box}revogr-overlay-selection .selection-border-range{position:absolute;pointer-events:none;z-index:9;box-shadow:-1px 0 0 #0d63e8 inset, 1px 0 0 #0d63e8 inset, 0 -1px 0 #0d63e8 inset, 0 1px 0 #0d63e8 inset}revogr-overlay-selection .selection-border-range .range-handlers{height:100%;background-color:transparent;width:75%;max-width:50px;min-width:20px;left:50%;transform:translateX(-50%);position:absolute}revogr-overlay-selection .selection-border-range .range-handlers>span{pointer-events:auto;height:20px;width:20px;position:absolute;left:50%;transform:translateX(-50%)}revogr-overlay-selection .selection-border-range .range-handlers>span:before,revogr-overlay-selection .selection-border-range .range-handlers>span:after{position:absolute;border-radius:5px;width:15px;height:5px;left:50%;transform:translateX(-50%);background-color:rgba(0, 0, 0, 0.2)}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child{top:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:first-child:before{content:"";top:0}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child{bottom:-7px}revogr-overlay-selection .selection-border-range .range-handlers>span:last-child:after{content:"";bottom:0}revogr-overlay-selection revogr-edit{z-index:10}'}},[260,"revogr-overlay-selection",{readonly:[4],range:[4],canDrag:[4,"can-drag"],useClipboard:[4,"use-clipboard"],selectionStore:[16],dimensionRow:[16],dimensionCol:[16],dataStore:[16],colData:[16],lastCell:[16],editors:[16],applyChangesOnClose:[4,"apply-changes-on-close"],additionalData:[8,"additional-data"],isMobileDevice:[4,"is-mobile-device"]},[[5,"touchmove","onMouseMove"],[5,"mousemove","onMouseMove"],[5,"touchend","onMouseUp"],[5,"mouseup","onMouseUp"],[5,"mouseleave","onMouseUp"],[0,"dragstartcell","onCellDrag"],[4,"keyup","onKeyUp"],[4,"keydown","onKeyDown"]],{selectionStore:[{selectionServiceSet:0}],dimensionRow:[{createAutoFillService:0}],dimensionCol:[{createAutoFillService:0}],dataStore:[{columnServiceSet:0}],colData:[{columnServiceSet:0}]}]);function V(){"undefined"!=typeof customElements&&["revogr-overlay-selection","revogr-clipboard","revogr-edit","revogr-order-editor"].forEach((t=>{switch(t){case"revogr-overlay-selection":customElements.get(n(t))||customElements.define(n(t),W);break;case"revogr-clipboard":customElements.get(n(t))||X();break;case"revogr-edit":customElements.get(n(t))||z();break;case"revogr-order-editor":customElements.get(n(t))||$()}}))}export{W as O,V as d}