@redsift/table 12.5.3 → 12.5.4-muiv8-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3044,9 +3044,19 @@ const useStatefulTable = props => {
3044
3044
  },
3045
3045
  sortModel: sortModelParsedRef.current,
3046
3046
  onPinnedColumnsChange: (pinnedColumns, details) => {
3047
- updateUrl(buildModel({
3048
- pinnedColumnsModel: pinnedColumns
3049
- }), search, localStorageVersion, historyReplace, columns);
3047
+ var _apiRef$current$state2, _apiRef$current4, _apiRef$current4$stat, _apiRef$current4$stat2;
3048
+ // While pivot mode is active, MUI Premium emits synthetic pinned-column
3049
+ // models (e.g. `__row_group_by_columns_group__` for the grouping column)
3050
+ // that must not be persisted to the URL / localStorage. Read the live
3051
+ // grid state from apiRef rather than the parsed URL value because the
3052
+ // URL lags by a tick during pivot enable/disable transitions. Consumer
3053
+ // callbacks are always forwarded so observers can still react.
3054
+ const pivotActiveLive = (_apiRef$current$state2 = (_apiRef$current4 = apiRef.current) === null || _apiRef$current4 === void 0 ? void 0 : (_apiRef$current4$stat = _apiRef$current4.state) === null || _apiRef$current4$stat === void 0 ? void 0 : (_apiRef$current4$stat2 = _apiRef$current4$stat.pivoting) === null || _apiRef$current4$stat2 === void 0 ? void 0 : _apiRef$current4$stat2.active) !== null && _apiRef$current$state2 !== void 0 ? _apiRef$current$state2 : pivotActiveParsed;
3055
+ if (!pivotActiveLive) {
3056
+ updateUrl(buildModel({
3057
+ pinnedColumnsModel: pinnedColumns
3058
+ }), search, localStorageVersion, historyReplace, columns);
3059
+ }
3050
3060
  propsOnPinnedColumnsChange === null || propsOnPinnedColumnsChange === void 0 ? void 0 : propsOnPinnedColumnsChange(pinnedColumns, details);
3051
3061
  },
3052
3062
  pinnedColumns: pinnedColumnsModelRef.current,
@@ -3064,9 +3074,20 @@ const useStatefulTable = props => {
3064
3074
  },
3065
3075
  columnVisibilityModel: visibilityModelRef.current,
3066
3076
  onColumnVisibilityModelChange: (columnsVisibilityModel, details) => {
3067
- updateUrl(buildModel({
3068
- columnsModel: columnsVisibilityModel
3069
- }), search, localStorageVersion, historyReplace, columns);
3077
+ var _apiRef$current$state3, _apiRef$current5, _apiRef$current5$stat, _apiRef$current5$stat2;
3078
+ // While pivot mode is active, MUI Premium emits synthetic visibility
3079
+ // models that whitelist only the pivot value fields (hiding every base
3080
+ // column). Persisting that to the URL would re-hide all base columns
3081
+ // on the next load (see getColumnVisibilityFromString whitelist logic).
3082
+ // Read the live grid state rather than the parsed URL value because the
3083
+ // URL lags by a tick during pivot enable/disable transitions. Consumer
3084
+ // callbacks are always forwarded.
3085
+ const pivotActiveLive = (_apiRef$current$state3 = (_apiRef$current5 = apiRef.current) === null || _apiRef$current5 === void 0 ? void 0 : (_apiRef$current5$stat = _apiRef$current5.state) === null || _apiRef$current5$stat === void 0 ? void 0 : (_apiRef$current5$stat2 = _apiRef$current5$stat.pivoting) === null || _apiRef$current5$stat2 === void 0 ? void 0 : _apiRef$current5$stat2.active) !== null && _apiRef$current$state3 !== void 0 ? _apiRef$current$state3 : pivotActiveParsed;
3086
+ if (!pivotActiveLive) {
3087
+ updateUrl(buildModel({
3088
+ columnsModel: columnsVisibilityModel
3089
+ }), search, localStorageVersion, historyReplace, columns);
3090
+ }
3070
3091
  propsOnColumnVisibilityModelChange === null || propsOnColumnVisibilityModelChange === void 0 ? void 0 : propsOnColumnVisibilityModelChange(columnsVisibilityModel, details);
3071
3092
  },
3072
3093
  onColumnWidthChange: (params, event, details) => {
@@ -3484,15 +3505,11 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
3484
3505
  apiRef: apiRef,
3485
3506
  dataSource: dataSource,
3486
3507
  columns: columns,
3487
- columnVisibilityModel: columnVisibilityModel,
3488
3508
  onColumnVisibilityModelChange: onColumnVisibilityModelChange,
3489
3509
  onPinnedColumnsChange: onPinnedColumnsChange,
3490
- pinnedColumns: pinnedColumns,
3491
3510
  pageSizeOptions: pageSizeOptions,
3492
3511
  onColumnWidthChange: onColumnWidthChange,
3493
- rowGroupingModel: rowGroupingModel,
3494
3512
  onRowGroupingModelChange: onRowGroupingModelChange,
3495
- aggregationModel: aggregationModel,
3496
3513
  onAggregationModelChange: onAggregationModelChange,
3497
3514
  pivotModel: pivotModel,
3498
3515
  onPivotModelChange: onPivotModelChange,
@@ -3501,6 +3518,12 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
3501
3518
  // In dataSource mode: models are uncontrolled (MUI owns them),
3502
3519
  // onChange handlers are write-only for URL/localStorage persistence,
3503
3520
  // and initialState seeds MUI on mount from the persisted URL state.
3521
+ // columnVisibilityModel / pinnedColumns / rowGroupingModel /
3522
+ // aggregationModel are also uncontrolled here to avoid a controlled
3523
+ // re-render race with consumer-side microtask-deferred history
3524
+ // updates (otherwise user toggles flip back when MUI re-emits with
3525
+ // the stale controlled value). Consumers needing programmatic
3526
+ // changes should use the apiRef imperative API.
3504
3527
  }, isDataSourceMode ? {
3505
3528
  onFilterModelChange: onFilterModelChange,
3506
3529
  onSortModelChange: onSortModelChange,
@@ -3508,7 +3531,15 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
3508
3531
  initialState: _objectSpread2(_objectSpread2({}, initialState), {}, {
3509
3532
  density: controlledDensity,
3510
3533
  columns: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.columns), {}, {
3511
- orderedFields: columnOrderModel
3534
+ orderedFields: columnOrderModel,
3535
+ columnVisibilityModel
3536
+ }),
3537
+ pinnedColumns,
3538
+ rowGrouping: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.rowGrouping), {}, {
3539
+ model: rowGroupingModel
3540
+ }),
3541
+ aggregation: _objectSpread2(_objectSpread2({}, initialState === null || initialState === void 0 ? void 0 : initialState.aggregation), {}, {
3542
+ model: aggregationModel
3512
3543
  }),
3513
3544
  filter: {
3514
3545
  filterModel
@@ -3524,6 +3555,10 @@ const StatefulDataGrid = /*#__PURE__*/forwardRef((props, ref) => {
3524
3555
  })
3525
3556
  })
3526
3557
  } : {
3558
+ columnVisibilityModel,
3559
+ pinnedColumns,
3560
+ rowGroupingModel,
3561
+ aggregationModel,
3527
3562
  filterModel,
3528
3563
  sortModel,
3529
3564
  paginationModel,