@redsift/table 10.3.0-muiv5-alpha.0 → 10.3.0-muiv5-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,8 +1,8 @@
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';
1
+ import { GRID_DETAIL_PANEL_TOGGLE_COL_DEF, getGridNumericOperators as getGridNumericOperators$1, GridFilterInputMultipleValue, getGridStringOperators as getGridStringOperators$1, GridToolbarContainer, GridToolbarFilterButton, GridToolbarColumnsButton, GridToolbarDensitySelector, GridToolbarExport, gridVisibleSortedRowIdsSelector, gridPaginatedVisibleSortedGridRowEntriesSelector, gridPaginatedVisibleSortedGridRowIdsSelector, gridFilteredSortedRowEntriesSelector, gridFilteredSortedRowIdsSelector, useGridApiRef, DataGridPro } from '@mui/x-data-grid-pro';
2
2
  export { getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
3
3
  import * as React from 'react';
4
4
  import React__default, { Children, isValidElement, cloneElement, useLayoutEffect, useEffect, useRef, forwardRef, useContext, useState, useCallback, createElement, useMemo } from 'react';
5
- import { Icon, baseContainer, Theme, AppContainerContext, useTheme as useTheme$4, useId as useId$2, partitionComponents, isComponent, Flexbox, TextField as TextField$2, Button, Switch, Text, ButtonsColorPalette, IconButton as IconButton$2, Checkbox, ThemeProvider as ThemeProvider$4, LinkButton, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite, Shield } from '@redsift/design-system';
5
+ import { Icon, baseContainer, Theme, AppContainerContext, useTheme as useTheme$4, useId as useId$2, partitionComponents, isComponent, Flexbox, TextField as TextField$2, Button, Switch, Text, ButtonsColorPalette, IconButton as IconButton$2, Checkbox, LinkButton, ThemeProvider as ThemeProvider$4, RedsiftColorBlueN, RedsiftColorNeutralXDarkGrey, RedsiftColorNeutralWhite, Shield } from '@redsift/design-system';
6
6
  import { mdiSync, mdiFilterVariant, mdiViewColumn, mdiChevronUp, mdiChevronDown, mdiViewHeadline, mdiViewSequential, mdiViewStream, mdiChevronRight, mdiTrayArrowDown } from '@redsift/icons';
7
7
  import emStyled from '@emotion/styled';
8
8
  import { Global, ThemeContext as ThemeContext$3, keyframes } from '@emotion/react';
@@ -17870,76 +17870,6 @@ class LicenseInfo {
17870
17870
  }
17871
17871
  }
17872
17872
 
17873
- /**
17874
- * Component style.
17875
- */
17876
- const StyledDataGrid = styled$3.div`
17877
- ${_ref => {
17878
- let {
17879
- $height
17880
- } = _ref;
17881
- return $height ? css`
17882
- height: ${$height};
17883
- ` : '';
17884
- }}
17885
-
17886
- width: 100%;
17887
-
17888
- .MuiDataGrid-root {
17889
- font-family: var(--redsift-typography-datagrid-header-font-family);
17890
- border: none;
17891
- }
17892
-
17893
- .MuiDataGrid-row {
17894
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17895
- font-size: var(--redsift-typography-datagrid-cell-font-size);
17896
- font-weight: var(--redsift-typography-datagrid-cell-font-weight);
17897
- }
17898
-
17899
- .MuiDataGrid-columnHeaderTitle {
17900
- font-family: var(--redsift-typography-datagrid-header-font-family);
17901
- font-size: var(--redsift-typography-datagrid-header-font-size);
17902
- font-weight: var(--redsift-typography-datagrid-header-font-weight);
17903
- }
17904
-
17905
- .MuiDataGrid-columnHeaders {
17906
- border-bottom-color: var(--redsift-color-primary-n);
17907
- }
17908
-
17909
- .MuiDataGrid-columnSeparator {
17910
- display: none;
17911
- }
17912
-
17913
- .MuiTablePagination-root {
17914
- .MuiTablePagination-selectLabel {
17915
- font-family: var(--redsift-typography-datagrid-header-font-family);
17916
- }
17917
- .MuiTablePagination-displayedRows {
17918
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17919
- }
17920
-
17921
- .MuiInputBase-root {
17922
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17923
- }
17924
- }
17925
-
17926
- .Mui-checked {
17927
- color: var(--redsift-color-primary-n);
17928
- }
17929
-
17930
- .MuiDataGrid-rowCount {
17931
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17932
- }
17933
-
17934
- .MuiTablePagination-displayedRows {
17935
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17936
- }
17937
-
17938
- .MuiBadge-standard {
17939
- font-family: var(--redsift-typography-datagrid-cell-font-family);
17940
- }
17941
- `;
17942
-
17943
17873
  /**
17944
17874
  * Component style.
17945
17875
  */
