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