proje-react-panel 1.0.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.
package/.eslintrc.js ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: "@typescript-eslint/parser",
4
+ plugins: ["@typescript-eslint"],
5
+ overrides: [
6
+ {
7
+ files: ["*.ts", "*.tsx"],
8
+ rules: {
9
+ semi: 0,
10
+ "@typescript-eslint/no-shadow": ["error"],
11
+ "no-shadow": "off",
12
+ "no-undef": "off",
13
+ },
14
+ },
15
+ ],
16
+ };
@@ -0,0 +1,54 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <HTMLCodeStyleSettings>
4
+ <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
+ </HTMLCodeStyleSettings>
6
+ <JSCodeStyleSettings version="0">
7
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
9
+ <option name="FORCE_QUOTE_STYlE" value="true" />
10
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
11
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
12
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
13
+ </JSCodeStyleSettings>
14
+ <TypeScriptCodeStyleSettings version="0">
15
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
16
+ <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
17
+ <option name="FORCE_QUOTE_STYlE" value="true" />
18
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
19
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
20
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
21
+ </TypeScriptCodeStyleSettings>
22
+ <VueCodeStyleSettings>
23
+ <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
24
+ <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
25
+ </VueCodeStyleSettings>
26
+ <codeStyleSettings language="HTML">
27
+ <option name="SOFT_MARGINS" value="120" />
28
+ <indentOptions>
29
+ <option name="CONTINUATION_INDENT_SIZE" value="4" />
30
+ <option name="USE_TAB_CHARACTER" value="true" />
31
+ </indentOptions>
32
+ </codeStyleSettings>
33
+ <codeStyleSettings language="JavaScript">
34
+ <option name="SOFT_MARGINS" value="120" />
35
+ <indentOptions>
36
+ <option name="USE_TAB_CHARACTER" value="true" />
37
+ </indentOptions>
38
+ </codeStyleSettings>
39
+ <codeStyleSettings language="TypeScript">
40
+ <option name="SOFT_MARGINS" value="120" />
41
+ <indentOptions>
42
+ <option name="USE_TAB_CHARACTER" value="true" />
43
+ </indentOptions>
44
+ </codeStyleSettings>
45
+ <codeStyleSettings language="Vue">
46
+ <option name="SOFT_MARGINS" value="120" />
47
+ <indentOptions>
48
+ <option name="INDENT_SIZE" value="4" />
49
+ <option name="TAB_SIZE" value="4" />
50
+ <option name="USE_TAB_CHARACTER" value="true" />
51
+ </indentOptions>
52
+ </codeStyleSettings>
53
+ </code_scheme>
54
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GithubDefaultAccount">
4
+ <option name="defaultAccountId" value="1f47474a-5c46-4e64-871f-41c4af1c466e" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/react-panel.iml" filepath="$PROJECT_DIR$/.idea/react-panel.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings" defaultProject="true" />
4
+ </project>
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 demirsefa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # React Panel
2
+
3
+ ## Overview
4
+ React Panel is a web application built using as the backend framework and React for the frontend. It features a customizable sidebar and supports CRUD operations on entities. This project is designed to be a foundational template for building admin panels or other web-based interfaces.
5
+
6
+ ---
7
+
8
+ ## Features
9
+ - **Entity CRUD Operations**: Easily create, read, update, and delete entities through the panel.
10
+ - **Sidebar Navigation**: The application includes a sidebar for easy navigation, which is fully customizable.
11
+ - **Single Design Template**: Comes with a default design that can be customized to fit your needs.
12
+
13
+ ---
14
+
15
+ ## Getting Started
16
+ ### Prerequisites
17
+ - Node.js (LTS version recommended)
18
+ - npm or yarn package manager
19
+ - A supported database (e.g., PostgreSQL, MySQL, MongoDB)
20
+
21
+ ### Installation
22
+ 1. Clone the repository:
23
+ ```bash
24
+ git clone <repository-url>
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ type AppProps = {
3
+ children: React.ReactNode;
4
+ };
5
+ export declare function Panel({ children }: AppProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const CrudApi: {
2
+ getList: (api: string, page: number) => Promise<import("axios").AxiosResponse<any, any>>;
3
+ create: (api: string, data: any) => Promise<import("axios").AxiosResponse<any, any>>;
4
+ details(api: string, id: any): Promise<import("axios").AxiosResponse<any, any>>;
5
+ edit(api: string, data: any): Promise<import("axios").AxiosResponse<any, any>>;
6
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function Layout({ children, noSidebar, }: {
3
+ children?: React.ReactNode;
4
+ noSidebar?: boolean;
5
+ }): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function SideBar(): React.JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function createScreens(screens: Record<string, any>): void;
@@ -0,0 +1,10 @@
1
+ import 'reflect-metadata';
2
+ export interface CellOptions<T> {
3
+ name?: string;
4
+ title?: string;
5
+ type?: 'string' | 'number' | 'date';
6
+ placeHolder?: string;
7
+ linkTo?: (item: T) => string;
8
+ }
9
+ export declare function Cell<T>(options?: CellOptions<T>): PropertyDecorator;
10
+ export declare function getCellFields<T>(entityClass: any): CellOptions<T>[];
@@ -0,0 +1,6 @@
1
+ import 'reflect-metadata';
2
+ export interface CrudOptions {
3
+ controller: string;
4
+ }
5
+ export declare function Crud(options?: CrudOptions): ClassDecorator;
6
+ export declare function getClassCrudData(entityClass: any): CrudOptions | undefined;
@@ -0,0 +1,2 @@
1
+ import { ScreenCreatorData } from "./types/ScreenCreatorData";
2
+ export declare function getFields<T>(entityClass: T): ScreenCreatorData<T>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function getScreenForRoutes(): React.JSX.Element;
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react");exports.Panel=function({children:r}){return e.createElement(e.Fragment,null,r)};
@@ -0,0 +1 @@
1
+ export { Panel } from "./Panel";
@@ -0,0 +1 @@
1
+ import e from"react";function r({children:r}){return e.createElement(e.Fragment,null,r)}export{r as Panel};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import '../styles/list.scss';
3
+ import { CellOptions } from '../declerations/Cell';
4
+ import { Screen } from '../types/Screen';
5
+ interface ListProps<T> {
6
+ data: T[];
7
+ cells: CellOptions<T>[];
8
+ screen: Screen;
9
+ }
10
+ export declare function List<T>({ data, cells, screen }: ListProps<T>): React.JSX.Element;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import '../styles/form.scss';
3
+ import { Screen } from '../types/Screen';
4
+ export declare function ControllerCreate({ screen }: {
5
+ screen: Screen;
6
+ }): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { Screen } from '../types/Screen';
3
+ export declare function ControllerDetails({ screen }: {
4
+ screen: Screen;
5
+ }): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { Screen } from '../types/Screen';
3
+ export declare function ControllerEdit({ screen }: {
4
+ screen: Screen;
5
+ }): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { Screen } from '../types/Screen';
3
+ export declare function ControllerList({ screen }: {
4
+ screen: Screen;
5
+ }): React.JSX.Element;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Screen } from '../types/Screen';
3
+ export declare function Form({ data, screen }: {
4
+ data?: any;
5
+ screen: Screen;
6
+ }): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { ScreenCreatorData } from "./types/ScreenCreatorData";
2
+ export declare const StoreData: {
3
+ screens: Record<string, ScreenCreatorData<any>>;
4
+ };
@@ -0,0 +1,4 @@
1
+ export interface Screen {
2
+ key: string;
3
+ controller: string;
4
+ }
@@ -0,0 +1,8 @@
1
+ import { CellOptions } from "../declerations/Cell";
2
+ import { CrudOptions } from "../declerations/Crud";
3
+ export type ScreenCreatorData<T> = {
4
+ resolver: any;
5
+ fields: string[];
6
+ cells: CellOptions<T>[];
7
+ crud: CrudOptions;
8
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "proje-react-panel",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "author": "SEFA DEMİR",
6
+ "license": "ISC",
7
+ "main": "dist/index.cjs.js",
8
+ "module": "dist/index.esm.js",
9
+ "source": [
10
+ "src/index.ts",
11
+ "src/dom/index.ts"
12
+ ],
13
+ "types": "dist/index.d.ts",
14
+ "scripts": {
15
+ "test": "echo \"Error: no test specified\" && exit 1",
16
+ "build": "rollup -c ",
17
+ "lint": "eslint src --ext .ts,.tsx"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/demirsefa/react-panel.git"
22
+ },
23
+ "keywords": [],
24
+ "bugs": {
25
+ "url": "https://github.com/demirsefa/react-panel/issues"
26
+ },
27
+ "homepage": "https://github.com/demirsefa/react-panel#readme",
28
+ "dependencies": {
29
+ "axios": "^1.8.3",
30
+ "react-hook-form": "^7.54.2",
31
+ "rollup-plugin-serve": "^3.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@hookform/resolvers": "^4.1.3",
35
+ "@rollup/plugin-commonjs": "^28.0.3",
36
+ "@rollup/plugin-node-resolve": "^16.0.1",
37
+ "@types/react": "^19.0.10",
38
+ "@types/react-dom": "^19.0.4",
39
+ "@typescript-eslint/eslint-plugin": "^8.26.1",
40
+ "@typescript-eslint/parser": "^8.26.1",
41
+ "class-transformer": "^0.5.1",
42
+ "class-validator": "^0.14.1",
43
+ "eslint": "^8.57.1",
44
+ "react": "^19.0.0",
45
+ "react-router-dom": "^7.3.0",
46
+ "reflect-metadata": "^0.2.2",
47
+ "rollup": "^4.35.0",
48
+ "rollup-plugin-peer-deps-external": "^2.2.4",
49
+ "rollup-plugin-terser": "^7.0.2",
50
+ "rollup-plugin-typescript2": "^0.36.0",
51
+ "typescript": "^5.8.2"
52
+ }
53
+ }
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execSync } = require('child_process');
6
+ const { program } = require('commander');
7
+
8
+ // Define command line parameters
9
+ program
10
+ .option('--src <path>', 'Source path containing NestJS entity files')
11
+ .option('--to <path>', 'Destination path for generated entity files')
12
+ .parse(process.argv);
13
+
14
+ const options = program.opts();
15
+
16
+ // Check if required parameters are provided
17
+ if (!options.src || !options.to) {
18
+ console.error('Error: Both --src and --to parameters are required');
19
+ process.exit(1);
20
+ }
21
+
22
+ // Resolve paths
23
+ const srcPath = path.resolve(process.cwd(), options.src);
24
+ const destPath = path.resolve(process.cwd(), options.to);
25
+
26
+ // Ensure destination directory exists
27
+ if (!fs.existsSync(destPath)) {
28
+ fs.mkdirSync(destPath, { recursive: true });
29
+ }
30
+
31
+ // Find all entity files in the source directory recursively
32
+ function findEntityFiles(dir) {
33
+ let results = [];
34
+
35
+ const files = fs.readdirSync(dir, { withFileTypes: true });
36
+
37
+ for (const file of files) {
38
+ const fullPath = path.join(dir, file.name);
39
+
40
+ if (file.isDirectory()) {
41
+ results = results.concat(findEntityFiles(fullPath));
42
+ } else if (file.name.endsWith('.entity.ts')) {
43
+ results.push(fullPath);
44
+ }
45
+ }
46
+
47
+ return results;
48
+ }
49
+
50
+ // Extract interfaces ending with *Entity and class-validator decorators
51
+ function processEntityFile(filePath) {
52
+ const content = fs.readFileSync(filePath, 'utf8');
53
+ const fileName = path.basename(filePath);
54
+
55
+ // Regular expression to find interfaces ending with Entity
56
+ const interfaceRegex = /export\s+interface\s+(\w+Entity)\s*{([^}]*)}/gs;
57
+ const interfaceMatches = Array.from(content.matchAll(interfaceRegex));
58
+
59
+ const results = [];
60
+
61
+ for (const match of interfaceMatches) {
62
+ const interfaceName = match[1];
63
+ const interfaceContent = match[2];
64
+
65
+ // Create a new file with only the interface and class-validator imports
66
+ let newContent = `import { ${getClassValidatorImports(content)} } from 'class-validator';\n\n`;
67
+ newContent += `export interface ${interfaceName} {\n${extractPropertiesWithDecorators(interfaceContent, content)}\n}`;
68
+
69
+ results.push({
70
+ name: interfaceName,
71
+ content: newContent
72
+ });
73
+ }
74
+
75
+ return results;
76
+ }
77
+
78
+ // Extract class-validator imports from the original file
79
+ function getClassValidatorImports(content) {
80
+ const importRegex = /import\s+{([^}]*?)}\s+from\s+['"]class-validator['"]/;
81
+ const match = content.match(importRegex);
82
+
83
+ if (match && match[1]) {
84
+ return match[1].split(',')
85
+ .map(imp => imp.trim())
86
+ .filter(imp => imp !== '')
87
+ .join(', ');
88
+ }
89
+
90
+ return '';
91
+ }
92
+
93
+ // Extract properties with class-validator decorators
94
+ function extractPropertiesWithDecorators(interfaceContent, fullContent) {
95
+ const lines = interfaceContent.split('\n');
96
+ let result = '';
97
+
98
+ for (const line of lines) {
99
+ const propertyMatch = line.match(/^\s*(\w+)[\?:].*$/);
100
+
101
+ if (propertyMatch) {
102
+ const propName = propertyMatch[1];
103
+ const decoratorRegex = new RegExp(`@\\w+\\([^)]*\\)\\s*${propName}`, 'g');
104
+ const decoratorMatches = Array.from(fullContent.matchAll(decoratorRegex));
105
+
106
+ // Add all decorators for this property
107
+ if (decoratorMatches.length > 0) {
108
+ for (const dMatch of decoratorMatches) {
109
+ const decorator = dMatch[0].split(propName)[0].trim();
110
+ result += ` ${decorator}\n`;
111
+ }
112
+ }
113
+
114
+ result += ` ${line.trim()}\n\n`;
115
+ }
116
+ }
117
+
118
+ return result;
119
+ }
120
+
121
+ // Main function
122
+ function main() {
123
+ try {
124
+ console.log(`Searching for entity files in ${srcPath}...`);
125
+ const entityFiles = findEntityFiles(srcPath);
126
+
127
+ console.log(`Found ${entityFiles.length} entity files.`);
128
+
129
+ for (const file of entityFiles) {
130
+ console.log(`Processing ${file}...`);
131
+ const entities = processEntityFile(file);
132
+
133
+ for (const entity of entities) {
134
+ const outputPath = path.join(destPath, `${entity.name}.ts`);
135
+ fs.writeFileSync(outputPath, entity.content);
136
+ console.log(`Generated ${outputPath}`);
137
+ }
138
+ }
139
+
140
+ console.log('Done!');
141
+ } catch (error) {
142
+ console.error('Error:', error.message);
143
+ process.exit(1);
144
+ }
145
+ }
146
+
147
+ main();