-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(generator): handle all function for generate form and grid #37
Open
mrbadri
wants to merge
2
commits into
main
Choose a base branch
from
feat(generator)/base-36
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './components/builder/builder'; | ||
export * from './components/builder/builder.types'; | ||
export type * from './components/builder/builder.types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage" | ||
} | ||
] | ||
], | ||
"plugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# generator | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test generator` to execute the unit tests via [Jest](https://jestjs.io). | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "@mui-builder/generator", | ||
"version": "0.0.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "generator", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/generator/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/rollup:rollup", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/generator", | ||
"tsConfig": "packages/generator/tsconfig.lib.json", | ||
"project": "packages/generator/package.json", | ||
"entryFile": "packages/generator/src/index.ts", | ||
"external": ["react", "react-dom", "react/jsx-runtime"], | ||
"rollupConfig": "@nx/react/plugins/bundle-rollup", | ||
"compiler": "babel", | ||
"assets": [ | ||
{ | ||
"glob": "packages/generator/README.md", | ||
"input": ".", | ||
"output": "." | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import generateActionSubmit from './utils/actionSubmit/actionSubmit'; | ||
import generateFieldText from './utils/fieldText/fieldText'; | ||
import generateGridContainer from './utils/gridContainer/gridContainer'; | ||
import generateGridItem from './utils/gridItem/gridItem'; | ||
|
||
export { | ||
generateGridContainer, | ||
generateActionSubmit, | ||
generateGridItem, | ||
generateFieldText, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FormBuilderProps } from '@mui-builder/core'; | ||
import { Configs } from '@mui-builder/form'; | ||
|
||
export type GeneratorProps<T, C = FormBuilderProps | FormBuilderProps[]> = { | ||
children?: C; | ||
props?: T; | ||
configs?: Configs; | ||
}; | ||
export type Generator<T, C = FormBuilderProps | FormBuilderProps[]> = ( | ||
props: GeneratorProps<T, C> | ||
) => FormBuilderProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { SubmitFieldProps } from 'packages/components/form/src/components/actions/submit/submit.types'; | ||
|
||
import { Generator } from '../../types/public.types'; | ||
|
||
import generateID from '../id/id'; | ||
|
||
const generateActionSubmit: Generator<SubmitFieldProps, string> = ({ | ||
props, | ||
configs, | ||
}) => { | ||
return { | ||
id: generateID(), | ||
groupType: 'form', | ||
type: 'action-submit', | ||
props: { | ||
...(props as SubmitFieldProps), | ||
}, | ||
configs, | ||
}; | ||
}; | ||
|
||
export default generateActionSubmit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { TextProps } from 'packages/components/form/src/components/fields/text/text.types'; | ||
|
||
import { Generator } from '../../types/public.types'; | ||
|
||
import generateID from '../id/id'; | ||
|
||
const generateFieldText: Generator<TextProps> = ({ props }) => { | ||
return { | ||
id: generateID(), | ||
groupType: 'form', | ||
type: 'field-text', | ||
props: { | ||
...props, | ||
}, | ||
}; | ||
}; | ||
|
||
export default generateFieldText; |
21 changes: 21 additions & 0 deletions
21
packages/generator/src/utils/gridContainer/gridContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { GridProps } from '@mui-builder/grid'; | ||
|
||
import { Generator } from '../../types/public.types'; | ||
|
||
import generateID from '../id/id'; | ||
|
||
const generateGridContainer: Generator<GridProps> = ({ children, props }) => { | ||
return { | ||
id: generateID(), | ||
groupType: 'grid', | ||
type: 'container', | ||
props: { | ||
rowSpacing: 20, | ||
columnSpacing: 20, | ||
children, | ||
...props, | ||
}, | ||
}; | ||
}; | ||
|
||
export default generateGridContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { GridProps } from '@mui-builder/grid'; | ||
|
||
import { Generator } from '../../types/public.types'; | ||
|
||
import generateID from '../id/id'; | ||
|
||
const generateGridItem: Generator<GridProps> = ({ children, props }) => { | ||
return { | ||
id: generateID(), | ||
groupType: 'grid', | ||
type: 'container', | ||
props: { | ||
rowSpacing: 2, | ||
columnSpacing: 2, | ||
children, | ||
...props, | ||
}, | ||
}; | ||
}; | ||
|
||
export default generateGridItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function generateID(): string { | ||
// Create a timestamp in milliseconds | ||
const timestamp = new Date().getTime(); | ||
|
||
// Generate a random number based on the timestamp | ||
const randomPart = Math.floor((Math.random() + 1) * timestamp); | ||
|
||
// Convert to base-36 (numbers + letters), and get the substring to ensure a fixed length | ||
return `${timestamp.toString(36)}-${randomPart.toString(36)}`; | ||
} | ||
|
||
export default generateID; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"allowJs": false, | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
], | ||
"extends": "../../tsconfig.base.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"types": [ | ||
"node", | ||
|
||
"@nx/react/typings/cssmodule.d.ts", | ||
"@nx/react/typings/image.d.ts" | ||
] | ||
}, | ||
"exclude": [ | ||
"jest.config.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.test.jsx" | ||
], | ||
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
The verification process has revealed that the
package.json
file in thepackages/generator
directory does not contain ascripts
section. This confirms that the commandnx test generator
mentioned in the README.md is not set up and therefore, cannot be functional as described.Conclusion:
nx test generator
is not correctly set up in thepackage.json
scripts, as there is noscripts
section present in the file.Analysis chain
Confirm the command
nx test generator
is correct and functional as described.Scripts Executed
The following scripts were executed for the analysis:
Script:
Length of output: 73
Script:
Length of output: 56