@redsift/table 10.8.1-alpha.0 → 10.8.1-muiv5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +5 -6
- package/index.js +157 -135
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as _mui_x_data_grid_pro from '@mui/x-data-grid-pro';
|
|
2
2
|
import { GridFilterItem, GridCellParams, GridFilterOperator, GridFilterInputMultipleValue, DataGridProProps, GridFilterModel, GridToolbarExportProps, GridToolbarFilterButtonProps, GridToolbarColumnsButton, GridToolbarDensitySelector } from '@mui/x-data-grid-pro';
|
|
3
|
-
export
|
|
4
|
-
export { GridAlignment, GridColDef, GridFilterItem, GridFilterModel, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
|
|
3
|
+
export { GridAlignment, GridColDef, GridColumns, GridFilterItem, GridFilterModel, GridSelectionModel, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
|
|
5
4
|
import { Theme, Comp, IconProps, NotificationsColorPalette, ProductColorPalette, ShieldVariant } from '@redsift/design-system';
|
|
6
5
|
import React, { ReactNode, ComponentProps, RefObject } from 'react';
|
|
7
6
|
import { TablePaginationProps } from '@mui/material';
|
|
@@ -11,7 +10,7 @@ declare const DETAIL_PANEL_TOGGLE_COL_DEF: _mui_x_data_grid_pro.GridColDef<any,
|
|
|
11
10
|
declare const IS_BETWEEN: {
|
|
12
11
|
label: string;
|
|
13
12
|
value: string;
|
|
14
|
-
getApplyFilterFn: (filterItem: GridFilterItem) => ((params: GridCellParams
|
|
13
|
+
getApplyFilterFn: (filterItem: GridFilterItem) => ((params: GridCellParams) => boolean) | null;
|
|
15
14
|
InputComponent: (props: any) => JSX.Element;
|
|
16
15
|
};
|
|
17
16
|
|
|
@@ -96,12 +95,12 @@ type StyledDataGridProps = {
|
|
|
96
95
|
declare const DataGrid: Comp<DataGridProps, HTMLDivElement>;
|
|
97
96
|
|
|
98
97
|
interface CompletionResponseItem {
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
columnField: string;
|
|
99
|
+
operatorValue: string;
|
|
101
100
|
value?: string;
|
|
102
101
|
}
|
|
103
102
|
type CompletionResponse = {
|
|
104
|
-
|
|
103
|
+
linkOperator: 'and' | 'or';
|
|
105
104
|
items: CompletionResponseItem[];
|
|
106
105
|
};
|
|
107
106
|
interface LocaleText {
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridNumericOperators as getGridNumericOperators$1, GridFilterInputMultipleValue, getGridStringOperators as getGridStringOperators$1, GridToolbarContainer, GridToolbarFilterButton, GridToolbarColumnsButton, GridToolbarDensitySelector, GridToolbarExport,
|
|
2
|
-
export * from '@mui/x-data-grid-pro';
|
|
1
|
+
import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridNumericOperators as getGridNumericOperators$1, GridFilterInputMultipleValue, getGridStringOperators as getGridStringOperators$1, GridToolbarContainer, GridToolbarFilterButton, GridToolbarColumnsButton, GridToolbarDensitySelector, GridToolbarExport, gridVisibleSortedRowIdsSelector, useGridApiRef, DataGridPro, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
|
|
3
2
|
export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
|
|
4
3
|
import * as React from 'react';
|
|
5
4
|
import React__default, { Children, isValidElement, cloneElement, useLayoutEffect, useEffect, useRef, forwardRef, useContext, useState, useCallback, createElement, useMemo } from 'react';
|
|
@@ -17640,7 +17639,7 @@ const isBetweenOperator = {
|
|
|
17640
17639
|
label: 'is between',
|
|
17641
17640
|
value: 'isBetween',
|
|
17642
17641
|
getApplyFilterFn: filterItem => {
|
|
17643
|
-
if (!filterItem.
|
|
17642
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17644
17643
|
return null;
|
|
17645
17644
|
}
|
|
17646
17645
|
if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
|
|
@@ -17653,7 +17652,7 @@ const isBetweenOperator = {
|
|
|
17653
17652
|
return null;
|
|
17654
17653
|
}
|
|
17655
17654
|
return params => {
|
|
17656
|
-
return params.value !== null &&
|
|
17655
|
+
return params.value !== null && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
|
|
17657
17656
|
};
|
|
17658
17657
|
},
|
|
17659
17658
|
InputComponent: InputNumberInterval
|
|
@@ -17666,7 +17665,7 @@ const containsAnyOfOperator = {
|
|
|
17666
17665
|
label: 'contains any of',
|
|
17667
17666
|
value: 'containsAnyOf',
|
|
17668
17667
|
getApplyFilterFn: filterItem => {
|
|
17669
|
-
if (!filterItem.
|
|
17668
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17670
17669
|
return null;
|
|
17671
17670
|
}
|
|
17672
17671
|
return params => {
|
|
@@ -17689,7 +17688,7 @@ const containsAnyOfCIOperator = {
|
|
|
17689
17688
|
label: 'contains any of (case insensitive)',
|
|
17690
17689
|
value: 'containsAnyOf',
|
|
17691
17690
|
getApplyFilterFn: filterItem => {
|
|
17692
|
-
if (!filterItem.
|
|
17691
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17693
17692
|
return null;
|
|
17694
17693
|
}
|
|
17695
17694
|
return params => {
|
|
@@ -17716,7 +17715,7 @@ const endsWithAnyOfOperator = {
|
|
|
17716
17715
|
label: 'ends with any of',
|
|
17717
17716
|
value: 'endsWithAnyOf',
|
|
17718
17717
|
getApplyFilterFn: filterItem => {
|
|
17719
|
-
if (!filterItem.
|
|
17718
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17720
17719
|
return null;
|
|
17721
17720
|
}
|
|
17722
17721
|
return params => {
|
|
@@ -17743,7 +17742,7 @@ const isAnyOfOperator = {
|
|
|
17743
17742
|
label: 'is any of',
|
|
17744
17743
|
value: 'isAnyOf',
|
|
17745
17744
|
getApplyFilterFn: filterItem => {
|
|
17746
|
-
if (!filterItem.
|
|
17745
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17747
17746
|
return null;
|
|
17748
17747
|
}
|
|
17749
17748
|
return params => {
|
|
@@ -17767,7 +17766,7 @@ const isNotAnyOfOperator = {
|
|
|
17767
17766
|
label: 'is not any of',
|
|
17768
17767
|
value: 'isNotAnyOf',
|
|
17769
17768
|
getApplyFilterFn: filterItem => {
|
|
17770
|
-
if (!filterItem.
|
|
17769
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17771
17770
|
return null;
|
|
17772
17771
|
}
|
|
17773
17772
|
return params => {
|
|
@@ -17791,7 +17790,7 @@ const startsWithAnyOfOperator = {
|
|
|
17791
17790
|
label: 'starts with any of',
|
|
17792
17791
|
value: 'startsWithAnyOf',
|
|
17793
17792
|
getApplyFilterFn: filterItem => {
|
|
17794
|
-
if (!filterItem.
|
|
17793
|
+
if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
|
|
17795
17794
|
return null;
|
|
17796
17795
|
}
|
|
17797
17796
|
return params => {
|
|
@@ -17820,7 +17819,7 @@ const getGridStringOperators = () => [...getGridStringOperators$1(), ...getGridS
|
|
|
17820
17819
|
|
|
17821
17820
|
const API_URL = 'https://api.openai.com/v1/chat/completions';
|
|
17822
17821
|
async function getCompletion(text, role, openai_api_key) {
|
|
17823
|
-
let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-
|
|
17822
|
+
let model = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'gpt-3.5-turbo-0613';
|
|
17824
17823
|
try {
|
|
17825
17824
|
const messages = [{
|
|
17826
17825
|
role: 'system',
|
|
@@ -21952,16 +21951,16 @@ const getRole = (config, dateFormat) => {
|
|
|
21952
21951
|
}).join('\n');
|
|
21953
21952
|
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.
|
|
21954
21953
|
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.
|
|
21955
|
-
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "
|
|
21956
|
-
- "
|
|
21957
|
-
- "items": a list of conditions, each is an object with exactly the three keys "
|
|
21958
|
-
- "
|
|
21954
|
+
The AI assistant extracts information from the user input and generates a JSON object with exactly the two keys "linkOperator" and "items":
|
|
21955
|
+
- "linkOperator": the logical operator, only "and" or "or" are allowed. If there is only one condition in the "items", use "and".
|
|
21956
|
+
- "items": a list of conditions, each is an object with exactly the three keys "columnField", "operatorValue" and "value":
|
|
21957
|
+
- "columnField": the column name, must be one of ${columns}
|
|
21959
21958
|
- "value":
|
|
21960
|
-
- this can be skipped if the "
|
|
21961
|
-
- a list of multiple values if the "
|
|
21959
|
+
- this can be skipped if the "operatorValue" is either "isEmpty" or "isNotEmpty"
|
|
21960
|
+
- a list of multiple values if the "operatorValue" ends with "AnyOf"
|
|
21962
21961
|
- otherwise, it's a single value represented as a string: "true" instead of true, "false" instead of false, "0.6" instead of 0.6.
|
|
21963
21962
|
For "date" data type, use ${dateFormat}. If relative date is input, convert to the actual date given today is ${today}.
|
|
21964
|
-
- "
|
|
21963
|
+
- "operatorValue": the comparison operator, accepted values depend on the data type of the column
|
|
21965
21964
|
${operators}
|
|
21966
21965
|
|
|
21967
21966
|
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:
|
|
@@ -21998,10 +21997,10 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
21998
21997
|
nlpFilterConfig,
|
|
21999
21998
|
onFilterModelChange,
|
|
22000
21999
|
dateFormat = 'yyyy-mm-dd',
|
|
22001
|
-
defaultModel = 'gpt-4-
|
|
22000
|
+
defaultModel = 'gpt-4-0613',
|
|
22002
22001
|
defaultFilter = {
|
|
22003
22002
|
items: [],
|
|
22004
|
-
|
|
22003
|
+
linkOperator: 'and'
|
|
22005
22004
|
},
|
|
22006
22005
|
disablePower = false,
|
|
22007
22006
|
localeText
|
|
@@ -22079,7 +22078,7 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
22079
22078
|
value: prompt
|
|
22080
22079
|
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
22081
22080
|
variant: "primary",
|
|
22082
|
-
"
|
|
22081
|
+
"aira-label": buttonAriaLabel,
|
|
22083
22082
|
type: "submit",
|
|
22084
22083
|
isLoading: isLoading
|
|
22085
22084
|
}, buttonText)), !disablePower && /*#__PURE__*/React__default.createElement(Tooltip, null, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, /*#__PURE__*/React__default.createElement(Switch, {
|
|
@@ -22140,7 +22139,7 @@ const Toolbar$3 = props => {
|
|
|
22140
22139
|
let {
|
|
22141
22140
|
apiRef
|
|
22142
22141
|
} = _ref;
|
|
22143
|
-
return
|
|
22142
|
+
return gridVisibleSortedRowIdsSelector(apiRef);
|
|
22144
22143
|
}
|
|
22145
22144
|
},
|
|
22146
22145
|
printOptions: {
|
|
@@ -24592,8 +24591,8 @@ process.env.NODE_ENV !== "production" ? TablePagination.propTypes /* remove-prop
|
|
|
24592
24591
|
} : void 0;
|
|
24593
24592
|
var TablePagination$1 = TablePagination;
|
|
24594
24593
|
|
|
24595
|
-
const _excluded$1 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "ControlledPagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "
|
|
24596
|
-
_excluded2 = ["apiRef", "autoHeight", "className", "
|
|
24594
|
+
const _excluded$1 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "ControlledPagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "page", "onPageChange", "pageSize", "onPageSizeChange", "rowsPerPageOptions", "paginationProps", "paginationMode", "rowCount"],
|
|
24595
|
+
_excluded2 = ["apiRef", "autoHeight", "className", "components", "componentsProps", "filterModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "onPageChange", "onPageSizeChange", "selectionModel", "onSelectionModelChange", "page", "pageSize", "pagination", "paginationPlacement", "paginationProps", "rows", "rowsPerPageOptions", "sx", "theme", "paginationMode", "rowCount"];
|
|
24597
24596
|
const COMPONENT_NAME$1 = 'DataGrid';
|
|
24598
24597
|
const CLASSNAME$1 = 'redsift-datagrid';
|
|
24599
24598
|
const getSelectableRowsInTable = (apiRef, isRowSelectable) => {
|
|
@@ -24618,9 +24617,11 @@ const ControlledPagination = _ref3 => {
|
|
|
24618
24617
|
displayPagination = false,
|
|
24619
24618
|
selectionStatus,
|
|
24620
24619
|
apiRef,
|
|
24621
|
-
|
|
24622
|
-
|
|
24623
|
-
|
|
24620
|
+
page,
|
|
24621
|
+
onPageChange,
|
|
24622
|
+
pageSize,
|
|
24623
|
+
onPageSizeChange,
|
|
24624
|
+
rowsPerPageOptions,
|
|
24624
24625
|
isRowSelectable,
|
|
24625
24626
|
paginationProps
|
|
24626
24627
|
} = _ref3;
|
|
@@ -24650,17 +24651,13 @@ const ControlledPagination = _ref3 => {
|
|
|
24650
24651
|
}, `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$2({
|
|
24651
24652
|
component: "div",
|
|
24652
24653
|
count: numberOfFilteredRowsInTable,
|
|
24653
|
-
page:
|
|
24654
|
-
onPageChange: (event,
|
|
24655
|
-
|
|
24656
|
-
|
|
24657
|
-
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
page: paginationModel.page,
|
|
24661
|
-
pageSize: parseInt(event.target.value, 10)
|
|
24662
|
-
}),
|
|
24663
|
-
rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
|
|
24654
|
+
page: page,
|
|
24655
|
+
onPageChange: (event, newPage) => onPageChange(newPage),
|
|
24656
|
+
rowsPerPage: pageSize,
|
|
24657
|
+
onRowsPerPageChange: event => {
|
|
24658
|
+
onPageSizeChange(parseInt(event.target.value, 10));
|
|
24659
|
+
},
|
|
24660
|
+
rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
|
|
24664
24661
|
}, paginationProps)) : null);
|
|
24665
24662
|
};
|
|
24666
24663
|
const ServerSideControlledPagination = _ref4 => {
|
|
@@ -24668,10 +24665,12 @@ const ServerSideControlledPagination = _ref4 => {
|
|
|
24668
24665
|
selectionStatus,
|
|
24669
24666
|
displaySelection,
|
|
24670
24667
|
displayPagination,
|
|
24671
|
-
|
|
24672
|
-
|
|
24673
|
-
|
|
24668
|
+
page,
|
|
24669
|
+
onPageChange,
|
|
24670
|
+
pageSize,
|
|
24671
|
+
onPageSizeChange,
|
|
24674
24672
|
displayRowsPerPage,
|
|
24673
|
+
rowsPerPageOptions,
|
|
24675
24674
|
paginationProps,
|
|
24676
24675
|
rowCount
|
|
24677
24676
|
} = _ref4;
|
|
@@ -24690,17 +24689,13 @@ const ServerSideControlledPagination = _ref4 => {
|
|
|
24690
24689
|
}, totalRowsLabel) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$2({
|
|
24691
24690
|
component: "div",
|
|
24692
24691
|
count: totalNumberOfRowsInTable,
|
|
24693
|
-
page:
|
|
24694
|
-
onPageChange: (event,
|
|
24695
|
-
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
|
|
24700
|
-
page: paginationModel.page,
|
|
24701
|
-
pageSize: parseInt(event.target.value, 10)
|
|
24702
|
-
}),
|
|
24703
|
-
rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
|
|
24692
|
+
page: page,
|
|
24693
|
+
onPageChange: (event, newPage) => onPageChange(newPage),
|
|
24694
|
+
rowsPerPage: pageSize,
|
|
24695
|
+
onRowsPerPageChange: event => {
|
|
24696
|
+
onPageSizeChange(parseInt(event.target.value, 10));
|
|
24697
|
+
},
|
|
24698
|
+
rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
|
|
24704
24699
|
}, paginationProps)) : null);
|
|
24705
24700
|
};
|
|
24706
24701
|
const Toolbar = _ref5 => {
|
|
@@ -24715,9 +24710,11 @@ const Toolbar = _ref5 => {
|
|
|
24715
24710
|
selectionStatus,
|
|
24716
24711
|
apiRef,
|
|
24717
24712
|
isRowSelectable,
|
|
24718
|
-
|
|
24719
|
-
|
|
24720
|
-
|
|
24713
|
+
page,
|
|
24714
|
+
onPageChange,
|
|
24715
|
+
pageSize,
|
|
24716
|
+
onPageSizeChange,
|
|
24717
|
+
rowsPerPageOptions,
|
|
24721
24718
|
paginationProps,
|
|
24722
24719
|
paginationMode = 'client',
|
|
24723
24720
|
rowCount
|
|
@@ -24731,9 +24728,11 @@ const Toolbar = _ref5 => {
|
|
|
24731
24728
|
displayRowsPerPage: false,
|
|
24732
24729
|
displayPagination: ['top', 'both'].includes(paginationPlacement),
|
|
24733
24730
|
selectionStatus: selectionStatus.current,
|
|
24734
|
-
|
|
24735
|
-
|
|
24736
|
-
|
|
24731
|
+
page: page,
|
|
24732
|
+
onPageChange: onPageChange,
|
|
24733
|
+
pageSize: pageSize,
|
|
24734
|
+
onPageSizeChange: onPageSizeChange,
|
|
24735
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
24737
24736
|
paginationProps: paginationProps,
|
|
24738
24737
|
rowCount: rowCount
|
|
24739
24738
|
}) : /*#__PURE__*/React__default.createElement(ControlledPagination, {
|
|
@@ -24743,9 +24742,11 @@ const Toolbar = _ref5 => {
|
|
|
24743
24742
|
selectionStatus: selectionStatus.current,
|
|
24744
24743
|
apiRef: apiRef,
|
|
24745
24744
|
isRowSelectable: isRowSelectable,
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24745
|
+
page: page,
|
|
24746
|
+
onPageChange: onPageChange,
|
|
24747
|
+
pageSize: pageSize,
|
|
24748
|
+
onPageSizeChange: onPageSizeChange,
|
|
24749
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
24749
24750
|
paginationProps: paginationProps
|
|
24750
24751
|
}) : null);
|
|
24751
24752
|
};
|
|
@@ -24805,14 +24806,14 @@ const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionS
|
|
|
24805
24806
|
}
|
|
24806
24807
|
};
|
|
24807
24808
|
const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
24808
|
-
var
|
|
24809
|
+
var _initialState$paginat, _initialState$paginat2;
|
|
24809
24810
|
const datagridRef = ref || useRef();
|
|
24810
24811
|
const {
|
|
24811
24812
|
apiRef: propsApiRef,
|
|
24812
24813
|
autoHeight,
|
|
24813
24814
|
className,
|
|
24814
|
-
|
|
24815
|
-
|
|
24815
|
+
components,
|
|
24816
|
+
componentsProps,
|
|
24816
24817
|
filterModel: propsFilterModel,
|
|
24817
24818
|
height: propsHeight,
|
|
24818
24819
|
hideToolbar,
|
|
@@ -24820,15 +24821,17 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24820
24821
|
isRowSelectable,
|
|
24821
24822
|
license = process.env.MUI_LICENSE_KEY,
|
|
24822
24823
|
onFilterModelChange: propsOnFilterModelChange,
|
|
24823
|
-
|
|
24824
|
-
|
|
24825
|
-
|
|
24826
|
-
|
|
24824
|
+
onPageChange: propsOnPageChange,
|
|
24825
|
+
onPageSizeChange: propsOnPageSizeChange,
|
|
24826
|
+
selectionModel: propsSelectionModel,
|
|
24827
|
+
onSelectionModelChange,
|
|
24828
|
+
page: propsPage,
|
|
24829
|
+
pageSize: propsPageSize,
|
|
24827
24830
|
pagination,
|
|
24828
24831
|
paginationPlacement = 'both',
|
|
24829
24832
|
paginationProps,
|
|
24830
24833
|
rows,
|
|
24831
|
-
|
|
24834
|
+
rowsPerPageOptions,
|
|
24832
24835
|
sx,
|
|
24833
24836
|
theme: propsTheme,
|
|
24834
24837
|
paginationMode = 'client',
|
|
@@ -24838,7 +24841,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24838
24841
|
const theme = useTheme$4(propsTheme);
|
|
24839
24842
|
const _apiRef = useGridApiRef();
|
|
24840
24843
|
const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
|
|
24841
|
-
const RenderedToolbar =
|
|
24844
|
+
const RenderedToolbar = components !== null && components !== void 0 && components.Toolbar ? components.Toolbar : Toolbar$3;
|
|
24842
24845
|
LicenseInfo.setLicenseKey(license);
|
|
24843
24846
|
const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
|
|
24844
24847
|
const [filterModel, setFilterModel] = useState(propsFilterModel);
|
|
@@ -24852,41 +24855,52 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24852
24855
|
setFilterModel(model);
|
|
24853
24856
|
}
|
|
24854
24857
|
};
|
|
24855
|
-
const [
|
|
24858
|
+
const [selectionModel, setSelectionModel] = useState(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
24856
24859
|
useEffect(() => {
|
|
24857
|
-
|
|
24860
|
+
setSelectionModel(propsSelectionModel !== null && propsSelectionModel !== void 0 ? propsSelectionModel : []);
|
|
24858
24861
|
}, [propsSelectionModel]);
|
|
24859
|
-
const [
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
+
const [page, setPage] = React__default.useState((initialState === null || initialState === void 0 ? void 0 : (_initialState$paginat = initialState.pagination) === null || _initialState$paginat === void 0 ? void 0 : _initialState$paginat.page) || propsPage || 0);
|
|
24863
|
+
const [pageSize, setPageSize] = React__default.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]) || 100);
|
|
24864
|
+
const selectionStatus = useRef({
|
|
24865
|
+
type: 'none',
|
|
24866
|
+
numberOfSelectedRows: 0,
|
|
24867
|
+
numberOfSelectedRowsInPage: 0,
|
|
24868
|
+
page,
|
|
24869
|
+
pageSize
|
|
24862
24870
|
});
|
|
24863
|
-
const
|
|
24864
|
-
if (
|
|
24865
|
-
|
|
24871
|
+
const onPageChange = page => {
|
|
24872
|
+
if (propsOnPageChange) {
|
|
24873
|
+
propsOnPageChange(page, undefined);
|
|
24866
24874
|
} else {
|
|
24867
|
-
|
|
24875
|
+
setPage(page);
|
|
24868
24876
|
}
|
|
24869
24877
|
};
|
|
24870
24878
|
useEffect(() => {
|
|
24871
|
-
if (
|
|
24872
|
-
|
|
24879
|
+
if (propsPage || propsPage === 0) {
|
|
24880
|
+
setPage(propsPage);
|
|
24881
|
+
}
|
|
24882
|
+
}, [propsPage]);
|
|
24883
|
+
const onPageSizeChange = pageSize => {
|
|
24884
|
+
onPageChange(0);
|
|
24885
|
+
if (propsOnPageSizeChange) {
|
|
24886
|
+
propsOnPageSizeChange(pageSize, undefined);
|
|
24887
|
+
} else {
|
|
24888
|
+
setPageSize(pageSize);
|
|
24873
24889
|
}
|
|
24874
|
-
}
|
|
24875
|
-
|
|
24876
|
-
|
|
24877
|
-
|
|
24878
|
-
|
|
24879
|
-
|
|
24880
|
-
pageSize: paginationModel.pageSize
|
|
24881
|
-
});
|
|
24890
|
+
};
|
|
24891
|
+
useEffect(() => {
|
|
24892
|
+
if (propsPageSize) {
|
|
24893
|
+
setPageSize(propsPageSize);
|
|
24894
|
+
}
|
|
24895
|
+
}, [propsPageSize]);
|
|
24882
24896
|
|
|
24883
24897
|
// in server-side pagination we want to update the selection status
|
|
24884
24898
|
// every time we navigate between pages, resize our page or select something
|
|
24885
24899
|
useEffect(() => {
|
|
24886
24900
|
if (paginationMode == 'server') {
|
|
24887
|
-
onServerSideSelectionStatusChange(Array.isArray(
|
|
24901
|
+
onServerSideSelectionStatusChange(Array.isArray(selectionModel) ? selectionModel : [selectionModel], apiRef, selectionStatus, isRowSelectable, page, pageSize);
|
|
24888
24902
|
}
|
|
24889
|
-
}, [
|
|
24903
|
+
}, [selectionModel, page, pageSize]);
|
|
24890
24904
|
if (!Array.isArray(rows)) {
|
|
24891
24905
|
return null;
|
|
24892
24906
|
}
|
|
@@ -24916,54 +24930,56 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24916
24930
|
apiRef: apiRef,
|
|
24917
24931
|
autoHeight: autoHeight,
|
|
24918
24932
|
checkboxSelectionVisibleOnly: Boolean(pagination),
|
|
24919
|
-
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
//
|
|
24923
|
-
|
|
24924
|
-
|
|
24933
|
+
components: _objectSpread2(_objectSpread2({
|
|
24934
|
+
BaseButton,
|
|
24935
|
+
BaseCheckbox,
|
|
24936
|
+
// BaseTextField,
|
|
24937
|
+
BasePopper,
|
|
24938
|
+
ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24925
24939
|
displayName: "ColumnFilteredIcon"
|
|
24926
24940
|
})),
|
|
24927
|
-
|
|
24941
|
+
ColumnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24928
24942
|
displayName: "ColumnSelectorIcon"
|
|
24929
24943
|
})),
|
|
24930
|
-
|
|
24944
|
+
ColumnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24931
24945
|
displayName: "ColumnSortedAscendingIcon"
|
|
24932
24946
|
})),
|
|
24933
|
-
|
|
24947
|
+
ColumnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24934
24948
|
displayName: "ColumnSortedDescendingIcon"
|
|
24935
24949
|
})),
|
|
24936
|
-
|
|
24950
|
+
DensityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24937
24951
|
displayName: "DensityCompactIcon"
|
|
24938
24952
|
})),
|
|
24939
|
-
|
|
24953
|
+
DensityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24940
24954
|
displayName: "DensityStandardIcon"
|
|
24941
24955
|
})),
|
|
24942
|
-
|
|
24956
|
+
DensityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24943
24957
|
displayName: "DensityComfortableIcon"
|
|
24944
24958
|
})),
|
|
24945
|
-
|
|
24959
|
+
DetailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24946
24960
|
displayName: "DetailPanelCollapseIcon"
|
|
24947
24961
|
})),
|
|
24948
|
-
|
|
24962
|
+
DetailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24949
24963
|
displayName: "DetailPanelExpandIcon"
|
|
24950
24964
|
})),
|
|
24951
|
-
|
|
24965
|
+
ExportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
|
|
24952
24966
|
displayName: "ExportIcon"
|
|
24953
24967
|
})),
|
|
24954
|
-
|
|
24968
|
+
OpenFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({
|
|
24955
24969
|
displayName: "OpenFilterButtonIcon"
|
|
24956
24970
|
}, props))
|
|
24957
|
-
},
|
|
24958
|
-
|
|
24959
|
-
|
|
24971
|
+
}, components), {}, {
|
|
24972
|
+
Toolbar: Toolbar,
|
|
24973
|
+
Pagination: props => pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$2({}, props, {
|
|
24960
24974
|
displaySelection: false,
|
|
24961
24975
|
displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
|
|
24962
24976
|
displayPagination: ['bottom', 'both'].includes(paginationPlacement),
|
|
24963
24977
|
selectionStatus: selectionStatus.current,
|
|
24964
|
-
|
|
24965
|
-
|
|
24966
|
-
|
|
24978
|
+
page: page,
|
|
24979
|
+
onPageChange: onPageChange,
|
|
24980
|
+
pageSize: pageSize,
|
|
24981
|
+
onPageSizeChange: onPageSizeChange,
|
|
24982
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
24967
24983
|
paginationProps: paginationProps,
|
|
24968
24984
|
paginationMode: paginationMode,
|
|
24969
24985
|
rowCount: rowCount
|
|
@@ -24974,15 +24990,17 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24974
24990
|
selectionStatus: selectionStatus.current,
|
|
24975
24991
|
apiRef: apiRef,
|
|
24976
24992
|
isRowSelectable: isRowSelectable,
|
|
24977
|
-
|
|
24978
|
-
|
|
24979
|
-
|
|
24993
|
+
page: page,
|
|
24994
|
+
onPageChange: onPageChange,
|
|
24995
|
+
pageSize: pageSize,
|
|
24996
|
+
onPageSizeChange: onPageSizeChange,
|
|
24997
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
24980
24998
|
paginationProps: paginationProps,
|
|
24981
24999
|
paginationMode: paginationMode,
|
|
24982
25000
|
rowCount: rowCount
|
|
24983
25001
|
})) : null
|
|
24984
25002
|
}),
|
|
24985
|
-
|
|
25003
|
+
componentsProps: _objectSpread2(_objectSpread2({}, componentsProps), {}, {
|
|
24986
25004
|
toolbar: _objectSpread2({
|
|
24987
25005
|
hideToolbar,
|
|
24988
25006
|
RenderedToolbar,
|
|
@@ -24994,13 +25012,15 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
24994
25012
|
selectionStatus,
|
|
24995
25013
|
apiRef,
|
|
24996
25014
|
isRowSelectable,
|
|
24997
|
-
|
|
24998
|
-
|
|
24999
|
-
|
|
25015
|
+
page,
|
|
25016
|
+
onPageChange,
|
|
25017
|
+
pageSize,
|
|
25018
|
+
onPageSizeChange,
|
|
25019
|
+
rowsPerPageOptions,
|
|
25000
25020
|
paginationProps,
|
|
25001
25021
|
paginationMode,
|
|
25002
25022
|
rowCount
|
|
25003
|
-
},
|
|
25023
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbar)
|
|
25004
25024
|
}),
|
|
25005
25025
|
filterModel: filterModel,
|
|
25006
25026
|
initialState: initialState,
|
|
@@ -25010,37 +25030,39 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
25010
25030
|
paginationMode: paginationMode,
|
|
25011
25031
|
keepNonExistentRowsSelected: paginationMode == 'server',
|
|
25012
25032
|
rows: rows,
|
|
25013
|
-
|
|
25014
|
-
|
|
25015
|
-
|
|
25016
|
-
|
|
25017
|
-
|
|
25033
|
+
rowsPerPageOptions: rowsPerPageOptions,
|
|
25034
|
+
page: page,
|
|
25035
|
+
onPageChange: onPageChange,
|
|
25036
|
+
pageSize: pageSize,
|
|
25037
|
+
onPageSizeChange: onPageSizeChange,
|
|
25038
|
+
selectionModel: selectionModel,
|
|
25039
|
+
onSelectionModelChange: (newSelectionModel, details) => {
|
|
25018
25040
|
if (pagination && paginationMode != 'server') {
|
|
25019
|
-
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(
|
|
25041
|
+
const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref8 => {
|
|
25020
25042
|
let {
|
|
25021
25043
|
model
|
|
25022
|
-
} =
|
|
25044
|
+
} = _ref8;
|
|
25023
25045
|
return isRowSelectable({
|
|
25024
25046
|
row: model
|
|
25025
25047
|
});
|
|
25026
|
-
}).map(
|
|
25048
|
+
}).map(_ref9 => {
|
|
25027
25049
|
let {
|
|
25028
25050
|
id
|
|
25029
|
-
} =
|
|
25051
|
+
} = _ref9;
|
|
25030
25052
|
return id;
|
|
25031
25053
|
}) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
|
|
25032
25054
|
const numberOfSelectableRowsInPage = selectableRowsInPage.length;
|
|
25033
|
-
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(
|
|
25055
|
+
const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref10 => {
|
|
25034
25056
|
let {
|
|
25035
25057
|
model
|
|
25036
|
-
} =
|
|
25058
|
+
} = _ref10;
|
|
25037
25059
|
return isRowSelectable({
|
|
25038
25060
|
row: model
|
|
25039
25061
|
});
|
|
25040
|
-
}).map(
|
|
25062
|
+
}).map(_ref11 => {
|
|
25041
25063
|
let {
|
|
25042
25064
|
id
|
|
25043
|
-
} =
|
|
25065
|
+
} = _ref11;
|
|
25044
25066
|
return id;
|
|
25045
25067
|
}) : gridFilteredSortedRowIdsSelector(apiRef);
|
|
25046
25068
|
const numberOfSelectableRowsInTable = selectableRowsInTable.length;
|
|
@@ -25072,7 +25094,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
25072
25094
|
};
|
|
25073
25095
|
}
|
|
25074
25096
|
}
|
|
25075
|
-
|
|
25097
|
+
onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel, details);
|
|
25076
25098
|
},
|
|
25077
25099
|
sx: _objectSpread2(_objectSpread2({}, sx), {}, {
|
|
25078
25100
|
'.MuiDataGrid-columnHeaders': {
|