@mui/x-data-grid-generator 9.3.0 → 9.5.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.
@@ -200,12 +200,11 @@ const applyAggregation = (aggregationModel, colDefs, rows, groupId = 'root') =>
200
200
  return aggregateValues;
201
201
  };
202
202
  const generateParentRows = pathsToAutogenerate => {
203
- return Array.from(pathsToAutogenerate).map(path => {
204
- const pathArray = path.split(',');
203
+ return Array.from(pathsToAutogenerate).map(pathArray => {
205
204
  return {
206
205
  id: `auto-generated-parent-${pathArray.join('-')}`,
207
- path: pathArray.slice(0, pathArray.length),
208
- group: pathArray.slice(-1)[0]
206
+ path: pathArray.slice(),
207
+ group: pathArray[pathArray.length - 1]
209
208
  };
210
209
  });
211
210
  };
@@ -409,14 +408,18 @@ export const processTreeDataRows = (rows, queryOptions, serverOptions, columnsWi
409
408
  let childRowsWithDescendantCounts = childRows.map(row => {
410
409
  const descendants = findTreeDataRowChildren(filteredRows, row[pathKey], pathKey, -1);
411
410
  const descendantCount = descendants.length;
411
+ const children = findTreeDataRowChildren(filteredRows, row[pathKey], pathKey, 1);
412
+ const childrenCount = children.length;
412
413
  if (descendantCount > 0 && queryOptions.aggregationModel) {
413
414
  // Parent row, compute aggregation
414
415
  return _extends({}, row, {
415
- descendantCount
416
+ descendantCount,
417
+ childrenCount
416
418
  }, applyAggregation(queryOptions.aggregationModel, columnsWithDefaultColDef, descendants, row.id));
417
419
  }
418
420
  return _extends({}, row, {
419
- descendantCount
421
+ descendantCount,
422
+ childrenCount
420
423
  });
421
424
  });
422
425
  if (queryOptions.sortModel) {
@@ -428,15 +431,21 @@ export const processTreeDataRows = (rows, queryOptions, serverOptions, columnsWi
428
431
  if (queryOptions.aggregationModel) {
429
432
  aggregateRow = applyAggregation(queryOptions.aggregationModel, columnsWithDefaultColDef, filteredRows);
430
433
  }
431
- if (queryOptions.paginationModel && (queryOptions.groupKeys.length === 0 || nestedPagination)) {
432
- // Only paginate root rows, grid should refetch root rows when `paginationModel` updates
433
- // Except when nested pagination is enabled, in which case we paginate the children of the current group node
434
- const {
435
- pageSize,
436
- page
437
- } = queryOptions.paginationModel;
438
- if (pageSize < childRowsWithDescendantCounts.length) {
439
- childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(page * pageSize, (page + 1) * pageSize);
434
+
435
+ // Apply pagination using start/end if provided, otherwise fall back to paginationModel
436
+ if (queryOptions.groupKeys.length === 0 || nestedPagination) {
437
+ if (queryOptions.start !== undefined && queryOptions.end !== undefined) {
438
+ // Use start/end for range-based pagination (needed for nested lazy loading)
439
+ childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(queryOptions.start, queryOptions.end + 1);
440
+ } else if (queryOptions.paginationModel) {
441
+ // Fall back to paginationModel for backward compatibility
442
+ const {
443
+ pageSize,
444
+ page
445
+ } = queryOptions.paginationModel;
446
+ if (pageSize < childRowsWithDescendantCounts.length) {
447
+ childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(page * pageSize, page * pageSize + pageSize);
448
+ }
440
449
  }
441
450
  }
442
451
  return new Promise(resolve => {
@@ -453,7 +462,7 @@ export const processTreeDataRows = (rows, queryOptions, serverOptions, columnsWi
453
462
  /**
454
463
  * Simulates server data for row grouping feature
455
464
  */
456
- export const processRowGroupingRows = (rows, queryOptions, serverOptions, columnsWithDefaultColDef) => {
465
+ export const processRowGroupingRows = (rows, queryOptions, serverOptions, columnsWithDefaultColDef, nestedPagination) => {
457
466
  const {
458
467
  minDelay = 100,
459
468
  maxDelay = 300
@@ -469,7 +478,7 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
469
478
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: serverOptions.groupFields must be defined to compute row grouping data' : _formatErrorMessage(103));
470
479
  }
471
480
  const delay = randomInt(minDelay, maxDelay);
472
- const pathsToAutogenerate = new Set();
481
+ const pathsToAutogenerate = new Map();
473
482
  let rowsWithPaths = rows;
474
483
  const rowsWithMissingGroups = [];
475
484
 
@@ -481,13 +490,22 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
481
490
  const colDef = columnsWithDefaultColDef.find(({
482
491
  field: f
483
492
  }) => f === field);
493
+ const rawValue = row[field];
494
+ // multiSelect (array) grouping: empty → missing group, non-empty → sorted-joined
495
+ // key so `['A','B']` and `['B','A']` collapse to one group (matches client).
496
+ if (Array.isArray(rawValue)) {
497
+ if (rawValue.length === 0) {
498
+ return undefined;
499
+ }
500
+ return [...rawValue].sort().join(',');
501
+ }
484
502
  if (colDef?.groupingValueGetter) {
485
- return String(colDef.groupingValueGetter(row[field], row, colDef, apiRef));
503
+ return String(colDef.groupingValueGetter(rawValue, row, colDef, apiRef));
486
504
  }
487
505
  if (colDef?.valueGetter) {
488
- return String(colDef.valueGetter(row[field], row, colDef, apiRef));
506
+ return String(colDef.valueGetter(rawValue, row, colDef, apiRef));
489
507
  }
490
- return String(row[field]);
508
+ return String(rawValue);
491
509
  });
492
510
  for (let index = 0; index < partialPath.length; index += 1) {
493
511
  const value = partialPath[index];
@@ -500,9 +518,9 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
500
518
  return acc;
501
519
  }
502
520
  const parentPath = partialPath.slice(0, index + 1);
503
- const strigifiedPath = parentPath.join(',');
504
- if (!pathsToAutogenerate.has(strigifiedPath)) {
505
- pathsToAutogenerate.add(strigifiedPath);
521
+ const key = JSON.stringify(parentPath);
522
+ if (!pathsToAutogenerate.has(key)) {
523
+ pathsToAutogenerate.set(key, parentPath);
506
524
  }
507
525
  }
508
526
  acc.push(_extends({}, row, {
@@ -515,7 +533,7 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
515
533
  path: ['']
516
534
  }));
517
535
  }
518
- const autogeneratedRows = generateParentRows(pathsToAutogenerate);
536
+ const autogeneratedRows = generateParentRows(pathsToAutogenerate.values());
519
537
 
520
538
  // apply plain filtering
521
539
  const filteredRows = getTreeDataFilteredRows([...autogeneratedRows, ...rowsWithPaths, ...rowsWithMissingGroups], queryOptions.filterModel, columnsWithDefaultColDef);
@@ -537,14 +555,18 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
537
555
  id
538
556
  }) => typeof id !== 'string' || !id.startsWith('auto-generated-parent-'));
539
557
  const descendantCount = descendants.length;
558
+ const children = findTreeDataRowChildren(filteredRows, row[pathKey], pathKey, 1);
559
+ const childrenCount = children.length;
540
560
  if (descendantCount > 0 && queryOptions.aggregationModel) {
541
561
  // Parent row, compute aggregation
542
562
  return _extends({}, row, {
543
- descendantCount
563
+ descendantCount,
564
+ childrenCount
544
565
  }, applyAggregation(queryOptions.aggregationModel, columnsWithDefaultColDef, descendants, row.id));
545
566
  }
546
567
  return _extends({}, row, {
547
- descendantCount
568
+ descendantCount,
569
+ childrenCount
548
570
  });
549
571
  });
550
572
  if (queryOptions.sortModel) {
@@ -557,14 +579,21 @@ export const processRowGroupingRows = (rows, queryOptions, serverOptions, column
557
579
  if (queryOptions.aggregationModel) {
558
580
  aggregateRow = applyAggregation(queryOptions.aggregationModel, columnsWithDefaultColDef, filteredRows);
559
581
  }
560
- if (queryOptions.paginationModel && queryOptions.groupKeys.length === 0) {
561
- // Only paginate root rows, grid should refetch root rows when `paginationModel` updates
562
- const {
563
- pageSize,
564
- page
565
- } = queryOptions.paginationModel;
566
- if (pageSize < childRowsWithDescendantCounts.length) {
567
- childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(page * pageSize, (page + 1) * pageSize);
582
+
583
+ // Apply pagination using start/end if provided, otherwise fall back to paginationModel
584
+ if (queryOptions.groupKeys.length === 0 || nestedPagination) {
585
+ if (queryOptions.start !== undefined && queryOptions.end !== undefined) {
586
+ // Use start/end for range-based pagination (needed for nested lazy loading)
587
+ childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(queryOptions.start, queryOptions.end + 1);
588
+ } else if (queryOptions.paginationModel) {
589
+ // Fall back to paginationModel for backward compatibility
590
+ const {
591
+ pageSize,
592
+ page
593
+ } = queryOptions.paginationModel;
594
+ if (pageSize < childRowsWithDescendantCounts.length) {
595
+ childRowsWithDescendantCounts = childRowsWithDescendantCounts.slice(page * pageSize, (page + 1) * pageSize);
596
+ }
568
597
  }
569
598
  }
570
599
  return new Promise(resolve => {
@@ -711,7 +740,7 @@ export const processPivotingRows = (rows, queryOptions, serverOptions, columnsWi
711
740
  const pivotColumnKeys = Array.from(uniqueColumnGroups.keys());
712
741
 
713
742
  // Add paths and generate parent rows based on `visibleRows` (pivot row fields)
714
- const pathsToAutogenerate = new Set();
743
+ const pathsToAutogenerate = new Map();
715
744
  let rowsWithPaths = filteredRows;
716
745
  const rowsWithMissingGroups = [];
717
746
  if (visibleRows.length > 0) {
@@ -738,9 +767,9 @@ export const processPivotingRows = (rows, queryOptions, serverOptions, columnsWi
738
767
  return acc;
739
768
  }
740
769
  const parentPath = partialPath.slice(0, index + 1);
741
- const stringifiedPath = parentPath.join(',');
742
- if (!pathsToAutogenerate.has(stringifiedPath)) {
743
- pathsToAutogenerate.add(stringifiedPath);
770
+ const key = JSON.stringify(parentPath);
771
+ if (!pathsToAutogenerate.has(key)) {
772
+ pathsToAutogenerate.set(key, parentPath);
744
773
  }
745
774
  }
746
775
  acc.push(_extends({}, row, {
@@ -753,7 +782,7 @@ export const processPivotingRows = (rows, queryOptions, serverOptions, columnsWi
753
782
  path: ['']
754
783
  }));
755
784
  }
756
- const autogeneratedRows = generateParentRows(pathsToAutogenerate);
785
+ const autogeneratedRows = generateParentRows(pathsToAutogenerate.values());
757
786
 
758
787
  // Apply tree data filtering to include missing parents and children
759
788
  const filteredRowsWithGroups = getTreeDataFilteredRows([...autogeneratedRows, ...rowsWithPaths, ...rowsWithMissingGroups], queryOptions.filterModel, columnsWithDefaultColDef);
@@ -15,11 +15,12 @@ export interface UseDemoDataOptions {
15
15
  maxColumns?: number;
16
16
  visibleFields?: string[];
17
17
  editable?: boolean;
18
+ multiSelect?: boolean;
18
19
  treeData?: AddPathToDemoDataOptions;
19
20
  }
20
21
  export declare function extrapolateSeed(rowLength: number, data: GridDemoData): Promise<GridDemoData>;
21
22
  export declare const deepFreeze: <T>(object: T) => T;
22
- export interface ColumnsOptions extends Pick<UseDemoDataOptions, 'dataSet' | 'editable' | 'maxColumns' | 'visibleFields'> {}
23
+ export interface ColumnsOptions extends Pick<UseDemoDataOptions, 'dataSet' | 'editable' | 'maxColumns' | 'visibleFields' | 'multiSelect'> {}
23
24
  export declare const getColumnsFromOptions: (options: ColumnsOptions) => GridColDefGenerator[];
24
25
  export declare const getInitialState: (options: UseDemoDataOptions, columns: GridColDefGenerator[]) => {
25
26
  columns: {
@@ -15,11 +15,12 @@ export interface UseDemoDataOptions {
15
15
  maxColumns?: number;
16
16
  visibleFields?: string[];
17
17
  editable?: boolean;
18
+ multiSelect?: boolean;
18
19
  treeData?: AddPathToDemoDataOptions;
19
20
  }
20
21
  export declare function extrapolateSeed(rowLength: number, data: GridDemoData): Promise<GridDemoData>;
21
22
  export declare const deepFreeze: <T>(object: T) => T;
22
- export interface ColumnsOptions extends Pick<UseDemoDataOptions, 'dataSet' | 'editable' | 'maxColumns' | 'visibleFields'> {}
23
+ export interface ColumnsOptions extends Pick<UseDemoDataOptions, 'dataSet' | 'editable' | 'maxColumns' | 'visibleFields' | 'multiSelect'> {}
23
24
  export declare const getColumnsFromOptions: (options: ColumnsOptions) => GridColDefGenerator[];
24
25
  export declare const getInitialState: (options: UseDemoDataOptions, columns: GridColDefGenerator[]) => {
25
26
  columns: {
@@ -70,6 +70,9 @@ const deepFreeze = object => {
70
70
  exports.deepFreeze = deepFreeze;
71
71
  const getColumnsFromOptions = options => {
72
72
  let columns = options.dataSet === 'Commodity' ? (0, _commodities.getCommodityColumns)(options.editable) : (0, _employees.getEmployeeColumns)();
73
+ if (!options.multiSelect) {
74
+ columns = columns.filter(col => col.type !== 'multiSelect');
75
+ }
73
76
  if (options.visibleFields) {
74
77
  columns = columns.map(col => (0, _extends2.default)({}, col, {
75
78
  hide: !options.visibleFields?.includes(col.field)
@@ -108,9 +111,10 @@ const useDemoData = options => {
108
111
  dataSet: options.dataSet,
109
112
  editable: options.editable,
110
113
  maxColumns: options.maxColumns,
111
- visibleFields: options.visibleFields
114
+ visibleFields: options.visibleFields,
115
+ multiSelect: options.multiSelect
112
116
  });
113
- }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields]);
117
+ }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.multiSelect]);
114
118
  const [data, setData] = React.useState(() => {
115
119
  return (0, _treeDataGenerator.addTreeDataOptionsToDemoData)({
116
120
  columns,
@@ -120,7 +124,7 @@ const useDemoData = options => {
120
124
  });
121
125
  React.useEffect(() => {
122
126
  const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
123
- const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
127
+ const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-treeData:${treeDataKey}`;
124
128
 
125
129
  // Cache to allow fast switch between the JavaScript and TypeScript version
126
130
  // of the demos.
@@ -160,7 +164,7 @@ const useDemoData = options => {
160
164
  return () => {
161
165
  active = false;
162
166
  };
163
- }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, index, columns]);
167
+ }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, index, columns]);
164
168
  return {
165
169
  data,
166
170
  loading,
@@ -60,6 +60,9 @@ export const deepFreeze = object => {
60
60
  };
61
61
  export const getColumnsFromOptions = options => {
62
62
  let columns = options.dataSet === 'Commodity' ? getCommodityColumns(options.editable) : getEmployeeColumns();
63
+ if (!options.multiSelect) {
64
+ columns = columns.filter(col => col.type !== 'multiSelect');
65
+ }
63
66
  if (options.visibleFields) {
64
67
  columns = columns.map(col => _extends({}, col, {
65
68
  hide: !options.visibleFields?.includes(col.field)
@@ -96,9 +99,10 @@ export const useDemoData = options => {
96
99
  dataSet: options.dataSet,
97
100
  editable: options.editable,
98
101
  maxColumns: options.maxColumns,
99
- visibleFields: options.visibleFields
102
+ visibleFields: options.visibleFields,
103
+ multiSelect: options.multiSelect
100
104
  });
101
- }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields]);
105
+ }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.multiSelect]);
102
106
  const [data, setData] = React.useState(() => {
103
107
  return addTreeDataOptionsToDemoData({
104
108
  columns,
@@ -108,7 +112,7 @@ export const useDemoData = options => {
108
112
  });
109
113
  React.useEffect(() => {
110
114
  const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
111
- const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
115
+ const cacheKey = `${options.dataSet}-${rowLength}-${index}-${options.maxColumns}-multiSelect:${options.multiSelect ? 'true' : 'false'}-treeData:${treeDataKey}`;
112
116
 
113
117
  // Cache to allow fast switch between the JavaScript and TypeScript version
114
118
  // of the demos.
@@ -148,7 +152,7 @@ export const useDemoData = options => {
148
152
  return () => {
149
153
  active = false;
150
154
  };
151
- }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, index, columns]);
155
+ }, [rowLength, options.dataSet, options.maxColumns, options.treeData?.maxDepth, options.treeData?.groupingField, options.treeData?.averageChildren, options.multiSelect, index, columns]);
152
156
  return {
153
157
  data,
154
158
  loading,
@@ -22,6 +22,7 @@ interface UseMockServerOptions {
22
22
  maxColumns?: number;
23
23
  visibleFields?: string[];
24
24
  editable?: boolean;
25
+ multiSelect?: boolean;
25
26
  treeData?: AddPathToDemoDataOptions;
26
27
  derivedColumns?: boolean;
27
28
  }
@@ -22,6 +22,7 @@ interface UseMockServerOptions {
22
22
  maxColumns?: number;
23
23
  visibleFields?: string[];
24
24
  editable?: boolean;
25
+ multiSelect?: boolean;
25
26
  treeData?: AddPathToDemoDataOptions;
26
27
  derivedColumns?: boolean;
27
28
  }
@@ -45,6 +45,9 @@ const getColumnsFromOptions = options => {
45
45
  default:
46
46
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: Unknown dataset' : (0, _formatErrorMessage2.default)(106));
47
47
  }
48
+ if (!options.multiSelect) {
49
+ columns = columns.filter(col => col.type !== 'multiSelect');
50
+ }
48
51
  if (options.visibleFields) {
49
52
  columns = columns.map(col => (0, _extends2.default)({}, col, {
50
53
  hide: !options.visibleFields?.includes(col.field)
@@ -133,9 +136,10 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
133
136
  editable: options.editable,
134
137
  maxColumns: options.maxColumns,
135
138
  visibleFields: options.visibleFields,
136
- derivedColumns: options.derivedColumns
139
+ derivedColumns: options.derivedColumns,
140
+ multiSelect: options.multiSelect
137
141
  });
138
- }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.derivedColumns]);
142
+ }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.derivedColumns, options.multiSelect]);
139
143
  const initialState = React.useMemo(() => getInitialState(columns, options.treeData?.groupingField), [columns, options.treeData?.groupingField]);
140
144
  const columnsWithDerivedColDef = React.useMemo(() => columns.map(column => (0, _extends2.default)({}, defaultColDef[column.type || 'string'], column)), [columns]);
141
145
  const columnsWithDefaultColDef = React.useMemo(() => columnsWithDerivedColDef.filter(column => !column.derivedFrom), [columnsWithDerivedColDef]);
@@ -148,12 +152,13 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
148
152
  }, [options.treeData?.groupingField, isTreeData]);
149
153
  const getChildrenCount = React.useMemo(() => {
150
154
  if (isTreeData) {
151
- return row => row.descendantCount;
155
+ return row => row.childrenCount;
152
156
  }
153
157
  return undefined;
154
158
  }, [isTreeData]);
155
159
  React.useEffect(() => {
156
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}`;
160
+ const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
161
+ const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
157
162
 
158
163
  // Cache to allow fast switch between the JavaScript and TypeScript version
159
164
  // of the demos.
@@ -254,7 +259,7 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
254
259
  rows,
255
260
  rootRowCount,
256
261
  aggregateRow
257
- } = await (0, _serverUtils.processTreeDataRows)(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, nestedPagination ?? false);
262
+ } = await (0, _serverUtils.processTreeDataRows)(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, nestedPagination ?? (params.start !== undefined && params.end !== undefined));
258
263
  getRowsResponse = (0, _extends2.default)({
259
264
  rows: rows.slice().map(row => (0, _extends2.default)({}, row, {
260
265
  path: undefined
@@ -281,7 +286,7 @@ const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail, nested
281
286
  rows,
282
287
  rootRowCount,
283
288
  aggregateRow
284
- } = await (0, _serverUtils.processRowGroupingRows)(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef);
289
+ } = await (0, _serverUtils.processRowGroupingRows)(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, params.start !== undefined && params.end !== undefined);
285
290
  getRowsResponse = (0, _extends2.default)({
286
291
  rows: rows.slice().map(row => (0, _extends2.default)({}, row, {
287
292
  path: undefined
@@ -38,6 +38,9 @@ const getColumnsFromOptions = options => {
38
38
  default:
39
39
  throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: Unknown dataset' : _formatErrorMessage(106));
40
40
  }
41
+ if (!options.multiSelect) {
42
+ columns = columns.filter(col => col.type !== 'multiSelect');
43
+ }
41
44
  if (options.visibleFields) {
42
45
  columns = columns.map(col => _extends({}, col, {
43
46
  hide: !options.visibleFields?.includes(col.field)
@@ -126,9 +129,10 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
126
129
  editable: options.editable,
127
130
  maxColumns: options.maxColumns,
128
131
  visibleFields: options.visibleFields,
129
- derivedColumns: options.derivedColumns
132
+ derivedColumns: options.derivedColumns,
133
+ multiSelect: options.multiSelect
130
134
  });
131
- }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.derivedColumns]);
135
+ }, [options.dataSet, options.editable, options.maxColumns, options.visibleFields, options.derivedColumns, options.multiSelect]);
132
136
  const initialState = React.useMemo(() => getInitialState(columns, options.treeData?.groupingField), [columns, options.treeData?.groupingField]);
133
137
  const columnsWithDerivedColDef = React.useMemo(() => columns.map(column => _extends({}, defaultColDef[column.type || 'string'], column)), [columns]);
134
138
  const columnsWithDefaultColDef = React.useMemo(() => columnsWithDerivedColDef.filter(column => !column.derivedFrom), [columnsWithDerivedColDef]);
@@ -141,12 +145,13 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
141
145
  }, [options.treeData?.groupingField, isTreeData]);
142
146
  const getChildrenCount = React.useMemo(() => {
143
147
  if (isTreeData) {
144
- return row => row.descendantCount;
148
+ return row => row.childrenCount;
145
149
  }
146
150
  return undefined;
147
151
  }, [isTreeData]);
148
152
  React.useEffect(() => {
149
- const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}`;
153
+ const treeDataKey = (options.treeData?.maxDepth ?? 1) > 1 ? `${options.treeData?.maxDepth}-${options.treeData?.averageChildren ?? 2}-${options.treeData?.groupingField ?? ''}` : 'false';
154
+ const cacheKey = `${options.dataSet}-${options.rowLength}-${index}-${options.maxColumns}-treeData:${treeDataKey}`;
150
155
 
151
156
  // Cache to allow fast switch between the JavaScript and TypeScript version
152
157
  // of the demos.
@@ -247,7 +252,7 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
247
252
  rows,
248
253
  rootRowCount,
249
254
  aggregateRow
250
- } = await processTreeDataRows(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, nestedPagination ?? false);
255
+ } = await processTreeDataRows(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, nestedPagination ?? (params.start !== undefined && params.end !== undefined));
251
256
  getRowsResponse = _extends({
252
257
  rows: rows.slice().map(row => _extends({}, row, {
253
258
  path: undefined
@@ -274,7 +279,7 @@ export const useMockServer = (dataSetOptions, serverOptions, shouldRequestsFail,
274
279
  rows,
275
280
  rootRowCount,
276
281
  aggregateRow
277
- } = await processRowGroupingRows(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef);
282
+ } = await processRowGroupingRows(dataRef.current?.rows ?? [], params, serverOptionsWithDefault, columnsWithDefaultColDef, params.start !== undefined && params.end !== undefined);
278
283
  getRowsResponse = _extends({
279
284
  rows: rows.slice().map(row => _extends({}, row, {
280
285
  path: undefined
@@ -167,6 +167,63 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
167
167
  dataGeneratorUniquenessEnabled?: boolean;
168
168
  hide?: boolean;
169
169
  derivedFrom?: string;
170
+ } | {
171
+ type: "multiSelect";
172
+ valueOptions?: import("@mui/x-data-grid").ValueOptions[] | ((params: import("@mui/x-data-grid").GridValueOptionsParams<any>) => Array<import("@mui/x-data-grid").ValueOptions>) | undefined;
173
+ getOptionLabel: (value: import("@mui/x-data-grid").ValueOptions) => string;
174
+ getOptionValue: (value: import("@mui/x-data-grid").ValueOptions) => string | number;
175
+ separator?: string;
176
+ field: string;
177
+ headerName?: string;
178
+ description?: string;
179
+ width?: number;
180
+ flex?: number;
181
+ minWidth?: number;
182
+ maxWidth?: number;
183
+ hideable?: boolean;
184
+ sortable?: boolean;
185
+ sortingOrder?: readonly import("@mui/x-data-grid").GridSortDirection[];
186
+ resizable?: boolean;
187
+ editable?: boolean;
188
+ groupable?: boolean;
189
+ pinnable?: boolean;
190
+ sortComparator?: import("@mui/x-data-grid").GridComparatorFn<any> | undefined;
191
+ getSortComparator?: ((sortDirection: import("@mui/x-data-grid").GridSortDirection) => import("@mui/x-data-grid").GridComparatorFn<any> | undefined) | undefined;
192
+ align?: import("@mui/x-data-grid").GridAlignment;
193
+ valueGetter?: import("@mui/x-data-grid").GridValueGetter<any, any, any, never> | undefined;
194
+ rowSpanValueGetter?: import("@mui/x-data-grid").GridValueGetter<any, any, any, never> | undefined;
195
+ valueSetter?: import("@mui/x-data-grid").GridValueSetter<any, any, any> | undefined;
196
+ valueFormatter?: import("@mui/x-data-grid").GridValueFormatter<any, any, any, never> | undefined;
197
+ valueParser?: import("@mui/x-data-grid").GridValueParser<any, any, any> | undefined;
198
+ cellClassName?: import("@mui/x-data-grid").GridCellClassNamePropType<any, any> | undefined;
199
+ display?: "text" | "flex";
200
+ renderCell?: ((params: import("@mui/x-data-grid").GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>) => React.ReactNode) | undefined;
201
+ renderEditCell?: ((params: import("@mui/x-data-grid").GridRenderEditCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>) => React.ReactNode) | undefined;
202
+ preProcessEditCellProps?: ((params: import("@mui/x-data-grid").GridPreProcessEditCellProps) => import("@mui/x-data-grid").GridEditCellProps | Promise<import("@mui/x-data-grid").GridEditCellProps>) | undefined;
203
+ headerClassName?: import("@mui/x-data-grid").GridColumnHeaderClassNamePropType;
204
+ renderHeader?: ((params: import("@mui/x-data-grid").GridColumnHeaderParams<any, any, any>) => React.ReactNode) | undefined;
205
+ headerAlign?: import("@mui/x-data-grid").GridAlignment;
206
+ hideSortIcons?: boolean;
207
+ disableColumnMenu?: boolean;
208
+ filterable?: boolean;
209
+ filterOperators?: readonly import("@mui/x-data-grid").GridFilterOperator<any, any, any, any>[] | undefined;
210
+ getApplyQuickFilterFn?: import("@mui/x-data-grid").GetApplyQuickFilterFn<any, any> | undefined;
211
+ disableReorder?: boolean;
212
+ disableExport?: boolean;
213
+ colSpan?: number | import("@mui/x-data-grid").GridColSpanFn<any, any, any> | undefined;
214
+ examples?: any[] | undefined;
215
+ renderHeaderFilter?: (params: import("@mui/x-data-grid-pro").GridRenderHeaderFilterProps) => React.ReactNode;
216
+ aggregable?: boolean;
217
+ availableAggregationFunctions?: string[];
218
+ groupingValueGetter?: import("@mui/x-data-grid-premium").GridGroupingValueGetter<any> | undefined;
219
+ groupingValueSetter?: import("@mui/x-data-grid-premium").GridGroupingValueSetter<any> | undefined;
220
+ pastedValueParser?: import("@mui/x-data-grid-premium").GridPastedValueParser<any, any, any> | undefined;
221
+ pivotable?: boolean;
222
+ chartable?: boolean;
223
+ generateData?: (row: any, context: import("../index.mjs").GridDataGeneratorContext) => any;
224
+ dataGeneratorUniquenessEnabled?: boolean;
225
+ hide?: boolean;
226
+ derivedFrom?: string;
170
227
  })[];
171
228
  initialState: {
172
229
  columns: {
@@ -167,6 +167,63 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
167
167
  dataGeneratorUniquenessEnabled?: boolean;
168
168
  hide?: boolean;
169
169
  derivedFrom?: string;
170
+ } | {
171
+ type: "multiSelect";
172
+ valueOptions?: import("@mui/x-data-grid").ValueOptions[] | ((params: import("@mui/x-data-grid").GridValueOptionsParams<any>) => Array<import("@mui/x-data-grid").ValueOptions>) | undefined;
173
+ getOptionLabel: (value: import("@mui/x-data-grid").ValueOptions) => string;
174
+ getOptionValue: (value: import("@mui/x-data-grid").ValueOptions) => string | number;
175
+ separator?: string;
176
+ field: string;
177
+ headerName?: string;
178
+ description?: string;
179
+ width?: number;
180
+ flex?: number;
181
+ minWidth?: number;
182
+ maxWidth?: number;
183
+ hideable?: boolean;
184
+ sortable?: boolean;
185
+ sortingOrder?: readonly import("@mui/x-data-grid").GridSortDirection[];
186
+ resizable?: boolean;
187
+ editable?: boolean;
188
+ groupable?: boolean;
189
+ pinnable?: boolean;
190
+ sortComparator?: import("@mui/x-data-grid").GridComparatorFn<any> | undefined;
191
+ getSortComparator?: ((sortDirection: import("@mui/x-data-grid").GridSortDirection) => import("@mui/x-data-grid").GridComparatorFn<any> | undefined) | undefined;
192
+ align?: import("@mui/x-data-grid").GridAlignment;
193
+ valueGetter?: import("@mui/x-data-grid").GridValueGetter<any, any, any, never> | undefined;
194
+ rowSpanValueGetter?: import("@mui/x-data-grid").GridValueGetter<any, any, any, never> | undefined;
195
+ valueSetter?: import("@mui/x-data-grid").GridValueSetter<any, any, any> | undefined;
196
+ valueFormatter?: import("@mui/x-data-grid").GridValueFormatter<any, any, any, never> | undefined;
197
+ valueParser?: import("@mui/x-data-grid").GridValueParser<any, any, any> | undefined;
198
+ cellClassName?: import("@mui/x-data-grid").GridCellClassNamePropType<any, any> | undefined;
199
+ display?: "text" | "flex";
200
+ renderCell?: ((params: import("@mui/x-data-grid").GridRenderCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>) => React.ReactNode) | undefined;
201
+ renderEditCell?: ((params: import("@mui/x-data-grid").GridRenderEditCellParams<any, any, any, import("@mui/x-data-grid").GridTreeNodeWithRender>) => React.ReactNode) | undefined;
202
+ preProcessEditCellProps?: ((params: import("@mui/x-data-grid").GridPreProcessEditCellProps) => import("@mui/x-data-grid").GridEditCellProps | Promise<import("@mui/x-data-grid").GridEditCellProps>) | undefined;
203
+ headerClassName?: import("@mui/x-data-grid").GridColumnHeaderClassNamePropType;
204
+ renderHeader?: ((params: import("@mui/x-data-grid").GridColumnHeaderParams<any, any, any>) => React.ReactNode) | undefined;
205
+ headerAlign?: import("@mui/x-data-grid").GridAlignment;
206
+ hideSortIcons?: boolean;
207
+ disableColumnMenu?: boolean;
208
+ filterable?: boolean;
209
+ filterOperators?: readonly import("@mui/x-data-grid").GridFilterOperator<any, any, any, any>[] | undefined;
210
+ getApplyQuickFilterFn?: import("@mui/x-data-grid").GetApplyQuickFilterFn<any, any> | undefined;
211
+ disableReorder?: boolean;
212
+ disableExport?: boolean;
213
+ colSpan?: number | import("@mui/x-data-grid").GridColSpanFn<any, any, any> | undefined;
214
+ examples?: any[] | undefined;
215
+ renderHeaderFilter?: (params: import("@mui/x-data-grid-pro").GridRenderHeaderFilterProps) => React.ReactNode;
216
+ aggregable?: boolean;
217
+ availableAggregationFunctions?: string[];
218
+ groupingValueGetter?: import("@mui/x-data-grid-premium").GridGroupingValueGetter<any> | undefined;
219
+ groupingValueSetter?: import("@mui/x-data-grid-premium").GridGroupingValueSetter<any> | undefined;
220
+ pastedValueParser?: import("@mui/x-data-grid-premium").GridPastedValueParser<any, any, any> | undefined;
221
+ pivotable?: boolean;
222
+ chartable?: boolean;
223
+ generateData?: (row: any, context: import("../index.js").GridDataGeneratorContext) => any;
224
+ dataGeneratorUniquenessEnabled?: boolean;
225
+ hide?: boolean;
226
+ derivedFrom?: string;
170
227
  })[];
171
228
  initialState: {
172
229
  columns: {
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @mui/x-data-grid-generator v9.3.0
2
+ * @mui/x-data-grid-generator v9.5.0
3
3
  *
4
- * @license UNLICENSED
5
- * This source code is licensed under the UNLICENSED license found in the
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  "use strict";
package/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @mui/x-data-grid-generator v9.3.0
2
+ * @mui/x-data-grid-generator v9.5.0
3
3
  *
4
- * @license UNLICENSED
5
- * This source code is licensed under the UNLICENSED license found in the
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  export * from "./renderer/index.mjs";
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-generator",
3
- "version": "9.3.0",
3
+ "version": "9.5.0",
4
4
  "author": "MUI Team",
5
5
  "description": "Generate fake data for demo purposes only.",
6
- "license": "UNLICENSED",
6
+ "license": "MIT",
7
7
  "bugs": {
8
8
  "url": "https://github.com/mui/mui-x/issues"
9
9
  },
@@ -21,14 +21,14 @@
21
21
  "directory": "packages/x-data-grid-generator"
22
22
  },
23
23
  "dependencies": {
24
- "@babel/runtime": "^7.29.2",
24
+ "@babel/runtime": "^7.29.7",
25
25
  "chance": "^1.1.13",
26
26
  "clsx": "^2.1.1",
27
- "lru-cache": "^11.3.6",
28
- "@mui/x-data-grid": "^9.3.0",
29
- "@mui/x-data-grid-premium": "^9.3.0",
30
- "@mui/x-data-grid-pro": "^9.3.0",
31
- "@mui/x-internals": "^9.1.0"
27
+ "lru-cache": "^11.5.1",
28
+ "@mui/x-data-grid": "^9.5.0",
29
+ "@mui/x-data-grid-pro": "^9.5.0",
30
+ "@mui/x-internals": "^9.1.0",
31
+ "@mui/x-data-grid-premium": "^9.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@emotion/react": "^11.9.0",