@redsift/table 11.3.1-alpha.1 → 11.3.1-muiv5
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/index.d.ts +32 -26
- package/index.js +400 -289
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputMultipleValue, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators,
|
|
1
|
+
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridNumericOperators as getGridNumericOperators$1, GridFilterInputValue, GridFilterInputMultipleValue, getGridStringOperators as getGridStringOperators$1, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators, GridLinkOperator, GridToolbarContainer, GridToolbarFilterButton, GridToolbarColumnsButton, GridToolbarDensitySelector, GridToolbarExport, gridVisibleSortedRowIdsSelector, GridToolbarQuickFilter, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, useGridApiRef, DataGridPro } from '@mui/x-data-grid-pro';
|
|
2
2
|
export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { Children, isValidElement, cloneElement, forwardRef, useLayoutEffect, useEffect, useRef, useContext, useState, useCallback, createElement, useMemo } from 'react';
|
|
@@ -17639,7 +17639,7 @@ const isBetweenOperator = {
|
|
|
17639
17639
|
label: 'is between',
|
|
17640
17640
|
value: 'isBetween',
|
|
17641
17641
|
getApplyFilterFn: filterItem => {
|
|
17642
|
-
if (!filterItem.
|
|
17642
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17643
17643
|
return null;
|
|
17644
17644
|
}
|
|
17645
17645
|
if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
|
|
@@ -17652,7 +17652,7 @@ const isBetweenOperator = {
|
|
|
17652
17652
|
return null;
|
|
17653
17653
|
}
|
|
17654
17654
|
return params => {
|
|
17655
|
-
return params.value !== null &&
|
|
17655
|
+
return params.value !== null && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
17656
17656
|
};
|
|
17657
17657
|
},
|
|
17658
17658
|
InputComponent: InputNumberInterval
|
|
@@ -17665,7 +17665,7 @@ const doesNotEqual = {
|
|
|
17665
17665
|
label: 'does not equal',
|
|
17666
17666
|
value: 'doesNotEqual',
|
|
17667
17667
|
getApplyFilterFn: filterItem => {
|
|
17668
|
-
if (!filterItem.
|
|
17668
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17669
17669
|
return null;
|
|
17670
17670
|
}
|
|
17671
17671
|
return params => {
|
|
@@ -17686,7 +17686,7 @@ const doesNotContain = {
|
|
|
17686
17686
|
label: 'does not contain',
|
|
17687
17687
|
value: 'doesNotContain',
|
|
17688
17688
|
getApplyFilterFn: filterItem => {
|
|
17689
|
-
if (!filterItem.
|
|
17689
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17690
17690
|
return null;
|
|
17691
17691
|
}
|
|
17692
17692
|
return params => {
|
|
@@ -17707,7 +17707,7 @@ const containsAnyOfOperator = {
|
|
|
17707
17707
|
label: 'contains any of',
|
|
17708
17708
|
value: 'containsAnyOf',
|
|
17709
17709
|
getApplyFilterFn: filterItem => {
|
|
17710
|
-
if (!filterItem.
|
|
17710
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17711
17711
|
return null;
|
|
17712
17712
|
}
|
|
17713
17713
|
return params => {
|
|
@@ -17730,7 +17730,7 @@ const containsAnyOfCIOperator = {
|
|
|
17730
17730
|
label: 'contains any of (case insensitive)',
|
|
17731
17731
|
value: 'containsAnyOf',
|
|
17732
17732
|
getApplyFilterFn: filterItem => {
|
|
17733
|
-
if (!filterItem.
|
|
17733
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17734
17734
|
return null;
|
|
17735
17735
|
}
|
|
17736
17736
|
return params => {
|
|
@@ -17757,7 +17757,7 @@ const endsWithAnyOfOperator = {
|
|
|
17757
17757
|
label: 'ends with any of',
|
|
17758
17758
|
value: 'endsWithAnyOf',
|
|
17759
17759
|
getApplyFilterFn: filterItem => {
|
|
17760
|
-
if (!filterItem.
|
|
17760
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17761
17761
|
return null;
|
|
17762
17762
|
}
|
|
17763
17763
|
return params => {
|
|
@@ -17784,7 +17784,7 @@ const isAnyOfOperator = {
|
|
|
17784
17784
|
label: 'is any of',
|
|
17785
17785
|
value: 'isAnyOf',
|
|
17786
17786
|
getApplyFilterFn: filterItem => {
|
|
17787
|
-
if (!filterItem.
|
|
17787
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17788
17788
|
return null;
|
|
17789
17789
|
}
|
|
17790
17790
|
return params => {
|
|
@@ -17808,7 +17808,7 @@ const isNotAnyOfOperator = {
|
|
|
17808
17808
|
label: 'is not any of',
|
|
17809
17809
|
value: 'isNotAnyOf',
|
|
17810
17810
|
getApplyFilterFn: filterItem => {
|
|
17811
|
-
if (!filterItem.
|
|
17811
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17812
17812
|
return null;
|
|
17813
17813
|
}
|
|
17814
17814
|
return params => {
|
|
@@ -17832,7 +17832,7 @@ const startsWithAnyOfOperator = {
|
|
|
17832
17832
|
label: 'starts with any of',
|
|
17833
17833
|
value: 'startsWithAnyOf',
|
|
17834
17834
|
getApplyFilterFn: filterItem => {
|
|
17835
|
-
if (!filterItem.
|
|
17835
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17836
17836
|
return null;
|
|
17837
17837
|
}
|
|
17838
17838
|
return params => {
|
|
@@ -17877,13 +17877,13 @@ const operatorList = {
|
|
|
17877
17877
|
|
|
17878
17878
|
const getRsStringColumnType = () => {
|
|
17879
17879
|
return {
|
|
17880
|
-
|
|
17880
|
+
extendType: 'string',
|
|
17881
17881
|
filterOperators: operatorList.rsString
|
|
17882
17882
|
};
|
|
17883
17883
|
};
|
|
17884
17884
|
const getRsNumberColumnType = () => {
|
|
17885
17885
|
return {
|
|
17886
|
-
|
|
17886
|
+
extendType: 'number',
|
|
17887
17887
|
filterOperators: operatorList.rsNumber
|
|
17888
17888
|
};
|
|
17889
17889
|
};
|
|
@@ -17894,7 +17894,7 @@ const customColumnTypes = {
|
|
|
17894
17894
|
|
|
17895
17895
|
const API_URL = 'https://api.openai.com/v1/chat/completions';
|
|
17896
17896
|
async function getCompletion(text, role, openai_api_key) {
|
|
17897
|
-
let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-
|
|
17897
|
+
let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-0613';
|
|
17898
17898
|
try {
|
|
17899
17899
|
const messages = [{
|
|
17900
17900
|
role: 'system',
|
|
@@ -18061,39 +18061,42 @@ const numberOperatorDecoder = {
|
|
|
18061
18061
|
lt: '<',
|
|
18062
18062
|
lte: '<='
|
|
18063
18063
|
};
|
|
18064
|
-
const isOperatorValueValid = (
|
|
18065
|
-
const column = columns.find(column => column.field ===
|
|
18064
|
+
const isOperatorValueValid = (columnField, operatorValue, columns) => {
|
|
18065
|
+
const column = columns.find(column => column.field === columnField);
|
|
18066
18066
|
if (!column) {
|
|
18067
18067
|
return false;
|
|
18068
18068
|
}
|
|
18069
18069
|
const columnType = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
18070
|
-
const operators =
|
|
18070
|
+
const operators = operatorList[columnType];
|
|
18071
18071
|
if (!operators) {
|
|
18072
18072
|
return false;
|
|
18073
18073
|
}
|
|
18074
|
-
|
|
18074
|
+
if ('filterOperators' in operators) {
|
|
18075
|
+
return !!operators.filterOperators.find(op => columnType === 'number' && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
18076
|
+
}
|
|
18077
|
+
return !!operators.find(op => ['number', 'rsNumber'].includes(columnType) && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
18075
18078
|
};
|
|
18076
18079
|
const listOperators = ['containsAnyOf', 'endsWithAnyOf', 'isAnyOf', 'isNotAnyOf', 'startsWithAnyOf'];
|
|
18077
18080
|
|
|
18078
18081
|
// Check if the value doesn't break
|
|
18079
|
-
const isValueValid = (value,
|
|
18082
|
+
const isValueValid = (value, columnField, columns, operatorValue) => {
|
|
18080
18083
|
var _column$type;
|
|
18081
18084
|
// every field accepts undefined as value for default
|
|
18082
18085
|
if (value === undefined || value === '') {
|
|
18083
18086
|
return true;
|
|
18084
18087
|
}
|
|
18085
18088
|
|
|
18086
|
-
// xxxAnyOf accepts as value only lists, and we are
|
|
18089
|
+
// xxxAnyOf accepts as value only lists, and we are declearing them in the
|
|
18087
18090
|
// URL as `list=[...]`
|
|
18088
|
-
if (listOperators.includes(
|
|
18091
|
+
if (listOperators.includes(operatorValue)) {
|
|
18089
18092
|
return Array.isArray(value) || value === '';
|
|
18090
18093
|
}
|
|
18091
18094
|
|
|
18092
18095
|
// We are accepting arrays only if they are of the 'xxxAnyOf' type
|
|
18093
|
-
if (Array.isArray(value) && !listOperators.includes(
|
|
18096
|
+
if (Array.isArray(value) && !listOperators.includes(operatorValue)) {
|
|
18094
18097
|
return false;
|
|
18095
18098
|
}
|
|
18096
|
-
const column = columns.find(column => column.field ===
|
|
18099
|
+
const column = columns.find(column => column.field === columnField);
|
|
18097
18100
|
if (!column) {
|
|
18098
18101
|
return false;
|
|
18099
18102
|
}
|
|
@@ -18131,7 +18134,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18131
18134
|
if (!searchString) {
|
|
18132
18135
|
return 'invalid';
|
|
18133
18136
|
}
|
|
18134
|
-
let
|
|
18137
|
+
let linkOperator = GridLinkOperator.And;
|
|
18135
18138
|
let quickFilterValues = [];
|
|
18136
18139
|
const searchParams = new URLSearchParams();
|
|
18137
18140
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
@@ -18139,7 +18142,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18139
18142
|
searchParams.set(key, value);
|
|
18140
18143
|
}
|
|
18141
18144
|
if (key === '_logicOperator') {
|
|
18142
|
-
|
|
18145
|
+
linkOperator = value;
|
|
18143
18146
|
}
|
|
18144
18147
|
if (key === '_quickFilterValues') {
|
|
18145
18148
|
try {
|
|
@@ -18158,7 +18161,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18158
18161
|
if (isInvalid) {
|
|
18159
18162
|
return;
|
|
18160
18163
|
}
|
|
18161
|
-
const field = key.split('[')[0].slice(1);
|
|
18164
|
+
const field = key.split('[')[0].slice(1); // Slice to remove the _ at the beginning
|
|
18162
18165
|
if (!fields.includes(field)) {
|
|
18163
18166
|
return;
|
|
18164
18167
|
}
|
|
@@ -18175,6 +18178,7 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18175
18178
|
return;
|
|
18176
18179
|
}
|
|
18177
18180
|
const operator = splitRight[0];
|
|
18181
|
+
// if the operator is not part of the valid operators invalidate the URL
|
|
18178
18182
|
if (!isOperatorValueValid(field, operator, columns) || Array.isArray(operator)) {
|
|
18179
18183
|
isInvalid = true;
|
|
18180
18184
|
return;
|
|
@@ -18186,37 +18190,41 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18186
18190
|
return;
|
|
18187
18191
|
}
|
|
18188
18192
|
items.push({
|
|
18189
|
-
field,
|
|
18190
|
-
|
|
18193
|
+
columnField: field,
|
|
18194
|
+
operatorValue: ['number', 'rsNumber'].includes(columnType) && Object.keys(numberOperatorDecoder).includes(operator) ? numberOperatorDecoder[operator] : operator,
|
|
18191
18195
|
id,
|
|
18192
18196
|
value: listOperators.includes(operator) && decodedValue === '' ? [] : decodedValue,
|
|
18193
18197
|
type
|
|
18194
18198
|
});
|
|
18195
18199
|
});
|
|
18200
|
+
|
|
18201
|
+
// If we found some condition that results in an invalid URL,
|
|
18202
|
+
// return the empty filterModel (this will trigger the localStorage)
|
|
18203
|
+
// and will pick up the last valid search
|
|
18196
18204
|
if (isInvalid) {
|
|
18197
18205
|
return 'invalid';
|
|
18198
18206
|
}
|
|
18199
18207
|
return {
|
|
18200
18208
|
items,
|
|
18201
|
-
|
|
18209
|
+
linkOperator,
|
|
18202
18210
|
quickFilterValues
|
|
18203
18211
|
};
|
|
18204
18212
|
};
|
|
18205
18213
|
const getSearchParamsFromFilterModel = filterModel => {
|
|
18206
18214
|
var _filterModel$quickFil;
|
|
18207
18215
|
const searchParams = new URLSearchParams();
|
|
18208
|
-
searchParams.set('_logicOperator', filterModel['
|
|
18216
|
+
searchParams.set('_logicOperator', filterModel['linkOperator'] || '');
|
|
18209
18217
|
filterModel['items'].forEach(item => {
|
|
18210
18218
|
const {
|
|
18211
|
-
|
|
18212
|
-
|
|
18219
|
+
columnField,
|
|
18220
|
+
operatorValue,
|
|
18213
18221
|
value,
|
|
18214
18222
|
type
|
|
18215
18223
|
} = item;
|
|
18216
|
-
if (Object.keys(numberOperatorEncoder).includes(
|
|
18217
|
-
searchParams.set(`_${
|
|
18224
|
+
if (Object.keys(numberOperatorEncoder).includes(operatorValue)) {
|
|
18225
|
+
searchParams.set(`_${columnField}[${numberOperatorEncoder[operatorValue]},${encodeValue(type)}]`, encodeValue(value));
|
|
18218
18226
|
} else {
|
|
18219
|
-
searchParams.set(`_${
|
|
18227
|
+
searchParams.set(`_${columnField}[${encodeValue(operatorValue)},${encodeValue(type)}]`, encodeValue(value));
|
|
18220
18228
|
}
|
|
18221
18229
|
});
|
|
18222
18230
|
if ((_filterModel$quickFil = filterModel.quickFilterValues) !== null && _filterModel$quickFil !== void 0 && _filterModel$quickFil.length) {
|
|
@@ -18232,7 +18240,7 @@ const getSearchParamsFromFilterModel = filterModel => {
|
|
|
18232
18240
|
const getFilterModel = (search, columns, localStorageFilters, setLocalStorageFilters, initialState, isNewVersion) => {
|
|
18233
18241
|
const defaultValue = initialState && initialState.filter && initialState.filter.filterModel ? initialState.filter.filterModel : {
|
|
18234
18242
|
items: [],
|
|
18235
|
-
|
|
18243
|
+
linkOperator: GridLinkOperator.And
|
|
18236
18244
|
};
|
|
18237
18245
|
if (isNewVersion) {
|
|
18238
18246
|
return defaultValue;
|
|
@@ -18371,38 +18379,13 @@ const getPaginationModel = (search, localStoragePagination, setLocalStoragePagin
|
|
|
18371
18379
|
|
|
18372
18380
|
/** COLUMN VISIBILITY */
|
|
18373
18381
|
|
|
18374
|
-
const getColumnVisibilityFromString = (searchString, columns) => {
|
|
18375
|
-
if (!searchString) {
|
|
18376
|
-
return 'invalid';
|
|
18377
|
-
}
|
|
18378
|
-
const searchParams = new URLSearchParams(searchString);
|
|
18379
|
-
const value = searchParams.get('_columnVisibility');
|
|
18380
|
-
if (value === '' || value === null || value === '[]') {
|
|
18381
|
-
return 'invalid';
|
|
18382
|
-
}
|
|
18383
|
-
const parsedFields = value.slice(1, value.length - 1).split(',');
|
|
18384
|
-
const fields = columns.map(column => column.field);
|
|
18385
|
-
const visibility = {};
|
|
18386
|
-
for (const field of fields) {
|
|
18387
|
-
visibility[field] = false;
|
|
18388
|
-
}
|
|
18389
|
-
for (const parsedField of parsedFields) {
|
|
18390
|
-
if (fields.includes(parsedField)) {
|
|
18391
|
-
visibility[parsedField] = true;
|
|
18392
|
-
}
|
|
18393
|
-
}
|
|
18394
|
-
if (Object.values(visibility).filter(v => v === true).length === 0) {
|
|
18395
|
-
return 'invalid';
|
|
18396
|
-
}
|
|
18397
|
-
return visibility;
|
|
18398
|
-
};
|
|
18399
18382
|
const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
18400
18383
|
const searchParams = new URLSearchParams();
|
|
18401
|
-
const
|
|
18384
|
+
const columnFields = columns.map(column => column.field);
|
|
18402
18385
|
|
|
18403
18386
|
// if column visibility model is empty, show all columns
|
|
18404
18387
|
if (Object.keys(columnVisibility).length == 0) {
|
|
18405
|
-
searchParams.set('_columnVisibility', `[${
|
|
18388
|
+
searchParams.set('_columnVisibility', `[${columnFields.join(',')}]`);
|
|
18406
18389
|
return searchParams;
|
|
18407
18390
|
}
|
|
18408
18391
|
const finalColumnVisibility = columns.filter(c => {
|
|
@@ -18413,10 +18396,63 @@ const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
|
18413
18396
|
[colName]: true
|
|
18414
18397
|
});
|
|
18415
18398
|
}, columnVisibility);
|
|
18416
|
-
const visibleColumns =
|
|
18399
|
+
const visibleColumns = Object.entries(finalColumnVisibility)
|
|
18400
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18401
|
+
.filter(_ref => {
|
|
18402
|
+
let [_, visible] = _ref;
|
|
18403
|
+
return visible;
|
|
18404
|
+
})
|
|
18405
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18406
|
+
.map(_ref2 => {
|
|
18407
|
+
let [column, _] = _ref2;
|
|
18408
|
+
return encodeValue(column);
|
|
18409
|
+
});
|
|
18417
18410
|
searchParams.set('_columnVisibility', `[${visibleColumns.join(',')}]`);
|
|
18418
18411
|
return searchParams;
|
|
18419
18412
|
};
|
|
18413
|
+
const getColumnVisibilityFromString = (notParsed, tableColumns) => {
|
|
18414
|
+
if (!notParsed || notParsed.length === 1 && notParsed[0] === '?') {
|
|
18415
|
+
return 'invalid';
|
|
18416
|
+
}
|
|
18417
|
+
// remove the initial ? if present
|
|
18418
|
+
const parsed = notParsed[0] === '?' ? notParsed.slice(1) : notParsed;
|
|
18419
|
+
const visibility = {};
|
|
18420
|
+
let exist = false;
|
|
18421
|
+
let visibleColumnsCount = 0;
|
|
18422
|
+
for (const item of parsed.split('&')) {
|
|
18423
|
+
// if it's not column visibility field, skip
|
|
18424
|
+
const fieldURL = item.split('=')[0];
|
|
18425
|
+
if (fieldURL !== '_columnVisibility') {
|
|
18426
|
+
continue;
|
|
18427
|
+
}
|
|
18428
|
+
// e.g. item = _columnVisibility[abc,def]
|
|
18429
|
+
const left = item.split(']')[0];
|
|
18430
|
+
if (left.split('[').length < 2) {
|
|
18431
|
+
continue;
|
|
18432
|
+
}
|
|
18433
|
+
const encodedValues = item.split('[')[1].split(']')[0];
|
|
18434
|
+
if (typeof encodedValues !== 'string') {
|
|
18435
|
+
continue;
|
|
18436
|
+
}
|
|
18437
|
+
exist = true;
|
|
18438
|
+
const columnFields = tableColumns.map(column => column.field);
|
|
18439
|
+
// TODO: Add validation that , is present
|
|
18440
|
+
const columns = encodedValues.split(',').map(value => decodeValue(value));
|
|
18441
|
+
|
|
18442
|
+
// for each column, check if it's visible and add it to visibility model
|
|
18443
|
+
for (const column of columnFields) {
|
|
18444
|
+
const isColumnVisible = columns.includes(column);
|
|
18445
|
+
visibility[column] = isColumnVisible;
|
|
18446
|
+
if (isColumnVisible) {
|
|
18447
|
+
visibleColumnsCount += 1;
|
|
18448
|
+
}
|
|
18449
|
+
}
|
|
18450
|
+
}
|
|
18451
|
+
if (visibleColumnsCount === 0 && !exist) {
|
|
18452
|
+
return 'invalid';
|
|
18453
|
+
}
|
|
18454
|
+
return visibility;
|
|
18455
|
+
};
|
|
18420
18456
|
|
|
18421
18457
|
// Rules:
|
|
18422
18458
|
// - if we have something in the URL, use that info
|
|
@@ -18477,8 +18513,8 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
18477
18513
|
if (typeof encodedValues !== 'string') {
|
|
18478
18514
|
continue;
|
|
18479
18515
|
}
|
|
18480
|
-
const
|
|
18481
|
-
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' &&
|
|
18516
|
+
const columnFields = [...tableColumns.map(column => column.field), '__check__'];
|
|
18517
|
+
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' && columnFields.includes(val));
|
|
18482
18518
|
if (fieldURL === '_pinnedColumnsLeft') {
|
|
18483
18519
|
pinnedColumns['left'] = columns;
|
|
18484
18520
|
}
|
|
@@ -18486,9 +18522,9 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
18486
18522
|
pinnedColumns['right'] = columns;
|
|
18487
18523
|
}
|
|
18488
18524
|
}
|
|
18489
|
-
return pinnedColumns
|
|
18490
|
-
left: pinnedColumns
|
|
18491
|
-
right: pinnedColumns
|
|
18525
|
+
return pinnedColumns['left'] || pinnedColumns['right'] ? {
|
|
18526
|
+
left: pinnedColumns['left'] || [],
|
|
18527
|
+
right: pinnedColumns['right'] || []
|
|
18492
18528
|
} : 'invalid';
|
|
18493
18529
|
};
|
|
18494
18530
|
const getSearchParamsFromPinnedColumns = pinnedColumns => {
|
|
@@ -18538,7 +18574,7 @@ const getSearchParamsFromTab = search => {
|
|
|
18538
18574
|
}
|
|
18539
18575
|
return searchParams;
|
|
18540
18576
|
};
|
|
18541
|
-
const getFinalSearch =
|
|
18577
|
+
const getFinalSearch = _ref3 => {
|
|
18542
18578
|
let {
|
|
18543
18579
|
search,
|
|
18544
18580
|
localStorageVersion,
|
|
@@ -18548,7 +18584,7 @@ const getFinalSearch = _ref => {
|
|
|
18548
18584
|
columnsVisibilityModel,
|
|
18549
18585
|
pinnedColumnsModel,
|
|
18550
18586
|
columns
|
|
18551
|
-
} =
|
|
18587
|
+
} = _ref3;
|
|
18552
18588
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
18553
18589
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
18554
18590
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -18613,14 +18649,14 @@ const getModelsParsedOrUpdateLocalStorage = (search, localStorageVersion, column
|
|
|
18613
18649
|
pinnedColumnsModel
|
|
18614
18650
|
};
|
|
18615
18651
|
};
|
|
18616
|
-
const updateUrl = (
|
|
18652
|
+
const updateUrl = (_ref4, search, localStorageVersion, historyReplace, columns) => {
|
|
18617
18653
|
let {
|
|
18618
18654
|
filterModel,
|
|
18619
18655
|
sortModel,
|
|
18620
18656
|
paginationModel,
|
|
18621
18657
|
columnsModel: columnsVisibilityModel,
|
|
18622
18658
|
pinnedColumnsModel
|
|
18623
|
-
} =
|
|
18659
|
+
} = _ref4;
|
|
18624
18660
|
const newSearch = getFinalSearch({
|
|
18625
18661
|
search,
|
|
18626
18662
|
localStorageVersion,
|
|
@@ -18641,17 +18677,17 @@ const updateUrl = (_ref2, search, localStorageVersion, historyReplace, columns)
|
|
|
18641
18677
|
// do not use it for equivalence (e.g. with value `3` and undefined we
|
|
18642
18678
|
// will get 0).
|
|
18643
18679
|
const compareFilters = (firstFilter, secondFilter) => {
|
|
18644
|
-
if (firstFilter.
|
|
18680
|
+
if (firstFilter.columnField < secondFilter.columnField) {
|
|
18645
18681
|
return -1;
|
|
18646
|
-
} else if (firstFilter.
|
|
18682
|
+
} else if (firstFilter.columnField > secondFilter.columnField) {
|
|
18647
18683
|
return 1;
|
|
18648
18684
|
}
|
|
18649
|
-
if (firstFilter.
|
|
18685
|
+
if (firstFilter.operatorValue === undefined || secondFilter.operatorValue === undefined) {
|
|
18650
18686
|
return 0;
|
|
18651
18687
|
}
|
|
18652
|
-
if (firstFilter.
|
|
18688
|
+
if (firstFilter.operatorValue < secondFilter.operatorValue) {
|
|
18653
18689
|
return -1;
|
|
18654
|
-
} else if (firstFilter.
|
|
18690
|
+
} else if (firstFilter.operatorValue > secondFilter.operatorValue) {
|
|
18655
18691
|
return 1;
|
|
18656
18692
|
}
|
|
18657
18693
|
if (firstFilter.value < secondFilter.value) {
|
|
@@ -18662,18 +18698,18 @@ const compareFilters = (firstFilter, secondFilter) => {
|
|
|
18662
18698
|
return 0;
|
|
18663
18699
|
};
|
|
18664
18700
|
const areFiltersEquivalent = (firstFilter, secondFilter) => {
|
|
18665
|
-
return firstFilter.
|
|
18701
|
+
return firstFilter.columnField === secondFilter.columnField && firstFilter.operatorValue === secondFilter.operatorValue && firstFilter.value === secondFilter.value;
|
|
18666
18702
|
};
|
|
18667
18703
|
const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
18668
18704
|
const {
|
|
18669
18705
|
items,
|
|
18670
|
-
|
|
18706
|
+
linkOperator
|
|
18671
18707
|
} = filterModel;
|
|
18672
18708
|
const {
|
|
18673
18709
|
items: itemsToMatch,
|
|
18674
|
-
|
|
18710
|
+
linkOperator: linkOperatorToMatch
|
|
18675
18711
|
} = filterModelToMatch;
|
|
18676
|
-
if (
|
|
18712
|
+
if (linkOperator !== linkOperatorToMatch) {
|
|
18677
18713
|
return false;
|
|
18678
18714
|
}
|
|
18679
18715
|
if (items.length !== itemsToMatch.length) {
|
|
@@ -18686,7 +18722,7 @@ const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
|
18686
18722
|
const filterToCompare = itemsToMatch[i];
|
|
18687
18723
|
|
|
18688
18724
|
// compareFilters return 0 if and only if the filters have the same
|
|
18689
|
-
//
|
|
18725
|
+
// columnField, operatorValue, and value
|
|
18690
18726
|
if (!areFiltersEquivalent(filter, filterToCompare)) {
|
|
18691
18727
|
return false;
|
|
18692
18728
|
}
|
|
@@ -24497,16 +24533,16 @@ const getRole = (config, dateFormat) => {
|
|
|
24497
24533
|
}).join('\n');
|
|
24498
24534
|
return `The AI assistant parses user input to generate a JSON object that will be used as a row filter for a data table MUI Data Grid.
|
|
24499
24535
|
The filter supports mulitple conditions using only two logical operator "and", "or". It only allows "and" between all conditions or "or" between all conditions. It can't mix the two types.
|
|
24500
|
-
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "
|
|
24501
|
-
- "
|
|
24502
|
-
- "items": a list of conditions, each is an object with exactly the three keys "
|
|
24503
|
-
- "
|
|
24536
|
+
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "linkOperator" and "items":
|
|
24537
|
+
- "linkOperator": the logical operator, only "and" or "or" are allowed. If there is only one condition in the "items", use "and".
|
|
24538
|
+
- "items": a list of conditions, each is an object with exactly the three keys "columnField", "operatorValue" and "value":
|
|
24539
|
+
- "columnField": the column name, must be one of ${columns}
|
|
24504
24540
|
- "value":
|
|
24505
|
-
- this can be skipped if the "
|
|
24506
|
-
- a list of multiple values if the "
|
|
24541
|
+
- this can be skipped if the "operatorValue" is either "isEmpty" or "isNotEmpty"
|
|
24542
|
+
- a list of multiple values if the "operatorValue" ends with "AnyOf"
|
|
24507
24543
|
- otherwise, it's a single value represented as a string: "true" instead of true, "false" instead of false, "0.6" instead of 0.6.
|
|
24508
24544
|
For "date" data type, use ${dateFormat}. If relative date is input, convert to the actual date given today is ${today}.
|
|
24509
|
-
- "
|
|
24545
|
+
- "operatorValue": the comparison operator, accepted values depend on the data type of the column
|
|
24510
24546
|
${operators}
|
|
24511
24547
|
|
|
24512
24548
|
Below is the datatype in square bracket, constraints on the data range if any, followed by the description of each column used in the data table:
|
|
@@ -24543,10 +24579,10 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24543
24579
|
nlpFilterConfig,
|
|
24544
24580
|
onFilterModelChange,
|
|
24545
24581
|
dateFormat = 'yyyy-mm-dd',
|
|
24546
|
-
defaultModel = 'gpt-4-
|
|
24582
|
+
defaultModel = 'gpt-4-0613',
|
|
24547
24583
|
defaultFilter = {
|
|
24548
24584
|
items: [],
|
|
24549
|
-
|
|
24585
|
+
linkOperator: 'and'
|
|
24550
24586
|
},
|
|
24551
24587
|
disablePower = false,
|
|
24552
24588
|
localeText
|
|
@@ -24624,7 +24660,7 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24624
24660
|
value: prompt
|
|
24625
24661
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
24626
24662
|
variant: "primary",
|
|
24627
|
-
"
|
|
24663
|
+
"aira-label": buttonAriaLabel,
|
|
24628
24664
|
type: "submit",
|
|
24629
24665
|
isLoading: isLoading
|
|
24630
24666
|
}, buttonText)), !disablePower && /*#__PURE__*/React__default.createElement(Tooltip, null, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, /*#__PURE__*/React__default.createElement(Switch, {
|
|
@@ -24686,7 +24722,7 @@ const Toolbar$2 = props => {
|
|
|
24686
24722
|
let {
|
|
24687
24723
|
apiRef
|
|
24688
24724
|
} = _ref;
|
|
24689
|
-
return
|
|
24725
|
+
return gridVisibleSortedRowIdsSelector(apiRef);
|
|
24690
24726
|
}
|
|
24691
24727
|
},
|
|
24692
24728
|
printOptions: {
|
|
@@ -26920,10 +26956,12 @@ const ServerSideControlledPagination = _ref3 => {
|
|
|
26920
26956
|
selectionStatus,
|
|
26921
26957
|
displaySelection,
|
|
26922
26958
|
displayPagination,
|
|
26923
|
-
|
|
26924
|
-
|
|
26925
|
-
|
|
26959
|
+
page,
|
|
26960
|
+
onPageChange,
|
|
26961
|
+
pageSize,
|
|
26962
|
+
onPageSizeChange,
|
|
26926
26963
|
displayRowsPerPage,
|
|
26964
|
+
rowsPerPageOptions,
|
|
26927
26965
|
paginationProps,
|
|
26928
26966
|
rowCount
|
|
26929
26967
|
} = _ref3;
|
|
@@ -26942,17 +26980,13 @@ const ServerSideControlledPagination = _ref3 => {
|
|
|
26942
26980
|
}, totalRowsLabel) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$1({
|
|
26943
26981
|
component: "div",
|
|
26944
26982
|
count: totalNumberOfRowsInTable,
|
|
26945
|
-
page:
|
|
26946
|
-
onPageChange: (event,
|
|
26947
|
-
|
|
26948
|
-
|
|
26949
|
-
|
|
26950
|
-
|
|
26951
|
-
|
|
26952
|
-
page: paginationModel.page,
|
|
26953
|
-
pageSize: parseInt(event.target.value, 10)
|
|
26954
|
-
}),
|
|
26955
|
-
rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
|
|
26983
|
+
page: page,
|
|
26984
|
+
onPageChange: (event, newPage) => onPageChange(newPage),
|
|
26985
|
+
rowsPerPage: pageSize,
|
|
26986
|
+
onRowsPerPageChange: event => {
|
|
26987
|
+
onPageSizeChange(parseInt(event.target.value, 10));
|
|
26988
|
+
},
|
|
26989
|
+
rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
|
|
26956
26990
|
}, paginationProps)) : null);
|
|
26957
26991
|
};
|
|
26958
26992
|
|
|
@@ -26978,9 +27012,11 @@ const ControlledPagination = _ref3 => {
|
|
|
26978
27012
|
displayPagination = false,
|
|
26979
27013
|
selectionStatus,
|
|
26980
27014
|
apiRef,
|
|
26981
|
-
|
|
26982
|
-
|
|
26983
|
-
|
|
27015
|
+
page,
|
|
27016
|
+
onPageChange,
|
|
27017
|
+
pageSize,
|
|
27018
|
+
onPageSizeChange,
|
|
27019
|
+
rowsPerPageOptions,
|
|
26984
27020
|
isRowSelectable,
|
|
26985
27021
|
paginationProps
|
|
26986
27022
|
} = _ref3;
|
|
@@ -27010,25 +27046,17 @@ const ControlledPagination = _ref3 => {
|
|
|
27010
27046
|
}, `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$1({
|
|
27011
27047
|
component: "div",
|
|
27012
27048
|
count: numberOfFilteredRowsInTable,
|
|
27013
|
-
page:
|
|
27014
|
-
onPageChange: (event,
|
|
27015
|
-
|
|
27016
|
-
page,
|
|
27017
|
-
pageSize: paginationModel.pageSize
|
|
27018
|
-
});
|
|
27019
|
-
},
|
|
27020
|
-
rowsPerPage: paginationModel.pageSize,
|
|
27049
|
+
page: page,
|
|
27050
|
+
onPageChange: (event, newPage) => onPageChange(newPage),
|
|
27051
|
+
rowsPerPage: pageSize,
|
|
27021
27052
|
onRowsPerPageChange: event => {
|
|
27022
|
-
|
|
27023
|
-
page: paginationModel.page,
|
|
27024
|
-
pageSize: parseInt(event.target.value, 10)
|
|
27025
|
-
});
|
|
27053
|
+
onPageSizeChange(parseInt(event.target.value, 10));
|
|
27026
27054
|
},
|
|
27027
|
-
rowsPerPageOptions: displayRowsPerPage ?
|
|
27055
|
+
rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
|
|
27028
27056
|
}, paginationProps)) : null);
|
|
27029
27057
|
};
|
|
27030
27058
|
|
|
27031
|
-
const _excluded$3 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "
|
|
27059
|
+
const _excluded$3 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "page", "onPageChange", "pageSize", "onPageSizeChange", "rowsPerPageOptions", "paginationProps", "paginationMode", "rowCount"];
|
|
27032
27060
|
const ToolbarWrapper = _ref => {
|
|
27033
27061
|
let {
|
|
27034
27062
|
hideToolbar,
|
|
@@ -27040,9 +27068,11 @@ const ToolbarWrapper = _ref => {
|
|
|
27040
27068
|
selectionStatus,
|
|
27041
27069
|
apiRef,
|
|
27042
27070
|
isRowSelectable,
|
|
27043
|
-
|
|
27044
|
-
|
|
27045
|
-
|
|
27071
|
+
page,
|
|
27072
|
+
onPageChange,
|
|
27073
|
+
pageSize,
|
|
27074
|
+
onPageSizeChange,
|
|
27075
|
+
rowsPerPageOptions,
|
|
27046
27076
|
paginationProps,
|
|
27047
27077
|
paginationMode = 'client',
|
|
27048
27078
|
rowCount
|
|
@@ -27056,9 +27086,11 @@ const ToolbarWrapper = _ref => {
|
|
|
27056
27086
|
displayRowsPerPage: false,
|
|
27057
27087
|
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
27058
27088
|
selectionStatus: selectionStatus.current,
|
|
27059
|
-
|
|
27060
|
-
|
|
27061
|
-
|
|
27089
|
+
page: page,
|
|
27090
|
+
onPageChange: onPageChange,
|
|
27091
|
+
pageSize: pageSize,
|
|
27092
|
+
onPageSizeChange: onPageSizeChange,
|
|
27093
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27062
27094
|
paginationProps: paginationProps,
|
|
27063
27095
|
rowCount: rowCount
|
|
27064
27096
|
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
@@ -27068,26 +27100,30 @@ const ToolbarWrapper = _ref => {
|
|
|
27068
27100
|
selectionStatus: selectionStatus.current,
|
|
27069
27101
|
apiRef: apiRef,
|
|
27070
27102
|
isRowSelectable: isRowSelectable,
|
|
27071
|
-
|
|
27072
|
-
|
|
27073
|
-
|
|
27103
|
+
page: page,
|
|
27104
|
+
onPageChange: onPageChange,
|
|
27105
|
+
pageSize: pageSize,
|
|
27106
|
+
onPageSizeChange: onPageSizeChange,
|
|
27107
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27074
27108
|
paginationProps: paginationProps
|
|
27075
27109
|
}) : null);
|
|
27076
27110
|
};
|
|
27077
27111
|
|
|
27078
27112
|
const useControlledDatagridState = _ref => {
|
|
27079
|
-
var
|
|
27113
|
+
var _initialState$paginat, _initialState$paginat2;
|
|
27080
27114
|
let {
|
|
27081
27115
|
initialState,
|
|
27082
|
-
|
|
27116
|
+
rowsPerPageOptions,
|
|
27083
27117
|
propsColumnVisibilityModel,
|
|
27084
27118
|
propsFilterModel,
|
|
27085
27119
|
propsOnColumnVisibilityModelChange,
|
|
27086
27120
|
propsOnFilterModelChange,
|
|
27087
|
-
|
|
27121
|
+
propsOnPageChange,
|
|
27122
|
+
propsOnPageSizeChange,
|
|
27088
27123
|
propsOnPinnedColumnsChange,
|
|
27089
27124
|
propsOnSortModelChange,
|
|
27090
|
-
|
|
27125
|
+
propsPage,
|
|
27126
|
+
propsPageSize,
|
|
27091
27127
|
propsPinnedColumns,
|
|
27092
27128
|
propsSortModel
|
|
27093
27129
|
} = _ref;
|
|
@@ -27135,22 +27171,33 @@ const useControlledDatagridState = _ref => {
|
|
|
27135
27171
|
setSortModel(model);
|
|
27136
27172
|
}
|
|
27137
27173
|
};
|
|
27138
|
-
const [
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
if (propsOnPaginationModelChange) {
|
|
27144
|
-
propsOnPaginationModelChange(model, details);
|
|
27174
|
+
const [page, setPage] = useState((initialState === null || initialState === void 0 ? void 0 : (_initialState$paginat = initialState.pagination) === null || _initialState$paginat === void 0 ? void 0 : _initialState$paginat.page) || propsPage || 0);
|
|
27175
|
+
const [pageSize, setPageSize] = useState((initialState === null || initialState === void 0 ? void 0 : (_initialState$paginat2 = initialState.pagination) === null || _initialState$paginat2 === void 0 ? void 0 : _initialState$paginat2.pageSize) || propsPageSize || (rowsPerPageOptions === null || rowsPerPageOptions === void 0 ? void 0 : rowsPerPageOptions[0]) || 25);
|
|
27176
|
+
const onPageChange = page => {
|
|
27177
|
+
if (propsOnPageChange) {
|
|
27178
|
+
propsOnPageChange(page, undefined);
|
|
27145
27179
|
} else {
|
|
27146
|
-
|
|
27180
|
+
setPage(page);
|
|
27147
27181
|
}
|
|
27148
27182
|
};
|
|
27149
27183
|
useEffect(() => {
|
|
27150
|
-
if (
|
|
27151
|
-
|
|
27184
|
+
if (propsPage || propsPage === 0) {
|
|
27185
|
+
setPage(propsPage);
|
|
27186
|
+
}
|
|
27187
|
+
}, [propsPage]);
|
|
27188
|
+
const onPageSizeChange = pageSize => {
|
|
27189
|
+
onPageChange(0);
|
|
27190
|
+
if (propsOnPageSizeChange) {
|
|
27191
|
+
propsOnPageSizeChange(pageSize, undefined);
|
|
27192
|
+
} else {
|
|
27193
|
+
setPageSize(pageSize);
|
|
27152
27194
|
}
|
|
27153
|
-
}
|
|
27195
|
+
};
|
|
27196
|
+
useEffect(() => {
|
|
27197
|
+
if (propsPageSize) {
|
|
27198
|
+
setPageSize(propsPageSize);
|
|
27199
|
+
}
|
|
27200
|
+
}, [propsPageSize]);
|
|
27154
27201
|
return {
|
|
27155
27202
|
filterModel,
|
|
27156
27203
|
onFilterModelChange,
|
|
@@ -27160,12 +27207,14 @@ const useControlledDatagridState = _ref => {
|
|
|
27160
27207
|
onPinnedColumnsChange,
|
|
27161
27208
|
sortModel,
|
|
27162
27209
|
onSortModelChange,
|
|
27163
|
-
|
|
27164
|
-
|
|
27210
|
+
page,
|
|
27211
|
+
pageSize,
|
|
27212
|
+
onPageChange,
|
|
27213
|
+
onPageSizeChange
|
|
27165
27214
|
};
|
|
27166
27215
|
};
|
|
27167
27216
|
|
|
27168
|
-
const _excluded$2 = ["apiRef", "autoHeight", "className", "
|
|
27217
|
+
const _excluded$2 = ["apiRef", "autoHeight", "className", "columnTypes", "components", "componentsProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "onPageChange", "onPageSizeChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "selectionModel", "onSelectionModelChange", "page", "pageSize", "pagination", "paginationPlacement", "paginationProps", "rows", "rowsPerPageOptions", "sx", "theme", "paginationMode", "rowCount"];
|
|
27169
27218
|
const COMPONENT_NAME$2 = 'DataGrid';
|
|
27170
27219
|
const CLASSNAME$2 = 'redsift-datagrid';
|
|
27171
27220
|
const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -27174,30 +27223,33 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27174
27223
|
apiRef: propsApiRef,
|
|
27175
27224
|
autoHeight,
|
|
27176
27225
|
className,
|
|
27177
|
-
|
|
27178
|
-
|
|
27226
|
+
columnTypes: propsColumnTypes,
|
|
27227
|
+
components,
|
|
27228
|
+
componentsProps,
|
|
27179
27229
|
filterModel: propsFilterModel,
|
|
27180
27230
|
columnVisibilityModel: propsColumnVisibilityModel,
|
|
27181
27231
|
pinnedColumns: propsPinnedColumns,
|
|
27182
27232
|
sortModel: propsSortModel,
|
|
27183
|
-
paginationModel: propsPaginationModel,
|
|
27184
27233
|
height: propsHeight,
|
|
27185
27234
|
hideToolbar,
|
|
27186
27235
|
initialState,
|
|
27187
27236
|
isRowSelectable,
|
|
27188
27237
|
license = process.env.MUI_LICENSE_KEY,
|
|
27189
27238
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
onRowSelectionModelChange: propsOnRowSelectionModelChange,
|
|
27239
|
+
onPageChange: propsOnPageChange,
|
|
27240
|
+
onPageSizeChange: propsOnPageSizeChange,
|
|
27193
27241
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27194
27242
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27195
27243
|
onSortModelChange: propsOnSortModelChange,
|
|
27244
|
+
selectionModel: propsSelectionModel,
|
|
27245
|
+
onSelectionModelChange: propsOnSelectionModelChange,
|
|
27246
|
+
page: propsPage,
|
|
27247
|
+
pageSize: propsPageSize,
|
|
27196
27248
|
pagination,
|
|
27197
27249
|
paginationPlacement = 'both',
|
|
27198
27250
|
paginationProps,
|
|
27199
27251
|
rows,
|
|
27200
|
-
|
|
27252
|
+
rowsPerPageOptions,
|
|
27201
27253
|
sx,
|
|
27202
27254
|
theme: propsTheme,
|
|
27203
27255
|
paginationMode = 'client',
|
|
@@ -27207,7 +27259,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27207
27259
|
const theme = useTheme$4(propsTheme);
|
|
27208
27260
|
const _apiRef = useGridApiRef();
|
|
27209
27261
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
27210
|
-
const RenderedToolbar =
|
|
27262
|
+
const RenderedToolbar = components !== null && components !== void 0 && components.Toolbar ? components.Toolbar : Toolbar$2;
|
|
27211
27263
|
LicenseInfo.setLicenseKey(license);
|
|
27212
27264
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
27213
27265
|
const {
|
|
@@ -27215,52 +27267,56 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27215
27267
|
filterModel,
|
|
27216
27268
|
onColumnVisibilityModelChange,
|
|
27217
27269
|
onFilterModelChange,
|
|
27218
|
-
|
|
27270
|
+
onPageChange,
|
|
27271
|
+
onPageSizeChange,
|
|
27219
27272
|
onPinnedColumnsChange,
|
|
27220
27273
|
onSortModelChange,
|
|
27221
|
-
|
|
27274
|
+
page,
|
|
27275
|
+
pageSize,
|
|
27222
27276
|
pinnedColumns,
|
|
27223
27277
|
sortModel
|
|
27224
27278
|
} = useControlledDatagridState({
|
|
27225
27279
|
initialState,
|
|
27226
|
-
|
|
27280
|
+
rowsPerPageOptions,
|
|
27227
27281
|
propsColumnVisibilityModel,
|
|
27228
27282
|
propsFilterModel,
|
|
27229
27283
|
propsOnColumnVisibilityModelChange,
|
|
27230
27284
|
propsOnFilterModelChange,
|
|
27231
27285
|
propsOnPinnedColumnsChange,
|
|
27232
27286
|
propsOnSortModelChange,
|
|
27233
|
-
|
|
27287
|
+
propsPage,
|
|
27288
|
+
propsPageSize,
|
|
27234
27289
|
propsPinnedColumns,
|
|
27235
27290
|
propsSortModel,
|
|
27236
|
-
|
|
27291
|
+
propsOnPageChange,
|
|
27292
|
+
propsOnPageSizeChange
|
|
27237
27293
|
});
|
|
27238
|
-
const [
|
|
27294
|
+
const [selectionModel, setSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
27239
27295
|
useEffect(() => {
|
|
27240
|
-
|
|
27241
|
-
}, [
|
|
27242
|
-
const
|
|
27243
|
-
if (
|
|
27244
|
-
|
|
27296
|
+
setSelectionModel(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
27297
|
+
}, [propsSelectionModel]);
|
|
27298
|
+
const onSelectionModelChange = (selectionModel, details) => {
|
|
27299
|
+
if (propsOnSelectionModelChange) {
|
|
27300
|
+
propsOnSelectionModelChange(selectionModel, details);
|
|
27245
27301
|
} else {
|
|
27246
|
-
|
|
27302
|
+
setSelectionModel(selectionModel);
|
|
27247
27303
|
}
|
|
27248
27304
|
};
|
|
27249
27305
|
const selectionStatus = useRef({
|
|
27250
27306
|
type: 'none',
|
|
27251
27307
|
numberOfSelectedRows: 0,
|
|
27252
27308
|
numberOfSelectedRowsInPage: 0,
|
|
27253
|
-
page
|
|
27254
|
-
pageSize
|
|
27309
|
+
page,
|
|
27310
|
+
pageSize
|
|
27255
27311
|
});
|
|
27256
27312
|
|
|
27257
27313
|
// in server-side pagination we want to update the selection status
|
|
27258
27314
|
// every time we navigate between pages, resize our page or select something
|
|
27259
27315
|
useEffect(() => {
|
|
27260
27316
|
if (paginationMode == 'server') {
|
|
27261
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
27317
|
+
onServerSideSelectionStatusChange(Array.isArray(selectionModel) ? selectionModel : [selectionModel], apiRef, selectionStatus, isRowSelectable, page, pageSize);
|
|
27262
27318
|
}
|
|
27263
|
-
}, [
|
|
27319
|
+
}, [selectionModel, page, pageSize]);
|
|
27264
27320
|
if (!Array.isArray(rows)) {
|
|
27265
27321
|
return null;
|
|
27266
27322
|
}
|
|
@@ -27291,54 +27347,57 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27291
27347
|
apiRef: apiRef,
|
|
27292
27348
|
autoHeight: autoHeight,
|
|
27293
27349
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
27294
|
-
|
|
27295
|
-
|
|
27296
|
-
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27350
|
+
columnTypes: _objectSpread2(_objectSpread2({}, customColumnTypes), propsColumnTypes),
|
|
27351
|
+
components: _objectSpread2(_objectSpread2({
|
|
27352
|
+
BaseButton,
|
|
27353
|
+
BaseCheckbox,
|
|
27354
|
+
// BaseTextField,
|
|
27355
|
+
BasePopper,
|
|
27356
|
+
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27300
27357
|
displayName: "ColumnFilteredIcon"
|
|
27301
27358
|
})),
|
|
27302
|
-
|
|
27359
|
+
ColumnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27303
27360
|
displayName: "ColumnSelectorIcon"
|
|
27304
27361
|
})),
|
|
27305
|
-
|
|
27362
|
+
ColumnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27306
27363
|
displayName: "ColumnSortedAscendingIcon"
|
|
27307
27364
|
})),
|
|
27308
|
-
|
|
27365
|
+
ColumnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27309
27366
|
displayName: "ColumnSortedDescendingIcon"
|
|
27310
27367
|
})),
|
|
27311
|
-
|
|
27368
|
+
DensityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27312
27369
|
displayName: "DensityCompactIcon"
|
|
27313
27370
|
})),
|
|
27314
|
-
|
|
27371
|
+
DensityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27315
27372
|
displayName: "DensityStandardIcon"
|
|
27316
27373
|
})),
|
|
27317
|
-
|
|
27374
|
+
DensityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27318
27375
|
displayName: "DensityComfortableIcon"
|
|
27319
27376
|
})),
|
|
27320
|
-
|
|
27377
|
+
DetailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27321
27378
|
displayName: "DetailPanelCollapseIcon"
|
|
27322
27379
|
})),
|
|
27323
|
-
|
|
27380
|
+
DetailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27324
27381
|
displayName: "DetailPanelExpandIcon"
|
|
27325
27382
|
})),
|
|
27326
|
-
|
|
27383
|
+
ExportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27327
27384
|
displayName: "ExportIcon"
|
|
27328
27385
|
})),
|
|
27329
|
-
|
|
27386
|
+
OpenFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
27330
27387
|
displayName: "OpenFilterButtonIcon"
|
|
27331
27388
|
}, props))
|
|
27332
|
-
},
|
|
27333
|
-
|
|
27334
|
-
|
|
27389
|
+
}, components), {}, {
|
|
27390
|
+
Toolbar: ToolbarWrapper,
|
|
27391
|
+
Pagination: props => pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
27335
27392
|
displaySelection: false,
|
|
27336
27393
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
27337
27394
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
27338
27395
|
selectionStatus: selectionStatus.current,
|
|
27339
|
-
|
|
27340
|
-
|
|
27341
|
-
|
|
27396
|
+
page: page,
|
|
27397
|
+
onPageChange: onPageChange,
|
|
27398
|
+
pageSize: pageSize,
|
|
27399
|
+
onPageSizeChange: onPageSizeChange,
|
|
27400
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27342
27401
|
paginationProps: paginationProps,
|
|
27343
27402
|
paginationMode: paginationMode,
|
|
27344
27403
|
rowCount: rowCount
|
|
@@ -27349,14 +27408,16 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27349
27408
|
selectionStatus: selectionStatus.current,
|
|
27350
27409
|
apiRef: apiRef,
|
|
27351
27410
|
isRowSelectable: isRowSelectable,
|
|
27352
|
-
|
|
27353
|
-
|
|
27354
|
-
|
|
27411
|
+
page: page,
|
|
27412
|
+
onPageChange: onPageChange,
|
|
27413
|
+
pageSize: pageSize,
|
|
27414
|
+
onPageSizeChange: onPageSizeChange,
|
|
27415
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27355
27416
|
paginationProps: paginationProps,
|
|
27356
27417
|
paginationMode: paginationMode
|
|
27357
27418
|
})) : null
|
|
27358
27419
|
}),
|
|
27359
|
-
|
|
27420
|
+
componentsProps: _objectSpread2(_objectSpread2({}, componentsProps), {}, {
|
|
27360
27421
|
toolbar: _objectSpread2({
|
|
27361
27422
|
hideToolbar,
|
|
27362
27423
|
RenderedToolbar,
|
|
@@ -27367,13 +27428,15 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27367
27428
|
selectionStatus,
|
|
27368
27429
|
apiRef,
|
|
27369
27430
|
isRowSelectable,
|
|
27370
|
-
|
|
27371
|
-
|
|
27372
|
-
|
|
27431
|
+
page,
|
|
27432
|
+
onPageChange,
|
|
27433
|
+
pageSize,
|
|
27434
|
+
onPageSizeChange,
|
|
27435
|
+
rowsPerPageOptions,
|
|
27373
27436
|
paginationProps,
|
|
27374
27437
|
paginationMode,
|
|
27375
27438
|
rowCount
|
|
27376
|
-
},
|
|
27439
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbar)
|
|
27377
27440
|
}),
|
|
27378
27441
|
filterModel: filterModel,
|
|
27379
27442
|
columnVisibilityModel: columnVisibilityModel,
|
|
@@ -27389,11 +27452,13 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27389
27452
|
paginationMode: paginationMode,
|
|
27390
27453
|
keepNonExistentRowsSelected: paginationMode == 'server',
|
|
27391
27454
|
rows: rows,
|
|
27392
|
-
|
|
27393
|
-
|
|
27394
|
-
|
|
27395
|
-
|
|
27396
|
-
|
|
27455
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27456
|
+
page: page,
|
|
27457
|
+
onPageChange: onPageChange,
|
|
27458
|
+
pageSize: pageSize,
|
|
27459
|
+
onPageSizeChange: onPageSizeChange,
|
|
27460
|
+
selectionModel: selectionModel,
|
|
27461
|
+
onSelectionModelChange: (newSelectionModel, details) => {
|
|
27397
27462
|
if (pagination && paginationMode != 'server') {
|
|
27398
27463
|
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
27399
27464
|
let {
|
|
@@ -27451,7 +27516,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27451
27516
|
};
|
|
27452
27517
|
}
|
|
27453
27518
|
}
|
|
27454
|
-
|
|
27519
|
+
onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel, details);
|
|
27455
27520
|
},
|
|
27456
27521
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
27457
27522
|
'.MuiDataGrid-columnHeaders': {
|
|
@@ -27468,6 +27533,8 @@ DataGrid.className = CLASSNAME$2;
|
|
|
27468
27533
|
DataGrid.displayName = COMPONENT_NAME$2;
|
|
27469
27534
|
|
|
27470
27535
|
// Get and Set data from LocalStorage WITHOUT useState
|
|
27536
|
+
|
|
27537
|
+
// triggering a state update and consecutive re-render
|
|
27471
27538
|
const useFetchState = (defaultValue, key) => {
|
|
27472
27539
|
let stickyValue = null;
|
|
27473
27540
|
try {
|
|
@@ -27475,7 +27542,16 @@ const useFetchState = (defaultValue, key) => {
|
|
|
27475
27542
|
} catch (e) {
|
|
27476
27543
|
console.error('StatefulDataGrid: error getting item from local storage: ', e);
|
|
27477
27544
|
}
|
|
27478
|
-
|
|
27545
|
+
let parsedValue = stickyValue !== null && stickyValue !== undefined && stickyValue !== 'undefined' ? JSON.parse(stickyValue) : defaultValue;
|
|
27546
|
+
|
|
27547
|
+
// TODO: temporary workaround to avoid clashes when someone had sorting on the now-removed screenshot field (renamed to num_annotations)
|
|
27548
|
+
// Consider upgrading the Datagrid component library as the exception handling was added in this PR: https://github.com/mui-org/material-ui-x/pull/3224
|
|
27549
|
+
if (parsedValue instanceof Array) {
|
|
27550
|
+
const fields = (parsedValue || []).map(item => item.field);
|
|
27551
|
+
if (fields.includes('screenshot') || fields.includes('diffs')) {
|
|
27552
|
+
parsedValue = defaultValue;
|
|
27553
|
+
}
|
|
27554
|
+
}
|
|
27479
27555
|
const updateValue = useCallback(value => {
|
|
27480
27556
|
try {
|
|
27481
27557
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -27486,8 +27562,6 @@ const useFetchState = (defaultValue, key) => {
|
|
|
27486
27562
|
return [parsedValue, updateValue];
|
|
27487
27563
|
};
|
|
27488
27564
|
|
|
27489
|
-
// import useLocalStorage from './useLocalStorage';
|
|
27490
|
-
|
|
27491
27565
|
const useTableStates = (id, version) => {
|
|
27492
27566
|
const [paginationModel, setPaginationModel] = useFetchState('', buildStorageKey({
|
|
27493
27567
|
id,
|
|
@@ -27544,7 +27618,8 @@ const useStatefulTable = props => {
|
|
|
27544
27618
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27545
27619
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27546
27620
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27547
|
-
|
|
27621
|
+
onPageChange: propsOnPageChange,
|
|
27622
|
+
onPageSizeChange: propsOnPageSizeChange,
|
|
27548
27623
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27549
27624
|
onSortModelChange: propsOnSortModelChange,
|
|
27550
27625
|
useRouter,
|
|
@@ -27574,7 +27649,7 @@ const useStatefulTable = props => {
|
|
|
27574
27649
|
setDimensionModel
|
|
27575
27650
|
} = useTableStates(id, localStorageVersion);
|
|
27576
27651
|
|
|
27577
|
-
// clearing up old version keys
|
|
27652
|
+
// clearing up old version keys
|
|
27578
27653
|
useEffect(() => clearPreviousVersionStorage(id, previousLocalStorageVersions), [id, previousLocalStorageVersions]);
|
|
27579
27654
|
const onColumnDimensionChange = useCallback(_ref => {
|
|
27580
27655
|
let {
|
|
@@ -27607,6 +27682,7 @@ const useStatefulTable = props => {
|
|
|
27607
27682
|
column.width = dimensionModel[column.field] || column.width || 100;
|
|
27608
27683
|
return column;
|
|
27609
27684
|
}), [propsColumns, dimensionModel]);
|
|
27685
|
+
|
|
27610
27686
|
/** Add resetPage method to apiRef. */
|
|
27611
27687
|
apiRef.current.resetPage = () => {
|
|
27612
27688
|
apiRef.current.setPage(0);
|
|
@@ -27617,7 +27693,7 @@ const useStatefulTable = props => {
|
|
|
27617
27693
|
onFilterModelChange: (model, details) => {
|
|
27618
27694
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
27619
27695
|
items: model.items.map(item => {
|
|
27620
|
-
const column = apiRef.current.getColumn(item.
|
|
27696
|
+
const column = apiRef.current.getColumn(item.columnField);
|
|
27621
27697
|
item.type = column.type || 'string';
|
|
27622
27698
|
return item;
|
|
27623
27699
|
}),
|
|
@@ -27655,16 +27731,33 @@ const useStatefulTable = props => {
|
|
|
27655
27731
|
}, search, localStorageVersion, historyReplace, columns);
|
|
27656
27732
|
},
|
|
27657
27733
|
pinnedColumns: pinnedColumnsModel,
|
|
27658
|
-
|
|
27659
|
-
|
|
27660
|
-
|
|
27661
|
-
|
|
27662
|
-
|
|
27663
|
-
|
|
27734
|
+
page: paginationModelParsed.page,
|
|
27735
|
+
pageSize: paginationModelParsed.pageSize,
|
|
27736
|
+
onPageChange: (page, details) => {
|
|
27737
|
+
const direction = paginationModelParsed.page < page ? 'next' : 'back';
|
|
27738
|
+
propsOnPageChange === null || propsOnPageChange === void 0 ? void 0 : propsOnPageChange(page, details);
|
|
27739
|
+
updateUrl({
|
|
27740
|
+
filterModel: filterParsed,
|
|
27741
|
+
sortModel: sortModelParsed,
|
|
27742
|
+
paginationModel: {
|
|
27743
|
+
page,
|
|
27744
|
+
pageSize: paginationModelParsed.pageSize,
|
|
27745
|
+
direction
|
|
27746
|
+
},
|
|
27747
|
+
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
27748
|
+
pinnedColumnsModel: pinnedColumnsModel
|
|
27749
|
+
}, search, localStorageVersion, historyReplace, columns);
|
|
27750
|
+
},
|
|
27751
|
+
onPageSizeChange: (pageSize, details) => {
|
|
27752
|
+
propsOnPageSizeChange === null || propsOnPageSizeChange === void 0 ? void 0 : propsOnPageSizeChange(pageSize, details);
|
|
27664
27753
|
updateUrl({
|
|
27665
27754
|
filterModel: filterParsed,
|
|
27666
27755
|
sortModel: sortModelParsed,
|
|
27667
|
-
paginationModel:
|
|
27756
|
+
paginationModel: {
|
|
27757
|
+
page: paginationModelParsed.page,
|
|
27758
|
+
pageSize,
|
|
27759
|
+
direction: paginationModelParsed.direction
|
|
27760
|
+
},
|
|
27668
27761
|
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
27669
27762
|
pinnedColumnsModel: pinnedColumnsModel
|
|
27670
27763
|
}, search, localStorageVersion, historyReplace, columns);
|
|
@@ -27690,7 +27783,7 @@ const useStatefulTable = props => {
|
|
|
27690
27783
|
};
|
|
27691
27784
|
};
|
|
27692
27785
|
|
|
27693
|
-
const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "
|
|
27786
|
+
const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "columnTypes", "components", "componentsProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "page", "pageSize", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "previousLocalStorageVersions", "onFilterModelChange", "selectionModel", "onColumnWidthChange", "onPageChange", "onPageSizeChange", "onSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "rows", "rowsPerPageOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
|
|
27694
27787
|
const COMPONENT_NAME$1 = 'DataGrid';
|
|
27695
27788
|
const CLASSNAME$1 = 'redsift-datagrid';
|
|
27696
27789
|
const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -27700,13 +27793,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27700
27793
|
autoHeight,
|
|
27701
27794
|
className,
|
|
27702
27795
|
columns,
|
|
27703
|
-
|
|
27704
|
-
|
|
27796
|
+
columnTypes: propsColumnTypes,
|
|
27797
|
+
components,
|
|
27798
|
+
componentsProps,
|
|
27705
27799
|
filterModel: propsFilterModel,
|
|
27706
27800
|
columnVisibilityModel: propsColumnVisibilityModel,
|
|
27707
27801
|
pinnedColumns: propsPinnedColumns,
|
|
27708
27802
|
sortModel: propsSortModel,
|
|
27709
|
-
|
|
27803
|
+
page: propsPage,
|
|
27804
|
+
pageSize: propsPageSize,
|
|
27710
27805
|
height: propsHeight,
|
|
27711
27806
|
hideToolbar,
|
|
27712
27807
|
initialState,
|
|
@@ -27715,10 +27810,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27715
27810
|
localStorageVersion,
|
|
27716
27811
|
previousLocalStorageVersions,
|
|
27717
27812
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27718
|
-
|
|
27813
|
+
selectionModel: propsSelectionModel,
|
|
27719
27814
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27720
|
-
|
|
27721
|
-
|
|
27815
|
+
onPageChange: propsOnPageChange,
|
|
27816
|
+
onPageSizeChange: propsOnPageSizeChange,
|
|
27817
|
+
onSelectionModelChange: propsOnSelectionModelChange,
|
|
27722
27818
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27723
27819
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27724
27820
|
onSortModelChange: propsOnSortModelChange,
|
|
@@ -27726,7 +27822,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27726
27822
|
paginationPlacement = 'both',
|
|
27727
27823
|
paginationProps,
|
|
27728
27824
|
rows,
|
|
27729
|
-
|
|
27825
|
+
rowsPerPageOptions,
|
|
27730
27826
|
sx,
|
|
27731
27827
|
theme: propsTheme,
|
|
27732
27828
|
useRouter,
|
|
@@ -27737,38 +27833,43 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27737
27833
|
const theme = useTheme$4(propsTheme);
|
|
27738
27834
|
const _apiRef = useGridApiRef();
|
|
27739
27835
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
27740
|
-
const RenderedToolbar =
|
|
27836
|
+
const RenderedToolbar = components !== null && components !== void 0 && components.Toolbar ? components.Toolbar : Toolbar$2;
|
|
27741
27837
|
LicenseInfo.setLicenseKey(license);
|
|
27742
27838
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
27743
27839
|
const {
|
|
27744
27840
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
27745
27841
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
27746
|
-
|
|
27842
|
+
onPageChange: controlledOnPageChange,
|
|
27843
|
+
onPageSizeChange: controlledOnPageSizeChange,
|
|
27747
27844
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
27748
27845
|
onSortModelChange: controlledOnSortModelChange
|
|
27749
27846
|
} = useControlledDatagridState({
|
|
27750
27847
|
initialState,
|
|
27751
|
-
|
|
27848
|
+
rowsPerPageOptions,
|
|
27752
27849
|
propsColumnVisibilityModel,
|
|
27753
27850
|
propsFilterModel,
|
|
27754
27851
|
propsOnColumnVisibilityModelChange,
|
|
27755
27852
|
propsOnFilterModelChange,
|
|
27756
27853
|
propsOnPinnedColumnsChange,
|
|
27757
27854
|
propsOnSortModelChange,
|
|
27758
|
-
|
|
27855
|
+
propsPage,
|
|
27856
|
+
propsPageSize,
|
|
27759
27857
|
propsPinnedColumns,
|
|
27760
27858
|
propsSortModel,
|
|
27761
|
-
|
|
27859
|
+
propsOnPageChange,
|
|
27860
|
+
propsOnPageSizeChange
|
|
27762
27861
|
});
|
|
27763
27862
|
const {
|
|
27764
27863
|
columnVisibilityModel,
|
|
27765
27864
|
filterModel,
|
|
27766
27865
|
onColumnVisibilityModelChange,
|
|
27767
27866
|
onFilterModelChange,
|
|
27768
|
-
|
|
27867
|
+
onPageChange,
|
|
27868
|
+
onPageSizeChange,
|
|
27769
27869
|
onPinnedColumnsChange,
|
|
27770
27870
|
onSortModelChange,
|
|
27771
|
-
|
|
27871
|
+
page,
|
|
27872
|
+
pageSize,
|
|
27772
27873
|
pinnedColumns,
|
|
27773
27874
|
sortModel,
|
|
27774
27875
|
onColumnWidthChange
|
|
@@ -27779,39 +27880,40 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27779
27880
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
27780
27881
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27781
27882
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
27782
|
-
|
|
27883
|
+
onPageChange: controlledOnPageChange,
|
|
27884
|
+
onPageSizeChange: controlledOnPageSizeChange,
|
|
27783
27885
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
27784
27886
|
onSortModelChange: controlledOnSortModelChange,
|
|
27785
27887
|
useRouter: useRouter,
|
|
27786
27888
|
localStorageVersion,
|
|
27787
27889
|
previousLocalStorageVersions
|
|
27788
27890
|
});
|
|
27789
|
-
const [
|
|
27891
|
+
const [selectionModel, setSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
27790
27892
|
useEffect(() => {
|
|
27791
|
-
|
|
27792
|
-
}, [
|
|
27793
|
-
const
|
|
27794
|
-
if (
|
|
27795
|
-
|
|
27893
|
+
setSelectionModel(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
27894
|
+
}, [propsSelectionModel]);
|
|
27895
|
+
const onSelectionModelChange = (selectionModel, details) => {
|
|
27896
|
+
if (propsOnSelectionModelChange) {
|
|
27897
|
+
propsOnSelectionModelChange(selectionModel, details);
|
|
27796
27898
|
} else {
|
|
27797
|
-
|
|
27899
|
+
setSelectionModel(selectionModel);
|
|
27798
27900
|
}
|
|
27799
27901
|
};
|
|
27800
27902
|
const selectionStatus = useRef({
|
|
27801
27903
|
type: 'none',
|
|
27802
27904
|
numberOfSelectedRows: 0,
|
|
27803
27905
|
numberOfSelectedRowsInPage: 0,
|
|
27804
|
-
page
|
|
27805
|
-
pageSize:
|
|
27906
|
+
page,
|
|
27907
|
+
pageSize: pageSize
|
|
27806
27908
|
});
|
|
27807
27909
|
|
|
27808
27910
|
// in server-side pagination we want to update the selection status
|
|
27809
27911
|
// every time we navigate between pages, resize our page or select something
|
|
27810
27912
|
useEffect(() => {
|
|
27811
27913
|
if (paginationMode == 'server') {
|
|
27812
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
27914
|
+
onServerSideSelectionStatusChange(Array.isArray(selectionModel) ? selectionModel : [selectionModel], apiRef, selectionStatus, isRowSelectable, page, pageSize);
|
|
27813
27915
|
}
|
|
27814
|
-
}, [
|
|
27916
|
+
}, [selectionModel, page, pageSize]);
|
|
27815
27917
|
if (!Array.isArray(rows)) {
|
|
27816
27918
|
return null;
|
|
27817
27919
|
}
|
|
@@ -27844,13 +27946,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27844
27946
|
filterModel: filterModel,
|
|
27845
27947
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
27846
27948
|
onFilterModelChange: onFilterModelChange,
|
|
27847
|
-
|
|
27949
|
+
onPageChange: onPageChange,
|
|
27950
|
+
onPageSizeChange: onPageSizeChange,
|
|
27848
27951
|
onPinnedColumnsChange: onPinnedColumnsChange,
|
|
27849
27952
|
onSortModelChange: onSortModelChange,
|
|
27850
|
-
|
|
27953
|
+
page: page,
|
|
27954
|
+
pageSize: pageSize,
|
|
27851
27955
|
pinnedColumns: pinnedColumns,
|
|
27852
27956
|
sortModel: sortModel,
|
|
27853
|
-
|
|
27957
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27854
27958
|
onColumnWidthChange: onColumnWidthChange,
|
|
27855
27959
|
initialState: initialState,
|
|
27856
27960
|
isRowSelectable: isRowSelectable,
|
|
@@ -27861,55 +27965,58 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27861
27965
|
rowCount: rowCount,
|
|
27862
27966
|
autoHeight: autoHeight,
|
|
27863
27967
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
27864
|
-
|
|
27865
|
-
|
|
27866
|
-
|
|
27867
|
-
|
|
27868
|
-
|
|
27869
|
-
|
|
27968
|
+
columnTypes: _objectSpread2(_objectSpread2({}, customColumnTypes), propsColumnTypes),
|
|
27969
|
+
components: _objectSpread2(_objectSpread2({
|
|
27970
|
+
BaseButton,
|
|
27971
|
+
BaseCheckbox,
|
|
27972
|
+
// BaseTextField,
|
|
27973
|
+
BasePopper,
|
|
27974
|
+
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27870
27975
|
displayName: "ColumnFilteredIcon"
|
|
27871
27976
|
})),
|
|
27872
|
-
|
|
27977
|
+
ColumnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27873
27978
|
displayName: "ColumnSelectorIcon"
|
|
27874
27979
|
})),
|
|
27875
|
-
|
|
27980
|
+
ColumnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27876
27981
|
displayName: "ColumnSortedAscendingIcon"
|
|
27877
27982
|
})),
|
|
27878
|
-
|
|
27983
|
+
ColumnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27879
27984
|
displayName: "ColumnSortedDescendingIcon"
|
|
27880
27985
|
})),
|
|
27881
|
-
|
|
27986
|
+
DensityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27882
27987
|
displayName: "DensityCompactIcon"
|
|
27883
27988
|
})),
|
|
27884
|
-
|
|
27989
|
+
DensityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27885
27990
|
displayName: "DensityStandardIcon"
|
|
27886
27991
|
})),
|
|
27887
|
-
|
|
27992
|
+
DensityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27888
27993
|
displayName: "DensityComfortableIcon"
|
|
27889
27994
|
})),
|
|
27890
|
-
|
|
27995
|
+
DetailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27891
27996
|
displayName: "DetailPanelCollapseIcon"
|
|
27892
27997
|
})),
|
|
27893
|
-
|
|
27998
|
+
DetailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27894
27999
|
displayName: "DetailPanelExpandIcon"
|
|
27895
28000
|
})),
|
|
27896
|
-
|
|
28001
|
+
ExportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27897
28002
|
displayName: "ExportIcon"
|
|
27898
28003
|
})),
|
|
27899
|
-
|
|
28004
|
+
OpenFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
27900
28005
|
displayName: "OpenFilterButtonIcon"
|
|
27901
28006
|
}, props))
|
|
27902
|
-
},
|
|
27903
|
-
|
|
27904
|
-
|
|
28007
|
+
}, components), {}, {
|
|
28008
|
+
Toolbar: ToolbarWrapper,
|
|
28009
|
+
Pagination: props => {
|
|
27905
28010
|
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
27906
28011
|
displaySelection: false,
|
|
27907
28012
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
27908
28013
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
27909
28014
|
selectionStatus: selectionStatus.current,
|
|
27910
|
-
|
|
27911
|
-
|
|
27912
|
-
|
|
28015
|
+
page: page,
|
|
28016
|
+
pageSize: pageSize,
|
|
28017
|
+
onPageChange: onPageChange,
|
|
28018
|
+
onPageSizeChange: onPageSizeChange,
|
|
28019
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27913
28020
|
paginationProps: paginationProps,
|
|
27914
28021
|
paginationMode: paginationMode,
|
|
27915
28022
|
rowCount: rowCount
|
|
@@ -27920,15 +28027,17 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27920
28027
|
selectionStatus: selectionStatus.current,
|
|
27921
28028
|
apiRef: apiRef,
|
|
27922
28029
|
isRowSelectable: isRowSelectable,
|
|
27923
|
-
|
|
27924
|
-
|
|
27925
|
-
|
|
28030
|
+
page: page,
|
|
28031
|
+
pageSize: pageSize,
|
|
28032
|
+
onPageChange: onPageChange,
|
|
28033
|
+
onPageSizeChange: onPageSizeChange,
|
|
28034
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
27926
28035
|
paginationProps: paginationProps,
|
|
27927
28036
|
paginationMode: paginationMode
|
|
27928
28037
|
})) : null;
|
|
27929
28038
|
}
|
|
27930
28039
|
}),
|
|
27931
|
-
|
|
28040
|
+
componentsProps: _objectSpread2(_objectSpread2({}, componentsProps), {}, {
|
|
27932
28041
|
toolbar: _objectSpread2({
|
|
27933
28042
|
hideToolbar,
|
|
27934
28043
|
RenderedToolbar,
|
|
@@ -27939,16 +28048,18 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27939
28048
|
selectionStatus,
|
|
27940
28049
|
apiRef,
|
|
27941
28050
|
isRowSelectable,
|
|
27942
|
-
|
|
27943
|
-
|
|
27944
|
-
|
|
28051
|
+
page,
|
|
28052
|
+
pageSize,
|
|
28053
|
+
onPageChange,
|
|
28054
|
+
onPageSizeChange,
|
|
28055
|
+
rowsPerPageOptions,
|
|
27945
28056
|
paginationProps,
|
|
27946
28057
|
paginationMode,
|
|
27947
28058
|
rowCount
|
|
27948
|
-
},
|
|
28059
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbar)
|
|
27949
28060
|
}),
|
|
27950
|
-
|
|
27951
|
-
|
|
28061
|
+
selectionModel: selectionModel,
|
|
28062
|
+
onSelectionModelChange: (newSelectionModel, details) => {
|
|
27952
28063
|
if (pagination && paginationMode != 'server') {
|
|
27953
28064
|
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
27954
28065
|
let {
|
|
@@ -28006,7 +28117,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28006
28117
|
};
|
|
28007
28118
|
}
|
|
28008
28119
|
}
|
|
28009
|
-
|
|
28120
|
+
onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel, details);
|
|
28010
28121
|
},
|
|
28011
28122
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
28012
28123
|
'.MuiDataGrid-columnHeaders': {
|
|
@@ -28080,5 +28191,5 @@ const TextCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28080
28191
|
TextCell.className = CLASSNAME;
|
|
28081
28192
|
TextCell.displayName = COMPONENT_NAME;
|
|
28082
28193
|
|
|
28083
|
-
export { BaseButton, BaseCheckbox, BaseIcon, BasePopper, BaseTextField, CATEGORIES, CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, ControlledPagination, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DIMENSION_MODEL_KEY, DOES_NOT_CONTAIN, DOES_NOT_EQUAL, DataGrid, ENDS_WITH_ANY_OF, FILTER_MODEL_KEY, FILTER_SEARCH_KEY, GridToolbarFilterSemanticField, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, PAGINATION_MODEL_KEY, PINNED_COLUMNS, SORT_MODEL_KEY, STARTS_WITH_ANY_OF, ServerSideControlledPagination, StatefulDataGrid, TextCell, Toolbar$2 as Toolbar, ToolbarWrapper, VISIBILITY_MODEL_KEY, areFilterModelsEquivalent, buildStorageKey, clearPreviousVersionStorage, customColumnTypes, decodeValue, encodeValue, getColumnVisibilityFromString, getCompletion, getFilterModelFromString, getFinalSearch, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators, getModelsParsedOrUpdateLocalStorage, getPaginationFromString, getPinnedColumnsFromString, getRsNumberColumnType, getRsStringColumnType, getSearchParamsFromColumnVisibility, getSearchParamsFromFilterModel, getSearchParamsFromPagination, getSearchParamsFromPinnedColumns, getSearchParamsFromSorting, getSearchParamsFromTab, getSortingFromString,
|
|
28194
|
+
export { BaseButton, BaseCheckbox, BaseIcon, BasePopper, BaseTextField, CATEGORIES, CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, ControlledPagination, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DIMENSION_MODEL_KEY, DOES_NOT_CONTAIN, DOES_NOT_EQUAL, DataGrid, ENDS_WITH_ANY_OF, FILTER_MODEL_KEY, FILTER_SEARCH_KEY, GridToolbarFilterSemanticField, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, PAGINATION_MODEL_KEY, PINNED_COLUMNS, SORT_MODEL_KEY, STARTS_WITH_ANY_OF, ServerSideControlledPagination, StatefulDataGrid, TextCell, Toolbar$2 as Toolbar, ToolbarWrapper, VISIBILITY_MODEL_KEY, areFilterModelsEquivalent, buildStorageKey, clearPreviousVersionStorage, customColumnTypes, decodeValue, encodeValue, getColumnVisibilityFromString, getCompletion, getFilterModelFromString, getFinalSearch, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators, getModelsParsedOrUpdateLocalStorage, getPaginationFromString, getPinnedColumnsFromString, getRsNumberColumnType, getRsStringColumnType, getSearchParamsFromColumnVisibility, getSearchParamsFromFilterModel, getSearchParamsFromPagination, getSearchParamsFromPinnedColumns, getSearchParamsFromSorting, getSearchParamsFromTab, getSortingFromString, muiIconToDSIcon, numberOperatorDecoder, numberOperatorEncoder, onServerSideSelectionStatusChange, operatorList, updateUrl, urlSearchParamsToString };
|
|
28084
28195
|
//# sourceMappingURL=index.js.map
|