@revolist/revogrid 4.27.0 → 4.27.2
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-C7rdgaov.js → cell-renderer-BDIx0xys.js} +1 -1
- package/dist/cjs/{column.service-Bbml5C2j.js → column.service-D-ENzqyb.js} +2 -0
- package/dist/cjs/{filter.button-F2Bw3UAd.js → filter.button-C6ixuMmr.js} +3 -2
- package/dist/cjs/{header-cell-renderer-BljFI6wj.js → header-cell-renderer-B5Y4fdZC.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +63 -43
- package/dist/cjs/revo-grid.cjs.js +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +12 -11
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +139 -33
- package/dist/cjs/{row-resize.plugin-BRQy_qNn.js → row-resize.plugin-C4YOF1lN.js} +353 -185
- package/dist/collection/components/header/header-renderer.js +7 -6
- package/dist/collection/components/header/revogr-header-style.css +8 -3
- package/dist/collection/components/revoGrid/revo-grid-style.css +12 -2
- package/dist/collection/components/revoGrid/revo-grid.js +37 -21
- package/dist/collection/plugins/filter/filter.button.js +3 -2
- package/dist/collection/plugins/filter/filter.indexed.js +5 -0
- package/dist/collection/plugins/filter/filter.panel.js +138 -31
- package/dist/collection/plugins/filter/filter.plugin.js +48 -5
- package/dist/collection/plugins/filter/filter.style.css +25 -3
- package/dist/collection/plugins/groupingRow/grouping.const.js +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +84 -54
- 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/row-resize/row-resize.plugin.js +144 -113
- package/dist/collection/plugins/sorting/sorting.plugin.js +16 -13
- package/dist/collection/plugins/wcag/index.js +5 -4
- package/dist/collection/services/dimension.provider.js +17 -1
- package/dist/esm/{cell-renderer-BFpmdV8H.js → cell-renderer-D9ze8OJw.js} +1 -1
- package/dist/esm/{column.service-CM-wgGs8.js → column.service-pu_fdQ0S.js} +2 -1
- package/dist/esm/{filter.button-DMhpuAiw.js → filter.button-CEPUxLUo.js} +3 -2
- package/dist/{revo-grid/header-cell-renderer-Bqh1PrgH.js → esm/header-cell-renderer-YCiVIQ2E.js} +1 -1
- package/dist/esm/index.js +6 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/revo-grid.entry.js +63 -43
- package/dist/esm/revo-grid.js +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +1 -1
- package/dist/esm/revogr-data_4.entry.js +12 -11
- package/dist/esm/revogr-filter-panel.entry.js +139 -33
- package/dist/esm/{row-resize.plugin-BRiaHlHA.js → row-resize.plugin-Beu0pMds.js} +354 -187
- package/dist/revo-grid/{cell-renderer-BFpmdV8H.js → cell-renderer-D9ze8OJw.js} +1 -1
- package/dist/revo-grid/{column.service-CM-wgGs8.js → column.service-pu_fdQ0S.js} +2 -1
- package/dist/revo-grid/{filter.button-DMhpuAiw.js → filter.button-CEPUxLUo.js} +3 -2
- package/dist/{esm/header-cell-renderer-Bqh1PrgH.js → revo-grid/header-cell-renderer-YCiVIQ2E.js} +1 -1
- package/dist/revo-grid/index.esm.js +6 -6
- package/dist/revo-grid/revo-grid.entry.js +63 -43
- package/dist/revo-grid/revo-grid.esm.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +12 -11
- package/dist/revo-grid/revogr-filter-panel.entry.js +139 -33
- package/dist/revo-grid/{row-resize.plugin-BRiaHlHA.js → row-resize.plugin-Beu0pMds.js} +354 -187
- package/dist/types/components/revoGrid/revo-grid.d.ts +2 -0
- package/dist/types/plugins/filter/filter.indexed.d.ts +2 -0
- package/dist/types/plugins/filter/filter.panel.d.ts +9 -2
- package/dist/types/plugins/filter/filter.plugin.d.ts +8 -1
- package/dist/types/plugins/filter/filter.types.d.ts +8 -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/row-resize/row-resize.plugin.d.ts +14 -12
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +5 -0
- package/dist/types/services/dimension.provider.d.ts +7 -1
- package/dist/types/types/interfaces.d.ts +13 -1
- package/hydrate/index.js +561 -264
- package/hydrate/index.mjs +561 -264
- package/package.json +1 -1
- package/standalone/column.service.js +1 -1
- package/standalone/filter.button.js +1 -1
- package/standalone/index.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
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
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
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 } from './viewport.store-DWMKRDSH.js';
|
|
6
|
+
import { j as calculateRowHeaderSize, g as getViewportMaxCoordinate } from './viewport.store-DWMKRDSH.js';
|
|
7
7
|
import { g as getScrollbarSize, t as timeout } from './index-BvMNbQyq.js';
|
|
8
8
|
import { h } from './index-CtimkLsB.js';
|
|
9
|
-
import { b as FILTER_PROP, i as isFilterBtn } from './filter.button-
|
|
9
|
+
import { b as FILTER_PROP, i as isFilterBtn } from './filter.button-CEPUxLUo.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.
|
|
@@ -1361,6 +1361,11 @@ const filterTypes = {
|
|
|
1361
1361
|
boolean: ['notEmpty', 'empty'],
|
|
1362
1362
|
array: ['notEmpty', 'empty'],
|
|
1363
1363
|
};
|
|
1364
|
+
/** Preferred initial operator for built-in filter families. */
|
|
1365
|
+
const filterTypeDefaults = {
|
|
1366
|
+
string: 'contains',
|
|
1367
|
+
number: 'eqN',
|
|
1368
|
+
};
|
|
1364
1369
|
const filterNames = {
|
|
1365
1370
|
none: 'None',
|
|
1366
1371
|
empty: 'Is blank',
|
|
@@ -1403,6 +1408,8 @@ const FILTE_PANEL = 'revogr-filter-panel';
|
|
|
1403
1408
|
*
|
|
1404
1409
|
* @property {FilterLocalization|undefined} localization - translation for filter popup captions.
|
|
1405
1410
|
*
|
|
1411
|
+
* @property {boolean|undefined} defaultFilter - creates a draft condition when an empty filter panel opens. Defaults to true.
|
|
1412
|
+
*
|
|
1406
1413
|
* @property {boolean|undefined} disableDynamicFiltering - disables dynamic filtering. A way to apply filters on Save only.
|
|
1407
1414
|
*/
|
|
1408
1415
|
/**
|
|
@@ -1424,7 +1431,7 @@ class FilterPlugin extends BasePlugin {
|
|
|
1424
1431
|
* number: ['eqN', 'neqN', 'gt']
|
|
1425
1432
|
* }
|
|
1426
1433
|
*/
|
|
1427
|
-
this.filterByType = Object.
|
|
1434
|
+
this.filterByType = Object.fromEntries(Object.entries(filterTypes).map(([type, filters]) => [type, [...filters]]));
|
|
1428
1435
|
this.filterNameIndexByType = Object.assign({}, filterNames);
|
|
1429
1436
|
this.filterFunctionsIndexedByType = Object.assign({}, filterCoreFunctionsIndexedByType);
|
|
1430
1437
|
this.filterProp = FILTER_PROP;
|
|
@@ -1508,11 +1515,16 @@ class FilterPlugin extends BasePlugin {
|
|
|
1508
1515
|
return null;
|
|
1509
1516
|
}
|
|
1510
1517
|
initConfig(config) {
|
|
1511
|
-
var _a;
|
|
1518
|
+
var _a, _b, _c, _d;
|
|
1512
1519
|
this.config = config;
|
|
1513
1520
|
this.allowDuplicateOperators = (_a = config.allowDuplicateOperators) !== null && _a !== void 0 ? _a : true;
|
|
1514
1521
|
if (this.pop) {
|
|
1515
1522
|
this.pop.allowDuplicateOperators = this.allowDuplicateOperators;
|
|
1523
|
+
this.pop.disableDynamicFiltering =
|
|
1524
|
+
(_b = config.disableDynamicFiltering) !== null && _b !== void 0 ? _b : false;
|
|
1525
|
+
this.pop.closeOnOutsideClick =
|
|
1526
|
+
(_c = config.closeFilterPanelOnOutsideClick) !== null && _c !== void 0 ? _c : true;
|
|
1527
|
+
this.pop.filterCaptions = (_d = config.localization) === null || _d === void 0 ? void 0 : _d.captions;
|
|
1516
1528
|
}
|
|
1517
1529
|
if (config.multiFilterItems) {
|
|
1518
1530
|
this.multiFilterItems = Object.assign({}, config.multiFilterItems);
|
|
@@ -1601,11 +1613,12 @@ class FilterPlugin extends BasePlugin {
|
|
|
1601
1613
|
}
|
|
1602
1614
|
// filter button clicked, open filter dialog
|
|
1603
1615
|
const buttonPos = (filterButton instanceof HTMLElement ? filterButton : el).getBoundingClientRect();
|
|
1604
|
-
const data = Object.assign(Object.assign(Object.assign({}, e.detail), this.filterCollection[prop]), { x: buttonPos.x, y: buttonPos.y + buttonPos.height, anchorY: buttonPos.y, autoCorrect: true, filterTypes: this.getColumnFilter(e.detail.filter), filterItems: this.multiFilterItems, extraContent: this.extraHyperContent, extraBottomContent: this.extraBottomHyperContent });
|
|
1616
|
+
const data = Object.assign(Object.assign(Object.assign({}, e.detail), this.filterCollection[prop]), { x: buttonPos.x, y: buttonPos.y + buttonPos.height, anchorY: buttonPos.y, autoCorrect: true, filterTypes: this.getColumnFilter(e.detail.filter), defaultFilterType: this.getDefaultFilter(e.detail.filter), showDefaultFilter: this.shouldShowDefaultFilter(e.detail.filter), filterItems: this.multiFilterItems, extraContent: this.extraHyperContent, extraBottomContent: this.extraBottomHyperContent });
|
|
1605
1617
|
(_b = this.beforeshow) === null || _b === void 0 ? void 0 : _b.call(this, data);
|
|
1606
1618
|
this.pop.show(data);
|
|
1607
1619
|
}
|
|
1608
|
-
getColumnFilter(
|
|
1620
|
+
getColumnFilter(config) {
|
|
1621
|
+
const type = this.isColumnFilterOption(config) ? config.type : config;
|
|
1609
1622
|
let filterType = 'string';
|
|
1610
1623
|
if (!type) {
|
|
1611
1624
|
return { [filterType]: this.filterByType[filterType] };
|
|
@@ -1625,6 +1638,41 @@ class FilterPlugin extends BasePlugin {
|
|
|
1625
1638
|
}
|
|
1626
1639
|
return { [filterType]: this.filterByType[filterType] };
|
|
1627
1640
|
}
|
|
1641
|
+
/** Resolve the preferred operator against the column's available filters. */
|
|
1642
|
+
getDefaultFilter(config) {
|
|
1643
|
+
var _a;
|
|
1644
|
+
const filters = this.getColumnFilter(config);
|
|
1645
|
+
const availableFilters = Object.values(filters).flat();
|
|
1646
|
+
const columnDefault = this.isColumnFilterOption(config)
|
|
1647
|
+
? config.default
|
|
1648
|
+
: undefined;
|
|
1649
|
+
if (typeof columnDefault === 'string' &&
|
|
1650
|
+
availableFilters.includes(columnDefault)) {
|
|
1651
|
+
return columnDefault;
|
|
1652
|
+
}
|
|
1653
|
+
const firstFamily = Object.keys(filters)[0];
|
|
1654
|
+
const familyDefault = filterTypeDefaults[firstFamily];
|
|
1655
|
+
if (familyDefault && ((_a = filters[firstFamily]) === null || _a === void 0 ? void 0 : _a.includes(familyDefault))) {
|
|
1656
|
+
return familyDefault;
|
|
1657
|
+
}
|
|
1658
|
+
return availableFilters[0];
|
|
1659
|
+
}
|
|
1660
|
+
/** Resolve grid and column-level draft opt-outs. */
|
|
1661
|
+
shouldShowDefaultFilter(config) {
|
|
1662
|
+
var _a;
|
|
1663
|
+
if (this.isColumnFilterOption(config)) {
|
|
1664
|
+
if (config.default === false) {
|
|
1665
|
+
return false;
|
|
1666
|
+
}
|
|
1667
|
+
if (typeof config.default === 'string') {
|
|
1668
|
+
return true;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
return ((_a = this.config) === null || _a === void 0 ? void 0 : _a.defaultFilter) !== false;
|
|
1672
|
+
}
|
|
1673
|
+
isColumnFilterOption(value) {
|
|
1674
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
1675
|
+
}
|
|
1628
1676
|
isValidType(type) {
|
|
1629
1677
|
return !!(typeof type === 'string' && this.filterByType[type]);
|
|
1630
1678
|
}
|
|
@@ -1907,6 +1955,60 @@ function allAndConditionsSatisfied(pendingResults) {
|
|
|
1907
1955
|
return !pendingResults.includes(true);
|
|
1908
1956
|
}
|
|
1909
1957
|
|
|
1958
|
+
/**
|
|
1959
|
+
* Restores group headers around already-sorted data indexes without rebuilding
|
|
1960
|
+
* the physical source. Group insertion order follows the first sorted member,
|
|
1961
|
+
* matching the order produced by regrouping a sorted source.
|
|
1962
|
+
*/
|
|
1963
|
+
function gatherGroupedRowIndexes(source, sortedDataIndexes) {
|
|
1964
|
+
const groupPathByDataIndex = new Map();
|
|
1965
|
+
const currentGroupPath = [];
|
|
1966
|
+
source.forEach((model, physicalIndex) => {
|
|
1967
|
+
if (isGrouping(model)) {
|
|
1968
|
+
const depth = model[GROUP_DEPTH];
|
|
1969
|
+
if (typeof depth !== 'number') {
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
currentGroupPath.length = depth;
|
|
1973
|
+
currentGroupPath[depth] = physicalIndex;
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
if (model != null) {
|
|
1977
|
+
groupPathByDataIndex.set(physicalIndex, [...currentGroupPath]);
|
|
1978
|
+
}
|
|
1979
|
+
});
|
|
1980
|
+
const root = {
|
|
1981
|
+
children: new Map(),
|
|
1982
|
+
items: [],
|
|
1983
|
+
};
|
|
1984
|
+
for (const physicalIndex of sortedDataIndexes) {
|
|
1985
|
+
const groupPath = groupPathByDataIndex.get(physicalIndex);
|
|
1986
|
+
if (!(groupPath === null || groupPath === void 0 ? void 0 : groupPath.length)) {
|
|
1987
|
+
return undefined;
|
|
1988
|
+
}
|
|
1989
|
+
let node = root;
|
|
1990
|
+
for (const groupIndex of groupPath) {
|
|
1991
|
+
let child = node.children.get(groupIndex);
|
|
1992
|
+
if (!child) {
|
|
1993
|
+
child = { children: new Map(), items: [] };
|
|
1994
|
+
node.children.set(groupIndex, child);
|
|
1995
|
+
}
|
|
1996
|
+
node = child;
|
|
1997
|
+
}
|
|
1998
|
+
node.items.push(physicalIndex);
|
|
1999
|
+
}
|
|
2000
|
+
const groupedIndexes = [];
|
|
2001
|
+
const appendNode = (node) => {
|
|
2002
|
+
node.children.forEach((child, groupIndex) => {
|
|
2003
|
+
groupedIndexes.push(groupIndex);
|
|
2004
|
+
appendNode(child);
|
|
2005
|
+
});
|
|
2006
|
+
groupedIndexes.push(...node.items);
|
|
2007
|
+
};
|
|
2008
|
+
appendNode(root);
|
|
2009
|
+
return groupedIndexes;
|
|
2010
|
+
}
|
|
2011
|
+
|
|
1910
2012
|
/**
|
|
1911
2013
|
* Checks whether a sorting map contains at least one active order.
|
|
1912
2014
|
*
|
|
@@ -2144,18 +2246,6 @@ function getComparer(column, order) {
|
|
|
2144
2246
|
function getSortableRowIndexes(indexes, source) {
|
|
2145
2247
|
return indexes.filter(index => !isGrouping(source[index]));
|
|
2146
2248
|
}
|
|
2147
|
-
function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
|
|
2148
|
-
if (sortedRows.length === indexes.length) {
|
|
2149
|
-
return sortedRows;
|
|
2150
|
-
}
|
|
2151
|
-
let rowIndex = 0;
|
|
2152
|
-
return indexes.map(index => {
|
|
2153
|
-
if (isGrouping(source[index])) {
|
|
2154
|
-
return index;
|
|
2155
|
-
}
|
|
2156
|
-
return sortedRows[rowIndex++];
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
2249
|
/**
|
|
2160
2250
|
* Lifecycle
|
|
2161
2251
|
* 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.
|
|
@@ -2315,6 +2405,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
2315
2405
|
storeService.setData({ proxyItems: newItemsOrder });
|
|
2316
2406
|
}
|
|
2317
2407
|
applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
|
|
2408
|
+
var _a;
|
|
2318
2409
|
const storeService = this.providers.data.stores[type];
|
|
2319
2410
|
// row data
|
|
2320
2411
|
const source = storeService.store.get('source');
|
|
@@ -2322,7 +2413,10 @@ class SortingPlugin extends BasePlugin {
|
|
|
2322
2413
|
const proxyItems = storeService.store.get('proxyItems');
|
|
2323
2414
|
const sortItems = getSortableRowIndexes(proxyItems, source);
|
|
2324
2415
|
const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
|
|
2325
|
-
const
|
|
2416
|
+
const hasGroupingRows = sortedItems.length !== proxyItems.length;
|
|
2417
|
+
const newItemsOrder = hasGroupingRows
|
|
2418
|
+
? (_a = gatherGroupedRowIndexes(source, sortedItems)) !== null && _a !== void 0 ? _a : proxyItems
|
|
2419
|
+
: sortedItems;
|
|
2326
2420
|
// take row indexes before trim applied and proxy items
|
|
2327
2421
|
const prevItems = storeService.store.get('items');
|
|
2328
2422
|
storeService.setData({
|
|
@@ -2348,6 +2442,16 @@ class SortingPlugin extends BasePlugin {
|
|
|
2348
2442
|
}
|
|
2349
2443
|
this.postponeSort(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate);
|
|
2350
2444
|
}
|
|
2445
|
+
/**
|
|
2446
|
+
* Schedules the current active sort again after another plugin rebuilds row
|
|
2447
|
+
* proxy indexes while keeping the physical source unchanged.
|
|
2448
|
+
*/
|
|
2449
|
+
reapplySorting() {
|
|
2450
|
+
if (!hasActiveSorting(this.sorting) || !this.sortingFunc) {
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
this.startSorting(this.sorting, this.sortingFunc, this.sortingColumns, this.sortingOrder);
|
|
2454
|
+
}
|
|
2351
2455
|
/**
|
|
2352
2456
|
* Applies sorting requested by a sortable header click.
|
|
2353
2457
|
*
|
|
@@ -2531,8 +2635,10 @@ const TRIMMED_GROUPING = 'grouping';
|
|
|
2531
2635
|
* against the grouped physical source can still be remapped. If neither path
|
|
2532
2636
|
* resolves to a number, the caller drops the stale trim entry.
|
|
2533
2637
|
*/
|
|
2534
|
-
function
|
|
2535
|
-
const sourceIndex =
|
|
2638
|
+
function convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap) {
|
|
2639
|
+
const sourceIndex = typeof initialIndex === 'number'
|
|
2640
|
+
? initialIndex
|
|
2641
|
+
: Number.parseInt(initialIndex, 10);
|
|
2536
2642
|
const firstConversionIndex = firstLevelMap[sourceIndex];
|
|
2537
2643
|
if (!secondLevelMap) {
|
|
2538
2644
|
return firstConversionIndex;
|
|
@@ -2565,7 +2671,7 @@ function processDoubleConversionTrimmed(initiallyTrimed, firstLevelMap, secondLe
|
|
|
2565
2671
|
* if item exists we find it in collection
|
|
2566
2672
|
* we support 2 level of conversions
|
|
2567
2673
|
*/
|
|
2568
|
-
const newConversionIndex =
|
|
2674
|
+
const newConversionIndex = convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap);
|
|
2569
2675
|
// Group rows do not exist in the ungrouped index map and must not leak into new trims.
|
|
2570
2676
|
if (typeof newConversionIndex !== 'number') {
|
|
2571
2677
|
continue;
|
|
@@ -2626,18 +2732,6 @@ function filterOutEmptyGroupRows(source, filterTrimmed) {
|
|
|
2626
2732
|
return trimmed;
|
|
2627
2733
|
}
|
|
2628
2734
|
|
|
2629
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
2630
|
-
var t = {};
|
|
2631
|
-
for (var p in s)
|
|
2632
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2633
|
-
t[p] = s[p];
|
|
2634
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2635
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2636
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2637
|
-
t[p[i]] = s[p[i]];
|
|
2638
|
-
}
|
|
2639
|
-
return t;
|
|
2640
|
-
};
|
|
2641
2735
|
class GroupingRowPlugin extends BasePlugin {
|
|
2642
2736
|
getStore(type = GROUPING_ROW_TYPE) {
|
|
2643
2737
|
return this.providers.data.stores[type].store;
|
|
@@ -2653,15 +2747,16 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2653
2747
|
}
|
|
2654
2748
|
// expand event triggered
|
|
2655
2749
|
onExpand({ virtualIndex }) {
|
|
2656
|
-
const
|
|
2657
|
-
|
|
2658
|
-
let
|
|
2750
|
+
const store = this.getStore();
|
|
2751
|
+
const source = store.get('source');
|
|
2752
|
+
let newTrimmed = store.get('trimmed')[TRIMMED_GROUPING];
|
|
2753
|
+
const i = getPhysical(store, virtualIndex);
|
|
2659
2754
|
const isExpanded = getExpanded(source[i]);
|
|
2660
2755
|
if (!isExpanded) {
|
|
2661
|
-
const { trimmed, items } = doExpand(virtualIndex, source,
|
|
2756
|
+
const { trimmed, items: expandedItems } = doExpand(virtualIndex, source, store.get('items'));
|
|
2662
2757
|
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2663
|
-
if (
|
|
2664
|
-
setItems(
|
|
2758
|
+
if (expandedItems) {
|
|
2759
|
+
setItems(store, expandedItems);
|
|
2665
2760
|
}
|
|
2666
2761
|
}
|
|
2667
2762
|
else {
|
|
@@ -2669,7 +2764,7 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2669
2764
|
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2670
2765
|
this.revogrid.clearFocus();
|
|
2671
2766
|
}
|
|
2672
|
-
|
|
2767
|
+
store.set('source', source);
|
|
2673
2768
|
this.revogrid.addTrimmed(newTrimmed, TRIMMED_GROUPING);
|
|
2674
2769
|
}
|
|
2675
2770
|
setColumnGrouping(cols) {
|
|
@@ -2691,7 +2786,7 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2691
2786
|
onDrag(e) {
|
|
2692
2787
|
const { from, to } = e.detail;
|
|
2693
2788
|
const isDown = to - from >= 0;
|
|
2694
|
-
const
|
|
2789
|
+
const source = this.getStore().get('source');
|
|
2695
2790
|
const items = this.getStore().get('items');
|
|
2696
2791
|
let i = isDown ? from : to;
|
|
2697
2792
|
const end = isDown ? to : from;
|
|
@@ -2717,21 +2812,13 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2717
2812
|
const source = this.getStore().get('source');
|
|
2718
2813
|
return filterOutEmptyGroupRows(source, trimmed);
|
|
2719
2814
|
}
|
|
2720
|
-
isSortingRunning() {
|
|
2721
|
-
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2722
|
-
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
|
|
2723
|
-
}
|
|
2724
2815
|
/**
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2727
|
-
*
|
|
2728
|
-
* Reusing them after sorting would reopen groups the user collapsed before
|
|
2729
|
-
* sorting instead of using the current grouped source state.
|
|
2816
|
+
* Sorting changes proxy order without changing the physical source baseline.
|
|
2817
|
+
* Other proxy changes, such as row dragging, are user-authored source order
|
|
2818
|
+
* and must be retained when grouping is rebuilt.
|
|
2730
2819
|
*/
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, options = __rest(_b, ["expandedAll", "prevExpanded"]);
|
|
2734
|
-
return options;
|
|
2820
|
+
isSortingActiveOrPending(sortingPlugin) {
|
|
2821
|
+
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise) || hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting);
|
|
2735
2822
|
}
|
|
2736
2823
|
/**
|
|
2737
2824
|
* Starts global source update with group clearing and applying new one
|
|
@@ -2744,7 +2831,12 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2744
2831
|
* @param newOldIndexMap - provides us mapping with new indexes vs old indexes, we would use it for trimmed mapping
|
|
2745
2832
|
*/
|
|
2746
2833
|
const store = this.getStore();
|
|
2747
|
-
const
|
|
2834
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2835
|
+
const currentSource = store.get('source');
|
|
2836
|
+
const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2837
|
+
? currentSource.map((_, index) => index)
|
|
2838
|
+
: store.get('proxyItems');
|
|
2839
|
+
const { source, prevExpanded, oldNewIndexes } = getSource(currentSource, sourceItems, true);
|
|
2748
2840
|
const expanded = Object.assign({ prevExpanded }, options);
|
|
2749
2841
|
/**
|
|
2750
2842
|
* Group again
|
|
@@ -2754,8 +2846,13 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2754
2846
|
const customRenderer = options === null || options === void 0 ? void 0 : options.groupLabelTemplate;
|
|
2755
2847
|
const cellRenderer = options === null || options === void 0 ? void 0 : options.groupCellTemplate;
|
|
2756
2848
|
// setup source
|
|
2849
|
+
this.revogrid.dispatchEvent(new CustomEvent(BEFORE_GROUPING_APPLY_EVENT));
|
|
2757
2850
|
this.providers.data.setData(sourceWithGroups, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, { depth, customRenderer, cellRenderer }, true);
|
|
2851
|
+
this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups);
|
|
2758
2852
|
this.updateTrimmed(trimmed, oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, sourceWithGroups);
|
|
2853
|
+
if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
|
|
2854
|
+
sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
|
|
2855
|
+
}
|
|
2759
2856
|
}
|
|
2760
2857
|
/**
|
|
2761
2858
|
* Apply grouping on data set
|
|
@@ -2764,9 +2861,14 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2764
2861
|
*/
|
|
2765
2862
|
onDataSet(data) {
|
|
2766
2863
|
var _a, _b, _c;
|
|
2864
|
+
const currentSource = this.getStore().get('source');
|
|
2865
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2866
|
+
const currentItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2867
|
+
? currentSource.map((_, index) => index)
|
|
2868
|
+
: this.getStore().get('proxyItems');
|
|
2869
|
+
const { prevExpanded, oldNewIndexes } = getSource(currentSource, currentItems, true);
|
|
2767
2870
|
let preservedExpanded = {};
|
|
2768
2871
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.preserveGroupingOnUpdate) !== false) {
|
|
2769
|
-
let { prevExpanded } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
|
|
2770
2872
|
preservedExpanded = prevExpanded;
|
|
2771
2873
|
}
|
|
2772
2874
|
const source = data.source.filter(s => !isGrouping(s));
|
|
@@ -2778,6 +2880,7 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2778
2880
|
customRenderer: options.groupLabelTemplate,
|
|
2779
2881
|
cellRenderer: options.groupCellTemplate,
|
|
2780
2882
|
});
|
|
2883
|
+
queueMicrotask(() => this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups));
|
|
2781
2884
|
this.updateTrimmed(trimmed, oldNewIndexMap, undefined, sourceWithGroups, { filterTrimmedMode: 'recompute-after-source-set' });
|
|
2782
2885
|
}
|
|
2783
2886
|
/**
|
|
@@ -2813,10 +2916,6 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2813
2916
|
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))) {
|
|
2814
2917
|
return;
|
|
2815
2918
|
}
|
|
2816
|
-
// if sorting is running don't apply grouping, wait for sorting, then it'll apply in @aftersortingapply
|
|
2817
|
-
if (this.isSortingRunning()) {
|
|
2818
|
-
return;
|
|
2819
|
-
}
|
|
2820
2919
|
this.onDataSet(detail);
|
|
2821
2920
|
});
|
|
2822
2921
|
this.addEventListener('beforecolumnsset', ({ detail }) => {
|
|
@@ -2831,17 +2930,6 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2831
2930
|
this.addEventListener('beforefiltertrimmed', ({ detail }) => {
|
|
2832
2931
|
detail.itemsToFilter = this.beforeFilterTrimmed(detail.itemsToFilter);
|
|
2833
2932
|
});
|
|
2834
|
-
/**
|
|
2835
|
-
* sorting applied need to clear grouping and apply again
|
|
2836
|
-
* based on new results whole grouping order will changed
|
|
2837
|
-
*/
|
|
2838
|
-
this.addEventListener('aftersortingapply', () => {
|
|
2839
|
-
var _a, _b;
|
|
2840
|
-
if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2841
|
-
return;
|
|
2842
|
-
}
|
|
2843
|
-
this.doSourceUpdate(this.getCurrentExpandedOptions());
|
|
2844
|
-
});
|
|
2845
2933
|
/**
|
|
2846
2934
|
* Apply logic for focus inside of grouping
|
|
2847
2935
|
* We can't focus on grouping rows, navigation only inside of groups for now
|
|
@@ -2874,9 +2962,57 @@ class GroupingRowPlugin extends BasePlugin {
|
|
|
2874
2962
|
}
|
|
2875
2963
|
});
|
|
2876
2964
|
// clear rows
|
|
2877
|
-
const
|
|
2965
|
+
const store = this.getStore();
|
|
2966
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2967
|
+
const currentSource = store.get('source');
|
|
2968
|
+
const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
|
|
2969
|
+
? currentSource.map((_, index) => index)
|
|
2970
|
+
: store.get('proxyItems');
|
|
2971
|
+
const { source, oldNewIndexes } = getSource(currentSource, sourceItems, true);
|
|
2972
|
+
this.revogrid.dispatchEvent(new CustomEvent(BEFORE_GROUPING_APPLY_EVENT));
|
|
2878
2973
|
this.providers.data.setData(source, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, undefined, true);
|
|
2974
|
+
this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, undefined, currentSource, source);
|
|
2879
2975
|
this.updateTrimmed(undefined, undefined, oldNewIndexes, source);
|
|
2976
|
+
if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
|
|
2977
|
+
sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
remapRowDefinitions(firstLevelMap, secondLevelMap, previousSource, nextSource) {
|
|
2981
|
+
const definitions = this.providers.dimension.getRowDefinitions();
|
|
2982
|
+
const nextGroupIndexes = new Map();
|
|
2983
|
+
nextSource === null || nextSource === void 0 ? void 0 : nextSource.forEach((row, index) => {
|
|
2984
|
+
const groupId = row[PSEUDO_GROUP_ITEM_ID];
|
|
2985
|
+
if (groupId && !nextGroupIndexes.has(groupId)) {
|
|
2986
|
+
nextGroupIndexes.set(groupId, index);
|
|
2987
|
+
}
|
|
2988
|
+
});
|
|
2989
|
+
let changed = false;
|
|
2990
|
+
const remapped = definitions.flatMap(definition => {
|
|
2991
|
+
if (definition.type !== GROUPING_ROW_TYPE) {
|
|
2992
|
+
return [definition];
|
|
2993
|
+
}
|
|
2994
|
+
const previousRow = previousSource === null || previousSource === void 0 ? void 0 : previousSource[definition.index];
|
|
2995
|
+
const groupId = previousRow === null || previousRow === void 0 ? void 0 : previousRow[PSEUDO_GROUP_ITEM_ID];
|
|
2996
|
+
const index = groupId
|
|
2997
|
+
? nextGroupIndexes.get(groupId)
|
|
2998
|
+
: convertGroupingIndex(definition.index, firstLevelMap, secondLevelMap);
|
|
2999
|
+
if (typeof index !== 'number') {
|
|
3000
|
+
changed = true;
|
|
3001
|
+
return [];
|
|
3002
|
+
}
|
|
3003
|
+
if (index < 0) {
|
|
3004
|
+
changed = true;
|
|
3005
|
+
return [];
|
|
3006
|
+
}
|
|
3007
|
+
if (index === definition.index) {
|
|
3008
|
+
return [definition];
|
|
3009
|
+
}
|
|
3010
|
+
changed = true;
|
|
3011
|
+
return [Object.assign(Object.assign({}, definition), { index })];
|
|
3012
|
+
});
|
|
3013
|
+
if (changed) {
|
|
3014
|
+
this.providers.dimension.setRowDefinitions(remapped);
|
|
3015
|
+
}
|
|
2880
3016
|
}
|
|
2881
3017
|
updateTrimmed(trimmedGroup = {}, firstLevelMap = {}, secondLevelMap, source = this.getStore().get('source'), { filterTrimmedMode = 'remap', } = {}) {
|
|
2882
3018
|
// map previously trimmed data
|
|
@@ -3217,18 +3353,14 @@ const ROW_RESIZE_EVENT = 'rowresize';
|
|
|
3217
3353
|
const AFTER_ROW_RESIZE_EVENT = 'afterrowresize';
|
|
3218
3354
|
const ROW_RESIZE_CANCEL_EVENT = 'rowresizecancel';
|
|
3219
3355
|
class RowResizePlugin extends BasePlugin {
|
|
3220
|
-
static fromGridProperty(revogrid, providers) {
|
|
3221
|
-
const plugin = new RowResizePlugin(revogrid, providers);
|
|
3222
|
-
plugin.controlFromGridProperty();
|
|
3223
|
-
return plugin;
|
|
3224
|
-
}
|
|
3225
3356
|
constructor(revogrid, providers, config = {}) {
|
|
3226
3357
|
super(revogrid, providers);
|
|
3227
3358
|
this.enabled = false;
|
|
3228
|
-
this.
|
|
3229
|
-
this.
|
|
3230
|
-
this.
|
|
3231
|
-
this.
|
|
3359
|
+
this.appliedDefinitionIndexes = new Map();
|
|
3360
|
+
this.pendingBottomAnchor = false;
|
|
3361
|
+
this.keepBottomAnchor = false;
|
|
3362
|
+
this.rowDefinitionRemapQueued = false;
|
|
3363
|
+
this.pendingSourceCounts = new Map();
|
|
3232
3364
|
this.previousBodyCursor = '';
|
|
3233
3365
|
this.decorateRow = ({ detail, }) => {
|
|
3234
3366
|
if (!this.enabled ||
|
|
@@ -3292,22 +3424,72 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3292
3424
|
}
|
|
3293
3425
|
};
|
|
3294
3426
|
this.onWindowBlur = () => this.cancel('blur');
|
|
3295
|
-
this.
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3427
|
+
this.updateBottomAnchorState = ({ detail, }) => {
|
|
3428
|
+
if (detail.dimension !== 'rgRow') {
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
this.keepBottomAnchor = this.isMainViewportAtBottom(detail.coordinate);
|
|
3432
|
+
};
|
|
3433
|
+
this.applyPendingBottomAnchor = () => {
|
|
3434
|
+
if (!this.pendingBottomAnchor) {
|
|
3435
|
+
return;
|
|
3436
|
+
}
|
|
3437
|
+
this.pendingBottomAnchor = false;
|
|
3438
|
+
const dimension = this.providers.dimension.stores.rgRow.store;
|
|
3439
|
+
// Scroll surfaces have slightly different client sizes. Give the shared
|
|
3440
|
+
// scrolling service the content end and let each surface clamp to its own
|
|
3441
|
+
// exact bottom coordinate.
|
|
3442
|
+
void this.revogrid.scrollToCoordinate({ y: dimension.get('realSize') });
|
|
3443
|
+
};
|
|
3444
|
+
this.scheduleRowDefinitionRemap = () => {
|
|
3445
|
+
if (this.rowDefinitionRemapQueued) {
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
this.rowDefinitionRemapQueued = true;
|
|
3449
|
+
queueMicrotask(() => {
|
|
3450
|
+
if (!this.rowDefinitionRemapQueued) {
|
|
3451
|
+
return;
|
|
3452
|
+
}
|
|
3453
|
+
this.pruneRowDefinitions();
|
|
3454
|
+
this.reapplyRowDefinitionSizes();
|
|
3455
|
+
this.rowDefinitionRemapQueued = false;
|
|
3456
|
+
});
|
|
3457
|
+
};
|
|
3458
|
+
/** Map source-indexed row definitions back onto the current virtual order. */
|
|
3459
|
+
this.reapplyRowDefinitionSizes = () => {
|
|
3460
|
+
const rowDefinitions = this.providers.dimension.getRowDefinitions();
|
|
3461
|
+
for (const rowType of rowTypes) {
|
|
3299
3462
|
const items = this.providers.data.stores[rowType].store.get('items');
|
|
3463
|
+
const definitions = new Map(rowDefinitions
|
|
3464
|
+
.filter(definition => definition.type === rowType)
|
|
3465
|
+
.map(definition => [definition.index, definition.size]));
|
|
3466
|
+
const appliedIndexes = this.appliedDefinitionIndexes.get(rowType);
|
|
3467
|
+
if (!definitions.size && !(appliedIndexes === null || appliedIndexes === void 0 ? void 0 : appliedIndexes.size)) {
|
|
3468
|
+
continue;
|
|
3469
|
+
}
|
|
3470
|
+
const dimension = this.providers.dimension.stores[rowType];
|
|
3471
|
+
const currentSizes = dimension.store.get('sizes');
|
|
3472
|
+
const sizes = Object.assign({}, currentSizes);
|
|
3473
|
+
for (const index of appliedIndexes || []) {
|
|
3474
|
+
delete sizes[index];
|
|
3475
|
+
}
|
|
3300
3476
|
const indexes = new Set();
|
|
3301
3477
|
items.forEach((physicalIndex, virtualIndex) => {
|
|
3302
|
-
|
|
3478
|
+
const size = definitions.get(physicalIndex);
|
|
3479
|
+
if (size !== undefined) {
|
|
3480
|
+
sizes[virtualIndex] = size;
|
|
3303
3481
|
indexes.add(virtualIndex);
|
|
3304
3482
|
}
|
|
3305
3483
|
});
|
|
3306
|
-
this.
|
|
3484
|
+
this.appliedDefinitionIndexes.set(rowType, indexes);
|
|
3485
|
+
const sizeKeys = Object.keys(sizes);
|
|
3486
|
+
if (sizeKeys.length !== Object.keys(currentSizes).length ||
|
|
3487
|
+
sizeKeys.some(index => sizes[index] !== currentSizes[index])) {
|
|
3488
|
+
this.providers.dimension.setCustomSizes(rowType, sizes);
|
|
3489
|
+
}
|
|
3307
3490
|
}
|
|
3308
3491
|
};
|
|
3309
3492
|
this.config = resolveRowResizeConfig(config);
|
|
3310
|
-
this.rowDefinitionsRef = revogrid.rowDefinitions;
|
|
3311
3493
|
if (new.target !== RowResizePlugin) {
|
|
3312
3494
|
this.enabled = true;
|
|
3313
3495
|
this.registerEventListeners();
|
|
@@ -3315,77 +3497,53 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3315
3497
|
}
|
|
3316
3498
|
registerEventListeners() {
|
|
3317
3499
|
this.addEventListener('beforerowrender', this.decorateRow);
|
|
3318
|
-
this.addEventListener('beforeanysource', (
|
|
3500
|
+
this.addEventListener('beforeanysource', () => {
|
|
3319
3501
|
this.cancel('data-change');
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
for (const index of committed.keys()) {
|
|
3326
|
-
if (index >= detail.source.length) {
|
|
3327
|
-
committed.delete(index);
|
|
3328
|
-
removedIndexes.add(index);
|
|
3329
|
-
}
|
|
3330
|
-
}
|
|
3331
|
-
if (removedIndexes.size) {
|
|
3332
|
-
const rowDefinitions = this.revogrid.rowDefinitions.filter(definition => definition.type !== detail.type ||
|
|
3333
|
-
!removedIndexes.has(definition.index));
|
|
3334
|
-
this.rowDefinitionsRef = rowDefinitions;
|
|
3335
|
-
this.revogrid.rowDefinitions = rowDefinitions;
|
|
3336
|
-
}
|
|
3502
|
+
this.keepBottomAnchor = false;
|
|
3503
|
+
});
|
|
3504
|
+
this.addEventListener('afteranysource', ({ detail }) => {
|
|
3505
|
+
this.pendingSourceCounts.set(detail.type, detail.source.length);
|
|
3506
|
+
this.scheduleRowDefinitionRemap();
|
|
3337
3507
|
});
|
|
3338
|
-
this.addEventListener('afteranysource', this.rebuildCommittedSizes);
|
|
3339
3508
|
this.addEventListener('beforesourcesortingapply', this.cancelForDataChange);
|
|
3340
|
-
this.addEventListener('
|
|
3509
|
+
this.addEventListener('beforesortingapply', this.cancelForDataChange);
|
|
3510
|
+
this.addEventListener('sortingconfigchanged', this.cancelForDataChange);
|
|
3511
|
+
this.addEventListener(BEFORE_GROUPING_APPLY_EVENT, this.cancelForDataChange);
|
|
3512
|
+
this.addEventListener('aftersortingapply', this.scheduleRowDefinitionRemap);
|
|
3341
3513
|
this.addEventListener('beforefilterapply', this.cancelForDataChange);
|
|
3342
|
-
this.addEventListener('
|
|
3514
|
+
this.addEventListener('afterfilterapply', this.scheduleRowDefinitionRemap);
|
|
3515
|
+
this.addEventListener('beforerowdefinition', () => {
|
|
3343
3516
|
this.cancel('data-change');
|
|
3344
|
-
|
|
3345
|
-
this.committedSizes.clear();
|
|
3346
|
-
this.appliedIndexes.clear();
|
|
3347
|
-
this.rowDefinitionsRef = detail.vals;
|
|
3348
|
-
}
|
|
3349
|
-
});
|
|
3350
|
-
this.addEventListener('afterthemechanged', this.reapplyCommittedSizes);
|
|
3351
|
-
this.addEventListener('aftertrimmed', this.syncAppliedIndexes);
|
|
3352
|
-
this.addEventListener('roworderchange', () => {
|
|
3353
|
-
queueMicrotask(this.reapplyCommittedSizes);
|
|
3517
|
+
this.scheduleRowDefinitionRemap();
|
|
3354
3518
|
});
|
|
3519
|
+
this.addEventListener('afterthemechanged', this.scheduleRowDefinitionRemap);
|
|
3520
|
+
this.addEventListener('aftertrimmed', this.scheduleRowDefinitionRemap);
|
|
3521
|
+
this.addEventListener('roworderchange', this.scheduleRowDefinitionRemap);
|
|
3355
3522
|
this.addEventListener(GROUP_EXPAND_EVENT, () => {
|
|
3356
|
-
|
|
3523
|
+
if (this.keepBottomAnchor) {
|
|
3524
|
+
this.pendingBottomAnchor = true;
|
|
3525
|
+
}
|
|
3526
|
+
this.scheduleRowDefinitionRemap();
|
|
3357
3527
|
});
|
|
3528
|
+
this.addEventListener('aftergridrender', this.applyPendingBottomAnchor);
|
|
3529
|
+
this.addEventListener('viewportscroll', this.updateBottomAnchorState);
|
|
3358
3530
|
this.addEventListener('rowheaderschanged', ({ detail }) => {
|
|
3359
3531
|
if (!detail && !this.config.fullRow) {
|
|
3360
3532
|
this.cancel('row-headers-hidden');
|
|
3361
3533
|
}
|
|
3362
3534
|
});
|
|
3363
3535
|
}
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
this.watch('resizeRow', value => {
|
|
3369
|
-
this.gridResizeRow = value;
|
|
3370
|
-
this.syncGridProperty();
|
|
3371
|
-
});
|
|
3372
|
-
this.watch('plugins', value => {
|
|
3373
|
-
this.gridPlugins = value || [];
|
|
3374
|
-
this.syncGridProperty();
|
|
3375
|
-
});
|
|
3376
|
-
}
|
|
3377
|
-
syncGridProperty(refresh = true) {
|
|
3378
|
-
const hasConfiguredPlugin = this.gridPlugins.some(plugin => plugin !== RowResizePlugin &&
|
|
3536
|
+
syncGridConfig(refresh = true) {
|
|
3537
|
+
const { plugins = [], resizeRow } = this.revogrid;
|
|
3538
|
+
const isCorePlugin = this.constructor === RowResizePlugin;
|
|
3539
|
+
const hasConfiguredPlugin = plugins.some(plugin => plugin !== RowResizePlugin &&
|
|
3379
3540
|
plugin.prototype instanceof RowResizePlugin);
|
|
3380
|
-
const
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
typeof this.gridResizeRow === 'object'
|
|
3387
|
-
? this.gridResizeRow
|
|
3388
|
-
: undefined);
|
|
3541
|
+
const enabled = !isCorePlugin ||
|
|
3542
|
+
(!hasConfiguredPlugin && !!resizeRow);
|
|
3543
|
+
const resizeConfig = typeof resizeRow === 'object' ? resizeRow : undefined;
|
|
3544
|
+
const config = isCorePlugin
|
|
3545
|
+
? resolveRowResizeConfig(resizeConfig)
|
|
3546
|
+
: this.config;
|
|
3389
3547
|
const configChanged = config.minHeight !== this.config.minHeight ||
|
|
3390
3548
|
config.maxHeight !== this.config.maxHeight ||
|
|
3391
3549
|
config.fullRow !== this.config.fullRow;
|
|
@@ -3397,10 +3555,13 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3397
3555
|
if (enabled !== this.enabled) {
|
|
3398
3556
|
this.enabled = enabled;
|
|
3399
3557
|
if (enabled) {
|
|
3400
|
-
this.rowDefinitionsRef = this.revogrid.rowDefinitions;
|
|
3401
3558
|
this.registerEventListeners();
|
|
3402
3559
|
}
|
|
3403
3560
|
else {
|
|
3561
|
+
this.pendingBottomAnchor = false;
|
|
3562
|
+
this.keepBottomAnchor = false;
|
|
3563
|
+
this.rowDefinitionRemapQueued = false;
|
|
3564
|
+
this.pendingSourceCounts.clear();
|
|
3404
3565
|
this.clearSubscriptions();
|
|
3405
3566
|
}
|
|
3406
3567
|
}
|
|
@@ -3419,6 +3580,7 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3419
3580
|
}
|
|
3420
3581
|
const dimension = this.providers.dimension.stores[rowType];
|
|
3421
3582
|
const dimensionState = dimension.getCurrentState();
|
|
3583
|
+
const viewport = this.providers.viewport.stores[rowType];
|
|
3422
3584
|
const item = getItemByIndex(dimensionState, index);
|
|
3423
3585
|
const focusedStore = this.providers.selection.focusedStore;
|
|
3424
3586
|
const selectedRowType = focusedStore
|
|
@@ -3450,16 +3612,23 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3450
3612
|
currentHeight: startHeight,
|
|
3451
3613
|
previousSizes,
|
|
3452
3614
|
originalCustomSizes: Object.assign({}, dimensionState.sizes),
|
|
3453
|
-
|
|
3615
|
+
bottomAnchored: rowType === 'rgRow' &&
|
|
3616
|
+
this.isMainViewportAtBottom(viewport.lastCoordinate),
|
|
3454
3617
|
lastEvent: event,
|
|
3455
3618
|
};
|
|
3619
|
+
this.active = active;
|
|
3456
3620
|
const beforeEvent = this.emit(BEFORE_ROW_RESIZE_EVENT, this.eventDetail(active, event, startHeight));
|
|
3457
3621
|
if (beforeEvent.defaultPrevented) {
|
|
3622
|
+
if (this.active === active) {
|
|
3623
|
+
this.active = undefined;
|
|
3624
|
+
}
|
|
3625
|
+
return;
|
|
3626
|
+
}
|
|
3627
|
+
if (!this.enabled || this.active !== active) {
|
|
3458
3628
|
return;
|
|
3459
3629
|
}
|
|
3460
3630
|
event.preventDefault();
|
|
3461
3631
|
event.stopPropagation();
|
|
3462
|
-
this.active = active;
|
|
3463
3632
|
const doc = this.revogrid.ownerDocument;
|
|
3464
3633
|
this.previousBodyCursor = ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.style.cursor) || '';
|
|
3465
3634
|
if (doc.body) {
|
|
@@ -3482,6 +3651,7 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3482
3651
|
return;
|
|
3483
3652
|
}
|
|
3484
3653
|
this.providers.dimension.setCustomSizes(active.rowType, createRowResizePatch(active.indexes, size), true);
|
|
3654
|
+
this.requestBottomAnchor(active);
|
|
3485
3655
|
active.currentHeight = size;
|
|
3486
3656
|
this.emit(ROW_RESIZE_EVENT, this.eventDetail(active, active.lastEvent, size));
|
|
3487
3657
|
}
|
|
@@ -3500,7 +3670,8 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3500
3670
|
}
|
|
3501
3671
|
}
|
|
3502
3672
|
this.providers.dimension.setCustomSizes(active.rowType, currentSizes);
|
|
3503
|
-
|
|
3673
|
+
this.requestBottomAnchor(active);
|
|
3674
|
+
const detail = Object.assign(Object.assign({}, this.eventDetail(active, active.lastEvent, active.startHeight)), { reason });
|
|
3504
3675
|
this.finishGesture();
|
|
3505
3676
|
this.emit(ROW_RESIZE_CANCEL_EVENT, detail);
|
|
3506
3677
|
}
|
|
@@ -3519,51 +3690,44 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3519
3690
|
return;
|
|
3520
3691
|
}
|
|
3521
3692
|
const items = this.providers.data.stores[active.rowType].store.get('items');
|
|
3522
|
-
let committed = this.committedSizes.get(active.rowType);
|
|
3523
|
-
if (!committed) {
|
|
3524
|
-
committed = new Map();
|
|
3525
|
-
this.committedSizes.set(active.rowType, committed);
|
|
3526
|
-
}
|
|
3527
|
-
let applied = this.appliedIndexes.get(active.rowType);
|
|
3528
|
-
if (!applied) {
|
|
3529
|
-
applied = new Set();
|
|
3530
|
-
this.appliedIndexes.set(active.rowType, applied);
|
|
3531
|
-
}
|
|
3532
3693
|
const physicalIndexes = active.indexes.reduce((result, index) => {
|
|
3533
3694
|
const physicalIndex = items[index];
|
|
3534
3695
|
if (physicalIndex !== undefined) {
|
|
3535
|
-
committed.set(physicalIndex, active.currentHeight);
|
|
3536
|
-
applied.add(index);
|
|
3537
3696
|
result.push(physicalIndex);
|
|
3538
3697
|
}
|
|
3539
3698
|
return result;
|
|
3540
3699
|
}, []);
|
|
3541
3700
|
if (physicalIndexes.length) {
|
|
3542
|
-
const rowDefinitions = mergeRowResizeDefinitions(this.
|
|
3543
|
-
this.
|
|
3544
|
-
this.
|
|
3701
|
+
const rowDefinitions = mergeRowResizeDefinitions(this.providers.dimension.getRowDefinitions(), active.rowType, physicalIndexes, active.currentHeight);
|
|
3702
|
+
this.providers.dimension.setRowDefinitions(rowDefinitions);
|
|
3703
|
+
this.scheduleRowDefinitionRemap();
|
|
3704
|
+
this.keepBottomAnchor = active.bottomAnchored;
|
|
3705
|
+
this.requestBottomAnchor(active);
|
|
3545
3706
|
}
|
|
3546
3707
|
}
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3708
|
+
requestBottomAnchor(active) {
|
|
3709
|
+
if (active.bottomAnchored) {
|
|
3710
|
+
this.pendingBottomAnchor = true;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
isMainViewportAtBottom(coordinate) {
|
|
3714
|
+
const dimension = this.providers.dimension.stores.rgRow.getCurrentState();
|
|
3715
|
+
const viewport = this.providers.viewport.stores.rgRow.store.state;
|
|
3716
|
+
return (dimension.realSize > viewport.clientSize &&
|
|
3717
|
+
coordinate >= getViewportMaxCoordinate(dimension, viewport.virtualSize));
|
|
3718
|
+
}
|
|
3719
|
+
pruneRowDefinitions() {
|
|
3720
|
+
if (!this.pendingSourceCounts.size) {
|
|
3721
|
+
return;
|
|
3722
|
+
}
|
|
3723
|
+
const definitions = this.providers.dimension.getRowDefinitions();
|
|
3724
|
+
const rowDefinitions = definitions.filter(definition => {
|
|
3725
|
+
const count = this.pendingSourceCounts.get(definition.type);
|
|
3726
|
+
return count === undefined || definition.index < count;
|
|
3727
|
+
});
|
|
3728
|
+
this.pendingSourceCounts.clear();
|
|
3729
|
+
if (rowDefinitions.length !== definitions.length) {
|
|
3730
|
+
this.providers.dimension.setRowDefinitions(rowDefinitions);
|
|
3567
3731
|
}
|
|
3568
3732
|
}
|
|
3569
3733
|
finishGesture() {
|
|
@@ -3586,8 +3750,11 @@ class RowResizePlugin extends BasePlugin {
|
|
|
3586
3750
|
}
|
|
3587
3751
|
destroy() {
|
|
3588
3752
|
this.cancel('destroy');
|
|
3753
|
+
this.keepBottomAnchor = false;
|
|
3754
|
+
this.rowDefinitionRemapQueued = false;
|
|
3755
|
+
this.pendingSourceCounts.clear();
|
|
3589
3756
|
super.destroy();
|
|
3590
3757
|
}
|
|
3591
3758
|
}
|
|
3592
3759
|
|
|
3593
|
-
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnAutoSizeMode as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G,
|
|
3760
|
+
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnAutoSizeMode as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, AFTER_ROW_RESIZE_EVENT as H, ROW_RESIZE_CANCEL_EVENT as I, RowResizePlugin as J, DEFAULT_MIN_ROW_HEIGHT as K, resolveRowResizeConfig as L, clampRowResizeHeight as M, getRowResizeIndexes as N, createRowResizePatch as O, mergeRowResizeDefinitions as P, SortingPlugin as Q, ROW_RESIZE_HANDLE_CLASS as R, SelectionStore as S, hasActiveSorting as T, getSortingIndex as U, sortIndexByItems as V, defaultCellCompare as W, descCellCompare as X, getNextOrder as Y, getComparer as Z, 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, filterTypeDefaults as j, filterNames as k, DEFAULT_BLANK_SEMANTICS as l, isBlankValue as m, doCollapse as n, doExpand as o, COLUMN_DRAG_MOVE_EVENT as p, COLUMN_DRAG_END_EVENT as q, resolveBlankSemantics as r, BEFORE_COLUMN_DRAG_END_EVENT as s, themeTokenCssVariables as t, COLUMN_DRAG_START_EVENT as u, ColumnMovePlugin as v, getLeftRelative as w, getColumnDragPosition as x, BEFORE_ROW_RESIZE_EVENT as y, ROW_RESIZE_EVENT as z };
|