@@ -21755,7 +21685,8 @@ const TooltipTrigger = /*#__PURE__*/forwardRef((props, ref) => {
21755
21685
  const {
21756
21686
  getReferenceProps,
21757
21687
  refs,
21758
- tooltipId
21688
+ tooltipId,
21689
+ triggerClassName
21759
21690
  } = useTooltipContext();
21760
21691
  const childrenRef = children.ref;
21761
21692
  const triggerRef = useMergeRefs([refs.setReference, ref, childrenRef]);
@@ -21766,7 +21697,8 @@ const TooltipTrigger = /*#__PURE__*/forwardRef((props, ref) => {
21766
21697
  }, props), {}, {
21767
21698
  'aria-describedby': tooltipId
21768
21699
  }, children.props), {}, {
21769
- children: (_children$props$child = children.props.children) !== null && _children$props$child !== void 0 ? _children$props$child : ''
21700
+ children: (_children$props$child = children.props.children) !== null && _children$props$child !== void 0 ? _children$props$child : '',
21701
+ className: classNames(children.props.className, triggerClassName)
21770
21702
  }))));
21771
21703
  }
21772
21704
  return /*#__PURE__*/React__default.createElement("span", _extends$2({
@@ -21784,7 +21716,8 @@ function useTooltip(_ref) {
21784
21716
  placement,
21785
21717
  isOpen: propsIsOpen,
21786
21718
  onOpen,
21787
- tooltipId: propsTooltipId
21719
+ tooltipId: propsTooltipId,
21720
+ triggerClassName
21788
21721
  } = _ref;
21789
21722
  const arrowRef = useRef(null);
21790
21723
  const [isOpen, setIsOpen] = useState(propsIsOpen !== null && propsIsOpen !== void 0 ? propsIsOpen : defaultOpen);
@@ -21834,8 +21767,9 @@ function useTooltip(_ref) {
21834
21767
  handleOpen
21835
21768
  }, interactions), data), {}, {
21836
21769
  arrowRef,
21837
- tooltipId
21838
- }), [isOpen, handleOpen, interactions, data, arrowRef, tooltipId]);
21770
+ tooltipId,
21771
+ triggerClassName
21772
+ }), [isOpen, handleOpen, interactions, data, arrowRef, tooltipId, triggerClassName]);
21839
21773
  }
21840
21774
 
21841
21775
  const ThemeContext = /*#__PURE__*/React__default.createContext(null);
@@ -21860,7 +21794,8 @@ const BaseTooltip = props => {
21860
21794
  onOpen,
21861
21795
  placement,
21862
21796
  tooltipId,
21863
- theme: propsTheme
21797
+ theme: propsTheme,
21798
+ triggerClassName
21864
21799
  } = props;
21865
21800
  const theme = useTheme$4 ? useTheme$4(propsTheme) : undefined;
21866
21801
  const tooltip = useTooltip({
@@ -21870,7 +21805,8 @@ const BaseTooltip = props => {
21870
21805
  isOpen,
21871
21806
  onOpen,
21872
21807
  tooltipId,
21873
- theme
21808
+ theme,
21809
+ triggerClassName
21874
21810
  });
21875
21811
  const [[trigger], [content]] = partitionComponents(React__default.Children.toArray(children), [isComponent('TooltipTrigger'), isComponent('TooltipContent')]);
21876
21812
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
@@ -22154,33 +22090,7 @@ const Toolbar$3 = props => {
22154
22090
  }, semanticFilterProps ? /*#__PURE__*/React__default.createElement(GridToolbarFilterSemanticField, semanticFilterProps) : null)));
22155
22091
  };
22156
22092
 
