@comet/admin-generator 9.0.0-canary-20251209132220 → 9.0.0-canary-20251211112608
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.
|
@@ -63,30 +63,40 @@ export type FormFieldConfig<T> = (({
|
|
|
63
63
|
type: "text";
|
|
64
64
|
name: UsableFormFields<T>;
|
|
65
65
|
multiline?: boolean;
|
|
66
|
+
initialValue?: string;
|
|
66
67
|
} & InputBaseFieldConfig) | ({
|
|
67
68
|
type: "number";
|
|
68
69
|
name: UsableFormFields<T>;
|
|
69
70
|
decimals?: number;
|
|
71
|
+
initialValue?: number;
|
|
70
72
|
} & InputBaseFieldConfig) | ({
|
|
71
73
|
type: "numberRange";
|
|
72
74
|
name: UsableFormFields<T>;
|
|
73
75
|
minValue: number;
|
|
74
76
|
maxValue: number;
|
|
75
77
|
disableSlider?: boolean;
|
|
78
|
+
initialValue?: {
|
|
79
|
+
min: number;
|
|
80
|
+
max: number;
|
|
81
|
+
};
|
|
76
82
|
} & InputBaseFieldConfig) | {
|
|
77
83
|
type: "boolean";
|
|
78
84
|
name: UsableFormFields<T>;
|
|
85
|
+
initialValue?: boolean;
|
|
79
86
|
} | ({
|
|
80
87
|
type: "date";
|
|
81
88
|
name: UsableFormFields<T>;
|
|
89
|
+
initialValue?: string;
|
|
82
90
|
} & InputBaseFieldConfig) | ({
|
|
83
91
|
type: "dateTime";
|
|
84
92
|
name: UsableFormFields<T>;
|
|
93
|
+
initialValue?: Date;
|
|
85
94
|
} & InputBaseFieldConfig) | ({
|
|
86
95
|
type: "staticSelect";
|
|
87
96
|
name: UsableFormFields<T>;
|
|
88
97
|
values?: StaticSelectValue[];
|
|
89
98
|
inputType?: "select" | "radio";
|
|
99
|
+
initialValue?: string;
|
|
90
100
|
} & Omit<InputBaseFieldConfig, "endAdornment">) | ({
|
|
91
101
|
type: "asyncSelect";
|
|
92
102
|
name: UsableFormFields<T>;
|
|
@@ -296,6 +306,7 @@ export type GridConfig<T extends {
|
|
|
296
306
|
* @default false
|
|
297
307
|
*/
|
|
298
308
|
scopeAsProp?: boolean;
|
|
309
|
+
density?: "comfortable" | "compact" | "standard";
|
|
299
310
|
};
|
|
300
311
|
export type GeneratorConfig<T extends {
|
|
301
312
|
__typename?: string;
|
|
@@ -66,6 +66,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
66
66
|
if (!required && !config.readOnly) {
|
|
67
67
|
formValueConfig.formValueToGqlInputCode = `$fieldName ?? null`;
|
|
68
68
|
}
|
|
69
|
+
if (config.initialValue !== undefined) {
|
|
70
|
+
formValueConfig.defaultInitializationCode = JSON.stringify(config.initialValue);
|
|
71
|
+
}
|
|
69
72
|
}
|
|
70
73
|
else if (config.type == "number") {
|
|
71
74
|
code = `
|
|
@@ -102,6 +105,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
102
105
|
type: "string",
|
|
103
106
|
};
|
|
104
107
|
formValueConfig.initializationCode = `${initializationAssignment}`;
|
|
108
|
+
if (config.initialValue !== undefined) {
|
|
109
|
+
formValueConfig.defaultInitializationCode = JSON.stringify(config.initialValue);
|
|
110
|
+
}
|
|
105
111
|
}
|
|
106
112
|
else if (config.type === "numberRange") {
|
|
107
113
|
code = `
|
|
@@ -126,6 +132,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
126
132
|
${validateCode}
|
|
127
133
|
/>`;
|
|
128
134
|
formFragmentFields = [`${name}.min`, `${name}.max`];
|
|
135
|
+
if (config.initialValue !== undefined) {
|
|
136
|
+
formValueConfig.defaultInitializationCode = JSON.stringify(config.initialValue);
|
|
137
|
+
}
|
|
129
138
|
}
|
|
130
139
|
else if (config.type == "boolean") {
|
|
131
140
|
code = `<CheckboxField
|
|
@@ -141,7 +150,7 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
141
150
|
: ""}
|
|
142
151
|
${validateCode}
|
|
143
152
|
/>`;
|
|
144
|
-
formValueConfig.defaultInitializationCode =
|
|
153
|
+
formValueConfig.defaultInitializationCode = config.initialValue ? "true" : "false";
|
|
145
154
|
}
|
|
146
155
|
else if (config.type == "date") {
|
|
147
156
|
imports.push({
|
|
@@ -168,6 +177,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
168
177
|
if (!required && !config.readOnly) {
|
|
169
178
|
formValueConfig.formValueToGqlInputCode = `$fieldName ?? null`;
|
|
170
179
|
}
|
|
180
|
+
if (config.initialValue !== undefined) {
|
|
181
|
+
formValueConfig.defaultInitializationCode = JSON.stringify(config.initialValue);
|
|
182
|
+
}
|
|
171
183
|
}
|
|
172
184
|
else if (config.type == "dateTime") {
|
|
173
185
|
imports.push({
|
|
@@ -199,6 +211,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
199
211
|
if (!config.readOnly) {
|
|
200
212
|
formValueConfig.formValueToGqlInputCode = required ? `$fieldName.toISOString()` : `$fieldName ? $fieldName.toISOString() : null`;
|
|
201
213
|
}
|
|
214
|
+
if (config.initialValue !== undefined) {
|
|
215
|
+
formValueConfig.defaultInitializationCode = `new Date("${config.initialValue.toISOString()}")`;
|
|
216
|
+
}
|
|
202
217
|
}
|
|
203
218
|
else if (config.type == "block") {
|
|
204
219
|
code = `<Field name="${nameWithPrefix}" isEqual={isEqual} label={${fieldLabel}} variant="horizontal" fullWidth>
|
|
@@ -320,6 +335,9 @@ function generateFormField({ gqlIntrospection, baseOutputFilename, config, formC
|
|
|
320
335
|
})}]}
|
|
321
336
|
/>`;
|
|
322
337
|
}
|
|
338
|
+
if (config.initialValue !== undefined) {
|
|
339
|
+
formValueConfig.defaultInitializationCode = JSON.stringify(config.initialValue);
|
|
340
|
+
}
|
|
323
341
|
}
|
|
324
342
|
else {
|
|
325
343
|
throw new Error(`Unsupported type`);
|
|
@@ -687,7 +687,9 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
|
|
|
687
687
|
</>
|
|
688
688
|
)`
|
|
689
689
|
: undefined,
|
|
690
|
-
headerName:
|
|
690
|
+
headerName: column.headerName === ""
|
|
691
|
+
? `""`
|
|
692
|
+
: `intl.formatMessage({ id: "${instanceGqlType}.${column.name}", defaultMessage: "${column.headerName || (0, camelCaseToHumanReadable_1.camelCaseToHumanReadable)(column.name)}" })`,
|
|
691
693
|
type: column.gridType ? `"${column.gridType}"` : undefined,
|
|
692
694
|
filterable: (!column.filterOperators && !filterFields.includes(column.name)) || allowRowReordering ? `false` : undefined,
|
|
693
695
|
sortable: (!sortFields.includes(column.name) || allowRowReordering) && !column.sortBy ? `false` : undefined,
|
|
@@ -803,6 +805,7 @@ function generateGrid({ exportName, baseOutputFilename, targetDirectory, gqlIntr
|
|
|
803
805
|
onRowOrderChange={handleRowOrderChange}
|
|
804
806
|
hideFooterPagination`
|
|
805
807
|
: ""}
|
|
808
|
+
${config.density ? `density="${config.density}"` : ""}
|
|
806
809
|
/>
|
|
807
810
|
);
|
|
808
811
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comet/admin-generator",
|
|
3
|
-
"version": "9.0.0-canary-
|
|
3
|
+
"version": "9.0.0-canary-20251211112608",
|
|
4
4
|
"description": "Comet Admin Generator CLI tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/admin/admin-generator",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"@graphql-tools/load": "^7.8.14",
|
|
24
24
|
"change-case": "^4.1.2",
|
|
25
25
|
"commander": "^9.5.0",
|
|
26
|
-
"glob": "^
|
|
26
|
+
"glob": "^11.1.0",
|
|
27
27
|
"graphql": "^16.11.0",
|
|
28
28
|
"object-path": "^0.11.8",
|
|
29
29
|
"pluralize": "^8.0.0",
|
|
30
30
|
"ts-node": "^10.9.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@apollo/client": "^3.
|
|
34
|
-
"@mui/material": "^7.
|
|
33
|
+
"@apollo/client": "^3.14.0",
|
|
34
|
+
"@mui/material": "^7.3.5",
|
|
35
35
|
"@mui/x-data-grid": "^7.29.8",
|
|
36
36
|
"@types/jest": "^29.5.14",
|
|
37
37
|
"@types/node": "^24.9.1",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"react": "^18.3.1",
|
|
48
48
|
"react-dom": "^18.3.1",
|
|
49
49
|
"react-intl": "^7.1.11",
|
|
50
|
-
"rimraf": "^6.
|
|
50
|
+
"rimraf": "^6.1.2",
|
|
51
51
|
"ts-jest": "^29.4.0",
|
|
52
52
|
"typescript": "5.9.3",
|
|
53
|
-
"@comet/admin": "9.0.0-canary-
|
|
54
|
-
"@comet/admin-icons": "9.0.0-canary-
|
|
55
|
-
"@comet/cms-admin": "9.0.0-canary-
|
|
56
|
-
"@comet/eslint-config": "9.0.0-canary-
|
|
53
|
+
"@comet/admin": "9.0.0-canary-20251211112608",
|
|
54
|
+
"@comet/admin-icons": "9.0.0-canary-20251211112608",
|
|
55
|
+
"@comet/cms-admin": "9.0.0-canary-20251211112608",
|
|
56
|
+
"@comet/eslint-config": "9.0.0-canary-20251211112608"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22.0.0"
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"clean": "rimraf lib",
|
|
68
68
|
"dev": "tsc --watch --preserveWatchOutput -p tsconfig.build.json",
|
|
69
69
|
"lint": "run-p lint:prettier lint:eslint lint:tsc",
|
|
70
|
+
"lint:ci": "pnpm run lint",
|
|
70
71
|
"lint:eslint": "eslint --max-warnings 0 src/ **/*.json --no-warn-ignored",
|
|
71
72
|
"lint:prettier": "pnpm exec prettier --check './**/*.{js,json,md,yml,yaml}'",
|
|
72
73
|
"lint:tsc": "tsc",
|