@revolist/revogrid 4.14.1 → 4.14.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/{column.drag.plugin-c61efe93.js → column.drag.plugin-911acec7.js} +52 -28
- package/dist/cjs/column.drag.plugin-911acec7.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +20 -50
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js +42 -42
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.plugin.js +52 -27
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.types.js.map +1 -1
- package/dist/collection/serve/controller.js +12 -0
- package/dist/collection/services/column.data.provider.js +0 -38
- package/dist/collection/services/column.data.provider.js.map +1 -1
- package/dist/esm/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
- package/dist/esm/column.drag.plugin-a111b876.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/revo-grid.entry.js +20 -50
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
- package/dist/revo-grid/column.drag.plugin-a111b876.js.map +1 -0
- package/dist/revo-grid/index.esm.js +2 -2
- package/dist/revo-grid/revo-grid.entry.js +20 -50
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/types/components/revoGrid/revo-grid.d.ts +10 -7
- package/dist/types/components.d.ts +11 -12
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +12 -4
- package/dist/types/plugins/sorting/sorting.types.d.ts +1 -0
- package/dist/types/services/column.data.provider.d.ts +0 -7
- package/hydrate/index.js +137 -142
- package/hydrate/index.mjs +137 -142
- package/package.json +1 -1
- package/readme.md +6 -0
- package/standalone/revo-grid.js +70 -75
- package/standalone/revo-grid.js.map +1 -1
- package/dist/cjs/column.drag.plugin-c61efe93.js.map +0 -1
- package/dist/esm/column.drag.plugin-eb8f7e38.js.map +0 -1
- package/dist/revo-grid/column.drag.plugin-eb8f7e38.js.map +0 -1
|
@@ -136,6 +136,7 @@ export declare class RevoGridComponent {
|
|
|
136
136
|
/**
|
|
137
137
|
* Alternative way to set sorting.
|
|
138
138
|
* `{columns: [{prop: 'name', order: 'asc'}]}`
|
|
139
|
+
* Use SortingPlugin to get current sorting state
|
|
139
140
|
*/
|
|
140
141
|
sorting?: SortingConfig;
|
|
141
142
|
/**
|
|
@@ -258,7 +259,7 @@ export declare class RevoGridComponent {
|
|
|
258
259
|
to: number;
|
|
259
260
|
}>;
|
|
260
261
|
/**
|
|
261
|
-
* By `
|
|
262
|
+
* By `SortingPlugin`
|
|
262
263
|
* <br>Triggered immediately after header click.
|
|
263
264
|
* <br>First in sorting event sequence. Ff this event stops no other event called.
|
|
264
265
|
* <br>Use `e.preventDefault()` to prevent sorting.
|
|
@@ -269,7 +270,7 @@ export declare class RevoGridComponent {
|
|
|
269
270
|
additive: boolean;
|
|
270
271
|
}>;
|
|
271
272
|
/**
|
|
272
|
-
* By `
|
|
273
|
+
* By `SortingPlugin`
|
|
273
274
|
* <br>Same as `beforesorting` but triggered after `beforeanysource` (when source is changed).
|
|
274
275
|
* <br>Use `e.preventDefault()` to prevent sorting data change.
|
|
275
276
|
*/
|
|
@@ -278,7 +279,7 @@ export declare class RevoGridComponent {
|
|
|
278
279
|
sorting?: SortingOrder;
|
|
279
280
|
}>;
|
|
280
281
|
/**
|
|
281
|
-
* By `
|
|
282
|
+
* By `SortingPlugin`
|
|
282
283
|
* <br> After `beforesorting`
|
|
283
284
|
* <br>Triggered after column data updated with new sorting order.
|
|
284
285
|
* <br>Use `e.preventDefault()` to prevent sorting data change.
|
|
@@ -352,7 +353,7 @@ export declare class RevoGridComponent {
|
|
|
352
353
|
/** Column updated */
|
|
353
354
|
aftercolumnsset: EventEmitter<{
|
|
354
355
|
columns: ColumnCollection;
|
|
355
|
-
order:
|
|
356
|
+
order: SortingOrder;
|
|
356
357
|
}>;
|
|
357
358
|
/**
|
|
358
359
|
* Emitted before applying a filter to the data source.
|
|
@@ -424,6 +425,7 @@ export declare class RevoGridComponent {
|
|
|
424
425
|
filterconfigchanged: EventEmitter;
|
|
425
426
|
/**
|
|
426
427
|
* Emitted when the sorting configuration is changed
|
|
428
|
+
* SortingPlugin subsribed to this event
|
|
427
429
|
*/
|
|
428
430
|
sortingconfigchanged: EventEmitter<SortingConfig>;
|
|
429
431
|
/**
|
|
@@ -522,12 +524,13 @@ export declare class RevoGridComponent {
|
|
|
522
524
|
getColumnStore(type?: DimensionCols): Promise<Observable<DSourceState<ColumnRegular, DimensionCols>>>;
|
|
523
525
|
/**
|
|
524
526
|
* Update column sorting
|
|
525
|
-
* @param column -
|
|
526
|
-
* @param index - virtual column index
|
|
527
|
+
* @param column - column prop and cellCompare
|
|
527
528
|
* @param order - order to apply
|
|
528
529
|
* @param additive - if false will replace current order
|
|
530
|
+
*
|
|
531
|
+
* later passed to SortingPlugin
|
|
529
532
|
*/
|
|
530
|
-
updateColumnSorting(column: ColumnRegular,
|
|
533
|
+
updateColumnSorting(column: Pick<ColumnRegular, 'prop' | 'cellCompare'>, order: 'asc' | 'desc' | undefined, additive: boolean): Promise<void>;
|
|
531
534
|
/**
|
|
532
535
|
* Clears column sorting
|
|
533
536
|
*/
|
|
@@ -268,7 +268,7 @@ export namespace Components {
|
|
|
268
268
|
*/
|
|
269
269
|
"setDataAt": ({ row, col, colType, rowType, val, skipDataUpdate }: { row: number; col: number; val?: any; skipDataUpdate?: boolean; } & AllDimensionType) => Promise<void | undefined>;
|
|
270
270
|
/**
|
|
271
|
-
* Alternative way to set sorting. `{columns: [{prop: 'name', order: 'asc'}]}`
|
|
271
|
+
* Alternative way to set sorting. `{columns: [{prop: 'name', order: 'asc'}]}` Use SortingPlugin to get current sorting state
|
|
272
272
|
*/
|
|
273
273
|
"sorting"?: SortingConfig;
|
|
274
274
|
/**
|
|
@@ -289,12 +289,11 @@ export namespace Components {
|
|
|
289
289
|
"trimmedRows": Record<number, boolean>;
|
|
290
290
|
/**
|
|
291
291
|
* Update column sorting
|
|
292
|
-
* @param column -
|
|
293
|
-
* @param index - virtual column index
|
|
292
|
+
* @param column - column prop and cellCompare
|
|
294
293
|
* @param order - order to apply
|
|
295
|
-
* @param additive - if false will replace current order
|
|
294
|
+
* @param additive - if false will replace current order later passed to SortingPlugin
|
|
296
295
|
*/
|
|
297
|
-
"updateColumnSorting": (column: ColumnRegular,
|
|
296
|
+
"updateColumnSorting": (column: Pick<ColumnRegular, "prop" | "cellCompare">, order: "asc" | "desc" | undefined, additive: boolean) => Promise<void>;
|
|
298
297
|
/**
|
|
299
298
|
* Update columns
|
|
300
299
|
*/
|
|
@@ -834,7 +833,7 @@ declare global {
|
|
|
834
833
|
"beforecolumnapplied": ColumnCollection;
|
|
835
834
|
"aftercolumnsset": {
|
|
836
835
|
columns: ColumnCollection;
|
|
837
|
-
order:
|
|
836
|
+
order: SortingOrder;
|
|
838
837
|
};
|
|
839
838
|
"beforefilterapply": { collection: Record<ColumnProp, FilterCollectionItem> };
|
|
840
839
|
"beforefiltertrimmed": {
|
|
@@ -1384,7 +1383,7 @@ declare namespace LocalJSX {
|
|
|
1384
1383
|
*/
|
|
1385
1384
|
"onAftercolumnsset"?: (event: RevoGridCustomEvent<{
|
|
1386
1385
|
columns: ColumnCollection;
|
|
1387
|
-
order:
|
|
1386
|
+
order: SortingOrder;
|
|
1388
1387
|
}>) => void;
|
|
1389
1388
|
/**
|
|
1390
1389
|
* After data applied or range changed.
|
|
@@ -1484,7 +1483,7 @@ declare namespace LocalJSX {
|
|
|
1484
1483
|
*/
|
|
1485
1484
|
"onBeforerowdefinition"?: (event: RevoGridCustomEvent<{ vals: any; oldVals: any }>) => void;
|
|
1486
1485
|
/**
|
|
1487
|
-
* By `
|
|
1486
|
+
* By `SortingPlugin` <br>Triggered immediately after header click. <br>First in sorting event sequence. Ff this event stops no other event called. <br>Use `e.preventDefault()` to prevent sorting.
|
|
1488
1487
|
*/
|
|
1489
1488
|
"onBeforesorting"?: (event: RevoGridCustomEvent<{
|
|
1490
1489
|
column: ColumnRegular;
|
|
@@ -1492,7 +1491,7 @@ declare namespace LocalJSX {
|
|
|
1492
1491
|
additive: boolean;
|
|
1493
1492
|
}>) => void;
|
|
1494
1493
|
/**
|
|
1495
|
-
* By `
|
|
1494
|
+
* By `SortingPlugin` <br> After `beforesorting` <br>Triggered after column data updated with new sorting order. <br>Use `e.preventDefault()` to prevent sorting data change.
|
|
1496
1495
|
*/
|
|
1497
1496
|
"onBeforesortingapply"?: (event: RevoGridCustomEvent<{
|
|
1498
1497
|
column: ColumnRegular;
|
|
@@ -1507,7 +1506,7 @@ declare namespace LocalJSX {
|
|
|
1507
1506
|
source: DataType[];
|
|
1508
1507
|
}>) => void;
|
|
1509
1508
|
/**
|
|
1510
|
-
* By `
|
|
1509
|
+
* By `SortingPlugin` <br>Same as `beforesorting` but triggered after `beforeanysource` (when source is changed). <br>Use `e.preventDefault()` to prevent sorting data change.
|
|
1511
1510
|
*/
|
|
1512
1511
|
"onBeforesourcesortingapply"?: (event: RevoGridCustomEvent<{
|
|
1513
1512
|
type: DimensionRows;
|
|
@@ -1550,7 +1549,7 @@ declare namespace LocalJSX {
|
|
|
1550
1549
|
*/
|
|
1551
1550
|
"onRoworderchanged"?: (event: RevoGridCustomEvent<{ from: number; to: number }>) => void;
|
|
1552
1551
|
/**
|
|
1553
|
-
* Emitted when the sorting configuration is changed
|
|
1552
|
+
* Emitted when the sorting configuration is changed SortingPlugin subsribed to this event
|
|
1554
1553
|
*/
|
|
1555
1554
|
"onSortingconfigchanged"?: (event: RevoGridCustomEvent<SortingConfig>) => void;
|
|
1556
1555
|
/**
|
|
@@ -1605,7 +1604,7 @@ declare namespace LocalJSX {
|
|
|
1605
1604
|
*/
|
|
1606
1605
|
"rowSize"?: number;
|
|
1607
1606
|
/**
|
|
1608
|
-
* Alternative way to set sorting. `{columns: [{prop: 'name', order: 'asc'}]}`
|
|
1607
|
+
* Alternative way to set sorting. `{columns: [{prop: 'name', order: 'asc'}]}` Use SortingPlugin to get current sorting state
|
|
1609
1608
|
*/
|
|
1610
1609
|
"sorting"?: SortingConfig;
|
|
1611
1610
|
/**
|
|
@@ -7,8 +7,7 @@ export * from './sorting.sign';
|
|
|
7
7
|
/**
|
|
8
8
|
* Lifecycle
|
|
9
9
|
* 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.
|
|
10
|
-
*
|
|
11
|
-
* 2. Method `updateColumnSorting` - Updates the column sorting icon on the grid and the column itself, but the data remains untouched.
|
|
10
|
+
* 2. @event `beforesourcesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted.
|
|
12
11
|
* 3. @event `beforesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted. This event is only called from a column sorting click.
|
|
13
12
|
* 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
|
|
14
13
|
*
|
|
@@ -18,16 +17,25 @@ export declare class SortingPlugin extends BasePlugin {
|
|
|
18
17
|
revogrid: HTMLRevoGridElement;
|
|
19
18
|
sorting?: SortingOrder;
|
|
20
19
|
sortingFunc?: SortingOrderFunction;
|
|
20
|
+
/**
|
|
21
|
+
* Delayed sorting promise
|
|
22
|
+
*/
|
|
21
23
|
sortingPromise: (() => void) | null;
|
|
24
|
+
/**
|
|
25
|
+
* We need to sort only so often
|
|
26
|
+
*/
|
|
22
27
|
postponeSort: import("lodash").DebouncedFunc<(order?: SortingOrder, comparison?: SortingOrderFunction, ignoreViewportUpdate?: boolean) => void>;
|
|
23
|
-
runSorting(order?: SortingOrder, comparison?: SortingOrderFunction, ignoreViewportUpdate?: boolean): void;
|
|
24
28
|
constructor(revogrid: HTMLRevoGridElement, providers: PluginProviders, config?: SortingConfig);
|
|
29
|
+
/**
|
|
30
|
+
* Entry point for sorting, waits for all delayes, registers jobs
|
|
31
|
+
*/
|
|
25
32
|
startSorting(order?: SortingOrder, sortingFunc?: SortingOrderFunction, ignoreViewportUpdate?: boolean): void;
|
|
26
33
|
/**
|
|
27
34
|
* Apply sorting to data on header click
|
|
28
35
|
* If additive - add to existing sorting, multiple columns can be sorted
|
|
29
36
|
*/
|
|
30
|
-
headerclick(column: ColumnRegular,
|
|
37
|
+
headerclick(column: ColumnRegular, additive: boolean): void;
|
|
38
|
+
runSorting(order?: SortingOrder, comparison?: SortingOrderFunction, ignoreViewportUpdate?: boolean): void;
|
|
31
39
|
/**
|
|
32
40
|
* Sort items by sorting function
|
|
33
41
|
* @requires proxyItems applied to row store
|
|
@@ -2,13 +2,9 @@ import { DataStore } from "../store/index";
|
|
|
2
2
|
import type { ColumnProp, ColumnRegular, DimensionCols } from "../types/index";
|
|
3
3
|
import { ColumnCollection } from '../utils/column.utils';
|
|
4
4
|
export type ColumnDataSources = Record<DimensionCols, DataStore<ColumnRegular, DimensionCols>>;
|
|
5
|
-
type Sorting = Record<ColumnProp, ColumnRegular>;
|
|
6
|
-
type SortingOrder = Record<ColumnProp, 'asc' | 'desc' | undefined>;
|
|
7
5
|
export default class ColumnDataProvider {
|
|
8
6
|
readonly dataSources: ColumnDataSources;
|
|
9
|
-
sorting: Sorting | null;
|
|
10
7
|
collection: ColumnCollection | null;
|
|
11
|
-
get order(): SortingOrder;
|
|
12
8
|
get stores(): ColumnDataSources;
|
|
13
9
|
constructor();
|
|
14
10
|
column(c: number, type?: DimensionCols): ColumnRegular | undefined;
|
|
@@ -28,7 +24,4 @@ export default class ColumnDataProvider {
|
|
|
28
24
|
*/
|
|
29
25
|
updateColumns(updatedColumns: ColumnRegular[]): void;
|
|
30
26
|
updateColumn(column: ColumnRegular, index: number): void;
|
|
31
|
-
updateColumnSorting(column: ColumnRegular, index: number, sorting: 'asc' | 'desc' | undefined, additive: boolean): ColumnRegular;
|
|
32
|
-
clearSorting(): void;
|
|
33
27
|
}
|
|
34
|
-
export {};
|
package/hydrate/index.js
CHANGED
|
@@ -10598,89 +10598,11 @@ class RevoEdit {
|
|
|
10598
10598
|
}; }
|
|
10599
10599
|
}
|
|
10600
10600
|
|
|
10601
|
-
/**
|
|
10602
|
-
* A specialized version of `_.forEach` for arrays without support for
|
|
10603
|
-
* iteratee shorthands.
|
|
10604
|
-
*
|
|
10605
|
-
* @private
|
|
10606
|
-
* @param {Array} [array] The array to iterate over.
|
|
10607
|
-
* @param {Function} iteratee The function invoked per iteration.
|
|
10608
|
-
* @returns {Array} Returns `array`.
|
|
10609
|
-
*/
|
|
10610
|
-
function arrayEach(array, iteratee) {
|
|
10611
|
-
var index = -1,
|
|
10612
|
-
length = array == null ? 0 : array.length;
|
|
10613
|
-
|
|
10614
|
-
while (++index < length) {
|
|
10615
|
-
if (iteratee(array[index], index, array) === false) {
|
|
10616
|
-
break;
|
|
10617
|
-
}
|
|
10618
|
-
}
|
|
10619
|
-
return array;
|
|
10620
|
-
}
|
|
10621
|
-
|
|
10622
|
-
/**
|
|
10623
|
-
* Casts `value` to `identity` if it's not a function.
|
|
10624
|
-
*
|
|
10625
|
-
* @private
|
|
10626
|
-
* @param {*} value The value to inspect.
|
|
10627
|
-
* @returns {Function} Returns cast function.
|
|
10628
|
-
*/
|
|
10629
|
-
function castFunction(value) {
|
|
10630
|
-
return typeof value == 'function' ? value : identity;
|
|
10631
|
-
}
|
|
10632
|
-
|
|
10633
|
-
/**
|
|
10634
|
-
* Iterates over elements of `collection` and invokes `iteratee` for each element.
|
|
10635
|
-
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
|
10636
|
-
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
10637
|
-
*
|
|
10638
|
-
* **Note:** As with other "Collections" methods, objects with a "length"
|
|
10639
|
-
* property are iterated like arrays. To avoid this behavior use `_.forIn`
|
|
10640
|
-
* or `_.forOwn` for object iteration.
|
|
10641
|
-
*
|
|
10642
|
-
* @static
|
|
10643
|
-
* @memberOf _
|
|
10644
|
-
* @since 0.1.0
|
|
10645
|
-
* @alias each
|
|
10646
|
-
* @category Collection
|
|
10647
|
-
* @param {Array|Object} collection The collection to iterate over.
|
|
10648
|
-
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
10649
|
-
* @returns {Array|Object} Returns `collection`.
|
|
10650
|
-
* @see _.forEachRight
|
|
10651
|
-
* @example
|
|
10652
|
-
*
|
|
10653
|
-
* _.forEach([1, 2], function(value) {
|
|
10654
|
-
* console.log(value);
|
|
10655
|
-
* });
|
|
10656
|
-
* // => Logs `1` then `2`.
|
|
10657
|
-
*
|
|
10658
|
-
* _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
|
|
10659
|
-
* console.log(key);
|
|
10660
|
-
* });
|
|
10661
|
-
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
|
10662
|
-
*/
|
|
10663
|
-
function forEach(collection, iteratee) {
|
|
10664
|
-
var func = isArray$1(collection) ? arrayEach : baseEach$1;
|
|
10665
|
-
return func(collection, castFunction(iteratee));
|
|
10666
|
-
}
|
|
10667
|
-
|
|
10668
10601
|
class ColumnDataProvider {
|
|
10669
|
-
get order() {
|
|
10670
|
-
const order = {};
|
|
10671
|
-
const sorting = this.sorting;
|
|
10672
|
-
if (sorting) {
|
|
10673
|
-
Object.keys(sorting).forEach(prop => {
|
|
10674
|
-
order[prop] = sorting[prop].order;
|
|
10675
|
-
});
|
|
10676
|
-
}
|
|
10677
|
-
return order;
|
|
10678
|
-
}
|
|
10679
10602
|
get stores() {
|
|
10680
10603
|
return this.dataSources;
|
|
10681
10604
|
}
|
|
10682
10605
|
constructor() {
|
|
10683
|
-
this.sorting = null;
|
|
10684
10606
|
this.collection = null;
|
|
10685
10607
|
this.dataSources = columnTypes.reduce((sources, k) => {
|
|
10686
10608
|
sources[k] = new DataStore(k);
|
|
@@ -10739,7 +10661,6 @@ class ColumnDataProvider {
|
|
|
10739
10661
|
}, {}),
|
|
10740
10662
|
});
|
|
10741
10663
|
});
|
|
10742
|
-
this.sorting = data.sort;
|
|
10743
10664
|
this.collection = data;
|
|
10744
10665
|
return data;
|
|
10745
10666
|
}
|
|
@@ -10788,31 +10709,6 @@ class ColumnDataProvider {
|
|
|
10788
10709
|
const type = getColumnType(column);
|
|
10789
10710
|
setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
|
|
10790
10711
|
}
|
|
10791
|
-
updateColumnSorting(column, index, sorting, additive) {
|
|
10792
|
-
if (!additive) {
|
|
10793
|
-
this.clearSorting();
|
|
10794
|
-
}
|
|
10795
|
-
column.order = sorting;
|
|
10796
|
-
if (!this.sorting) {
|
|
10797
|
-
this.sorting = {};
|
|
10798
|
-
}
|
|
10799
|
-
this.sorting[column.prop] = column;
|
|
10800
|
-
this.updateColumn(column, index);
|
|
10801
|
-
return column;
|
|
10802
|
-
}
|
|
10803
|
-
clearSorting() {
|
|
10804
|
-
const types = reduce(this.sorting, (r, c) => {
|
|
10805
|
-
const k = getColumnType(c);
|
|
10806
|
-
r[k] = true;
|
|
10807
|
-
return r;
|
|
10808
|
-
}, {});
|
|
10809
|
-
forEach(types, (_, type) => {
|
|
10810
|
-
const cols = this.dataSources[type].store.get('source');
|
|
10811
|
-
forEach(cols, (c) => (c.order = undefined));
|
|
10812
|
-
this.dataSources[type].setData({ source: [...cols] });
|
|
10813
|
-
});
|
|
10814
|
-
this.sorting = {};
|
|
10815
|
-
}
|
|
10816
10712
|
}
|
|
10817
10713
|
|
|
10818
10714
|
/**
|
|
@@ -11079,6 +10975,73 @@ class ViewportProvider {
|
|
|
11079
10975
|
}
|
|
11080
10976
|
}
|
|
11081
10977
|
|
|
10978
|
+
/**
|
|
10979
|
+
* A specialized version of `_.forEach` for arrays without support for
|
|
10980
|
+
* iteratee shorthands.
|
|
10981
|
+
*
|
|
10982
|
+
* @private
|
|
10983
|
+
* @param {Array} [array] The array to iterate over.
|
|
10984
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
10985
|
+
* @returns {Array} Returns `array`.
|
|
10986
|
+
*/
|
|
10987
|
+
function arrayEach(array, iteratee) {
|
|
10988
|
+
var index = -1,
|
|
10989
|
+
length = array == null ? 0 : array.length;
|
|
10990
|
+
|
|
10991
|
+
while (++index < length) {
|
|
10992
|
+
if (iteratee(array[index], index, array) === false) {
|
|
10993
|
+
break;
|
|
10994
|
+
}
|
|
10995
|
+
}
|
|
10996
|
+
return array;
|
|
10997
|
+
}
|
|
10998
|
+
|
|
10999
|
+
/**
|
|
11000
|
+
* Casts `value` to `identity` if it's not a function.
|
|
11001
|
+
*
|
|
11002
|
+
* @private
|
|
11003
|
+
* @param {*} value The value to inspect.
|
|
11004
|
+
* @returns {Function} Returns cast function.
|
|
11005
|
+
*/
|
|
11006
|
+
function castFunction(value) {
|
|
11007
|
+
return typeof value == 'function' ? value : identity;
|
|
11008
|
+
}
|
|
11009
|
+
|
|
11010
|
+
/**
|
|
11011
|
+
* Iterates over elements of `collection` and invokes `iteratee` for each element.
|
|
11012
|
+
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
|
11013
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
11014
|
+
*
|
|
11015
|
+
* **Note:** As with other "Collections" methods, objects with a "length"
|
|
11016
|
+
* property are iterated like arrays. To avoid this behavior use `_.forIn`
|
|
11017
|
+
* or `_.forOwn` for object iteration.
|
|
11018
|
+
*
|
|
11019
|
+
* @static
|
|
11020
|
+
* @memberOf _
|
|
11021
|
+
* @since 0.1.0
|
|
11022
|
+
* @alias each
|
|
11023
|
+
* @category Collection
|
|
11024
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
11025
|
+
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
11026
|
+
* @returns {Array|Object} Returns `collection`.
|
|
11027
|
+
* @see _.forEachRight
|
|
11028
|
+
* @example
|
|
11029
|
+
*
|
|
11030
|
+
* _.forEach([1, 2], function(value) {
|
|
11031
|
+
* console.log(value);
|
|
11032
|
+
* });
|
|
11033
|
+
* // => Logs `1` then `2`.
|
|
11034
|
+
*
|
|
11035
|
+
* _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
|
|
11036
|
+
* console.log(key);
|
|
11037
|
+
* });
|
|
11038
|
+
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
|
11039
|
+
*/
|
|
11040
|
+
function forEach(collection, iteratee) {
|
|
11041
|
+
var func = isArray$1(collection) ? arrayEach : baseEach$1;
|
|
11042
|
+
return func(collection, castFunction(iteratee));
|
|
11043
|
+
}
|
|
11044
|
+
|
|
11082
11045
|
/**
|
|
11083
11046
|
* Base layer for plugins
|
|
11084
11047
|
* Provide minimal starting core for plugins to work
|
|
@@ -12130,24 +12093,23 @@ const SortingSign = ({ column }) => {
|
|
|
12130
12093
|
/**
|
|
12131
12094
|
* Lifecycle
|
|
12132
12095
|
* 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.
|
|
12133
|
-
*
|
|
12134
|
-
* 2. Method `updateColumnSorting` - Updates the column sorting icon on the grid and the column itself, but the data remains untouched.
|
|
12096
|
+
* 2. @event `beforesourcesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted.
|
|
12135
12097
|
* 3. @event `beforesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted. This event is only called from a column sorting click.
|
|
12136
12098
|
* 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
|
|
12137
12099
|
*
|
|
12138
12100
|
* Note: If you prevent an event, it will not proceed to the subsequent steps.
|
|
12139
12101
|
*/
|
|
12140
12102
|
class SortingPlugin extends BasePlugin {
|
|
12141
|
-
runSorting(order, comparison, ignoreViewportUpdate) {
|
|
12142
|
-
var _a;
|
|
12143
|
-
this.sort(order, comparison, undefined, ignoreViewportUpdate);
|
|
12144
|
-
(_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
12145
|
-
this.sortingPromise = null;
|
|
12146
|
-
}
|
|
12147
12103
|
constructor(revogrid, providers, config) {
|
|
12148
12104
|
super(revogrid, providers);
|
|
12149
12105
|
this.revogrid = revogrid;
|
|
12106
|
+
/**
|
|
12107
|
+
* Delayed sorting promise
|
|
12108
|
+
*/
|
|
12150
12109
|
this.sortingPromise = null;
|
|
12110
|
+
/**
|
|
12111
|
+
* We need to sort only so often
|
|
12112
|
+
*/
|
|
12151
12113
|
this.postponeSort = debounce$1((order, comparison, ignoreViewportUpdate) => this.runSorting(order, comparison, ignoreViewportUpdate), 50);
|
|
12152
12114
|
const setConfig = (cfg) => {
|
|
12153
12115
|
var _a;
|
|
@@ -12158,9 +12120,15 @@ class SortingPlugin extends BasePlugin {
|
|
|
12158
12120
|
sortingFunc[col.prop] = getComparer(col, col.order);
|
|
12159
12121
|
order[col.prop] = col.order;
|
|
12160
12122
|
});
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12123
|
+
if (cfg.additive) {
|
|
12124
|
+
this.sorting = Object.assign(Object.assign({}, this.sorting), order);
|
|
12125
|
+
this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
|
|
12126
|
+
}
|
|
12127
|
+
else {
|
|
12128
|
+
// // set sorting
|
|
12129
|
+
this.sorting = order;
|
|
12130
|
+
this.sortingFunc = sortingFunc;
|
|
12131
|
+
}
|
|
12164
12132
|
}
|
|
12165
12133
|
};
|
|
12166
12134
|
setConfig(config);
|
|
@@ -12169,6 +12137,13 @@ class SortingPlugin extends BasePlugin {
|
|
|
12169
12137
|
setConfig(detail);
|
|
12170
12138
|
this.startSorting(this.sorting, this.sortingFunc);
|
|
12171
12139
|
});
|
|
12140
|
+
this.addEventListener('beforeheaderrender', ({ detail, }) => {
|
|
12141
|
+
var _a;
|
|
12142
|
+
const { data: column } = detail;
|
|
12143
|
+
if (column.sortable) {
|
|
12144
|
+
detail.data = Object.assign(Object.assign({}, column), { order: (_a = this.sorting) === null || _a === void 0 ? void 0 : _a[column.prop] });
|
|
12145
|
+
}
|
|
12146
|
+
});
|
|
12172
12147
|
this.addEventListener('beforeanysource', ({ detail: { type }, }) => {
|
|
12173
12148
|
// if sorting was provided - sort data
|
|
12174
12149
|
if (!!this.sorting && this.sortingFunc) {
|
|
@@ -12202,9 +12177,12 @@ class SortingPlugin extends BasePlugin {
|
|
|
12202
12177
|
if (!((_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.sortable)) {
|
|
12203
12178
|
return;
|
|
12204
12179
|
}
|
|
12205
|
-
this.headerclick(e.detail.column,
|
|
12180
|
+
this.headerclick(e.detail.column, (_d = (_c = e.detail) === null || _c === void 0 ? void 0 : _c.originalEvent) === null || _d === void 0 ? void 0 : _d.shiftKey);
|
|
12206
12181
|
});
|
|
12207
12182
|
}
|
|
12183
|
+
/**
|
|
12184
|
+
* Entry point for sorting, waits for all delayes, registers jobs
|
|
12185
|
+
*/
|
|
12208
12186
|
startSorting(order, sortingFunc, ignoreViewportUpdate) {
|
|
12209
12187
|
if (!this.sortingPromise) {
|
|
12210
12188
|
// add job before render
|
|
@@ -12218,18 +12196,18 @@ class SortingPlugin extends BasePlugin {
|
|
|
12218
12196
|
* Apply sorting to data on header click
|
|
12219
12197
|
* If additive - add to existing sorting, multiple columns can be sorted
|
|
12220
12198
|
*/
|
|
12221
|
-
headerclick(column,
|
|
12222
|
-
var _a, _b;
|
|
12223
|
-
|
|
12199
|
+
headerclick(column, additive) {
|
|
12200
|
+
var _a, _b, _c;
|
|
12201
|
+
const columnProp = column.prop;
|
|
12202
|
+
let order = getNextOrder((_a = this.sorting) === null || _a === void 0 ? void 0 : _a[columnProp]);
|
|
12224
12203
|
const beforeEvent = this.emit('beforesorting', { column, order, additive });
|
|
12225
12204
|
if (beforeEvent.defaultPrevented) {
|
|
12226
12205
|
return;
|
|
12227
12206
|
}
|
|
12228
12207
|
order = beforeEvent.detail.order;
|
|
12229
|
-
const newCol = this.providers.column.updateColumnSorting(beforeEvent.detail.column, index, order, additive);
|
|
12230
12208
|
// apply sort data
|
|
12231
12209
|
const beforeApplyEvent = this.emit('beforesortingapply', {
|
|
12232
|
-
column:
|
|
12210
|
+
column: beforeEvent.detail.column,
|
|
12233
12211
|
order,
|
|
12234
12212
|
additive,
|
|
12235
12213
|
});
|
|
@@ -12243,28 +12221,34 @@ class SortingPlugin extends BasePlugin {
|
|
|
12243
12221
|
this.sorting = Object.assign(Object.assign({}, this.sorting), sorting);
|
|
12244
12222
|
// extend sorting function with new sorting for multiple columns sorting
|
|
12245
12223
|
this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
|
|
12246
|
-
if (
|
|
12247
|
-
delete sorting[
|
|
12248
|
-
delete sortingFunc[
|
|
12224
|
+
if (columnProp in sorting && size$1(sorting) > 1 && order === undefined) {
|
|
12225
|
+
delete sorting[columnProp];
|
|
12226
|
+
delete sortingFunc[columnProp];
|
|
12249
12227
|
}
|
|
12250
12228
|
else {
|
|
12251
|
-
sorting[
|
|
12252
|
-
sortingFunc[
|
|
12229
|
+
sorting[columnProp] = order;
|
|
12230
|
+
sortingFunc[columnProp] = cmp;
|
|
12253
12231
|
}
|
|
12254
12232
|
}
|
|
12255
12233
|
else {
|
|
12256
12234
|
if (order) {
|
|
12257
12235
|
// reset sorting
|
|
12258
|
-
this.sorting = { [
|
|
12259
|
-
this.sortingFunc = { [
|
|
12236
|
+
this.sorting = { [columnProp]: order };
|
|
12237
|
+
this.sortingFunc = { [columnProp]: cmp };
|
|
12260
12238
|
}
|
|
12261
12239
|
else {
|
|
12262
|
-
(
|
|
12263
|
-
(
|
|
12240
|
+
(_b = this.sorting) === null || _b === void 0 ? true : delete _b[columnProp];
|
|
12241
|
+
(_c = this.sortingFunc) === null || _c === void 0 ? true : delete _c[columnProp];
|
|
12264
12242
|
}
|
|
12265
12243
|
}
|
|
12266
12244
|
this.startSorting(this.sorting, this.sortingFunc);
|
|
12267
12245
|
}
|
|
12246
|
+
runSorting(order, comparison, ignoreViewportUpdate) {
|
|
12247
|
+
var _a;
|
|
12248
|
+
this.sort(order, comparison, undefined, ignoreViewportUpdate);
|
|
12249
|
+
(_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
12250
|
+
this.sortingPromise = null;
|
|
12251
|
+
}
|
|
12268
12252
|
/**
|
|
12269
12253
|
* Sort items by sorting function
|
|
12270
12254
|
* @requires proxyItems applied to row store
|
|
@@ -12310,6 +12294,10 @@ class SortingPlugin extends BasePlugin {
|
|
|
12310
12294
|
}
|
|
12311
12295
|
}
|
|
12312
12296
|
}
|
|
12297
|
+
// refresh columns to redraw column headers and show correct icon
|
|
12298
|
+
columnTypes.forEach((type) => {
|
|
12299
|
+
this.providers.column.dataSources[type].refresh();
|
|
12300
|
+
});
|
|
12313
12301
|
this.emit('aftersortingapply');
|
|
12314
12302
|
}
|
|
12315
12303
|
}
|
|
@@ -14568,25 +14556,29 @@ class RevoGridComponent {
|
|
|
14568
14556
|
}
|
|
14569
14557
|
/**
|
|
14570
14558
|
* Update column sorting
|
|
14571
|
-
* @param column -
|
|
14572
|
-
* @param index - virtual column index
|
|
14559
|
+
* @param column - column prop and cellCompare
|
|
14573
14560
|
* @param order - order to apply
|
|
14574
14561
|
* @param additive - if false will replace current order
|
|
14562
|
+
*
|
|
14563
|
+
* later passed to SortingPlugin
|
|
14575
14564
|
*/
|
|
14576
|
-
async updateColumnSorting(column,
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14565
|
+
async updateColumnSorting(column, order, additive) {
|
|
14566
|
+
this.sortingconfigchanged.emit({
|
|
14567
|
+
columns: [{
|
|
14568
|
+
prop: column.prop,
|
|
14569
|
+
order,
|
|
14570
|
+
cellCompare: column.cellCompare,
|
|
14571
|
+
}],
|
|
14572
|
+
additive,
|
|
14573
|
+
});
|
|
14581
14574
|
}
|
|
14582
14575
|
/**
|
|
14583
14576
|
* Clears column sorting
|
|
14584
14577
|
*/
|
|
14585
14578
|
async clearSorting() {
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
}
|
|
14589
|
-
this.columnProvider.clearSorting();
|
|
14579
|
+
this.sortingconfigchanged.emit({
|
|
14580
|
+
columns: [],
|
|
14581
|
+
});
|
|
14590
14582
|
}
|
|
14591
14583
|
/**
|
|
14592
14584
|
* Receive all columns in data source
|
|
@@ -14794,7 +14786,10 @@ class RevoGridComponent {
|
|
|
14794
14786
|
const columns = this.columnProvider.setColumns(beforeApplyEvent.detail);
|
|
14795
14787
|
this.aftercolumnsset.emit({
|
|
14796
14788
|
columns,
|
|
14797
|
-
order:
|
|
14789
|
+
order: Object.entries(beforeApplyEvent.detail.sort).reduce((acc, [prop, column]) => {
|
|
14790
|
+
acc[prop] = column.order;
|
|
14791
|
+
return acc;
|
|
14792
|
+
}, {}),
|
|
14798
14793
|
});
|
|
14799
14794
|
}
|
|
14800
14795
|
disableVirtualXChanged(newVal = false, prevVal = false) {
|