@redsift/table 9.3.2 → 9.3.3-muiv5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +24 -11
  2. package/index.js +161 -117
  3. package/index.js.map +1 -1
  4. package/package.json +4 -4
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, gridExpandedSortedRowIdsSelector, useGridApiRef, DataGridPro, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector } from '@mui/x-data-grid-pro';
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, useState, useCallback, createElement } from 'react';
@@ -17467,7 +17466,7 @@ const isBetweenOperator = {
17467
17466
  label: 'is between',
17468
17467
  value: 'isBetween',
17469
17468
  getApplyFilterFn: filterItem => {
17470
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17469
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17471
17470
  return null;
17472
17471
  }
17473
17472
  if (!Array.isArray(filterItem.value) || filterItem.value.length !== 2) {
@@ -17480,7 +17479,7 @@ const isBetweenOperator = {
17480
17479
  return null;
17481
17480
  }
17482
17481
  return params => {
17483
- return params.value !== null && params.value !== undefined && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
17482
+ return params.value !== null && filterItem.value[0] <= params.value && params.value <= filterItem.value[1];
17484
17483
  };
17485
17484
  },
17486
17485
  InputComponent: InputNumberInterval
@@ -17493,7 +17492,7 @@ const containsAnyOfOperator = {
17493
17492
  label: 'contains any of',
17494
17493
  value: 'containsAnyOf',
17495
17494
  getApplyFilterFn: filterItem => {
17496
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17495
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17497
17496
  return null;
17498
17497
  }
17499
17498
  return params => {
@@ -17516,7 +17515,7 @@ const containsAnyOfCIOperator = {
17516
17515
  label: 'contains any of (case insensitive)',
17517
17516
  value: 'containsAnyOf',
17518
17517
  getApplyFilterFn: filterItem => {
17519
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17518
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17520
17519
  return null;
17521
17520
  }
17522
17521
  return params => {
@@ -17543,7 +17542,7 @@ const endsWithAnyOfOperator = {
17543
17542
  label: 'ends with any of',
17544
17543
  value: 'endsWithAnyOf',
17545
17544
  getApplyFilterFn: filterItem => {
17546
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17545
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17547
17546
  return null;
17548
17547
  }
17549
17548
  return params => {
@@ -17570,7 +17569,7 @@ const isAnyOfOperator = {
17570
17569
  label: 'is any of',
17571
17570
  value: 'isAnyOf',
17572
17571
  getApplyFilterFn: filterItem => {
17573
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17572
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17574
17573
  return null;
17575
17574
  }
17576
17575
  return params => {
@@ -17594,7 +17593,7 @@ const isNotAnyOfOperator = {
17594
17593
  label: 'is not any of',
17595
17594
  value: 'isNotAnyOf',
17596
17595
  getApplyFilterFn: filterItem => {
17597
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17596
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17598
17597
  return null;
17599
17598
  }
17600
17599
  return params => {
@@ -17618,7 +17617,7 @@ const startsWithAnyOfOperator = {
17618
17617
  label: 'starts with any of',
17619
17618
  value: 'startsWithAnyOf',
17620
17619
  getApplyFilterFn: filterItem => {
17621
- if (!filterItem.field || !filterItem.value || !filterItem.operator) {
17620
+ if (!filterItem.columnField || !filterItem.value || !filterItem.operatorValue) {
17622
17621
  return null;
17623
17622
  }
17624
17623
  return params => {
@@ -21462,7 +21461,7 @@ const StyledTooltipContent = styled$3.div`
21462
21461
 
21463
21462
  const COMPONENT_NAME$5 = 'TooltipContent';
21464
21463
  const CLASSNAME$5 = 'redsift-tooltip-content';
21465
- const DEFAULT_PROPS$3 = {};
21464
+ const DEFAULT_PROPS$4 = {};
21466
21465
 
21467
21466
  /**
21468
21467
  * The TooltipContent component.
@@ -21524,12 +21523,12 @@ const TooltipContent = /*#__PURE__*/forwardRef((props, ref) => {
21524
21523
  }, children)));
21525
21524
  });
21526
21525
  TooltipContent.className = CLASSNAME$5;
21527
- TooltipContent.defaultProps = DEFAULT_PROPS$3;
21526
+ TooltipContent.defaultProps = DEFAULT_PROPS$4;
21528
21527
  TooltipContent.displayName = COMPONENT_NAME$5;
21529
21528
 
21530
21529
  const COMPONENT_NAME$4 = 'TooltipTrigger';
21531
21530
  const CLASSNAME$4 = 'redsift-tooltip-trigger';
21532
- const DEFAULT_PROPS$2 = {};
21531
+ const DEFAULT_PROPS$3 = {};
21533
21532
 
21534
21533
  /**
21535
21534
  * The TooltipTrigger component.
@@ -21560,7 +21559,7 @@ const TooltipTrigger = /*#__PURE__*/forwardRef((props, ref) => {
21560
21559
  }, getReferenceProps(props)), children);
21561
21560
  });
21562
21561
  TooltipTrigger.className = CLASSNAME$4;
21563
- TooltipTrigger.defaultProps = DEFAULT_PROPS$2;
21562
+ TooltipTrigger.defaultProps = DEFAULT_PROPS$3;
21564
21563
  TooltipTrigger.displayName = COMPONENT_NAME$4;
21565
21564
 
21566
21565
  function useTooltip(_ref) {
@@ -21626,7 +21625,7 @@ function useTooltip(_ref) {
21626
21625
 
21627
21626
  const COMPONENT_NAME$3 = 'Tooltip';
21628
21627
  const CLASSNAME$3 = 'redsift-tooltip';
21629
- const DEFAULT_PROPS$1 = {
21628
+ const DEFAULT_PROPS$2 = {
21630
21629
  delay: 500,
21631
21630
  placement: TooltipPlacement.top
21632
21631
  };
@@ -21658,7 +21657,7 @@ const BaseTooltip = props => {
21658
21657
  }, trigger, content);
21659
21658
  };
21660
21659
  BaseTooltip.className = CLASSNAME$3;
21661
- BaseTooltip.defaultProps = DEFAULT_PROPS$1;
21660
+ BaseTooltip.defaultProps = DEFAULT_PROPS$2;
21662
21661
  BaseTooltip.displayName = COMPONENT_NAME$3;
21663
21662
  const Tooltip = Object.assign(BaseTooltip, {
21664
21663
  Trigger: TooltipTrigger,
@@ -21689,13 +21688,26 @@ const StyledGridToolbarFilterSemanticField = styled$3.form`
21689
21688
  }
21690
21689
  `;
21691
21690
 
21692
- const _excluded$e = ["className", "nlpFilterConfig", "onFilterModelChange"];
21691
+ const _excluded$e = ["className", "nlpFilterConfig", "onFilterModelChange", "dateFormat", "defaultModel", "defaultFilter", "disablePower", "localeText"];
21693
21692
  const COMPONENT_NAME$2 = 'GridToolbarFilterSemanticField';
21694
21693
  const CLASSNAME$2 = 'redsift-datagrid-toolbar-nlp-filter-field';
21695
- const DATE_FORMAT = 'yyyy-mm-dd';
21696
- const DEFAULT_GPT_MODEL = 'gpt-4-0613';
21697
- const DEFAULT_FILTER = {
21698
- items: []
21694
+ const DEFAULT_PROPS$1 = {
21695
+ dateFormat: 'yyyy-mm-dd',
21696
+ defaultModel: 'gpt-4-0613',
21697
+ defaultFilter: {
21698
+ items: [],
21699
+ linkOperator: 'and'
21700
+ },
21701
+ disablePower: false,
21702
+ localeText: {
21703
+ textLabel: 'Semantic filtering',
21704
+ textPlaceholder: 'Describe here how you would like to filter this datagrid.',
21705
+ buttonAriaLabel: 'Submit',
21706
+ buttonText: 'Run',
21707
+ powerText: 'Power mode',
21708
+ powerTooltipContent: 'The Power mode can get better results but is slower.',
21709
+ errorText: 'Unable to find a valid filter, please try again with a more specific prompt.'
21710
+ }
21699
21711
  };
21700
21712
  const DEFAULT_OPERATORS = {
21701
21713
  string: ['contains', 'equals', 'startsWith', 'endsWith', 'isEmpty', 'isNotEmpty', 'isAnyOf'],
@@ -21703,7 +21715,7 @@ const DEFAULT_OPERATORS = {
21703
21715
  boolean: ['is'],
21704
21716
  date: ['is', 'not', 'after', 'onOrAfter', 'before', 'onOrBefore', 'isEmpty', 'isNotEmpty']
21705
21717
  };
21706
- const getRole = config => {
21718
+ const getRole = (config, dateFormat) => {
21707
21719
  const today = new Date().toDateString();
21708
21720
  const columns = `[${config.columns.map(_ref => {
21709
21721
  let {
@@ -21733,7 +21745,7 @@ The AI assistant extracts information from the user input and generates a JSON o
21733
21745
  - this can be skipped if the "operatorValue" is either "isEmpty" or "isNotEmpty"
21734
21746
  - a list of multiple values if the "operatorValue" ends with "AnyOf"
21735
21747
  - otherwise, it's a single value represented as a string: "true" instead of true, "false" instead of false, "0.6" instead of 0.6.
21736
- For "date" data type, use ${DATE_FORMAT}. If relative date is input, convert to the actual date given today is ${today}.
21748
+ For "date" data type, use ${dateFormat}. If relative date is input, convert to the actual date given today is ${today}.
21737
21749
  - "operatorValue": the comparison operator, accepted values depend on the data type of the column
21738
21750
  ${operators}
21739
21751
 
@@ -21750,9 +21762,9 @@ Return just the JSON object without any extra text, explanation or note.
21750
21762
  If the user input can't be parsed, return a JSON object to indicate the error and the reason {"code":"error", "reason":"explain why it was failed to parse"}.
21751
21763
  `;
21752
21764
  };
21753
- async function getOpenAICompletion(config, prompt, model) {
21765
+ async function getOpenAICompletion(config, prompt, model, dateFormat) {
21754
21766
  const text = 'Parse the text delimited by triple backticks: ```' + prompt.trim() + '``` and make sure the output is a valid JSON object';
21755
- const role = getRole(config);
21767
+ const role = getRole(config, dateFormat);
21756
21768
  const completion = await getCompletion(text, role, config.openaiApiKey, model);
21757
21769
  const response = JSON.parse(completion);
21758
21770
  if ('code' in response) {
@@ -21769,11 +21781,25 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
21769
21781
  const {
21770
21782
  className,
21771
21783
  nlpFilterConfig,
21772
- onFilterModelChange
21784
+ onFilterModelChange,
21785
+ dateFormat = DEFAULT_PROPS$1.dateFormat,
21786
+ defaultModel = DEFAULT_PROPS$1.defaultModel,
21787
+ defaultFilter = DEFAULT_PROPS$1.defaultFilter,
21788
+ disablePower = DEFAULT_PROPS$1.disablePower,
21789
+ localeText
21773
21790
  } = props,
21774
21791
  forwardedProps = _objectWithoutProperties(props, _excluded$e);
21792
+ const {
21793
+ textLabel,
21794
+ textPlaceholder,
21795
+ buttonAriaLabel,
21796
+ buttonText,
21797
+ powerText,
21798
+ powerTooltipContent,
21799
+ errorText
21800
+ } = _objectSpread2(_objectSpread2({}, DEFAULT_PROPS$1.localeText), localeText);
21775
21801
  const [prompt, setPrompt] = useState('');
21776
- const modelRef = useRef(DEFAULT_GPT_MODEL);
21802
+ const modelRef = useRef(defaultModel);
21777
21803
  const showErrorRef = useRef(false);
21778
21804
  const [isLoading, setIsLoading] = useState(false);
21779
21805
  const handlePromptSubmit = async event => {
@@ -21784,7 +21810,7 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
21784
21810
  // Use the cache if it's available and it's not the default filter.
21785
21811
  // We still want to rerun default filter because it might be due to request fail.
21786
21812
  const response = sessionStorage.getItem(prompt);
21787
- if (response && response !== JSON.stringify(DEFAULT_FILTER)) {
21813
+ if (response && response !== JSON.stringify(defaultFilter)) {
21788
21814
  filter = JSON.parse(response);
21789
21815
  } else {
21790
21816
  setIsLoading(true);
@@ -21793,12 +21819,12 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
21793
21819
  if (nlpFilterConfig.completionFunc !== undefined) {
21794
21820
  filter = await nlpFilterConfig.completionFunc(nlpFilterConfig, prompt, modelRef.current);
21795
21821
  } else {
21796
- filter = await getOpenAICompletion(nlpFilterConfig, prompt, modelRef.current);
21822
+ filter = await getOpenAICompletion(nlpFilterConfig, prompt, modelRef.current, dateFormat);
21797
21823
  }
21798
21824
  sessionStorage.setItem(prompt, JSON.stringify(filter));
21799
21825
  } catch (error) {
21800
21826
  showErrorRef.current = true;
21801
- filter = DEFAULT_FILTER;
21827
+ filter = defaultFilter;
21802
21828
  }
21803
21829
 
21804
21830
  // MUI requires different id
@@ -21821,25 +21847,26 @@ const GridToolbarFilterSemanticField = /*#__PURE__*/forwardRef((props, ref) => {
21821
21847
  width: "100%"
21822
21848
  }, /*#__PURE__*/React__default.createElement(TextField$2, {
21823
21849
  width: "100%",
21824
- label: "Semantic filtering",
21825
- placeholder: "Describe here how you would like to filter this datagrid.",
21850
+ label: textLabel,
21851
+ placeholder: textPlaceholder,
21826
21852
  onChange: value => setPrompt(value),
21827
21853
  value: prompt
21828
21854
  }), /*#__PURE__*/React__default.createElement(Button, {
21829
21855
  variant: "primary",
21830
- "aria-label": "Submit",
21856
+ "aira-label": buttonAriaLabel,
21831
21857
  type: "submit",
21832
21858
  isLoading: isLoading
21833
- }, "Run")), /*#__PURE__*/React__default.createElement(Tooltip, null, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, /*#__PURE__*/React__default.createElement(Switch, {
21859
+ }, buttonText)), !disablePower && /*#__PURE__*/React__default.createElement(Tooltip, null, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, /*#__PURE__*/React__default.createElement(Switch, {
21834
21860
  width: "175px",
21835
21861
  isSelected: modelRef.current === 'gpt-4-0613',
21836
21862
  onChange: value => modelRef.current = value ? 'gpt-4-0613' : 'gpt-3.5-turbo-0613'
21837
- }, "Power mode")), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, "The Power mode can get better results but is slower."))), showErrorRef.current && /*#__PURE__*/React__default.createElement(Text, {
21863
+ }, powerText)), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, powerTooltipContent))), showErrorRef.current && /*#__PURE__*/React__default.createElement(Text, {
21838
21864
  color: "error",
21839
21865
  marginLeft: "8px"
21840
- }, "Unable to find a valid filter, please try again with a more specific prompt."));
21866
+ }, errorText));
21841
21867
  });
21842
21868
  GridToolbarFilterSemanticField.className = CLASSNAME$2;
21869
+ GridToolbarFilterSemanticField.defaultProps = DEFAULT_PROPS$1;
21843
21870
  GridToolbarFilterSemanticField.displayName = COMPONENT_NAME$2;
21844
21871
 
21845
21872
  /**
@@ -21863,9 +21890,12 @@ const Toolbar$2 = props => {
21863
21890
  hasDensityButton = true,
21864
21891
  densityButtonProps,
21865
21892
  densityButtonRef,
21866
- nlpFilterConfig = undefined,
21867
- onFilterModelChange
21893
+ onFilterModelChange,
21894
+ semanticFilterProps = undefined
21868
21895
  } = props;
21896
+ if (semanticFilterProps && onFilterModelChange) {
21897
+ semanticFilterProps.onFilterModelChange = onFilterModelChange;
21898
+ }
21869
21899
  return /*#__PURE__*/React__default.createElement(GridToolbarWrapper, null, /*#__PURE__*/React__default.createElement(GridToolbarContainer, null, /*#__PURE__*/React__default.createElement(Flexbox, {
21870
21900
  gap: "0"
21871
21901
  }, hasFilterButton ? /*#__PURE__*/React__default.createElement(GridToolbarFilterButton, _extends$2({}, filterButtonProps, {
@@ -21885,7 +21915,7 @@ const Toolbar$2 = props => {
21885
21915
  let {
21886
21916
  apiRef
21887
21917
  } = _ref;
21888
- return gridExpandedSortedRowIdsSelector(apiRef);
21918
+ return gridVisibleSortedRowIdsSelector(apiRef);
21889
21919
  }
21890
21920
  },
21891
21921
  printOptions: {
@@ -21896,10 +21926,7 @@ const Toolbar$2 = props => {
21896
21926
  className: filterButtonProps !== null && filterButtonProps !== void 0 && filterButtonProps.className ? `${filterButtonProps === null || filterButtonProps === void 0 ? void 0 : filterButtonProps.className} redsift-condensed` : 'redsift-condensed'
21897
21927
  })) : null), /*#__PURE__*/React__default.createElement(Flexbox, {
21898
21928
  flexGrow: 3
21899
- }, nlpFilterConfig && onFilterModelChange ? /*#__PURE__*/React__default.createElement(GridToolbarFilterSemanticField, {
21900
- nlpFilterConfig: nlpFilterConfig,
21901
- onFilterModelChange: onFilterModelChange
21902
- }) : null)));
21929
+ }, semanticFilterProps ? /*#__PURE__*/React__default.createElement(GridToolbarFilterSemanticField, semanticFilterProps) : null)));
21903
21930
  };
21904
21931
 
21905
21932
  const _excluded$d = ["displayName"];
@@ -24340,7 +24367,7 @@ process.env.NODE_ENV !== "production" ? TablePagination.propTypes /* remove-prop
24340
24367
  } : void 0;
24341
24368
  var TablePagination$1 = TablePagination;
24342
24369
 
24343
- const _excluded$1 = ["apiRef", "autoHeight", "className", "slots", "slotProps", "filterModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "paginationModel", "onPaginationModelChange", "onRowSelectionModelChange", "pagination", "paginationPlacement", "paginationProps", "rows", "pageSizeOptions", "sx"];
24370
+ const _excluded$1 = ["apiRef", "autoHeight", "className", "components", "componentsProps", "filterModel", "height", "hideToolbar", "initialState", "isRowSelectable", "license", "onFilterModelChange", "onPageChange", "onPageSizeChange", "onSelectionModelChange", "page", "pageSize", "pagination", "paginationPlacement", "paginationProps", "rows", "rowsPerPageOptions", "sx"];
24344
24371
  const COMPONENT_NAME$1 = 'DataGrid';
24345
24372
  const CLASSNAME$1 = 'redsift-datagrid';
24346
24373
  const DEFAULT_PROPS = {
@@ -24369,9 +24396,11 @@ const ControlledPagination = _ref3 => {
24369
24396
  displayPagination = false,
24370
24397
  selectionStatus,
24371
24398
  apiRef,
24372
- paginationModel,
24373
- onPaginationModelChange,
24374
- pageSizeOptions,
24399
+ page,
24400
+ onPageChange,
24401
+ pageSize,
24402
+ onPageSizeChange,
24403
+ rowsPerPageOptions,
24375
24404
  isRowSelectable,
24376
24405
  paginationProps
24377
24406
  } = _ref3;
@@ -24401,28 +24430,24 @@ const ControlledPagination = _ref3 => {
24401
24430
  }, `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$2({
24402
24431
  component: "div",
24403
24432
  count: numberOfFilteredRowsInTable,
24404
- page: paginationModel.page,
24405
- onPageChange: (event, page) => onPaginationModelChange({
24406
- page,
24407
- pageSize: paginationModel.pageSize
24408
- }),
24409
- rowsPerPage: paginationModel.pageSize,
24410
- onRowsPerPageChange: event => onPaginationModelChange({
24411
- page: paginationModel.page,
24412
- pageSize: parseInt(event.target.value, 10)
24413
- }),
24414
- rowsPerPageOptions: displayRowsPerPage ? pageSizeOptions : []
24433
+ page: page,
24434
+ onPageChange: (event, newPage) => onPageChange(newPage),
24435
+ rowsPerPage: pageSize,
24436
+ onRowsPerPageChange: event => {
24437
+ onPageSizeChange(parseInt(event.target.value, 10));
24438
+ },
24439
+ rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
24415
24440
  }, paginationProps)) : null);
24416
24441
  };
24417
24442
  const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24418
- var _ref4, _ref5, _initialState$paginat, _initialState$paginat2, _initialState$paginat3, _pageSizeOptions$, _ref6, _initialState$paginat4, _initialState$paginat5, _initialState$paginat6;
24443
+ var _initialState$paginat, _initialState$paginat2;
24419
24444
  const datagridRef = ref || useRef();
24420
24445
  const {
24421
24446
  apiRef: propsApiRef,
24422
24447
  autoHeight,
24423
24448
  className,
24424
- slots,
24425
- slotProps,
24449
+ components,
24450
+ componentsProps,
24426
24451
  filterModel: propsFilterModel,
24427
24452
  height: propsHeight,
24428
24453
  hideToolbar,
@@ -24430,20 +24455,22 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24430
24455
  isRowSelectable,
24431
24456
  license,
24432
24457
  onFilterModelChange: propsOnFilterModelChange,
24433
- paginationModel: propsPaginationModel,
24434
- onPaginationModelChange: propsOnPaginationModelChange,
24435
- onRowSelectionModelChange,
24458
+ onPageChange: propsOnPageChange,
24459
+ onPageSizeChange: propsOnPageSizeChange,
24460
+ onSelectionModelChange,
24461
+ page: propsPage,
24462
+ pageSize: propsPageSize,
24436
24463
  pagination,
24437
24464
  paginationPlacement,
24438
24465
  paginationProps,
24439
24466
  rows,
24440
- pageSizeOptions,
24467
+ rowsPerPageOptions,
24441
24468
  sx
24442
24469
  } = props,
24443
24470
  forwardedProps = _objectWithoutProperties(props, _excluded$1);
24444
24471
  const _apiRef = useGridApiRef();
24445
24472
  const apiRef = propsApiRef !== null && propsApiRef !== void 0 ? propsApiRef : _apiRef;
24446
- const RenderedToolbar = slots !== null && slots !== void 0 && slots.toolbar ? slots.toolbar : Toolbar$2;
24473
+ const RenderedToolbar = components !== null && components !== void 0 && components.Toolbar ? components.Toolbar : Toolbar$2;
24447
24474
  LicenseInfo.setLicenseKey(license);
24448
24475
  const height = propsHeight !== null && propsHeight !== void 0 ? propsHeight : autoHeight ? undefined : '500px';
24449
24476
  const selectionStatus = useRef({
@@ -24461,22 +24488,33 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24461
24488
  setFilterModel(model);
24462
24489
  }
24463
24490
  };
24464
- const [paginationModel, setPaginationModel] = useState({
24465
- pageSize: (_ref4 = (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : 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 && _ref4 !== void 0 ? _ref4 : 100,
24466
- page: (_ref6 = (_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 && _ref6 !== void 0 ? _ref6 : 0
24467
- });
24468
- const onPaginationModelChange = model => {
24469
- if (propsOnPaginationModelChange) {
24470
- propsOnPaginationModelChange(model, undefined);
24491
+ 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);
24492
+ 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);
24493
+ const onPageChange = page => {
24494
+ if (propsOnPageChange) {
24495
+ propsOnPageChange(page, undefined);
24496
+ } else {
24497
+ setPage(page);
24498
+ }
24499
+ };
24500
+ useEffect(() => {
24501
+ if (propsPage || propsPage === 0) {
24502
+ setPage(propsPage);
24503
+ }
24504
+ }, [propsPage]);
24505
+ const onPageSizeChange = pageSize => {
24506
+ onPageChange(0);
24507
+ if (propsOnPageSizeChange) {
24508
+ propsOnPageSizeChange(pageSize, undefined);
24471
24509
  } else {
24472
- setPaginationModel(model);
24510
+ setPageSize(pageSize);
24473
24511
  }
24474
24512
  };
24475
24513
  useEffect(() => {
24476
- if (propsPaginationModel) {
24477
- setPaginationModel(propsPaginationModel);
24514
+ if (propsPageSize) {
24515
+ setPageSize(propsPageSize);
24478
24516
  }
24479
- }, [propsPaginationModel]);
24517
+ }, [propsPageSize]);
24480
24518
  if (!Array.isArray(rows)) {
24481
24519
  return null;
24482
24520
  }
@@ -24488,46 +24526,46 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24488
24526
  apiRef: apiRef,
24489
24527
  autoHeight: autoHeight,
24490
24528
  checkboxSelectionVisibleOnly: Boolean(pagination),
24491
- slots: _objectSpread2(_objectSpread2({
24492
- baseButton: BaseButton,
24493
- baseCheckbox: BaseCheckbox,
24494
- // baseTextField,
24495
- basePopper: BasePopper,
24496
- columnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24529
+ components: _objectSpread2(_objectSpread2({
24530
+ BaseButton,
24531
+ BaseCheckbox,
24532
+ // BaseTextField,
24533
+ BasePopper,
24534
+ ColumnFilteredIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24497
24535
  displayName: "ColumnFilteredIcon"
24498
24536
  })),
24499
- columnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24537
+ ColumnSelectorIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24500
24538
  displayName: "ColumnSelectorIcon"
24501
24539
  })),
24502
- columnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24540
+ ColumnSortedAscendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24503
24541
  displayName: "ColumnSortedAscendingIcon"
24504
24542
  })),
24505
- columnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24543
+ ColumnSortedDescendingIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24506
24544
  displayName: "ColumnSortedDescendingIcon"
24507
24545
  })),
24508
- densityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24546
+ DensityCompactIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24509
24547
  displayName: "DensityCompactIcon"
24510
24548
  })),
24511
- densityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24549
+ DensityStandardIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24512
24550
  displayName: "DensityStandardIcon"
24513
24551
  })),
24514
- densityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24552
+ DensityComfortableIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24515
24553
  displayName: "DensityComfortableIcon"
24516
24554
  })),
24517
- detailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24555
+ DetailPanelCollapseIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24518
24556
  displayName: "DetailPanelCollapseIcon"
24519
24557
  })),
24520
- detailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24558
+ DetailPanelExpandIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24521
24559
  displayName: "DetailPanelExpandIcon"
24522
24560
  })),
