@revolist/revogrid 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-element/revo-grid.js +25 -8
- package/custom-element/revogr-edit2.js +5 -1
- package/custom-element/revogr-overlay-selection2.js +11 -6
- package/custom-element/revogr-row-headers2.js +41 -2
- package/dist/cjs/revo-grid_11.cjs.entry.js +82 -17
- package/dist/collection/components/overlay/keyboard.service.js +1 -1
- package/dist/collection/components/overlay/revogr-edit.js +6 -2
- package/dist/collection/components/overlay/revogr-overlay-selection.js +25 -6
- package/dist/collection/components/revo-grid/revo-grid.js +5 -4
- package/dist/collection/components/revo-grid/viewport.section.js +2 -2
- package/dist/collection/services/dimension.provider.js +18 -2
- package/dist/collection/store/viewPort/viewport.helpers.js +35 -0
- package/dist/collection/store/viewPort/viewport.store.js +7 -3
- package/dist/esm/revo-grid_11.entry.js +82 -17
- package/dist/esm-es5/revo-grid_11.entry.js +1 -1
- package/dist/revo-grid/revo-grid_11.entry.js +1 -1
- package/dist/revo-grid/revo-grid_11.system.entry.js +1 -1
- package/dist/types/components/overlay/editors/text.d.ts +5 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +2 -1
- package/dist/types/components/overlay/revogr-edit.d.ts +9 -2
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +9 -1
- package/dist/types/components/revo-grid/viewport.section.d.ts +2 -1
- package/dist/types/components.d.ts +5 -1
- package/dist/types/interfaces.d.ts +1 -3
- package/dist/types/services/dimension.provider.d.ts +8 -1
- package/dist/types/store/viewPort/viewport.helpers.d.ts +9 -0
- package/dist/types/store/viewPort/viewport.store.d.ts +1 -1
- package/package.json +1 -1
|
@@ -582,6 +582,21 @@ class DimensionProvider {
|
|
|
582
582
|
this.viewports.stores[type].setViewport({ realCount });
|
|
583
583
|
this.stores[type].setRealSize(realCount);
|
|
584
584
|
}
|
|
585
|
+
/**
|
|
586
|
+
* Apply new custom sizes to dimension and view port
|
|
587
|
+
* @param type - dimension type
|
|
588
|
+
* @param sizes - new custom sizes
|
|
589
|
+
* @param keepOld - keep old sizes merge new with old
|
|
590
|
+
*/
|
|
591
|
+
setCustomSizes(type, sizes, keepOld = false) {
|
|
592
|
+
let newSizes = sizes;
|
|
593
|
+
if (keepOld) {
|
|
594
|
+
const oldSizes = this.stores[type].store.get('sizes');
|
|
595
|
+
newSizes = Object.assign(Object.assign({}, oldSizes), sizes);
|
|
596
|
+
}
|
|
597
|
+
this.stores[type].setDimensionSize(newSizes);
|
|
598
|
+
this.viewports.stores[type].setViewPortDimension(newSizes, !keepOld ? this.stores[type].store.get('originItemSize') : undefined);
|
|
599
|
+
}
|
|
585
600
|
/**
|
|
586
601
|
* Sets dimension data and view port coordinate
|
|
587
602
|
* @param items - data/column items
|
|
@@ -606,8 +621,9 @@ class DimensionProvider {
|
|
|
606
621
|
this.stores[type].drop();
|
|
607
622
|
}
|
|
608
623
|
}
|
|
609
|
-
setColumns(type, sizes, noVirtual = false) {
|
|
610
|
-
this.
|
|
624
|
+
setColumns(type, newLength, sizes, noVirtual = false) {
|
|
625
|
+
this.setRealSize(newLength, type);
|
|
626
|
+
this.setCustomSizes(type, sizes);
|
|
611
627
|
if (noVirtual) {
|
|
612
628
|
this.setNoVirtual(type);
|
|
613
629
|
}
|
|
@@ -2576,7 +2592,7 @@ class ViewportService {
|
|
|
2576
2592
|
* First we render vertical parts - pinned start, data, pinned end
|
|
2577
2593
|
* Per each column we render data collections: headers, pinned top, center data, pinned bottom
|
|
2578
2594
|
*/
|
|
2579
|
-
const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onScroll }) => {
|
|
2595
|
+
const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onCancelEdit, onScroll }) => {
|
|
2580
2596
|
const viewPortHtml = [];
|
|
2581
2597
|
/** render viewports columns */
|
|
2582
2598
|
for (let view of columns) {
|
|
@@ -2586,7 +2602,7 @@ const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns,
|
|
|
2586
2602
|
];
|
|
2587
2603
|
view.dataPorts.forEach((data, j) => {
|
|
2588
2604
|
const key = view.prop.key + (j + 1);
|
|
2589
|
-
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
2605
|
+
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onCancelEdit: () => onCancelEdit(), onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
2590
2606
|
h("revogr-data", Object.assign({}, data, { [UUID]: data.uuid }, { key: key, readonly: readonly, range: range, rowClass: rowClass, rowSelectionStore: data.rowSelectionStore, slot: DATA_SLOT })),
|
|
2591
2607
|
h("revogr-temp-range", { selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }),
|
|
2592
2608
|
h("revogr-focus", { colData: data.colData, dataStore: data.dataStore, selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol })));
|
|
@@ -3336,8 +3352,7 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
3336
3352
|
this.beforecolumnsset.emit(columnGather);
|
|
3337
3353
|
for (let type of columnTypes) {
|
|
3338
3354
|
const items = columnGather.columns[type];
|
|
3339
|
-
this.dimensionProvider.
|
|
3340
|
-
this.dimensionProvider.setColumns(type, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
3355
|
+
this.dimensionProvider.setColumns(type, items.length, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
3341
3356
|
}
|
|
3342
3357
|
this.beforecolumnapplied.emit(columnGather);
|
|
3343
3358
|
const columns = this.columnProvider.setColumns(columnGather);
|
|
@@ -3519,10 +3534,12 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
3519
3534
|
const anyView = this.viewport.columns[0];
|
|
3520
3535
|
views.push(h("revogr-row-headers", { height: contentHeight, resize: this.resize, dataPorts: anyView.dataPorts, headerProp: anyView.headerProp, uiid: anyView.prop[UUID], rowHeaderColumn: typeof this.rowHeaders === 'object' ? this.rowHeaders : undefined, onScrollViewport: ({ detail: e }) => this.scrollingService.onScroll(e, 'headerRow'), onElementToScroll: ({ detail: e }) => this.scrollingService.registerElement(e, 'headerRow') }));
|
|
3521
3536
|
}
|
|
3522
|
-
views.push(h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns,
|
|
3537
|
+
views.push(h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns, onCancelEdit: () => {
|
|
3538
|
+
this.selectionStoreConnector.setEdit(false);
|
|
3539
|
+
}, onEdit: detail => {
|
|
3523
3540
|
const event = this.beforeeditstart.emit(detail);
|
|
3524
3541
|
if (!event.defaultPrevented) {
|
|
3525
|
-
this.selectionStoreConnector.setEdit(detail.
|
|
3542
|
+
this.selectionStoreConnector.setEdit(detail.val);
|
|
3526
3543
|
}
|
|
3527
3544
|
}, registerElement: (e, k) => this.scrollingService.registerElement(e, k), onScroll: details => this.scrollingService.onScroll(details) }));
|
|
3528
3545
|
return (h(Host, Object.assign({}, { [`${UUID}`]: this.uuid }), h(RevoViewPort, { viewports: this.viewportProvider.stores, dimensions: this.dimensionProvider.stores, orderRef: e => (this.orderService = e), registerElement: (e, k) => this.scrollingService.registerElement(e, k), nakedClick: () => this.viewport.clearEdit(), onScroll: details => this.scrollingService.onScroll(details) }, views), this.extraElements));
|
|
@@ -332,7 +332,11 @@ const Edit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
332
332
|
this.closeEdit = createEvent(this, "closeEdit", 3);
|
|
333
333
|
this.currentEditor = null;
|
|
334
334
|
}
|
|
335
|
-
/**
|
|
335
|
+
/**
|
|
336
|
+
* Callback triggered on cell editor save
|
|
337
|
+
* Closes editor when called
|
|
338
|
+
* @param preventFocus - if true editor will not be closed and next cell will not be focused
|
|
339
|
+
*/
|
|
336
340
|
onSave(val, preventFocus) {
|
|
337
341
|
if (this.editCell) {
|
|
338
342
|
this.cellEdit.emit({
|
|
@@ -76,7 +76,7 @@ class KeyboardService {
|
|
|
76
76
|
if (this.sv.selectionStoreService.edited) {
|
|
77
77
|
switch (e.code) {
|
|
78
78
|
case codesLetter.ESCAPE:
|
|
79
|
-
this.sv.
|
|
79
|
+
this.sv.cancelEdit();
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
return;
|
|
@@ -466,6 +466,7 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
466
466
|
this.internalCellEdit = createEvent(this, "internalCellEdit", 7);
|
|
467
467
|
this.internalFocusCell = createEvent(this, "internalFocusCell", 7);
|
|
468
468
|
this.setEdit = createEvent(this, "setEdit", 3);
|
|
469
|
+
this.cancelEdit = createEvent(this, "cancelEdit", 7);
|
|
469
470
|
this.setRange = createEvent(this, "setRange", 7);
|
|
470
471
|
this.setTempRange = createEvent(this, "setTempRange", 7);
|
|
471
472
|
this.focusCell = createEvent(this, "focusCell", 3);
|
|
@@ -528,7 +529,8 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
528
529
|
this.keyboardService = new KeyboardService({
|
|
529
530
|
selectionStoreService: this.selectionStoreService,
|
|
530
531
|
selectionStore: s,
|
|
531
|
-
doEdit: (v
|
|
532
|
+
doEdit: (v) => this.doEdit(v),
|
|
533
|
+
cancelEdit: () => this.closeEdit(),
|
|
532
534
|
clearCell: () => this.clearCell(),
|
|
533
535
|
getData: () => this.getData(),
|
|
534
536
|
internalPaste: () => this.internalPaste.emit()
|
|
@@ -628,17 +630,20 @@ const OverlaySelection = /*@__PURE__*/ proxyCustomElement(class extends HTMLElem
|
|
|
628
630
|
this.autoFillService.selectionStart(e, data);
|
|
629
631
|
}
|
|
630
632
|
}
|
|
631
|
-
doEdit(val = ''
|
|
633
|
+
doEdit(val = '') {
|
|
632
634
|
var _a;
|
|
633
635
|
if (this.canEdit()) {
|
|
634
636
|
const editCell = this.selectionStore.get('focus');
|
|
635
637
|
const data = this.columnService.getSaveData(editCell.y, editCell.x);
|
|
636
|
-
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), {
|
|
637
|
-
val }));
|
|
638
|
+
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
|
|
638
639
|
}
|
|
639
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Close editor event triggered
|
|
643
|
+
* @param details - if requires focus next
|
|
644
|
+
*/
|
|
640
645
|
closeEdit(e) {
|
|
641
|
-
this.
|
|
646
|
+
this.cancelEdit.emit();
|
|
642
647
|
if (e === null || e === void 0 ? void 0 : e.detail) {
|
|
643
648
|
this.focusNext();
|
|
644
649
|
}
|
|
@@ -188,6 +188,41 @@ function getFirstItem(s) {
|
|
|
188
188
|
function getLastItem(s) {
|
|
189
189
|
return s.items[s.end];
|
|
190
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Set items sizes from start index to end
|
|
193
|
+
* @param vpItems
|
|
194
|
+
* @param start
|
|
195
|
+
* @param size
|
|
196
|
+
* @param lastCoordinate
|
|
197
|
+
* @returns
|
|
198
|
+
*/
|
|
199
|
+
function setItemSizes(vpItems, initialIndex, size, lastCoordinate) {
|
|
200
|
+
const items = [...vpItems];
|
|
201
|
+
const count = items.length;
|
|
202
|
+
let pos = lastCoordinate;
|
|
203
|
+
let i = 0;
|
|
204
|
+
let start = initialIndex;
|
|
205
|
+
// viewport not inited
|
|
206
|
+
if (!count) {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
// loop through array from initial item after recombination
|
|
210
|
+
while (i < count) {
|
|
211
|
+
const item = items[start];
|
|
212
|
+
item.start = pos;
|
|
213
|
+
item.size = size;
|
|
214
|
+
item.end = item.start + size;
|
|
215
|
+
pos = item.end;
|
|
216
|
+
// loop by start index
|
|
217
|
+
start++;
|
|
218
|
+
i++;
|
|
219
|
+
// if start index out of array, reset it
|
|
220
|
+
if (start === count) {
|
|
221
|
+
start = 0;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return items;
|
|
225
|
+
}
|
|
191
226
|
|
|
192
227
|
/**
|
|
193
228
|
* Store is responsible for visible
|
|
@@ -258,8 +293,8 @@ class ViewportStore {
|
|
|
258
293
|
}
|
|
259
294
|
}
|
|
260
295
|
/** Update viewport sizes */
|
|
261
|
-
setViewPortDimension(sizes) {
|
|
262
|
-
|
|
296
|
+
setViewPortDimension(sizes, dropToOriginalSize) {
|
|
297
|
+
let items = this.store.get('items');
|
|
263
298
|
const count = items.length;
|
|
264
299
|
// viewport not inited
|
|
265
300
|
if (!count) {
|
|
@@ -268,6 +303,10 @@ class ViewportStore {
|
|
|
268
303
|
let changedCoordinate = 0;
|
|
269
304
|
let i = 0;
|
|
270
305
|
let start = this.store.get('start');
|
|
306
|
+
// drop to original size if requested
|
|
307
|
+
if (dropToOriginalSize) {
|
|
308
|
+
items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
|
|
309
|
+
}
|
|
271
310
|
// loop through array from initial item after recombination
|
|
272
311
|
while (i < count) {
|
|
273
312
|
const item = items[start];
|
|
@@ -4430,6 +4430,21 @@ class DimensionProvider {
|
|
|
4430
4430
|
this.viewports.stores[type].setViewport({ realCount });
|
|
4431
4431
|
this.stores[type].setRealSize(realCount);
|
|
4432
4432
|
}
|
|
4433
|
+
/**
|
|
4434
|
+
* Apply new custom sizes to dimension and view port
|
|
4435
|
+
* @param type - dimension type
|
|
4436
|
+
* @param sizes - new custom sizes
|
|
4437
|
+
* @param keepOld - keep old sizes merge new with old
|
|
4438
|
+
*/
|
|
4439
|
+
setCustomSizes(type, sizes, keepOld = false) {
|
|
4440
|
+
let newSizes = sizes;
|
|
4441
|
+
if (keepOld) {
|
|
4442
|
+
const oldSizes = this.stores[type].store.get('sizes');
|
|
4443
|
+
newSizes = Object.assign(Object.assign({}, oldSizes), sizes);
|
|
4444
|
+
}
|
|
4445
|
+
this.stores[type].setDimensionSize(newSizes);
|
|
4446
|
+
this.viewports.stores[type].setViewPortDimension(newSizes, !keepOld ? this.stores[type].store.get('originItemSize') : undefined);
|
|
4447
|
+
}
|
|
4433
4448
|
/**
|
|
4434
4449
|
* Sets dimension data and view port coordinate
|
|
4435
4450
|
* @param items - data/column items
|
|
@@ -4454,8 +4469,9 @@ class DimensionProvider {
|
|
|
4454
4469
|
this.stores[type].drop();
|
|
4455
4470
|
}
|
|
4456
4471
|
}
|
|
4457
|
-
setColumns(type, sizes, noVirtual = false) {
|
|
4458
|
-
this.
|
|
4472
|
+
setColumns(type, newLength, sizes, noVirtual = false) {
|
|
4473
|
+
this.setRealSize(newLength, type);
|
|
4474
|
+
this.setCustomSizes(type, sizes);
|
|
4459
4475
|
if (noVirtual) {
|
|
4460
4476
|
this.setNoVirtual(type);
|
|
4461
4477
|
}
|
|
@@ -4668,6 +4684,41 @@ function getFirstItem(s) {
|
|
|
4668
4684
|
function getLastItem(s) {
|
|
4669
4685
|
return s.items[s.end];
|
|
4670
4686
|
}
|
|
4687
|
+
/**
|
|
4688
|
+
* Set items sizes from start index to end
|
|
4689
|
+
* @param vpItems
|
|
4690
|
+
* @param start
|
|
4691
|
+
* @param size
|
|
4692
|
+
* @param lastCoordinate
|
|
4693
|
+
* @returns
|
|
4694
|
+
*/
|
|
4695
|
+
function setItemSizes(vpItems, initialIndex, size, lastCoordinate) {
|
|
4696
|
+
const items = [...vpItems];
|
|
4697
|
+
const count = items.length;
|
|
4698
|
+
let pos = lastCoordinate;
|
|
4699
|
+
let i = 0;
|
|
4700
|
+
let start = initialIndex;
|
|
4701
|
+
// viewport not inited
|
|
4702
|
+
if (!count) {
|
|
4703
|
+
return [];
|
|
4704
|
+
}
|
|
4705
|
+
// loop through array from initial item after recombination
|
|
4706
|
+
while (i < count) {
|
|
4707
|
+
const item = items[start];
|
|
4708
|
+
item.start = pos;
|
|
4709
|
+
item.size = size;
|
|
4710
|
+
item.end = item.start + size;
|
|
4711
|
+
pos = item.end;
|
|
4712
|
+
// loop by start index
|
|
4713
|
+
start++;
|
|
4714
|
+
i++;
|
|
4715
|
+
// if start index out of array, reset it
|
|
4716
|
+
if (start === count) {
|
|
4717
|
+
start = 0;
|
|
4718
|
+
}
|
|
4719
|
+
}
|
|
4720
|
+
return items;
|
|
4721
|
+
}
|
|
4671
4722
|
|
|
4672
4723
|
/**
|
|
4673
4724
|
* Store is responsible for visible
|
|
@@ -4738,8 +4789,8 @@ class ViewportStore {
|
|
|
4738
4789
|
}
|
|
4739
4790
|
}
|
|
4740
4791
|
/** Update viewport sizes */
|
|
4741
|
-
setViewPortDimension(sizes) {
|
|
4742
|
-
|
|
4792
|
+
setViewPortDimension(sizes, dropToOriginalSize) {
|
|
4793
|
+
let items = this.store.get('items');
|
|
4743
4794
|
const count = items.length;
|
|
4744
4795
|
// viewport not inited
|
|
4745
4796
|
if (!count) {
|
|
@@ -4748,6 +4799,10 @@ class ViewportStore {
|
|
|
4748
4799
|
let changedCoordinate = 0;
|
|
4749
4800
|
let i = 0;
|
|
4750
4801
|
let start = this.store.get('start');
|
|
4802
|
+
// drop to original size if requested
|
|
4803
|
+
if (dropToOriginalSize) {
|
|
4804
|
+
items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
|
|
4805
|
+
}
|
|
4751
4806
|
// loop through array from initial item after recombination
|
|
4752
4807
|
while (i < count) {
|
|
4753
4808
|
const item = items[start];
|
|
@@ -24433,7 +24488,7 @@ class ViewportService {
|
|
|
24433
24488
|
* First we render vertical parts - pinned start, data, pinned end
|
|
24434
24489
|
* Per each column we render data collections: headers, pinned top, center data, pinned bottom
|
|
24435
24490
|
*/
|
|
24436
|
-
const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onScroll }) => {
|
|
24491
|
+
const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onCancelEdit, onScroll }) => {
|
|
24437
24492
|
const viewPortHtml = [];
|
|
24438
24493
|
/** render viewports columns */
|
|
24439
24494
|
for (let view of columns) {
|
|
@@ -24443,7 +24498,7 @@ const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns,
|
|
|
24443
24498
|
];
|
|
24444
24499
|
view.dataPorts.forEach((data, j) => {
|
|
24445
24500
|
const key = view.prop.key + (j + 1);
|
|
24446
|
-
const dataView = (index.h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
24501
|
+
const dataView = (index.h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onCancelEdit: () => onCancelEdit(), onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
24447
24502
|
index.h("revogr-data", Object.assign({}, data, { [UUID]: data.uuid }, { key: key, readonly: readonly, range: range, rowClass: rowClass, rowSelectionStore: data.rowSelectionStore, slot: DATA_SLOT })),
|
|
24448
24503
|
index.h("revogr-temp-range", { selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }),
|
|
24449
24504
|
index.h("revogr-focus", { colData: data.colData, dataStore: data.dataStore, selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol })));
|
|
@@ -25205,8 +25260,7 @@ const RevoGridComponent = class {
|
|
|
25205
25260
|
this.beforecolumnsset.emit(columnGather);
|
|
25206
25261
|
for (let type of columnTypes) {
|
|
25207
25262
|
const items = columnGather.columns[type];
|
|
25208
|
-
this.dimensionProvider.
|
|
25209
|
-
this.dimensionProvider.setColumns(type, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
25263
|
+
this.dimensionProvider.setColumns(type, items.length, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
25210
25264
|
}
|
|
25211
25265
|
this.beforecolumnapplied.emit(columnGather);
|
|
25212
25266
|
const columns = this.columnProvider.setColumns(columnGather);
|
|
@@ -25388,10 +25442,12 @@ const RevoGridComponent = class {
|
|
|
25388
25442
|
const anyView = this.viewport.columns[0];
|
|
25389
25443
|
views.push(index.h("revogr-row-headers", { height: contentHeight, resize: this.resize, dataPorts: anyView.dataPorts, headerProp: anyView.headerProp, uiid: anyView.prop[UUID], rowHeaderColumn: typeof this.rowHeaders === 'object' ? this.rowHeaders : undefined, onScrollViewport: ({ detail: e }) => this.scrollingService.onScroll(e, 'headerRow'), onElementToScroll: ({ detail: e }) => this.scrollingService.registerElement(e, 'headerRow') }));
|
|
25390
25444
|
}
|
|
25391
|
-
views.push(index.h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns,
|
|
25445
|
+
views.push(index.h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns, onCancelEdit: () => {
|
|
25446
|
+
this.selectionStoreConnector.setEdit(false);
|
|
25447
|
+
}, onEdit: detail => {
|
|
25392
25448
|
const event = this.beforeeditstart.emit(detail);
|
|
25393
25449
|
if (!event.defaultPrevented) {
|
|
25394
|
-
this.selectionStoreConnector.setEdit(detail.
|
|
25450
|
+
this.selectionStoreConnector.setEdit(detail.val);
|
|
25395
25451
|
}
|
|
25396
25452
|
}, registerElement: (e, k) => this.scrollingService.registerElement(e, k), onScroll: details => this.scrollingService.onScroll(details) }));
|
|
25397
25453
|
return (index.h(index.Host, Object.assign({}, { [`${UUID}`]: this.uuid }), index.h(RevoViewPort, { viewports: this.viewportProvider.stores, dimensions: this.dimensionProvider.stores, orderRef: e => (this.orderService = e), registerElement: (e, k) => this.scrollingService.registerElement(e, k), nakedClick: () => this.viewport.clearEdit(), onScroll: details => this.scrollingService.onScroll(details) }, views), this.extraElements));
|
|
@@ -26087,7 +26143,11 @@ const Edit = class {
|
|
|
26087
26143
|
this.closeEdit = index.createEvent(this, "closeEdit", 3);
|
|
26088
26144
|
this.currentEditor = null;
|
|
26089
26145
|
}
|
|
26090
|
-
/**
|
|
26146
|
+
/**
|
|
26147
|
+
* Callback triggered on cell editor save
|
|
26148
|
+
* Closes editor when called
|
|
26149
|
+
* @param preventFocus - if true editor will not be closed and next cell will not be focused
|
|
26150
|
+
*/
|
|
26091
26151
|
onSave(val, preventFocus) {
|
|
26092
26152
|
if (this.editCell) {
|
|
26093
26153
|
this.cellEdit.emit({
|
|
@@ -27029,7 +27089,7 @@ class KeyboardService {
|
|
|
27029
27089
|
if (this.sv.selectionStoreService.edited) {
|
|
27030
27090
|
switch (e.code) {
|
|
27031
27091
|
case codesLetter.ESCAPE:
|
|
27032
|
-
this.sv.
|
|
27092
|
+
this.sv.cancelEdit();
|
|
27033
27093
|
break;
|
|
27034
27094
|
}
|
|
27035
27095
|
return;
|
|
@@ -27418,6 +27478,7 @@ const OverlaySelection = class {
|
|
|
27418
27478
|
this.internalCellEdit = index.createEvent(this, "internalCellEdit", 7);
|
|
27419
27479
|
this.internalFocusCell = index.createEvent(this, "internalFocusCell", 7);
|
|
27420
27480
|
this.setEdit = index.createEvent(this, "setEdit", 3);
|
|
27481
|
+
this.cancelEdit = index.createEvent(this, "cancelEdit", 7);
|
|
27421
27482
|
this.setRange = index.createEvent(this, "setRange", 7);
|
|
27422
27483
|
this.setTempRange = index.createEvent(this, "setTempRange", 7);
|
|
27423
27484
|
this.focusCell = index.createEvent(this, "focusCell", 3);
|
|
@@ -27480,7 +27541,8 @@ const OverlaySelection = class {
|
|
|
27480
27541
|
this.keyboardService = new KeyboardService({
|
|
27481
27542
|
selectionStoreService: this.selectionStoreService,
|
|
27482
27543
|
selectionStore: s,
|
|
27483
|
-
doEdit: (v
|
|
27544
|
+
doEdit: (v) => this.doEdit(v),
|
|
27545
|
+
cancelEdit: () => this.closeEdit(),
|
|
27484
27546
|
clearCell: () => this.clearCell(),
|
|
27485
27547
|
getData: () => this.getData(),
|
|
27486
27548
|
internalPaste: () => this.internalPaste.emit()
|
|
@@ -27580,17 +27642,20 @@ const OverlaySelection = class {
|
|
|
27580
27642
|
this.autoFillService.selectionStart(e, data);
|
|
27581
27643
|
}
|
|
27582
27644
|
}
|
|
27583
|
-
doEdit(val = ''
|
|
27645
|
+
doEdit(val = '') {
|
|
27584
27646
|
var _a;
|
|
27585
27647
|
if (this.canEdit()) {
|
|
27586
27648
|
const editCell = this.selectionStore.get('focus');
|
|
27587
27649
|
const data = this.columnService.getSaveData(editCell.y, editCell.x);
|
|
27588
|
-
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), {
|
|
27589
|
-
val }));
|
|
27650
|
+
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
|
|
27590
27651
|
}
|
|
27591
27652
|
}
|
|
27653
|
+
/**
|
|
27654
|
+
* Close editor event triggered
|
|
27655
|
+
* @param details - if requires focus next
|
|
27656
|
+
*/
|
|
27592
27657
|
closeEdit(e) {
|
|
27593
|
-
this.
|
|
27658
|
+
this.cancelEdit.emit();
|
|
27594
27659
|
if (e === null || e === void 0 ? void 0 : e.detail) {
|
|
27595
27660
|
this.focusNext();
|
|
27596
27661
|
}
|
|
@@ -8,7 +8,11 @@ export class Edit {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
this.currentEditor = null;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Callback triggered on cell editor save
|
|
13
|
+
* Closes editor when called
|
|
14
|
+
* @param preventFocus - if true editor will not be closed and next cell will not be focused
|
|
15
|
+
*/
|
|
12
16
|
onSave(val, preventFocus) {
|
|
13
17
|
if (this.editCell) {
|
|
14
18
|
this.cellEdit.emit({
|
|
@@ -150,7 +154,7 @@ export class Edit {
|
|
|
150
154
|
"composed": true,
|
|
151
155
|
"docs": {
|
|
152
156
|
"tags": [],
|
|
153
|
-
"text": "Close editor event"
|
|
157
|
+
"text": "Close editor event\npass true if requires focus next"
|
|
154
158
|
},
|
|
155
159
|
"complexType": {
|
|
156
160
|
"original": "boolean | undefined",
|
|
@@ -71,7 +71,8 @@ export class OverlaySelection {
|
|
|
71
71
|
this.keyboardService = new KeyboardService({
|
|
72
72
|
selectionStoreService: this.selectionStoreService,
|
|
73
73
|
selectionStore: s,
|
|
74
|
-
doEdit: (v
|
|
74
|
+
doEdit: (v) => this.doEdit(v),
|
|
75
|
+
cancelEdit: () => this.closeEdit(),
|
|
75
76
|
clearCell: () => this.clearCell(),
|
|
76
77
|
getData: () => this.getData(),
|
|
77
78
|
internalPaste: () => this.internalPaste.emit()
|
|
@@ -173,17 +174,20 @@ export class OverlaySelection {
|
|
|
173
174
|
this.autoFillService.selectionStart(e, data);
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
|
-
doEdit(val = ''
|
|
177
|
+
doEdit(val = '') {
|
|
177
178
|
var _a;
|
|
178
179
|
if (this.canEdit()) {
|
|
179
180
|
const editCell = this.selectionStore.get('focus');
|
|
180
181
|
const data = this.columnService.getSaveData(editCell.y, editCell.x);
|
|
181
|
-
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), {
|
|
182
|
-
val }));
|
|
182
|
+
(_a = this.setEdit) === null || _a === void 0 ? void 0 : _a.emit(Object.assign(Object.assign({}, data), { val }));
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Close editor event triggered
|
|
187
|
+
* @param details - if requires focus next
|
|
188
|
+
*/
|
|
185
189
|
closeEdit(e) {
|
|
186
|
-
this.
|
|
190
|
+
this.cancelEdit.emit();
|
|
187
191
|
if (e === null || e === void 0 ? void 0 : e.detail) {
|
|
188
192
|
this.focusNext();
|
|
189
193
|
}
|
|
@@ -563,7 +567,7 @@ export class OverlaySelection {
|
|
|
563
567
|
},
|
|
564
568
|
"complexType": {
|
|
565
569
|
"original": "Edition.BeforeEdit",
|
|
566
|
-
"resolved": "{
|
|
570
|
+
"resolved": "{ prop: ColumnProp; model: DataType; val?: string; rowIndex: number; type: DimensionRows; }",
|
|
567
571
|
"references": {
|
|
568
572
|
"Edition": {
|
|
569
573
|
"location": "import",
|
|
@@ -571,6 +575,21 @@ export class OverlaySelection {
|
|
|
571
575
|
}
|
|
572
576
|
}
|
|
573
577
|
}
|
|
578
|
+
}, {
|
|
579
|
+
"method": "cancelEdit",
|
|
580
|
+
"name": "cancelEdit",
|
|
581
|
+
"bubbles": true,
|
|
582
|
+
"cancelable": true,
|
|
583
|
+
"composed": true,
|
|
584
|
+
"docs": {
|
|
585
|
+
"tags": [],
|
|
586
|
+
"text": "Used for editors support when close requested"
|
|
587
|
+
},
|
|
588
|
+
"complexType": {
|
|
589
|
+
"original": "any",
|
|
590
|
+
"resolved": "any",
|
|
591
|
+
"references": {}
|
|
592
|
+
}
|
|
574
593
|
}, {
|
|
575
594
|
"method": "setRange",
|
|
576
595
|
"name": "setRange",
|
|
@@ -392,8 +392,7 @@ export class RevoGridComponent {
|
|
|
392
392
|
this.beforecolumnsset.emit(columnGather);
|
|
393
393
|
for (let type of columnTypes) {
|
|
394
394
|
const items = columnGather.columns[type];
|
|
395
|
-
this.dimensionProvider.
|
|
396
|
-
this.dimensionProvider.setColumns(type, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
395
|
+
this.dimensionProvider.setColumns(type, items.length, ColumnDataProvider.getSizes(items), type !== 'rgCol');
|
|
397
396
|
}
|
|
398
397
|
this.beforecolumnapplied.emit(columnGather);
|
|
399
398
|
const columns = this.columnProvider.setColumns(columnGather);
|
|
@@ -575,10 +574,12 @@ export class RevoGridComponent {
|
|
|
575
574
|
const anyView = this.viewport.columns[0];
|
|
576
575
|
views.push(h("revogr-row-headers", { height: contentHeight, resize: this.resize, dataPorts: anyView.dataPorts, headerProp: anyView.headerProp, uiid: anyView.prop[UUID], rowHeaderColumn: typeof this.rowHeaders === 'object' ? this.rowHeaders : undefined, onScrollViewport: ({ detail: e }) => this.scrollingService.onScroll(e, 'headerRow'), onElementToScroll: ({ detail: e }) => this.scrollingService.registerElement(e, 'headerRow') }));
|
|
577
576
|
}
|
|
578
|
-
views.push(h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns,
|
|
577
|
+
views.push(h(ViewPortSections, { columnFilter: !!this.filter, resize: this.resize, readonly: this.readonly, range: this.range, rowClass: this.rowClass, editors: this.editors, useClipboard: this.useClipboard, columns: this.viewport.columns, onCancelEdit: () => {
|
|
578
|
+
this.selectionStoreConnector.setEdit(false);
|
|
579
|
+
}, onEdit: detail => {
|
|
579
580
|
const event = this.beforeeditstart.emit(detail);
|
|
580
581
|
if (!event.defaultPrevented) {
|
|
581
|
-
this.selectionStoreConnector.setEdit(detail.
|
|
582
|
+
this.selectionStoreConnector.setEdit(detail.val);
|
|
582
583
|
}
|
|
583
584
|
}, registerElement: (e, k) => this.scrollingService.registerElement(e, k), onScroll: details => this.scrollingService.onScroll(details) }));
|
|
584
585
|
return (h(Host, Object.assign({}, { [`${UUID}`]: this.uuid }),
|
|
@@ -9,7 +9,7 @@ import { DATA_SLOT, HEADER_SLOT } from './viewport.helpers';
|
|
|
9
9
|
* First we render vertical parts - pinned start, data, pinned end
|
|
10
10
|
* Per each column we render data collections: headers, pinned top, center data, pinned bottom
|
|
11
11
|
*/
|
|
12
|
-
export const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onScroll }) => {
|
|
12
|
+
export const ViewPortSections = ({ resize, editors, rowClass, readonly, range, columns, useClipboard, columnFilter, registerElement, onEdit, onCancelEdit, onScroll }) => {
|
|
13
13
|
const viewPortHtml = [];
|
|
14
14
|
/** render viewports columns */
|
|
15
15
|
for (let view of columns) {
|
|
@@ -19,7 +19,7 @@ export const ViewPortSections = ({ resize, editors, rowClass, readonly, range, c
|
|
|
19
19
|
];
|
|
20
20
|
view.dataPorts.forEach((data, j) => {
|
|
21
21
|
const key = view.prop.key + (j + 1);
|
|
22
|
-
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
22
|
+
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { slot: data.slot, selectionStore: data.segmentSelectionStore, editors: editors, readonly: readonly, range: range, useClipboard: useClipboard, onCancelEdit: () => onCancelEdit(), onSetEdit: ({ detail }) => onEdit(detail) }),
|
|
23
23
|
h("revogr-data", Object.assign({}, data, { [UUID]: data.uuid }, { key: key, readonly: readonly, range: range, rowClass: rowClass, rowSelectionStore: data.rowSelectionStore, slot: DATA_SLOT })),
|
|
24
24
|
h("revogr-temp-range", { selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }),
|
|
25
25
|
h("revogr-focus", { colData: data.colData, dataStore: data.dataStore, selectionStore: data.segmentSelectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol })));
|
|
@@ -21,6 +21,21 @@ export default class DimensionProvider {
|
|
|
21
21
|
this.viewports.stores[type].setViewport({ realCount });
|
|
22
22
|
this.stores[type].setRealSize(realCount);
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Apply new custom sizes to dimension and view port
|
|
26
|
+
* @param type - dimension type
|
|
27
|
+
* @param sizes - new custom sizes
|
|
28
|
+
* @param keepOld - keep old sizes merge new with old
|
|
29
|
+
*/
|
|
30
|
+
setCustomSizes(type, sizes, keepOld = false) {
|
|
31
|
+
let newSizes = sizes;
|
|
32
|
+
if (keepOld) {
|
|
33
|
+
const oldSizes = this.stores[type].store.get('sizes');
|
|
34
|
+
newSizes = Object.assign(Object.assign({}, oldSizes), sizes);
|
|
35
|
+
}
|
|
36
|
+
this.stores[type].setDimensionSize(newSizes);
|
|
37
|
+
this.viewports.stores[type].setViewPortDimension(newSizes, !keepOld ? this.stores[type].store.get('originItemSize') : undefined);
|
|
38
|
+
}
|
|
24
39
|
/**
|
|
25
40
|
* Sets dimension data and view port coordinate
|
|
26
41
|
* @param items - data/column items
|
|
@@ -45,8 +60,9 @@ export default class DimensionProvider {
|
|
|
45
60
|
this.stores[type].drop();
|
|
46
61
|
}
|
|
47
62
|
}
|
|
48
|
-
setColumns(type, sizes, noVirtual = false) {
|
|
49
|
-
this.
|
|
63
|
+
setColumns(type, newLength, sizes, noVirtual = false) {
|
|
64
|
+
this.setRealSize(newLength, type);
|
|
65
|
+
this.setCustomSizes(type, sizes);
|
|
50
66
|
if (noVirtual) {
|
|
51
67
|
this.setNoVirtual(type);
|
|
52
68
|
}
|
|
@@ -181,3 +181,38 @@ export function getFirstItem(s) {
|
|
|
181
181
|
export function getLastItem(s) {
|
|
182
182
|
return s.items[s.end];
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Set items sizes from start index to end
|
|
186
|
+
* @param vpItems
|
|
187
|
+
* @param start
|
|
188
|
+
* @param size
|
|
189
|
+
* @param lastCoordinate
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
export function setItemSizes(vpItems, initialIndex, size, lastCoordinate) {
|
|
193
|
+
const items = [...vpItems];
|
|
194
|
+
const count = items.length;
|
|
195
|
+
let pos = lastCoordinate;
|
|
196
|
+
let i = 0;
|
|
197
|
+
let start = initialIndex;
|
|
198
|
+
// viewport not inited
|
|
199
|
+
if (!count) {
|
|
200
|
+
return [];
|
|
201
|
+
}
|
|
202
|
+
// loop through array from initial item after recombination
|
|
203
|
+
while (i < count) {
|
|
204
|
+
const item = items[start];
|
|
205
|
+
item.start = pos;
|
|
206
|
+
item.size = size;
|
|
207
|
+
item.end = item.start + size;
|
|
208
|
+
pos = item.end;
|
|
209
|
+
// loop by start index
|
|
210
|
+
start++;
|
|
211
|
+
i++;
|
|
212
|
+
// if start index out of array, reset it
|
|
213
|
+
if (start === count) {
|
|
214
|
+
start = 0;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return items;
|
|
218
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Redraw items during scrolling
|
|
8
8
|
*/
|
|
9
9
|
import { createStore } from '@stencil/store';
|
|
10
|
-
import { addMissingItems, getFirstItem, getLastItem, getUpdatedItemsByPosition, isActiveRange, updateMissingAndRange } from './viewport.helpers';
|
|
10
|
+
import { addMissingItems, getFirstItem, getLastItem, getUpdatedItemsByPosition, isActiveRange, setItemSizes, updateMissingAndRange } from './viewport.helpers';
|
|
11
11
|
import { setStore } from '../../utils/store.utils';
|
|
12
12
|
function initialState() {
|
|
13
13
|
return {
|
|
@@ -73,8 +73,8 @@ export default class ViewportStore {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
/** Update viewport sizes */
|
|
76
|
-
setViewPortDimension(sizes) {
|
|
77
|
-
|
|
76
|
+
setViewPortDimension(sizes, dropToOriginalSize) {
|
|
77
|
+
let items = this.store.get('items');
|
|
78
78
|
const count = items.length;
|
|
79
79
|
// viewport not inited
|
|
80
80
|
if (!count) {
|
|
@@ -83,6 +83,10 @@ export default class ViewportStore {
|
|
|
83
83
|
let changedCoordinate = 0;
|
|
84
84
|
let i = 0;
|
|
85
85
|
let start = this.store.get('start');
|
|
86
|
+
// drop to original size if requested
|
|
87
|
+
if (dropToOriginalSize) {
|
|
88
|
+
items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
|
|
89
|
+
}
|
|
86
90
|
// loop through array from initial item after recombination
|
|
87
91
|
while (i < count) {
|
|
88
92
|
const item = items[start];
|