@revolist/revogrid 4.22.0 → 4.23.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/dist/cjs/{cell-renderer-uZmDBXz7.js → cell-renderer-DWJ9Px9f.js} +9 -3
- package/dist/cjs/{column.drag.plugin-CM_5mKV3.js → column.drag.plugin-CaEBDG-Q.js} +409 -267
- package/dist/cjs/{column.service-DvQDqxxx.js → column.service-f612L4ql.js} +1 -1
- package/dist/cjs/{dimension.helpers-CaIsYC99.js → dimension.helpers-B9HgANnM.js} +14 -146
- package/dist/cjs/{edit.utils-CwMzSIVF.js → edit.utils-pKeiYFLJ.js} +22 -1
- package/dist/cjs/{header-cell-renderer-B1dJwgTO.js → header-cell-renderer-4yq9_WbM.js} +1 -1
- package/dist/cjs/index-DxaSE5uZ.js +136 -0
- package/dist/cjs/index.cjs.js +45 -31
- package/dist/cjs/revo-grid.cjs.entry.js +35 -15
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +44 -26
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +11 -9
- package/dist/cjs/revogr-data_4.cjs.entry.js +132 -178
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +2 -1
- package/dist/cjs/{text-editor-BTnGaIl3.js → text-editor-B4W-m-r-.js} +3 -3
- package/dist/cjs/{throttle-CI4MsAqs.js → throttle-BCwEuJJq.js} +59 -24
- package/dist/cjs/viewport.helpers-BND76K2j.js +140 -0
- package/dist/cjs/{viewport.store-Dcjud-a-.js → viewport.store-BlKQ4x9H.js} +16 -16
- package/dist/collection/components/clipboard/revogr-clipboard.js +1 -1
- package/dist/collection/components/data/revogr-data.js +5 -3
- package/dist/collection/components/header/header-group-renderer.js +2 -1
- package/dist/collection/components/header/header-renderer.js +6 -5
- package/dist/collection/components/header/revogr-header-style.css +13 -3
- package/dist/collection/components/header/revogr-header.js +105 -42
- package/dist/collection/components/order/order-row.service.js +6 -5
- package/dist/collection/components/overlay/keyboard.service.js +25 -3
- package/dist/collection/components/overlay/selection.utils.js +8 -6
- package/dist/collection/components/revoGrid/revo-grid.js +6 -5
- package/dist/collection/components/revoGrid/viewport.service.js +2 -1
- package/dist/collection/components/scroll/revogr-viewport-scroll.js +10 -6
- package/dist/collection/components/scrollable/revogr-scroll-virtual.js +4 -10
- package/dist/collection/plugins/filter/filter.panel.js +2 -1
- package/dist/collection/plugins/filter/filter.plugin.js +11 -4
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +25 -1
- package/dist/collection/plugins/moveColumn/column.drag.plugin.js +18 -15
- package/dist/collection/plugins/sorting/sorting.func.js +173 -15
- package/dist/collection/plugins/sorting/sorting.plugin.js +167 -84
- package/dist/collection/plugins/sorting/sorting.sign.js +7 -1
- package/dist/collection/serve/controller.js +98 -37
- package/dist/collection/serve/data.js +273 -144
- package/dist/collection/services/dimension.provider.js +16 -1
- package/dist/collection/services/local.scroll.service.js +59 -24
- package/dist/collection/services/scroll.dimension.helpers.js +83 -0
- package/dist/collection/services/selection.store.connector.js +4 -1
- package/dist/collection/store/dimension/dimension.recalculate.plugin.js +22 -9
- package/dist/collection/store/dimension/dimension.store.js +4 -2
- package/dist/collection/store/vp/viewport.helpers.js +9 -0
- package/dist/collection/store/vp/viewport.store.js +5 -16
- package/dist/collection/types/events.js +4 -0
- package/dist/collection/utils/key.utils.js +20 -0
- package/dist/collection/utils/store.utils.js +3 -3
- package/dist/{revo-grid/cell-renderer-K_BKH7Kx.js → esm/cell-renderer-8UiGd-s7.js} +9 -3
- package/dist/esm/{column.drag.plugin-DEqZ2qXJ.js → column.drag.plugin-BsfhsfmB.js} +402 -266
- package/dist/esm/{column.service-Cdz3dYqZ.js → column.service-DbpulTog.js} +1 -1
- package/dist/{revo-grid/debounce-BfO9dz9v.js → esm/debounce-PCRWZliA.js} +1 -1
- package/dist/{revo-grid/dimension.helpers-DzxqJQqN.js → esm/dimension.helpers-CGKwSvw6.js} +7 -128
- package/dist/esm/{edit.utils-CzfeG98N.js → edit.utils-Dnnbd0xG.js} +22 -2
- package/dist/{revo-grid/header-cell-renderer-DXhxZMly.js → esm/header-cell-renderer-DGI2FAD8.js} +1 -1
- package/dist/esm/index-Db3qZoW5.js +127 -0
- package/dist/esm/index.js +15 -10
- package/dist/esm/revo-grid.entry.js +34 -14
- package/dist/esm/revogr-attribution_7.entry.js +43 -25
- package/dist/esm/revogr-clipboard_3.entry.js +12 -10
- package/dist/esm/revogr-data_4.entry.js +133 -179
- package/dist/esm/revogr-filter-panel.entry.js +3 -2
- package/dist/esm/{text-editor-C1ks5eQ4.js → text-editor-C3RUSwH5.js} +2 -2
- package/dist/esm/{throttle-BEjFQa2l.js → throttle-CaUDyxyU.js} +60 -25
- package/dist/esm/viewport.helpers-CoCAvmZs.js +133 -0
- package/dist/{revo-grid/viewport.store-saAZJHRo.js → esm/viewport.store-COAfzAyu.js} +15 -17
- package/dist/{esm/cell-renderer-K_BKH7Kx.js → revo-grid/cell-renderer-8UiGd-s7.js} +9 -3
- package/dist/revo-grid/{column.drag.plugin-DEqZ2qXJ.js → column.drag.plugin-BsfhsfmB.js} +402 -266
- package/dist/revo-grid/{column.service-Cdz3dYqZ.js → column.service-DbpulTog.js} +1 -1
- package/dist/{esm/debounce-BfO9dz9v.js → revo-grid/debounce-PCRWZliA.js} +1 -1
- package/dist/{esm/dimension.helpers-DzxqJQqN.js → revo-grid/dimension.helpers-CGKwSvw6.js} +7 -128
- package/dist/revo-grid/{edit.utils-CzfeG98N.js → edit.utils-Dnnbd0xG.js} +22 -2
- package/dist/{esm/header-cell-renderer-DXhxZMly.js → revo-grid/header-cell-renderer-DGI2FAD8.js} +1 -1
- package/dist/revo-grid/index-Db3qZoW5.js +127 -0
- package/dist/revo-grid/index.esm.js +15 -10
- package/dist/revo-grid/revo-grid.entry.js +34 -14
- package/dist/revo-grid/revogr-attribution_7.entry.js +43 -25
- package/dist/revo-grid/revogr-clipboard_3.entry.js +12 -10
- package/dist/revo-grid/revogr-data_4.entry.js +133 -179
- package/dist/revo-grid/revogr-filter-panel.entry.js +3 -2
- package/dist/revo-grid/{text-editor-C1ks5eQ4.js → text-editor-C3RUSwH5.js} +2 -2
- package/dist/revo-grid/{throttle-BEjFQa2l.js → throttle-CaUDyxyU.js} +60 -25
- package/dist/revo-grid/viewport.helpers-CoCAvmZs.js +133 -0
- package/dist/{esm/viewport.store-saAZJHRo.js → revo-grid/viewport.store-COAfzAyu.js} +15 -17
- package/dist/types/components/header/header-group-renderer.d.ts +1 -0
- package/dist/types/components/header/header-renderer.d.ts +1 -0
- package/dist/types/components/header/revogr-header.d.ts +6 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +5 -0
- package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +8 -0
- package/dist/types/plugins/moveColumn/column.drag.plugin.d.ts +29 -3
- package/dist/types/plugins/sorting/sorting.func.d.ts +25 -2
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +84 -9
- package/dist/types/plugins/sorting/sorting.sign.d.ts +5 -1
- package/dist/types/plugins/sorting/sorting.types.d.ts +46 -1
- package/dist/types/services/local.scroll.service.d.ts +10 -2
- package/dist/types/services/scroll.dimension.helpers.d.ts +20 -0
- package/dist/types/store/vp/viewport.helpers.d.ts +2 -0
- package/dist/types/types/events.d.ts +1 -1
- package/dist/types/types/interfaces.d.ts +11 -0
- package/dist/types/utils/key.utils.d.ts +8 -0
- package/hydrate/index.js +791 -539
- package/hydrate/index.mjs +791 -539
- package/package.json +1 -1
- package/standalone/column.service.js +1 -1
- package/standalone/data.store.js +1 -1
- package/standalone/debounce.js +1 -1
- package/standalone/dimension.helpers.js +1 -1
- package/standalone/index.js +1 -1
- package/standalone/local.scroll.timer.js +1 -1
- package/standalone/revo-grid.js +1 -1
- package/standalone/revogr-clipboard2.js +1 -1
- package/standalone/revogr-data2.js +1 -1
- package/standalone/revogr-edit.js +1 -1
- package/standalone/revogr-edit2.js +1 -1
- package/standalone/revogr-filter-panel.js +1 -1
- package/standalone/revogr-header2.js +1 -1
- package/standalone/revogr-order-editor2.js +1 -1
- package/standalone/revogr-overlay-selection2.js +1 -1
- package/standalone/revogr-row-headers.js +1 -1
- package/standalone/revogr-row-headers2.js +1 -1
- package/standalone/revogr-scroll-virtual2.js +1 -1
- package/standalone/revogr-viewport-scroll2.js +1 -1
- package/standalone/selection.utils.js +1 -1
- package/standalone/throttle.js +1 -1
- package/standalone/toNumber.js +1 -1
- package/dist/cjs/viewport.helpers-BAovztDd.js +0 -58
- package/dist/esm/viewport.helpers-VXhsJZtn.js +0 -52
- package/dist/revo-grid/viewport.helpers-VXhsJZtn.js +0 -52
|
@@ -49,8 +49,8 @@ export function getCurrentCell({ x, y }, { el, rows, cols }) {
|
|
|
49
49
|
cellX = width - 1;
|
|
50
50
|
}
|
|
51
51
|
// Get the row and column items based on the cell position
|
|
52
|
-
const rgRow = getItemByPosition(rows, cellY);
|
|
53
|
-
const rgCol = getItemByPosition(cols, cellX);
|
|
52
|
+
const rgRow = getItemByPosition(rows, cellY + (rows.renderOffset || 0));
|
|
53
|
+
const rgCol = getItemByPosition(cols, cellX + (cols.renderOffset || 0));
|
|
54
54
|
// Set the row and column index to 0 if they are before the first item
|
|
55
55
|
if (rgCol.itemIndex < 0) {
|
|
56
56
|
rgCol.itemIndex = 0;
|
|
@@ -120,10 +120,12 @@ export function styleByCellProps(styles) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
export function getCell({ x, y, x1, y1 }, dimensionRow, dimensionCol) {
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
123
|
+
const rowOffset = dimensionRow.renderOffset || 0;
|
|
124
|
+
const colOffset = dimensionCol.renderOffset || 0;
|
|
125
|
+
const top = getItemByIndex(dimensionRow, y).start - rowOffset;
|
|
126
|
+
const left = getItemByIndex(dimensionCol, x).start - colOffset;
|
|
127
|
+
const bottom = getItemByIndex(dimensionRow, y1).end - rowOffset;
|
|
128
|
+
const right = getItemByIndex(dimensionCol, x1).end - colOffset;
|
|
127
129
|
return {
|
|
128
130
|
left,
|
|
129
131
|
right,
|
|
@@ -626,12 +626,13 @@ export class RevoGridComponent {
|
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
628
|
const columns = this.columnProvider.setColumns(beforeApplyEvent.detail);
|
|
629
|
+
const order = {};
|
|
630
|
+
for (const prop of Object.keys(beforeApplyEvent.detail.sort)) {
|
|
631
|
+
order[prop] = beforeApplyEvent.detail.sort[prop].order;
|
|
632
|
+
}
|
|
629
633
|
this.aftercolumnsset.emit({
|
|
630
634
|
columns,
|
|
631
|
-
order
|
|
632
|
-
acc[prop] = column.order;
|
|
633
|
-
return acc;
|
|
634
|
-
}, {}),
|
|
635
|
+
order,
|
|
635
636
|
});
|
|
636
637
|
}
|
|
637
638
|
disableVirtualXChanged(newVal = false, prevVal = false) {
|
|
@@ -920,7 +921,7 @@ export class RevoGridComponent {
|
|
|
920
921
|
if (Object.keys((_a = this.trimmedRows) !== null && _a !== void 0 ? _a : {}).length > 0) {
|
|
921
922
|
this.trimmedRowsChanged(this.trimmedRows);
|
|
922
923
|
}
|
|
923
|
-
this.rowDefChanged(this.rowDefinitions);
|
|
924
|
+
this.rowDefChanged(this.rowDefinitions, undefined, undefined, false);
|
|
924
925
|
// init grouping
|
|
925
926
|
if (this.grouping && Object.keys(this.grouping).length > 0) {
|
|
926
927
|
this.groupingChanged(this.grouping);
|
|
@@ -108,7 +108,8 @@ export default class ViewportService {
|
|
|
108
108
|
(_a = this.config.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setCustomSizes(type, detail, true);
|
|
109
109
|
// set resize event
|
|
110
110
|
const changedItems = {};
|
|
111
|
-
for (const
|
|
111
|
+
for (const i of Object.keys(detail || {})) {
|
|
112
|
+
const size = detail[i];
|
|
112
113
|
const virtualIndex = parseInt(i, 10);
|
|
113
114
|
const item = getSourceItem(store, virtualIndex);
|
|
114
115
|
if (item) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { h, Host, } from "@stencil/core";
|
|
5
5
|
import GridResizeService from "../revoGrid/viewport.resize.service";
|
|
6
|
-
import LocalScrollService from "../../services/local.scroll.service";
|
|
6
|
+
import LocalScrollService, { getContentSize } from "../../services/local.scroll.service";
|
|
7
7
|
import { LocalScrollTimer } from "../../services/local.scroll.timer";
|
|
8
8
|
import { CONTENT_SLOT, FOOTER_SLOT, HEADER_SLOT, } from "../revoGrid/viewport.helpers";
|
|
9
9
|
/**
|
|
@@ -34,7 +34,7 @@ export class RevogrViewportScroll {
|
|
|
34
34
|
* @param e
|
|
35
35
|
*/
|
|
36
36
|
async changeScroll(e, silent = false) {
|
|
37
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
38
|
if (silent) {
|
|
39
39
|
if (e.coordinate && this.verticalScroll) {
|
|
40
40
|
switch (e.dimension) {
|
|
@@ -47,15 +47,16 @@ export class RevogrViewportScroll {
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
if (e.delta) {
|
|
50
|
+
let currentPhysicalCoordinate = 0;
|
|
50
51
|
switch (e.dimension) {
|
|
51
52
|
case 'rgCol':
|
|
52
|
-
|
|
53
|
+
currentPhysicalCoordinate = this.horizontalScroll.scrollLeft;
|
|
53
54
|
break;
|
|
54
55
|
case 'rgRow':
|
|
55
|
-
|
|
56
|
+
currentPhysicalCoordinate = (_b = (_a = this.verticalScroll) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : 0;
|
|
56
57
|
break;
|
|
57
58
|
}
|
|
58
|
-
this.
|
|
59
|
+
return (_d = (_c = this.localScrollService) === null || _c === void 0 ? void 0 : _c.setScrollByDelta(e, currentPhysicalCoordinate)) !== null && _d !== void 0 ? _d : e;
|
|
59
60
|
}
|
|
60
61
|
return e;
|
|
61
62
|
}
|
|
@@ -207,7 +208,10 @@ export class RevogrViewportScroll {
|
|
|
207
208
|
this.setScrollVisibility('rgCol', this.horizontalScroll.clientWidth, this.contentWidth);
|
|
208
209
|
}
|
|
209
210
|
render() {
|
|
210
|
-
|
|
211
|
+
var _a, _b, _c, _d;
|
|
212
|
+
const physicalContentHeight = getContentSize(this.contentHeight, (_b = (_a = this.verticalScroll) === null || _a === void 0 ? void 0 : _a.clientHeight) !== null && _b !== void 0 ? _b : 0);
|
|
213
|
+
const physicalContentWidth = getContentSize(this.contentWidth, (_d = (_c = this.horizontalScroll) === null || _c === void 0 ? void 0 : _c.clientWidth) !== null && _d !== void 0 ? _d : 0);
|
|
214
|
+
return (h(Host, { key: 'a0c47dede9d131dea8c8ca449e8a323f24d9b113', onWheel: this.horizontalMouseWheel, onScroll: (e) => this.applyScroll('rgCol', e) }, h("div", { key: '6c960e753ffe522ba4afb1c379264873b6c617f3', class: "inner-content-table", style: { width: `${physicalContentWidth}px` } }, h("div", { key: '1a6cbcbd3634e84756b54c8150aebd25c824e14a', class: "header-wrapper", ref: e => (this.header = e) }, h("slot", { key: 'e4202c687bc39b4f78f3ed9840e979b032f06af8', name: HEADER_SLOT })), h("div", { key: '651415b5b32e72735065b183317386a34042bb85', class: "vertical-inner", ref: el => (this.verticalScroll = el), onWheel: this.verticalMouseWheel, onScroll: (e) => this.applyScroll('rgRow', e) }, h("div", { key: 'e65623b78d80957d8676adb019618953ef267ec3', class: "content-wrapper", style: { height: `${physicalContentHeight}px` } }, h("slot", { key: '5af47b12ef1226587cf774233447b5252d65e836', name: CONTENT_SLOT }))), h("div", { key: 'cbc0fd64fbfb53d3b18e547bbe34e32b7bb9c043', class: "footer-wrapper", ref: e => (this.footer = e) }, h("slot", { key: 'a8e4bfaef400973121090bac3069eb85469a95f3', name: FOOTER_SLOT })))));
|
|
211
215
|
}
|
|
212
216
|
/**
|
|
213
217
|
* Extra layer for scroll event monitoring, where MouseWheel event is not passing
|
|
@@ -37,15 +37,9 @@ export class RevogrScrollVirtual {
|
|
|
37
37
|
*/
|
|
38
38
|
async changeScroll(e) {
|
|
39
39
|
if (e.delta) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
break;
|
|
44
|
-
case 'rgRow':
|
|
45
|
-
e.coordinate = this.element.scrollTop + e.delta;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
this.setScroll(e);
|
|
40
|
+
const scrollProperty = e.dimension === 'rgRow' ? 'scrollTop' : 'scrollLeft';
|
|
41
|
+
const currentPhysicalCoordinate = this.element[scrollProperty];
|
|
42
|
+
return this.localScrollService.setScrollByDelta(e, currentPhysicalCoordinate);
|
|
49
43
|
}
|
|
50
44
|
return e;
|
|
51
45
|
}
|
|
@@ -108,7 +102,7 @@ export class RevogrScrollVirtual {
|
|
|
108
102
|
}
|
|
109
103
|
render() {
|
|
110
104
|
const size = getContentSize(this.realSize, this.dimension === 'rgRow' ? this.element.clientHeight : this.element.clientWidth, this.clientSize);
|
|
111
|
-
return (h(Host, { key: '
|
|
105
|
+
return (h(Host, { key: '7213817ef941eee4050b714266598ec0c2961ee9', onScroll: (e) => this.onScroll(e) }, h("div", { key: '501da49c63253ab943172494b9dbf5399be56cee', style: {
|
|
112
106
|
[this.dimension === 'rgRow' ? 'height' : 'width']: `${size}px`,
|
|
113
107
|
} })));
|
|
114
108
|
}
|
|
@@ -250,7 +250,8 @@ export class FilterPanel {
|
|
|
250
250
|
const options = [];
|
|
251
251
|
const prop = this.changes.prop;
|
|
252
252
|
const hidden = new Set();
|
|
253
|
-
Object.
|
|
253
|
+
Object.keys(this.filterItems).forEach((prop) => {
|
|
254
|
+
const values = this.filterItems[prop];
|
|
254
255
|
values.forEach((filter) => {
|
|
255
256
|
if (filter.hidden) {
|
|
256
257
|
hidden.add(filter.type);
|
|
@@ -152,17 +152,24 @@ export class FilterPlugin extends BasePlugin {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
if (config.collection) {
|
|
155
|
-
const
|
|
156
|
-
|
|
155
|
+
const filterCollection = {};
|
|
156
|
+
for (const prop of Object.keys(config.collection)) {
|
|
157
|
+
const item = config.collection[prop];
|
|
158
|
+
if (this.filterFunctionsIndexedByType[item.type]) {
|
|
159
|
+
filterCollection[prop] = item;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.filterCollection = filterCollection;
|
|
157
163
|
}
|
|
158
164
|
else {
|
|
159
165
|
this.filterCollection = {};
|
|
160
166
|
}
|
|
161
167
|
if (config.localization) {
|
|
162
168
|
if (config.localization.filterNames) {
|
|
163
|
-
|
|
169
|
+
const filterNames = config.localization.filterNames;
|
|
170
|
+
Object.keys(filterNames).forEach((k) => {
|
|
164
171
|
if (this.filterNameIndexByType[k] != void 0) {
|
|
165
|
-
this.filterNameIndexByType[k] =
|
|
172
|
+
this.filterNameIndexByType[k] = filterNames[k];
|
|
166
173
|
}
|
|
167
174
|
});
|
|
168
175
|
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
5
|
+
var t = {};
|
|
6
|
+
for (var p in s)
|
|
7
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
10
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
12
|
+
t[p[i]] = s[p[i]];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
4
16
|
import { getPhysical, setItems, columnTypes, } from "../../store/index";
|
|
5
17
|
import { BasePlugin } from "../base.plugin";
|
|
6
18
|
import { FILTER_TRIMMED_TYPE } from "../filter/filter.plugin";
|
|
@@ -97,6 +109,18 @@ export class GroupingRowPlugin extends BasePlugin {
|
|
|
97
109
|
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
98
110
|
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
|
|
99
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns grouping options for regrouping that must preserve current UI state.
|
|
114
|
+
*
|
|
115
|
+
* `expandedAll` and config `prevExpanded` are initial/config instructions.
|
|
116
|
+
* Reusing them after sorting would reopen groups the user collapsed before
|
|
117
|
+
* sorting instead of using the current grouped source state.
|
|
118
|
+
*/
|
|
119
|
+
getCurrentExpandedOptions() {
|
|
120
|
+
var _a;
|
|
121
|
+
const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, { expandedAll: _expandedAll, prevExpanded: _prevExpanded } = _b, options = __rest(_b, ["expandedAll", "prevExpanded"]);
|
|
122
|
+
return options;
|
|
123
|
+
}
|
|
100
124
|
/**
|
|
101
125
|
* Starts global source update with group clearing and applying new one
|
|
102
126
|
* Initiated when need to reapply grouping
|
|
@@ -199,7 +223,7 @@ export class GroupingRowPlugin extends BasePlugin {
|
|
|
199
223
|
if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
200
224
|
return;
|
|
201
225
|
}
|
|
202
|
-
this.doSourceUpdate(
|
|
226
|
+
this.doSourceUpdate(this.getCurrentExpandedOptions());
|
|
203
227
|
});
|
|
204
228
|
/**
|
|
205
229
|
* Apply logic for focus inside of grouping
|
|
@@ -13,11 +13,11 @@ import { dispatch } from "../dispatcher";
|
|
|
13
13
|
import { ON_COLUMN_CLICK } from "../../components/header/header-cell-renderer";
|
|
14
14
|
import { isColGrouping } from "../../utils/column.utils";
|
|
15
15
|
const COLUMN_CLICK = ON_COLUMN_CLICK;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
export const COLUMN_DRAG_MOVE_EVENT = 'columndragmousemove';
|
|
17
|
+
export const COLUMN_DRAG_END_EVENT = 'columndragend';
|
|
18
|
+
export const BEFORE_COLUMN_DRAG_END_EVENT = 'beforecolumndragend';
|
|
19
19
|
// use this event subscription to drop D&D for particular columns
|
|
20
|
-
const
|
|
20
|
+
export const COLUMN_DRAG_START_EVENT = 'columndragstart';
|
|
21
21
|
export class ColumnMovePlugin extends BasePlugin {
|
|
22
22
|
constructor(revogrid, providers) {
|
|
23
23
|
super(revogrid, providers);
|
|
@@ -47,7 +47,7 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
47
47
|
if (event.defaultPrevented) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const { defaultPrevented } = dispatch(this.revogrid,
|
|
50
|
+
const { defaultPrevented } = dispatch(this.revogrid, COLUMN_DRAG_START_EVENT, data);
|
|
51
51
|
// check if allowed to drag particulat column
|
|
52
52
|
if (defaultPrevented) {
|
|
53
53
|
return;
|
|
@@ -68,7 +68,7 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
68
68
|
const cols = this.getDimension(data.pin || 'rgCol');
|
|
69
69
|
const gridRect = this.revogrid.getBoundingClientRect();
|
|
70
70
|
const elRect = dataEl.getBoundingClientRect();
|
|
71
|
-
const startItem = getItemByPosition(cols, getLeftRelative(event.x, gridRect.left, elRect.left - gridRect.left));
|
|
71
|
+
const startItem = getItemByPosition(cols, getLeftRelative(event.x, gridRect.left, elRect.left - gridRect.left) + (cols.renderOffset || 0));
|
|
72
72
|
this.staticDragData = {
|
|
73
73
|
startPos: event.x,
|
|
74
74
|
startItem,
|
|
@@ -78,7 +78,7 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
78
78
|
gridEl: this.revogrid,
|
|
79
79
|
cols,
|
|
80
80
|
};
|
|
81
|
-
this.dragData = this.getData(this.staticDragData);
|
|
81
|
+
this.dragData = this.getData(this.staticDragData, []);
|
|
82
82
|
mousemove.target.addEventListener('mousemove', mousemove.callback);
|
|
83
83
|
this.orderUi.start(event, Object.assign(Object.assign({}, this.dragData), this.staticDragData));
|
|
84
84
|
}
|
|
@@ -86,24 +86,24 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
86
86
|
if (!this.staticDragData) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const dragData = (this.dragData = this.getData(this.staticDragData));
|
|
89
|
+
const dragData = (this.dragData = this.getData(this.staticDragData, []));
|
|
90
90
|
if (!dragData) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
const start = this.staticDragData.startPos;
|
|
94
94
|
if (Math.abs(start - e.x) > 10) {
|
|
95
95
|
const x = getLeftRelative(e.x, this.dragData.gridRect.left, this.dragData.scrollOffset);
|
|
96
|
-
const rgCol = getItemByPosition(this.staticDragData.cols, x);
|
|
96
|
+
const rgCol = getItemByPosition(this.staticDragData.cols, x + (this.staticDragData.cols.renderOffset || 0));
|
|
97
97
|
this.orderUi.autoscroll(x, dragData.elRect.width);
|
|
98
98
|
// prevent position change if out of bounds
|
|
99
99
|
if (rgCol.itemIndex >= this.staticDragData.cols.count) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
this.orderUi.showHandler(rgCol.end + dragData.scrollOffset, dragData.gridRect.width);
|
|
102
|
+
this.orderUi.showHandler(rgCol.end - (this.staticDragData.cols.renderOffset || 0) + dragData.scrollOffset, dragData.gridRect.width);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
move(e) {
|
|
106
|
-
dispatch(this.revogrid,
|
|
106
|
+
dispatch(this.revogrid, COLUMN_DRAG_MOVE_EVENT, e);
|
|
107
107
|
// then do move
|
|
108
108
|
this.moveFunc(e);
|
|
109
109
|
}
|
|
@@ -117,11 +117,12 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
117
117
|
if (relativePos < 0) {
|
|
118
118
|
relativePos = 0;
|
|
119
119
|
}
|
|
120
|
-
const newPosition = getItemByPosition(this.staticDragData.cols, relativePos);
|
|
120
|
+
const newPosition = getItemByPosition(this.staticDragData.cols, relativePos + (this.staticDragData.cols.renderOffset || 0));
|
|
121
121
|
const store = this.providers.column.stores[this.dragData.type].store;
|
|
122
|
+
const source = store.get('source');
|
|
122
123
|
const newItems = [...store.get('items')];
|
|
123
124
|
// prevent position change if needed
|
|
124
|
-
const { defaultPrevented: stopDrag } = dispatch(this.revogrid,
|
|
125
|
+
const { defaultPrevented: stopDrag } = dispatch(this.revogrid, BEFORE_COLUMN_DRAG_END_EVENT, Object.assign(Object.assign({}, this.staticDragData), { startPosition: this.staticDragData.startItem, newPosition, newItem: source[newItems[this.staticDragData.startItem.itemIndex]] }));
|
|
125
126
|
if (!stopDrag) {
|
|
126
127
|
const prevItems = [...newItems];
|
|
127
128
|
// todo: if move item out of group remove item from group
|
|
@@ -130,7 +131,7 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
130
131
|
store.set('items', newItems);
|
|
131
132
|
this.providers.dimension.updateSizesPositionByNewDataIndexes(this.dragData.type, newItems, prevItems);
|
|
132
133
|
}
|
|
133
|
-
dispatch(this.revogrid,
|
|
134
|
+
dispatch(this.revogrid, COLUMN_DRAG_END_EVENT, this.getData(this.staticDragData, newItems, source));
|
|
134
135
|
}
|
|
135
136
|
this.clearOrder();
|
|
136
137
|
}
|
|
@@ -150,13 +151,15 @@ export class ColumnMovePlugin extends BasePlugin {
|
|
|
150
151
|
super.clearSubscriptions();
|
|
151
152
|
this.clearLocalSubscriptions();
|
|
152
153
|
}
|
|
153
|
-
getData({ gridEl, dataEl, pin,
|
|
154
|
+
getData({ gridEl, dataEl, pin }, order, source = []) {
|
|
154
155
|
const gridRect = gridEl.getBoundingClientRect();
|
|
155
156
|
const elRect = dataEl.getBoundingClientRect();
|
|
156
157
|
const scrollOffset = elRect.left - gridRect.left;
|
|
157
158
|
return {
|
|
159
|
+
columns: order.map(index => source[index]).filter(Boolean),
|
|
158
160
|
elRect,
|
|
159
161
|
gridRect,
|
|
162
|
+
order,
|
|
160
163
|
type: pin || 'rgCol',
|
|
161
164
|
scrollOffset,
|
|
162
165
|
};
|
|
@@ -1,13 +1,177 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
+
import { GROUP_COLUMN_PROP } from "../groupingRow/grouping.const";
|
|
4
5
|
import { isGrouping } from "../groupingRow/grouping.service";
|
|
5
6
|
import { getCellRaw } from "../../utils/column.utils";
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether a sorting map contains at least one active order.
|
|
9
|
+
*
|
|
10
|
+
* Empty maps and properties with `undefined` order are treated as inactive.
|
|
11
|
+
*/
|
|
12
|
+
export function hasActiveSorting(sorting) {
|
|
13
|
+
for (const prop of Object.keys(sorting || {})) {
|
|
14
|
+
if (sorting === null || sorting === void 0 ? void 0 : sorting[prop]) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compares column properties after object-key coercion.
|
|
22
|
+
*/
|
|
23
|
+
function isSameColumnProp(a, b) {
|
|
24
|
+
return String(a) === String(b);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns active sorting properties in explicit priority order.
|
|
28
|
+
*/
|
|
29
|
+
function getActiveSortingProps(sorting, sortingOrder) {
|
|
30
|
+
const activeProps = [];
|
|
31
|
+
const add = (prop) => {
|
|
32
|
+
if ((sorting === null || sorting === void 0 ? void 0 : sorting[prop]) && !activeProps.some(active => isSameColumnProp(active, prop))) {
|
|
33
|
+
activeProps.push(prop);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
sortingOrder === null || sortingOrder === void 0 ? void 0 : sortingOrder.forEach(add);
|
|
37
|
+
Object.keys(sorting || {}).forEach(add);
|
|
38
|
+
return activeProps;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns one-based additive sorting rank for a column.
|
|
42
|
+
*
|
|
43
|
+
* A single active sort does not need a visible rank, so it returns undefined.
|
|
44
|
+
*/
|
|
45
|
+
export function getSortingIndex(sorting, prop, sortingOrder) {
|
|
46
|
+
const activeProps = getActiveSortingProps(sorting, sortingOrder);
|
|
47
|
+
if (activeProps.length <= 1) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const index = activeProps.findIndex(active => isSameColumnProp(active, prop));
|
|
51
|
+
return index >= 0 ? index + 1 : undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Collects only active comparator functions from a sorting function map.
|
|
55
|
+
*
|
|
56
|
+
* This keeps undefined comparator entries from triggering sorting work.
|
|
57
|
+
*/
|
|
58
|
+
function activeSortingEntries(sortingFunc = {}, sortingOrder) {
|
|
59
|
+
const entries = [];
|
|
60
|
+
const add = (prop) => {
|
|
61
|
+
const cmp = sortingFunc[prop];
|
|
62
|
+
if (typeof cmp === 'function' && !entries.some(([active]) => isSameColumnProp(active, prop))) {
|
|
63
|
+
entries.push([prop, cmp]);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
sortingOrder === null || sortingOrder === void 0 ? void 0 : sortingOrder.forEach(add);
|
|
67
|
+
Object.keys(sortingFunc).forEach(add);
|
|
68
|
+
return entries;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Reads and normalizes a value for the built-in default comparer.
|
|
72
|
+
*/
|
|
73
|
+
function getDefaultCompareValue(item, prop, column) {
|
|
74
|
+
const aRaw = column ? getCellRaw(item, column) : item === null || item === void 0 ? void 0 : item[prop];
|
|
75
|
+
return typeof aRaw === 'number' ? aRaw : aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
76
|
+
}
|
|
77
|
+
function isEmptyCompareValue(value) {
|
|
78
|
+
return value === '' || value === null || value === undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compares two already-normalized default comparer values.
|
|
82
|
+
*/
|
|
83
|
+
function compareValues(av, bv) {
|
|
84
|
+
if (av === bv) {
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
const aEmpty = isEmptyCompareValue(av);
|
|
88
|
+
const bEmpty = isEmptyCompareValue(bv);
|
|
89
|
+
if (aEmpty || bEmpty) {
|
|
90
|
+
if (aEmpty && bEmpty) {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
return aEmpty ? -1 : 1;
|
|
94
|
+
}
|
|
95
|
+
if (av > bv) {
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
return -1;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Sorts indexes by precomputed values for default column comparers.
|
|
102
|
+
*
|
|
103
|
+
* This avoids repeatedly parsing the same cell value during large default
|
|
104
|
+
* sorts while preserving normal multi-column ordering.
|
|
105
|
+
*/
|
|
106
|
+
function sortIndexByDefaultComparers(indexes, source, entries, sorting, sortingColumns) {
|
|
107
|
+
const prepared = entries.map(([prop]) => {
|
|
108
|
+
const values = [];
|
|
109
|
+
const column = sortingColumns[prop];
|
|
110
|
+
for (const index of indexes) {
|
|
111
|
+
values[index] = getDefaultCompareValue(source[index], prop, column);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
order: sorting[prop],
|
|
115
|
+
values,
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
return indexes.sort((a, b) => {
|
|
119
|
+
for (const { order, values } of prepared) {
|
|
120
|
+
const sorted = compareValues(values[a], values[b]);
|
|
121
|
+
if (sorted) {
|
|
122
|
+
return order === 'desc' ? -sorted : sorted;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return 0;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Detects whether the optimized default-comparer path can be used.
|
|
130
|
+
*
|
|
131
|
+
* Grouped rows and custom `cellCompare` functions stay on the legacy
|
|
132
|
+
* comparator path to preserve their exact behavior.
|
|
133
|
+
*/
|
|
134
|
+
function canUseDefaultCompareFastPath(entries, indexes, source, sorting, sortingColumns) {
|
|
135
|
+
return !indexes.some(index => isGrouping(source[index])) && !!sorting && !!sortingColumns && entries.every(([prop]) => {
|
|
136
|
+
const order = sorting[prop];
|
|
137
|
+
const column = sortingColumns[prop];
|
|
138
|
+
return !!order && !(column === null || column === void 0 ? void 0 : column.cellCompare);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Group placeholder rows are generated for their grouping column. If sorting is
|
|
143
|
+
* requested for another column, the grouped source must be unwrapped first.
|
|
144
|
+
*/
|
|
145
|
+
function hasGroupingRowsForOtherSorting(entries, indexes, source) {
|
|
146
|
+
return indexes.some(index => {
|
|
147
|
+
const item = source[index];
|
|
148
|
+
return isGrouping(item) && !entries.some(([prop]) => isSameColumnProp(item[GROUP_COLUMN_PROP], prop));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Sorts row indexes against a source collection.
|
|
153
|
+
*
|
|
154
|
+
* @param indexes - Current proxy row indexes to sort.
|
|
155
|
+
* @param source - Full source collection addressed by the indexes.
|
|
156
|
+
* @param sortingFunc - Comparator functions by column property.
|
|
157
|
+
* @param sorting - Active sorting order by column property.
|
|
158
|
+
* @param sortingColumns - Column metadata by property for default-comparer optimization.
|
|
159
|
+
* @param sortingOrder - Active sorting priority in click/config insertion order.
|
|
160
|
+
* @returns Sorted proxy indexes. With no sorting function keys, returns source-order indexes.
|
|
161
|
+
*/
|
|
162
|
+
export function sortIndexByItems(indexes, source, sortingFunc = {}, sorting, sortingColumns, sortingOrder) {
|
|
163
|
+
const hasSortingKeys = Object.keys(sortingFunc).length > 0;
|
|
164
|
+
const sortingEntries = activeSortingEntries(sortingFunc, sortingOrder);
|
|
7
165
|
// if no sorting - return unsorted indexes
|
|
8
|
-
if (
|
|
166
|
+
if (sortingEntries.length === 0) {
|
|
9
167
|
// Unsorted indexes
|
|
10
|
-
return [...Array(indexes.length).keys()];
|
|
168
|
+
return hasSortingKeys ? indexes : [...new Array(indexes.length).keys()];
|
|
169
|
+
}
|
|
170
|
+
if (hasGroupingRowsForOtherSorting(sortingEntries, indexes, source)) {
|
|
171
|
+
return indexes;
|
|
172
|
+
}
|
|
173
|
+
if (canUseDefaultCompareFastPath(sortingEntries, indexes, source, sorting, sortingColumns)) {
|
|
174
|
+
return sortIndexByDefaultComparers(indexes, source, sortingEntries, sorting, sortingColumns);
|
|
11
175
|
}
|
|
12
176
|
//
|
|
13
177
|
/**
|
|
@@ -17,15 +181,15 @@ export function sortIndexByItems(indexes, source, sortingFunc = {}) {
|
|
|
17
181
|
return indexes.sort((a, b) => {
|
|
18
182
|
const itemA = source[a];
|
|
19
183
|
const itemB = source[b];
|
|
20
|
-
for (const [prop, cmp] of
|
|
184
|
+
for (const [prop, cmp] of sortingEntries) {
|
|
21
185
|
if (isGrouping(itemA)) {
|
|
22
|
-
if (itemA[
|
|
23
|
-
return
|
|
186
|
+
if (!isSameColumnProp(itemA[GROUP_COLUMN_PROP], prop)) {
|
|
187
|
+
return a - b;
|
|
24
188
|
}
|
|
25
189
|
}
|
|
26
190
|
if (isGrouping(itemB)) {
|
|
27
|
-
if (itemB[
|
|
28
|
-
return
|
|
191
|
+
if (!isSameColumnProp(itemB[GROUP_COLUMN_PROP], prop)) {
|
|
192
|
+
return a - b;
|
|
29
193
|
}
|
|
30
194
|
}
|
|
31
195
|
/**
|
|
@@ -45,13 +209,7 @@ export function defaultCellCompare(prop, a, b) {
|
|
|
45
209
|
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
46
210
|
const av = typeof aRaw === 'number' ? aRaw : aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
47
211
|
const bv = typeof bRaw === 'number' ? bRaw : bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
48
|
-
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
if (av > bv) {
|
|
52
|
-
return 1;
|
|
53
|
-
}
|
|
54
|
-
return -1;
|
|
212
|
+
return compareValues(av, bv);
|
|
55
213
|
}
|
|
56
214
|
export function descCellCompare(cmp) {
|
|
57
215
|
return (prop, a, b) => {
|