24523
- exportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24561
+ ExportIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({}, props, {
24524
24562
  displayName: "ExportIcon"
24525
24563
  })),
24526
- openFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({
24564
+ OpenFilterButtonIcon: props => /*#__PURE__*/React__default.createElement(BaseIcon, _extends$2({
24527
24565
  displayName: "OpenFilterButtonIcon"
24528
24566
  }, props))
24529
- }, slots), {}, {
24530
- toolbar: props => {
24567
+ }, components), {}, {
24568
+ Toolbar: props => {
24531
24569
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !hideToolbar ? /*#__PURE__*/React__default.createElement(RenderedToolbar, _extends$2({}, props, {
24532
24570
  filterModel: filterModel,
24533
24571
  onFilterModelChange: onFilterModelChange
@@ -24538,27 +24576,31 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24538
24576
  selectionStatus: selectionStatus.current,
24539
24577
  apiRef: apiRef,
24540
24578
  isRowSelectable: isRowSelectable,
24541
- paginationModel: paginationModel,
24542
- onPaginationModelChange: onPaginationModelChange,
24543
- pageSizeOptions: pageSizeOptions,
24579
+ page: page,
24580
+ onPageChange: onPageChange,
24581
+ pageSize: pageSize,
24582
+ onPageSizeChange: onPageSizeChange,
24583
+ rowsPerPageOptions: rowsPerPageOptions,
24544
24584
  paginationProps: paginationProps
24545
24585
  }) : null);
24546
24586
  },
24547
- pagination: props => pagination ? /*#__PURE__*/React__default.createElement(ControlledPagination, _extends$2({}, props, {
24587
+ Pagination: props => pagination ? /*#__PURE__*/React__default.createElement(ControlledPagination, _extends$2({}, props, {
24548
24588
  displaySelection: false,
24549
24589
  displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
24550
24590
  displayPagination: ['bottom', 'both'].includes(paginationPlacement),
24551
24591
  selectionStatus: selectionStatus.current,
24552
24592
  apiRef: apiRef,
24553
24593
  isRowSelectable: isRowSelectable,
24554
- paginationModel: paginationModel,
24555
- onPaginationModelChange: onPaginationModelChange,
24556
- pageSizeOptions: pageSizeOptions,
24594
+ page: page,
24595
+ onPageChange: onPageChange,
24596
+ pageSize: pageSize,
24597
+ onPageSizeChange: onPageSizeChange,
24598
+ rowsPerPageOptions: rowsPerPageOptions,
24557
24599
  paginationProps: paginationProps
24558
24600
  })) : null
24559
24601
  }),
24560
- slotProps: _objectSpread2(_objectSpread2({}, slotProps), {}, {
24561
- toolbar: _objectSpread2({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.toolbar)
24602
+ componentsProps: _objectSpread2(_objectSpread2({}, componentsProps), {}, {
24603
+ toolbar: _objectSpread2({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbar)
24562
24604
  }),
24563
24605
  filterModel: filterModel,
24564
24606
  initialState: initialState,
@@ -24566,38 +24608,40 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24566
24608
  onFilterModelChange: onFilterModelChange,
24567
24609
  pagination: pagination,
24568
24610
  rows: rows,
24569
- pageSizeOptions: pageSizeOptions,
24570
- paginationModel: paginationModel,
24571
- onPaginationModelChange: onPaginationModelChange,
24572
- onRowSelectionModelChange: (newSelectionModel, details) => {
24611
+ rowsPerPageOptions: rowsPerPageOptions,
24612
+ page: page,
24613
+ onPageChange: onPageChange,
24614
+ pageSize: pageSize,
24615
+ onPageSizeChange: onPageSizeChange,
24616
+ onSelectionModelChange: (newSelectionModel, details) => {
24573
24617
  if (pagination) {
24574
- const selectableRowsInPage = props.isRowSelectable && typeof props.isRowSelectable === 'function' ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref7 => {
24618
+ const selectableRowsInPage = props.isRowSelectable && typeof props.isRowSelectable === 'function' ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref4 => {
24575
24619
  var _props$isRowSelectabl;
24576
24620
  let {
24577
24621
  model
24578
- } = _ref7;
24622
+ } = _ref4;
24579
24623
  return (_props$isRowSelectabl = props.isRowSelectable) === null || _props$isRowSelectabl === void 0 ? void 0 : _props$isRowSelectabl.call(props, {
24580
24624
  row: model
24581
24625
  });
24582
- }).map(_ref8 => {
24626
+ }).map(_ref5 => {
24583
24627
  let {
24584
24628
  id
24585
- } = _ref8;
24629
+ } = _ref5;
24586
24630
  return id;
24587
24631
  }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
24588
24632
  const numberOfSelectableRowsInPage = selectableRowsInPage.length;
24589
- const selectableRowsInTable = props.isRowSelectable && typeof props.isRowSelectable === 'function' ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref9 => {
24633
+ const selectableRowsInTable = props.isRowSelectable && typeof props.isRowSelectable === 'function' ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref6 => {
24590
24634
  var _props$isRowSelectabl2;
24591
24635
  let {
24592
24636
  model
24593
- } = _ref9;
24637
+ } = _ref6;
24594
24638
  return (_props$isRowSelectabl2 = props.isRowSelectable) === null || _props$isRowSelectabl2 === void 0 ? void 0 : _props$isRowSelectabl2.call(props, {
24595
24639
  row: model
24596
24640
  });
24597
- }).map(_ref10 => {
24641
+ }).map(_ref7 => {
24598
24642
  let {
24599
24643
  id
24600
- } = _ref10;
24644
+ } = _ref7;
24601
24645
  return id;
24602
24646
  }) : gridFilteredSortedRowIdsSelector(apiRef);
24603
24647
  const numberOfSelectableRowsInTable = selectableRowsInTable.length;
@@ -24629,7 +24673,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24629
24673
  };
24630
24674
  }
24631
24675
  }
24632
- onRowSelectionModelChange === null || onRowSelectionModelChange === void 0 ? void 0 : onRowSelectionModelChange(newSelectionModel, details);
24676
+ onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel, details);
24633
24677
  },
24634
24678
  sx: _objectSpread2(_objectSpread2({}, sx), {}, {
24635
24679
  '.MuiDataGrid-columnHeaders': {