@comet/admin-generator 8.8.0-canary-20251120114500 → 8.8.0-canary-20251120141652

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.
@@ -0,0 +1,5 @@
1
+ export declare function detectMuiXGridVariant(): {
2
+ variant: "community" | "pro" | "premium";
3
+ package: string;
4
+ gridComponent: string;
5
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.detectMuiXGridVariant = detectMuiXGridVariant;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ function detectMuiXGridVariant() {
9
+ const packageJson = JSON.parse(fs_1.default.readFileSync("package.json", "utf-8"));
10
+ const packages = Object.keys(packageJson.dependencies);
11
+ if (packages.includes("@mui/x-data-grid-premium")) {
12
+ return {
13
+ variant: "premium",
14
+ package: "@mui/x-data-grid-premium",
15
+ gridComponent: "DataGridPremium",
16
+ };
17
+ }
18
+ else if (packages.includes("@mui/x-data-grid-pro")) {
19
+ return {
20
+ variant: "pro",
21
+ package: "@mui/x-data-grid-pro",
22
+ gridComponent: "DataGridPro",
23
+ };
24
+ }
25
+ else {
26
+ return {
27
+ variant: "community",
28
+ package: "@mui/x-data-grid",
29
+ gridComponent: "DataGrid",
30
+ };
31
+ }
32
+ }
@@ -21,6 +21,7 @@ const findRootBlocks_1 = require("../utils/findRootBlocks");
21
21
  const generateGqlOperation_1 = require("../utils/generateGqlOperation");
22
22
  const generateImportsCode_1 = require("../utils/generateImportsCode");
23
23
  const runtimeTypeGuards_1 = require("../utils/runtimeTypeGuards");
24
+ const detectMuiXVersion_1 = require("./detectMuiXVersion");
24
25
  const findInputObjectType_1 = require("./findInputObjectType");
25
26
  const generateGqlFieldList_1 = require("./generateGqlFieldList");
26
27
  const generateGridToolbar_1 = require("./generateGridToolbar");
@@ -121,6 +122,7 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
121
122
  if (!gqlType) {
122
123
  throw new Error("gqlType is required in grid config");
123
124
  }
125
+ const muiXGridVariant = (0, detectMuiXVersion_1.detectMuiXGridVariant)();
124
126
  const gqlTypePlural = (0, pluralize_1.plural)(gqlType);
125
127
  //const title = config.title ?? camelCaseToHumanReadable(gqlType);
126
128
  const instanceGqlType = gqlType[0].toLowerCase() + gqlType.substring(1);
@@ -171,14 +173,15 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
171
173
  { name: "ListItemIcon", importPath: "@mui/material" },
172
174
  { name: "ListItemText", importPath: "@mui/material" },
173
175
  { name: "CircularProgress", importPath: "@mui/material" },
174
- { name: "DataGridPro", importPath: "@mui/x-data-grid-pro" },
175
- { name: "GridLogicOperator", importPath: "@mui/x-data-grid-pro" },
176
- { name: "GridRenderCellParams", importPath: "@mui/x-data-grid-pro" },
177
- { name: "GridSlotsComponent", importPath: "@mui/x-data-grid-pro" },
178
- { name: "GridToolbarProps", importPath: "@mui/x-data-grid-pro" },
179
- { name: "GridColumnHeaderTitle", importPath: "@mui/x-data-grid-pro" },
180
- { name: "GridToolbarQuickFilter", importPath: "@mui/x-data-grid-pro" },
181
- { name: "GridRowOrderChangeParams", importPath: "@mui/x-data-grid-pro" },
176
+ { name: muiXGridVariant.gridComponent, importPath: muiXGridVariant.package },
177
+ { name: `${muiXGridVariant.gridComponent}Props`, importPath: muiXGridVariant.package },
178
+ { name: "GridLogicOperator", importPath: muiXGridVariant.package },
179
+ { name: "GridRenderCellParams", importPath: muiXGridVariant.package },
180
+ { name: "GridSlotsComponent", importPath: muiXGridVariant.package },
181
+ { name: "GridToolbarProps", importPath: muiXGridVariant.package },
182
+ { name: "GridColumnHeaderTitle", importPath: muiXGridVariant.package },
183
+ { name: "GridToolbarQuickFilter", importPath: muiXGridVariant.package },
184
+ { name: "GridRowOrderChangeParams", importPath: muiXGridVariant.package },
182
185
  { name: "useMemo", importPath: "react" },
183
186
  ];
184
187
  const iconsToImport = ["Add", "Edit", "Info", "Excel"];
@@ -519,15 +522,14 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
519
522
  });
520
523
  }
521
524
  if (config.selectionProps) {
522
- imports.push({ name: "DataGridProProps", importPath: "@mui/x-data-grid-pro" });
523
525
  props.push({
524
526
  name: "rowSelectionModel",
525
- type: `DataGridProProps["rowSelectionModel"]`,
527
+ type: `${muiXGridVariant.gridComponent}Props["rowSelectionModel"]`,
526
528
  optional: true,
527
529
  });
528
530
  props.push({
529
531
  name: "onRowSelectionModelChange",
530
- type: `DataGridProProps["onRowSelectionModelChange"]`,
532
+ type: `${muiXGridVariant.gridComponent}Props["onRowSelectionModelChange"]`,
531
533
  optional: true,
532
534
  });
533
535
  }
@@ -784,7 +786,7 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
784
786
  ${generateGridExportApi(config.excelExport, gqlTypePlural, instanceGqlTypePlural, gridQuery, gqlArgs)}
785
787
 
786
788
  return (
787
- <DataGridPro
789
+ <${muiXGridVariant.gridComponent}
788
790
  {...dataGridProps}
789
791
  rows={rows}
790
792
  rowCount={rowCount}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/admin-generator",
3
- "version": "8.8.0-canary-20251120114500",
3
+ "version": "8.8.0-canary-20251120141652",
4
4
  "description": "Comet Admin Generator CLI tool",
5
5
  "repository": {
6
6
  "directory": "packages/admin/admin-generator",
@@ -48,10 +48,10 @@
48
48
  "rimraf": "^6.0.1",
49
49
  "ts-jest": "^29.4.0",
50
50
  "typescript": "5.9.3",
51
- "@comet/admin": "8.8.0-canary-20251120114500",
52
- "@comet/admin-icons": "8.8.0-canary-20251120114500",
53
- "@comet/cms-admin": "8.8.0-canary-20251120114500",
54
- "@comet/eslint-config": "8.8.0-canary-20251120114500"
51
+ "@comet/admin": "8.8.0-canary-20251120141652",
52
+ "@comet/admin-icons": "8.8.0-canary-20251120141652",
53
+ "@comet/cms-admin": "8.8.0-canary-20251120141652",
54
+ "@comet/eslint-config": "8.8.0-canary-20251120141652"
55
55
  },
56
56
  "engines": {
57
57
  "node": ">=22.0.0"