proje-react-panel 1.0.0 → 1.0.1

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.
Files changed (38) hide show
  1. package/.idea/modules.xml +1 -1
  2. package/dist/assets/output-ML2TfIjs.css +1 -0
  3. package/dist/{list → components/list}/List.d.ts +2 -3
  4. package/dist/index.cjs.js +12 -1
  5. package/dist/index.d.ts +6 -1
  6. package/dist/index.esm.js +12 -1
  7. package/dist/screens/ControllerCreate.d.ts +0 -1
  8. package/dist/{getFields.d.ts → utils/getFields.d.ts} +1 -1
  9. package/dist/{storeData.d.ts → utils/storeData.d.ts} +1 -1
  10. package/package.json +9 -5
  11. package/src/api/crudApi.ts +16 -0
  12. package/src/components/Panel.tsx +13 -0
  13. package/src/components/layout/Layout.tsx +18 -0
  14. package/src/components/layout/SideBar.tsx +23 -0
  15. package/src/components/list/List.tsx +75 -0
  16. package/src/declerations/Cell.ts +37 -0
  17. package/src/declerations/Crud.ts +20 -0
  18. package/src/index.ts +6 -0
  19. package/src/screens/ControllerCreate.tsx +13 -0
  20. package/src/screens/ControllerDetails.tsx +34 -0
  21. package/src/screens/ControllerEdit.tsx +31 -0
  22. package/src/screens/ControllerList.tsx +40 -0
  23. package/src/screens/Form.tsx +67 -0
  24. package/src/styles/form.scss +58 -0
  25. package/src/styles/index.scss +4 -0
  26. package/src/styles/layout.scss +13 -0
  27. package/src/styles/list.scss +39 -0
  28. package/src/styles/sidebar.scss +76 -0
  29. package/src/types/Screen.ts +4 -0
  30. package/src/types/ScreenCreatorData.ts +9 -0
  31. package/src/utils/createScreens.ts +5 -0
  32. package/src/utils/getFields.ts +21 -0
  33. package/src/utils/getScreenForRoutes.tsx +44 -0
  34. package/src/utils/storeData.ts +7 -0
  35. /package/.idea/{react-panel.iml → proje-react-panel.iml} +0 -0
  36. /package/dist/{Panel.d.ts → components/Panel.d.ts} +0 -0
  37. /package/dist/{createScreens.d.ts → utils/createScreens.d.ts} +0 -0
  38. /package/dist/{getScreenForRoutes.d.ts → utils/getScreenForRoutes.d.ts} +0 -0
@@ -0,0 +1,9 @@
1
+ import { CellOptions } from "../declerations/Cell";
2
+ import { CrudOptions } from "../declerations/Crud";
3
+
4
+ export type ScreenCreatorData<T> = {
5
+ resolver: any,
6
+ fields: string[],
7
+ cells: CellOptions<T>[],
8
+ crud: CrudOptions
9
+ }
@@ -0,0 +1,5 @@
1
+ import { StoreData } from "./storeData";
2
+
3
+ export function createScreens(screens: Record<string, any>) {
4
+ StoreData.screens = screens;
5
+ }
@@ -0,0 +1,21 @@
1
+ import { getMetadataStorage } from "class-validator";
2
+ import { getClassCrudData } from "../declerations/Crud";
3
+ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
4
+ import { getCellFields } from "../declerations/Cell";
5
+ import { ScreenCreatorData } from "../types/ScreenCreatorData";
6
+
7
+ export function getFields<T>(entityClass: T): ScreenCreatorData<T> {
8
+ const metadataStorage = getMetadataStorage();
9
+ const targetMetadata = metadataStorage.getTargetValidationMetadatas(
10
+ entityClass as any,
11
+ "",
12
+ false, false,
13
+ );
14
+ const crud = getClassCrudData(entityClass);
15
+ return {
16
+ resolver: classValidatorResolver(entityClass as any),
17
+ fields: Array.from(new Set(targetMetadata.map((meta) => meta.propertyName))),
18
+ cells: getCellFields(entityClass),
19
+ crud: crud!,
20
+ };
21
+ }
@@ -0,0 +1,44 @@
1
+ import { Route } from 'react-router-dom';
2
+ import { ControllerCreate } from '../screens/ControllerCreate';
3
+ import { ControllerDetails } from '../screens/ControllerDetails';
4
+ import { ControllerEdit } from '../screens/ControllerEdit';
5
+ import { ControllerList } from '../screens/ControllerList';
6
+ import { Screen } from '../types/Screen';
7
+ import React from 'react';
8
+ import { StoreData } from "./storeData";
9
+
10
+ export function getScreenForRoutes() {
11
+ const screens = Object.entries(StoreData.screens);
12
+ return (
13
+ <>
14
+ {screens.map(([key, screenData]) => {
15
+ let routePath = `/${screenData.crud.controller}`;
16
+ const screen: Screen = {
17
+ key,
18
+ controller: screenData.crud.controller,
19
+ };
20
+ return (
21
+ <React.Fragment key={'index'}>
22
+ <Route
23
+ path={routePath + '/create'}
24
+ element={<ControllerCreate screen={screen} />}
25
+ />
26
+ <Route
27
+ path={routePath + '/details/:id'}
28
+ element={<ControllerDetails screen={screen} />}
29
+ />
30
+ <Route
31
+ path={routePath + '/edit/:id'}
32
+ element={<ControllerEdit screen={screen} />}
33
+ />
34
+ <Route
35
+ path={routePath}
36
+ element={<ControllerList screen={screen} />}
37
+ />
38
+ </React.Fragment>
39
+ );
40
+ })}
41
+ <Route path="*" element={<div>404 - Not Found</div>} />
42
+ </>
43
+ );
44
+ }
@@ -0,0 +1,7 @@
1
+ import { ScreenCreatorData } from "../types/ScreenCreatorData";
2
+
3
+ export const StoreData: {
4
+ screens: Record<string, ScreenCreatorData<any>>
5
+ } = {
6
+ screens: {},
7
+ };
File without changes