@redsift/table 11.2.1-muiv5 → 11.2.2-alpha.1
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 +26 -32
- package/index.js +290 -395
- package/index.js.map +1 -1
- package/package.json +6 -6
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, GridLogicOperator, GridToolbarContainer, GridToolbarFilterButton, GridToolbarColumnsButton, GridToolbarDensitySelector, GridToolbarExport, gridExpandedSortedRowIdsSelector, 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.field || !filterItem.value || !filterItem.operator) {
|
|
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 && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
17655
|
+
return params.value !== null && params.value !== undefined && 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.field || !filterItem.value || !filterItem.value) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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.field || !filterItem.value || !filterItem.operator) {
|
|
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
|
+
type: 'string',
|
|
17881
17881
|
filterOperators: operatorList.rsString
|
|
17882
17882
|
};
|
|
17883
17883
|
};
|
|
17884
17884
|
const getRsNumberColumnType = () => {
|
|
17885
17885
|
return {
|
|
17886
|
-
|
|
17886
|
+
type: '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-1106';
|
|
17898
17898
|
try {
|
|
17899
17899
|
const messages = [{
|
|
17900
17900
|
role: 'system',
|
|
@@ -18063,42 +18063,39 @@ const numberOperatorDecoder = {
|
|
|
18063
18063
|
lt: '<',
|
|
18064
18064
|
lte: '<='
|
|
18065
18065
|
};
|
|
18066
|
-
const isOperatorValueValid = (
|
|
18067
|
-
const column = columns.find(column => column.field ===
|
|
18066
|
+
const isOperatorValueValid = (field, operator, columns) => {
|
|
18067
|
+
const column = columns.find(column => column.field === field);
|
|
18068
18068
|
if (!column) {
|
|
18069
18069
|
return false;
|
|
18070
18070
|
}
|
|
18071
18071
|
const columnType = (column === null || column === void 0 ? void 0 : column.type) || 'string';
|
|
18072
|
-
const operators = operatorList[columnType];
|
|
18072
|
+
const operators = column.filterOperators || operatorList[columnType];
|
|
18073
18073
|
if (!operators) {
|
|
18074
18074
|
return false;
|
|
18075
18075
|
}
|
|
18076
|
-
|
|
18077
|
-
return !!operators.filterOperators.find(op => columnType === 'number' && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
18078
|
-
}
|
|
18079
|
-
return !!operators.find(op => ['number', 'rsNumber'].includes(columnType) && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operatorValue : op['value'] === operatorValue);
|
|
18076
|
+
return !!operators.find(op => columnType === 'number' && Object.keys(numberOperatorEncoder).includes(op.value) ? numberOperatorEncoder[op.value] === operator : op.value === operator);
|
|
18080
18077
|
};
|
|
18081
18078
|
const listOperators = ['containsAnyOf', 'endsWithAnyOf', 'isAnyOf', 'isNotAnyOf', 'startsWithAnyOf'];
|
|
18082
18079
|
|
|
18083
18080
|
// Check if the value doesn't break
|
|
18084
|
-
const isValueValid = (value,
|
|
18081
|
+
const isValueValid = (value, field, columns, operator) => {
|
|
18085
18082
|
var _column$type;
|
|
18086
18083
|
// every field accepts undefined as value for default
|
|
18087
18084
|
if (value === undefined || value === '') {
|
|
18088
18085
|
return true;
|
|
18089
18086
|
}
|
|
18090
18087
|
|
|
18091
|
-
// xxxAnyOf accepts as value only lists, and we are
|
|
18088
|
+
// xxxAnyOf accepts as value only lists, and we are declaring them in the
|
|
18092
18089
|
// URL as `list=[...]`
|
|
18093
|
-
if (listOperators.includes(
|
|
18090
|
+
if (listOperators.includes(operator)) {
|
|
18094
18091
|
return Array.isArray(value) || value === '';
|
|
18095
18092
|
}
|
|
18096
18093
|
|
|
18097
18094
|
// We are accepting arrays only if they are of the 'xxxAnyOf' type
|
|
18098
|
-
if (Array.isArray(value) && !listOperators.includes(
|
|
18095
|
+
if (Array.isArray(value) && !listOperators.includes(operator)) {
|
|
18099
18096
|
return false;
|
|
18100
18097
|
}
|
|
18101
|
-
const column = columns.find(column => column.field ===
|
|
18098
|
+
const column = columns.find(column => column.field === field);
|
|
18102
18099
|
if (!column) {
|
|
18103
18100
|
return false;
|
|
18104
18101
|
}
|
|
@@ -18136,14 +18133,14 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18136
18133
|
if (!searchString) {
|
|
18137
18134
|
return 'invalid';
|
|
18138
18135
|
}
|
|
18139
|
-
let
|
|
18136
|
+
let logicOperator = GridLogicOperator.And;
|
|
18140
18137
|
const searchParams = new URLSearchParams();
|
|
18141
18138
|
for (const [key, value] of new URLSearchParams(searchString)) {
|
|
18142
18139
|
if (key.startsWith('_') && !['_logicOperator', '_sortColumn', '_pinnedColumnsLeft', '_pinnedColumnsRight', '_columnVisibility', '_pagination'].includes(key)) {
|
|
18143
18140
|
searchParams.set(key, value);
|
|
18144
18141
|
}
|
|
18145
18142
|
if (key === '_logicOperator') {
|
|
18146
|
-
|
|
18143
|
+
logicOperator = value === GridLogicOperator.And || value === GridLogicOperator.Or ? value : GridLogicOperator.And;
|
|
18147
18144
|
}
|
|
18148
18145
|
}
|
|
18149
18146
|
let id = 5000;
|
|
@@ -18184,8 +18181,8 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18184
18181
|
return;
|
|
18185
18182
|
}
|
|
18186
18183
|
items.push({
|
|
18187
|
-
|
|
18188
|
-
|
|
18184
|
+
field,
|
|
18185
|
+
operator: columnType === 'number' && Object.keys(numberOperatorDecoder).includes(operator) ? numberOperatorDecoder[operator] : operator,
|
|
18189
18186
|
id,
|
|
18190
18187
|
value: listOperators.includes(operator) && decodedValue === '' ? [] : decodedValue,
|
|
18191
18188
|
type
|
|
@@ -18200,23 +18197,23 @@ const getFilterModelFromString = (searchString, columns) => {
|
|
|
18200
18197
|
}
|
|
18201
18198
|
return {
|
|
18202
18199
|
items,
|
|
18203
|
-
|
|
18200
|
+
logicOperator
|
|
18204
18201
|
};
|
|
18205
18202
|
};
|
|
18206
18203
|
const getSearchParamsFromFilterModel = filterModel => {
|
|
18207
18204
|
const searchParams = new URLSearchParams();
|
|
18208
|
-
searchParams.set('_logicOperator', filterModel['
|
|
18205
|
+
searchParams.set('_logicOperator', filterModel['logicOperator'] || '');
|
|
18209
18206
|
filterModel['items'].forEach(item => {
|
|
18210
18207
|
const {
|
|
18211
|
-
|
|
18212
|
-
|
|
18208
|
+
field,
|
|
18209
|
+
operator,
|
|
18213
18210
|
value,
|
|
18214
18211
|
type
|
|
18215
18212
|
} = item;
|
|
18216
|
-
if (Object.keys(numberOperatorEncoder).includes(
|
|
18217
|
-
searchParams.set(`_${
|
|
18213
|
+
if (Object.keys(numberOperatorEncoder).includes(operator)) {
|
|
18214
|
+
searchParams.set(`_${field}[${numberOperatorEncoder[operator]},${encodeValue(type)}]`, encodeValue(value));
|
|
18218
18215
|
} else {
|
|
18219
|
-
searchParams.set(`_${
|
|
18216
|
+
searchParams.set(`_${field}[${encodeValue(operator)},${encodeValue(type)}]`, encodeValue(value));
|
|
18220
18217
|
}
|
|
18221
18218
|
});
|
|
18222
18219
|
return searchParams;
|
|
@@ -18242,7 +18239,7 @@ const getFilterModel = (search, columns, localStorageFilters, setLocalStorageFil
|
|
|
18242
18239
|
}
|
|
18243
18240
|
return initialState && initialState.filter && initialState.filter.filterModel ? initialState.filter.filterModel : {
|
|
18244
18241
|
items: [],
|
|
18245
|
-
|
|
18242
|
+
logicOperator: GridLogicOperator.And
|
|
18246
18243
|
};
|
|
18247
18244
|
};
|
|
18248
18245
|
|
|
@@ -18330,6 +18327,7 @@ const getSearchParamsFromPagination = pagination => {
|
|
|
18330
18327
|
// - if we don't have that, use the localStorage and update the URL
|
|
18331
18328
|
// - if we don't have that, return an empty PaginationModel
|
|
18332
18329
|
const getPaginationModel = (search, localStoragePagination, setLocalStoragePagination, initialState) => {
|
|
18330
|
+
var _initialState$paginat;
|
|
18333
18331
|
const pagination = getPaginationFromString(search);
|
|
18334
18332
|
if (pagination !== 'invalid') {
|
|
18335
18333
|
const searchFromPaginationModel = getSearchParamsFromPagination(pagination);
|
|
@@ -18343,11 +18341,11 @@ const getPaginationModel = (search, localStoragePagination, setLocalStoragePagin
|
|
|
18343
18341
|
if (paginationModelFromLocalStorage !== 'invalid') {
|
|
18344
18342
|
return paginationModelFromLocalStorage;
|
|
18345
18343
|
}
|
|
18346
|
-
return initialState !== null && initialState !== void 0 && initialState.pagination ? _objectSpread2({
|
|
18344
|
+
return initialState !== null && initialState !== void 0 && (_initialState$paginat = initialState.pagination) !== null && _initialState$paginat !== void 0 && _initialState$paginat.paginationModel ? _objectSpread2({
|
|
18347
18345
|
page: 0,
|
|
18348
18346
|
pageSize: 25,
|
|
18349
18347
|
direction: 'next'
|
|
18350
|
-
}, initialState.pagination) : {
|
|
18348
|
+
}, initialState.pagination.paginationModel) : {
|
|
18351
18349
|
page: 0,
|
|
18352
18350
|
pageSize: 25,
|
|
18353
18351
|
direction: 'next'
|
|
@@ -18356,13 +18354,38 @@ const getPaginationModel = (search, localStoragePagination, setLocalStoragePagin
|
|
|
18356
18354
|
|
|
18357
18355
|
/** COLUMN VISIBILITY */
|
|
18358
18356
|
|
|
18357
|
+
const getColumnVisibilityFromString = (searchString, columns) => {
|
|
18358
|
+
if (!searchString) {
|
|
18359
|
+
return 'invalid';
|
|
18360
|
+
}
|
|
18361
|
+
const searchParams = new URLSearchParams(searchString);
|
|
18362
|
+
const value = searchParams.get('_columnVisibility');
|
|
18363
|
+
if (value === '' || value === null || value === '[]') {
|
|
18364
|
+
return 'invalid';
|
|
18365
|
+
}
|
|
18366
|
+
const parsedFields = value.slice(1, value.length - 1).split(',');
|
|
18367
|
+
const fields = columns.map(column => column.field);
|
|
18368
|
+
const visibility = {};
|
|
18369
|
+
for (const field of fields) {
|
|
18370
|
+
visibility[field] = false;
|
|
18371
|
+
}
|
|
18372
|
+
for (const parsedField of parsedFields) {
|
|
18373
|
+
if (fields.includes(parsedField)) {
|
|
18374
|
+
visibility[parsedField] = true;
|
|
18375
|
+
}
|
|
18376
|
+
}
|
|
18377
|
+
if (Object.values(visibility).filter(v => v === true).length === 0) {
|
|
18378
|
+
return 'invalid';
|
|
18379
|
+
}
|
|
18380
|
+
return visibility;
|
|
18381
|
+
};
|
|
18359
18382
|
const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
18360
18383
|
const searchParams = new URLSearchParams();
|
|
18361
|
-
const
|
|
18384
|
+
const fields = columns.map(column => column.field);
|
|
18362
18385
|
|
|
18363
18386
|
// if column visibility model is empty, show all columns
|
|
18364
18387
|
if (Object.keys(columnVisibility).length == 0) {
|
|
18365
|
-
searchParams.set('_columnVisibility', `[${
|
|
18388
|
+
searchParams.set('_columnVisibility', `[${fields.join(',')}]`);
|
|
18366
18389
|
return searchParams;
|
|
18367
18390
|
}
|
|
18368
18391
|
const finalColumnVisibility = columns.filter(c => {
|
|
@@ -18373,63 +18396,10 @@ const getSearchParamsFromColumnVisibility = (columnVisibility, columns) => {
|
|
|
18373
18396
|
[colName]: true
|
|
18374
18397
|
});
|
|
18375
18398
|
}, columnVisibility);
|
|
18376
|
-
const visibleColumns =
|
|
18377
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18378
|
-
.filter(_ref => {
|
|
18379
|
-
let [_, visible] = _ref;
|
|
18380
|
-
return visible;
|
|
18381
|
-
})
|
|
18382
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18383
|
-
.map(_ref2 => {
|
|
18384
|
-
let [column, _] = _ref2;
|
|
18385
|
-
return encodeValue(column);
|
|
18386
|
-
});
|
|
18399
|
+
const visibleColumns = fields.filter(column => finalColumnVisibility[column] !== false);
|
|
18387
18400
|
searchParams.set('_columnVisibility', `[${visibleColumns.join(',')}]`);
|
|
18388
18401
|
return searchParams;
|
|
18389
18402
|
};
|
|
18390
|
-
const getColumnVisibilityFromString = (notParsed, tableColumns) => {
|
|
18391
|
-
if (!notParsed || notParsed.length === 1 && notParsed[0] === '?') {
|
|
18392
|
-
return 'invalid';
|
|
18393
|
-
}
|
|
18394
|
-
// remove the initial ? if present
|
|
18395
|
-
const parsed = notParsed[0] === '?' ? notParsed.slice(1) : notParsed;
|
|
18396
|
-
const visibility = {};
|
|
18397
|
-
let exist = false;
|
|
18398
|
-
let visibleColumnsCount = 0;
|
|
18399
|
-
for (const item of parsed.split('&')) {
|
|
18400
|
-
// if it's not column visibility field, skip
|
|
18401
|
-
const fieldURL = item.split('=')[0];
|
|
18402
|
-
if (fieldURL !== '_columnVisibility') {
|
|
18403
|
-
continue;
|
|
18404
|
-
}
|
|
18405
|
-
// e.g. item = _columnVisibility[abc,def]
|
|
18406
|
-
const left = item.split(']')[0];
|
|
18407
|
-
if (left.split('[').length < 2) {
|
|
18408
|
-
continue;
|
|
18409
|
-
}
|
|
18410
|
-
const encodedValues = item.split('[')[1].split(']')[0];
|
|
18411
|
-
if (typeof encodedValues !== 'string') {
|
|
18412
|
-
continue;
|
|
18413
|
-
}
|
|
18414
|
-
exist = true;
|
|
18415
|
-
const columnFields = tableColumns.map(column => column.field);
|
|
18416
|
-
// TODO: Add validation that , is present
|
|
18417
|
-
const columns = encodedValues.split(',').map(value => decodeValue(value));
|
|
18418
|
-
|
|
18419
|
-
// for each column, check if it's visible and add it to visibility model
|
|
18420
|
-
for (const column of columnFields) {
|
|
18421
|
-
const isColumnVisible = columns.includes(column);
|
|
18422
|
-
visibility[column] = isColumnVisible;
|
|
18423
|
-
if (isColumnVisible) {
|
|
18424
|
-
visibleColumnsCount += 1;
|
|
18425
|
-
}
|
|
18426
|
-
}
|
|
18427
|
-
}
|
|
18428
|
-
if (visibleColumnsCount === 0 && !exist) {
|
|
18429
|
-
return 'invalid';
|
|
18430
|
-
}
|
|
18431
|
-
return visibility;
|
|
18432
|
-
};
|
|
18433
18403
|
|
|
18434
18404
|
// Rules:
|
|
18435
18405
|
// - if we have something in the URL, use that info
|
|
@@ -18484,8 +18454,8 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
18484
18454
|
if (typeof encodedValues !== 'string') {
|
|
18485
18455
|
continue;
|
|
18486
18456
|
}
|
|
18487
|
-
const
|
|
18488
|
-
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' &&
|
|
18457
|
+
const fields = [...tableColumns.map(column => column.field), '__check__'];
|
|
18458
|
+
const columns = encodedValues.split(',').map(value => decodeValue(value)).filter(val => typeof val === 'string' && fields.includes(val));
|
|
18489
18459
|
if (fieldURL === '_pinnedColumnsLeft') {
|
|
18490
18460
|
pinnedColumns['left'] = columns;
|
|
18491
18461
|
}
|
|
@@ -18493,9 +18463,9 @@ const getPinnedColumnsFromString = (notParsed, tableColumns) => {
|
|
|
18493
18463
|
pinnedColumns['right'] = columns;
|
|
18494
18464
|
}
|
|
18495
18465
|
}
|
|
18496
|
-
return pinnedColumns
|
|
18497
|
-
left: pinnedColumns
|
|
18498
|
-
right: pinnedColumns
|
|
18466
|
+
return pinnedColumns.left && pinnedColumns.left.length > 0 || pinnedColumns.right && pinnedColumns.right.length > 0 ? {
|
|
18467
|
+
left: pinnedColumns.left || [],
|
|
18468
|
+
right: pinnedColumns.right || []
|
|
18499
18469
|
} : 'invalid';
|
|
18500
18470
|
};
|
|
18501
18471
|
const getSearchParamsFromPinnedColumns = pinnedColumns => {
|
|
@@ -18547,7 +18517,7 @@ const getSearchParamsFromTab = search => {
|
|
|
18547
18517
|
}
|
|
18548
18518
|
return searchParams;
|
|
18549
18519
|
};
|
|
18550
|
-
const getFinalSearch =
|
|
18520
|
+
const getFinalSearch = _ref => {
|
|
18551
18521
|
let {
|
|
18552
18522
|
search,
|
|
18553
18523
|
filterModel,
|
|
@@ -18556,7 +18526,7 @@ const getFinalSearch = _ref3 => {
|
|
|
18556
18526
|
columnsVisibilityModel,
|
|
18557
18527
|
pinnedColumnsModel,
|
|
18558
18528
|
columns
|
|
18559
|
-
} =
|
|
18529
|
+
} = _ref;
|
|
18560
18530
|
const filterModelSearch = getSearchParamsFromFilterModel(filterModel);
|
|
18561
18531
|
const sortModelSearch = getSearchParamsFromSorting(sortModel);
|
|
18562
18532
|
const paginationModelSearch = getSearchParamsFromPagination(paginationModel);
|
|
@@ -18611,14 +18581,14 @@ const getModelsParsedOrUpdateLocalStorage = (search, columns, historyReplace, in
|
|
|
18611
18581
|
pinnedColumnsModel
|
|
18612
18582
|
};
|
|
18613
18583
|
};
|
|
18614
|
-
const updateUrl = (
|
|
18584
|
+
const updateUrl = (_ref2, search, historyReplace, columns) => {
|
|
18615
18585
|
let {
|
|
18616
18586
|
filterModel,
|
|
18617
18587
|
sortModel,
|
|
18618
18588
|
paginationModel,
|
|
18619
18589
|
columnsModel: columnsVisibilityModel,
|
|
18620
18590
|
pinnedColumnsModel
|
|
18621
|
-
} =
|
|
18591
|
+
} = _ref2;
|
|
18622
18592
|
const newSearch = getFinalSearch({
|
|
18623
18593
|
search,
|
|
18624
18594
|
filterModel,
|
|
@@ -18638,17 +18608,17 @@ const updateUrl = (_ref4, search, historyReplace, columns) => {
|
|
|
18638
18608
|
// do not use it for equivalence (e.g. with value `3` and undefined we
|
|
18639
18609
|
// will get 0).
|
|
18640
18610
|
const compareFilters = (firstFilter, secondFilter) => {
|
|
18641
|
-
if (firstFilter.
|
|
18611
|
+
if (firstFilter.field < secondFilter.field) {
|
|
18642
18612
|
return -1;
|
|
18643
|
-
} else if (firstFilter.
|
|
18613
|
+
} else if (firstFilter.field > secondFilter.field) {
|
|
18644
18614
|
return 1;
|
|
18645
18615
|
}
|
|
18646
|
-
if (firstFilter.
|
|
18616
|
+
if (firstFilter.operator === undefined || secondFilter.operator === undefined) {
|
|
18647
18617
|
return 0;
|
|
18648
18618
|
}
|
|
18649
|
-
if (firstFilter.
|
|
18619
|
+
if (firstFilter.operator < secondFilter.operator) {
|
|
18650
18620
|
return -1;
|
|
18651
|
-
} else if (firstFilter.
|
|
18621
|
+
} else if (firstFilter.operator > secondFilter.operator) {
|
|
18652
18622
|
return 1;
|
|
18653
18623
|
}
|
|
18654
18624
|
if (firstFilter.value < secondFilter.value) {
|
|
@@ -18659,18 +18629,18 @@ const compareFilters = (firstFilter, secondFilter) => {
|
|
|
18659
18629
|
return 0;
|
|
18660
18630
|
};
|
|
18661
18631
|
const areFiltersEquivalent = (firstFilter, secondFilter) => {
|
|
18662
|
-
return firstFilter.
|
|
18632
|
+
return firstFilter.field === secondFilter.field && firstFilter.operator === secondFilter.operator && firstFilter.value === secondFilter.value;
|
|
18663
18633
|
};
|
|
18664
18634
|
const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
18665
18635
|
const {
|
|
18666
18636
|
items,
|
|
18667
|
-
|
|
18637
|
+
logicOperator
|
|
18668
18638
|
} = filterModel;
|
|
18669
18639
|
const {
|
|
18670
18640
|
items: itemsToMatch,
|
|
18671
|
-
|
|
18641
|
+
logicOperator: logicOperatorToMatch
|
|
18672
18642
|
} = filterModelToMatch;
|
|
18673
|
-
if (
|
|
18643
|
+
if (logicOperator !== logicOperatorToMatch) {
|
|
18674
18644
|
return false;
|
|
18675
18645
|
}
|
|
18676
18646
|
if (items.length !== itemsToMatch.length) {
|
|
@@ -18683,7 +18653,7 @@ const areFilterModelsEquivalent = (filterModel, filterModelToMatch) => {
|
|
|
18683
18653
|
const filterToCompare = itemsToMatch[i];
|
|
18684
18654
|
|
|
18685
18655
|
// compareFilters return 0 if and only if the filters have the same
|
|
18686
|
-
//
|
|
18656
|
+
// field, operator, and value
|
|
18687
18657
|
if (!areFiltersEquivalent(filter, filterToCompare)) {
|
|
18688
18658
|
return false;
|
|
18689
18659
|
}
|
|
@@ -24494,16 +24464,16 @@ const getRole = (config, dateFormat) => {
|
|
|
24494
24464
|
}).join('\n');
|
|
24495
24465
|
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.
|
|
24496
24466
|
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.
|
|
24497
|
-
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "
|
|
24498
|
-
- "
|
|
24499
|
-
- "items": a list of conditions, each is an object with exactly the three keys "
|
|
24500
|
-
- "
|
|
24467
|
+
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "logicOperator" and "items":
|
|
24468
|
+
- "logicOperator": the logical operator, only "and" or "or" are allowed. If there is only one condition in the "items", use "and".
|
|
24469
|
+
- "items": a list of conditions, each is an object with exactly the three keys "field", "operator" and "value":
|
|
24470
|
+
- "field": the column name, must be one of ${columns}
|
|
24501
24471
|
- "value":
|
|
24502
|
-
- this can be skipped if the "
|
|
24503
|
-
- a list of multiple values if the "
|
|
24472
|
+
- this can be skipped if the "operator" is either "isEmpty" or "isNotEmpty"
|
|
24473
|
+
- a list of multiple values if the "operator" ends with "AnyOf"
|
|
24504
24474
|
- otherwise, it's a single value represented as a string: "true" instead of true, "false" instead of false, "0.6" instead of 0.6.
|
|
24505
24475
|
For "date" data type, use ${dateFormat}. If relative date is input, convert to the actual date given today is ${today}.
|
|
24506
|
-
- "
|
|
24476
|
+
- "operator": the comparison operator, accepted values depend on the data type of the column
|
|
24507
24477
|
${operators}
|
|
24508
24478
|
|
|
24509
24479
|
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:
|
|
@@ -24540,10 +24510,10 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24540
24510
|
nlpFilterConfig,
|
|
24541
24511
|
onFilterModelChange,
|
|
24542
24512
|
dateFormat = 'yyyy-mm-dd',
|
|
24543
|
-
defaultModel = 'gpt-4-
|
|
24513
|
+
defaultModel = 'gpt-4-1106-preview',
|
|
24544
24514
|
defaultFilter = {
|
|
24545
24515
|
items: [],
|
|
24546
|
-
|
|
24516
|
+
logicOperator: 'and'
|
|
24547
24517
|
},
|
|
24548
24518
|
disablePower = false,
|
|
24549
24519
|
localeText
|
|
@@ -24621,7 +24591,7 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24621
24591
|
value: prompt
|
|
24622
24592
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
24623
24593
|
variant: "primary",
|
|
24624
|
-
"
|
|
24594
|
+
"aria-label": buttonAriaLabel,
|
|
24625
24595
|
type: "submit",
|
|
24626
24596
|
isLoading: isLoading
|
|
24627
24597
|
}, buttonText)), !disablePower && /*#__PURE__*/React__default.createElement(Tooltip, null, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, /*#__PURE__*/React__default.createElement(Switch, {
|
|
@@ -24682,7 +24652,7 @@ const Toolbar$2 = props => {
|
|
|
24682
24652
|
let {
|
|
24683
24653
|
apiRef
|
|
24684
24654
|
} = _ref;
|
|
24685
|
-
return
|
|
24655
|
+
return gridExpandedSortedRowIdsSelector(apiRef);
|
|
24686
24656
|
}
|
|
24687
24657
|
},
|
|
24688
24658
|
printOptions: {
|
|
@@ -26914,12 +26884,10 @@ const ServerSideControlledPagination = _ref3 => {
|
|
|
26914
26884
|
selectionStatus,
|
|
26915
26885
|
displaySelection,
|
|
26916
26886
|
displayPagination,
|
|
26917
|
-
|
|
26918
|
-
|
|
26919
|
-
|
|
26920
|
-
onPageSizeChange,
|
|
26887
|
+
paginationModel,
|
|
26888
|
+
onPaginationModelChange,
|
|
26889
|
+
pageSizeOptions,
|
|
26921
26890
|
displayRowsPerPage,
|
|
26922
|
-
rowsPerPageOptions,
|
|
26923
26891
|
paginationProps,
|
|
26924
26892
|
rowCount
|
|
26925
26893
|
} = _ref3;
|
|
@@ -26938,13 +26906,17 @@ const ServerSideControlledPagination = _ref3 => {
|
|
|
26938
26906
|
}, totalRowsLabel) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$1({
|
|
26939
26907
|
component: "div",
|
|
26940
26908
|
count: totalNumberOfRowsInTable,
|
|
26941
|
-
page: page,
|
|
26942
|
-
onPageChange: (event,
|
|
26943
|
-
|
|
26944
|
-
|
|
26945
|
-
|
|
26946
|
-
|
|
26947
|
-
|
|
26909
|
+
page: paginationModel.page,
|
|
26910
|
+
onPageChange: (event, page) => onPaginationModelChange({
|
|
26911
|
+
page,
|
|
26912
|
+
pageSize: paginationModel.pageSize
|
|
26913
|
+
}),
|
|
26914
|
+
rowsPerPage: paginationModel.pageSize,
|
|
26915
|
+
onRowsPerPageChange: event => onPaginationModelChange({
|
|
26916
|
+
page: paginationModel.page,
|
|
26917
|
+
pageSize: parseInt(event.target.value, 10)
|
|
26918
|
+
}),
|
|
26919
|
+
rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
|
|
26948
26920
|
}, paginationProps)) : null);
|
|
26949
26921
|
};
|
|
26950
26922
|
|
|
@@ -26970,11 +26942,9 @@ const ControlledPagination = _ref3 => {
|
|
|
26970
26942
|
displayPagination = false,
|
|
26971
26943
|
selectionStatus,
|
|
26972
26944
|
apiRef,
|
|
26973
|
-
|
|
26974
|
-
|
|
26975
|
-
|
|
26976
|
-
onPageSizeChange,
|
|
26977
|
-
rowsPerPageOptions,
|
|
26945
|
+
paginationModel,
|
|
26946
|
+
onPaginationModelChange,
|
|
26947
|
+
pageSizeOptions,
|
|
26978
26948
|
isRowSelectable,
|
|
26979
26949
|
paginationProps
|
|
26980
26950
|
} = _ref3;
|
|
@@ -27004,17 +26974,25 @@ const ControlledPagination = _ref3 => {
|
|
|
27004
26974
|
}, `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$1({
|
|
27005
26975
|
component: "div",
|
|
27006
26976
|
count: numberOfFilteredRowsInTable,
|
|
27007
|
-
page: page,
|
|
27008
|
-
onPageChange: (event,
|
|
27009
|
-
|
|
26977
|
+
page: paginationModel.page,
|
|
26978
|
+
onPageChange: (event, page) => {
|
|
26979
|
+
onPaginationModelChange({
|
|
26980
|
+
page,
|
|
26981
|
+
pageSize: paginationModel.pageSize
|
|
26982
|
+
});
|
|
26983
|
+
},
|
|
26984
|
+
rowsPerPage: paginationModel.pageSize,
|
|
27010
26985
|
onRowsPerPageChange: event => {
|
|
27011
|
-
|
|
26986
|
+
onPaginationModelChange({
|
|
26987
|
+
page: paginationModel.page,
|
|
26988
|
+
pageSize: parseInt(event.target.value, 10)
|
|
26989
|
+
});
|
|
27012
26990
|
},
|
|
27013
|
-
rowsPerPageOptions: displayRowsPerPage ?
|
|
26991
|
+
rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
|
|
27014
26992
|
}, paginationProps)) : null);
|
|
27015
26993
|
};
|
|
27016
26994
|
|
|
27017
|
-
const _excluded$3 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "
|
|
26995
|
+
const _excluded$3 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "paginationModel", "onPaginationModelChange", "pageSizeOptions", "paginationProps", "paginationMode", "rowCount"];
|
|
27018
26996
|
const ToolbarWrapper = _ref => {
|
|
27019
26997
|
let {
|
|
27020
26998
|
hideToolbar,
|
|
@@ -27026,11 +27004,9 @@ const ToolbarWrapper = _ref => {
|
|
|
27026
27004
|
selectionStatus,
|
|
27027
27005
|
apiRef,
|
|
27028
27006
|
isRowSelectable,
|
|
27029
|
-
|
|
27030
|
-
|
|
27031
|
-
|
|
27032
|
-
onPageSizeChange,
|
|
27033
|
-
rowsPerPageOptions,
|
|
27007
|
+
paginationModel,
|
|
27008
|
+
onPaginationModelChange,
|
|
27009
|
+
pageSizeOptions,
|
|
27034
27010
|
paginationProps,
|
|
27035
27011
|
paginationMode = 'client',
|
|
27036
27012
|
rowCount
|
|
@@ -27044,11 +27020,9 @@ const ToolbarWrapper = _ref => {
|
|
|
27044
27020
|
displayRowsPerPage: false,
|
|
27045
27021
|
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
27046
27022
|
selectionStatus: selectionStatus.current,
|
|
27047
|
-
|
|
27048
|
-
|
|
27049
|
-
|
|
27050
|
-
onPageSizeChange: onPageSizeChange,
|
|
27051
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27023
|
+
paginationModel: paginationModel,
|
|
27024
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27025
|
+
pageSizeOptions: pageSizeOptions,
|
|
27052
27026
|
paginationProps: paginationProps,
|
|
27053
27027
|
rowCount: rowCount
|
|
27054
27028
|
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
@@ -27058,30 +27032,26 @@ const ToolbarWrapper = _ref => {
|
|
|
27058
27032
|
selectionStatus: selectionStatus.current,
|
|
27059
27033
|
apiRef: apiRef,
|
|
27060
27034
|
isRowSelectable: isRowSelectable,
|
|
27061
|
-
|
|
27062
|
-
|
|
27063
|
-
|
|
27064
|
-
onPageSizeChange: onPageSizeChange,
|
|
27065
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27035
|
+
paginationModel: paginationModel,
|
|
27036
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27037
|
+
pageSizeOptions: pageSizeOptions,
|
|
27066
27038
|
paginationProps: paginationProps
|
|
27067
27039
|
}) : null);
|
|
27068
27040
|
};
|
|
27069
27041
|
|
|
27070
27042
|
const useControlledDatagridState = _ref => {
|
|
27071
|
-
var _initialState$paginat, _initialState$paginat2;
|
|
27043
|
+
var _ref2, _ref3, _propsPaginationModel, _initialState$paginat, _initialState$paginat2, _pageSizeOptions$, _ref4, _propsPaginationModel2, _initialState$paginat3, _initialState$paginat4;
|
|
27072
27044
|
let {
|
|
27073
27045
|
initialState,
|
|
27074
|
-
|
|
27046
|
+
pageSizeOptions,
|
|
27075
27047
|
propsColumnVisibilityModel,
|
|
27076
27048
|
propsFilterModel,
|
|
27077
27049
|
propsOnColumnVisibilityModelChange,
|
|
27078
27050
|
propsOnFilterModelChange,
|
|
27079
|
-
|
|
27080
|
-
propsOnPageSizeChange,
|
|
27051
|
+
propsOnPaginationModelChange,
|
|
27081
27052
|
propsOnPinnedColumnsChange,
|
|
27082
27053
|
propsOnSortModelChange,
|
|
27083
|
-
|
|
27084
|
-
propsPageSize,
|
|
27054
|
+
propsPaginationModel,
|
|
27085
27055
|
propsPinnedColumns,
|
|
27086
27056
|
propsSortModel
|
|
27087
27057
|
} = _ref;
|
|
@@ -27129,33 +27099,22 @@ const useControlledDatagridState = _ref => {
|
|
|
27129
27099
|
setSortModel(model);
|
|
27130
27100
|
}
|
|
27131
27101
|
};
|
|
27132
|
-
const [
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
}
|
|
27140
|
-
};
|
|
27141
|
-
useEffect(() => {
|
|
27142
|
-
if (propsPage || propsPage === 0) {
|
|
27143
|
-
setPage(propsPage);
|
|
27144
|
-
}
|
|
27145
|
-
}, [propsPage]);
|
|
27146
|
-
const onPageSizeChange = pageSize => {
|
|
27147
|
-
onPageChange(0);
|
|
27148
|
-
if (propsOnPageSizeChange) {
|
|
27149
|
-
propsOnPageSizeChange(pageSize, undefined);
|
|
27102
|
+
const [paginationModel, setPaginationModel] = useState({
|
|
27103
|
+
pageSize: (_ref2 = (_ref3 = (_propsPaginationModel = propsPaginationModel === null || propsPaginationModel === void 0 ? void 0 : propsPaginationModel.pageSize) !== null && _propsPaginationModel !== void 0 ? _propsPaginationModel : initialState === null || initialState === void 0 ? void 0 : (_initialState$paginat = initialState.pagination) === null || _initialState$paginat === void 0 ? void 0 : (_initialState$paginat2 = _initialState$paginat.paginationModel) === null || _initialState$paginat2 === void 0 ? void 0 : _initialState$paginat2.pageSize) !== null && _ref3 !== void 0 ? _ref3 : typeof (pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions[0]) === 'number' ? pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : pageSizeOptions[0] : pageSizeOptions === null || pageSizeOptions === void 0 ? void 0 : (_pageSizeOptions$ = pageSizeOptions[0]) === null || _pageSizeOptions$ === void 0 ? void 0 : _pageSizeOptions$.value) !== null && _ref2 !== void 0 ? _ref2 : 25,
|
|
27104
|
+
page: (_ref4 = (_propsPaginationModel2 = propsPaginationModel === null || propsPaginationModel === void 0 ? void 0 : propsPaginationModel.page) !== null && _propsPaginationModel2 !== void 0 ? _propsPaginationModel2 : initialState === null || initialState === void 0 ? void 0 : (_initialState$paginat3 = initialState.pagination) === null || _initialState$paginat3 === void 0 ? void 0 : (_initialState$paginat4 = _initialState$paginat3.paginationModel) === null || _initialState$paginat4 === void 0 ? void 0 : _initialState$paginat4.page) !== null && _ref4 !== void 0 ? _ref4 : 0
|
|
27105
|
+
});
|
|
27106
|
+
const onPaginationModelChange = (model, details) => {
|
|
27107
|
+
if (propsOnPaginationModelChange) {
|
|
27108
|
+
propsOnPaginationModelChange(model, details);
|
|
27150
27109
|
} else {
|
|
27151
|
-
|
|
27110
|
+
setPaginationModel(model);
|
|
27152
27111
|
}
|
|
27153
27112
|
};
|
|
27154
27113
|
useEffect(() => {
|
|
27155
|
-
if (
|
|
27156
|
-
|
|
27114
|
+
if (propsPaginationModel) {
|
|
27115
|
+
setPaginationModel(propsPaginationModel);
|
|
27157
27116
|
}
|
|
27158
|
-
}, [
|
|
27117
|
+
}, [propsPaginationModel]);
|
|
27159
27118
|
return {
|
|
27160
27119
|
filterModel,
|
|
27161
27120
|
onFilterModelChange,
|
|
@@ -27165,14 +27124,12 @@ const useControlledDatagridState = _ref => {
|
|
|
27165
27124
|
onPinnedColumnsChange,
|
|
27166
27125
|
sortModel,
|
|
27167
27126
|
onSortModelChange,
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
onPageChange,
|
|
27171
|
-
onPageSizeChange
|
|
27127
|
+
paginationModel,
|
|
27128
|
+
onPaginationModelChange
|
|
27172
27129
|
};
|
|
27173
27130
|
};
|
|
27174
27131
|
|
|
27175
|
-
const _excluded$2 = ["apiRef", "autoHeight", "className", "
|
|
27132
|
+
const _excluded$2 = ["apiRef", "autoHeight", "className", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "rowSelectionModel", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "rows", "pageSizeOptions", "sx", "theme", "paginationMode", "rowCount"];
|
|
27176
27133
|
const COMPONENT_NAME$2 = 'DataGrid';
|
|
27177
27134
|
const CLASSNAME$2 = 'redsift-datagrid';
|
|
27178
27135
|
const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -27181,33 +27138,30 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27181
27138
|
apiRef: propsApiRef,
|
|
27182
27139
|
autoHeight,
|
|
27183
27140
|
className,
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
componentsProps,
|
|
27141
|
+
slots,
|
|
27142
|
+
slotProps,
|
|
27187
27143
|
filterModel: propsFilterModel,
|
|
27188
27144
|
columnVisibilityModel: propsColumnVisibilityModel,
|
|
27189
27145
|
pinnedColumns: propsPinnedColumns,
|
|
27190
27146
|
sortModel: propsSortModel,
|
|
27147
|
+
paginationModel: propsPaginationModel,
|
|
27191
27148
|
height: propsHeight,
|
|
27192
27149
|
hideToolbar,
|
|
27193
27150
|
initialState,
|
|
27194
27151
|
isRowSelectable,
|
|
27195
27152
|
license = process.env.MUI_LICENSE_KEY,
|
|
27196
27153
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27197
|
-
|
|
27198
|
-
|
|
27154
|
+
rowSelectionModel: propsRowSelectionModel,
|
|
27155
|
+
onPaginationModelChange: propsOnPaginationModelChange,
|
|
27156
|
+
onRowSelectionModelChange: propsOnRowSelectionModelChange,
|
|
27199
27157
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27200
27158
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27201
27159
|
onSortModelChange: propsOnSortModelChange,
|
|
27202
|
-
selectionModel: propsSelectionModel,
|
|
27203
|
-
onSelectionModelChange: propsOnSelectionModelChange,
|
|
27204
|
-
page: propsPage,
|
|
27205
|
-
pageSize: propsPageSize,
|
|
27206
27160
|
pagination,
|
|
27207
27161
|
paginationPlacement = 'both',
|
|
27208
27162
|
paginationProps,
|
|
27209
27163
|
rows,
|
|
27210
|
-
|
|
27164
|
+
pageSizeOptions,
|
|
27211
27165
|
sx,
|
|
27212
27166
|
theme: propsTheme,
|
|
27213
27167
|
paginationMode = 'client',
|
|
@@ -27217,7 +27171,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27217
27171
|
const theme = useTheme$4(propsTheme);
|
|
27218
27172
|
const _apiRef = useGridApiRef();
|
|
27219
27173
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
27220
|
-
const RenderedToolbar =
|
|
27174
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar$2;
|
|
27221
27175
|
LicenseInfo.setLicenseKey(license);
|
|
27222
27176
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
27223
27177
|
const {
|
|
@@ -27225,56 +27179,52 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27225
27179
|
filterModel,
|
|
27226
27180
|
onColumnVisibilityModelChange,
|
|
27227
27181
|
onFilterModelChange,
|
|
27228
|
-
|
|
27229
|
-
onPageSizeChange,
|
|
27182
|
+
onPaginationModelChange,
|
|
27230
27183
|
onPinnedColumnsChange,
|
|
27231
27184
|
onSortModelChange,
|
|
27232
|
-
|
|
27233
|
-
pageSize,
|
|
27185
|
+
paginationModel,
|
|
27234
27186
|
pinnedColumns,
|
|
27235
27187
|
sortModel
|
|
27236
27188
|
} = useControlledDatagridState({
|
|
27237
27189
|
initialState,
|
|
27238
|
-
|
|
27190
|
+
pageSizeOptions,
|
|
27239
27191
|
propsColumnVisibilityModel,
|
|
27240
27192
|
propsFilterModel,
|
|
27241
27193
|
propsOnColumnVisibilityModelChange,
|
|
27242
27194
|
propsOnFilterModelChange,
|
|
27243
27195
|
propsOnPinnedColumnsChange,
|
|
27244
27196
|
propsOnSortModelChange,
|
|
27245
|
-
|
|
27246
|
-
propsPageSize,
|
|
27197
|
+
propsPaginationModel,
|
|
27247
27198
|
propsPinnedColumns,
|
|
27248
27199
|
propsSortModel,
|
|
27249
|
-
|
|
27250
|
-
propsOnPageSizeChange
|
|
27200
|
+
propsOnPaginationModelChange
|
|
27251
27201
|
});
|
|
27252
|
-
const [
|
|
27202
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
27253
27203
|
useEffect(() => {
|
|
27254
|
-
|
|
27255
|
-
}, [
|
|
27256
|
-
const
|
|
27257
|
-
if (
|
|
27258
|
-
|
|
27204
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
27205
|
+
}, [propsRowSelectionModel]);
|
|
27206
|
+
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
27207
|
+
if (propsOnRowSelectionModelChange) {
|
|
27208
|
+
propsOnRowSelectionModelChange(selectionModel, details);
|
|
27259
27209
|
} else {
|
|
27260
|
-
|
|
27210
|
+
setRowSelectionModel(selectionModel);
|
|
27261
27211
|
}
|
|
27262
27212
|
};
|
|
27263
27213
|
const selectionStatus = useRef({
|
|
27264
27214
|
type: 'none',
|
|
27265
27215
|
numberOfSelectedRows: 0,
|
|
27266
27216
|
numberOfSelectedRowsInPage: 0,
|
|
27267
|
-
page,
|
|
27268
|
-
pageSize
|
|
27217
|
+
page: paginationModel.page,
|
|
27218
|
+
pageSize: paginationModel.pageSize
|
|
27269
27219
|
});
|
|
27270
27220
|
|
|
27271
27221
|
// in server-side pagination we want to update the selection status
|
|
27272
27222
|
// every time we navigate between pages, resize our page or select something
|
|
27273
27223
|
useEffect(() => {
|
|
27274
27224
|
if (paginationMode == 'server') {
|
|
27275
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
27225
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatus, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
27276
27226
|
}
|
|
27277
|
-
}, [
|
|
27227
|
+
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize]);
|
|
27278
27228
|
if (!Array.isArray(rows)) {
|
|
27279
27229
|
return null;
|
|
27280
27230
|
}
|
|
@@ -27305,57 +27255,54 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27305
27255
|
apiRef: apiRef,
|
|
27306
27256
|
autoHeight: autoHeight,
|
|
27307
27257
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
27308
|
-
|
|
27309
|
-
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27313
|
-
|
|
27314
|
-
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27258
|
+
slots: _objectSpread2(_objectSpread2({
|
|
27259
|
+
baseButton: BaseButton,
|
|
27260
|
+
baseCheckbox: BaseCheckbox,
|
|
27261
|
+
// baseTextField,
|
|
27262
|
+
basePopper: BasePopper,
|
|
27263
|
+
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27315
27264
|
displayName: "ColumnFilteredIcon"
|
|
27316
27265
|
})),
|
|
27317
|
-
|
|
27266
|
+
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27318
27267
|
displayName: "ColumnSelectorIcon"
|
|
27319
27268
|
})),
|
|
27320
|
-
|
|
27269
|
+
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27321
27270
|
displayName: "ColumnSortedAscendingIcon"
|
|
27322
27271
|
})),
|
|
27323
|
-
|
|
27272
|
+
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27324
27273
|
displayName: "ColumnSortedDescendingIcon"
|
|
27325
27274
|
})),
|
|
27326
|
-
|
|
27275
|
+
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27327
27276
|
displayName: "DensityCompactIcon"
|
|
27328
27277
|
})),
|
|
27329
|
-
|
|
27278
|
+
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27330
27279
|
displayName: "DensityStandardIcon"
|
|
27331
27280
|
})),
|
|
27332
|
-
|
|
27281
|
+
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27333
27282
|
displayName: "DensityComfortableIcon"
|
|
27334
27283
|
})),
|
|
27335
|
-
|
|
27284
|
+
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27336
27285
|
displayName: "DetailPanelCollapseIcon"
|
|
27337
27286
|
})),
|
|
27338
|
-
|
|
27287
|
+
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27339
27288
|
displayName: "DetailPanelExpandIcon"
|
|
27340
27289
|
})),
|
|
27341
|
-
|
|
27290
|
+
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27342
27291
|
displayName: "ExportIcon"
|
|
27343
27292
|
})),
|
|
27344
|
-
|
|
27293
|
+
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
27345
27294
|
displayName: "OpenFilterButtonIcon"
|
|
27346
27295
|
}, props))
|
|
27347
|
-
},
|
|
27348
|
-
|
|
27349
|
-
|
|
27296
|
+
}, slots), {}, {
|
|
27297
|
+
toolbar: ToolbarWrapper,
|
|
27298
|
+
pagination: props => pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
27350
27299
|
displaySelection: false,
|
|
27351
27300
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
27352
27301
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
27353
27302
|
selectionStatus: selectionStatus.current,
|
|
27354
|
-
|
|
27355
|
-
|
|
27356
|
-
|
|
27357
|
-
onPageSizeChange: onPageSizeChange,
|
|
27358
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27303
|
+
paginationModel: paginationModel,
|
|
27304
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27305
|
+
pageSizeOptions: pageSizeOptions,
|
|
27359
27306
|
paginationProps: paginationProps,
|
|
27360
27307
|
paginationMode: paginationMode,
|
|
27361
27308
|
rowCount: rowCount
|
|
@@ -27366,16 +27313,14 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27366
27313
|
selectionStatus: selectionStatus.current,
|
|
27367
27314
|
apiRef: apiRef,
|
|
27368
27315
|
isRowSelectable: isRowSelectable,
|
|
27369
|
-
|
|
27370
|
-
|
|
27371
|
-
|
|
27372
|
-
onPageSizeChange: onPageSizeChange,
|
|
27373
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27316
|
+
paginationModel: paginationModel,
|
|
27317
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27318
|
+
pageSizeOptions: pageSizeOptions,
|
|
27374
27319
|
paginationProps: paginationProps,
|
|
27375
27320
|
paginationMode: paginationMode
|
|
27376
27321
|
})) : null
|
|
27377
27322
|
}),
|
|
27378
|
-
|
|
27323
|
+
slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
|
|
27379
27324
|
toolbar: _objectSpread2({
|
|
27380
27325
|
hideToolbar,
|
|
27381
27326
|
RenderedToolbar,
|
|
@@ -27386,15 +27331,13 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27386
27331
|
selectionStatus,
|
|
27387
27332
|
apiRef,
|
|
27388
27333
|
isRowSelectable,
|
|
27389
|
-
|
|
27390
|
-
|
|
27391
|
-
|
|
27392
|
-
onPageSizeChange,
|
|
27393
|
-
rowsPerPageOptions,
|
|
27334
|
+
paginationModel,
|
|
27335
|
+
onPaginationModelChange,
|
|
27336
|
+
pageSizeOptions,
|
|
27394
27337
|
paginationProps,
|
|
27395
27338
|
paginationMode,
|
|
27396
27339
|
rowCount
|
|
27397
|
-
},
|
|
27340
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
|
|
27398
27341
|
}),
|
|
27399
27342
|
filterModel: filterModel,
|
|
27400
27343
|
columnVisibilityModel: columnVisibilityModel,
|
|
@@ -27410,13 +27353,11 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27410
27353
|
paginationMode: paginationMode,
|
|
27411
27354
|
keepNonExistentRowsSelected: paginationMode == 'server',
|
|
27412
27355
|
rows: rows,
|
|
27413
|
-
|
|
27414
|
-
|
|
27415
|
-
|
|
27416
|
-
|
|
27417
|
-
|
|
27418
|
-
selectionModel: selectionModel,
|
|
27419
|
-
onSelectionModelChange: (newSelectionModel, details) => {
|
|
27356
|
+
pageSizeOptions: pageSizeOptions,
|
|
27357
|
+
paginationModel: paginationModel,
|
|
27358
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27359
|
+
rowSelectionModel: rowSelectionModel,
|
|
27360
|
+
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
27420
27361
|
if (pagination && paginationMode != 'server') {
|
|
27421
27362
|
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
27422
27363
|
let {
|
|
@@ -27474,7 +27415,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27474
27415
|
};
|
|
27475
27416
|
}
|
|
27476
27417
|
}
|
|
27477
|
-
|
|
27418
|
+
onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
|
|
27478
27419
|
},
|
|
27479
27420
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
27480
27421
|
'.MuiDataGrid-columnHeaders': {
|
|
@@ -27491,8 +27432,6 @@ DataGrid.className = CLASSNAME$2;
|
|
|
27491
27432
|
DataGrid.displayName = COMPONENT_NAME$2;
|
|
27492
27433
|
|
|
27493
27434
|
// Get and Set data from LocalStorage WITHOUT useState
|
|
27494
|
-
|
|
27495
|
-
// triggering a state update and consecutive re-render
|
|
27496
27435
|
const useFetchState = (defaultValue, key) => {
|
|
27497
27436
|
let stickyValue = null;
|
|
27498
27437
|
try {
|
|
@@ -27500,16 +27439,7 @@ const useFetchState = (defaultValue, key) => {
|
|
|
27500
27439
|
} catch (e) {
|
|
27501
27440
|
console.error('StatefulDataGrid: error getting item from local storage: ', e);
|
|
27502
27441
|
}
|
|
27503
|
-
|
|
27504
|
-
|
|
27505
|
-
// TODO: temporary workaround to avoid clashes when someone had sorting on the now-removed screenshot field (renamed to num_annotations)
|
|
27506
|
-
// 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
|
|
27507
|
-
if (parsedValue instanceof Array) {
|
|
27508
|
-
const fields = (parsedValue || []).map(item => item.field);
|
|
27509
|
-
if (fields.includes('screenshot') || fields.includes('diffs')) {
|
|
27510
|
-
parsedValue = defaultValue;
|
|
27511
|
-
}
|
|
27512
|
-
}
|
|
27442
|
+
const parsedValue = stickyValue !== null && stickyValue !== undefined && stickyValue !== 'undefined' ? JSON.parse(stickyValue) : defaultValue;
|
|
27513
27443
|
const updateValue = useCallback(value => {
|
|
27514
27444
|
try {
|
|
27515
27445
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -27520,6 +27450,8 @@ const useFetchState = (defaultValue, key) => {
|
|
|
27520
27450
|
return [parsedValue, updateValue];
|
|
27521
27451
|
};
|
|
27522
27452
|
|
|
27453
|
+
// import useLocalStorage from './useLocalStorage';
|
|
27454
|
+
|
|
27523
27455
|
const useTableStates = (id, version) => {
|
|
27524
27456
|
const [paginationModel, setPaginationModel] = useFetchState('', buildStorageKey({
|
|
27525
27457
|
id,
|
|
@@ -27576,8 +27508,7 @@ const useStatefulTable = props => {
|
|
|
27576
27508
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27577
27509
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27578
27510
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27579
|
-
|
|
27580
|
-
onPageSizeChange: propsOnPageSizeChange,
|
|
27511
|
+
onPaginationModelChange: propsOnPaginationModelChange,
|
|
27581
27512
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27582
27513
|
onSortModelChange: propsOnSortModelChange,
|
|
27583
27514
|
useRouter,
|
|
@@ -27639,7 +27570,6 @@ const useStatefulTable = props => {
|
|
|
27639
27570
|
column.width = dimensionModel[column.field] || column.width || 100;
|
|
27640
27571
|
return column;
|
|
27641
27572
|
}), [propsColumns, dimensionModel]);
|
|
27642
|
-
|
|
27643
27573
|
/** Add resetPage method to apiRef. */
|
|
27644
27574
|
apiRef.current.resetPage = () => {
|
|
27645
27575
|
apiRef.current.setPage(0);
|
|
@@ -27650,7 +27580,7 @@ const useStatefulTable = props => {
|
|
|
27650
27580
|
onFilterModelChange: (model, details) => {
|
|
27651
27581
|
const filterModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
27652
27582
|
items: model.items.map(item => {
|
|
27653
|
-
const column = apiRef.current.getColumn(item.
|
|
27583
|
+
const column = apiRef.current.getColumn(item.field);
|
|
27654
27584
|
item.type = column.type || 'string';
|
|
27655
27585
|
return item;
|
|
27656
27586
|
})
|
|
@@ -27687,33 +27617,16 @@ const useStatefulTable = props => {
|
|
|
27687
27617
|
}, search, historyReplace, columns);
|
|
27688
27618
|
},
|
|
27689
27619
|
pinnedColumns: pinnedColumnsModel,
|
|
27690
|
-
|
|
27691
|
-
|
|
27692
|
-
|
|
27693
|
-
|
|
27694
|
-
|
|
27695
|
-
|
|
27696
|
-
filterModel: filterParsed,
|
|
27697
|
-
sortModel: sortModelParsed,
|
|
27698
|
-
paginationModel: {
|
|
27699
|
-
page,
|
|
27700
|
-
pageSize: paginationModelParsed.pageSize,
|
|
27701
|
-
direction
|
|
27702
|
-
},
|
|
27703
|
-
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
27704
|
-
pinnedColumnsModel: pinnedColumnsModel
|
|
27705
|
-
}, search, historyReplace, columns);
|
|
27706
|
-
},
|
|
27707
|
-
onPageSizeChange: (pageSize, details) => {
|
|
27708
|
-
propsOnPageSizeChange === null || propsOnPageSizeChange === void 0 ? void 0 : propsOnPageSizeChange(pageSize, details);
|
|
27620
|
+
paginationModel: paginationModelParsed,
|
|
27621
|
+
onPaginationModelChange: (model, details) => {
|
|
27622
|
+
const paginationModel = _objectSpread2(_objectSpread2({}, model), {}, {
|
|
27623
|
+
direction: paginationModelParsed.page < model.page ? 'next' : 'back'
|
|
27624
|
+
});
|
|
27625
|
+
propsOnPaginationModelChange === null || propsOnPaginationModelChange === void 0 ? void 0 : propsOnPaginationModelChange(paginationModel, details);
|
|
27709
27626
|
updateUrl({
|
|
27710
27627
|
filterModel: filterParsed,
|
|
27711
27628
|
sortModel: sortModelParsed,
|
|
27712
|
-
paginationModel:
|
|
27713
|
-
page: paginationModelParsed.page,
|
|
27714
|
-
pageSize,
|
|
27715
|
-
direction: paginationModelParsed.direction
|
|
27716
|
-
},
|
|
27629
|
+
paginationModel: paginationModel,
|
|
27717
27630
|
columnsModel: apiRef.current.state.columns.columnVisibilityModel,
|
|
27718
27631
|
pinnedColumnsModel: pinnedColumnsModel
|
|
27719
27632
|
}, search, historyReplace, columns);
|
|
@@ -27739,7 +27652,7 @@ const useStatefulTable = props => {
|
|
|
27739
27652
|
};
|
|
27740
27653
|
};
|
|
27741
27654
|
|
|
27742
|
-
const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "
|
|
27655
|
+
const _excluded$1 = ["apiRef", "autoHeight", "className", "columns", "slots", "slotProps", "filterModel", "columnVisibilityModel", "pinnedColumns", "sortModel", "paginationModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "localStorageVersion", "onFilterModelChange", "rowSelectionModel", "onColumnWidthChange", "onPaginationModelChange", "onRowSelectionModelChange", "onColumnVisibilityModelChange", "onPinnedColumnsChange", "onSortModelChange", "pagination", "paginationPlacement", "paginationProps", "rows", "pageSizeOptions", "sx", "theme", "useRouter", "paginationMode", "rowCount"];
|
|
27743
27656
|
const COMPONENT_NAME$1 = 'DataGrid';
|
|
27744
27657
|
const CLASSNAME$1 = 'redsift-datagrid';
|
|
27745
27658
|
const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
@@ -27749,15 +27662,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27749
27662
|
autoHeight,
|
|
27750
27663
|
className,
|
|
27751
27664
|
columns,
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
componentsProps,
|
|
27665
|
+
slots,
|
|
27666
|
+
slotProps,
|
|
27755
27667
|
filterModel: propsFilterModel,
|
|
27756
27668
|
columnVisibilityModel: propsColumnVisibilityModel,
|
|
27757
27669
|
pinnedColumns: propsPinnedColumns,
|
|
27758
27670
|
sortModel: propsSortModel,
|
|
27759
|
-
|
|
27760
|
-
pageSize: propsPageSize,
|
|
27671
|
+
paginationModel: propsPaginationModel,
|
|
27761
27672
|
height: propsHeight,
|
|
27762
27673
|
hideToolbar,
|
|
27763
27674
|
initialState,
|
|
@@ -27765,11 +27676,10 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27765
27676
|
license = process.env.MUI_LICENSE_KEY,
|
|
27766
27677
|
localStorageVersion,
|
|
27767
27678
|
onFilterModelChange: propsOnFilterModelChange,
|
|
27768
|
-
|
|
27679
|
+
rowSelectionModel: propsRowSelectionModel,
|
|
27769
27680
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27770
|
-
|
|
27771
|
-
|
|
27772
|
-
onSelectionModelChange: propsOnSelectionModelChange,
|
|
27681
|
+
onPaginationModelChange: propsOnPaginationModelChange,
|
|
27682
|
+
onRowSelectionModelChange: propsOnRowSelectionModelChange,
|
|
27773
27683
|
onColumnVisibilityModelChange: propsOnColumnVisibilityModelChange,
|
|
27774
27684
|
onPinnedColumnsChange: propsOnPinnedColumnsChange,
|
|
27775
27685
|
onSortModelChange: propsOnSortModelChange,
|
|
@@ -27777,7 +27687,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27777
27687
|
paginationPlacement = 'both',
|
|
27778
27688
|
paginationProps,
|
|
27779
27689
|
rows,
|
|
27780
|
-
|
|
27690
|
+
pageSizeOptions,
|
|
27781
27691
|
sx,
|
|
27782
27692
|
theme: propsTheme,
|
|
27783
27693
|
useRouter,
|
|
@@ -27788,43 +27698,38 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27788
27698
|
const theme = useTheme$4(propsTheme);
|
|
27789
27699
|
const _apiRef = useGridApiRef();
|
|
27790
27700
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
27791
|
-
const RenderedToolbar =
|
|
27701
|
+
const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar$2;
|
|
27792
27702
|
LicenseInfo.setLicenseKey(license);
|
|
27793
27703
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
27794
27704
|
const {
|
|
27795
27705
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
27796
27706
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
27797
|
-
|
|
27798
|
-
onPageSizeChange: controlledOnPageSizeChange,
|
|
27707
|
+
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
27799
27708
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
27800
27709
|
onSortModelChange: controlledOnSortModelChange
|
|
27801
27710
|
} = useControlledDatagridState({
|
|
27802
27711
|
initialState,
|
|
27803
|
-
|
|
27712
|
+
pageSizeOptions,
|
|
27804
27713
|
propsColumnVisibilityModel,
|
|
27805
27714
|
propsFilterModel,
|
|
27806
27715
|
propsOnColumnVisibilityModelChange,
|
|
27807
27716
|
propsOnFilterModelChange,
|
|
27808
27717
|
propsOnPinnedColumnsChange,
|
|
27809
27718
|
propsOnSortModelChange,
|
|
27810
|
-
|
|
27811
|
-
propsPageSize,
|
|
27719
|
+
propsPaginationModel,
|
|
27812
27720
|
propsPinnedColumns,
|
|
27813
27721
|
propsSortModel,
|
|
27814
|
-
|
|
27815
|
-
propsOnPageSizeChange
|
|
27722
|
+
propsOnPaginationModelChange
|
|
27816
27723
|
});
|
|
27817
27724
|
const {
|
|
27818
27725
|
columnVisibilityModel,
|
|
27819
27726
|
filterModel,
|
|
27820
27727
|
onColumnVisibilityModelChange,
|
|
27821
27728
|
onFilterModelChange,
|
|
27822
|
-
|
|
27823
|
-
onPageSizeChange,
|
|
27729
|
+
onPaginationModelChange,
|
|
27824
27730
|
onPinnedColumnsChange,
|
|
27825
27731
|
onSortModelChange,
|
|
27826
|
-
|
|
27827
|
-
pageSize,
|
|
27732
|
+
paginationModel,
|
|
27828
27733
|
pinnedColumns,
|
|
27829
27734
|
sortModel,
|
|
27830
27735
|
onColumnWidthChange
|
|
@@ -27835,39 +27740,38 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27835
27740
|
onColumnVisibilityModelChange: controlledOnColumnVisibilityModelChange,
|
|
27836
27741
|
onColumnWidthChange: propsOnColumnWidthChange,
|
|
27837
27742
|
onFilterModelChange: controlledOnFilterModelChange,
|
|
27838
|
-
|
|
27839
|
-
onPageSizeChange: controlledOnPageSizeChange,
|
|
27743
|
+
onPaginationModelChange: controlledOnPaginationModelChange,
|
|
27840
27744
|
onPinnedColumnsChange: controlledOnPinnedColumnsChange,
|
|
27841
27745
|
onSortModelChange: controlledOnSortModelChange,
|
|
27842
27746
|
useRouter: useRouter,
|
|
27843
27747
|
localStorageVersion
|
|
27844
27748
|
});
|
|
27845
|
-
const [
|
|
27749
|
+
const [rowSelectionModel, setRowSelectionModel] = useState(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
27846
27750
|
useEffect(() => {
|
|
27847
|
-
|
|
27848
|
-
}, [
|
|
27849
|
-
const
|
|
27850
|
-
if (
|
|
27851
|
-
|
|
27751
|
+
setRowSelectionModel(propsRowSelectionModel !== null && propsRowSelectionModel !== void 0 ? propsRowSelectionModel : []);
|
|
27752
|
+
}, [propsRowSelectionModel]);
|
|
27753
|
+
const onRowSelectionModelChange = (selectionModel, details) => {
|
|
27754
|
+
if (propsOnRowSelectionModelChange) {
|
|
27755
|
+
propsOnRowSelectionModelChange(selectionModel, details);
|
|
27852
27756
|
} else {
|
|
27853
|
-
|
|
27757
|
+
setRowSelectionModel(selectionModel);
|
|
27854
27758
|
}
|
|
27855
27759
|
};
|
|
27856
27760
|
const selectionStatus = useRef({
|
|
27857
27761
|
type: 'none',
|
|
27858
27762
|
numberOfSelectedRows: 0,
|
|
27859
27763
|
numberOfSelectedRowsInPage: 0,
|
|
27860
|
-
page,
|
|
27861
|
-
pageSize: pageSize
|
|
27764
|
+
page: paginationModel.page,
|
|
27765
|
+
pageSize: paginationModel.pageSize
|
|
27862
27766
|
});
|
|
27863
27767
|
|
|
27864
27768
|
// in server-side pagination we want to update the selection status
|
|
27865
27769
|
// every time we navigate between pages, resize our page or select something
|
|
27866
27770
|
useEffect(() => {
|
|
27867
27771
|
if (paginationMode == 'server') {
|
|
27868
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
27772
|
+
onServerSideSelectionStatusChange(Array.isArray(rowSelectionModel) ? rowSelectionModel : [rowSelectionModel], apiRef, selectionStatus, isRowSelectable, paginationModel.page, paginationModel.pageSize);
|
|
27869
27773
|
}
|
|
27870
|
-
}, [
|
|
27774
|
+
}, [rowSelectionModel, paginationModel.page, paginationModel.pageSize]);
|
|
27871
27775
|
if (!Array.isArray(rows)) {
|
|
27872
27776
|
return null;
|
|
27873
27777
|
}
|
|
@@ -27900,15 +27804,13 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27900
27804
|
filterModel: filterModel,
|
|
27901
27805
|
onColumnVisibilityModelChange: onColumnVisibilityModelChange,
|
|
27902
27806
|
onFilterModelChange: onFilterModelChange,
|
|
27903
|
-
|
|
27904
|
-
onPageSizeChange: onPageSizeChange,
|
|
27807
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27905
27808
|
onPinnedColumnsChange: onPinnedColumnsChange,
|
|
27906
27809
|
onSortModelChange: onSortModelChange,
|
|
27907
|
-
|
|
27908
|
-
pageSize: pageSize,
|
|
27810
|
+
paginationModel: paginationModel,
|
|
27909
27811
|
pinnedColumns: pinnedColumns,
|
|
27910
27812
|
sortModel: sortModel,
|
|
27911
|
-
|
|
27813
|
+
pageSizeOptions: pageSizeOptions,
|
|
27912
27814
|
onColumnWidthChange: onColumnWidthChange,
|
|
27913
27815
|
initialState: initialState,
|
|
27914
27816
|
isRowSelectable: isRowSelectable,
|
|
@@ -27919,58 +27821,55 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27919
27821
|
rowCount: rowCount,
|
|
27920
27822
|
autoHeight: autoHeight,
|
|
27921
27823
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
27922
|
-
|
|
27923
|
-
|
|
27924
|
-
|
|
27925
|
-
|
|
27926
|
-
|
|
27927
|
-
|
|
27928
|
-
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27824
|
+
slots: _objectSpread2(_objectSpread2({
|
|
27825
|
+
baseButton: BaseButton,
|
|
27826
|
+
baseCheckbox: BaseCheckbox,
|
|
27827
|
+
// baseTextField,
|
|
27828
|
+
basePopper: BasePopper,
|
|
27829
|
+
columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27929
27830
|
displayName: "ColumnFilteredIcon"
|
|
27930
27831
|
})),
|
|
27931
|
-
|
|
27832
|
+
columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27932
27833
|
displayName: "ColumnSelectorIcon"
|
|
27933
27834
|
})),
|
|
27934
|
-
|
|
27835
|
+
columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27935
27836
|
displayName: "ColumnSortedAscendingIcon"
|
|
27936
27837
|
})),
|
|
27937
|
-
|
|
27838
|
+
columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27938
27839
|
displayName: "ColumnSortedDescendingIcon"
|
|
27939
27840
|
})),
|
|
27940
|
-
|
|
27841
|
+
densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27941
27842
|
displayName: "DensityCompactIcon"
|
|
27942
27843
|
})),
|
|
27943
|
-
|
|
27844
|
+
densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27944
27845
|
displayName: "DensityStandardIcon"
|
|
27945
27846
|
})),
|
|
27946
|
-
|
|
27847
|
+
densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27947
27848
|
displayName: "DensityComfortableIcon"
|
|
27948
27849
|
})),
|
|
27949
|
-
|
|
27850
|
+
detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27950
27851
|
displayName: "DetailPanelCollapseIcon"
|
|
27951
27852
|
})),
|
|
27952
|
-
|
|
27853
|
+
detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27953
27854
|
displayName: "DetailPanelExpandIcon"
|
|
27954
27855
|
})),
|
|
27955
|
-
|
|
27856
|
+
exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({}, props, {
|
|
27956
27857
|
displayName: "ExportIcon"
|
|
27957
27858
|
})),
|
|
27958
|
-
|
|
27859
|
+
openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$1({
|
|
27959
27860
|
displayName: "OpenFilterButtonIcon"
|
|
27960
27861
|
}, props))
|
|
27961
|
-
},
|
|
27962
|
-
|
|
27963
|
-
|
|
27862
|
+
}, slots), {}, {
|
|
27863
|
+
toolbar: ToolbarWrapper,
|
|
27864
|
+
pagination: props => {
|
|
27964
27865
|
return pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$1({}, props, {
|
|
27965
27866
|
displaySelection: false,
|
|
27966
27867
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
27967
27868
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
27968
27869
|
selectionStatus: selectionStatus.current,
|
|
27969
|
-
|
|
27970
|
-
|
|
27971
|
-
|
|
27972
|
-
onPageSizeChange: onPageSizeChange,
|
|
27973
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27870
|
+
paginationModel: paginationModel,
|
|
27871
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27872
|
+
pageSizeOptions: pageSizeOptions,
|
|
27974
27873
|
paginationProps: paginationProps,
|
|
27975
27874
|
paginationMode: paginationMode,
|
|
27976
27875
|
rowCount: rowCount
|
|
@@ -27981,17 +27880,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
27981
27880
|
selectionStatus: selectionStatus.current,
|
|
27982
27881
|
apiRef: apiRef,
|
|
27983
27882
|
isRowSelectable: isRowSelectable,
|
|
27984
|
-
|
|
27985
|
-
|
|
27986
|
-
|
|
27987
|
-
onPageSizeChange: onPageSizeChange,
|
|
27988
|
-
rowsPerPageOptions: rowsPerPageOptions,
|
|
27883
|
+
paginationModel: paginationModel,
|
|
27884
|
+
onPaginationModelChange: onPaginationModelChange,
|
|
27885
|
+
pageSizeOptions: pageSizeOptions,
|
|
27989
27886
|
paginationProps: paginationProps,
|
|
27990
27887
|
paginationMode: paginationMode
|
|
27991
27888
|
})) : null;
|
|
27992
27889
|
}
|
|
27993
27890
|
}),
|
|
27994
|
-
|
|
27891
|
+
slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
|
|
27995
27892
|
toolbar: _objectSpread2({
|
|
27996
27893
|
hideToolbar,
|
|
27997
27894
|
RenderedToolbar,
|
|
@@ -28002,18 +27899,16 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28002
27899
|
selectionStatus,
|
|
28003
27900
|
apiRef,
|
|
28004
27901
|
isRowSelectable,
|
|
28005
|
-
|
|
28006
|
-
|
|
28007
|
-
|
|
28008
|
-
onPageSizeChange,
|
|
28009
|
-
rowsPerPageOptions,
|
|
27902
|
+
paginationModel,
|
|
27903
|
+
onPaginationModelChange,
|
|
27904
|
+
pageSizeOptions,
|
|
28010
27905
|
paginationProps,
|
|
28011
27906
|
paginationMode,
|
|
28012
27907
|
rowCount
|
|
28013
|
-
},
|
|
27908
|
+
}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
|
|
28014
27909
|
}),
|
|
28015
|
-
|
|
28016
|
-
|
|
27910
|
+
rowSelectionModel: rowSelectionModel,
|
|
27911
|
+
onRowSelectionModelChange: (newSelectionModel, details) => {
|
|
28017
27912
|
if (pagination && paginationMode != 'server') {
|
|
28018
27913
|
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref => {
|
|
28019
27914
|
let {
|
|
@@ -28071,7 +27966,7 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28071
27966
|
};
|
|
28072
27967
|
}
|
|
28073
27968
|
}
|
|
28074
|
-
|
|
27969
|
+
onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
|
|
28075
27970
|
},
|
|
28076
27971
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
28077
27972
|
'.MuiDataGrid-columnHeaders': {
|
|
@@ -28145,5 +28040,5 @@ const TextCell = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
28145
28040
|
TextCell.className = CLASSNAME;
|
|
28146
28041
|
TextCell.displayName = COMPONENT_NAME;
|
|
28147
28042
|
|
|
28148
|
-
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 };
|
|
28043
|
+
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, isOperatorValueValid, isValueValid, muiIconToDSIcon, numberOperatorDecoder, numberOperatorEncoder, onServerSideSelectionStatusChange, operatorList, updateUrl, urlSearchParamsToString };
|
|
28149
28044
|
//# sourceMappingURL=index.js.map
|