proje-react-panel 1.0.14 → 1.0.16

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 (168) hide show
  1. package/.cursor/rules.md +122 -0
  2. package/.cursor/settings.json +57 -0
  3. package/.eslintrc.js +5 -0
  4. package/.eslintrc.json +26 -0
  5. package/.prettierrc +10 -0
  6. package/.vscode/launch.json +27 -0
  7. package/.vscode/settings.json +8 -0
  8. package/PTD.md +234 -0
  9. package/README.md +62 -28
  10. package/dist/api/CrudApi.d.ts +12 -0
  11. package/dist/components/Panel.d.ts +2 -2
  12. package/dist/components/components/Checkbox.d.ts +6 -0
  13. package/dist/components/components/Counter.d.ts +9 -0
  14. package/dist/components/components/FormField.d.ts +13 -0
  15. package/dist/components/components/ImageUploader.d.ts +15 -0
  16. package/dist/components/components/InnerForm.d.ts +12 -0
  17. package/dist/components/components/LoadingScreen.d.ts +2 -0
  18. package/dist/components/components/index.d.ts +8 -0
  19. package/dist/components/components/list/Datagrid.d.ts +13 -0
  20. package/dist/components/components/list/EmptyList.d.ts +2 -0
  21. package/dist/components/components/list/FilterPopup.d.ts +11 -0
  22. package/dist/components/components/list/ListPage.d.ts +22 -0
  23. package/dist/components/components/list/Pagination.d.ts +11 -0
  24. package/dist/components/components/list/index.d.ts +0 -0
  25. package/dist/components/layout/Layout.d.ts +2 -1
  26. package/dist/components/layout/SideBar.d.ts +4 -3
  27. package/dist/components/layout/index.d.ts +2 -0
  28. package/dist/components/list/Datagrid.d.ts +12 -0
  29. package/dist/components/list/EmptyList.d.ts +2 -0
  30. package/dist/components/list/FilterPopup.d.ts +10 -0
  31. package/dist/components/list/Pagination.d.ts +11 -0
  32. package/dist/components/list/index.d.ts +0 -0
  33. package/dist/{src/screens → components/pages}/ControllerDetails.d.ts +1 -1
  34. package/dist/components/pages/FormPage.d.ts +12 -0
  35. package/dist/components/pages/ListPage.d.ts +18 -0
  36. package/dist/components/pages/Login.d.ts +13 -0
  37. package/dist/decorators/form/Form.d.ts +6 -0
  38. package/dist/decorators/form/FormOptions.d.ts +7 -0
  39. package/dist/decorators/form/Input.d.ts +17 -0
  40. package/dist/decorators/form/getFormFields.d.ts +3 -0
  41. package/dist/decorators/list/Cell.d.ts +21 -0
  42. package/dist/decorators/list/GetCellFields.d.ts +2 -0
  43. package/dist/decorators/list/ImageCell.d.ts +6 -0
  44. package/dist/decorators/list/List.d.ts +28 -0
  45. package/dist/decorators/list/ListData.d.ts +6 -0
  46. package/dist/decorators/list/getListFields.d.ts +2 -0
  47. package/dist/index.cjs.js +1 -1
  48. package/dist/index.d.ts +20 -10
  49. package/dist/index.esm.js +1 -1
  50. package/dist/initPanel.d.ts +2 -2
  51. package/dist/store/store.d.ts +1 -5
  52. package/dist/types/AnyClass.d.ts +1 -0
  53. package/dist/types/ScreenCreatorData.d.ts +5 -3
  54. package/dist/types/initPanelOptions.d.ts +0 -6
  55. package/dist/utils/format.d.ts +1 -0
  56. package/dist/utils/getFields.d.ts +2 -1
  57. package/package.json +13 -6
  58. package/src/api/CrudApi.ts +30 -11
  59. package/src/assets/icons/svg/create.svg +9 -0
  60. package/src/assets/icons/svg/filter.svg +3 -0
  61. package/src/assets/icons/svg/pencil.svg +8 -0
  62. package/src/assets/icons/svg/search.svg +8 -0
  63. package/src/assets/icons/svg/trash.svg +8 -0
  64. package/src/components/Panel.tsx +11 -11
  65. package/src/components/components/Checkbox.tsx +9 -0
  66. package/src/components/components/Counter.tsx +51 -0
  67. package/src/components/components/FormField.tsx +94 -0
  68. package/src/components/components/ImageUploader.tsx +301 -0
  69. package/src/components/components/InnerForm.tsx +74 -0
  70. package/src/components/components/LoadingScreen.tsx +12 -0
  71. package/src/components/components/index.ts +8 -0
  72. package/src/components/components/list/Datagrid.tsx +121 -0
  73. package/src/components/components/list/EmptyList.tsx +26 -0
  74. package/src/components/components/list/FilterPopup.tsx +202 -0
  75. package/src/components/components/list/ListPage.tsx +178 -0
  76. package/src/components/components/list/Pagination.tsx +110 -0
  77. package/src/components/components/list/index.ts +1 -0
  78. package/src/components/layout/Layout.tsx +8 -1
  79. package/src/components/layout/SideBar.tsx +103 -31
  80. package/src/components/layout/index.ts +2 -0
  81. package/src/components/pages/ControllerDetails.tsx +37 -0
  82. package/src/components/pages/FormPage.tsx +34 -0
  83. package/src/components/pages/Login.tsx +79 -0
  84. package/src/decorators/form/Form.ts +18 -0
  85. package/src/decorators/form/FormOptions.ts +8 -0
  86. package/src/decorators/form/Input.ts +53 -0
  87. package/src/decorators/form/getFormFields.ts +13 -0
  88. package/src/decorators/list/Cell.ts +32 -0
  89. package/src/decorators/list/GetCellFields.ts +13 -0
  90. package/src/decorators/list/ImageCell.ts +13 -0
  91. package/src/decorators/list/List.ts +31 -0
  92. package/src/decorators/list/ListData.ts +7 -0
  93. package/src/decorators/list/getListFields.ts +10 -0
  94. package/src/index.ts +28 -10
  95. package/src/initPanel.ts +4 -12
  96. package/src/store/store.ts +23 -28
  97. package/src/styles/counter.scss +42 -0
  98. package/src/styles/filter-popup.scss +134 -0
  99. package/src/styles/image-uploader.scss +94 -0
  100. package/src/styles/index.scss +26 -7
  101. package/src/styles/layout.scss +1 -6
  102. package/src/styles/list.scss +175 -7
  103. package/src/styles/loading-screen.scss +42 -0
  104. package/src/styles/pagination.scss +66 -0
  105. package/src/styles/sidebar.scss +64 -0
  106. package/src/styles/utils/scrollbar.scss +19 -0
  107. package/src/types/AnyClass.ts +1 -0
  108. package/src/types/ScreenCreatorData.ts +5 -3
  109. package/src/types/initPanelOptions.ts +1 -7
  110. package/src/types/svg.d.ts +5 -0
  111. package/src/utils/format.ts +7 -0
  112. package/src/utils/getFields.ts +11 -9
  113. package/dist/api/crudApi.d.ts +0 -17
  114. package/dist/components/Form.d.ts +0 -6
  115. package/dist/components/FormField.d.ts +0 -13
  116. package/dist/components/list/List.d.ts +0 -10
  117. package/dist/components/screens/ControllerCreate.d.ts +0 -5
  118. package/dist/components/screens/ControllerDetails.d.ts +0 -5
  119. package/dist/components/screens/ControllerEdit.d.ts +0 -5
  120. package/dist/components/screens/ControllerList.d.ts +0 -5
  121. package/dist/components/screens/Login.d.ts +0 -2
  122. package/dist/decorators/Cell.d.ts +0 -9
  123. package/dist/decorators/Input.d.ts +0 -13
  124. package/dist/hooks/useScreens.d.ts +0 -2
  125. package/dist/initPanelOptions.d.ts +0 -8
  126. package/dist/screens/ControllerCreate.d.ts +0 -5
  127. package/dist/screens/ControllerDetails.d.ts +0 -5
  128. package/dist/screens/ControllerEdit.d.ts +0 -5
  129. package/dist/screens/ControllerList.d.ts +0 -5
  130. package/dist/screens/Form.d.ts +0 -6
  131. package/dist/src/api/crudApi.d.ts +0 -6
  132. package/dist/src/components/Panel.d.ts +0 -9
  133. package/dist/src/components/layout/Layout.d.ts +0 -11
  134. package/dist/src/components/layout/SideBar.d.ts +0 -10
  135. package/dist/src/components/list/List.d.ts +0 -10
  136. package/dist/src/decorators/Cell.d.ts +0 -10
  137. package/dist/src/decorators/Crud.d.ts +0 -6
  138. package/dist/src/index.d.ts +0 -8
  139. package/dist/src/screens/ControllerCreate.d.ts +0 -5
  140. package/dist/src/screens/ControllerEdit.d.ts +0 -5
  141. package/dist/src/screens/ControllerList.d.ts +0 -5
  142. package/dist/src/screens/Form.d.ts +0 -6
  143. package/dist/src/store/store.d.ts +0 -19
  144. package/dist/src/types/Screen.d.ts +0 -4
  145. package/dist/src/types/ScreenCreatorData.d.ts +0 -8
  146. package/dist/src/utils/createScreens.d.ts +0 -1
  147. package/dist/src/utils/getFields.d.ts +0 -2
  148. package/dist/src/utils/getScreens.d.ts +0 -2
  149. package/dist/utils/crudScreens.d.ts +0 -2
  150. package/dist/utils/getScreens.d.ts +0 -2
  151. package/src/api/AuthApi.ts +0 -14
  152. package/src/components/Form.tsx +0 -70
  153. package/src/components/FormField.tsx +0 -60
  154. package/src/components/list/List.tsx +0 -81
  155. package/src/components/screens/ControllerCreate.tsx +0 -7
  156. package/src/components/screens/ControllerDetails.tsx +0 -40
  157. package/src/components/screens/ControllerEdit.tsx +0 -35
  158. package/src/components/screens/ControllerList.tsx +0 -45
  159. package/src/components/screens/Login.tsx +0 -68
  160. package/src/decorators/Cell.ts +0 -34
  161. package/src/decorators/Input.ts +0 -50
  162. package/src/hooks/useScreens.tsx +0 -36
  163. /package/dist/components/{ErrorBoundary.d.ts → components/ErrorBoundary.d.ts} +0 -0
  164. /package/dist/components/{ErrorComponent.d.ts → components/ErrorComponent.d.ts} +0 -0
  165. /package/dist/components/{Label.d.ts → components/Label.d.ts} +0 -0
  166. /package/src/components/{ErrorBoundary.tsx → components/ErrorBoundary.tsx} +0 -0
  167. /package/src/components/{ErrorComponent.tsx → components/ErrorComponent.tsx} +0 -0
  168. /package/src/components/{Label.tsx → components/Label.tsx} +0 -0
