@rivet-health/design-system 40.27.2 → 40.28.0
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/esm2020/lib/table/simple-table/simple-table.component.mjs +3 -2
- package/esm2020/lib/table/table/state-helpers/column-helpers.mjs +255 -0
- package/esm2020/lib/table/table/state-helpers/display-helpers.mjs +48 -0
- package/esm2020/lib/table/table/state-helpers/order-helpers.mjs +143 -0
- package/esm2020/lib/table/table/state-helpers/pagination-helpers.mjs +174 -0
- package/esm2020/lib/table/table/state-helpers/result-helpers.mjs +77 -0
- package/esm2020/lib/table/table/state-helpers/search-helpers.mjs +28 -0
- package/esm2020/lib/table/table/state-helpers/selection-helpers.mjs +180 -0
- package/esm2020/lib/table/table/state.mjs +73 -631
- package/esm2020/lib/table/table/table-header-resize-handle/table-header-resize-handle.component.mjs +4 -4
- package/fesm2015/rivet-health-design-system.mjs +821 -513
- package/fesm2015/rivet-health-design-system.mjs.map +1 -1
- package/fesm2020/rivet-health-design-system.mjs +962 -633
- package/fesm2020/rivet-health-design-system.mjs.map +1 -1
- package/lib/table/table/state-helpers/column-helpers.d.ts +14 -0
- package/lib/table/table/state-helpers/display-helpers.d.ts +5 -0
- package/lib/table/table/state-helpers/order-helpers.d.ts +12 -0
- package/lib/table/table/state-helpers/pagination-helpers.d.ts +13 -0
- package/lib/table/table/state-helpers/result-helpers.d.ts +11 -0
- package/lib/table/table/state-helpers/search-helpers.d.ts +5 -0
- package/lib/table/table/state-helpers/selection-helpers.d.ts +13 -0
- package/lib/table/table/state.d.ts +48 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { DOCUMENT, DatePipe as DatePipe$1, DecimalPipe, CurrencyPipe, PercentPip
|
|
|
6
6
|
import { BehaviorSubject, Subject, merge, scan, startWith, connectable, map, ReplaySubject, distinctUntilChanged, skip, filter, combineLatest, shareReplay, skipUntil, mergeScan, from, share, fromEvent, tap, switchMap, takeUntil, concatWith, of } from 'rxjs';
|
|
7
7
|
import { timeYears, timeYear, timeMonths, timeMonth, timeDays, timeDay, timeSunday, timeWeek, utcYear, utcMonth, utcWeek, utcDay } from 'd3-time';
|
|
8
8
|
import { timeFormat, utcFormat } from 'd3-time-format';
|
|
9
|
-
import { defaultsDeep, sortBy, isNumber, flattenDeep, debounce, isEqual, uniqueId, cloneDeep,
|
|
9
|
+
import { defaultsDeep, sortBy, isNumber, flattenDeep, debounce, isEqual, uniqueId, cloneDeep, difference, toInteger, orderBy, range, union, sumBy, sum, uniq } from 'lodash';
|
|
10
10
|
import Fuse from 'fuse.js';
|
|
11
11
|
import { query, style, animate, trigger, transition, group } from '@angular/animations';
|
|
12
12
|
import { map as map$1, distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs/operators';
|
|
@@ -8095,6 +8095,784 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
8095
8095
|
args: ['class.selected']
|
|
8096
8096
|
}] } });
|
|
8097
8097
|
|
|
8098
|
+
var TableColumnHelpers;
|
|
8099
|
+
(function (TableColumnHelpers) {
|
|
8100
|
+
function getColumnAlignment(dataType, isFirst) {
|
|
8101
|
+
if (isFirst)
|
|
8102
|
+
return 'left';
|
|
8103
|
+
switch (dataType) {
|
|
8104
|
+
case 'date':
|
|
8105
|
+
case 'longText':
|
|
8106
|
+
return 'left';
|
|
8107
|
+
case 'advanced':
|
|
8108
|
+
case 'icon':
|
|
8109
|
+
case 'shortText':
|
|
8110
|
+
return 'center';
|
|
8111
|
+
case 'currency':
|
|
8112
|
+
case 'number':
|
|
8113
|
+
return 'right';
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
TableColumnHelpers.getColumnAlignment = getColumnAlignment;
|
|
8117
|
+
function getAllColumns(state, supportedColumns, columnNameMap) {
|
|
8118
|
+
// If the table offers more columns than the user has configuration settings
|
|
8119
|
+
// for (or if the user has no configuration settings yet), we'll append them
|
|
8120
|
+
// to the end (unless they should be pinned by default, in which case we'll
|
|
8121
|
+
// append them after the other pinned columns). This ensures that new columns
|
|
8122
|
+
// we add to existing tables over time (1) get displayed even though they
|
|
8123
|
+
// don't appear in the user's configuration settings yet, and (2) don't
|
|
8124
|
+
// interrupt their existing setup.
|
|
8125
|
+
const columnNamesWithoutUserSettings = difference([...supportedColumns.keys()], state.display.columnSettings.map(({ key }) => key));
|
|
8126
|
+
// Throw out settings for columns no longer offered by the table.
|
|
8127
|
+
const columnsWithUserSettings = state.display.columnSettings.filter(({ key }) => supportedColumns.has(key));
|
|
8128
|
+
const columnsWithoutUserSettings = [
|
|
8129
|
+
...columnNamesWithoutUserSettings,
|
|
8130
|
+
].map((key) => {
|
|
8131
|
+
var _a;
|
|
8132
|
+
return ({
|
|
8133
|
+
key,
|
|
8134
|
+
enabled: true,
|
|
8135
|
+
preferredWidth: 'auto',
|
|
8136
|
+
pinned: !!((_a = supportedColumns.get(key)) === null || _a === void 0 ? void 0 : _a.defaultPinned),
|
|
8137
|
+
});
|
|
8138
|
+
});
|
|
8139
|
+
return orderIntentionally([...columnsWithUserSettings, ...columnsWithoutUserSettings], columnNameMap);
|
|
8140
|
+
}
|
|
8141
|
+
TableColumnHelpers.getAllColumns = getAllColumns;
|
|
8142
|
+
function orderIntentionally(columns, columnNameMap) {
|
|
8143
|
+
return [
|
|
8144
|
+
...columns.filter(v => v.pinned),
|
|
8145
|
+
...columns.filter(v => v.enabled && !v.pinned),
|
|
8146
|
+
...columns
|
|
8147
|
+
.filter(v => !v.enabled && !v.pinned)
|
|
8148
|
+
.sort((a, b) => {
|
|
8149
|
+
var _a, _b;
|
|
8150
|
+
const aName = (_a = columnNameMap.get(a.key)) !== null && _a !== void 0 ? _a : a.key;
|
|
8151
|
+
const bName = (_b = columnNameMap.get(b.key)) !== null && _b !== void 0 ? _b : b.key;
|
|
8152
|
+
return aName.localeCompare(bName);
|
|
8153
|
+
}),
|
|
8154
|
+
];
|
|
8155
|
+
}
|
|
8156
|
+
function getAlignment(metadata, index, allowSelection) {
|
|
8157
|
+
return getColumnAlignment(metadata.dataType, index === 0 && !allowSelection);
|
|
8158
|
+
}
|
|
8159
|
+
function resolveColumns(state, supportedColumns, columnNameMap, allowSelection) {
|
|
8160
|
+
const allColumns = getAllColumns(state, supportedColumns, columnNameMap);
|
|
8161
|
+
return allColumns
|
|
8162
|
+
.filter(({ enabled }) => enabled)
|
|
8163
|
+
.reduce((fullColumns, settings, i) => {
|
|
8164
|
+
const metadata = supportedColumns.get(settings.key);
|
|
8165
|
+
const resolvedWidth = settings.preferredWidth === 'auto'
|
|
8166
|
+
? metadata.minWidth
|
|
8167
|
+
: Math.max(metadata.minWidth, settings.preferredWidth);
|
|
8168
|
+
const previousColumn = fullColumns[i - 1];
|
|
8169
|
+
return [
|
|
8170
|
+
...fullColumns,
|
|
8171
|
+
Object.assign(Object.assign(Object.assign({}, settings), metadata), { width: resolvedWidth, left: settings.pinned
|
|
8172
|
+
? previousColumn
|
|
8173
|
+
? (previousColumn.left || 0) + previousColumn.width
|
|
8174
|
+
: !!allowSelection
|
|
8175
|
+
? 40
|
|
8176
|
+
: 0
|
|
8177
|
+
: null, alignment: getAlignment(metadata, i, !!allowSelection) }),
|
|
8178
|
+
];
|
|
8179
|
+
}, []);
|
|
8180
|
+
}
|
|
8181
|
+
TableColumnHelpers.resolveColumns = resolveColumns;
|
|
8182
|
+
function changeColumnPin(state, columns, columnNameMap, column, pinned) {
|
|
8183
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8184
|
+
if (pinned) {
|
|
8185
|
+
const target = allColumns.find(c => c.key === column);
|
|
8186
|
+
const wasEnabled = !!(target === null || target === void 0 ? void 0 : target.enabled);
|
|
8187
|
+
if (!wasEnabled) {
|
|
8188
|
+
const enabledCount = allColumns.filter(col => col.enabled).length;
|
|
8189
|
+
if (enabledCount >= RivTable.ColumnsMaxShown) {
|
|
8190
|
+
return state; // refuse the pin since it would exceed the max
|
|
8191
|
+
}
|
|
8192
|
+
}
|
|
8193
|
+
}
|
|
8194
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { pinned: c.key === column ? pinned : c.pinned,
|
|
8195
|
+
// Check/enable if being pinned
|
|
8196
|
+
enabled: c.key === column && pinned ? true : c.enabled }))), columnNameMap) }) });
|
|
8197
|
+
}
|
|
8198
|
+
TableColumnHelpers.changeColumnPin = changeColumnPin;
|
|
8199
|
+
function changeColumnsFreezeState(state, columns, columnNameMap, index, freeze) {
|
|
8200
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8201
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: allColumns.map((c, i) => {
|
|
8202
|
+
return Object.assign(Object.assign({}, c), { pinned: freeze && i <= index });
|
|
8203
|
+
}) }) });
|
|
8204
|
+
}
|
|
8205
|
+
TableColumnHelpers.changeColumnsFreezeState = changeColumnsFreezeState;
|
|
8206
|
+
function moveColumnTo(state, columns, columnNameMap, column, position) {
|
|
8207
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8208
|
+
const previousIndex = allColumns.findIndex(c => c.key === column);
|
|
8209
|
+
const lastIndex = position == 'end' ? allColumns.findIndex(c => !c.enabled) : 0;
|
|
8210
|
+
const newIndex = position == 'start'
|
|
8211
|
+
? 0
|
|
8212
|
+
: lastIndex == -1
|
|
8213
|
+
? allColumns.length - 1
|
|
8214
|
+
: lastIndex;
|
|
8215
|
+
if (!allColumns[previousIndex].enabled &&
|
|
8216
|
+
allColumns.filter(col => col.enabled).length >= RivTable.ColumnsMaxShown)
|
|
8217
|
+
return state;
|
|
8218
|
+
const movedState = changeColumnOrder(state, columns, columnNameMap, previousIndex, newIndex);
|
|
8219
|
+
//Make sure the column is enabled
|
|
8220
|
+
return changeColumnEnabled(movedState, columns, columnNameMap, column, true);
|
|
8221
|
+
}
|
|
8222
|
+
TableColumnHelpers.moveColumnTo = moveColumnTo;
|
|
8223
|
+
function changeColumnOrder(state, columns, columnNameMap, previousIndex, newIndex) {
|
|
8224
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8225
|
+
// First, put the columns in the desired order.
|
|
8226
|
+
const item = allColumns[previousIndex];
|
|
8227
|
+
const withoutItem = allColumns.filter((_, i) => i !== previousIndex);
|
|
8228
|
+
const reordered = [
|
|
8229
|
+
...withoutItem.slice(0, newIndex),
|
|
8230
|
+
item,
|
|
8231
|
+
...withoutItem.slice(newIndex),
|
|
8232
|
+
];
|
|
8233
|
+
// Then, we may need to fix the pins (all pinned columns appear at the
|
|
8234
|
+
// beginning of the columns array) since the user is allowed to drag
|
|
8235
|
+
// and drop columns to and from the pinned area. If the user drags a
|
|
8236
|
+
// column across that threshold, update its pinned status.
|
|
8237
|
+
const updated = reordered.map((settings, i, arr) => {
|
|
8238
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8239
|
+
if (newIndex === i) {
|
|
8240
|
+
return Object.assign(Object.assign({}, settings), { pinned: settings.pinned
|
|
8241
|
+
? (_b = (_a = arr[i - 1]) === null || _a === void 0 ? void 0 : _a.pinned) !== null && _b !== void 0 ? _b : true
|
|
8242
|
+
: (_d = (_c = arr[i + 1]) === null || _c === void 0 ? void 0 : _c.pinned) !== null && _d !== void 0 ? _d : false, enabled: settings.enabled
|
|
8243
|
+
? (_f = (_e = arr[i - 1]) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : true
|
|
8244
|
+
: (_h = (_g = arr[i + 1]) === null || _g === void 0 ? void 0 : _g.enabled) !== null && _h !== void 0 ? _h : false });
|
|
8245
|
+
}
|
|
8246
|
+
else
|
|
8247
|
+
return settings;
|
|
8248
|
+
});
|
|
8249
|
+
const wasDisabled = !item.enabled;
|
|
8250
|
+
const becameEnabled = updated[newIndex].enabled;
|
|
8251
|
+
if (wasDisabled && becameEnabled) {
|
|
8252
|
+
const enabledCount = allColumns.filter(c => c.enabled).length;
|
|
8253
|
+
if (enabledCount >= RivTable.ColumnsMaxShown) {
|
|
8254
|
+
// Refuse the move; keep state as-is
|
|
8255
|
+
return state;
|
|
8256
|
+
}
|
|
8257
|
+
}
|
|
8258
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(updated, columnNameMap) }) });
|
|
8259
|
+
}
|
|
8260
|
+
TableColumnHelpers.changeColumnOrder = changeColumnOrder;
|
|
8261
|
+
function changeColumnEnabled(state, columns, columnNameMap, column, enabled) {
|
|
8262
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8263
|
+
if (enabled &&
|
|
8264
|
+
allColumns.filter(col => col.enabled).length >= RivTable.ColumnsMaxShown) {
|
|
8265
|
+
return state;
|
|
8266
|
+
}
|
|
8267
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { enabled: c.key === column ? enabled : c.enabled,
|
|
8268
|
+
// Unpin if being unchecked
|
|
8269
|
+
pinned: c.key === column && !enabled ? false : c.pinned }))), columnNameMap) }) });
|
|
8270
|
+
}
|
|
8271
|
+
TableColumnHelpers.changeColumnEnabled = changeColumnEnabled;
|
|
8272
|
+
function enableAllColumns(state, columns, columnNameMap, enabled) {
|
|
8273
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8274
|
+
if (enabled && allColumns.length > RivTable.ColumnsMaxShown)
|
|
8275
|
+
return state;
|
|
8276
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { enabled: enabled,
|
|
8277
|
+
// Unpin if being unchecked
|
|
8278
|
+
pinned: !enabled ? false : c.pinned }))), columnNameMap) }) });
|
|
8279
|
+
}
|
|
8280
|
+
TableColumnHelpers.enableAllColumns = enableAllColumns;
|
|
8281
|
+
function changeColumnWidth(state, columns, columnNameMap, column, preferredWidth) {
|
|
8282
|
+
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8283
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: allColumns.map(c => (Object.assign(Object.assign({}, c), { preferredWidth: c.key === column ? preferredWidth : c.preferredWidth }))) }) });
|
|
8284
|
+
}
|
|
8285
|
+
TableColumnHelpers.changeColumnWidth = changeColumnWidth;
|
|
8286
|
+
function resetToDefaultColumns(state, columns, columnNameMap, defaultColumnState) {
|
|
8287
|
+
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(defaultColumnState, columnNameMap) }) });
|
|
8288
|
+
}
|
|
8289
|
+
TableColumnHelpers.resetToDefaultColumns = resetToDefaultColumns;
|
|
8290
|
+
})(TableColumnHelpers || (TableColumnHelpers = {}));
|
|
8291
|
+
|
|
8292
|
+
var TableResultHelpers;
|
|
8293
|
+
(function (TableResultHelpers) {
|
|
8294
|
+
function isRegularResult(result) {
|
|
8295
|
+
if ('currentPageData' in result) {
|
|
8296
|
+
return true;
|
|
8297
|
+
}
|
|
8298
|
+
return false;
|
|
8299
|
+
}
|
|
8300
|
+
TableResultHelpers.isRegularResult = isRegularResult;
|
|
8301
|
+
function isGroupResult(result) {
|
|
8302
|
+
if ('totalGroupCount' in result) {
|
|
8303
|
+
return true;
|
|
8304
|
+
}
|
|
8305
|
+
return false;
|
|
8306
|
+
}
|
|
8307
|
+
TableResultHelpers.isGroupResult = isGroupResult;
|
|
8308
|
+
function isNestedResult(result) {
|
|
8309
|
+
if ('currentPageNestedRows' in result) {
|
|
8310
|
+
return true;
|
|
8311
|
+
}
|
|
8312
|
+
return false;
|
|
8313
|
+
}
|
|
8314
|
+
TableResultHelpers.isNestedResult = isNestedResult;
|
|
8315
|
+
function isNestedWithHeaderResult(result) {
|
|
8316
|
+
if ('currentPageNestedHeaders' in result) {
|
|
8317
|
+
return true;
|
|
8318
|
+
}
|
|
8319
|
+
return false;
|
|
8320
|
+
}
|
|
8321
|
+
TableResultHelpers.isNestedWithHeaderResult = isNestedWithHeaderResult;
|
|
8322
|
+
function getAllRowsFromResult(result) {
|
|
8323
|
+
if (isGroupResult(result)) {
|
|
8324
|
+
return result.groupResults.flatMap(groups => groups.currentPageData);
|
|
8325
|
+
}
|
|
8326
|
+
else if (isNestedResult(result)) {
|
|
8327
|
+
return getAllRowsFromNestedRows(result.currentPageNestedRows);
|
|
8328
|
+
}
|
|
8329
|
+
else if (isNestedWithHeaderResult(result)) {
|
|
8330
|
+
return getAllRowsFromNestedHeaders(result.currentPageNestedHeaders);
|
|
8331
|
+
}
|
|
8332
|
+
else {
|
|
8333
|
+
return result.currentPageData;
|
|
8334
|
+
}
|
|
8335
|
+
}
|
|
8336
|
+
TableResultHelpers.getAllRowsFromResult = getAllRowsFromResult;
|
|
8337
|
+
function getAllRowsFromNestedRows(nestedRows) {
|
|
8338
|
+
const allRows = [];
|
|
8339
|
+
function recursiveGetNestedRows(currentNestedRow) {
|
|
8340
|
+
var _a;
|
|
8341
|
+
allRows.push(currentNestedRow.data);
|
|
8342
|
+
const subRows = (_a = currentNestedRow.subRows) !== null && _a !== void 0 ? _a : [];
|
|
8343
|
+
for (const subRow of subRows) {
|
|
8344
|
+
recursiveGetNestedRows(subRow);
|
|
8345
|
+
}
|
|
8346
|
+
}
|
|
8347
|
+
for (const nestedRow of nestedRows) {
|
|
8348
|
+
recursiveGetNestedRows(nestedRow);
|
|
8349
|
+
}
|
|
8350
|
+
return allRows;
|
|
8351
|
+
}
|
|
8352
|
+
TableResultHelpers.getAllRowsFromNestedRows = getAllRowsFromNestedRows;
|
|
8353
|
+
function getAllRowsFromNestedHeaders(nestedHeaders) {
|
|
8354
|
+
const allRows = [];
|
|
8355
|
+
for (const outerNestedHeaderRow of nestedHeaders) {
|
|
8356
|
+
const rowsInHeader = getAllRowsFromNestedRows(outerNestedHeaderRow.subRows);
|
|
8357
|
+
for (const rowInHeader of rowsInHeader) {
|
|
8358
|
+
allRows.push(rowInHeader);
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
return allRows;
|
|
8362
|
+
}
|
|
8363
|
+
TableResultHelpers.getAllRowsFromNestedHeaders = getAllRowsFromNestedHeaders;
|
|
8364
|
+
function getCsvFilename(pluralEntityName, options) {
|
|
8365
|
+
var _a, _b;
|
|
8366
|
+
return (((_b = (_a = options === null || options === void 0 ? void 0 : options.csvFileBasename) === null || _a === void 0 ? void 0 : _a.slice(0, 200)) !== null && _b !== void 0 ? _b : pluralEntityName) + '.csv');
|
|
8367
|
+
}
|
|
8368
|
+
TableResultHelpers.getCsvFilename = getCsvFilename;
|
|
8369
|
+
})(TableResultHelpers || (TableResultHelpers = {}));
|
|
8370
|
+
|
|
8371
|
+
var TableSearchHelpers;
|
|
8372
|
+
(function (TableSearchHelpers) {
|
|
8373
|
+
function getSearchColumnsSelectedState(state, expectedValue) {
|
|
8374
|
+
switch (expectedValue) {
|
|
8375
|
+
case 'all':
|
|
8376
|
+
return Array.from(state.query.searchColumns.values()).every(value => value);
|
|
8377
|
+
case 'none':
|
|
8378
|
+
return Array.from(state.query.searchColumns.values()).every(value => !value);
|
|
8379
|
+
}
|
|
8380
|
+
}
|
|
8381
|
+
TableSearchHelpers.getSearchColumnsSelectedState = getSearchColumnsSelectedState;
|
|
8382
|
+
function toggleAllSearchColumns(state) {
|
|
8383
|
+
const noneSelected = getSearchColumnsSelectedState(state, 'none');
|
|
8384
|
+
const payload = new Map(Array.from(state.query.searchColumns.keys()).map(key => [
|
|
8385
|
+
key,
|
|
8386
|
+
noneSelected,
|
|
8387
|
+
]));
|
|
8388
|
+
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { searchColumns: payload }) });
|
|
8389
|
+
}
|
|
8390
|
+
TableSearchHelpers.toggleAllSearchColumns = toggleAllSearchColumns;
|
|
8391
|
+
})(TableSearchHelpers || (TableSearchHelpers = {}));
|
|
8392
|
+
|
|
8393
|
+
var TableDisplayHelpers;
|
|
8394
|
+
(function (TableDisplayHelpers) {
|
|
8395
|
+
function getZeroStateMessage(state, entity) {
|
|
8396
|
+
if ((TableResultHelpers.isGroupResult(state.result) &&
|
|
8397
|
+
state.result.totalGroupCount > 0) ||
|
|
8398
|
+
(!TableResultHelpers.isGroupResult(state.result) &&
|
|
8399
|
+
state.result.totalMatchingRowCount > 0))
|
|
8400
|
+
return null;
|
|
8401
|
+
const allSearchColumnsSelected = TableSearchHelpers.getSearchColumnsSelectedState(state, 'all');
|
|
8402
|
+
if (state.query.search && allSearchColumnsSelected)
|
|
8403
|
+
return `No ${entity} match your current search keyword.`;
|
|
8404
|
+
if (state.query.search && !allSearchColumnsSelected)
|
|
8405
|
+
return `No ${entity} match your current search keyword in the selected search columns.`;
|
|
8406
|
+
if (state.query.filters)
|
|
8407
|
+
return `No ${entity} match your current filters.`;
|
|
8408
|
+
return `No ${entity}.`;
|
|
8409
|
+
}
|
|
8410
|
+
TableDisplayHelpers.getZeroStateMessage = getZeroStateMessage;
|
|
8411
|
+
function memoizedCellRowSpan(s, fullColumns, options) {
|
|
8412
|
+
const getRowSpanForCell = options === null || options === void 0 ? void 0 : options.getRowSpanForCell;
|
|
8413
|
+
const result = s.result;
|
|
8414
|
+
// If the dataset exceeds the current page size, skip span calculations.
|
|
8415
|
+
if (s.result.totalMatchingRowCount > s.query.pagination.pageSize)
|
|
8416
|
+
return null;
|
|
8417
|
+
// If the user hasn't provided the row span configuration, default to no spanning
|
|
8418
|
+
if (!getRowSpanForCell)
|
|
8419
|
+
return null;
|
|
8420
|
+
// Row spanning is not supported on grouped tables.
|
|
8421
|
+
if (TableResultHelpers.isGroupResult(result))
|
|
8422
|
+
return null;
|
|
8423
|
+
// Memoize the user's configuration for the current page.
|
|
8424
|
+
return new Map(fullColumns.map(column => [
|
|
8425
|
+
column.key,
|
|
8426
|
+
result.currentPageData.map((_, i) => {
|
|
8427
|
+
const raw = getRowSpanForCell(i, column.key);
|
|
8428
|
+
if (raw === 0)
|
|
8429
|
+
return 0;
|
|
8430
|
+
else
|
|
8431
|
+
return Math.max(1, toInteger(raw));
|
|
8432
|
+
}),
|
|
8433
|
+
]));
|
|
8434
|
+
}
|
|
8435
|
+
TableDisplayHelpers.memoizedCellRowSpan = memoizedCellRowSpan;
|
|
8436
|
+
})(TableDisplayHelpers || (TableDisplayHelpers = {}));
|
|
8437
|
+
|
|
8438
|
+
var TableOrderHelpers;
|
|
8439
|
+
(function (TableOrderHelpers) {
|
|
8440
|
+
function orderEmptyLast(rows, key, direction) {
|
|
8441
|
+
return orderBy(rows, [row => row[key] == null, key], ['asc', direction]);
|
|
8442
|
+
}
|
|
8443
|
+
TableOrderHelpers.orderEmptyLast = orderEmptyLast;
|
|
8444
|
+
function orderNestedRowsEmptyLast(rows, key, direction) {
|
|
8445
|
+
return orderBy(rows, [row => row.data[key] == null, row => row.data[key]], ['asc', direction]);
|
|
8446
|
+
}
|
|
8447
|
+
TableOrderHelpers.orderNestedRowsEmptyLast = orderNestedRowsEmptyLast;
|
|
8448
|
+
function orderNestedRowsBySearchMatch(rows, idToSearchIndexMap) {
|
|
8449
|
+
return orderBy(rows, [row => idToSearchIndexMap.get(row.data.id)], ['asc']);
|
|
8450
|
+
}
|
|
8451
|
+
TableOrderHelpers.orderNestedRowsBySearchMatch = orderNestedRowsBySearchMatch;
|
|
8452
|
+
function toggleColumnOrder(state, column) {
|
|
8453
|
+
var _a;
|
|
8454
|
+
if (((_a = state.query.order) === null || _a === void 0 ? void 0 : _a.column) === column) {
|
|
8455
|
+
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { order: state.query.order.direction === 'asc'
|
|
8456
|
+
? {
|
|
8457
|
+
column,
|
|
8458
|
+
direction: 'desc',
|
|
8459
|
+
}
|
|
8460
|
+
: null }) });
|
|
8461
|
+
}
|
|
8462
|
+
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { order: {
|
|
8463
|
+
column,
|
|
8464
|
+
direction: 'asc',
|
|
8465
|
+
} }) });
|
|
8466
|
+
}
|
|
8467
|
+
TableOrderHelpers.toggleColumnOrder = toggleColumnOrder;
|
|
8468
|
+
/*
|
|
8469
|
+
We only sort the lowest level rows if rows are nested.
|
|
8470
|
+
|
|
8471
|
+
In other words, we sort within each nested group, but do
|
|
8472
|
+
NOT sort in relation to the other groups.
|
|
8473
|
+
*/
|
|
8474
|
+
function sortLowLevelNestedRows(allRows, sortKey, direction) {
|
|
8475
|
+
function recursiveSortRows(nestedRows) {
|
|
8476
|
+
const hasDeeperNesting = nestedRows.some(row => row.subRows && row.subRows.length > 0);
|
|
8477
|
+
if (!hasDeeperNesting) {
|
|
8478
|
+
const sortedRows = orderNestedRowsEmptyLast(nestedRows, sortKey, direction);
|
|
8479
|
+
return sortedRows;
|
|
8480
|
+
}
|
|
8481
|
+
else {
|
|
8482
|
+
// If there is a deeper nesting, keep recursing
|
|
8483
|
+
const sortedRows = [];
|
|
8484
|
+
for (const currentNestedRow of nestedRows) {
|
|
8485
|
+
if (currentNestedRow.subRows && currentNestedRow.subRows.length > 0) {
|
|
8486
|
+
const sortedSubRows = recursiveSortRows(currentNestedRow.subRows);
|
|
8487
|
+
sortedRows.push(Object.assign(Object.assign({}, currentNestedRow), { subRows: sortedSubRows }));
|
|
8488
|
+
}
|
|
8489
|
+
else {
|
|
8490
|
+
sortedRows.push(currentNestedRow);
|
|
8491
|
+
}
|
|
8492
|
+
}
|
|
8493
|
+
return sortedRows;
|
|
8494
|
+
}
|
|
8495
|
+
}
|
|
8496
|
+
return recursiveSortRows(allRows);
|
|
8497
|
+
}
|
|
8498
|
+
TableOrderHelpers.sortLowLevelNestedRows = sortLowLevelNestedRows;
|
|
8499
|
+
// Sort the data inside the headers, not the headers themselves
|
|
8500
|
+
function sortLowLevelNestedRowsWithHeaders(allHeaders, sortKey, direction) {
|
|
8501
|
+
const sortedHeaderRows = [];
|
|
8502
|
+
for (const headerRow of allHeaders) {
|
|
8503
|
+
const sortedSubRows = sortLowLevelNestedRows(headerRow.subRows, sortKey, direction);
|
|
8504
|
+
sortedHeaderRows.push(Object.assign(Object.assign({}, headerRow), { subRows: sortedSubRows }));
|
|
8505
|
+
}
|
|
8506
|
+
return sortedHeaderRows;
|
|
8507
|
+
}
|
|
8508
|
+
TableOrderHelpers.sortLowLevelNestedRowsWithHeaders = sortLowLevelNestedRowsWithHeaders;
|
|
8509
|
+
// Create map to help us sort on Fuse relevance order
|
|
8510
|
+
function createIdToSearchIndexMap(rowsMatchingSearch) {
|
|
8511
|
+
const idToSearchIndexMap = new Map();
|
|
8512
|
+
for (let i = 0; i < rowsMatchingSearch.length; i++) {
|
|
8513
|
+
const rowMatchingIndex = rowsMatchingSearch[i];
|
|
8514
|
+
idToSearchIndexMap.set(rowMatchingIndex.id, i);
|
|
8515
|
+
}
|
|
8516
|
+
return idToSearchIndexMap;
|
|
8517
|
+
}
|
|
8518
|
+
TableOrderHelpers.createIdToSearchIndexMap = createIdToSearchIndexMap;
|
|
8519
|
+
// Sort based on how well the rows match a search
|
|
8520
|
+
function sortNestedRowsBasedOnSearchMatches(allRows, idToSearchIndexMap) {
|
|
8521
|
+
function recursiveSortRowsBySearchMatch(nestedRows) {
|
|
8522
|
+
const hasDeeperNesting = nestedRows.some(row => row.subRows && row.subRows.length > 0);
|
|
8523
|
+
if (!hasDeeperNesting) {
|
|
8524
|
+
const sortedRows = orderNestedRowsBySearchMatch(nestedRows, idToSearchIndexMap);
|
|
8525
|
+
return sortedRows;
|
|
8526
|
+
}
|
|
8527
|
+
else {
|
|
8528
|
+
// If there is a deeper nesting, keep recursing
|
|
8529
|
+
const sortedRows = [];
|
|
8530
|
+
for (const currentNestedRow of nestedRows) {
|
|
8531
|
+
if (currentNestedRow.subRows && currentNestedRow.subRows.length > 0) {
|
|
8532
|
+
const sortedSubRows = recursiveSortRowsBySearchMatch(currentNestedRow.subRows);
|
|
8533
|
+
sortedRows.push(Object.assign(Object.assign({}, currentNestedRow), { subRows: sortedSubRows }));
|
|
8534
|
+
}
|
|
8535
|
+
else {
|
|
8536
|
+
sortedRows.push(currentNestedRow);
|
|
8537
|
+
}
|
|
8538
|
+
}
|
|
8539
|
+
return sortedRows;
|
|
8540
|
+
}
|
|
8541
|
+
}
|
|
8542
|
+
return recursiveSortRowsBySearchMatch(allRows);
|
|
8543
|
+
}
|
|
8544
|
+
TableOrderHelpers.sortNestedRowsBasedOnSearchMatches = sortNestedRowsBasedOnSearchMatches;
|
|
8545
|
+
// Sort based on how well the rows match a search
|
|
8546
|
+
function sortNestedRowsWithHeadersBasedOnSearchMatches(allHeaders, idToSearchIndexMap) {
|
|
8547
|
+
const sortedHeaderRows = [];
|
|
8548
|
+
for (const headerRow of allHeaders) {
|
|
8549
|
+
const sortedSubRows = sortNestedRowsBasedOnSearchMatches(headerRow.subRows, idToSearchIndexMap);
|
|
8550
|
+
sortedHeaderRows.push(Object.assign(Object.assign({}, headerRow), { subRows: sortedSubRows }));
|
|
8551
|
+
}
|
|
8552
|
+
return sortedHeaderRows;
|
|
8553
|
+
}
|
|
8554
|
+
TableOrderHelpers.sortNestedRowsWithHeadersBasedOnSearchMatches = sortNestedRowsWithHeadersBasedOnSearchMatches;
|
|
8555
|
+
})(TableOrderHelpers || (TableOrderHelpers = {}));
|
|
8556
|
+
|
|
8557
|
+
var TablePaginationHelpers;
|
|
8558
|
+
(function (TablePaginationHelpers) {
|
|
8559
|
+
function getPageCount(state) {
|
|
8560
|
+
if (TableResultHelpers.isGroupResult(state.result)) {
|
|
8561
|
+
return Math.max(Math.ceil(state.result.totalGroupCount / state.query.grouping.groupsPerPage), 1);
|
|
8562
|
+
}
|
|
8563
|
+
return Math.max(Math.ceil(state.result.totalMatchingRowCount / state.query.pagination.pageSize), 1);
|
|
8564
|
+
}
|
|
8565
|
+
TablePaginationHelpers.getPageCount = getPageCount;
|
|
8566
|
+
function getPreviousPage(state) {
|
|
8567
|
+
return state.query.pagination.page === 0
|
|
8568
|
+
? null
|
|
8569
|
+
: state.query.pagination.page - 1;
|
|
8570
|
+
}
|
|
8571
|
+
TablePaginationHelpers.getPreviousPage = getPreviousPage;
|
|
8572
|
+
function getPages(state) {
|
|
8573
|
+
const padding = 4;
|
|
8574
|
+
const min = 0;
|
|
8575
|
+
const max = getPageCount(state) - 1;
|
|
8576
|
+
const desiredStart = state.query.pagination.page - padding;
|
|
8577
|
+
const clampedStart = Math.max(min, desiredStart);
|
|
8578
|
+
const desiredEnd = state.query.pagination.page + padding;
|
|
8579
|
+
const clampedEnd = Math.min(max, desiredEnd);
|
|
8580
|
+
const start = Math.max(min, clampedStart - (desiredEnd - clampedEnd));
|
|
8581
|
+
const end = Math.min(max, clampedEnd + (clampedStart - desiredStart));
|
|
8582
|
+
return range(start, end + 1);
|
|
8583
|
+
}
|
|
8584
|
+
TablePaginationHelpers.getPages = getPages;
|
|
8585
|
+
function getNextPage(state) {
|
|
8586
|
+
const max = getPageCount(state) - 1;
|
|
8587
|
+
const next = state.query.pagination.page + 1;
|
|
8588
|
+
return next <= max ? next : null;
|
|
8589
|
+
}
|
|
8590
|
+
TablePaginationHelpers.getNextPage = getNextPage;
|
|
8591
|
+
// We don't want to show the pagination controls when they are unnecessary.
|
|
8592
|
+
function getShowPaginationControls(state) {
|
|
8593
|
+
if (state.query.pagination.page > 0) {
|
|
8594
|
+
return true;
|
|
8595
|
+
}
|
|
8596
|
+
if (TableResultHelpers.isGroupResult(state.result)) {
|
|
8597
|
+
return state.result.totalGroupCount > state.query.grouping.groupsPerPage;
|
|
8598
|
+
}
|
|
8599
|
+
return (state.result.totalMatchingRowCount > Math.min(...[...RivTable.pageSizes]));
|
|
8600
|
+
}
|
|
8601
|
+
TablePaginationHelpers.getShowPaginationControls = getShowPaginationControls;
|
|
8602
|
+
function getPageRowStart(state) {
|
|
8603
|
+
return state.query.pagination.page * state.query.pagination.pageSize + 1;
|
|
8604
|
+
}
|
|
8605
|
+
TablePaginationHelpers.getPageRowStart = getPageRowStart;
|
|
8606
|
+
function getPageRowEnd(state) {
|
|
8607
|
+
return Math.min((state.query.pagination.page + 1) * state.query.pagination.pageSize, state.result.totalMatchingRowCount);
|
|
8608
|
+
}
|
|
8609
|
+
TablePaginationHelpers.getPageRowEnd = getPageRowEnd;
|
|
8610
|
+
function isPageOutOfBounds(state, result) {
|
|
8611
|
+
if (TableResultHelpers.isGroupResult(result)) {
|
|
8612
|
+
const minGroupValToShowOnCurrentPage = state.query.pagination.page * state.query.grouping.groupsPerPage + 1;
|
|
8613
|
+
if (result.totalGroupCount < minGroupValToShowOnCurrentPage) {
|
|
8614
|
+
return true;
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
else {
|
|
8618
|
+
const minRowToShowOnCurrentPage = state.query.pagination.page * state.query.pagination.pageSize + 1;
|
|
8619
|
+
if (result.totalMatchingRowCount < minRowToShowOnCurrentPage) {
|
|
8620
|
+
return true;
|
|
8621
|
+
}
|
|
8622
|
+
}
|
|
8623
|
+
return false;
|
|
8624
|
+
}
|
|
8625
|
+
TablePaginationHelpers.isPageOutOfBounds = isPageOutOfBounds;
|
|
8626
|
+
// Paginate based on bottom level rows, splitting as necessary to fit within the page
|
|
8627
|
+
function paginateNestedRows(allNestedRows, pageNumber, pageSize) {
|
|
8628
|
+
const startIdx = pageSize * pageNumber;
|
|
8629
|
+
const endIdx = startIdx + pageSize;
|
|
8630
|
+
let bottomLevelRowCount = 0;
|
|
8631
|
+
function recursivePaginateRows(currentNestedRow) {
|
|
8632
|
+
// If there are no subrows, stop recursing
|
|
8633
|
+
if (!currentNestedRow.subRows) {
|
|
8634
|
+
bottomLevelRowCount++;
|
|
8635
|
+
// Since we add 1 first, the bounds should be (startIdx, endIdx]
|
|
8636
|
+
if (bottomLevelRowCount > startIdx && bottomLevelRowCount <= endIdx) {
|
|
8637
|
+
return currentNestedRow;
|
|
8638
|
+
}
|
|
8639
|
+
return null;
|
|
8640
|
+
}
|
|
8641
|
+
else {
|
|
8642
|
+
const subRowsToKeep = [];
|
|
8643
|
+
for (const subRow of currentNestedRow.subRows) {
|
|
8644
|
+
const countedRow = recursivePaginateRows(subRow);
|
|
8645
|
+
if (countedRow != null) {
|
|
8646
|
+
subRowsToKeep.push(countedRow);
|
|
8647
|
+
}
|
|
8648
|
+
}
|
|
8649
|
+
if (subRowsToKeep.length == 0) {
|
|
8650
|
+
return null;
|
|
8651
|
+
}
|
|
8652
|
+
else {
|
|
8653
|
+
// Keep any top level row that has at least one subrow
|
|
8654
|
+
return Object.assign(Object.assign({}, currentNestedRow), { subRows: subRowsToKeep });
|
|
8655
|
+
}
|
|
8656
|
+
}
|
|
8657
|
+
}
|
|
8658
|
+
const paginatedRows = [];
|
|
8659
|
+
for (const nestedRow of allNestedRows) {
|
|
8660
|
+
const recursedRow = recursivePaginateRows(nestedRow);
|
|
8661
|
+
if (recursedRow != null) {
|
|
8662
|
+
paginatedRows.push(recursedRow);
|
|
8663
|
+
}
|
|
8664
|
+
}
|
|
8665
|
+
return paginatedRows;
|
|
8666
|
+
}
|
|
8667
|
+
TablePaginationHelpers.paginateNestedRows = paginateNestedRows;
|
|
8668
|
+
// Paginate based on bottom level rows, splitting as necessary to fit within the page
|
|
8669
|
+
function paginateNestedHeaderRows(allHeaders, pageNumber, pageSize) {
|
|
8670
|
+
const startIdx = pageSize * pageNumber;
|
|
8671
|
+
const endIdx = startIdx + pageSize;
|
|
8672
|
+
let bottomLevelRowCount = 0;
|
|
8673
|
+
function recursivePaginateRows(currentNestedRow) {
|
|
8674
|
+
// If there are no subrows, stop recursing
|
|
8675
|
+
if (!currentNestedRow.subRows) {
|
|
8676
|
+
bottomLevelRowCount++;
|
|
8677
|
+
// Since we add 1 first, the bounds should be (startIdx, endIdx]
|
|
8678
|
+
if (bottomLevelRowCount > startIdx && bottomLevelRowCount <= endIdx) {
|
|
8679
|
+
return currentNestedRow;
|
|
8680
|
+
}
|
|
8681
|
+
return null;
|
|
8682
|
+
}
|
|
8683
|
+
else {
|
|
8684
|
+
const subRowsToKeep = [];
|
|
8685
|
+
for (const subRow of currentNestedRow.subRows) {
|
|
8686
|
+
const countedRow = recursivePaginateRows(subRow);
|
|
8687
|
+
if (countedRow != null) {
|
|
8688
|
+
subRowsToKeep.push(countedRow);
|
|
8689
|
+
}
|
|
8690
|
+
}
|
|
8691
|
+
if (subRowsToKeep.length == 0) {
|
|
8692
|
+
return null;
|
|
8693
|
+
}
|
|
8694
|
+
else {
|
|
8695
|
+
// Keep any top level row that has at least one subrow
|
|
8696
|
+
return Object.assign(Object.assign({}, currentNestedRow), { subRows: subRowsToKeep });
|
|
8697
|
+
}
|
|
8698
|
+
}
|
|
8699
|
+
}
|
|
8700
|
+
const paginatedHeaders = [];
|
|
8701
|
+
for (const headerRow of allHeaders) {
|
|
8702
|
+
const paginatedSubRows = [];
|
|
8703
|
+
for (const subRow of headerRow.subRows) {
|
|
8704
|
+
const recursedSubRow = recursivePaginateRows(subRow);
|
|
8705
|
+
if (recursedSubRow != null) {
|
|
8706
|
+
paginatedSubRows.push(recursedSubRow);
|
|
8707
|
+
}
|
|
8708
|
+
}
|
|
8709
|
+
if (paginatedSubRows.length > 0) {
|
|
8710
|
+
// Keep any header that has at least one subrow in the current page
|
|
8711
|
+
paginatedHeaders.push(Object.assign(Object.assign({}, headerRow), { subRows: paginatedSubRows }));
|
|
8712
|
+
}
|
|
8713
|
+
}
|
|
8714
|
+
return paginatedHeaders;
|
|
8715
|
+
}
|
|
8716
|
+
TablePaginationHelpers.paginateNestedHeaderRows = paginateNestedHeaderRows;
|
|
8717
|
+
})(TablePaginationHelpers || (TablePaginationHelpers = {}));
|
|
8718
|
+
|
|
8719
|
+
var TableSelectionHelpers;
|
|
8720
|
+
(function (TableSelectionHelpers) {
|
|
8721
|
+
function isRowSelected(state, id) {
|
|
8722
|
+
switch (state.selection.mode) {
|
|
8723
|
+
case 'include':
|
|
8724
|
+
return state.selection.included.has(id);
|
|
8725
|
+
case 'exclude':
|
|
8726
|
+
return !state.selection.excluded.has(id);
|
|
8727
|
+
}
|
|
8728
|
+
}
|
|
8729
|
+
TableSelectionHelpers.isRowSelected = isRowSelected;
|
|
8730
|
+
function isGroupSelected(state, group) {
|
|
8731
|
+
switch (state.selection.mode) {
|
|
8732
|
+
case 'include': {
|
|
8733
|
+
let allFound = true;
|
|
8734
|
+
let anyFound = false;
|
|
8735
|
+
for (const row of group.currentPageData) {
|
|
8736
|
+
if (!state.selection.included.has(row.id)) {
|
|
8737
|
+
allFound = false;
|
|
8738
|
+
}
|
|
8739
|
+
else {
|
|
8740
|
+
anyFound = true;
|
|
8741
|
+
}
|
|
8742
|
+
}
|
|
8743
|
+
return allFound ? true : anyFound ? 'indeterminate' : false;
|
|
8744
|
+
}
|
|
8745
|
+
case 'exclude': {
|
|
8746
|
+
let allFound = true;
|
|
8747
|
+
let anyFound = false;
|
|
8748
|
+
for (const row of group.currentPageData) {
|
|
8749
|
+
if (state.selection.excluded.has(row.id)) {
|
|
8750
|
+
allFound = false;
|
|
8751
|
+
}
|
|
8752
|
+
else {
|
|
8753
|
+
anyFound = true;
|
|
8754
|
+
}
|
|
8755
|
+
}
|
|
8756
|
+
return allFound ? true : anyFound ? 'indeterminate' : false;
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
}
|
|
8760
|
+
TableSelectionHelpers.isGroupSelected = isGroupSelected;
|
|
8761
|
+
function isAllSelected(state) {
|
|
8762
|
+
// If there are no rows, "all selected" should be false
|
|
8763
|
+
if (state.result.totalMatchingRowCount === 0) {
|
|
8764
|
+
return false;
|
|
8765
|
+
}
|
|
8766
|
+
if ((state.selection.mode === 'exclude' &&
|
|
8767
|
+
state.selection.excluded.size === 0) ||
|
|
8768
|
+
(state.selection.mode === 'include' &&
|
|
8769
|
+
state.selection.included.size === state.result.totalMatchingRowCount))
|
|
8770
|
+
return true;
|
|
8771
|
+
if ((state.selection.mode === 'exclude' &&
|
|
8772
|
+
state.selection.excluded.size === state.result.totalMatchingRowCount) ||
|
|
8773
|
+
(state.selection.mode === 'include' &&
|
|
8774
|
+
state.selection.included.size === 0))
|
|
8775
|
+
return false;
|
|
8776
|
+
return 'indeterminate';
|
|
8777
|
+
}
|
|
8778
|
+
TableSelectionHelpers.isAllSelected = isAllSelected;
|
|
8779
|
+
function isCurrentPageSelected(state) {
|
|
8780
|
+
const selectedStates = TableResultHelpers.getAllRowsFromResult(state.result).map(({ id }) => isRowSelected(state, id));
|
|
8781
|
+
if (selectedStates.length > 0) {
|
|
8782
|
+
if (selectedStates.every(v => v))
|
|
8783
|
+
return true;
|
|
8784
|
+
if (selectedStates.some(v => v))
|
|
8785
|
+
return 'indeterminate';
|
|
8786
|
+
}
|
|
8787
|
+
return false;
|
|
8788
|
+
}
|
|
8789
|
+
TableSelectionHelpers.isCurrentPageSelected = isCurrentPageSelected;
|
|
8790
|
+
function selectedCount(state) {
|
|
8791
|
+
switch (state.selection.mode) {
|
|
8792
|
+
case 'include':
|
|
8793
|
+
return state.selection.included.size;
|
|
8794
|
+
case 'exclude':
|
|
8795
|
+
return (state.result.totalMatchingRowCount - state.selection.excluded.size);
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
TableSelectionHelpers.selectedCount = selectedCount;
|
|
8799
|
+
function setRowSelected(state, id, selected, contiguous) {
|
|
8800
|
+
if (selected) {
|
|
8801
|
+
const newSelection = new Set([id]);
|
|
8802
|
+
if (contiguous && state.selection.mostRecentlySelected) {
|
|
8803
|
+
const startIdx = TableResultHelpers.getAllRowsFromResult(state.result).findIndex(row => row.id === state.selection.mostRecentlySelected);
|
|
8804
|
+
const endIdx = TableResultHelpers.getAllRowsFromResult(state.result).findIndex(row => row.id === id);
|
|
8805
|
+
if (typeof startIdx === 'number' && typeof endIdx === 'number') {
|
|
8806
|
+
for (let i = Math.min(startIdx, endIdx); i <= Math.max(startIdx, endIdx); i++) {
|
|
8807
|
+
newSelection.add(TableResultHelpers.getAllRowsFromResult(state.result)[i].id);
|
|
8808
|
+
}
|
|
8809
|
+
}
|
|
8810
|
+
}
|
|
8811
|
+
return Object.assign(Object.assign({}, state), { selection: Object.assign({ mostRecentlySelected: id }, (state.selection.mode === 'include'
|
|
8812
|
+
? {
|
|
8813
|
+
mode: 'include',
|
|
8814
|
+
included: new Set(union([...state.selection.included], [...newSelection])),
|
|
8815
|
+
}
|
|
8816
|
+
: {
|
|
8817
|
+
mode: 'exclude',
|
|
8818
|
+
excluded: new Set(difference([...state.selection.excluded], [...newSelection])),
|
|
8819
|
+
})) });
|
|
8820
|
+
}
|
|
8821
|
+
else {
|
|
8822
|
+
return Object.assign(Object.assign({}, state), { selection: Object.assign({ mostRecentlySelected: null }, (state.selection.mode === 'include'
|
|
8823
|
+
? {
|
|
8824
|
+
mode: 'include',
|
|
8825
|
+
included: new Set(difference([...state.selection.included], [id])),
|
|
8826
|
+
}
|
|
8827
|
+
: {
|
|
8828
|
+
mode: 'exclude',
|
|
8829
|
+
excluded: new Set(union([...state.selection.excluded], [id])),
|
|
8830
|
+
})) });
|
|
8831
|
+
}
|
|
8832
|
+
}
|
|
8833
|
+
TableSelectionHelpers.setRowSelected = setRowSelected;
|
|
8834
|
+
function toggleGroupSelected(state, group) {
|
|
8835
|
+
const isGroupFullySelected = isGroupSelected(state, Object.assign(Object.assign({}, group), { currentPageData: group.rows })) ===
|
|
8836
|
+
true;
|
|
8837
|
+
return group.rows.reduce((accumulatedState, row) => {
|
|
8838
|
+
return setRowSelected(accumulatedState, row.id, !isGroupFullySelected, false);
|
|
8839
|
+
}, state);
|
|
8840
|
+
}
|
|
8841
|
+
TableSelectionHelpers.toggleGroupSelected = toggleGroupSelected;
|
|
8842
|
+
function togglePageSelected(state) {
|
|
8843
|
+
const isPageFullySelected = TableResultHelpers.getAllRowsFromResult(state.result).every(({ id }) => isRowSelected(state, id));
|
|
8844
|
+
return TableResultHelpers.getAllRowsFromResult(state.result).reduce((accumulatedState, row) => {
|
|
8845
|
+
return setRowSelected(accumulatedState, row.id, !isPageFullySelected, false);
|
|
8846
|
+
}, state);
|
|
8847
|
+
}
|
|
8848
|
+
TableSelectionHelpers.togglePageSelected = togglePageSelected;
|
|
8849
|
+
function toggleAllSelected(state) {
|
|
8850
|
+
if (isAllSelected(state) === true) {
|
|
8851
|
+
return Object.assign(Object.assign({}, state), { selection: {
|
|
8852
|
+
mostRecentlySelected: null,
|
|
8853
|
+
mode: 'include',
|
|
8854
|
+
included: new Set(),
|
|
8855
|
+
} });
|
|
8856
|
+
}
|
|
8857
|
+
else {
|
|
8858
|
+
return Object.assign(Object.assign({}, state), { selection: {
|
|
8859
|
+
mostRecentlySelected: null,
|
|
8860
|
+
mode: 'exclude',
|
|
8861
|
+
excluded: new Set(),
|
|
8862
|
+
} });
|
|
8863
|
+
}
|
|
8864
|
+
}
|
|
8865
|
+
TableSelectionHelpers.toggleAllSelected = toggleAllSelected;
|
|
8866
|
+
function clearSelection(state) {
|
|
8867
|
+
return Object.assign(Object.assign({}, state), { selection: {
|
|
8868
|
+
mostRecentlySelected: null,
|
|
8869
|
+
mode: 'include',
|
|
8870
|
+
included: new Set(),
|
|
8871
|
+
} });
|
|
8872
|
+
}
|
|
8873
|
+
TableSelectionHelpers.clearSelection = clearSelection;
|
|
8874
|
+
})(TableSelectionHelpers || (TableSelectionHelpers = {}));
|
|
8875
|
+
|
|
8098
8876
|
var RivTable;
|
|
8099
8877
|
(function (RivTable) {
|
|
8100
8878
|
RivTable.pageSizes = [25, 50, 100, 250];
|
|
@@ -8173,8 +8951,8 @@ var RivTable;
|
|
|
8173
8951
|
// Augment state with derived state, and subscribe.
|
|
8174
8952
|
const state = connectable(coreState.pipe(map(({ state: s }) => {
|
|
8175
8953
|
var _a, _b, _c, _d;
|
|
8176
|
-
const resolvedColumns = resolveColumns(s, columns, columnNameMap, !!(options === null || options === void 0 ? void 0 : options.allowSelection));
|
|
8177
|
-
if (isGroupResult(s.result)) {
|
|
8954
|
+
const resolvedColumns = TableColumnHelpers.resolveColumns(s, columns, columnNameMap, !!(options === null || options === void 0 ? void 0 : options.allowSelection));
|
|
8955
|
+
if (TableResultHelpers.isGroupResult(s.result)) {
|
|
8178
8956
|
if (options === null || options === void 0 ? void 0 : options.getRowSpanForCell) {
|
|
8179
8957
|
// eslint-disable-next-line no-console
|
|
8180
8958
|
console.warn('Heads up! Custom row spans are not supported for grouped tables.');
|
|
@@ -8186,8 +8964,8 @@ var RivTable;
|
|
|
8186
8964
|
const rowGroups = s.result.groupResults.map(group => ({
|
|
8187
8965
|
rows: group.currentPageData.map(row => (Object.assign(Object.assign({}, row), { rowLink: (options === null || options === void 0 ? void 0 : options.rowLink)
|
|
8188
8966
|
? options.rowLink(row, group.groupData)
|
|
8189
|
-
: null, selected: isRowSelected(s, row.id) }))),
|
|
8190
|
-
selected: isGroupSelected(s, group),
|
|
8967
|
+
: null, selected: TableSelectionHelpers.isRowSelected(s, row.id) }))),
|
|
8968
|
+
selected: TableSelectionHelpers.isGroupSelected(s, group),
|
|
8191
8969
|
totalMatchingRowCount: group.totalMatchingRowCount,
|
|
8192
8970
|
groupData: group.groupData,
|
|
8193
8971
|
}));
|
|
@@ -8202,9 +8980,9 @@ var RivTable;
|
|
|
8202
8980
|
page: 0,
|
|
8203
8981
|
pageSize: s.result.totalMatchingRowCount,
|
|
8204
8982
|
} }), { type: 'load' }));
|
|
8205
|
-
if (!isGroupResult(dataSet))
|
|
8983
|
+
if (!TableResultHelpers.isGroupResult(dataSet))
|
|
8206
8984
|
throw new Error('Returned non-grouped CSV data for grouped table');
|
|
8207
|
-
const fullColumns = resolveColumns(s, columns, columnNameMap, !!options.allowSelection);
|
|
8985
|
+
const fullColumns = TableColumnHelpers.resolveColumns(s, columns, columnNameMap, !!options.allowSelection);
|
|
8208
8986
|
const data = [];
|
|
8209
8987
|
data.push(fullColumns.map(({ key }) => { var _a; return (_a = columnNameMap.get(key)) !== null && _a !== void 0 ? _a : key; }));
|
|
8210
8988
|
if (groupCellFormatter) {
|
|
@@ -8215,7 +8993,8 @@ var RivTable;
|
|
|
8215
8993
|
group: groups.groupData,
|
|
8216
8994
|
})))) {
|
|
8217
8995
|
const record = rowItem.row;
|
|
8218
|
-
if (mode === 'selection' &&
|
|
8996
|
+
if (mode === 'selection' &&
|
|
8997
|
+
!TableSelectionHelpers.isRowSelected(s, record.id))
|
|
8219
8998
|
continue;
|
|
8220
8999
|
const row = [];
|
|
8221
9000
|
for (const column of fullColumns) {
|
|
@@ -8229,11 +9008,11 @@ var RivTable;
|
|
|
8229
9008
|
yield yield __await({ loading: false, data });
|
|
8230
9009
|
});
|
|
8231
9010
|
}
|
|
8232
|
-
return Object.assign(Object.assign({}, s), { query: Object.assign(Object.assign({}, s.query), { pagination: Object.assign(Object.assign({}, s.query.pagination), { previous: getPreviousPage(s), pages: getPages(s), next: getNextPage(s), pageCount: getPageCount(s), showControls: getShowPaginationControls(s), pageRowStart: getPageRowStart(s), pageRowEnd: getPageRowEnd(s) }), noSearchColumnsSelected: getSearchColumnsSelectedState(s, 'none') }), display: Object.assign(Object.assign({}, s.display), { columns: resolvedColumns, allColumns: getAllColumns(s, columns, columnNameMap), columnNameMap: columnNameMap, searchableColumnMap: searchableColumnMap, zeroStateMessage: getZeroStateMessage(s, pluralEntityName), columnsAreFreezable: !!(options === null || options === void 0 ? void 0 : options.columnsAreFreezable), columnsAreHideable: !!(options === null || options === void 0 ? void 0 : options.columnsAreHideable), columnsAreReorderable: (_a = options === null || options === void 0 ? void 0 : options.columnsAreReorderable) !== null && _a !== void 0 ? _a : true, rowsAreGrayed: !!(options === null || options === void 0 ? void 0 : options.rowsAreGrayed), customSummaryRow: !!(options === null || options === void 0 ? void 0 : options.customSummaryRow), csvExportAllowed, enabledCount: resolvedColumns.length, hidePageSizeSelector: !!(options === null || options === void 0 ? void 0 : options.hidePageSizeSelector), cellRowSpan: (_i, _column) => 1, needsRightBorder: () => false }), selection: Object.assign(Object.assign({}, s.selection), { allowSelection: (_b = options === null || options === void 0 ? void 0 : options.allowSelection) !== null && _b !== void 0 ? _b : false, isAllSelected: isAllSelected(s), isCurrentPageSelected: isCurrentPageSelected(s), selectedCount: selectedCount(s) }), result: Object.assign(Object.assign({}, s.result), { isGrouped: true, rowGroups, rows: rowGroups.flatMap(group => group.rows), csvData, csvFilename: getCsvFilename(pluralEntityName, options) }) });
|
|
9011
|
+
return Object.assign(Object.assign({}, s), { query: Object.assign(Object.assign({}, s.query), { pagination: Object.assign(Object.assign({}, s.query.pagination), { previous: TablePaginationHelpers.getPreviousPage(s), pages: TablePaginationHelpers.getPages(s), next: TablePaginationHelpers.getNextPage(s), pageCount: TablePaginationHelpers.getPageCount(s), showControls: TablePaginationHelpers.getShowPaginationControls(s), pageRowStart: TablePaginationHelpers.getPageRowStart(s), pageRowEnd: TablePaginationHelpers.getPageRowEnd(s) }), noSearchColumnsSelected: TableSearchHelpers.getSearchColumnsSelectedState(s, 'none') }), display: Object.assign(Object.assign({}, s.display), { columns: resolvedColumns, allColumns: TableColumnHelpers.getAllColumns(s, columns, columnNameMap), columnNameMap: columnNameMap, searchableColumnMap: searchableColumnMap, zeroStateMessage: TableDisplayHelpers.getZeroStateMessage(s, pluralEntityName), columnsAreFreezable: !!(options === null || options === void 0 ? void 0 : options.columnsAreFreezable), columnsAreHideable: !!(options === null || options === void 0 ? void 0 : options.columnsAreHideable), columnsAreReorderable: (_a = options === null || options === void 0 ? void 0 : options.columnsAreReorderable) !== null && _a !== void 0 ? _a : true, rowsAreGrayed: !!(options === null || options === void 0 ? void 0 : options.rowsAreGrayed), customSummaryRow: !!(options === null || options === void 0 ? void 0 : options.customSummaryRow), csvExportAllowed, enabledCount: resolvedColumns.length, hidePageSizeSelector: !!(options === null || options === void 0 ? void 0 : options.hidePageSizeSelector), cellRowSpan: (_i, _column) => 1, needsRightBorder: () => false }), selection: Object.assign(Object.assign({}, s.selection), { allowSelection: (_b = options === null || options === void 0 ? void 0 : options.allowSelection) !== null && _b !== void 0 ? _b : false, isAllSelected: TableSelectionHelpers.isAllSelected(s), isCurrentPageSelected: TableSelectionHelpers.isCurrentPageSelected(s), selectedCount: TableSelectionHelpers.selectedCount(s) }), result: Object.assign(Object.assign({}, s.result), { isGrouped: true, rowGroups, rows: rowGroups.flatMap(group => group.rows), csvData, csvFilename: TableResultHelpers.getCsvFilename(pluralEntityName, options) }) });
|
|
8233
9012
|
}
|
|
8234
9013
|
else {
|
|
8235
|
-
const rows = s.result.currentPageData.map(row => (Object.assign(Object.assign({}, row), { rowLink: (options === null || options === void 0 ? void 0 : options.rowLink) ? options.rowLink(row) : null, selected: isRowSelected(s, row.id) })));
|
|
8236
|
-
const cellRowSpanCache = memoizedCellRowSpan(s, resolvedColumns, options);
|
|
9014
|
+
const rows = s.result.currentPageData.map(row => (Object.assign(Object.assign({}, row), { rowLink: (options === null || options === void 0 ? void 0 : options.rowLink) ? options.rowLink(row) : null, selected: TableSelectionHelpers.isRowSelected(s, row.id) })));
|
|
9015
|
+
const cellRowSpanCache = TableDisplayHelpers.memoizedCellRowSpan(s, resolvedColumns, options);
|
|
8237
9016
|
const cellRowSpan = (rowIndex, column) => { var _a, _b; return (_b = (_a = cellRowSpanCache === null || cellRowSpanCache === void 0 ? void 0 : cellRowSpanCache.get(column)) === null || _a === void 0 ? void 0 : _a[rowIndex]) !== null && _b !== void 0 ? _b : 1; };
|
|
8238
9017
|
const hasAnyRowSpans = cellRowSpanCache
|
|
8239
9018
|
? [...cellRowSpanCache.values()].some(spans => spans.some(span => span > 1))
|
|
@@ -8252,13 +9031,14 @@ var RivTable;
|
|
|
8252
9031
|
page: 0,
|
|
8253
9032
|
pageSize: s.result.totalMatchingRowCount,
|
|
8254
9033
|
} }), { type: 'load' }));
|
|
8255
|
-
if (isGroupResult(dataSet))
|
|
9034
|
+
if (TableResultHelpers.isGroupResult(dataSet))
|
|
8256
9035
|
throw new Error('Returned grouped CSV data for non-grouped table');
|
|
8257
|
-
const fullColumns = resolveColumns(s, columns, columnNameMap, !!options.allowSelection);
|
|
9036
|
+
const fullColumns = TableColumnHelpers.resolveColumns(s, columns, columnNameMap, !!options.allowSelection);
|
|
8258
9037
|
const data = [];
|
|
8259
9038
|
data.push(fullColumns.map(({ key }) => { var _a; return (_a = columnNameMap.get(key)) !== null && _a !== void 0 ? _a : key; }));
|
|
8260
9039
|
for (const record of dataSet.currentPageData) {
|
|
8261
|
-
if (mode === 'selection' &&
|
|
9040
|
+
if (mode === 'selection' &&
|
|
9041
|
+
!TableSelectionHelpers.isRowSelected(s, record.id))
|
|
8262
9042
|
continue;
|
|
8263
9043
|
const row = [];
|
|
8264
9044
|
for (const column of fullColumns) {
|
|
@@ -8269,19 +9049,19 @@ var RivTable;
|
|
|
8269
9049
|
yield yield __await({ loading: false, data });
|
|
8270
9050
|
});
|
|
8271
9051
|
}
|
|
8272
|
-
return Object.assign(Object.assign({}, s), { query: Object.assign(Object.assign({}, s.query), { order: hasAnyRowSpans ? null : s.query.order, pagination: Object.assign(Object.assign({}, s.query.pagination), { previous: getPreviousPage(s), pages: getPages(s), next: getNextPage(s), pageCount: getPageCount(s), showControls: getShowPaginationControls(s), pageRowStart: getPageRowStart(s), pageRowEnd: getPageRowEnd(s) }), noSearchColumnsSelected: getSearchColumnsSelectedState(s, 'none') }), display: Object.assign(Object.assign({}, s.display), { columns: resolvedColumns.map(column => hasAnyRowSpans ? Object.assign(Object.assign({}, column), { orderable: false }) : column), allColumns: getAllColumns(s, columns, columnNameMap), columnNameMap: columnNameMap, searchableColumnMap: searchableColumnMap, zeroStateMessage: getZeroStateMessage(s, pluralEntityName), columnsAreFreezable: !!(options === null || options === void 0 ? void 0 : options.columnsAreFreezable), columnsAreHideable: !!(options === null || options === void 0 ? void 0 : options.columnsAreHideable), columnsAreReorderable: (_c = options === null || options === void 0 ? void 0 : options.columnsAreReorderable) !== null && _c !== void 0 ? _c : true, rowsAreGrayed: !!(options === null || options === void 0 ? void 0 : options.rowsAreGrayed), customSummaryRow: !!(options === null || options === void 0 ? void 0 : options.customSummaryRow), csvExportAllowed, enabledCount: resolvedColumns.length, hidePageSizeSelector: !!(options === null || options === void 0 ? void 0 : options.hidePageSizeSelector), cellRowSpan, needsRightBorder: (rowIndex, column) => {
|
|
9052
|
+
return Object.assign(Object.assign({}, s), { query: Object.assign(Object.assign({}, s.query), { order: hasAnyRowSpans ? null : s.query.order, pagination: Object.assign(Object.assign({}, s.query.pagination), { previous: TablePaginationHelpers.getPreviousPage(s), pages: TablePaginationHelpers.getPages(s), next: TablePaginationHelpers.getNextPage(s), pageCount: TablePaginationHelpers.getPageCount(s), showControls: TablePaginationHelpers.getShowPaginationControls(s), pageRowStart: TablePaginationHelpers.getPageRowStart(s), pageRowEnd: TablePaginationHelpers.getPageRowEnd(s) }), noSearchColumnsSelected: TableSearchHelpers.getSearchColumnsSelectedState(s, 'none') }), display: Object.assign(Object.assign({}, s.display), { columns: resolvedColumns.map(column => hasAnyRowSpans ? Object.assign(Object.assign({}, column), { orderable: false }) : column), allColumns: TableColumnHelpers.getAllColumns(s, columns, columnNameMap), columnNameMap: columnNameMap, searchableColumnMap: searchableColumnMap, zeroStateMessage: TableDisplayHelpers.getZeroStateMessage(s, pluralEntityName), columnsAreFreezable: !!(options === null || options === void 0 ? void 0 : options.columnsAreFreezable), columnsAreHideable: !!(options === null || options === void 0 ? void 0 : options.columnsAreHideable), columnsAreReorderable: (_c = options === null || options === void 0 ? void 0 : options.columnsAreReorderable) !== null && _c !== void 0 ? _c : true, rowsAreGrayed: !!(options === null || options === void 0 ? void 0 : options.rowsAreGrayed), customSummaryRow: !!(options === null || options === void 0 ? void 0 : options.customSummaryRow), csvExportAllowed, enabledCount: resolvedColumns.length, hidePageSizeSelector: !!(options === null || options === void 0 ? void 0 : options.hidePageSizeSelector), cellRowSpan, needsRightBorder: (rowIndex, column) => {
|
|
8273
9053
|
const i = resolvedColumnKeys.findIndex(key => key === column);
|
|
8274
9054
|
if (i < 0 || i === resolvedColumnKeys.length - 1)
|
|
8275
9055
|
return false;
|
|
8276
9056
|
const rightColKey = resolvedColumnKeys[i + 1];
|
|
8277
9057
|
const spanOnRight = cellRowSpan(rowIndex, rightColKey);
|
|
8278
9058
|
return spanOnRight > 1 || spanOnRight === 0;
|
|
8279
|
-
} }), selection: Object.assign(Object.assign({}, s.selection), { allowSelection: (_d = options === null || options === void 0 ? void 0 : options.allowSelection) !== null && _d !== void 0 ? _d : false, isAllSelected: isAllSelected(s), isCurrentPageSelected: isCurrentPageSelected(s), selectedCount: selectedCount(s) }), result: Object.assign(Object.assign({}, s.result), { isGrouped: false, rows, rowsAsGroup: {
|
|
9059
|
+
} }), selection: Object.assign(Object.assign({}, s.selection), { allowSelection: (_d = options === null || options === void 0 ? void 0 : options.allowSelection) !== null && _d !== void 0 ? _d : false, isAllSelected: TableSelectionHelpers.isAllSelected(s), isCurrentPageSelected: TableSelectionHelpers.isCurrentPageSelected(s), selectedCount: TableSelectionHelpers.selectedCount(s) }), result: Object.assign(Object.assign({}, s.result), { isGrouped: false, rows, rowsAsGroup: {
|
|
8280
9060
|
rows,
|
|
8281
9061
|
selected: false,
|
|
8282
9062
|
totalMatchingRowCount: rows.length,
|
|
8283
9063
|
groupData: { key: '' },
|
|
8284
|
-
}, csvFilename: getCsvFilename(pluralEntityName, options), csvData }) });
|
|
9064
|
+
}, csvFilename: TableResultHelpers.getCsvFilename(pluralEntityName, options), csvData }) });
|
|
8285
9065
|
}
|
|
8286
9066
|
}), scan((stable, newState) => stableState(stable, newState))), {
|
|
8287
9067
|
connector: () => new ReplaySubject(1),
|
|
@@ -8298,9 +9078,6 @@ var RivTable;
|
|
|
8298
9078
|
return { actions, state, effects };
|
|
8299
9079
|
}
|
|
8300
9080
|
RivTable.createManager = createManager;
|
|
8301
|
-
function orderEmptyLast(rows, key, direction) {
|
|
8302
|
-
return orderBy(rows, [row => row[key] == null, key], ['asc', direction]);
|
|
8303
|
-
}
|
|
8304
9081
|
function createInMemoryManager(fetchDataset, columns, pluralEntityName, options) {
|
|
8305
9082
|
var _a, _b, _c;
|
|
8306
9083
|
let data;
|
|
@@ -8357,14 +9134,14 @@ var RivTable;
|
|
|
8357
9134
|
const matches = fuse.search(query.search).map(result => result.item);
|
|
8358
9135
|
ordered =
|
|
8359
9136
|
hasExplicitSort && query.order
|
|
8360
|
-
? orderEmptyLast(matches, orderColumn, query.order.direction)
|
|
9137
|
+
? TableOrderHelpers.orderEmptyLast(matches, orderColumn, query.order.direction)
|
|
8361
9138
|
: matches;
|
|
8362
9139
|
}
|
|
8363
9140
|
else if (hasExplicitSort && query.order) {
|
|
8364
|
-
ordered = orderEmptyLast(data, orderColumn, query.order.direction);
|
|
9141
|
+
ordered = TableOrderHelpers.orderEmptyLast(data, orderColumn, query.order.direction);
|
|
8365
9142
|
}
|
|
8366
9143
|
else if (query.order == null && defaultSortSpec) {
|
|
8367
|
-
ordered = orderEmptyLast(data, defaultSortSpec.key, defaultSortSpec.direction);
|
|
9144
|
+
ordered = TableOrderHelpers.orderEmptyLast(data, defaultSortSpec.key, defaultSortSpec.direction);
|
|
8368
9145
|
}
|
|
8369
9146
|
else {
|
|
8370
9147
|
ordered = data;
|
|
@@ -8405,26 +9182,6 @@ var RivTable;
|
|
|
8405
9182
|
return createManager(source, columnMetadata, pluralEntityName, options);
|
|
8406
9183
|
}
|
|
8407
9184
|
RivTable.createInMemoryManager = createInMemoryManager;
|
|
8408
|
-
///////////////
|
|
8409
|
-
// Utilities //
|
|
8410
|
-
///////////////
|
|
8411
|
-
function getColumnAlignment(dataType, isFirst) {
|
|
8412
|
-
if (isFirst)
|
|
8413
|
-
return 'left';
|
|
8414
|
-
switch (dataType) {
|
|
8415
|
-
case 'date':
|
|
8416
|
-
case 'longText':
|
|
8417
|
-
return 'left';
|
|
8418
|
-
case 'advanced':
|
|
8419
|
-
case 'icon':
|
|
8420
|
-
case 'shortText':
|
|
8421
|
-
return 'center';
|
|
8422
|
-
case 'currency':
|
|
8423
|
-
case 'number':
|
|
8424
|
-
return 'right';
|
|
8425
|
-
}
|
|
8426
|
-
}
|
|
8427
|
-
RivTable.getColumnAlignment = getColumnAlignment;
|
|
8428
9185
|
})(RivTable || (RivTable = {}));
|
|
8429
9186
|
/**
|
|
8430
9187
|
* This function keeps the state object references as stable as possible, which
|
|
@@ -8462,326 +9219,6 @@ function stableState(target, source) {
|
|
|
8462
9219
|
}
|
|
8463
9220
|
return target;
|
|
8464
9221
|
}
|
|
8465
|
-
function getPageCount(state) {
|
|
8466
|
-
if (isGroupResult(state.result)) {
|
|
8467
|
-
return Math.max(Math.ceil(state.result.totalGroupCount / state.query.grouping.groupsPerPage), 1);
|
|
8468
|
-
}
|
|
8469
|
-
return Math.max(Math.ceil(state.result.totalMatchingRowCount / state.query.pagination.pageSize), 1);
|
|
8470
|
-
}
|
|
8471
|
-
function getPreviousPage(state) {
|
|
8472
|
-
return state.query.pagination.page === 0
|
|
8473
|
-
? null
|
|
8474
|
-
: state.query.pagination.page - 1;
|
|
8475
|
-
}
|
|
8476
|
-
function getPages(state) {
|
|
8477
|
-
const padding = 4;
|
|
8478
|
-
const min = 0;
|
|
8479
|
-
const max = getPageCount(state) - 1;
|
|
8480
|
-
const desiredStart = state.query.pagination.page - padding;
|
|
8481
|
-
const clampedStart = Math.max(min, desiredStart);
|
|
8482
|
-
const desiredEnd = state.query.pagination.page + padding;
|
|
8483
|
-
const clampedEnd = Math.min(max, desiredEnd);
|
|
8484
|
-
const start = Math.max(min, clampedStart - (desiredEnd - clampedEnd));
|
|
8485
|
-
const end = Math.min(max, clampedEnd + (clampedStart - desiredStart));
|
|
8486
|
-
return range(start, end + 1);
|
|
8487
|
-
}
|
|
8488
|
-
function getNextPage(state) {
|
|
8489
|
-
const max = getPageCount(state) - 1;
|
|
8490
|
-
const next = state.query.pagination.page + 1;
|
|
8491
|
-
return next <= max ? next : null;
|
|
8492
|
-
}
|
|
8493
|
-
// We don't want to show the pagination controls when they are unnecessary.
|
|
8494
|
-
function getShowPaginationControls(state) {
|
|
8495
|
-
if (state.query.pagination.page > 0) {
|
|
8496
|
-
return true;
|
|
8497
|
-
}
|
|
8498
|
-
if (isGroupResult(state.result)) {
|
|
8499
|
-
return state.result.totalGroupCount > state.query.grouping.groupsPerPage;
|
|
8500
|
-
}
|
|
8501
|
-
return (state.result.totalMatchingRowCount > Math.min(...[...RivTable.pageSizes]));
|
|
8502
|
-
}
|
|
8503
|
-
function getPageRowStart(state) {
|
|
8504
|
-
return state.query.pagination.page * state.query.pagination.pageSize + 1;
|
|
8505
|
-
}
|
|
8506
|
-
function getPageRowEnd(state) {
|
|
8507
|
-
return Math.min((state.query.pagination.page + 1) * state.query.pagination.pageSize, state.result.totalMatchingRowCount);
|
|
8508
|
-
}
|
|
8509
|
-
function getCsvFilename(pluralEntityName, options) {
|
|
8510
|
-
var _a, _b;
|
|
8511
|
-
return ((_b = (_a = options === null || options === void 0 ? void 0 : options.csvFileBasename) === null || _a === void 0 ? void 0 : _a.slice(0, 200)) !== null && _b !== void 0 ? _b : pluralEntityName) + '.csv';
|
|
8512
|
-
}
|
|
8513
|
-
function memoizedCellRowSpan(s, fullColumns, options) {
|
|
8514
|
-
const getRowSpanForCell = options === null || options === void 0 ? void 0 : options.getRowSpanForCell;
|
|
8515
|
-
const result = s.result;
|
|
8516
|
-
// If the dataset exceeds the current page size, skip span calculations.
|
|
8517
|
-
if (s.result.totalMatchingRowCount > s.query.pagination.pageSize)
|
|
8518
|
-
return null;
|
|
8519
|
-
// If the user hasn't provided the row span configuration, default to no spanning
|
|
8520
|
-
if (!getRowSpanForCell)
|
|
8521
|
-
return null;
|
|
8522
|
-
// Row spanning is not supported on grouped tables.
|
|
8523
|
-
if (isGroupResult(result))
|
|
8524
|
-
return null;
|
|
8525
|
-
// Memoize the user's configuration for the current page.
|
|
8526
|
-
return new Map(fullColumns.map(column => [
|
|
8527
|
-
column.key,
|
|
8528
|
-
result.currentPageData.map((_, i) => {
|
|
8529
|
-
const raw = getRowSpanForCell(i, column.key);
|
|
8530
|
-
if (raw === 0)
|
|
8531
|
-
return 0;
|
|
8532
|
-
else
|
|
8533
|
-
return Math.max(1, toInteger(raw));
|
|
8534
|
-
}),
|
|
8535
|
-
]));
|
|
8536
|
-
}
|
|
8537
|
-
function getAllColumns(state, supportedColumns, columnNameMap) {
|
|
8538
|
-
// If the table offers more columns than the user has configuration settings
|
|
8539
|
-
// for (or if the user has no configuration settings yet), we'll append them
|
|
8540
|
-
// to the end (unless they should be pinned by default, in which case we'll
|
|
8541
|
-
// append them after the other pinned columns). This ensures that new columns
|
|
8542
|
-
// we add to existing tables over time (1) get displayed even though they
|
|
8543
|
-
// don't appear in the user's configuration settings yet, and (2) don't
|
|
8544
|
-
// interrupt their existing setup.
|
|
8545
|
-
const columnNamesWithoutUserSettings = difference([...supportedColumns.keys()], state.display.columnSettings.map(({ key }) => key));
|
|
8546
|
-
// Throw out settings for columns no longer offered by the table.
|
|
8547
|
-
const columnsWithUserSettings = state.display.columnSettings.filter(({ key }) => supportedColumns.has(key));
|
|
8548
|
-
const columnsWithoutUserSettings = [
|
|
8549
|
-
...columnNamesWithoutUserSettings,
|
|
8550
|
-
].map((key) => {
|
|
8551
|
-
var _a;
|
|
8552
|
-
return ({
|
|
8553
|
-
key,
|
|
8554
|
-
enabled: true,
|
|
8555
|
-
preferredWidth: 'auto',
|
|
8556
|
-
pinned: !!((_a = supportedColumns.get(key)) === null || _a === void 0 ? void 0 : _a.defaultPinned),
|
|
8557
|
-
});
|
|
8558
|
-
});
|
|
8559
|
-
return orderIntentionally([...columnsWithUserSettings, ...columnsWithoutUserSettings], columnNameMap);
|
|
8560
|
-
}
|
|
8561
|
-
function orderIntentionally(columns, columnNameMap) {
|
|
8562
|
-
return [
|
|
8563
|
-
...columns.filter(v => v.pinned),
|
|
8564
|
-
...columns.filter(v => v.enabled && !v.pinned),
|
|
8565
|
-
...columns
|
|
8566
|
-
.filter(v => !v.enabled && !v.pinned)
|
|
8567
|
-
.sort((a, b) => {
|
|
8568
|
-
var _a, _b;
|
|
8569
|
-
const aName = (_a = columnNameMap.get(a.key)) !== null && _a !== void 0 ? _a : a.key;
|
|
8570
|
-
const bName = (_b = columnNameMap.get(b.key)) !== null && _b !== void 0 ? _b : b.key;
|
|
8571
|
-
return aName.localeCompare(bName);
|
|
8572
|
-
}),
|
|
8573
|
-
];
|
|
8574
|
-
}
|
|
8575
|
-
function getAlignment(metadata, index, allowSelection) {
|
|
8576
|
-
return RivTable.getColumnAlignment(metadata.dataType, index === 0 && !allowSelection);
|
|
8577
|
-
}
|
|
8578
|
-
function resolveColumns(state, supportedColumns, columnNameMap, allowSelection) {
|
|
8579
|
-
const allColumns = getAllColumns(state, supportedColumns, columnNameMap);
|
|
8580
|
-
return allColumns
|
|
8581
|
-
.filter(({ enabled }) => enabled)
|
|
8582
|
-
.reduce((fullColumns, settings, i) => {
|
|
8583
|
-
const metadata = supportedColumns.get(settings.key);
|
|
8584
|
-
const resolvedWidth = settings.preferredWidth === 'auto'
|
|
8585
|
-
? metadata.minWidth
|
|
8586
|
-
: Math.max(metadata.minWidth, settings.preferredWidth);
|
|
8587
|
-
const previousColumn = fullColumns[i - 1];
|
|
8588
|
-
return [
|
|
8589
|
-
...fullColumns,
|
|
8590
|
-
Object.assign(Object.assign(Object.assign({}, settings), metadata), { width: resolvedWidth, left: settings.pinned
|
|
8591
|
-
? previousColumn
|
|
8592
|
-
? (previousColumn.left || 0) + previousColumn.width
|
|
8593
|
-
: !!allowSelection
|
|
8594
|
-
? 40
|
|
8595
|
-
: 0
|
|
8596
|
-
: null, alignment: getAlignment(metadata, i, !!allowSelection) }),
|
|
8597
|
-
];
|
|
8598
|
-
}, []);
|
|
8599
|
-
}
|
|
8600
|
-
function getZeroStateMessage(state, entity) {
|
|
8601
|
-
if ((isGroupResult(state.result) && state.result.totalGroupCount > 0) ||
|
|
8602
|
-
(!isGroupResult(state.result) && state.result.totalMatchingRowCount > 0))
|
|
8603
|
-
return null;
|
|
8604
|
-
const allSearchColumnsSelected = getSearchColumnsSelectedState(state, 'all');
|
|
8605
|
-
if (state.query.search && allSearchColumnsSelected)
|
|
8606
|
-
return `No ${entity} match your current search keyword.`;
|
|
8607
|
-
if (state.query.search && !allSearchColumnsSelected)
|
|
8608
|
-
return `No ${entity} match your current search keyword in the selected search columns.`;
|
|
8609
|
-
if (state.query.filters)
|
|
8610
|
-
return `No ${entity} match your current filters.`;
|
|
8611
|
-
return `No ${entity}.`;
|
|
8612
|
-
}
|
|
8613
|
-
function changeColumnPin(state, columns, columnNameMap, column, pinned) {
|
|
8614
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8615
|
-
if (pinned) {
|
|
8616
|
-
const target = allColumns.find(c => c.key === column);
|
|
8617
|
-
const wasEnabled = !!(target === null || target === void 0 ? void 0 : target.enabled);
|
|
8618
|
-
if (!wasEnabled) {
|
|
8619
|
-
const enabledCount = allColumns.filter(col => col.enabled).length;
|
|
8620
|
-
if (enabledCount >= RivTable.ColumnsMaxShown) {
|
|
8621
|
-
return state; // refuse the pin since it would exceed the max
|
|
8622
|
-
}
|
|
8623
|
-
}
|
|
8624
|
-
}
|
|
8625
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { pinned: c.key === column ? pinned : c.pinned,
|
|
8626
|
-
// Check/enable if being pinned
|
|
8627
|
-
enabled: c.key === column && pinned ? true : c.enabled }))), columnNameMap) }) });
|
|
8628
|
-
}
|
|
8629
|
-
function changeColumnsFreezeState(state, columns, columnNameMap, index, freeze) {
|
|
8630
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8631
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: allColumns.map((c, i) => {
|
|
8632
|
-
return Object.assign(Object.assign({}, c), { pinned: freeze && i <= index });
|
|
8633
|
-
}) }) });
|
|
8634
|
-
}
|
|
8635
|
-
function moveColumnTo(state, columns, columnNameMap, column, position) {
|
|
8636
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8637
|
-
const previousIndex = allColumns.findIndex(c => c.key === column);
|
|
8638
|
-
const lastIndex = position == 'end' ? allColumns.findIndex(c => !c.enabled) : 0;
|
|
8639
|
-
const newIndex = position == 'start'
|
|
8640
|
-
? 0
|
|
8641
|
-
: lastIndex == -1
|
|
8642
|
-
? allColumns.length - 1
|
|
8643
|
-
: lastIndex;
|
|
8644
|
-
if (!allColumns[previousIndex].enabled &&
|
|
8645
|
-
allColumns.filter(col => col.enabled).length >= RivTable.ColumnsMaxShown)
|
|
8646
|
-
return state;
|
|
8647
|
-
const movedState = changeColumnOrder(state, columns, columnNameMap, previousIndex, newIndex);
|
|
8648
|
-
//Make sure the column is enabled
|
|
8649
|
-
return changeColumnEnabled(movedState, columns, columnNameMap, column, true);
|
|
8650
|
-
}
|
|
8651
|
-
function changeColumnOrder(state, columns, columnNameMap, previousIndex, newIndex) {
|
|
8652
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8653
|
-
// First, put the columns in the desired order.
|
|
8654
|
-
const item = allColumns[previousIndex];
|
|
8655
|
-
const withoutItem = allColumns.filter((_, i) => i !== previousIndex);
|
|
8656
|
-
const reordered = [
|
|
8657
|
-
...withoutItem.slice(0, newIndex),
|
|
8658
|
-
item,
|
|
8659
|
-
...withoutItem.slice(newIndex),
|
|
8660
|
-
];
|
|
8661
|
-
// Then, we may need to fix the pins (all pinned columns appear at the
|
|
8662
|
-
// beginning of the columns array) since the user is allowed to drag
|
|
8663
|
-
// and drop columns to and from the pinned area. If the user drags a
|
|
8664
|
-
// column across that threshold, update its pinned status.
|
|
8665
|
-
const updated = reordered.map((settings, i, arr) => {
|
|
8666
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8667
|
-
if (newIndex === i) {
|
|
8668
|
-
return Object.assign(Object.assign({}, settings), { pinned: settings.pinned
|
|
8669
|
-
? (_b = (_a = arr[i - 1]) === null || _a === void 0 ? void 0 : _a.pinned) !== null && _b !== void 0 ? _b : true
|
|
8670
|
-
: (_d = (_c = arr[i + 1]) === null || _c === void 0 ? void 0 : _c.pinned) !== null && _d !== void 0 ? _d : false, enabled: settings.enabled
|
|
8671
|
-
? (_f = (_e = arr[i - 1]) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : true
|
|
8672
|
-
: (_h = (_g = arr[i + 1]) === null || _g === void 0 ? void 0 : _g.enabled) !== null && _h !== void 0 ? _h : false });
|
|
8673
|
-
}
|
|
8674
|
-
else
|
|
8675
|
-
return settings;
|
|
8676
|
-
});
|
|
8677
|
-
const wasDisabled = !item.enabled;
|
|
8678
|
-
const becameEnabled = updated[newIndex].enabled;
|
|
8679
|
-
if (wasDisabled && becameEnabled) {
|
|
8680
|
-
const enabledCount = allColumns.filter(c => c.enabled).length;
|
|
8681
|
-
if (enabledCount >= RivTable.ColumnsMaxShown) {
|
|
8682
|
-
// Refuse the move; keep state as-is
|
|
8683
|
-
return state;
|
|
8684
|
-
}
|
|
8685
|
-
}
|
|
8686
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(updated, columnNameMap) }) });
|
|
8687
|
-
}
|
|
8688
|
-
function changeColumnEnabled(state, columns, columnNameMap, column, enabled) {
|
|
8689
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8690
|
-
if (enabled &&
|
|
8691
|
-
allColumns.filter(col => col.enabled).length >= RivTable.ColumnsMaxShown) {
|
|
8692
|
-
return state;
|
|
8693
|
-
}
|
|
8694
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { enabled: c.key === column ? enabled : c.enabled,
|
|
8695
|
-
// Unpin if being unchecked
|
|
8696
|
-
pinned: c.key === column && !enabled ? false : c.pinned }))), columnNameMap) }) });
|
|
8697
|
-
}
|
|
8698
|
-
function enableAllColumns(state, columns, columnNameMap, enabled) {
|
|
8699
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8700
|
-
if (enabled && allColumns.length > RivTable.ColumnsMaxShown)
|
|
8701
|
-
return state;
|
|
8702
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(allColumns.map(c => (Object.assign(Object.assign({}, c), { enabled: enabled,
|
|
8703
|
-
// Unpin if being unchecked
|
|
8704
|
-
pinned: !enabled ? false : c.pinned }))), columnNameMap) }) });
|
|
8705
|
-
}
|
|
8706
|
-
function changeColumnWidth(state, columns, columnNameMap, column, preferredWidth) {
|
|
8707
|
-
const allColumns = getAllColumns(state, columns, columnNameMap);
|
|
8708
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: allColumns.map(c => (Object.assign(Object.assign({}, c), { preferredWidth: c.key === column ? preferredWidth : c.preferredWidth }))) }) });
|
|
8709
|
-
}
|
|
8710
|
-
function resetToDefaultColumns(state, columns, columnNameMap, defaultColumnState) {
|
|
8711
|
-
return Object.assign(Object.assign({}, state), { display: Object.assign(Object.assign({}, state.display), { columnSettings: orderIntentionally(defaultColumnState, columnNameMap) }) });
|
|
8712
|
-
}
|
|
8713
|
-
function isRowSelected(state, id) {
|
|
8714
|
-
switch (state.selection.mode) {
|
|
8715
|
-
case 'include':
|
|
8716
|
-
return state.selection.included.has(id);
|
|
8717
|
-
case 'exclude':
|
|
8718
|
-
return !state.selection.excluded.has(id);
|
|
8719
|
-
}
|
|
8720
|
-
}
|
|
8721
|
-
function isGroupSelected(state, group) {
|
|
8722
|
-
switch (state.selection.mode) {
|
|
8723
|
-
case 'include': {
|
|
8724
|
-
let allFound = true;
|
|
8725
|
-
let anyFound = false;
|
|
8726
|
-
for (const row of group.currentPageData) {
|
|
8727
|
-
if (!state.selection.included.has(row.id)) {
|
|
8728
|
-
allFound = false;
|
|
8729
|
-
}
|
|
8730
|
-
else {
|
|
8731
|
-
anyFound = true;
|
|
8732
|
-
}
|
|
8733
|
-
}
|
|
8734
|
-
return allFound ? true : anyFound ? 'indeterminate' : false;
|
|
8735
|
-
}
|
|
8736
|
-
case 'exclude': {
|
|
8737
|
-
let allFound = true;
|
|
8738
|
-
let anyFound = false;
|
|
8739
|
-
for (const row of group.currentPageData) {
|
|
8740
|
-
if (state.selection.excluded.has(row.id)) {
|
|
8741
|
-
allFound = false;
|
|
8742
|
-
}
|
|
8743
|
-
else {
|
|
8744
|
-
anyFound = true;
|
|
8745
|
-
}
|
|
8746
|
-
}
|
|
8747
|
-
return allFound ? true : anyFound ? 'indeterminate' : false;
|
|
8748
|
-
}
|
|
8749
|
-
}
|
|
8750
|
-
}
|
|
8751
|
-
function isAllSelected(state) {
|
|
8752
|
-
// If there are no rows, "all selected" should be false
|
|
8753
|
-
if (state.result.totalMatchingRowCount === 0) {
|
|
8754
|
-
return false;
|
|
8755
|
-
}
|
|
8756
|
-
if ((state.selection.mode === 'exclude' &&
|
|
8757
|
-
state.selection.excluded.size === 0) ||
|
|
8758
|
-
(state.selection.mode === 'include' &&
|
|
8759
|
-
state.selection.included.size === state.result.totalMatchingRowCount))
|
|
8760
|
-
return true;
|
|
8761
|
-
if ((state.selection.mode === 'exclude' &&
|
|
8762
|
-
state.selection.excluded.size === state.result.totalMatchingRowCount) ||
|
|
8763
|
-
(state.selection.mode === 'include' && state.selection.included.size === 0))
|
|
8764
|
-
return false;
|
|
8765
|
-
return 'indeterminate';
|
|
8766
|
-
}
|
|
8767
|
-
function isCurrentPageSelected(state) {
|
|
8768
|
-
const selectedStates = getAllRowsFromResult(state.result).map(({ id }) => isRowSelected(state, id));
|
|
8769
|
-
if (selectedStates.length > 0) {
|
|
8770
|
-
if (selectedStates.every(v => v))
|
|
8771
|
-
return true;
|
|
8772
|
-
if (selectedStates.some(v => v))
|
|
8773
|
-
return 'indeterminate';
|
|
8774
|
-
}
|
|
8775
|
-
return false;
|
|
8776
|
-
}
|
|
8777
|
-
function selectedCount(state) {
|
|
8778
|
-
switch (state.selection.mode) {
|
|
8779
|
-
case 'include':
|
|
8780
|
-
return state.selection.included.size;
|
|
8781
|
-
case 'exclude':
|
|
8782
|
-
return state.result.totalMatchingRowCount - state.selection.excluded.size;
|
|
8783
|
-
}
|
|
8784
|
-
}
|
|
8785
9222
|
function refreshResultWith(state, source, mostRecentAction) {
|
|
8786
9223
|
return __asyncGenerator(this, arguments, function* refreshResultWith_1() {
|
|
8787
9224
|
yield yield __await({
|
|
@@ -8793,7 +9230,7 @@ function refreshResultWith(state, source, mostRecentAction) {
|
|
|
8793
9230
|
});
|
|
8794
9231
|
try {
|
|
8795
9232
|
const result = yield __await(source(state.query, mostRecentAction));
|
|
8796
|
-
if (isPageOutOfBounds(state, result)) {
|
|
9233
|
+
if (TablePaginationHelpers.isPageOutOfBounds(state, result)) {
|
|
8797
9234
|
state.query.pagination.page = 0;
|
|
8798
9235
|
}
|
|
8799
9236
|
yield yield __await({
|
|
@@ -8817,106 +9254,6 @@ function refreshResultWith(state, source, mostRecentAction) {
|
|
|
8817
9254
|
}
|
|
8818
9255
|
});
|
|
8819
9256
|
}
|
|
8820
|
-
function setRowSelected(state, id, selected, contiguous) {
|
|
8821
|
-
if (selected) {
|
|
8822
|
-
const newSelection = new Set([id]);
|
|
8823
|
-
if (contiguous && state.selection.mostRecentlySelected) {
|
|
8824
|
-
const startIdx = getAllRowsFromResult(state.result).findIndex(row => row.id === state.selection.mostRecentlySelected);
|
|
8825
|
-
const endIdx = getAllRowsFromResult(state.result).findIndex(row => row.id === id);
|
|
8826
|
-
if (typeof startIdx === 'number' && typeof endIdx === 'number') {
|
|
8827
|
-
for (let i = Math.min(startIdx, endIdx); i <= Math.max(startIdx, endIdx); i++) {
|
|
8828
|
-
newSelection.add(getAllRowsFromResult(state.result)[i].id);
|
|
8829
|
-
}
|
|
8830
|
-
}
|
|
8831
|
-
}
|
|
8832
|
-
return Object.assign(Object.assign({}, state), { selection: Object.assign({ mostRecentlySelected: id }, (state.selection.mode === 'include'
|
|
8833
|
-
? {
|
|
8834
|
-
mode: 'include',
|
|
8835
|
-
included: new Set(union([...state.selection.included], [...newSelection])),
|
|
8836
|
-
}
|
|
8837
|
-
: {
|
|
8838
|
-
mode: 'exclude',
|
|
8839
|
-
excluded: new Set(difference([...state.selection.excluded], [...newSelection])),
|
|
8840
|
-
})) });
|
|
8841
|
-
}
|
|
8842
|
-
else {
|
|
8843
|
-
return Object.assign(Object.assign({}, state), { selection: Object.assign({ mostRecentlySelected: null }, (state.selection.mode === 'include'
|
|
8844
|
-
? {
|
|
8845
|
-
mode: 'include',
|
|
8846
|
-
included: new Set(difference([...state.selection.included], [id])),
|
|
8847
|
-
}
|
|
8848
|
-
: {
|
|
8849
|
-
mode: 'exclude',
|
|
8850
|
-
excluded: new Set(union([...state.selection.excluded], [id])),
|
|
8851
|
-
})) });
|
|
8852
|
-
}
|
|
8853
|
-
}
|
|
8854
|
-
function toggleGroupSelected(state, group) {
|
|
8855
|
-
const isGroupFullySelected = isGroupSelected(state, Object.assign(Object.assign({}, group), { currentPageData: group.rows })) === true;
|
|
8856
|
-
return group.rows.reduce((accumulatedState, row) => {
|
|
8857
|
-
return setRowSelected(accumulatedState, row.id, !isGroupFullySelected, false);
|
|
8858
|
-
}, state);
|
|
8859
|
-
}
|
|
8860
|
-
function togglePageSelected(state) {
|
|
8861
|
-
const isPageFullySelected = getAllRowsFromResult(state.result).every(({ id }) => isRowSelected(state, id));
|
|
8862
|
-
return getAllRowsFromResult(state.result).reduce((accumulatedState, row) => {
|
|
8863
|
-
return setRowSelected(accumulatedState, row.id, !isPageFullySelected, false);
|
|
8864
|
-
}, state);
|
|
8865
|
-
}
|
|
8866
|
-
function toggleAllSelected(state) {
|
|
8867
|
-
if (isAllSelected(state) === true) {
|
|
8868
|
-
return Object.assign(Object.assign({}, state), { selection: {
|
|
8869
|
-
mostRecentlySelected: null,
|
|
8870
|
-
mode: 'include',
|
|
8871
|
-
included: new Set(),
|
|
8872
|
-
} });
|
|
8873
|
-
}
|
|
8874
|
-
else {
|
|
8875
|
-
return Object.assign(Object.assign({}, state), { selection: {
|
|
8876
|
-
mostRecentlySelected: null,
|
|
8877
|
-
mode: 'exclude',
|
|
8878
|
-
excluded: new Set(),
|
|
8879
|
-
} });
|
|
8880
|
-
}
|
|
8881
|
-
}
|
|
8882
|
-
function clearSelection(state) {
|
|
8883
|
-
return Object.assign(Object.assign({}, state), { selection: {
|
|
8884
|
-
mostRecentlySelected: null,
|
|
8885
|
-
mode: 'include',
|
|
8886
|
-
included: new Set(),
|
|
8887
|
-
} });
|
|
8888
|
-
}
|
|
8889
|
-
function toggleColumnOrder(state, column) {
|
|
8890
|
-
var _a;
|
|
8891
|
-
if (((_a = state.query.order) === null || _a === void 0 ? void 0 : _a.column) === column) {
|
|
8892
|
-
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { order: state.query.order.direction === 'asc'
|
|
8893
|
-
? {
|
|
8894
|
-
column,
|
|
8895
|
-
direction: 'desc',
|
|
8896
|
-
}
|
|
8897
|
-
: null }) });
|
|
8898
|
-
}
|
|
8899
|
-
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { order: {
|
|
8900
|
-
column,
|
|
8901
|
-
direction: 'asc',
|
|
8902
|
-
} }) });
|
|
8903
|
-
}
|
|
8904
|
-
function getSearchColumnsSelectedState(state, expectedValue) {
|
|
8905
|
-
switch (expectedValue) {
|
|
8906
|
-
case 'all':
|
|
8907
|
-
return Array.from(state.query.searchColumns.values()).every(value => value);
|
|
8908
|
-
case 'none':
|
|
8909
|
-
return Array.from(state.query.searchColumns.values()).every(value => !value);
|
|
8910
|
-
}
|
|
8911
|
-
}
|
|
8912
|
-
function toggleAllSearchColumns(state) {
|
|
8913
|
-
const noneSelected = getSearchColumnsSelectedState(state, 'none');
|
|
8914
|
-
const payload = new Map(Array.from(state.query.searchColumns.keys()).map(key => [
|
|
8915
|
-
key,
|
|
8916
|
-
noneSelected,
|
|
8917
|
-
]));
|
|
8918
|
-
return Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { searchColumns: payload }) });
|
|
8919
|
-
}
|
|
8920
9257
|
function reduce(state, action, columns, source, columnNameMap, defaultColumnState) {
|
|
8921
9258
|
var _a, _b;
|
|
8922
9259
|
return __asyncGenerator(this, arguments, function* reduce_1() {
|
|
@@ -8932,7 +9269,7 @@ function reduce(state, action, columns, source, columnNameMap, defaultColumnStat
|
|
|
8932
9269
|
} }), source, action))));
|
|
8933
9270
|
break;
|
|
8934
9271
|
case 'orderColumnToggle':
|
|
8935
|
-
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(toggleColumnOrder(state, action.column), source, action))));
|
|
9272
|
+
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(TableOrderHelpers.toggleColumnOrder(state, action.column), source, action))));
|
|
8936
9273
|
break;
|
|
8937
9274
|
case 'searchChange':
|
|
8938
9275
|
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { search: action.payload, pagination: Object.assign(Object.assign({}, state.query.pagination), { page: 0 }) }), selection: {
|
|
@@ -8958,10 +9295,10 @@ function reduce(state, action, columns, source, columnNameMap, defaultColumnStat
|
|
|
8958
9295
|
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { grouping: action.payload }) }), source, action))));
|
|
8959
9296
|
break;
|
|
8960
9297
|
case 'previousPageNavigate':
|
|
8961
|
-
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { pagination: Object.assign(Object.assign({}, state.query.pagination), { page: (_a = getPreviousPage(state)) !== null && _a !== void 0 ? _a : 0 }) }) }), source, action))));
|
|
9298
|
+
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { pagination: Object.assign(Object.assign({}, state.query.pagination), { page: (_a = TablePaginationHelpers.getPreviousPage(state)) !== null && _a !== void 0 ? _a : 0 }) }) }), source, action))));
|
|
8962
9299
|
break;
|
|
8963
9300
|
case 'nextPageNavigate':
|
|
8964
|
-
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { pagination: Object.assign(Object.assign({}, state.query.pagination), { page: (_b = getNextPage(state)) !== null && _b !== void 0 ? _b : getPageCount(state) - 1 }) }) }), source, action))));
|
|
9301
|
+
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { pagination: Object.assign(Object.assign({}, state.query.pagination), { page: (_b = TablePaginationHelpers.getNextPage(state)) !== null && _b !== void 0 ? _b : TablePaginationHelpers.getPageCount(state) - 1 }) }) }), source, action))));
|
|
8965
9302
|
break;
|
|
8966
9303
|
case 'pageChange':
|
|
8967
9304
|
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { pagination: Object.assign(Object.assign({}, state.query.pagination), { page: action.page }) }) }), source, action))));
|
|
@@ -8989,49 +9326,49 @@ function reduce(state, action, columns, source, columnNameMap, defaultColumnStat
|
|
|
8989
9326
|
break;
|
|
8990
9327
|
case 'columnPinChange':
|
|
8991
9328
|
yield yield __await({
|
|
8992
|
-
state: changeColumnPin(state, columns, columnNameMap, action.column, action.pinned),
|
|
9329
|
+
state: TableColumnHelpers.changeColumnPin(state, columns, columnNameMap, action.column, action.pinned),
|
|
8993
9330
|
effect: 'saveColumnPreferences',
|
|
8994
9331
|
});
|
|
8995
9332
|
break;
|
|
8996
9333
|
case 'columnsFreezeUpToChange':
|
|
8997
9334
|
yield yield __await({
|
|
8998
|
-
state: changeColumnsFreezeState(state, columns, columnNameMap, action.index, action.freeze),
|
|
9335
|
+
state: TableColumnHelpers.changeColumnsFreezeState(state, columns, columnNameMap, action.index, action.freeze),
|
|
8999
9336
|
effect: 'saveColumnPreferences',
|
|
9000
9337
|
});
|
|
9001
9338
|
break;
|
|
9002
9339
|
case 'columnOrderChange':
|
|
9003
9340
|
yield yield __await({
|
|
9004
|
-
state: changeColumnOrder(state, columns, columnNameMap, action.previousIndex, action.newIndex),
|
|
9341
|
+
state: TableColumnHelpers.changeColumnOrder(state, columns, columnNameMap, action.previousIndex, action.newIndex),
|
|
9005
9342
|
effect: 'saveColumnPreferences',
|
|
9006
9343
|
});
|
|
9007
9344
|
break;
|
|
9008
9345
|
case 'columnMoveToChange':
|
|
9009
9346
|
yield yield __await({
|
|
9010
|
-
state: moveColumnTo(state, columns, columnNameMap, action.column, action.position),
|
|
9347
|
+
state: TableColumnHelpers.moveColumnTo(state, columns, columnNameMap, action.column, action.position),
|
|
9011
9348
|
effect: 'saveColumnPreferences',
|
|
9012
9349
|
});
|
|
9013
9350
|
break;
|
|
9014
9351
|
case 'columnEnabledChange':
|
|
9015
9352
|
yield yield __await({
|
|
9016
|
-
state: changeColumnEnabled(state, columns, columnNameMap, action.column, action.enabled),
|
|
9353
|
+
state: TableColumnHelpers.changeColumnEnabled(state, columns, columnNameMap, action.column, action.enabled),
|
|
9017
9354
|
effect: 'saveColumnPreferences',
|
|
9018
9355
|
});
|
|
9019
9356
|
break;
|
|
9020
9357
|
case 'enableAllColumnsChange':
|
|
9021
9358
|
yield yield __await({
|
|
9022
|
-
state: enableAllColumns(state, columns, columnNameMap, action.enabled),
|
|
9359
|
+
state: TableColumnHelpers.enableAllColumns(state, columns, columnNameMap, action.enabled),
|
|
9023
9360
|
effect: 'saveColumnPreferences',
|
|
9024
9361
|
});
|
|
9025
9362
|
break;
|
|
9026
9363
|
case 'columnWidthChange':
|
|
9027
9364
|
yield yield __await({
|
|
9028
|
-
state: changeColumnWidth(state, columns, columnNameMap, action.column, action.preferredWidth),
|
|
9365
|
+
state: TableColumnHelpers.changeColumnWidth(state, columns, columnNameMap, action.column, action.preferredWidth),
|
|
9029
9366
|
effect: 'saveColumnPreferences',
|
|
9030
9367
|
});
|
|
9031
9368
|
break;
|
|
9032
9369
|
case 'resetToDefaultColumns':
|
|
9033
9370
|
yield yield __await({
|
|
9034
|
-
state: resetToDefaultColumns(state, columns, columnNameMap, defaultColumnState),
|
|
9371
|
+
state: TableColumnHelpers.resetToDefaultColumns(state, columns, columnNameMap, defaultColumnState),
|
|
9035
9372
|
effect: 'saveColumnPreferences',
|
|
9036
9373
|
});
|
|
9037
9374
|
break;
|
|
@@ -9043,31 +9380,31 @@ function reduce(state, action, columns, source, columnNameMap, defaultColumnStat
|
|
|
9043
9380
|
break;
|
|
9044
9381
|
case 'rowSelectedChange':
|
|
9045
9382
|
yield yield __await({
|
|
9046
|
-
state: setRowSelected(state, action.id, action.selected, action.contiguous),
|
|
9383
|
+
state: TableSelectionHelpers.setRowSelected(state, action.id, action.selected, action.contiguous),
|
|
9047
9384
|
effect: null,
|
|
9048
9385
|
});
|
|
9049
9386
|
break;
|
|
9050
9387
|
case 'pageSelectedChange':
|
|
9051
9388
|
yield yield __await({
|
|
9052
|
-
state: togglePageSelected(state),
|
|
9389
|
+
state: TableSelectionHelpers.togglePageSelected(state),
|
|
9053
9390
|
effect: null,
|
|
9054
9391
|
});
|
|
9055
9392
|
break;
|
|
9056
9393
|
case 'allSelectedChange':
|
|
9057
9394
|
yield yield __await({
|
|
9058
|
-
state: toggleAllSelected(state),
|
|
9395
|
+
state: TableSelectionHelpers.toggleAllSelected(state),
|
|
9059
9396
|
effect: null,
|
|
9060
9397
|
});
|
|
9061
9398
|
break;
|
|
9062
9399
|
case 'selectionClear':
|
|
9063
9400
|
yield yield __await({
|
|
9064
|
-
state: clearSelection(state),
|
|
9401
|
+
state: TableSelectionHelpers.clearSelection(state),
|
|
9065
9402
|
effect: null,
|
|
9066
9403
|
});
|
|
9067
9404
|
break;
|
|
9068
9405
|
case 'groupSelectionChange':
|
|
9069
9406
|
yield yield __await({
|
|
9070
|
-
state: toggleGroupSelected(state, action.payload),
|
|
9407
|
+
state: TableSelectionHelpers.toggleGroupSelected(state, action.payload),
|
|
9071
9408
|
effect: null,
|
|
9072
9409
|
});
|
|
9073
9410
|
break;
|
|
@@ -9081,40 +9418,11 @@ function reduce(state, action, columns, source, columnNameMap, defaultColumnStat
|
|
|
9081
9418
|
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(Object.assign(Object.assign({}, state), { query: Object.assign(Object.assign({}, state.query), { grouping: Object.assign(Object.assign({}, state.query.grouping), { viewMoreKey: action.viewMoreKey }) }) }), source, action))));
|
|
9082
9419
|
break;
|
|
9083
9420
|
case 'toggleAllSearchColumns':
|
|
9084
|
-
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(toggleAllSearchColumns(state), source, action))));
|
|
9421
|
+
yield __await(yield* __asyncDelegator(__asyncValues(refreshResultWith(TableSearchHelpers.toggleAllSearchColumns(state), source, action))));
|
|
9085
9422
|
break;
|
|
9086
9423
|
}
|
|
9087
9424
|
});
|
|
9088
9425
|
}
|
|
9089
|
-
function isGroupResult(result) {
|
|
9090
|
-
if ('totalGroupCount' in result) {
|
|
9091
|
-
return true;
|
|
9092
|
-
}
|
|
9093
|
-
return false;
|
|
9094
|
-
}
|
|
9095
|
-
function getAllRowsFromResult(result) {
|
|
9096
|
-
if (isGroupResult(result)) {
|
|
9097
|
-
return result.groupResults.flatMap(groups => groups.currentPageData);
|
|
9098
|
-
}
|
|
9099
|
-
else {
|
|
9100
|
-
return result.currentPageData;
|
|
9101
|
-
}
|
|
9102
|
-
}
|
|
9103
|
-
function isPageOutOfBounds(state, result) {
|
|
9104
|
-
if (isGroupResult(result)) {
|
|
9105
|
-
const minGroupValToShowOnCurrentPage = state.query.pagination.page * state.query.grouping.groupsPerPage + 1;
|
|
9106
|
-
if (result.totalGroupCount < minGroupValToShowOnCurrentPage) {
|
|
9107
|
-
return true;
|
|
9108
|
-
}
|
|
9109
|
-
}
|
|
9110
|
-
else {
|
|
9111
|
-
const minRowToShowOnCurrentPage = state.query.pagination.page * state.query.pagination.pageSize + 1;
|
|
9112
|
-
if (result.totalMatchingRowCount < minRowToShowOnCurrentPage) {
|
|
9113
|
-
return true;
|
|
9114
|
-
}
|
|
9115
|
-
}
|
|
9116
|
-
return false;
|
|
9117
|
-
}
|
|
9118
9426
|
|
|
9119
9427
|
function createCellCoordinateCalculator(cells, totalColumns) {
|
|
9120
9428
|
// Pre-calculate coordinates for all cells
|
|
@@ -9193,7 +9501,7 @@ class SimpleTableComponent {
|
|
|
9193
9501
|
const allowedTypes = RivTable.ColumnDataTypes.join(', ');
|
|
9194
9502
|
throw new Error(`Each header cell must define an appropriate dataType, one of ${allowedTypes}`);
|
|
9195
9503
|
}
|
|
9196
|
-
const newAlignment =
|
|
9504
|
+
const newAlignment = TableColumnHelpers.getColumnAlignment(dataType, i === 0);
|
|
9197
9505
|
const newLeftPinOffset = runningWidthTotal;
|
|
9198
9506
|
runningWidthTotal += headerCell.width;
|
|
9199
9507
|
const changed = headerCell.alignment != newAlignment ||
|
|
@@ -9653,10 +9961,10 @@ class TableHeaderResizeHandleComponent {
|
|
|
9653
9961
|
}
|
|
9654
9962
|
}
|
|
9655
9963
|
TableHeaderResizeHandleComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableHeaderResizeHandleComponent, deps: [{ token: i0.ElementRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
|
|
9656
|
-
TableHeaderResizeHandleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableHeaderResizeHandleComponent, selector: "riv-table-header-resize-handle", outputs: { dragResize: "dragResize" }, ngImport: i0, template: "", styles: [":host{position:absolute;top:0;right:calc(var(--border-width) * -1);bottom:0;padding-left:var(--size-small);background-color:var(--brand);background-clip:content-box;box-sizing:content-box;width:var(--border-width);opacity:0;transition:opacity var(--medium-transition);cursor:ew-resize}:host:hover{opacity:1}\n"] });
|
|
9964
|
+
TableHeaderResizeHandleComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.10", type: TableHeaderResizeHandleComponent, selector: "riv-table-header-resize-handle", outputs: { dragResize: "dragResize" }, ngImport: i0, template: "", styles: [":host{position:absolute;top:0;right:calc(var(--border-width) * -1);bottom:0;padding-left:var(--size-small);background-color:var(--brand);background-clip:content-box;box-sizing:content-box;width:var(--border-width);opacity:0;transition:opacity var(--medium-transition);cursor:ew-resize}:host:hover{opacity:1}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
9657
9965
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TableHeaderResizeHandleComponent, decorators: [{
|
|
9658
9966
|
type: Component,
|
|
9659
|
-
args: [{ selector: 'riv-table-header-resize-handle', template: "", styles: [":host{position:absolute;top:0;right:calc(var(--border-width) * -1);bottom:0;padding-left:var(--size-small);background-color:var(--brand);background-clip:content-box;box-sizing:content-box;width:var(--border-width);opacity:0;transition:opacity var(--medium-transition);cursor:ew-resize}:host:hover{opacity:1}\n"] }]
|
|
9967
|
+
args: [{ selector: 'riv-table-header-resize-handle', changeDetection: ChangeDetectionStrategy.OnPush, template: "", styles: [":host{position:absolute;top:0;right:calc(var(--border-width) * -1);bottom:0;padding-left:var(--size-small);background-color:var(--brand);background-clip:content-box;box-sizing:content-box;width:var(--border-width);opacity:0;transition:opacity var(--medium-transition);cursor:ew-resize}:host:hover{opacity:1}\n"] }]
|
|
9660
9968
|
}], ctorParameters: function () {
|
|
9661
9969
|
return [{ type: i0.ElementRef }, { type: Document, decorators: [{
|
|
9662
9970
|
type: Inject,
|