22157
- const _excluded$d = ["displayName"];
22158
- const muiIconToDSIcon = {
22159
- ColumnFilteredIcon: mdiFilterVariant,
22160
- ColumnSelectorIcon: mdiViewColumn,
22161
- ColumnSortedAscendingIcon: mdiChevronUp,
22162
- ColumnSortedDescendingIcon: mdiChevronDown,
22163
- DensityCompactIcon: mdiViewHeadline,
22164
- DensityStandardIcon: mdiViewSequential,
22165
- DensityComfortableIcon: mdiViewStream,
22166
- DetailPanelCollapseIcon: mdiChevronDown,
22167
- DetailPanelExpandIcon: mdiChevronRight,
22168
- ExportIcon: mdiTrayArrowDown,
22169
- OpenFilterButtonIcon: mdiFilterVariant
22170
- };
22171
- const BaseIcon = /*#__PURE__*/forwardRef((props, ref) => {
22172
- const {
22173
- displayName
22174
- } = props,
22175
- forwardedProps = _objectWithoutProperties(props, _excluded$d);
22176
- return /*#__PURE__*/React__default.createElement(Icon, _extends$2({}, forwardedProps, forwardedProps.inputProps, {
22177
- ref: ref,
22178
- size: forwardedProps.fontSize,
22179
- icon: muiIconToDSIcon[displayName]
22180
- }));
22181
- });
22182
-
22183
- const _excluded$c = ["children", "color", "onClick", "startIcon"];
22093
+ const _excluded$d = ["children", "color", "onClick", "startIcon"];
22184
22094
  const BaseButton = /*#__PURE__*/forwardRef((props, ref) => {
22185
22095
  var _props$className;
22186
22096
  const {
@@ -22189,7 +22099,7 @@ const BaseButton = /*#__PURE__*/forwardRef((props, ref) => {
22189
22099
  onClick,
22190
22100
  startIcon
22191
22101
  } = props,
22192
- forwardedProps = _objectWithoutProperties(props, _excluded$c);
22102
+ forwardedProps = _objectWithoutProperties(props, _excluded$d);
22193
22103
  const color = Object.keys(ButtonsColorPalette).includes(propsColor) ? propsColor : 'primary';
22194
22104
  if ((_props$className = props.className) !== null && _props$className !== void 0 && _props$className.includes('redsift-condensed')) {
22195
22105
  return /*#__PURE__*/React__default.createElement(IconButton$2, _extends$2({}, forwardedProps, {
@@ -22215,7 +22125,7 @@ const BaseButton = /*#__PURE__*/forwardRef((props, ref) => {
22215
22125
  }), children);
22216
22126
  });
22217
22127
 
22218
- const _excluded$b = ["checked", "indeterminate", "disabled", "onChange"];
22128
+ const _excluded$c = ["checked", "indeterminate", "disabled", "onChange"];
22219
22129
  const BaseCheckbox = /*#__PURE__*/forwardRef((props, ref) => {
22220
22130
  const {
22221
22131
  checked,
@@ -22223,7 +22133,7 @@ const BaseCheckbox = /*#__PURE__*/forwardRef((props, ref) => {
22223
22133
  disabled,
22224
22134
  onChange
22225
22135
  } = props,
22226
- forwardedProps = _objectWithoutProperties(props, _excluded$b);
22136
+ forwardedProps = _objectWithoutProperties(props, _excluded$c);
22227
22137
  return /*#__PURE__*/React__default.createElement(Checkbox, _extends$2({}, forwardedProps, forwardedProps.inputProps, {
22228
22138
  isSelected: checked && !indeterminate,
22229
22139
  isDisabled: disabled,
@@ -22233,6 +22143,32 @@ const BaseCheckbox = /*#__PURE__*/forwardRef((props, ref) => {
22233
22143
  }));
22234
22144
  });
22235
22145
 
22146
+ const _excluded$b = ["displayName"];
22147
+ const muiIconToDSIcon = {
22148
+ ColumnFilteredIcon: mdiFilterVariant,
22149
+ ColumnSelectorIcon: mdiViewColumn,
22150
+ ColumnSortedAscendingIcon: mdiChevronUp,
22151
+ ColumnSortedDescendingIcon: mdiChevronDown,
22152
+ DensityCompactIcon: mdiViewHeadline,
22153
+ DensityStandardIcon: mdiViewSequential,
22154
+ DensityComfortableIcon: mdiViewStream,
22155
+ DetailPanelCollapseIcon: mdiChevronDown,
22156
+ DetailPanelExpandIcon: mdiChevronRight,
22157
+ ExportIcon: mdiTrayArrowDown,
22158
+ OpenFilterButtonIcon: mdiFilterVariant
22159
+ };
22160
+ const BaseIcon = /*#__PURE__*/forwardRef((props, ref) => {
22161
+ const {
22162
+ displayName
22163
+ } = props,
22164
+ forwardedProps = _objectWithoutProperties(props, _excluded$b);
22165
+ return /*#__PURE__*/React__default.createElement(Icon, _extends$2({}, forwardedProps, forwardedProps.inputProps, {
22166
+ ref: ref,
22167
+ size: forwardedProps.fontSize,
22168
+ icon: muiIconToDSIcon[displayName]
22169
+ }));
22170
+ });
22171
+
22236
22172
  const _excluded$a = ["anchorEl", "component", "components", "componentsProps", "container", "disablePortal", "keepMounted", "modifiers", "open", "placement", "popperOptions", "popperRef", "transition", "slots", "slotProps"];
22237
22173
  const PopperRoot = styled$1(BasePopper$1, {
22238
22174
  name: 'MuiPopper',
@@ -22434,6 +22370,86 @@ const BasePopper = /*#__PURE__*/forwardRef((props, ref) => {
22434
22370
  }));
22435
22371
  });
22436
22372
 
22373
+ const defaultSxStyle = {
22374
+ '.MuiDataGrid-columnHeaders': {
22375
+ flexDirection: 'column',
22376
+ alignItems: 'normal'
22377
+ },
22378
+ '.MuiDataGrid-selectedRowCount': {
22379
+ margin: 'none'
22380
+ }
22381
+ };
22382
+
22383
+ /**
22384
+ * Component style.
22385
+ */
22386
+ const StyledDataGrid = styled$3.div`
22387
+ ${_ref => {
22388
+ let {
22389
+ $height
22390
+ } = _ref;
22391
+ return $height ? css`
22392
+ height: ${$height};
22393
+ ` : '';
22394
+ }}
22395
+
22396
+ width: 100%;
22397
+
22398
+ .MuiDataGrid-root {
22399
+ font-family: var(--redsift-typography-datagrid-header-font-family);
22400
+ border: none;
22401
+ }
22402
+
22403
+ .MuiDataGrid-row {
22404
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22405
+ font-size: var(--redsift-typography-datagrid-cell-font-size);
22406
+ font-weight: var(--redsift-typography-datagrid-cell-font-weight);
22407
+ }
22408
+
22409
+ .MuiDataGrid-columnHeaderTitle {
22410
+ font-family: var(--redsift-typography-datagrid-header-font-family);
22411
+ font-size: var(--redsift-typography-datagrid-header-font-size);
22412
+ font-weight: var(--redsift-typography-datagrid-header-font-weight);
22413
+ }
22414
+
22415
+ .MuiDataGrid-columnHeaders {
22416
+ border-bottom-color: var(--redsift-color-primary-n);
22417
+ }
22418
+
22419
+ .MuiDataGrid-columnSeparator {
22420
+ display: none;
22421
+ }
22422
+
22423
+ .MuiTablePagination-root {
22424
+ .MuiTablePagination-selectLabel {
22425
+ font-family: var(--redsift-typography-datagrid-header-font-family);
22426
+ }
22427
+ .MuiTablePagination-displayedRows {
22428
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22429
+ }
22430
+
22431
+ .MuiInputBase-root {
22432
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22433
+ }
22434
+ }
22435
+
22436
+ .Mui-checked {
22437
+ color: var(--redsift-color-primary-n);
22438
+ }
22439
+
22440
+ .MuiDataGrid-rowCount {
22441
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22442
+ }
22443
+
22444
+ .MuiTablePagination-displayedRows {
22445
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22446
+ }
22447
+
22448
+ .MuiBadge-standard {
22449
+ font-family: var(--redsift-typography-datagrid-cell-font-family);
22450
+ }
22451
+ `;
22452
+
22437
22453
  function Ripple(props) {
22438
22454
  const {
22439
22455
  className,
@@ -24592,14 +24608,149 @@ process.env.NODE_ENV !== "production" ? TablePagination.propTypes /* remove-prop
24592
24608
  } : void 0;
24593
24609
  var TablePagination$1 = TablePagination;
24594
24610
 
24595
- const _excluded$1 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "ControlledPagination", "paginationPlacement", "selectionStatus", "apiRef", "isRowSelectable", "page", "onPageChange", "pageSize", "onPageSizeChange", "rowsPerPageOptions", "paginationProps", "paginationMode", "rowCount"],
24596
- _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
- const COMPONENT_NAME$1 = 'DataGrid';
24598
- const CLASSNAME$1 = 'redsift-datagrid';
24599
- const DEFAULT_PROPS = {
24600
- license: process.env.MUI_LICENSE_KEY,
24601
- paginationPlacement: 'both'
24611
+ const ControlledPagination$1 = _ref => {
24612
+ let {
24613
+ apiRef,
24614
+ selectionStatus,
24615
+ setSelectionStatusType,
24616
+ selectionStatusType,
24617
+ displaySelection,
24618
+ displayPagination,
24619
+ page,
24620
+ onPageChange,
24621
+ pageSize,
24622
+ onPageSizeChange,
24623
+ displayRowsPerPage,
24624
+ rowsPerPageOptions,
24625
+ paginationProps,
24626
+ rowCount
24627
+ } = _ref;
24628
+ const totalNumberOfRowsInTable = rowCount;
24629
+ const totalRowsLabel = `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`;
24630
+ const pageRowsLabel = `All ${selectionStatus.numberOfSelectedRowsInPage} selectable rows on this page are selected${selectionStatus.numberOfSelectedRows != selectionStatus.numberOfSelectedRowsInPage ? ` (${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected in total)` : ''}.`;
24631
+ return /*#__PURE__*/React__default.createElement(Flexbox, {
24632
+ flexDirection: "row",
24633
+ alignItems: "center",
24634
+ justifyContent: "space-between",
24635
+ marginBottom: "7px"
24636
+ }, displaySelection ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, selectionStatusType === 'table' ? /*#__PURE__*/React__default.createElement(Text, {
24637
+ fontSize: "14px"
24638
+ }, "All selectable rows in the table are selected.", ' ', /*#__PURE__*/React__default.createElement(LinkButton, {
24639
+ onClick: () => {
24640
+ setSelectionStatusType('none');
24641
+ apiRef.current.selectRows([], false, true);
24642
+ }
24643
+ }, "Clear selection.")) : selectionStatus.type === 'page' && selectionStatus.numberOfSelectedRowsInPage != 0 ? /*#__PURE__*/React__default.createElement(Text, {
24644
+ fontSize: "14px"
24645
+ }, pageRowsLabel, ' ', /*#__PURE__*/React__default.createElement(LinkButton, {
24646
+ onClick: () => {
24647
+ setSelectionStatusType('table');
24648
+ }
24649
+ }, "Select all selectable rows in the table.")) : selectionStatus.type === 'other' ? /*#__PURE__*/React__default.createElement(Text, {
24650
+ fontSize: "14px"
24651
+ }, totalRowsLabel) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$2({
24652
+ component: "div",
24653
+ count: totalNumberOfRowsInTable,
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 : []
24661
+ }, paginationProps)) : null);
24602
24662
  };
24663
+
24664
+ const onServerSideSelectionStatusChange = _ref => {
24665
+ let {
24666
+ newSelectionModel,
24667
+ apiRef,
24668
+ selectionStatus,
24669
+ selectionStatusType,
24670
+ setSelectionStatusType,
24671
+ isRowSelectable,
24672
+ page,
24673
+ pageSize
24674
+ } = _ref;
24675
+ const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref2 => {
24676
+ let {
24677
+ model
24678
+ } = _ref2;
24679
+ return isRowSelectable({
24680
+ row: model
24681
+ });
24682
+ }).map(_ref3 => {
24683
+ let {
24684
+ id
24685
+ } = _ref3;
24686
+ return id;
24687
+ }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
24688
+ const numberOfSelectableRowsInPage = selectableRowsInPage.length;
24689
+ const numberOfSelectedRows = newSelectionModel.length;
24690
+ const selectedRowsInPage = selectableRowsInPage.filter(rowId => newSelectionModel.includes(rowId));
24691
+ const numberOfSelectedRowsInPage = selectedRowsInPage.length;
24692
+ const isSamePage = (selectionStatus === null || selectionStatus === void 0 ? void 0 : selectionStatus.current.page) == page;
24693
+ const isSamePageSize = (selectionStatus === null || selectionStatus === void 0 ? void 0 : selectionStatus.current.pageSize) == pageSize;
24694
+ if (selectionStatusType === 'table') {
24695
+ // if we just move across page or pageSize
24696
+ if (!isSamePage || !isSamePageSize) {
24697
+ selectionStatus.current = {
24698
+ type: 'table',
24699
+ numberOfSelectedRows,
24700
+ numberOfSelectedRowsInPage,
24701
+ page,
24702
+ pageSize
24703
+ };
24704
+ }
24705
+ // if we selected all selectable rows (as effect of the previous if condition)
24706
+ else if (numberOfSelectedRows > 0) {
24707
+ setSelectionStatusType('none');
24708
+ selectionStatus.current = {
24709
+ type: 'none',
24710
+ numberOfSelectedRows,
24711
+ numberOfSelectedRowsInPage,
24712
+ page,
24713
+ pageSize
24714
+ };
24715
+ apiRef.current.selectRows([], false, true);
24716
+ }
24717
+ return;
24718
+ }
24719
+ if (selectionStatusType === 'page' && isSamePage && isSamePageSize && numberOfSelectedRowsInPage === numberOfSelectableRowsInPage) {
24720
+ setTimeout(() => {
24721
+ apiRef.current.selectRows(selectedRowsInPage, false, false);
24722
+ }, 0);
24723
+ }
24724
+ if (numberOfSelectedRowsInPage === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage != 0) {
24725
+ setSelectionStatusType('page');
24726
+ selectionStatus.current = {
24727
+ type: 'page',
24728
+ numberOfSelectedRows,
24729
+ numberOfSelectedRowsInPage,
24730
+ page,
24731
+ pageSize
24732
+ };
24733
+ } else if (numberOfSelectedRows > 0) {
24734
+ setSelectionStatusType('other');
24735
+ selectionStatus.current = {
24736
+ type: 'other',
24737
+ numberOfSelectedRows,
24738
+ numberOfSelectedRowsInPage,
24739
+ page,
24740
+ pageSize
24741
+ };
24742
+ } else {
24743
+ setSelectionStatusType('none');
24744
+ selectionStatus.current = {
24745
+ type: 'none',
24746
+ numberOfSelectedRows,
24747
+ numberOfSelectedRowsInPage,
24748
+ page,
24749
+ pageSize
24750
+ };
24751
+ }
24752
+ };
24753
+
24603
24754
  const getSelectableRowsInTable = (apiRef, isRowSelectable) => {
24604
24755
  return isRowSelectable && typeof isRowSelectable === 'function' ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref => {
24605
24756
  let {
@@ -24615,7 +24766,8 @@ const getSelectableRowsInTable = (apiRef, isRowSelectable) => {
24615
24766
  return id;
24616
24767
  }) : gridFilteredSortedRowIdsSelector(apiRef);
24617
24768
  };
24618
- const ControlledPagination = _ref3 => {
24769
+
24770
+ const ControlledPagination = _ref => {
24619
24771
  let {
24620
24772
  displaySelection = false,
24621
24773
  displayRowsPerPage = false,
@@ -24629,7 +24781,7 @@ const ControlledPagination = _ref3 => {
24629
24781
  rowsPerPageOptions,
24630
24782
  isRowSelectable,
24631
24783
  paginationProps
24632
- } = _ref3;
24784
+ } = _ref;
24633
24785
  const filteredRowsInTable = getSelectableRowsInTable(apiRef);
24634
24786
  const selectableRowsInTable = getSelectableRowsInTable(apiRef, isRowSelectable);
24635
24787
  const numberOfFilteredRowsInTable = filteredRowsInTable.length;
@@ -24665,54 +24817,26 @@ const ControlledPagination = _ref3 => {
24665
24817
  rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
24666
24818
  }, paginationProps)) : null);
24667
24819
  };
24668
- const ServerSideControlledPagination = _ref4 => {
24669
- let {
24670
- selectionStatus,
24671
- displaySelection,
24672
- displayPagination,
24673
- page,
24674
- onPageChange,
24675
- pageSize,
24676
- onPageSizeChange,
24677
- displayRowsPerPage,
24678
- rowsPerPageOptions,
24679
- paginationProps,
24680
- rowCount
24681
- } = _ref4;
24682
- const totalNumberOfRowsInTable = rowCount;
24683
- const totalRowsLabel = `${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected`;
24684
- const pageRowsLabel = `All ${selectionStatus.numberOfSelectedRowsInPage} selectable rows on this page are selected${selectionStatus.numberOfSelectedRows != selectionStatus.numberOfSelectedRowsInPage ? ` (${selectionStatus.numberOfSelectedRows} row${selectionStatus.numberOfSelectedRows > 1 ? 's' : ''} selected in total)` : ''}.`;
24685
- return /*#__PURE__*/React__default.createElement(Flexbox, {
24686
- flexDirection: "row",
24687
- alignItems: "center",
24688
- justifyContent: "space-between",
24689
- marginBottom: "7px"
24690
- }, displaySelection ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, selectionStatus.type === 'page' && selectionStatus.numberOfSelectedRowsInPage != 0 ? /*#__PURE__*/React__default.createElement(Text, {
24691
- fontSize: "14px"
24692
- }, pageRowsLabel) : selectionStatus.type === 'other' ? /*#__PURE__*/React__default.createElement(Text, {
24693
- fontSize: "14px"
24694
- }, totalRowsLabel) : /*#__PURE__*/React__default.createElement(Text, null)) : null, displayPagination ? /*#__PURE__*/React__default.createElement(TablePagination$1, _extends$2({
24695
- component: "div",
24696
- count: totalNumberOfRowsInTable,
24697
- page: page,
24698
- onPageChange: (event, newPage) => onPageChange(newPage),
24699
- rowsPerPage: pageSize,
24700
- onRowsPerPageChange: event => {
24701
- onPageSizeChange(parseInt(event.target.value, 10));
24702
- },
24703
- rowsPerPageOptions: displayRowsPerPage ? rowsPerPageOptions : []
24704
- }, paginationProps)) : null);
24820
+
24821
+ const _excluded$1 = ["hideToolbar", "RenderedToolbar", "filterModel", "onFilterModelChange", "pagination", "paginationPlacement", "selectionStatus", "selectionStatusType", "setSelectionStatusType", "apiRef", "isRowSelectable", "page", "onPageChange", "pageSize", "onPageSizeChange", "rowsPerPageOptions", "paginationProps", "paginationMode", "rowCount"],
24822
+ _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", "onSelectionStatusChange"];
24823
+ const COMPONENT_NAME$1 = 'DataGrid';
24824
+ const CLASSNAME$1 = 'redsift-datagrid';
24825
+ const DEFAULT_PROPS = {
24826
+ license: process.env.MUI_LICENSE_KEY,
24827
+ paginationPlacement: 'both'
24705
24828
  };
24706
- const Toolbar = _ref5 => {
24829
+ const Toolbar = _ref => {
24707
24830
  let {
24708
24831
  hideToolbar,
24709
24832
  RenderedToolbar,
24710
24833
  filterModel,
24711
24834
  onFilterModelChange,
24712
24835
  pagination,
24713
- ControlledPagination,
24714
24836
  paginationPlacement,
24715
24837
  selectionStatus,
24838
+ selectionStatusType,
24839
+ setSelectionStatusType,
24716
24840
  apiRef,
24717
24841
  isRowSelectable,
24718
24842
  page,
@@ -24723,16 +24847,19 @@ const Toolbar = _ref5 => {
24723
24847
  paginationProps,
24724
24848
  paginationMode = 'client',
24725
24849
  rowCount
24726
- } = _ref5,
24727
- forwardedProps = _objectWithoutProperties(_ref5, _excluded$1);
24850
+ } = _ref,
24851
+ forwardedProps = _objectWithoutProperties(_ref, _excluded$1);
24728
24852
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !hideToolbar ? /*#__PURE__*/React__default.createElement(RenderedToolbar, _extends$2({}, forwardedProps, {
24729
24853
  filterModel: filterModel,
24730
24854
  onFilterModelChange: onFilterModelChange
24731
- })) : null, pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, {
24855
+ })) : null, pagination ? paginationMode === 'server' ? /*#__PURE__*/React__default.createElement(ControlledPagination$1, {
24856
+ apiRef: apiRef,
24732
24857
  displaySelection: true,
24733
24858
  displayRowsPerPage: false,
24734
24859
  displayPagination: ['top', 'both'].includes(paginationPlacement),
24735
24860
  selectionStatus: selectionStatus.current,
24861
+ setSelectionStatusType: setSelectionStatusType,
24862
+ selectionStatusType: selectionStatusType,
24736
24863
  page: page,
24737
24864
  onPageChange: onPageChange,
24738
24865
  pageSize: pageSize,
@@ -24755,61 +24882,6 @@ const Toolbar = _ref5 => {
24755
24882
  paginationProps: paginationProps
24756
24883
  }) : null);
24757
24884
  };
24758
- const onServerSideSelectionStatusChange = (newSelectionModel, apiRef, selectionStatus, isRowSelectable, page, pageSize) => {
24759
- const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref6 => {
24760
- let {
24761
- model
24762
- } = _ref6;
24763
- return isRowSelectable({
24764
- row: model
24765
- });
24766
- }).map(_ref7 => {
24767
- let {
24768
- id
24769
- } = _ref7;
24770
- return id;
24771
- }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
24772
- const numberOfSelectableRowsInPage = selectableRowsInPage.length;
24773
- const numberOfSelectedRows = newSelectionModel.length;
24774
- const selectedRowsInPage = selectableRowsInPage.filter(rowId => newSelectionModel.includes(rowId));
24775
- const numberOfSelectedRowsInPage = selectedRowsInPage.length;
24776
- const isSamePage = (selectionStatus === null || selectionStatus === void 0 ? void 0 : selectionStatus.current.page) == page;
24777
- const isSamePageSize = (selectionStatus === null || selectionStatus === void 0 ? void 0 : selectionStatus.current.pageSize) == pageSize;
24778
-
24779
- // if previous status is `page`,
24780
- // if page and pageSize didn't change
24781
- // and all the rows are selected, deselect all row
24782
- if (selectionStatus.current.type === 'page' && isSamePage && isSamePageSize && numberOfSelectedRowsInPage === numberOfSelectableRowsInPage) {
24783
- setTimeout(() => {
24784
- apiRef.current.selectRows(selectedRowsInPage, false, false);
24785
- }, 0);
24786
- }
24787
- if (numberOfSelectedRowsInPage === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage != 0) {
24788
- selectionStatus.current = {
24789
- type: 'page',
24790
- numberOfSelectedRows,
24791
- numberOfSelectedRowsInPage,
24792
- page,
24793
- pageSize
24794
- };
24795
- } else if (numberOfSelectedRows > 0) {
24796
- selectionStatus.current = {
24797
- type: 'other',
24798
- numberOfSelectedRows,
24799
- numberOfSelectedRowsInPage,
24800
- page,
24801
- pageSize
24802
- };
24803
- } else {
24804
- selectionStatus.current = {
24805
- type: 'none',
24806
- numberOfSelectedRows,
24807
- numberOfSelectedRowsInPage,
24808
- page,
24809
- pageSize
24810
- };
24811
- }
24812
- };
24813
24885
  const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24814
24886
  var _initialState$paginat, _initialState$paginat2;
24815
24887
  const datagridRef = ref || useRef();
@@ -24840,7 +24912,8 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24840
24912
  sx,
24841
24913
  theme: propsTheme,
24842
24914
  paginationMode = 'client',
24843
- rowCount
24915
+ rowCount,
24916
+ onSelectionStatusChange: propsOnSelectionStatusChange
24844
24917
  } = props,
24845
24918
  forwardedProps = _objectWithoutProperties(props, _excluded2);
24846
24919
  const theme = useTheme$4(propsTheme);
@@ -24866,8 +24939,9 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24866
24939
  }, [propsSelectionModel]);
24867
24940
  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);
24868
24941
  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);
24942
+ const [selectionStatusType, setSelectionStatusType] = useState('none');
24869
24943
  const selectionStatus = useRef({
24870
- type: 'none',
24944
+ type: selectionStatusType,
24871
24945
  numberOfSelectedRows: 0,
24872
24946
  numberOfSelectedRowsInPage: 0,
24873
24947
  page,
@@ -24898,17 +24972,35 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24898
24972
  setPageSize(propsPageSize);
24899
24973
  }
24900
24974
  }, [propsPageSize]);