@@ -0,0 +1,8 @@
1
+ export { InnerForm } from './InnerForm';
2
+ export { FormField } from './FormField';
3
+ export { LoadingScreen } from './LoadingScreen';
4
+ export { Counter } from './Counter';
5
+ export { ImageUploader } from './ImageUploader';
6
+ export { ErrorComponent } from './ErrorComponent';
7
+ export { Label } from './Label';
8
+ export { ErrorBoundary } from './ErrorBoundary';
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ListData } from '../../../decorators/list/ListData';
3
+ interface DatagridProps<T extends {
4
+ id: string;
5
+ }> {
6
+ data: T[];
7
+ listData: ListData;
8
+ onRemoveItem?: (item: T) => Promise<void>;
9
+ }
10
+ export declare function Datagrid<T extends {
11
+ id: string;
12
+ }>({ data, listData, onRemoveItem }: DatagridProps<T>): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const EmptyList: React.FC;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ListData } from '../../../decorators/list/ListData';
3
+ interface FilterPopupProps {
4
+ isOpen: boolean;
5
+ onClose: () => void;
6
+ onApplyFilters: (filters: Record<string, string>) => void;
7
+ listData: ListData;
8
+ activeFilters?: Record<string, string>;
9
+ }
10
+ export declare function FilterPopup({ isOpen, onClose, onApplyFilters, listData, activeFilters, }: FilterPopupProps): React.ReactElement | null;
11
+ export {};
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { AnyClass } from '../../../types/AnyClass';
3
+ export interface GetDataParams {
4
+ page?: number;
5
+ limit?: number;
6
+ filters?: Record<string, any>;
7
+ }
8
+ export interface PaginatedResponse<T> {
9
+ data: T[];
10
+ total: number;
11
+ page: number;
12
+ limit: number;
13
+ }
14
+ export type GetDataForList<T> = (params: GetDataParams) => Promise<PaginatedResponse<T>>;
15
+ export declare function ListPage<T extends AnyClass & {
16
+ id: string;
17
+ }>({ model, getData, onRemoveItem, customHeader, }: {
18
+ model: T;
19
+ getData: GetDataForList<T>;
20
+ customHeader?: React.ReactNode;
21
+ onRemoveItem?: (item: T) => Promise<void>;
22
+ }): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface PaginationProps {
3
+ pagination: {
4
+ total: number;
5
+ page: number;
6
+ limit: number;
7
+ };
8
+ onPageChange: (page: number) => void;
9
+ }
10
+ export declare function Pagination({ pagination, onPageChange }: PaginationProps): React.JSX.Element | null;
11
+ export {};
File without changes
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { ScreenCreatorData } from "../../types/ScreenCreatorData";
3
- export declare function Layout<IconType>({ children, menu, getIcons, }: {
3
+ export declare function Layout<IconType>({ children, menu, getIcons, logout, }: {
4
4
  children?: React.ReactNode;
5
5
  menu?: (screens: Record<string, ScreenCreatorData>) => {
6
6
  name: string;
@@ -8,4 +8,5 @@ export declare function Layout<IconType>({ children, menu, getIcons, }: {
8
8
  iconType: IconType;
9
9
  }[];
10
10
  getIcons?: (iconType: IconType) => React.ReactNode;
11
+ logout?: () => void;
11
12
  }): React.JSX.Element;
@@ -1,13 +1,14 @@
1
- import React from "react";
2
- import { ScreenCreatorData } from "../../types/ScreenCreatorData";
1
+ import React from 'react';
2
+ import { ScreenCreatorData } from '../../types/ScreenCreatorData';
3
3
  type GetMenuFunction<IconType> = (screens: Record<string, ScreenCreatorData>) => {
4
4
  name: string;
5
5
  path: string;
6
6
  iconType: IconType;
7
7
  }[];
8
8
  type GetIconsFunction<IconType> = (iconType: IconType) => React.ReactNode;
9
- export declare function SideBar<IconType>({ menu, getIcons, }: {
9
+ export declare function SideBar<IconType>({ menu, getIcons, onLogout, }: {
10
10
  menu?: GetMenuFunction<IconType>;
11
11
  getIcons?: GetIconsFunction<IconType>;
12
+ onLogout?: () => void;
12
13
  }): React.JSX.Element;
13
14
  export {};
@@ -0,0 +1,2 @@
1
+ export { SideBar } from './SideBar';
2
+ export { Layout } from './Layout';
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { ListData } from '../../decorators/list/ListData';
3
+ interface ListProps<T extends {
4
+ id: string;
5
+ }> {
6
+ data: T[];
7
+ listData: ListData;
8
+ }
9
+ export declare function Datagrid<T extends {
10
+ id: string;
11
+ }>({ data, listData }: ListProps<T>): React.JSX.Element;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const EmptyList: React.FC;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { CellOptions } from '../../decorators/list/Cell';
3
+ interface FilterPopupProps {
4
+ isOpen: boolean;
5
+ onClose: () => void;
6
+ onApplyFilters: (filters: any) => void;
7
+ fields: CellOptions[];
8
+ }
9
+ export declare const FilterPopup: React.FC<FilterPopupProps>;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ interface PaginationProps {
3
+ pagination: {
4
+ total: number;
5
+ page: number;
6
+ limit: number;
7
+ };
8
+ onPageChange: (page: number) => void;
9
+ }
10
+ export declare function Pagination({ pagination, onPageChange }: PaginationProps): React.JSX.Element | null;
11
+ export {};
File without changes
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Screen } from '../types/Screen';
2
+ import { Screen } from '../../types/Screen';
3
3
  export declare function ControllerDetails({ screen }: {
4
4
  screen: Screen;
5
5
  }): React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export type GetDetailsDataFN<T> = (param: Record<string, string>) => Promise<T>;
4
+ export type OnSubmitFN<T> = (data: T) => Promise<T>;
5
+ export interface FormPageProps<T extends AnyClass> {
6
+ model: T;
7
+ getDetailsData?: GetDetailsDataFN<T>;
8
+ redirect?: string;
9
+ onSubmit: OnSubmitFN<T>;
10
+ redirectBackOnSuccess?: boolean;
11
+ }
12
+ export declare function FormPage<T extends AnyClass>({ model, getDetailsData, onSubmit, redirect, redirectBackOnSuccess, ...rest }: FormPageProps<T>): React.JSX.Element;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export interface PaginationParams {
4
+ page?: number;
5
+ limit?: number;
6
+ filters?: Record<string, any>;
7
+ }
8
+ export interface PaginatedResponse<T> {
9
+ data: T[];
10
+ total: number;
11
+ page: number;
12
+ limit: number;
13
+ }
14
+ export type GetDataForList<T> = (params: PaginationParams) => Promise<PaginatedResponse<T>>;
15
+ export declare function ListPage<T extends AnyClass>({ model, getData, }: {
16
+ model: T;
17
+ getData: GetDataForList<T>;
18
+ }): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export type OnLogin = {
3
+ login: (username: string, password: string) => Promise<LoginResponse>;
4
+ };
5
+ interface LoginResponse {
6
+ user: any;
7
+ token: string;
8
+ }
9
+ interface LoginProps {
10
+ onLogin: OnLogin;
11
+ }
12
+ export declare function Login({ onLogin }: LoginProps): React.JSX.Element;
13
+ export {};
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { AnyClass } from "../../types/AnyClass";
3
+ export interface FormConfiguration {
4
+ }
5
+ export declare function FormDecorator(options?: FormConfiguration): ClassDecorator;
6
+ export declare function getFormConfiguration(entityClass: AnyClass): FormConfiguration | undefined;
@@ -0,0 +1,7 @@
1
+ import { FormConfiguration } from "./Form";
2
+ import { InputOptions } from "./Input";
3
+ export interface FormOptions {
4
+ resolver: any;
5
+ form?: FormConfiguration;
6
+ inputs?: InputOptions[];
7
+ }
@@ -0,0 +1,17 @@
1
+ import 'reflect-metadata';
2
+ import { AnyClass } from '../../types/AnyClass';
3
+ export interface InputOptions {
4
+ type?: 'input' | 'select' | 'textarea' | 'file-upload' | 'checkbox' | 'hidden' | 'nested';
5
+ inputType?: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
6
+ name?: string;
7
+ label?: string;
8
+ placeholder?: string;
9
+ cancelPasswordValidationOnEdit?: boolean;
10
+ options?: {
11
+ value: string;
12
+ label: string;
13
+ }[];
14
+ nestedFields?: InputOptions[];
15
+ }
16
+ export declare function Input(options?: InputOptions): PropertyDecorator;
17
+ export declare function getInputFields<T extends AnyClass>(entityClass: T): InputOptions[];
@@ -0,0 +1,3 @@
1
+ import { AnyClass } from "../../types/AnyClass";
2
+ import { FormOptions } from "./FormOptions";
3
+ export declare function getFormFields<T extends AnyClass>(entityClass: T): FormOptions;
@@ -0,0 +1,21 @@
1
+ import 'reflect-metadata';
2
+ export declare const CELL_KEY: unique symbol;
3
+ interface Filter {
4
+ type: 'string' | 'number' | 'date' | 'static-select';
5
+ }
6
+ export interface StaticSelectFilter extends Filter {
7
+ type: 'static-select';
8
+ options: {
9
+ value: string;
10
+ label: string;
11
+ }[];
12
+ }
13
+ export interface CellOptions {
14
+ name?: string;
15
+ title?: string;
16
+ type?: 'string' | 'date' | 'image' | 'number';
17
+ placeHolder?: string;
18
+ filter?: Filter | StaticSelectFilter;
19
+ }
20
+ export declare function Cell(options?: CellOptions): PropertyDecorator;
21
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CellOptions } from "./Cell";
2
+ export declare function getCellFields(entityClass: any): CellOptions[];
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { CellOptions } from "./Cell";
3
+ export interface ImageCellOptions extends CellOptions {
4
+ baseUrl: string;
5
+ }
6
+ export declare function ImageCell(options?: ImageCellOptions): PropertyDecorator;
@@ -0,0 +1,28 @@
1
+ import 'reflect-metadata';
2
+ export interface ListHeaderOptions {
3
+ title?: string;
4
+ create?: {
5
+ path: string;
6
+ label: string;
7
+ };
8
+ }
9
+ export interface ListUtilCellOptions {
10
+ details?: {
11
+ path: string;
12
+ label: string;
13
+ };
14
+ edit?: {
15
+ path: string;
16
+ label: string;
17
+ };
18
+ delete?: {
19
+ path: string;
20
+ label: string;
21
+ };
22
+ }
23
+ export interface ListOptions {
24
+ headers?: ListHeaderOptions;
25
+ utilCells?: ListUtilCellOptions;
26
+ }
27
+ export declare function List(options?: ListOptions): ClassDecorator;
28
+ export declare function getClassListData(entityClass: any): ListOptions | undefined;
@@ -0,0 +1,6 @@
1
+ import { ListOptions } from "./List";
2
+ import { CellOptions } from "./Cell";
3
+ export interface ListData {
4
+ list?: ListOptions;
5
+ cells: CellOptions[];
6
+ }
@@ -0,0 +1,2 @@
1
+ import { ListData } from "./ListData";
2
+ export declare function getListFields<T>(entityClass: T): ListData;