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