@revolist/revogrid 4.26.2 → 4.27.1
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-Cf2Pu4S0.js → cell-renderer-BDIx0xys.js} +3 -3
- package/dist/cjs/{column.service-C7p5eC5V.js → column.service-D-ENzqyb.js} +5 -3
- package/dist/cjs/{dimension.helpers-CgHhnN1d.js → dimension.helpers-CptesQOZ.js} +52 -8
- package/dist/cjs/{edit.utils-rAcGublN.js → edit.utils-CBAbQhGP.js} +1 -1
- package/dist/cjs/{header-cell-renderer-DHClfIto.js → header-cell-renderer-B5Y4fdZC.js} +1 -1
- package/dist/cjs/{index--FdNLz1Z.js → index-BVESmpqW.js} +1 -1
- package/dist/cjs/index.cjs.js +72 -55
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +131 -86
- package/dist/cjs/revo-grid.cjs.js +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +51 -19
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +4 -4
- package/dist/cjs/revogr-data_4.cjs.entry.js +21 -15
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +9 -9
- package/dist/cjs/{column.drag.plugin-CK5HADlW.js → row-resize.plugin-sK9_rcUN.js} +759 -86
- package/dist/cjs/{text-editor-F04kTx53.js → text-editor-CJyQaYei.js} +2 -2
- package/dist/cjs/{throttle-fV6BUmM7.js → throttle-BsaP4fgu.js} +3 -3
- package/dist/cjs/{viewport.store-B4Clk4m9.js → viewport.store-mhsdi61t.js} +1 -1
- package/dist/collection/components/data/revogr-data-style.css +11 -0
- package/dist/collection/components/data/revogr-data.js +14 -8
- package/dist/collection/components/header/revogr-header-style.css +1 -0
- package/dist/collection/components/overlay/keyboard.service.js +33 -3
- package/dist/collection/components/overlay/revogr-overlay-selection.js +12 -10
- package/dist/collection/components/revoGrid/plugin.service.js +2 -2
- package/dist/collection/components/revoGrid/revo-grid.js +80 -30
- package/dist/collection/components/revoGrid/viewport.scrolling.service.js +24 -13
- package/dist/collection/components/revoGrid/viewport.service.js +1 -1
- package/dist/collection/plugins/filter/filter.constants.js +9 -0
- package/dist/collection/plugins/filter/filter.panel.js +8 -8
- package/dist/collection/plugins/filter/filter.plugin.js +109 -10
- package/dist/collection/plugins/filter/filter.style.css +2 -0
- package/dist/collection/plugins/groupingRow/grouping.const.js +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +93 -56
- package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +1 -1
- package/dist/collection/plugins/groupingRow/grouping.service.js +1 -1
- package/dist/collection/plugins/groupingRow/grouping.sorting.service.js +58 -0
- package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +5 -3
- package/dist/collection/plugins/index.js +1 -0
- package/dist/collection/plugins/row-resize/index.js +6 -0
- package/dist/collection/plugins/row-resize/row-resize.plugin.js +416 -0
- package/dist/collection/plugins/row-resize/row-resize.types.js +1 -0
- package/dist/collection/plugins/row-resize/row-resize.utils.js +55 -0
- package/dist/collection/plugins/sorting/sorting.plugin.js +16 -13
- package/dist/collection/plugins/wcag/index.js +5 -4
- package/dist/collection/serve/controller.js +1 -1
- package/dist/collection/services/data.provider.js +8 -2
- package/dist/collection/services/dimension.provider.js +17 -1
- package/dist/collection/services/local.scroll.timer.js +3 -3
- package/dist/collection/services/selection.store.connector.js +4 -2
- package/dist/collection/store/dataSource/data.pending.plugin.js +21 -0
- package/dist/collection/store/dataSource/data.store.js +25 -3
- package/dist/collection/store/dataSource/trimmed.plugin.js +9 -6
- package/dist/collection/store/dimension/dimension.trim.plugin.js +1 -3
- package/dist/collection/types/events.js +4 -1
- package/dist/collection/utils/column.utils.js +1 -1
- package/dist/esm/{cell-renderer-11cf-lu3.js → cell-renderer-D9ze8OJw.js} +3 -3
- package/dist/esm/{column.service-Cfw3L0PN.js → column.service-pu_fdQ0S.js} +5 -4
- package/dist/{revo-grid/dimension.helpers-fl4HSSK9.js → esm/dimension.helpers-Cln9sALu.js} +52 -9
- package/dist/{revo-grid/edit.utils-4e9fsqOR.js → esm/edit.utils-3ZbhQCv_.js} +1 -1
- package/dist/esm/{header-cell-renderer-Cqtg1ETB.js → header-cell-renderer-YCiVIQ2E.js} +1 -1
- package/dist/esm/{index-D24ku9ej.js → index-BvMNbQyq.js} +1 -1
- package/dist/esm/index.js +14 -11
- package/dist/esm/loader.js +1 -1
- package/dist/esm/revo-grid.entry.js +113 -68
- package/dist/esm/revo-grid.js +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +51 -19
- package/dist/esm/revogr-clipboard_3.entry.js +4 -4
- package/dist/esm/revogr-data_4.entry.js +21 -15
- package/dist/esm/revogr-filter-panel.entry.js +9 -9
- package/dist/esm/{column.drag.plugin-DDBKeTGI.js → row-resize.plugin-DBOgjLdE.js} +748 -87
- package/dist/{revo-grid/text-editor-DlMnLkRK.js → esm/text-editor-eHtrwvxH.js} +2 -2
- package/dist/{revo-grid/throttle-Cpk1LoGk.js → esm/throttle-3rhqdcLy.js} +3 -3
- package/dist/{revo-grid/viewport.store-BSXmsiZc.js → esm/viewport.store-DWMKRDSH.js} +1 -1
- package/dist/revo-grid/{cell-renderer-11cf-lu3.js → cell-renderer-D9ze8OJw.js} +3 -3
- package/dist/revo-grid/{column.service-Cfw3L0PN.js → column.service-pu_fdQ0S.js} +5 -4
- package/dist/{esm/dimension.helpers-fl4HSSK9.js → revo-grid/dimension.helpers-Cln9sALu.js} +52 -9
- package/dist/{esm/edit.utils-4e9fsqOR.js → revo-grid/edit.utils-3ZbhQCv_.js} +1 -1
- package/dist/revo-grid/{header-cell-renderer-Cqtg1ETB.js → header-cell-renderer-YCiVIQ2E.js} +1 -1
- package/dist/revo-grid/{index-D24ku9ej.js → index-BvMNbQyq.js} +1 -1
- package/dist/revo-grid/index.esm.js +14 -11
- package/dist/revo-grid/revo-grid.entry.js +113 -68
- package/dist/revo-grid/revo-grid.esm.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +51 -19
- package/dist/revo-grid/revogr-clipboard_3.entry.js +4 -4
- package/dist/revo-grid/revogr-data_4.entry.js +21 -15
- package/dist/revo-grid/revogr-filter-panel.entry.js +9 -9
- package/dist/revo-grid/{column.drag.plugin-DDBKeTGI.js → row-resize.plugin-DBOgjLdE.js} +748 -87
- package/dist/{esm/text-editor-DlMnLkRK.js → revo-grid/text-editor-eHtrwvxH.js} +2 -2
- package/dist/{esm/throttle-Cpk1LoGk.js → revo-grid/throttle-3rhqdcLy.js} +3 -3
- package/dist/{esm/viewport.store-BSXmsiZc.js → revo-grid/viewport.store-DWMKRDSH.js} +1 -1
- package/dist/types/components/data/revogr-data.d.ts +1 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +6 -0
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +3 -1
- package/dist/types/components/revoGrid/revo-grid.d.ts +9 -1
- package/dist/types/components/revoGrid/viewport.scrolling.service.d.ts +3 -1
- package/dist/types/components.d.ts +23 -10
- package/dist/types/plugins/filter/filter.constants.d.ts +6 -0
- package/dist/types/plugins/filter/filter.plugin.d.ts +15 -0
- package/dist/types/plugins/groupingRow/grouping.const.d.ts +1 -0
- package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +5 -7
- package/dist/types/plugins/groupingRow/grouping.sorting.service.d.ts +7 -0
- package/dist/types/plugins/groupingRow/grouping.trimmed.service.d.ts +9 -0
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/row-resize/index.d.ts +3 -0
- package/dist/types/plugins/row-resize/row-resize.plugin.d.ts +46 -0
- package/dist/types/plugins/row-resize/row-resize.types.d.ts +40 -0
- package/dist/types/plugins/row-resize/row-resize.utils.d.ts +14 -0
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +5 -0
- package/dist/types/services/data.provider.d.ts +2 -0
- package/dist/types/services/dimension.provider.d.ts +7 -1
- package/dist/types/store/dataSource/data.pending.plugin.d.ts +9 -0
- package/dist/types/store/dataSource/data.store.d.ts +10 -0
- package/dist/types/store/dataSource/trimmed.plugin.d.ts +5 -0
- package/dist/types/types/events.d.ts +1 -1
- package/dist/types/types/interfaces.d.ts +3 -1
- package/hydrate/index.js +980 -191
- package/hydrate/index.mjs +980 -191
- package/package.json +1 -1
- package/readme.md +4 -1
- package/standalone/column.service.js +1 -1
- package/standalone/data.store.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-data2.js +1 -1
- package/standalone/revogr-filter-panel.js +1 -1
- package/standalone/revogr-header2.js +1 -1
- package/standalone/revogr-overlay-selection2.js +1 -1
- package/standalone/revogr-row-headers2.js +1 -1
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
var column_service = require('./column.service-
|
|
7
|
-
var dimension_helpers = require('./dimension.helpers-
|
|
8
|
-
var viewport_store = require('./viewport.store-
|
|
9
|
-
var index$1 = require('./index
|
|
6
|
+
var column_service = require('./column.service-D-ENzqyb.js');
|
|
7
|
+
var dimension_helpers = require('./dimension.helpers-CptesQOZ.js');
|
|
8
|
+
var viewport_store = require('./viewport.store-mhsdi61t.js');
|
|
9
|
+
var index$1 = require('./index-BVESmpqW.js');
|
|
10
10
|
var index = require('./index-DRvxCueo.js');
|
|
11
11
|
var filter_button = require('./filter.button-F2Bw3UAd.js');
|
|
12
12
|
var debounce = require('./debounce-CcpHiH2p.js');
|
|
13
|
-
var headerCellRenderer = require('./header-cell-renderer-
|
|
13
|
+
var headerCellRenderer = require('./header-cell-renderer-B5Y4fdZC.js');
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Public theme tokens and their CSS custom-property counterparts.
|
|
@@ -153,9 +153,7 @@ const trimmedPlugin = (storeService) => {
|
|
|
153
153
|
}
|
|
154
154
|
case 'trimmed': {
|
|
155
155
|
const trim = val;
|
|
156
|
-
|
|
157
|
-
trimmedPreviousSizes = storeService.store.get('sizes');
|
|
158
|
-
}
|
|
156
|
+
trimmedPreviousSizes !== null && trimmedPreviousSizes !== void 0 ? trimmedPreviousSizes : (trimmedPreviousSizes = storeService.store.get('sizes'));
|
|
159
157
|
trimmingObject = removeMultipleAndShift(trimmedPreviousSizes, trim || {});
|
|
160
158
|
// save a reference to the trimmed object to prevent changes after trimming
|
|
161
159
|
storeService.setSizes(trimmingObject);
|
|
@@ -1382,6 +1380,13 @@ const filterNames = {
|
|
|
1382
1380
|
lte: '<=',
|
|
1383
1381
|
};
|
|
1384
1382
|
|
|
1383
|
+
/** Fewer rows keep the existing synchronous filtering behavior. */
|
|
1384
|
+
const ASYNC_FILTER_ROW_THRESHOLD = 15000;
|
|
1385
|
+
/** Maximum rows evaluated in one filtering chunk. */
|
|
1386
|
+
const FILTER_CHUNK_SIZE = 1000;
|
|
1387
|
+
/** Yield after approximately this much accumulated filtering work. */
|
|
1388
|
+
const FILTER_TIME_BUDGET_MS = 5;
|
|
1389
|
+
|
|
1385
1390
|
// filter.plugin.tsx
|
|
1386
1391
|
const FILTER_TRIMMED_TYPE = 'filter';
|
|
1387
1392
|
const FILTER_CONFIG_CHANGED_EVENT = 'filterconfigchanged';
|
|
@@ -1426,6 +1431,7 @@ class FilterPlugin extends BasePlugin {
|
|
|
1426
1431
|
this.filterFunctionsIndexedByType = Object.assign({}, filterCoreFunctionsIndexedByType);
|
|
1427
1432
|
this.filterProp = filter_button.FILTER_PROP;
|
|
1428
1433
|
this.allowDuplicateOperators = true;
|
|
1434
|
+
this.filteringRunId = 0;
|
|
1429
1435
|
if (config) {
|
|
1430
1436
|
this.initConfig(config);
|
|
1431
1437
|
}
|
|
@@ -1434,7 +1440,7 @@ class FilterPlugin extends BasePlugin {
|
|
|
1434
1440
|
...existingNodes,
|
|
1435
1441
|
index.h("revogr-filter-panel", { filterNames: this.filterNameIndexByType, filterEntities: this.filterFunctionsIndexedByType, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), onResetChange: e => this.onFilterReset(e.detail), disableDynamicFiltering: config === null || config === void 0 ? void 0 : config.disableDynamicFiltering, closeOnOutsideClick: config === null || config === void 0 ? void 0 : config.closeFilterPanelOnOutsideClick, allowDuplicateOperators: this.allowDuplicateOperators, ref: e => (this.pop = e) }, ' ', this.extraContent()),
|
|
1436
1442
|
];
|
|
1437
|
-
const aftersourceset =
|
|
1443
|
+
const aftersourceset = () => {
|
|
1438
1444
|
const filterCollectionProps = Object.keys(this.filterCollection);
|
|
1439
1445
|
if (filterCollectionProps.length > 0) {
|
|
1440
1446
|
// handle old way of filtering by reworking FilterCollection to new MultiFilterItem
|
|
@@ -1451,12 +1457,26 @@ class FilterPlugin extends BasePlugin {
|
|
|
1451
1457
|
}
|
|
1452
1458
|
});
|
|
1453
1459
|
}
|
|
1454
|
-
if (
|
|
1460
|
+
if (!this.hasActiveFilters()) {
|
|
1461
|
+
this.cancelFiltering();
|
|
1455
1462
|
return;
|
|
1456
1463
|
}
|
|
1457
|
-
|
|
1458
|
-
await this.runFiltering(this.multiFilterItems);
|
|
1464
|
+
void this.runFiltering(this.multiFilterItems);
|
|
1459
1465
|
};
|
|
1466
|
+
/**
|
|
1467
|
+
* This executes before the data store replaces its source.
|
|
1468
|
+
* For a large source with active filters:
|
|
1469
|
+
* 1. Existing filtering runs are invalidated.
|
|
1470
|
+
* 2. Pending state starts.
|
|
1471
|
+
* 3. Visible rows become empty.
|
|
1472
|
+
* 4. The source is replaced while the DataStore guard prevents it from exposing unfiltered rows.
|
|
1473
|
+
*/
|
|
1474
|
+
this.addEventListener('beforesourceset', ({ detail }) => {
|
|
1475
|
+
if (detail.source.length >= ASYNC_FILTER_ROW_THRESHOLD &&
|
|
1476
|
+
this.hasActiveFilters()) {
|
|
1477
|
+
this.deferFiltering();
|
|
1478
|
+
}
|
|
1479
|
+
});
|
|
1460
1480
|
this.addEventListener('headerclick', e => this.headerclick(e));
|
|
1461
1481
|
this.addEventListener(FILTER_CONFIG_CHANGED_EVENT, ({ detail }) => {
|
|
1462
1482
|
if (!detail) {
|
|
@@ -1617,7 +1637,7 @@ class FilterPlugin extends BasePlugin {
|
|
|
1617
1637
|
// store the filter items
|
|
1618
1638
|
this.multiFilterItems = filterItems;
|
|
1619
1639
|
// run the filtering when the items change
|
|
1620
|
-
this.runFiltering(this.multiFilterItems);
|
|
1640
|
+
await this.runFiltering(this.multiFilterItems);
|
|
1621
1641
|
}
|
|
1622
1642
|
onFilterReset(prop) {
|
|
1623
1643
|
delete this.multiFilterItems[prop !== null && prop !== void 0 ? prop : ''];
|
|
@@ -1627,6 +1647,8 @@ class FilterPlugin extends BasePlugin {
|
|
|
1627
1647
|
* Triggers grid filtering
|
|
1628
1648
|
*/
|
|
1629
1649
|
async doFiltering(collection, source, columns, filterItems) {
|
|
1650
|
+
// creates the execution token - owns the actual calculation
|
|
1651
|
+
const runId = this.beginFiltering();
|
|
1630
1652
|
const columnsToUpdate = [];
|
|
1631
1653
|
/**
|
|
1632
1654
|
* Loop through the columns and update the columns that need to be updated with the `hasFilter` property.
|
|
@@ -1651,7 +1673,25 @@ class FilterPlugin extends BasePlugin {
|
|
|
1651
1673
|
column[this.filterProp] = true;
|
|
1652
1674
|
}
|
|
1653
1675
|
});
|
|
1654
|
-
|
|
1676
|
+
let itemsToTrim;
|
|
1677
|
+
const hasFilters = Object.keys(filterItems).length > 0 || this.hasActiveFilters();
|
|
1678
|
+
const isLargeSource = hasFilters && source.length >= ASYNC_FILTER_ROW_THRESHOLD;
|
|
1679
|
+
if (isLargeSource) {
|
|
1680
|
+
this.providers.data.setItemsPending(true);
|
|
1681
|
+
await index$1.timeout();
|
|
1682
|
+
}
|
|
1683
|
+
if (!hasFilters) {
|
|
1684
|
+
itemsToTrim = {};
|
|
1685
|
+
}
|
|
1686
|
+
else if (isLargeSource && this.supportsChunkedFiltering()) {
|
|
1687
|
+
itemsToTrim = await this.getRowFilterInChunks(source, filterItems, columnByProp, runId);
|
|
1688
|
+
}
|
|
1689
|
+
else {
|
|
1690
|
+
itemsToTrim = this.getRowFilter(source, filterItems, columnByProp);
|
|
1691
|
+
}
|
|
1692
|
+
if (!itemsToTrim || runId !== this.filteringRunId) {
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1655
1695
|
// check is filter event prevented
|
|
1656
1696
|
const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', {
|
|
1657
1697
|
collection,
|
|
@@ -1659,10 +1699,12 @@ class FilterPlugin extends BasePlugin {
|
|
|
1659
1699
|
source,
|
|
1660
1700
|
filterItems,
|
|
1661
1701
|
});
|
|
1662
|
-
if (defaultPrevented) {
|
|
1702
|
+
if (defaultPrevented || runId !== this.filteringRunId) {
|
|
1703
|
+
this.releaseFiltering(runId);
|
|
1663
1704
|
return;
|
|
1664
1705
|
}
|
|
1665
1706
|
this.providers.data.setTrimmed({ [FILTER_TRIMMED_TYPE]: detail.itemsToFilter });
|
|
1707
|
+
this.releaseFiltering(runId);
|
|
1666
1708
|
// applies the hasFilter to the columns to show filter icon
|
|
1667
1709
|
this.providers.column.updateColumns(columnsToUpdate);
|
|
1668
1710
|
this.emit('afterfilterapply', {
|
|
@@ -1676,6 +1718,10 @@ class FilterPlugin extends BasePlugin {
|
|
|
1676
1718
|
await this.runFiltering(this.multiFilterItems);
|
|
1677
1719
|
}
|
|
1678
1720
|
async runFiltering(multiFilterItems) {
|
|
1721
|
+
// runFiltering: First token: "Is this request still valid after event handlers run?"
|
|
1722
|
+
// doFiltering: Second token: "Is this calculation still the newest one?"
|
|
1723
|
+
// creates a preflight token and sets the grid to a pending state
|
|
1724
|
+
const runId = this.beginFiltering();
|
|
1679
1725
|
const collection = {};
|
|
1680
1726
|
// handle old filterCollection to return the first filter only (if any) from multiFilterItems
|
|
1681
1727
|
const filterProps = Object.keys(multiFilterItems);
|
|
@@ -1699,10 +1745,67 @@ class FilterPlugin extends BasePlugin {
|
|
|
1699
1745
|
columns,
|
|
1700
1746
|
filterItems: this.multiFilterItems,
|
|
1701
1747
|
});
|
|
1702
|
-
if (defaultPrevented) {
|
|
1748
|
+
if (defaultPrevented || runId !== this.filteringRunId) {
|
|
1749
|
+
this.releaseFiltering(runId);
|
|
1703
1750
|
return;
|
|
1704
1751
|
}
|
|
1705
|
-
this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
|
|
1752
|
+
await this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
|
|
1753
|
+
}
|
|
1754
|
+
/** Whether this plugin currently owns filter state that must follow a new source. */
|
|
1755
|
+
hasActiveFilters() {
|
|
1756
|
+
return (Object.keys(this.multiFilterItems).length > 0 ||
|
|
1757
|
+
Object.keys(this.filterCollection).length > 0);
|
|
1758
|
+
}
|
|
1759
|
+
/** Preserve whole-source semantics for plugins that override getRowFilter. */
|
|
1760
|
+
supportsChunkedFiltering() {
|
|
1761
|
+
return this.getRowFilter === FilterPlugin.prototype.getRowFilter;
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Hide visible rows and invalidate current filtering until a deferred filter
|
|
1765
|
+
* run is ready. Used by filter extensions with their own debounced state.
|
|
1766
|
+
*/
|
|
1767
|
+
deferFiltering() {
|
|
1768
|
+
this.beginFiltering(true);
|
|
1769
|
+
}
|
|
1770
|
+
beginFiltering(pending = false) {
|
|
1771
|
+
const runId = ++this.filteringRunId;
|
|
1772
|
+
if (pending) {
|
|
1773
|
+
this.providers.data.setItemsPending(true);
|
|
1774
|
+
}
|
|
1775
|
+
return runId;
|
|
1776
|
+
}
|
|
1777
|
+
releaseFiltering(runId) {
|
|
1778
|
+
if (runId === this.filteringRunId) {
|
|
1779
|
+
this.providers.data.setItemsPending(false);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
cancelFiltering() {
|
|
1783
|
+
this.releaseFiltering(this.beginFiltering());
|
|
1784
|
+
}
|
|
1785
|
+
async getRowFilterInChunks(rows, filterItems, columnByProp, runId) {
|
|
1786
|
+
const trimmed = {};
|
|
1787
|
+
let sliceStarted = performance.now();
|
|
1788
|
+
for (let offset = 0; offset < rows.length; offset += FILTER_CHUNK_SIZE) {
|
|
1789
|
+
if (runId !== this.filteringRunId) {
|
|
1790
|
+
return;
|
|
1791
|
+
}
|
|
1792
|
+
const end = Math.min(offset + FILTER_CHUNK_SIZE, rows.length);
|
|
1793
|
+
const chunkTrimmed = this.getRowFilter(rows.slice(offset, end), filterItems, columnByProp);
|
|
1794
|
+
// filter that chunk
|
|
1795
|
+
for (const chunkIndex in chunkTrimmed) {
|
|
1796
|
+
trimmed[offset + Number(chunkIndex)] = true;
|
|
1797
|
+
}
|
|
1798
|
+
if (end < rows.length &&
|
|
1799
|
+
performance.now() - sliceStarted >= FILTER_TIME_BUDGET_MS) {
|
|
1800
|
+
await index$1.timeout();
|
|
1801
|
+
sliceStarted = performance.now();
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return runId === this.filteringRunId ? trimmed : undefined;
|
|
1805
|
+
}
|
|
1806
|
+
destroy() {
|
|
1807
|
+
this.cancelFiltering();
|
|
1808
|
+
super.destroy();
|
|
1706
1809
|
}
|
|
1707
1810
|
/**
|
|
1708
1811
|
* Get trimmed rows based on filter
|
|
@@ -1806,6 +1909,60 @@ function allAndConditionsSatisfied(pendingResults) {
|
|
|
1806
1909
|
return !pendingResults.includes(true);
|
|
1807
1910
|
}
|
|
1808
1911
|
|
|
1912
|
+
/**
|
|
1913
|
+
* Restores group headers around already-sorted data indexes without rebuilding
|
|
1914
|
+
* the physical source. Group insertion order follows the first sorted member,
|
|
1915
|
+
* matching the order produced by regrouping a sorted source.
|
|
1916
|
+
*/
|
|
1917
|
+
function gatherGroupedRowIndexes(source, sortedDataIndexes) {
|
|
1918
|
+
const groupPathByDataIndex = new Map();
|
|
1919
|
+
const currentGroupPath = [];
|
|
1920
|
+
source.forEach((model, physicalIndex) => {
|
|
1921
|
+
if (column_service.isGrouping(model)) {
|
|
1922
|
+
const depth = model[column_service.GROUP_DEPTH];
|
|
1923
|
+
if (typeof depth !== 'number') {
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1926
|
+
currentGroupPath.length = depth;
|
|
1927
|
+
currentGroupPath[depth] = physicalIndex;
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
if (model != null) {
|
|
1931
|
+
groupPathByDataIndex.set(physicalIndex, [...currentGroupPath]);
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1934
|
+
const root = {
|
|
1935
|
+
children: new Map(),
|
|
1936
|
+
items: [],
|
|
1937
|
+
};
|
|
1938
|
+
for (const physicalIndex of sortedDataIndexes) {
|
|
1939
|
+
const groupPath = groupPathByDataIndex.get(physicalIndex);
|
|
1940
|
+
if (!(groupPath === null || groupPath === void 0 ? void 0 : groupPath.length)) {
|
|
1941
|
+
return undefined;
|
|
1942
|
+
}
|
|
1943
|
+
let node = root;
|
|
1944
|
+
for (const groupIndex of groupPath) {
|
|
1945
|
+
let child = node.children.get(groupIndex);
|
|
1946
|
+
if (!child) {
|
|
1947
|
+
child = { children: new Map(), items: [] };
|
|
1948
|
+
node.children.set(groupIndex, child);
|
|
1949
|
+
}
|
|
1950
|
+
node = child;
|
|
1951
|
+
}
|
|
1952
|
+
node.items.push(physicalIndex);
|
|
1953
|
+
}
|
|
1954
|
+
const groupedIndexes = [];
|
|
1955
|
+
const appendNode = (node) => {
|
|
1956
|
+
node.children.forEach((child, groupIndex) => {
|
|
1957
|
+
groupedIndexes.push(groupIndex);
|
|
1958
|
+
appendNode(child);
|
|
1959
|
+
});
|
|
1960
|
+
groupedIndexes.push(...node.items);
|
|
1961
|
+
};
|
|
1962
|
+
appendNode(root);
|
|
1963
|
+
return groupedIndexes;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1809
1966
|
/**
|
|
1810
1967
|
* Checks whether a sorting map contains at least one active order.
|
|
1811
1968
|
*
|
|
@@ -2043,18 +2200,6 @@ function getComparer(column, order) {
|
|
|
2043
2200
|
function getSortableRowIndexes(indexes, source) {
|
|
2044
2201
|
return indexes.filter(index => !column_service.isGrouping(source[index]));
|
|
2045
2202
|
}
|
|
2046
|
-
function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
|
|
2047
|
-
if (sortedRows.length === indexes.length) {
|
|
2048
|
-
return sortedRows;
|
|
2049
|
-
}
|
|
2050
|
-
let rowIndex = 0;
|
|
2051
|
-
return indexes.map(index => {
|
|
2052
|
-
if (column_service.isGrouping(source[index])) {
|
|
2053
|
-
return index;
|
|
2054
|
-
}
|
|
2055
|
-
return sortedRows[rowIndex++];
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
2203
|
/**
|
|
2059
2204
|
* Lifecycle
|
|
2060
2205
|
* 1. @event `beforesorting` - Triggered when sorting just starts. Nothing has happened yet. This can be triggered from a column or from the source. If the type is from rows, the column will be undefined.
|
|
@@ -2214,6 +2359,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
2214
2359
|
storeService.setData({ proxyItems: newItemsOrder });
|
|
2215
2360
|
}
|
|
2216
2361
|
applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
|
|
2362
|
+
var _a;
|
|
2217
2363
|
const storeService = this.providers.data.stores[type];
|
|
2218
2364
|
// row data
|
|
2219
2365
|
const source = storeService.store.get('source');
|
|
@@ -2221,7 +2367,10 @@ class SortingPlugin extends BasePlugin {
|
|
|
2221
2367
|
const proxyItems = storeService.store.get('proxyItems');
|
|
2222
2368
|
const sortItems = getSortableRowIndexes(proxyItems, source);
|
|
2223
2369
|
const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
|
|
2224
|
-
const
|
|
2370
|
+
const hasGroupingRows = sortedItems.length !== proxyItems.length;
|
|
2371
|
+
const newItemsOrder = hasGroupingRows
|
|
2372
|
+
? (_a = gatherGroupedRowIndexes(source, sortedItems)) !== null && _a !== void 0 ? _a : proxyItems
|
|
2373
|
+
: sortedItems;
|
|
2225
2374
|
// take row indexes before trim applied and proxy items
|
|
2226
2375
|
const prevItems = storeService.store.get('items');
|
|
2227
2376
|
storeService.setData({
|
|
@@ -2247,6 +2396,16 @@ class SortingPlugin extends BasePlugin {
|
|
|
2247
2396
|
}
|
|
2248
2397
|
this.postponeSort(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate);
|
|
2249
2398
|
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Schedules the current active sort again after another plugin rebuilds row
|
|
2401
|
+
* proxy indexes while keeping the physical source unchanged.
|
|
2402
|
+
*/
|
|
2403
|
+
reapplySorting() {
|
|
2404
|
+
if (!hasActiveSorting(this.sorting) || !this.sortingFunc) {
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
this.startSorting(this.sorting, this.sortingFunc, this.sortingColumns, this.sortingOrder);
|
|
2408
|
+
}
|
|
2250
2409
|
/**
|
|
2251
2410
|
* Applies sorting requested by a sortable header click.
|
|
2252
2411
|
*
|
|
@@ -2430,8 +2589,10 @@ const TRIMMED_GROUPING = 'grouping';
|
|
|
2430
2589
|
* against the grouped physical source can still be remapped. If neither path
|
|
2431
2590
|
* resolves to a number, the caller drops the stale trim entry.
|
|
2432
2591
|
*/
|
|
2433
|
-
function
|
|
2434
|
-
const sourceIndex =
|
|
2592
|
+
function convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap) {
|
|
2593
|
+
const sourceIndex = typeof initialIndex === 'number'
|
|
2594
|
+
? initialIndex
|
|
2595
|
+
: Number.parseInt(initialIndex, 10);
|
|
2435
2596
|
const firstConversionIndex = firstLevelMap[sourceIndex];
|
|
2436
2597
|
if (!secondLevelMap) {
|
|
2437
2598
|
return firstConversionIndex;
|
|
@@ -2464,7 +2625,7 @@ function processDoubleConversionTrimmed(initiallyTrimed, firstLevelMap, secondLe
|
|
|
2464
2625
|
* if item exists we find it in collection
|
|
2465
2626
|
* we support 2 level of conversions
|
|
2466
2627
|
*/
|
|
2467
|
-
const newConversionIndex =
|
|
2628
|
+
const newConversionIndex = convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap);
|
|
2468
2629
|
// Group rows do not exist in the ungrouped index map and must not leak into new trims.
|
|
2469
2630
|
if (typeof newConversionIndex !== 'number') {
|
|
2470
2631
|
continue;
|
|
@@ -2525,18 +2686,6 @@ function filterOutEmptyGroupRows(source, filterTrimmed) {
|
|
|
2525
2686
|
return trimmed;
|
|
2526
2687
|
}
|
|
2527
2688
|
|
|
2528
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
2529
|
-
var t = {};
|
|
2530
|
-
for (var p in s)
|
|
2531
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2532
|
-
t[p] = s[p];
|
|
2533
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2534
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2535
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2536
|
-
t[p[i]] = s[p[i]];
|
|
2537
|
-
}
|
|
2538
|
-
return t;
|
|
2539
|
-
};
|
|
2540
2689
|
class GroupingRowPlugin extends BasePlugin {
|
|
2541
2690
|
getStore(type = column_service.GROUPING_ROW_TYPE) {
|
|
2542
2691
|
return this.providers.data.stores[type].store;
|
|
@@ -2552,15 +2701,16 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2552
2701
|
}
|
|
2553
2702
|
// expand event triggered
|
|
2554
2703
|
onExpand({ virtualIndex }) {
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2557
|
-
let
|
|
2704
|
+
const store = this.getStore();
|
|
2705
|
+
const source = store.get('source');
|
|
2706
|
+
let newTrimmed = store.get('trimmed')[TRIMMED_GROUPING];
|
|
2707
|
+
const i = dimension_helpers.getPhysical(store, virtualIndex);
|
|
2558
2708
|
const isExpanded = column_service.getExpanded(source[i]);
|
|
2559
2709
|
if (!isExpanded) {
|
|
2560
|
-
const { trimmed, items } = doExpand(virtualIndex, source,
|
|
2710
|
+
const { trimmed, items: expandedItems } = doExpand(virtualIndex, source, store.get('items'));
|
|
2561
2711
|
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2562
|
-
if (
|
|
2563
|
-
dimension_helpers.setItems(
|
|
2712
|
+
if (expandedItems) {
|
|
2713
|
+
dimension_helpers.setItems(store, expandedItems);
|
|
2564
2714
|
}
|
|
2565
2715
|
}
|
|
2566
2716
|
else {
|
|
@@ -2568,7 +2718,7 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2568
2718
|
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2569
2719
|
this.revogrid.clearFocus();
|
|
2570
2720
|
}
|
|
2571
|
-
|
|
2721
|
+
store.set('source', source);
|
|
2572
2722
|
this.revogrid.addTrimmed(newTrimmed, TRIMMED_GROUPING);
|
|
2573
2723
|
}
|
|
2574
2724
|
setColumnGrouping(cols) {
|
|
@@ -2590,7 +2740,7 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2590
2740
|
onDrag(e) {
|
|
2591
2741
|
const { from, to } = e.detail;
|
|
2592
2742
|
const isDown = to - from >= 0;
|
|
2593
|
-
const
|
|
2743
|
+
const source = this.getStore().get('source');
|
|
2594
2744
|
const items = this.getStore().get('items');
|
|
2595
2745
|
let i = isDown ? from : to;
|
|
2596
2746
|
const end = isDown ? to : from;
|
|
@@ -2616,21 +2766,13 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2616
2766
|
const source = this.getStore().get('source');
|
|
2617
2767
|
return filterOutEmptyGroupRows(source, trimmed);
|
|
2618
2768
|
}
|
|
2619
|
-
isSortingRunning() {
|
|
2620
|
-
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2621
|
-
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
|
|
2622
|
-
}
|
|
2623
2769
|
/**
|
|
2624
|
-
*
|
|
2625
|
-
*
|
|
2626
|
-
*
|
|
2627
|
-
* Reusing them after sorting would reopen groups the user collapsed before
|
|
2628
|
-
* sorting instead of using the current grouped source state.
|
|
2770
|
+
* Sorting changes proxy order without changing the physical source baseline.
|
|
2771
|
+
* Other proxy changes, such as row dragging, are user-authored source order
|
|
2772
|
+
* and must be retained when grouping is rebuilt.
|
|
2629
2773
|
*/
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, options = __rest(_b, ["expandedAll", "prevExpanded"]);
|
|
2633
|
-
return options;
|
|
2774
|
+
isSortingActiveOrPending(sortingPlugin) {
|
|
2775
|
+
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise) || hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting);
|
|
2634
2776
|
}
|
|
2635
2777
|
/**
|
|
2636
2778
|
* Starts global source update with group clearing and applying new one
|
|
@@ -2643,7 +2785,12 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2643
2785
|
* @param newOldIndexMap - provides us mapping with new indexes vs old indexes, we would use it for trimmed mapping
|
|
2644
2786
|
*/
|
|
2645
2787
|
const store = this.getStore();
|
|
2646
|
-
const
|
|
2788
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2789
|
+
const currentSource = store.get('source');
|
|
2790
|
+
const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2791
|
+
? currentSource.map((_, index) => index)
|
|
2792
|
+
: store.get('proxyItems');
|
|
2793
|
+
const { source, prevExpanded, oldNewIndexes } = column_service.getSource(currentSource, sourceItems, true);
|
|
2647
2794
|
const expanded = Object.assign({ prevExpanded }, options);
|
|
2648
2795
|
/**
|
|
2649
2796
|
* Group again
|
|
@@ -2653,8 +2800,13 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2653
2800
|
const customRenderer = options === null || options === void 0 ? void 0 : options.groupLabelTemplate;
|
|
2654
2801
|
const cellRenderer = options === null || options === void 0 ? void 0 : options.groupCellTemplate;
|
|
2655
2802
|
// setup source
|
|
2803
|
+
this.revogrid.dispatchEvent(new CustomEvent(column_service.BEFORE_GROUPING_APPLY_EVENT));
|
|
2656
2804
|
this.providers.data.setData(sourceWithGroups, column_service.GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, { depth, customRenderer, cellRenderer }, true);
|
|
2805
|
+
this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups);
|
|
2657
2806
|
this.updateTrimmed(trimmed, oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, sourceWithGroups);
|
|
2807
|
+
if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
|
|
2808
|
+
sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
|
|
2809
|
+
}
|
|
2658
2810
|
}
|
|
2659
2811
|
/**
|
|
2660
2812
|
* Apply grouping on data set
|
|
@@ -2663,9 +2815,14 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2663
2815
|
*/
|
|
2664
2816
|
onDataSet(data) {
|
|
2665
2817
|
var _a, _b, _c;
|
|
2818
|
+
const currentSource = this.getStore().get('source');
|
|
2819
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2820
|
+
const currentItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2821
|
+
? currentSource.map((_, index) => index)
|
|
2822
|
+
: this.getStore().get('proxyItems');
|
|
2823
|
+
const { prevExpanded, oldNewIndexes } = column_service.getSource(currentSource, currentItems, true);
|
|
2666
2824
|
let preservedExpanded = {};
|
|
2667
2825
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.preserveGroupingOnUpdate) !== false) {
|
|
2668
|
-
let { prevExpanded } = column_service.getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
|
|
2669
2826
|
preservedExpanded = prevExpanded;
|
|
2670
2827
|
}
|
|
2671
2828
|
const source = data.source.filter(s => !column_service.isGrouping(s));
|
|
@@ -2677,7 +2834,8 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2677
2834
|
customRenderer: options.groupLabelTemplate,
|
|
2678
2835
|
cellRenderer: options.groupCellTemplate,
|
|
2679
2836
|
});
|
|
2680
|
-
this.
|
|
2837
|
+
queueMicrotask(() => this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups));
|
|
2838
|
+
this.updateTrimmed(trimmed, oldNewIndexMap, undefined, sourceWithGroups, { filterTrimmedMode: 'recompute-after-source-set' });
|
|
2681
2839
|
}
|
|
2682
2840
|
/**
|
|
2683
2841
|
* External call to apply grouping. Called by revogrid when prop changed.
|
|
@@ -2712,10 +2870,6 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2712
2870
|
if (!(((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length) && ((_c = detail === null || detail === void 0 ? void 0 : detail.source) === null || _c === void 0 ? void 0 : _c.length))) {
|
|
2713
2871
|
return;
|
|
2714
2872
|
}
|
|
2715
|
-
// if sorting is running don't apply grouping, wait for sorting, then it'll apply in @aftersortingapply
|
|
2716
|
-
if (this.isSortingRunning()) {
|
|
2717
|
-
return;
|
|
2718
|
-
}
|
|
2719
2873
|
this.onDataSet(detail);
|
|
2720
2874
|
});
|
|
2721
2875
|
this.addEventListener('beforecolumnsset', ({ detail }) => {
|
|
@@ -2730,17 +2884,6 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2730
2884
|
this.addEventListener('beforefiltertrimmed', ({ detail }) => {
|
|
2731
2885
|
detail.itemsToFilter = this.beforeFilterTrimmed(detail.itemsToFilter);
|
|
2732
2886
|
});
|
|
2733
|
-
/**
|
|
2734
|
-
* sorting applied need to clear grouping and apply again
|
|
2735
|
-
* based on new results whole grouping order will changed
|
|
2736
|
-
*/
|
|
2737
|
-
this.addEventListener('aftersortingapply', () => {
|
|
2738
|
-
var _a, _b;
|
|
2739
|
-
if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2740
|
-
return;
|
|
2741
|
-
}
|
|
2742
|
-
this.doSourceUpdate(this.getCurrentExpandedOptions());
|
|
2743
|
-
});
|
|
2744
2887
|
/**
|
|
2745
2888
|
* Apply logic for focus inside of grouping
|
|
2746
2889
|
* We can't focus on grouping rows, navigation only inside of groups for now
|
|
@@ -2773,14 +2916,69 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2773
2916
|
}
|
|
2774
2917
|
});
|
|
2775
2918
|
// clear rows
|
|
2776
|
-
const
|
|
2919
|
+
const store = this.getStore();
|
|
2920
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2921
|
+
const currentSource = store.get('source');
|
|
2922
|
+
const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2923
|
+
? currentSource.map((_, index) => index)
|
|
2924
|
+
: store.get('proxyItems');
|
|
2925
|
+
const { source, oldNewIndexes } = column_service.getSource(currentSource, sourceItems, true);
|
|
2926
|
+
this.revogrid.dispatchEvent(new CustomEvent(column_service.BEFORE_GROUPING_APPLY_EVENT));
|
|
2777
2927
|
this.providers.data.setData(source, column_service.GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, undefined, true);
|
|
2928
|
+
this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, undefined, currentSource, source);
|
|
2778
2929
|
this.updateTrimmed(undefined, undefined, oldNewIndexes, source);
|
|
2930
|
+
if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
|
|
2931
|
+
sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
|
|
2932
|
+
}
|
|
2779
2933
|
}
|
|
2780
|
-
|
|
2934
|
+
remapRowDefinitions(firstLevelMap, secondLevelMap, previousSource, nextSource) {
|
|
2935
|
+
const definitions = this.providers.dimension.getRowDefinitions();
|
|
2936
|
+
const nextGroupIndexes = new Map();
|
|
2937
|
+
nextSource === null || nextSource === void 0 ? void 0 : nextSource.forEach((row, index) => {
|
|
2938
|
+
const groupId = row[column_service.PSEUDO_GROUP_ITEM_ID];
|
|
2939
|
+
if (groupId && !nextGroupIndexes.has(groupId)) {
|
|
2940
|
+
nextGroupIndexes.set(groupId, index);
|
|
2941
|
+
}
|
|
2942
|
+
});
|
|
2943
|
+
let changed = false;
|
|
2944
|
+
const remapped = definitions.flatMap(definition => {
|
|
2945
|
+
if (definition.type !== column_service.GROUPING_ROW_TYPE) {
|
|
2946
|
+
return [definition];
|
|
2947
|
+
}
|
|
2948
|
+
const previousRow = previousSource === null || previousSource === void 0 ? void 0 : previousSource[definition.index];
|
|
2949
|
+
const groupId = previousRow === null || previousRow === void 0 ? void 0 : previousRow[column_service.PSEUDO_GROUP_ITEM_ID];
|
|
2950
|
+
const index = groupId
|
|
2951
|
+
? nextGroupIndexes.get(groupId)
|
|
2952
|
+
: convertGroupingIndex(definition.index, firstLevelMap, secondLevelMap);
|
|
2953
|
+
if (typeof index !== 'number') {
|
|
2954
|
+
changed = true;
|
|
2955
|
+
return [];
|
|
2956
|
+
}
|
|
2957
|
+
if (index < 0) {
|
|
2958
|
+
changed = true;
|
|
2959
|
+
return [];
|
|
2960
|
+
}
|
|
2961
|
+
if (index === definition.index) {
|
|
2962
|
+
return [definition];
|
|
2963
|
+
}
|
|
2964
|
+
changed = true;
|
|
2965
|
+
return [Object.assign(Object.assign({}, definition), { index })];
|
|
2966
|
+
});
|
|
2967
|
+
if (changed) {
|
|
2968
|
+
this.providers.dimension.setRowDefinitions(remapped);
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
updateTrimmed(trimmedGroup = {}, firstLevelMap = {}, secondLevelMap, source = this.getStore().get('source'), { filterTrimmedMode = 'remap', } = {}) {
|
|
2781
2972
|
// map previously trimmed data
|
|
2782
2973
|
const trimemedOptionsToUpgrade = processDoubleConversionTrimmed(this.getStore().get('trimmed'), firstLevelMap, secondLevelMap);
|
|
2783
2974
|
for (let type in trimemedOptionsToUpgrade) {
|
|
2975
|
+
if (filterTrimmedMode === 'recompute-after-source-set' &&
|
|
2976
|
+
type === FILTER_TRIMMED_TYPE) {
|
|
2977
|
+
// The filter plugin recalculates this trim against the installed source
|
|
2978
|
+
// during aftersourceset. Reapplying remapped old indexes afterwards
|
|
2979
|
+
// would overwrite that fresh result.
|
|
2980
|
+
continue;
|
|
2981
|
+
}
|
|
2784
2982
|
if (type === FILTER_TRIMMED_TYPE) {
|
|
2785
2983
|
/** Regrouping changes physical indexes, so filter trim needs fresh group-header state. */
|
|
2786
2984
|
trimemedOptionsToUpgrade[type] = filterOutEmptyGroupRows(source, trimemedOptionsToUpgrade[type]);
|
|
@@ -3050,14 +3248,480 @@ function getColumnDragPosition(targetItem, startItem, renderOffset, scrollOffset
|
|
|
3050
3248
|
return insertionEdge - renderOffset + scrollOffset;
|
|
3051
3249
|
}
|
|
3052
3250
|
|
|
3251
|
+
const DEFAULT_MIN_ROW_HEIGHT = 20;
|
|
3252
|
+
const finiteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
3253
|
+
function resolveRowResizeConfig(config = {}) {
|
|
3254
|
+
const minHeight = finiteNumber(config.minHeight)
|
|
3255
|
+
? Math.max(1, Math.round(config.minHeight))
|
|
3256
|
+
: DEFAULT_MIN_ROW_HEIGHT;
|
|
3257
|
+
const maxHeight = finiteNumber(config.maxHeight)
|
|
3258
|
+
? Math.max(minHeight, Math.round(config.maxHeight))
|
|
3259
|
+
: undefined;
|
|
3260
|
+
return { minHeight, maxHeight, fullRow: config.fullRow === true };
|
|
3261
|
+
}
|
|
3262
|
+
function clampRowResizeHeight(height, config) {
|
|
3263
|
+
var _a;
|
|
3264
|
+
const rounded = Number.isFinite(height)
|
|
3265
|
+
? Math.round(height)
|
|
3266
|
+
: config.minHeight;
|
|
3267
|
+
return Math.min(Math.max(rounded, config.minHeight), (_a = config.maxHeight) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY);
|
|
3268
|
+
}
|
|
3269
|
+
function getRowResizeIndexes({ rowType, rowIndex, rowCount, selectedRange, selectedRowType, }) {
|
|
3270
|
+
if (!selectedRange ||
|
|
3271
|
+
selectedRowType !== rowType ||
|
|
3272
|
+
rowIndex < Math.min(selectedRange.y, selectedRange.y1) ||
|
|
3273
|
+
rowIndex > Math.max(selectedRange.y, selectedRange.y1)) {
|
|
3274
|
+
return rowIndex >= 0 && rowIndex < rowCount ? [rowIndex] : [];
|
|
3275
|
+
}
|
|
3276
|
+
const start = Math.max(0, Math.min(selectedRange.y, selectedRange.y1));
|
|
3277
|
+
const end = Math.min(rowCount - 1, Math.max(selectedRange.y, selectedRange.y1));
|
|
3278
|
+
return Array.from({ length: Math.max(0, end - start + 1) }, (_, i) => start + i);
|
|
3279
|
+
}
|
|
3280
|
+
function createRowResizePatch(indexes, size) {
|
|
3281
|
+
return indexes.reduce((patch, index) => {
|
|
3282
|
+
patch[index] = size;
|
|
3283
|
+
return patch;
|
|
3284
|
+
}, {});
|
|
3285
|
+
}
|
|
3286
|
+
function mergeRowResizeDefinitions(definitions, rowType, physicalIndexes, size) {
|
|
3287
|
+
const targetIndexes = new Set(physicalIndexes);
|
|
3288
|
+
const existingIndexes = new Set();
|
|
3289
|
+
const merged = definitions.map(definition => {
|
|
3290
|
+
if (definition.type !== rowType || !targetIndexes.has(definition.index)) {
|
|
3291
|
+
return definition;
|
|
3292
|
+
}
|
|
3293
|
+
existingIndexes.add(definition.index);
|
|
3294
|
+
return Object.assign(Object.assign({}, definition), { size });
|
|
3295
|
+
});
|
|
3296
|
+
for (const index of targetIndexes) {
|
|
3297
|
+
if (!existingIndexes.has(index)) {
|
|
3298
|
+
merged.push({ type: rowType, index, size });
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
return merged;
|
|
3302
|
+
}
|
|
3303
|
+
|
|
3304
|
+
const ROW_RESIZE_HANDLE_CLASS = 'row-resize-handle';
|
|
3305
|
+
const BEFORE_ROW_RESIZE_EVENT = 'beforerowresize';
|
|
3306
|
+
const ROW_RESIZE_EVENT = 'rowresize';
|
|
3307
|
+
const AFTER_ROW_RESIZE_EVENT = 'afterrowresize';
|
|
3308
|
+
const ROW_RESIZE_CANCEL_EVENT = 'rowresizecancel';
|
|
3309
|
+
class RowResizePlugin extends BasePlugin {
|
|
3310
|
+
constructor(revogrid, providers, config = {}) {
|
|
3311
|
+
super(revogrid, providers);
|
|
3312
|
+
this.enabled = false;
|
|
3313
|
+
this.appliedDefinitionIndexes = new Map();
|
|
3314
|
+
this.pendingBottomAnchor = false;
|
|
3315
|
+
this.keepBottomAnchor = false;
|
|
3316
|
+
this.rowDefinitionRemapQueued = false;
|
|
3317
|
+
this.pendingSourceCounts = new Map();
|
|
3318
|
+
this.previousBodyCursor = '';
|
|
3319
|
+
this.decorateRow = ({ detail, }) => {
|
|
3320
|
+
if (!this.enabled ||
|
|
3321
|
+
(detail.colType !== 'rowHeaders' && !this.config.fullRow)) {
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3324
|
+
const handle = this.h('div', {
|
|
3325
|
+
'key': `row-resize-${detail.rowType}-${detail.item.itemIndex}`,
|
|
3326
|
+
'class': { [ROW_RESIZE_HANDLE_CLASS]: true },
|
|
3327
|
+
'data-row-resize-index': detail.item.itemIndex,
|
|
3328
|
+
'aria-hidden': 'true',
|
|
3329
|
+
'onPointerDown': (event) => this.startResize(event, detail.rowType, detail.item.itemIndex),
|
|
3330
|
+
});
|
|
3331
|
+
detail.node.$children$ = [...(detail.node.$children$ || []), handle];
|
|
3332
|
+
};
|
|
3333
|
+
this.cancelForDataChange = () => this.cancel('data-change');
|
|
3334
|
+
this.onPointerMove = (event) => {
|
|
3335
|
+
const active = this.active;
|
|
3336
|
+
if ((active === null || active === void 0 ? void 0 : active.pointerId) !== event.pointerId) {
|
|
3337
|
+
return;
|
|
3338
|
+
}
|
|
3339
|
+
event.preventDefault();
|
|
3340
|
+
active.lastEvent = event;
|
|
3341
|
+
this.pendingHeight = clampRowResizeHeight(active.startHeight + event.clientY - active.startY, this.config);
|
|
3342
|
+
if (this.animationFrame === undefined) {
|
|
3343
|
+
const view = this.revogrid.ownerDocument.defaultView;
|
|
3344
|
+
this.animationFrame = view === null || view === void 0 ? void 0 : view.requestAnimationFrame(() => {
|
|
3345
|
+
this.animationFrame = undefined;
|
|
3346
|
+
this.flushPendingResize();
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
};
|
|
3350
|
+
this.onPointerUp = (event) => {
|
|
3351
|
+
const active = this.active;
|
|
3352
|
+
if ((active === null || active === void 0 ? void 0 : active.pointerId) !== event.pointerId) {
|
|
3353
|
+
return;
|
|
3354
|
+
}
|
|
3355
|
+
event.preventDefault();
|
|
3356
|
+
active.lastEvent = event;
|
|
3357
|
+
this.pendingHeight = clampRowResizeHeight(active.startHeight + event.clientY - active.startY, this.config);
|
|
3358
|
+
this.flushPendingResize();
|
|
3359
|
+
if (this.active !== active) {
|
|
3360
|
+
return;
|
|
3361
|
+
}
|
|
3362
|
+
const detail = this.eventDetail(active, event, active.currentHeight);
|
|
3363
|
+
this.finishGesture();
|
|
3364
|
+
this.commitResize(active);
|
|
3365
|
+
this.emit(AFTER_ROW_RESIZE_EVENT, detail);
|
|
3366
|
+
};
|
|
3367
|
+
this.onPointerCancel = (event) => {
|
|
3368
|
+
var _a;
|
|
3369
|
+
if (((_a = this.active) === null || _a === void 0 ? void 0 : _a.pointerId) === event.pointerId) {
|
|
3370
|
+
this.active.lastEvent = event;
|
|
3371
|
+
this.cancel('pointercancel');
|
|
3372
|
+
}
|
|
3373
|
+
};
|
|
3374
|
+
this.onKeyDown = (event) => {
|
|
3375
|
+
if (event.key === 'Escape' && this.active) {
|
|
3376
|
+
event.preventDefault();
|
|
3377
|
+
this.cancel('escape');
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
this.onWindowBlur = () => this.cancel('blur');
|
|
3381
|
+
this.updateBottomAnchorState = ({ detail, }) => {
|
|
3382
|
+
if (detail.dimension !== 'rgRow') {
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
this.keepBottomAnchor = this.isMainViewportAtBottom(detail.coordinate);
|
|
3386
|
+
};
|
|
3387
|
+
this.applyPendingBottomAnchor = () => {
|
|
3388
|
+
if (!this.pendingBottomAnchor) {
|
|
3389
|
+
return;
|
|
3390
|
+
}
|
|
3391
|
+
this.pendingBottomAnchor = false;
|
|
3392
|
+
const dimension = this.providers.dimension.stores.rgRow.store;
|
|
3393
|
+
// Scroll surfaces have slightly different client sizes. Give the shared
|
|
3394
|
+
// scrolling service the content end and let each surface clamp to its own
|
|
3395
|
+
// exact bottom coordinate.
|
|
3396
|
+
void this.revogrid.scrollToCoordinate({ y: dimension.get('realSize') });
|
|
3397
|
+
};
|
|
3398
|
+
this.scheduleRowDefinitionRemap = () => {
|
|
3399
|
+
if (this.rowDefinitionRemapQueued) {
|
|
3400
|
+
return;
|
|
3401
|
+
}
|
|
3402
|
+
this.rowDefinitionRemapQueued = true;
|
|
3403
|
+
queueMicrotask(() => {
|
|
3404
|
+
if (!this.rowDefinitionRemapQueued) {
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
this.pruneRowDefinitions();
|
|
3408
|
+
this.reapplyRowDefinitionSizes();
|
|
3409
|
+
this.rowDefinitionRemapQueued = false;
|
|
3410
|
+
});
|
|
3411
|
+
};
|
|
3412
|
+
/** Map source-indexed row definitions back onto the current virtual order. */
|
|
3413
|
+
this.reapplyRowDefinitionSizes = () => {
|
|
3414
|
+
const rowDefinitions = this.providers.dimension.getRowDefinitions();
|
|
3415
|
+
for (const rowType of column_service.rowTypes) {
|
|
3416
|
+
const items = this.providers.data.stores[rowType].store.get('items');
|
|
3417
|
+
const definitions = new Map(rowDefinitions
|
|
3418
|
+
.filter(definition => definition.type === rowType)
|
|
3419
|
+
.map(definition => [definition.index, definition.size]));
|
|
3420
|
+
const appliedIndexes = this.appliedDefinitionIndexes.get(rowType);
|
|
3421
|
+
if (!definitions.size && !(appliedIndexes === null || appliedIndexes === void 0 ? void 0 : appliedIndexes.size)) {
|
|
3422
|
+
continue;
|
|
3423
|
+
}
|
|
3424
|
+
const dimension = this.providers.dimension.stores[rowType];
|
|
3425
|
+
const currentSizes = dimension.store.get('sizes');
|
|
3426
|
+
const sizes = Object.assign({}, currentSizes);
|
|
3427
|
+
for (const index of appliedIndexes || []) {
|
|
3428
|
+
delete sizes[index];
|
|
3429
|
+
}
|
|
3430
|
+
const indexes = new Set();
|
|
3431
|
+
items.forEach((physicalIndex, virtualIndex) => {
|
|
3432
|
+
const size = definitions.get(physicalIndex);
|
|
3433
|
+
if (size !== undefined) {
|
|
3434
|
+
sizes[virtualIndex] = size;
|
|
3435
|
+
indexes.add(virtualIndex);
|
|
3436
|
+
}
|
|
3437
|
+
});
|
|
3438
|
+
this.appliedDefinitionIndexes.set(rowType, indexes);
|
|
3439
|
+
const sizeKeys = Object.keys(sizes);
|
|
3440
|
+
if (sizeKeys.length !== Object.keys(currentSizes).length ||
|
|
3441
|
+
sizeKeys.some(index => sizes[index] !== currentSizes[index])) {
|
|
3442
|
+
this.providers.dimension.setCustomSizes(rowType, sizes);
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
};
|
|
3446
|
+
this.config = resolveRowResizeConfig(config);
|
|
3447
|
+
if (new.target !== RowResizePlugin) {
|
|
3448
|
+
this.enabled = true;
|
|
3449
|
+
this.registerEventListeners();
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
registerEventListeners() {
|
|
3453
|
+
this.addEventListener('beforerowrender', this.decorateRow);
|
|
3454
|
+
this.addEventListener('beforeanysource', () => {
|
|
3455
|
+
this.cancel('data-change');
|
|
3456
|
+
this.keepBottomAnchor = false;
|
|
3457
|
+
});
|
|
3458
|
+
this.addEventListener('afteranysource', ({ detail }) => {
|
|
3459
|
+
this.pendingSourceCounts.set(detail.type, detail.source.length);
|
|
3460
|
+
this.scheduleRowDefinitionRemap();
|
|
3461
|
+
});
|
|
3462
|
+
this.addEventListener('beforesourcesortingapply', this.cancelForDataChange);
|
|
3463
|
+
this.addEventListener('beforesortingapply', this.cancelForDataChange);
|
|
3464
|
+
this.addEventListener('sortingconfigchanged', this.cancelForDataChange);
|
|
3465
|
+
this.addEventListener(column_service.BEFORE_GROUPING_APPLY_EVENT, this.cancelForDataChange);
|
|
3466
|
+
this.addEventListener('aftersortingapply', this.scheduleRowDefinitionRemap);
|
|
3467
|
+
this.addEventListener('beforefilterapply', this.cancelForDataChange);
|
|
3468
|
+
this.addEventListener('afterfilterapply', this.scheduleRowDefinitionRemap);
|
|
3469
|
+
this.addEventListener('beforerowdefinition', () => {
|
|
3470
|
+
this.cancel('data-change');
|
|
3471
|
+
this.scheduleRowDefinitionRemap();
|
|
3472
|
+
});
|
|
3473
|
+
this.addEventListener('afterthemechanged', this.scheduleRowDefinitionRemap);
|
|
3474
|
+
this.addEventListener('aftertrimmed', this.scheduleRowDefinitionRemap);
|
|
3475
|
+
this.addEventListener('roworderchange', this.scheduleRowDefinitionRemap);
|
|
3476
|
+
this.addEventListener(column_service.GROUP_EXPAND_EVENT, () => {
|
|
3477
|
+
if (this.keepBottomAnchor) {
|
|
3478
|
+
this.pendingBottomAnchor = true;
|
|
3479
|
+
}
|
|
3480
|
+
this.scheduleRowDefinitionRemap();
|
|
3481
|
+
});
|
|
3482
|
+
this.addEventListener('aftergridrender', this.applyPendingBottomAnchor);
|
|
3483
|
+
this.addEventListener('viewportscroll', this.updateBottomAnchorState);
|
|
3484
|
+
this.addEventListener('rowheaderschanged', ({ detail }) => {
|
|
3485
|
+
if (!detail && !this.config.fullRow) {
|
|
3486
|
+
this.cancel('row-headers-hidden');
|
|
3487
|
+
}
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
syncGridConfig(refresh = true) {
|
|
3491
|
+
const { plugins = [], resizeRow } = this.revogrid;
|
|
3492
|
+
const isCorePlugin = this.constructor === RowResizePlugin;
|
|
3493
|
+
const hasConfiguredPlugin = plugins.some(plugin => plugin !== RowResizePlugin &&
|
|
3494
|
+
plugin.prototype instanceof RowResizePlugin);
|
|
3495
|
+
const enabled = !isCorePlugin ||
|
|
3496
|
+
(!hasConfiguredPlugin && !!resizeRow);
|
|
3497
|
+
const resizeConfig = typeof resizeRow === 'object' ? resizeRow : undefined;
|
|
3498
|
+
const config = isCorePlugin
|
|
3499
|
+
? resolveRowResizeConfig(resizeConfig)
|
|
3500
|
+
: this.config;
|
|
3501
|
+
const configChanged = config.minHeight !== this.config.minHeight ||
|
|
3502
|
+
config.maxHeight !== this.config.maxHeight ||
|
|
3503
|
+
config.fullRow !== this.config.fullRow;
|
|
3504
|
+
if (enabled === this.enabled && !configChanged) {
|
|
3505
|
+
return;
|
|
3506
|
+
}
|
|
3507
|
+
this.cancel('config-change');
|
|
3508
|
+
this.config = config;
|
|
3509
|
+
if (enabled !== this.enabled) {
|
|
3510
|
+
this.enabled = enabled;
|
|
3511
|
+
if (enabled) {
|
|
3512
|
+
this.registerEventListeners();
|
|
3513
|
+
}
|
|
3514
|
+
else {
|
|
3515
|
+
this.pendingBottomAnchor = false;
|
|
3516
|
+
this.keepBottomAnchor = false;
|
|
3517
|
+
this.rowDefinitionRemapQueued = false;
|
|
3518
|
+
this.pendingSourceCounts.clear();
|
|
3519
|
+
this.clearSubscriptions();
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
if (refresh) {
|
|
3523
|
+
queueMicrotask(() => void this.revogrid.refresh());
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
startResize(event, rowType, index) {
|
|
3527
|
+
var _a, _b;
|
|
3528
|
+
if (!this.enabled ||
|
|
3529
|
+
this.active ||
|
|
3530
|
+
event.defaultPrevented ||
|
|
3531
|
+
!event.isPrimary ||
|
|
3532
|
+
(event.pointerType !== 'touch' && event.button !== 0)) {
|
|
3533
|
+
return;
|
|
3534
|
+
}
|
|
3535
|
+
const dimension = this.providers.dimension.stores[rowType];
|
|
3536
|
+
const dimensionState = dimension.getCurrentState();
|
|
3537
|
+
const viewport = this.providers.viewport.stores[rowType];
|
|
3538
|
+
const item = dimension_helpers.getItemByIndex(dimensionState, index);
|
|
3539
|
+
const focusedStore = this.providers.selection.focusedStore;
|
|
3540
|
+
const selectedRowType = focusedStore
|
|
3541
|
+
? this.providers.selection.storesYToType[focusedStore.position.y]
|
|
3542
|
+
: undefined;
|
|
3543
|
+
const indexes = getRowResizeIndexes({
|
|
3544
|
+
rowType,
|
|
3545
|
+
rowIndex: index,
|
|
3546
|
+
rowCount: dimensionState.count,
|
|
3547
|
+
selectedRange: this.providers.selection.selectedRange,
|
|
3548
|
+
selectedRowType,
|
|
3549
|
+
});
|
|
3550
|
+
if (!indexes.length) {
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
const previousSizes = indexes.reduce((sizes, rowIndex) => {
|
|
3554
|
+
const row = dimension_helpers.getItemByIndex(dimensionState, rowIndex);
|
|
3555
|
+
sizes[rowIndex] = row.end - row.start;
|
|
3556
|
+
return sizes;
|
|
3557
|
+
}, {});
|
|
3558
|
+
const startHeight = item.end - item.start;
|
|
3559
|
+
const active = {
|
|
3560
|
+
pointerId: event.pointerId,
|
|
3561
|
+
rowType,
|
|
3562
|
+
index,
|
|
3563
|
+
indexes,
|
|
3564
|
+
startY: event.clientY,
|
|
3565
|
+
startHeight,
|
|
3566
|
+
currentHeight: startHeight,
|
|
3567
|
+
previousSizes,
|
|
3568
|
+
originalCustomSizes: Object.assign({}, dimensionState.sizes),
|
|
3569
|
+
bottomAnchored: rowType === 'rgRow' &&
|
|
3570
|
+
this.isMainViewportAtBottom(viewport.lastCoordinate),
|
|
3571
|
+
lastEvent: event,
|
|
3572
|
+
};
|
|
3573
|
+
this.active = active;
|
|
3574
|
+
const beforeEvent = this.emit(BEFORE_ROW_RESIZE_EVENT, this.eventDetail(active, event, startHeight));
|
|
3575
|
+
if (beforeEvent.defaultPrevented) {
|
|
3576
|
+
if (this.active === active) {
|
|
3577
|
+
this.active = undefined;
|
|
3578
|
+
}
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
if (!this.enabled || this.active !== active) {
|
|
3582
|
+
return;
|
|
3583
|
+
}
|
|
3584
|
+
event.preventDefault();
|
|
3585
|
+
event.stopPropagation();
|
|
3586
|
+
const doc = this.revogrid.ownerDocument;
|
|
3587
|
+
this.previousBodyCursor = ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.style.cursor) || '';
|
|
3588
|
+
if (doc.body) {
|
|
3589
|
+
doc.body.style.cursor = 'row-resize';
|
|
3590
|
+
}
|
|
3591
|
+
doc.addEventListener('pointermove', this.onPointerMove, true);
|
|
3592
|
+
doc.addEventListener('pointerup', this.onPointerUp, true);
|
|
3593
|
+
doc.addEventListener('pointercancel', this.onPointerCancel, true);
|
|
3594
|
+
doc.addEventListener('keydown', this.onKeyDown, true);
|
|
3595
|
+
(_b = doc.defaultView) === null || _b === void 0 ? void 0 : _b.addEventListener('blur', this.onWindowBlur);
|
|
3596
|
+
}
|
|
3597
|
+
flushPendingResize() {
|
|
3598
|
+
const active = this.active;
|
|
3599
|
+
if (!active || this.pendingHeight === undefined) {
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
const size = this.pendingHeight;
|
|
3603
|
+
this.pendingHeight = undefined;
|
|
3604
|
+
if (size === active.currentHeight) {
|
|
3605
|
+
return;
|
|
3606
|
+
}
|
|
3607
|
+
this.providers.dimension.setCustomSizes(active.rowType, createRowResizePatch(active.indexes, size), true);
|
|
3608
|
+
this.requestBottomAnchor(active);
|
|
3609
|
+
active.currentHeight = size;
|
|
3610
|
+
this.emit(ROW_RESIZE_EVENT, this.eventDetail(active, active.lastEvent, size));
|
|
3611
|
+
}
|
|
3612
|
+
cancel(reason) {
|
|
3613
|
+
const active = this.active;
|
|
3614
|
+
if (!active) {
|
|
3615
|
+
return;
|
|
3616
|
+
}
|
|
3617
|
+
const currentSizes = Object.assign({}, this.providers.dimension.stores[active.rowType].store.get('sizes'));
|
|
3618
|
+
for (const index of active.indexes) {
|
|
3619
|
+
if (Object.hasOwn(active.originalCustomSizes, index)) {
|
|
3620
|
+
currentSizes[index] = active.originalCustomSizes[index];
|
|
3621
|
+
}
|
|
3622
|
+
else {
|
|
3623
|
+
delete currentSizes[index];
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
this.providers.dimension.setCustomSizes(active.rowType, currentSizes);
|
|
3627
|
+
this.requestBottomAnchor(active);
|
|
3628
|
+
const detail = Object.assign(Object.assign({}, this.eventDetail(active, active.lastEvent, active.startHeight)), { reason });
|
|
3629
|
+
this.finishGesture();
|
|
3630
|
+
this.emit(ROW_RESIZE_CANCEL_EVENT, detail);
|
|
3631
|
+
}
|
|
3632
|
+
eventDetail(active, originalEvent, size) {
|
|
3633
|
+
return {
|
|
3634
|
+
rowType: active.rowType,
|
|
3635
|
+
index: active.index,
|
|
3636
|
+
indexes: [...active.indexes],
|
|
3637
|
+
size,
|
|
3638
|
+
previousSizes: Object.assign({}, active.previousSizes),
|
|
3639
|
+
originalEvent,
|
|
3640
|
+
};
|
|
3641
|
+
}
|
|
3642
|
+
commitResize(active) {
|
|
3643
|
+
if (active.currentHeight === active.startHeight) {
|
|
3644
|
+
return;
|
|
3645
|
+
}
|
|
3646
|
+
const items = this.providers.data.stores[active.rowType].store.get('items');
|
|
3647
|
+
const physicalIndexes = active.indexes.reduce((result, index) => {
|
|
3648
|
+
const physicalIndex = items[index];
|
|
3649
|
+
if (physicalIndex !== undefined) {
|
|
3650
|
+
result.push(physicalIndex);
|
|
3651
|
+
}
|
|
3652
|
+
return result;
|
|
3653
|
+
}, []);
|
|
3654
|
+
if (physicalIndexes.length) {
|
|
3655
|
+
const rowDefinitions = mergeRowResizeDefinitions(this.providers.dimension.getRowDefinitions(), active.rowType, physicalIndexes, active.currentHeight);
|
|
3656
|
+
this.providers.dimension.setRowDefinitions(rowDefinitions);
|
|
3657
|
+
this.scheduleRowDefinitionRemap();
|
|
3658
|
+
this.keepBottomAnchor = active.bottomAnchored;
|
|
3659
|
+
this.requestBottomAnchor(active);
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
requestBottomAnchor(active) {
|
|
3663
|
+
if (active.bottomAnchored) {
|
|
3664
|
+
this.pendingBottomAnchor = true;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
isMainViewportAtBottom(coordinate) {
|
|
3668
|
+
const dimension = this.providers.dimension.stores.rgRow.getCurrentState();
|
|
3669
|
+
const viewport = this.providers.viewport.stores.rgRow.store.state;
|
|
3670
|
+
return (dimension.realSize > viewport.clientSize &&
|
|
3671
|
+
coordinate >= viewport_store.getViewportMaxCoordinate(dimension, viewport.virtualSize));
|
|
3672
|
+
}
|
|
3673
|
+
pruneRowDefinitions() {
|
|
3674
|
+
if (!this.pendingSourceCounts.size) {
|
|
3675
|
+
return;
|
|
3676
|
+
}
|
|
3677
|
+
const definitions = this.providers.dimension.getRowDefinitions();
|
|
3678
|
+
const rowDefinitions = definitions.filter(definition => {
|
|
3679
|
+
const count = this.pendingSourceCounts.get(definition.type);
|
|
3680
|
+
return count === undefined || definition.index < count;
|
|
3681
|
+
});
|
|
3682
|
+
this.pendingSourceCounts.clear();
|
|
3683
|
+
if (rowDefinitions.length !== definitions.length) {
|
|
3684
|
+
this.providers.dimension.setRowDefinitions(rowDefinitions);
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
finishGesture() {
|
|
3688
|
+
const doc = this.revogrid.ownerDocument;
|
|
3689
|
+
const view = doc.defaultView;
|
|
3690
|
+
if (this.animationFrame !== undefined) {
|
|
3691
|
+
view === null || view === void 0 ? void 0 : view.cancelAnimationFrame(this.animationFrame);
|
|
3692
|
+
}
|
|
3693
|
+
doc.removeEventListener('pointermove', this.onPointerMove, true);
|
|
3694
|
+
doc.removeEventListener('pointerup', this.onPointerUp, true);
|
|
3695
|
+
doc.removeEventListener('pointercancel', this.onPointerCancel, true);
|
|
3696
|
+
doc.removeEventListener('keydown', this.onKeyDown, true);
|
|
3697
|
+
view === null || view === void 0 ? void 0 : view.removeEventListener('blur', this.onWindowBlur);
|
|
3698
|
+
if (doc.body) {
|
|
3699
|
+
doc.body.style.cursor = this.previousBodyCursor;
|
|
3700
|
+
}
|
|
3701
|
+
this.animationFrame = undefined;
|
|
3702
|
+
this.pendingHeight = undefined;
|
|
3703
|
+
this.active = undefined;
|
|
3704
|
+
}
|
|
3705
|
+
destroy() {
|
|
3706
|
+
this.cancel('destroy');
|
|
3707
|
+
this.keepBottomAnchor = false;
|
|
3708
|
+
this.rowDefinitionRemapQueued = false;
|
|
3709
|
+
this.pendingSourceCounts.clear();
|
|
3710
|
+
super.destroy();
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
|
|
3714
|
+
exports.AFTER_ROW_RESIZE_EVENT = AFTER_ROW_RESIZE_EVENT;
|
|
3053
3715
|
exports.AutoSizeColumnPlugin = AutoSizeColumnPlugin;
|
|
3054
3716
|
exports.BEFORE_COLUMN_DRAG_END_EVENT = BEFORE_COLUMN_DRAG_END_EVENT;
|
|
3717
|
+
exports.BEFORE_ROW_RESIZE_EVENT = BEFORE_ROW_RESIZE_EVENT;
|
|
3055
3718
|
exports.BasePlugin = BasePlugin;
|
|
3056
3719
|
exports.COLUMN_DRAG_END_EVENT = COLUMN_DRAG_END_EVENT;
|
|
3057
3720
|
exports.COLUMN_DRAG_MOVE_EVENT = COLUMN_DRAG_MOVE_EVENT;
|
|
3058
3721
|
exports.COLUMN_DRAG_START_EVENT = COLUMN_DRAG_START_EVENT;
|
|
3059
3722
|
exports.ColumnMovePlugin = ColumnMovePlugin;
|
|
3060
3723
|
exports.DEFAULT_BLANK_SEMANTICS = DEFAULT_BLANK_SEMANTICS;
|
|
3724
|
+
exports.DEFAULT_MIN_ROW_HEIGHT = DEFAULT_MIN_ROW_HEIGHT;
|
|
3061
3725
|
exports.DimensionStore = DimensionStore;
|
|
3062
3726
|
exports.ExportCsv = ExportCsv;
|
|
3063
3727
|
exports.ExportFilePlugin = ExportFilePlugin;
|
|
@@ -3066,9 +3730,15 @@ exports.FILTER_TRIMMED_TYPE = FILTER_TRIMMED_TYPE;
|
|
|
3066
3730
|
exports.FILTE_PANEL = FILTE_PANEL;
|
|
3067
3731
|
exports.FilterPlugin = FilterPlugin;
|
|
3068
3732
|
exports.GroupingRowPlugin = GroupingRowPlugin;
|
|
3733
|
+
exports.ROW_RESIZE_CANCEL_EVENT = ROW_RESIZE_CANCEL_EVENT;
|
|
3734
|
+
exports.ROW_RESIZE_EVENT = ROW_RESIZE_EVENT;
|
|
3735
|
+
exports.ROW_RESIZE_HANDLE_CLASS = ROW_RESIZE_HANDLE_CLASS;
|
|
3736
|
+
exports.RowResizePlugin = RowResizePlugin;
|
|
3069
3737
|
exports.SelectionStore = SelectionStore;
|
|
3070
3738
|
exports.SortingPlugin = SortingPlugin;
|
|
3071
3739
|
exports.StretchColumn = StretchColumn;
|
|
3740
|
+
exports.clampRowResizeHeight = clampRowResizeHeight;
|
|
3741
|
+
exports.createRowResizePatch = createRowResizePatch;
|
|
3072
3742
|
exports.defaultCellCompare = defaultCellCompare;
|
|
3073
3743
|
exports.defineTheme = defineTheme;
|
|
3074
3744
|
exports.descCellCompare = descCellCompare;
|
|
@@ -3081,10 +3751,13 @@ exports.getColumnDragPosition = getColumnDragPosition;
|
|
|
3081
3751
|
exports.getComparer = getComparer;
|
|
3082
3752
|
exports.getLeftRelative = getLeftRelative;
|
|
3083
3753
|
exports.getNextOrder = getNextOrder;
|
|
3754
|
+
exports.getRowResizeIndexes = getRowResizeIndexes;
|
|
3084
3755
|
exports.getSortingIndex = getSortingIndex;
|
|
3085
3756
|
exports.hasActiveSorting = hasActiveSorting;
|
|
3086
3757
|
exports.isBlankValue = isBlankValue;
|
|
3087
3758
|
exports.isStretchPlugin = isStretchPlugin;
|
|
3759
|
+
exports.mergeRowResizeDefinitions = mergeRowResizeDefinitions;
|
|
3088
3760
|
exports.resolveBlankSemantics = resolveBlankSemantics;
|
|
3761
|
+
exports.resolveRowResizeConfig = resolveRowResizeConfig;
|
|
3089
3762
|
exports.sortIndexByItems = sortIndexByItems;
|
|
3090
3763
|
exports.themeTokenCssVariables = themeTokenCssVariables;
|