@revolist/revogrid 4.13.2 → 4.13.3
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-0f367fe1.js → column.drag.plugin-b3483e65.js} +48 -38
- package/dist/cjs/column.drag.plugin-b3483e65.js.map +1 -0
- package/dist/cjs/index.cjs.js +5 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +1 -1
- package/dist/collection/plugins/sorting/sorting.func.js +40 -0
- package/dist/collection/plugins/sorting/sorting.func.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.plugin.js +6 -39
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
- package/dist/{revo-grid/column.drag.plugin-d201beb7.js → esm/column.drag.plugin-da99fde5.js} +46 -40
- package/dist/esm/column.drag.plugin-da99fde5.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/revo-grid.entry.js +1 -1
- package/dist/{esm/column.drag.plugin-d201beb7.js → revo-grid/column.drag.plugin-da99fde5.js} +46 -40
- package/dist/revo-grid/column.drag.plugin-da99fde5.js.map +1 -0
- package/dist/revo-grid/index.esm.js +2 -2
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/types/plugins/sorting/sorting.func.d.ts +7 -1
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +1 -7
- package/hydrate/index.js +43 -37
- package/hydrate/index.mjs +43 -37
- package/package.json +1 -1
- package/standalone/index.js +1 -1
- package/standalone/revo-grid.js +45 -39
- package/standalone/revo-grid.js.map +1 -1
- package/dist/cjs/column.drag.plugin-0f367fe1.js.map +0 -1
- package/dist/esm/column.drag.plugin-d201beb7.js.map +0 -1
- package/dist/revo-grid/column.drag.plugin-d201beb7.js.map +0 -1
package/hydrate/index.js
CHANGED
|
@@ -12071,6 +12071,45 @@ function sortIndexByItems(indexes, source, sortingFunc = {}) {
|
|
|
12071
12071
|
return 0;
|
|
12072
12072
|
});
|
|
12073
12073
|
}
|
|
12074
|
+
function defaultCellCompare(prop, a, b) {
|
|
12075
|
+
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
12076
|
+
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
12077
|
+
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
12078
|
+
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
12079
|
+
if (av === bv) {
|
|
12080
|
+
return 0;
|
|
12081
|
+
}
|
|
12082
|
+
if (av > bv) {
|
|
12083
|
+
return 1;
|
|
12084
|
+
}
|
|
12085
|
+
return -1;
|
|
12086
|
+
}
|
|
12087
|
+
function descCellCompare(cmp) {
|
|
12088
|
+
return (prop, a, b) => {
|
|
12089
|
+
return -1 * cmp(prop, a, b);
|
|
12090
|
+
};
|
|
12091
|
+
}
|
|
12092
|
+
function getNextOrder(currentOrder) {
|
|
12093
|
+
switch (currentOrder) {
|
|
12094
|
+
case undefined:
|
|
12095
|
+
return 'asc';
|
|
12096
|
+
case 'asc':
|
|
12097
|
+
return 'desc';
|
|
12098
|
+
case 'desc':
|
|
12099
|
+
return undefined;
|
|
12100
|
+
}
|
|
12101
|
+
}
|
|
12102
|
+
function getComparer(column, order) {
|
|
12103
|
+
var _a;
|
|
12104
|
+
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || (defaultCellCompare === null || defaultCellCompare === void 0 ? void 0 : defaultCellCompare.bind({ column, order }));
|
|
12105
|
+
if (order == 'asc') {
|
|
12106
|
+
return cellCmp;
|
|
12107
|
+
}
|
|
12108
|
+
if (order == 'desc') {
|
|
12109
|
+
return descCellCompare(cellCmp);
|
|
12110
|
+
}
|
|
12111
|
+
return undefined;
|
|
12112
|
+
}
|
|
12074
12113
|
|
|
12075
12114
|
const SortingSign = ({ column }) => {
|
|
12076
12115
|
var _a;
|
|
@@ -12105,7 +12144,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12105
12144
|
const sortingFunc = {};
|
|
12106
12145
|
const order = {};
|
|
12107
12146
|
(_a = cfg.columns) === null || _a === void 0 ? void 0 : _a.forEach(col => {
|
|
12108
|
-
sortingFunc[col.prop] =
|
|
12147
|
+
sortingFunc[col.prop] = getComparer(col, col.order);
|
|
12109
12148
|
order[col.prop] = col.order;
|
|
12110
12149
|
});
|
|
12111
12150
|
// // set sorting
|
|
@@ -12137,7 +12176,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12137
12176
|
const columns = this.providers.column.getColumns();
|
|
12138
12177
|
const sortingFunc = {};
|
|
12139
12178
|
for (let prop in order) {
|
|
12140
|
-
const cmp =
|
|
12179
|
+
const cmp = getComparer(getColumnByProp(columns, prop), order[prop]);
|
|
12141
12180
|
sortingFunc[prop] = cmp;
|
|
12142
12181
|
}
|
|
12143
12182
|
// set sorting
|
|
@@ -12164,24 +12203,13 @@ class SortingPlugin extends BasePlugin {
|
|
|
12164
12203
|
}
|
|
12165
12204
|
this.postponeSort(order, sortingFunc, ignoreViewportUpdate);
|
|
12166
12205
|
}
|
|
12167
|
-
getComparer(column, order) {
|
|
12168
|
-
var _a, _b;
|
|
12169
|
-
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || ((_b = this.defaultCellCompare) === null || _b === void 0 ? void 0 : _b.bind({ column, order }));
|
|
12170
|
-
if (order == 'asc') {
|
|
12171
|
-
return cellCmp;
|
|
12172
|
-
}
|
|
12173
|
-
if (order == 'desc') {
|
|
12174
|
-
return this.descCellCompare(cellCmp);
|
|
12175
|
-
}
|
|
12176
|
-
return undefined;
|
|
12177
|
-
}
|
|
12178
12206
|
/**
|
|
12179
12207
|
* Apply sorting to data on header click
|
|
12180
12208
|
* If additive - add to existing sorting, multiple columns can be sorted
|
|
12181
12209
|
*/
|
|
12182
12210
|
headerclick(column, index, additive) {
|
|
12183
12211
|
var _a, _b;
|
|
12184
|
-
let order =
|
|
12212
|
+
let order = getNextOrder(column.order);
|
|
12185
12213
|
const beforeEvent = this.emit('beforesorting', { column, order, additive });
|
|
12186
12214
|
if (beforeEvent.defaultPrevented) {
|
|
12187
12215
|
return;
|
|
@@ -12197,7 +12225,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12197
12225
|
if (beforeApplyEvent.defaultPrevented) {
|
|
12198
12226
|
return;
|
|
12199
12227
|
}
|
|
12200
|
-
const cmp =
|
|
12228
|
+
const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);
|
|
12201
12229
|
if (beforeApplyEvent.detail.additive && this.sorting) {
|
|
12202
12230
|
const sorting = {};
|
|
12203
12231
|
const sortingFunc = {};
|
|
@@ -12273,28 +12301,6 @@ class SortingPlugin extends BasePlugin {
|
|
|
12273
12301
|
}
|
|
12274
12302
|
this.emit('aftersortingapply');
|
|
12275
12303
|
}
|
|
12276
|
-
defaultCellCompare(prop, a, b) {
|
|
12277
|
-
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
12278
|
-
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
12279
|
-
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
12280
|
-
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
12281
|
-
return av == bv ? 0 : av > bv ? 1 : -1;
|
|
12282
|
-
}
|
|
12283
|
-
descCellCompare(cmp) {
|
|
12284
|
-
return (prop, a, b) => {
|
|
12285
|
-
return -1 * cmp(prop, a, b);
|
|
12286
|
-
};
|
|
12287
|
-
}
|
|
12288
|
-
getNextOrder(currentOrder) {
|
|
12289
|
-
switch (currentOrder) {
|
|
12290
|
-
case undefined:
|
|
12291
|
-
return 'asc';
|
|
12292
|
-
case 'asc':
|
|
12293
|
-
return 'desc';
|
|
12294
|
-
case 'desc':
|
|
12295
|
-
return undefined;
|
|
12296
|
-
}
|
|
12297
|
-
}
|
|
12298
12304
|
}
|
|
12299
12305
|
|
|
12300
12306
|
/**
|
package/hydrate/index.mjs
CHANGED
|
@@ -12067,6 +12067,45 @@ function sortIndexByItems(indexes, source, sortingFunc = {}) {
|
|
|
12067
12067
|
return 0;
|
|
12068
12068
|
});
|
|
12069
12069
|
}
|
|
12070
|
+
function defaultCellCompare(prop, a, b) {
|
|
12071
|
+
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
12072
|
+
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
12073
|
+
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
12074
|
+
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
12075
|
+
if (av === bv) {
|
|
12076
|
+
return 0;
|
|
12077
|
+
}
|
|
12078
|
+
if (av > bv) {
|
|
12079
|
+
return 1;
|
|
12080
|
+
}
|
|
12081
|
+
return -1;
|
|
12082
|
+
}
|
|
12083
|
+
function descCellCompare(cmp) {
|
|
12084
|
+
return (prop, a, b) => {
|
|
12085
|
+
return -1 * cmp(prop, a, b);
|
|
12086
|
+
};
|
|
12087
|
+
}
|
|
12088
|
+
function getNextOrder(currentOrder) {
|
|
12089
|
+
switch (currentOrder) {
|
|
12090
|
+
case undefined:
|
|
12091
|
+
return 'asc';
|
|
12092
|
+
case 'asc':
|
|
12093
|
+
return 'desc';
|
|
12094
|
+
case 'desc':
|
|
12095
|
+
return undefined;
|
|
12096
|
+
}
|
|
12097
|
+
}
|
|
12098
|
+
function getComparer(column, order) {
|
|
12099
|
+
var _a;
|
|
12100
|
+
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || (defaultCellCompare === null || defaultCellCompare === void 0 ? void 0 : defaultCellCompare.bind({ column, order }));
|
|
12101
|
+
if (order == 'asc') {
|
|
12102
|
+
return cellCmp;
|
|
12103
|
+
}
|
|
12104
|
+
if (order == 'desc') {
|
|
12105
|
+
return descCellCompare(cellCmp);
|
|
12106
|
+
}
|
|
12107
|
+
return undefined;
|
|
12108
|
+
}
|
|
12070
12109
|
|
|
12071
12110
|
const SortingSign = ({ column }) => {
|
|
12072
12111
|
var _a;
|
|
@@ -12101,7 +12140,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12101
12140
|
const sortingFunc = {};
|
|
12102
12141
|
const order = {};
|
|
12103
12142
|
(_a = cfg.columns) === null || _a === void 0 ? void 0 : _a.forEach(col => {
|
|
12104
|
-
sortingFunc[col.prop] =
|
|
12143
|
+
sortingFunc[col.prop] = getComparer(col, col.order);
|
|
12105
12144
|
order[col.prop] = col.order;
|
|
12106
12145
|
});
|
|
12107
12146
|
// // set sorting
|
|
@@ -12133,7 +12172,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12133
12172
|
const columns = this.providers.column.getColumns();
|
|
12134
12173
|
const sortingFunc = {};
|
|
12135
12174
|
for (let prop in order) {
|
|
12136
|
-
const cmp =
|
|
12175
|
+
const cmp = getComparer(getColumnByProp(columns, prop), order[prop]);
|
|
12137
12176
|
sortingFunc[prop] = cmp;
|
|
12138
12177
|
}
|
|
12139
12178
|
// set sorting
|
|
@@ -12160,24 +12199,13 @@ class SortingPlugin extends BasePlugin {
|
|
|
12160
12199
|
}
|
|
12161
12200
|
this.postponeSort(order, sortingFunc, ignoreViewportUpdate);
|
|
12162
12201
|
}
|
|
12163
|
-
getComparer(column, order) {
|
|
12164
|
-
var _a, _b;
|
|
12165
|
-
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || ((_b = this.defaultCellCompare) === null || _b === void 0 ? void 0 : _b.bind({ column, order }));
|
|
12166
|
-
if (order == 'asc') {
|
|
12167
|
-
return cellCmp;
|
|
12168
|
-
}
|
|
12169
|
-
if (order == 'desc') {
|
|
12170
|
-
return this.descCellCompare(cellCmp);
|
|
12171
|
-
}
|
|
12172
|
-
return undefined;
|
|
12173
|
-
}
|
|
12174
12202
|
/**
|
|
12175
12203
|
* Apply sorting to data on header click
|
|
12176
12204
|
* If additive - add to existing sorting, multiple columns can be sorted
|
|
12177
12205
|
*/
|
|
12178
12206
|
headerclick(column, index, additive) {
|
|
12179
12207
|
var _a, _b;
|
|
12180
|
-
let order =
|
|
12208
|
+
let order = getNextOrder(column.order);
|
|
12181
12209
|
const beforeEvent = this.emit('beforesorting', { column, order, additive });
|
|
12182
12210
|
if (beforeEvent.defaultPrevented) {
|
|
12183
12211
|
return;
|
|
@@ -12193,7 +12221,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
12193
12221
|
if (beforeApplyEvent.defaultPrevented) {
|
|
12194
12222
|
return;
|
|
12195
12223
|
}
|
|
12196
|
-
const cmp =
|
|
12224
|
+
const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);
|
|
12197
12225
|
if (beforeApplyEvent.detail.additive && this.sorting) {
|
|
12198
12226
|
const sorting = {};
|
|
12199
12227
|
const sortingFunc = {};
|
|
@@ -12269,28 +12297,6 @@ class SortingPlugin extends BasePlugin {
|
|
|
12269
12297
|
}
|
|
12270
12298
|
this.emit('aftersortingapply');
|
|
12271
12299
|
}
|
|
12272
|
-
defaultCellCompare(prop, a, b) {
|
|
12273
|
-
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
12274
|
-
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
12275
|
-
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
12276
|
-
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
12277
|
-
return av == bv ? 0 : av > bv ? 1 : -1;
|
|
12278
|
-
}
|
|
12279
|
-
descCellCompare(cmp) {
|
|
12280
|
-
return (prop, a, b) => {
|
|
12281
|
-
return -1 * cmp(prop, a, b);
|
|
12282
|
-
};
|
|
12283
|
-
}
|
|
12284
|
-
getNextOrder(currentOrder) {
|
|
12285
|
-
switch (currentOrder) {
|
|
12286
|
-
case undefined:
|
|
12287
|
-
return 'asc';
|
|
12288
|
-
case 'asc':
|
|
12289
|
-
return 'desc';
|
|
12290
|
-
case 'desc':
|
|
12291
|
-
return undefined;
|
|
12292
|
-
}
|
|
12293
|
-
}
|
|
12294
12300
|
}
|
|
12295
12301
|
|
|
12296
12302
|
/**
|
package/package.json
CHANGED
package/standalone/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { setMode } from '@stencil/core/internal/client';
|
|
5
5
|
export { getAssetPath, h, setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
|
|
6
6
|
import { g as getTheme, B as BasePlugin } from './revo-grid.js';
|
|
7
|
-
export { A as AutoSizeColumnPlugin, B as BasePlugin, C as ColumnMovePlugin, D as DimensionStore, b as ExportCsv, E as ExportFilePlugin, d as FILTER_CONFIG_CHANGED_EVENT, F as FILTER_TRIMMED_TYPE, e as FILTE_PANEL, f as FilterPlugin, G as GroupingRowPlugin, RevoGrid, o as SortingPlugin, S as StretchColumn, c as columnTypes, defineCustomElement as defineCustomElementRevoGrid, l as doCollapse, m as doExpand, h as filterCoreFunctionsIndexedByType, k as filterNames, j as filterTypes, n as getLeftRelative, i as isRowType, a as isStretchPlugin, r as rowTypes, s as sortIndexByItems } from './revo-grid.js';
|
|
7
|
+
export { A as AutoSizeColumnPlugin, B as BasePlugin, C as ColumnMovePlugin, D as DimensionStore, b as ExportCsv, E as ExportFilePlugin, d as FILTER_CONFIG_CHANGED_EVENT, F as FILTER_TRIMMED_TYPE, e as FILTE_PANEL, f as FilterPlugin, G as GroupingRowPlugin, RevoGrid, o as SortingPlugin, S as StretchColumn, c as columnTypes, p as defaultCellCompare, defineCustomElement as defineCustomElementRevoGrid, q as descCellCompare, l as doCollapse, m as doExpand, h as filterCoreFunctionsIndexedByType, k as filterNames, j as filterTypes, u as getComparer, n as getLeftRelative, t as getNextOrder, i as isRowType, a as isStretchPlugin, r as rowTypes, s as sortIndexByItems } from './revo-grid.js';
|
|
8
8
|
export { S as SortingSign, d as dispatch, a as dispatchByEvent } from './revogr-header2.js';
|
|
9
9
|
export { C as CELL_CLASS, j as CELL_HANDLER_CLASS, D as DATA_COL, a as DATA_ROW, b as DISABLED_CLASS, h as DRAGGABLE_CLASS, k as DRAGG_TEXT, g as DRAG_ICON_CLASS, E as EDIT_INPUT_WR, F as FOCUS_CLASS, G as GRID_INTERNALS, f as HEADER_ACTUAL_ROW_CLASS, H as HEADER_CLASS, e as HEADER_ROW_CLASS, d as HEADER_SORTABLE_CLASS, M as MIN_COL_SIZE, i as MOBILE_CLASS, R as RESIZE_INTERVAL, l as ROW_FOCUSED_CLASS, c as ROW_HEADER_TYPE, S as SELECTION_BORDER_CLASS, T as TMP_SELECTION_BG_CLASS } from './consts.js';
|
|
10
10
|
export { a as applyMixins, f as findPositionInArray, g as getScrollbarSize, m as mergeSortedArray, p as pushSorted, r as range, s as scaleValue, t as timeout } from './index2.js';
|
package/standalone/revo-grid.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
4
|
import { h, proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, Host } from '@stencil/core/internal/client';
|
|
5
|
-
import { H as reduce, I as baseEach, A as getColumnType, s as isGrouping, r as getGroupingName, z as getCellDataParsed,
|
|
5
|
+
import { H as reduce, I as baseEach, A as getColumnType, s as isGrouping, r as getGroupingName, z as getCellDataParsed, y as getCellRaw, F as getColumnByProp, f as GROUP_EXPANDED, v as getParsedGroup, b as PSEUDO_GROUP_ITEM_ID, w as isSameGroup, G as GROUP_DEPTH, d as PSEUDO_GROUP_ITEM_VALUE, m as GROUPING_ROW_TYPE, o as getSource, e as PSEUDO_GROUP_COLUMN, q as gatherGrouping, t as isGroupingColumn, p as getExpanded, C as isColGrouping, B as getColumnSizes, J as EMPTY_INDEX, D as getColumns, K as SelectionStoreConnector } from './column.service.js';
|
|
6
6
|
import './platform.js';
|
|
7
7
|
import { j as createStore, i as setStore, k as identity, l as isArray, b as getSourceItem, m as toInteger, n as isIterateeCall, o as baseProperty, q as isArrayLike, r as getTag, u as baseKeys, g as getPhysical, e as setItems, D as DataStore, f as getSourceItemVirtualIndexByProp, d as setSourceByPhysicalIndex, s as setSourceByVirtualIndex, a as getVisibleSourceItem, h as gatherTrimmedItems } from './data.store.js';
|
|
8
8
|
import { d as debounce } from './debounce.js';
|
|
@@ -1803,6 +1803,45 @@ function sortIndexByItems(indexes, source, sortingFunc = {}) {
|
|
|
1803
1803
|
return 0;
|
|
1804
1804
|
});
|
|
1805
1805
|
}
|
|
1806
|
+
function defaultCellCompare(prop, a, b) {
|
|
1807
|
+
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
1808
|
+
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
1809
|
+
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
1810
|
+
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
1811
|
+
if (av === bv) {
|
|
1812
|
+
return 0;
|
|
1813
|
+
}
|
|
1814
|
+
if (av > bv) {
|
|
1815
|
+
return 1;
|
|
1816
|
+
}
|
|
1817
|
+
return -1;
|
|
1818
|
+
}
|
|
1819
|
+
function descCellCompare(cmp) {
|
|
1820
|
+
return (prop, a, b) => {
|
|
1821
|
+
return -1 * cmp(prop, a, b);
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
function getNextOrder(currentOrder) {
|
|
1825
|
+
switch (currentOrder) {
|
|
1826
|
+
case undefined:
|
|
1827
|
+
return 'asc';
|
|
1828
|
+
case 'asc':
|
|
1829
|
+
return 'desc';
|
|
1830
|
+
case 'desc':
|
|
1831
|
+
return undefined;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function getComparer(column, order) {
|
|
1835
|
+
var _a;
|
|
1836
|
+
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || (defaultCellCompare === null || defaultCellCompare === void 0 ? void 0 : defaultCellCompare.bind({ column, order }));
|
|
1837
|
+
if (order == 'asc') {
|
|
1838
|
+
return cellCmp;
|
|
1839
|
+
}
|
|
1840
|
+
if (order == 'desc') {
|
|
1841
|
+
return descCellCompare(cellCmp);
|
|
1842
|
+
}
|
|
1843
|
+
return undefined;
|
|
1844
|
+
}
|
|
1806
1845
|
|
|
1807
1846
|
/**
|
|
1808
1847
|
* Lifecycle
|
|
@@ -1832,7 +1871,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
1832
1871
|
const sortingFunc = {};
|
|
1833
1872
|
const order = {};
|
|
1834
1873
|
(_a = cfg.columns) === null || _a === void 0 ? void 0 : _a.forEach(col => {
|
|
1835
|
-
sortingFunc[col.prop] =
|
|
1874
|
+
sortingFunc[col.prop] = getComparer(col, col.order);
|
|
1836
1875
|
order[col.prop] = col.order;
|
|
1837
1876
|
});
|
|
1838
1877
|
// // set sorting
|
|
@@ -1864,7 +1903,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
1864
1903
|
const columns = this.providers.column.getColumns();
|
|
1865
1904
|
const sortingFunc = {};
|
|
1866
1905
|
for (let prop in order) {
|
|
1867
|
-
const cmp =
|
|
1906
|
+
const cmp = getComparer(getColumnByProp(columns, prop), order[prop]);
|
|
1868
1907
|
sortingFunc[prop] = cmp;
|
|
1869
1908
|
}
|
|
1870
1909
|
// set sorting
|
|
@@ -1891,24 +1930,13 @@ class SortingPlugin extends BasePlugin {
|
|
|
1891
1930
|
}
|
|
1892
1931
|
this.postponeSort(order, sortingFunc, ignoreViewportUpdate);
|
|
1893
1932
|
}
|
|
1894
|
-
getComparer(column, order) {
|
|
1895
|
-
var _a, _b;
|
|
1896
|
-
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || ((_b = this.defaultCellCompare) === null || _b === void 0 ? void 0 : _b.bind({ column, order }));
|
|
1897
|
-
if (order == 'asc') {
|
|
1898
|
-
return cellCmp;
|
|
1899
|
-
}
|
|
1900
|
-
if (order == 'desc') {
|
|
1901
|
-
return this.descCellCompare(cellCmp);
|
|
1902
|
-
}
|
|
1903
|
-
return undefined;
|
|
1904
|
-
}
|
|
1905
1933
|
/**
|
|
1906
1934
|
* Apply sorting to data on header click
|
|
1907
1935
|
* If additive - add to existing sorting, multiple columns can be sorted
|
|
1908
1936
|
*/
|
|
1909
1937
|
headerclick(column, index, additive) {
|
|
1910
1938
|
var _a, _b;
|
|
1911
|
-
let order =
|
|
1939
|
+
let order = getNextOrder(column.order);
|
|
1912
1940
|
const beforeEvent = this.emit('beforesorting', { column, order, additive });
|
|
1913
1941
|
if (beforeEvent.defaultPrevented) {
|
|
1914
1942
|
return;
|
|
@@ -1924,7 +1952,7 @@ class SortingPlugin extends BasePlugin {
|
|
|
1924
1952
|
if (beforeApplyEvent.defaultPrevented) {
|
|
1925
1953
|
return;
|
|
1926
1954
|
}
|
|
1927
|
-
const cmp =
|
|
1955
|
+
const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);
|
|
1928
1956
|
if (beforeApplyEvent.detail.additive && this.sorting) {
|
|
1929
1957
|
const sorting = {};
|
|
1930
1958
|
const sortingFunc = {};
|
|
@@ -2000,28 +2028,6 @@ class SortingPlugin extends BasePlugin {
|
|
|
2000
2028
|
}
|
|
2001
2029
|
this.emit('aftersortingapply');
|
|
2002
2030
|
}
|
|
2003
|
-
defaultCellCompare(prop, a, b) {
|
|
2004
|
-
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
2005
|
-
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
2006
|
-
const av = aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
2007
|
-
const bv = bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
2008
|
-
return av == bv ? 0 : av > bv ? 1 : -1;
|
|
2009
|
-
}
|
|
2010
|
-
descCellCompare(cmp) {
|
|
2011
|
-
return (prop, a, b) => {
|
|
2012
|
-
return -1 * cmp(prop, a, b);
|
|
2013
|
-
};
|
|
2014
|
-
}
|
|
2015
|
-
getNextOrder(currentOrder) {
|
|
2016
|
-
switch (currentOrder) {
|
|
2017
|
-
case undefined:
|
|
2018
|
-
return 'asc';
|
|
2019
|
-
case 'asc':
|
|
2020
|
-
return 'desc';
|
|
2021
|
-
case 'desc':
|
|
2022
|
-
return undefined;
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
2031
|
}
|
|
2026
2032
|
|
|
2027
2033
|
// provide collapse data
|
|
@@ -4633,6 +4639,6 @@ function defineCustomElement$1() {
|
|
|
4633
4639
|
const RevoGrid = RevoGridComponent;
|
|
4634
4640
|
const defineCustomElement = defineCustomElement$1;
|
|
4635
4641
|
|
|
4636
|
-
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnMovePlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, RevoGrid, StretchColumn as S, isStretchPlugin as a, ExportCsv as b, columnTypes as c, FILTER_CONFIG_CHANGED_EVENT as d, defineCustomElement, FILTE_PANEL as e, FilterPlugin as f, getTheme as g, filterCoreFunctionsIndexedByType as h, isRowType as i, filterTypes as j, filterNames as k, doCollapse as l, doExpand as m, getLeftRelative as n, SortingPlugin as o, rowTypes as r, sortIndexByItems as s };
|
|
4642
|
+
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnMovePlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, RevoGrid, StretchColumn as S, isStretchPlugin as a, ExportCsv as b, columnTypes as c, FILTER_CONFIG_CHANGED_EVENT as d, defineCustomElement, FILTE_PANEL as e, FilterPlugin as f, getTheme as g, filterCoreFunctionsIndexedByType as h, isRowType as i, filterTypes as j, filterNames as k, doCollapse as l, doExpand as m, getLeftRelative as n, SortingPlugin as o, defaultCellCompare as p, descCellCompare as q, rowTypes as r, sortIndexByItems as s, getNextOrder as t, getComparer as u };
|
|
4637
4643
|
|
|
4638
4644
|
//# sourceMappingURL=revo-grid.js.map
|