24975
+ const onSelectionStatusChange = selectionStatusType => {
24976
+ if (propsOnSelectionStatusChange) {
24977
+ propsOnSelectionStatusChange(selectionStatusType);
24978
+ }
24979
+ };
24980
+ useEffect(() => {
24981
+ onSelectionStatusChange(selectionStatusType);
24982
+ }, [selectionStatusType]);
24901
24983
 
24902
24984
  // in server-side pagination we want to update the selection status
24903
24985
  // every time we navigate between pages, resize our page or select something
24904
24986
  useEffect(() => {
24905
- if (paginationMode == 'server') {
24906
- onServerSideSelectionStatusChange(Array.isArray(selectionModel) ? selectionModel : [selectionModel], apiRef, selectionStatus, isRowSelectable, page, pageSize);
24987
+ if (paginationMode === 'server') {
24988
+ onServerSideSelectionStatusChange({
24989
+ newSelectionModel: Array.isArray(selectionModel) ? selectionModel : [selectionModel],
24990
+ apiRef,
24991
+ selectionStatus,
24992
+ selectionStatusType,
24993
+ setSelectionStatusType,
24994
+ isRowSelectable,
24995
+ page,
24996
+ pageSize
24997
+ });
24907
24998
  }
24908
24999
  }, [selectionModel, page, pageSize]);
24909
25000
  if (!Array.isArray(rows)) {
24910
25001
  return null;
24911
25002
  }
25003
+ const isServerTableSelection = paginationMode === 'server' && selectionStatusType === 'table';
24912
25004
  const muiTheme = useMemo(() => createTheme({
24913
25005
  palette: {
24914
25006
  mode: theme,
@@ -24975,7 +25067,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
24975
25067
  }, props))
24976
25068
  }, components), {}, {
24977
25069
  Toolbar: Toolbar,
24978
- Pagination: props => pagination ? paginationMode == 'server' ? /*#__PURE__*/React__default.createElement(ServerSideControlledPagination, _extends$2({}, props, {
25070
+ Pagination: props => pagination ? paginationMode === 'server' ? /*#__PURE__*/React__default.createElement(ControlledPagination$1, _extends$2({}, props, {
24979
25071
  displaySelection: false,
24980
25072
  displayRowsPerPage: ['bottom', 'both'].includes(paginationPlacement),
24981
25073
  displayPagination: ['bottom', 'both'].includes(paginationPlacement),
@@ -25012,9 +25104,10 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25012
25104
  filterModel,
25013
25105
  onFilterModelChange,
25014
25106
  pagination,
25015
- ControlledPagination: paginationMode == 'server' ? ServerSideControlledPagination : ControlledPagination,
25016
25107
  paginationPlacement,
25017
25108
  selectionStatus,
25109
+ selectionStatusType,
25110
+ setSelectionStatusType,
25018
25111
  apiRef,
25019
25112
  isRowSelectable,
25020
25113
  page,
@@ -25029,45 +25122,45 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25029
25122
  }),
25030
25123
  filterModel: filterModel,
25031
25124
  initialState: initialState,
25032
- isRowSelectable: isRowSelectable,
25125
+ isRowSelectable: !isServerTableSelection ? isRowSelectable : () => false,
25033
25126
  onFilterModelChange: onFilterModelChange,
25034
25127
  pagination: pagination,
25035
25128
  paginationMode: paginationMode,
25036
- keepNonExistentRowsSelected: paginationMode == 'server',
25129
+ keepNonExistentRowsSelected: paginationMode === 'server',
25037
25130
  rows: rows,
25038
25131
  rowsPerPageOptions: rowsPerPageOptions,
25039
25132
  page: page,
25040
25133
  onPageChange: onPageChange,
25041
25134
  pageSize: pageSize,
25042
25135
  onPageSizeChange: onPageSizeChange,
25043
- selectionModel: selectionModel,
25136
+ selectionModel: isServerTableSelection ? getSelectableRowsInTable(apiRef, isRowSelectable) : selectionModel,
25044
25137
  onSelectionModelChange: (newSelectionModel, details) => {
25045
25138
  if (pagination && paginationMode != 'server') {
25046
- const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref8 => {
25139
+ const selectableRowsInPage = isRowSelectable ? gridPaginatedVisibleSortedGridRowEntriesSelector(apiRef).filter(_ref2 => {
25047
25140
  let {
25048
25141
  model
25049
- } = _ref8;
25142
+ } = _ref2;
25050
25143
  return isRowSelectable({
25051
25144
  row: model
25052
25145
  });
25053
- }).map(_ref9 => {
25146
+ }).map(_ref3 => {
25054
25147
  let {
25055
25148
  id
25056
- } = _ref9;
25149
+ } = _ref3;
25057
25150
  return id;
25058
25151
  }) : gridPaginatedVisibleSortedGridRowIdsSelector(apiRef);
25059
25152
  const numberOfSelectableRowsInPage = selectableRowsInPage.length;
25060
- const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref10 => {
25153
+ const selectableRowsInTable = isRowSelectable ? gridFilteredSortedRowEntriesSelector(apiRef).filter(_ref4 => {
25061
25154
  let {
25062
25155
  model
25063
- } = _ref10;
25156
+ } = _ref4;
25064
25157
  return isRowSelectable({
25065
25158
  row: model
25066
25159
  });
25067
- }).map(_ref11 => {
25160
+ }).map(_ref5 => {
25068
25161
  let {
25069
25162
  id
25070
- } = _ref11;
25163
+ } = _ref5;
25071
25164
  return id;
25072
25165
  }) : gridFilteredSortedRowIdsSelector(apiRef);
25073
25166
  const numberOfSelectableRowsInTable = selectableRowsInTable.length;
@@ -25078,21 +25171,25 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25078
25171
  }, 0);
25079
25172
  }
25080
25173
  if (numberOfSelectedRows === numberOfSelectableRowsInPage && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
25174
+ setSelectionStatusType('page');
25081
25175
  selectionStatus.current = {
25082
25176
  type: 'page',
25083
25177
  numberOfSelectedRows
25084
25178
  };
25085
25179
  } else if (numberOfSelectedRows === numberOfSelectableRowsInTable && numberOfSelectableRowsInPage < numberOfSelectableRowsInTable) {
25180
+ setSelectionStatusType('table');
25086
25181
  selectionStatus.current = {
25087
25182
  type: 'table',
25088
25183
  numberOfSelectedRows
25089
25184
  };
25090
25185
  } else if (numberOfSelectedRows > 0) {
25186
+ setSelectionStatusType('other');
25091
25187
  selectionStatus.current = {
25092
25188
  type: 'other',
25093
25189
  numberOfSelectedRows
25094
25190
  };
25095
25191
  } else {
25192
+ setSelectionStatusType('none');
25096
25193
  selectionStatus.current = {
25097
25194
  type: 'none',
25098
25195
  numberOfSelectedRows
@@ -25101,15 +25198,7 @@ const DataGrid = /*#__PURE__*/forwardRef((props, ref) => {
25101
25198
  }
25102
25199
  onSelectionModelChange === null || onSelectionModelChange === void 0 ? void 0 : onSelectionModelChange(newSelectionModel, details);
25103
25200
  },
25104
- sx: _objectSpread2(_objectSpread2({}, sx), {}, {
25105
- '.MuiDataGrid-columnHeaders': {
25106
- flexDirection: 'column',
25107
- alignItems: 'normal'
25108
- },
25109
- '.MuiDataGrid-selectedRowCount': {
25110
- margin: 'none'
25111
- }
25112
- })
25201
+ sx: _objectSpread2(_objectSpread2({}, sx), defaultSxStyle)
25113
25202
  })))));
25114
25203
  });
25115
25204
  DataGrid.className = CLASSNAME$1;