proje-react-panel 1.6.0 → 1.8.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/.cursor/rules.md +11 -1
- package/.vscode/settings.json +1 -1
- package/README.md +57 -1
- package/dist/__tests__/components/form/CustomField.test.d.ts +4 -0
- package/dist/api/ApiConfig.d.ts +11 -0
- package/dist/api/AuthApi.d.ts +2 -5
- package/dist/api/CrudApi.d.ts +11 -12
- package/dist/components/DashboardContainer.d.ts +7 -0
- package/dist/components/DashboardGrid.d.ts +9 -0
- package/dist/components/DashboardItem.d.ts +10 -0
- package/dist/components/ThemeSwitcher.d.ts +7 -0
- package/dist/components/dashboard/Dashboard.d.ts +7 -0
- package/dist/components/dashboard/DashboardGrid.d.ts +7 -0
- package/dist/components/dashboard/DashboardItem.d.ts +6 -0
- package/dist/components/dashboard/index.d.ts +3 -0
- package/dist/components/form/CustomField.d.ts +9 -0
- package/dist/decorators/auth/DefaultLoginForm.d.ts +4 -0
- package/dist/decorators/form/Input.d.ts +1 -1
- package/dist/decorators/form/inputs/CustomInput.d.ts +16 -0
- package/dist/index.cjs.js +15 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +15 -1
- package/dist/store/themeStore.d.ts +23 -0
- package/dist/types/Login.d.ts +8 -0
- package/guides/AUTH_LAYOUT_EXAMPLE.md +343 -0
- package/guides/AUTH_LAYOUT_GUIDE.md +819 -0
- package/guides/COLOR_SYSTEM_GUIDE.md +296 -0
- package/guides/DASHBOARD_GUIDE.md +531 -0
- package/guides/IMPLEMENTATION_GUIDE.md +899 -0
- package/guides/USAGE.md +85 -0
- package/how_to.md +184 -0
- package/package.json +7 -1
- package/src/__tests__/components/form/CustomField.test.tsx +92 -0
- package/src/api/ApiConfig.ts +63 -0
- package/src/api/AuthApi.ts +8 -0
- package/src/api/CrudApi.ts +96 -60
- package/src/components/dashboard/Dashboard.tsx +11 -0
- package/src/components/dashboard/DashboardGrid.tsx +14 -0
- package/src/components/dashboard/DashboardItem.tsx +9 -0
- package/src/components/dashboard/index.ts +3 -0
- package/src/components/form/CustomField.tsx +34 -0
- package/src/components/form/FormField.tsx +5 -1
- package/src/components/layout/Layout.tsx +18 -2
- package/src/components/list/ListPage.tsx +1 -1
- package/src/decorators/auth/DefaultLoginForm.ts +32 -0
- package/src/decorators/form/Input.ts +1 -1
- package/src/decorators/form/inputs/CustomInput.ts +26 -0
- package/src/index.ts +31 -0
- package/src/styles/base/_variables.scss +45 -0
- package/src/styles/components/button.scss +3 -3
- package/src/styles/components/checkbox.scss +6 -6
- package/src/styles/components/form-header.scss +21 -19
- package/src/styles/components/uploader.scss +15 -37
- package/src/styles/counter.scss +25 -33
- package/src/styles/dashboard.scss +9 -0
- package/src/styles/details.scss +6 -15
- package/src/styles/error-boundary.scss +75 -74
- package/src/styles/filter-popup.scss +29 -27
- package/src/styles/form.scss +16 -15
- package/src/styles/index.scss +8 -4
- package/src/styles/layout.scss +9 -8
- package/src/styles/list.scss +29 -27
- package/src/styles/loading-screen.scss +4 -4
- package/src/styles/login.scss +3 -3
- package/src/styles/pagination.scss +13 -13
- package/src/styles/sidebar.scss +24 -22
- package/src/styles/utils/scrollbar.scss +4 -3
- package/src/types/Login.ts +9 -0
- package/src/utils/logout.ts +2 -0
- package/dist/components/components/Checkbox.d.ts +0 -7
- package/dist/components/components/Counter.d.ts +0 -9
- package/dist/components/components/ErrorBoundary.d.ts +0 -16
- package/dist/components/components/ErrorComponent.d.ts +0 -4
- package/dist/components/components/FormField.d.ts +0 -17
- package/dist/components/components/ImageUploader.d.ts +0 -15
- package/dist/components/components/InnerForm.d.ts +0 -17
- package/dist/components/components/Label.d.ts +0 -9
- package/dist/components/components/LoadingScreen.d.ts +0 -2
- package/dist/components/components/Uploader.d.ts +0 -8
- package/dist/components/components/index.d.ts +0 -8
- package/dist/components/components/list/Datagrid.d.ts +0 -9
- package/dist/components/components/list/EmptyList.d.ts +0 -2
- package/dist/components/components/list/FilterPopup.d.ts +0 -11
- package/dist/components/components/list/ListPage.d.ts +0 -20
- package/dist/components/components/list/Pagination.d.ts +0 -11
- package/dist/components/components/list/index.d.ts +0 -0
- package/dist/components/pages/ControllerDetails.d.ts +0 -5
- package/dist/components/pages/FormPage.d.ts +0 -18
- package/dist/components/pages/ListPage.d.ts +0 -18
- package/dist/components/pages/Login.d.ts +0 -13
- package/dist/decorators/Crud.d.ts +0 -6
- package/dist/decorators/form/FormOptions.d.ts +0 -7
- package/dist/decorators/form/getFormFields.d.ts +0 -3
- package/dist/decorators/list/GetCellFields.d.ts +0 -2
- package/dist/decorators/list/ImageCell.d.ts +0 -6
- package/dist/decorators/list/ListData.d.ts +0 -6
- package/dist/decorators/list/getListFields.d.ts +0 -2
- package/dist/initPanel.d.ts +0 -2
- package/dist/types/Screen.d.ts +0 -4
- package/dist/types/ScreenCreatorData.d.ts +0 -13
- package/dist/types/getDetailsData.d.ts +0 -1
- package/dist/types/initPanelOptions.d.ts +0 -2
- package/dist/utils/createScreens.d.ts +0 -1
- package/dist/utils/getFields.d.ts +0 -3
package/.cursor/rules.md
CHANGED
|
@@ -40,7 +40,17 @@ export function Button({ label, onClick }: ButtonProps) {
|
|
|
40
40
|
|
|
41
41
|
Use SCSS exclusively for styling.
|
|
42
42
|
|
|
43
|
-
## 5.
|
|
43
|
+
## 5. Package Management
|
|
44
|
+
|
|
45
|
+
**ALWAYS use yarn, NEVER use npm.**
|
|
46
|
+
|
|
47
|
+
- Use `yarn add` instead of `npm install`
|
|
48
|
+
- Use `yarn remove` instead of `npm uninstall`
|
|
49
|
+
- Use `yarn` instead of `npm install` for installing dependencies
|
|
50
|
+
- Use `yarn build` instead of `npm run build`
|
|
51
|
+
- Use `yarn test` instead of `npm test`
|
|
52
|
+
|
|
53
|
+
## 6. General Rules
|
|
44
54
|
|
|
45
55
|
- Keep components focused and single-responsibility
|
|
46
56
|
- Use meaningful names
|
package/.vscode/settings.json
CHANGED
package/README.md
CHANGED
|
@@ -10,18 +10,24 @@ A powerful and flexible React-based panel library for building administrative in
|
|
|
10
10
|
- **Layout System**: Consistent layout management
|
|
11
11
|
- **Panel Component**: Core panel functionality
|
|
12
12
|
- **Counter Component**: Utility component for counting operations
|
|
13
|
+
- **Dashboard Components**: Flexible grid-based dashboard layout system
|
|
14
|
+
- **Color System**: Centralized color system with SCSS variables and CSS custom properties
|
|
13
15
|
|
|
14
16
|
## Decorators
|
|
15
17
|
|
|
16
18
|
The library provides several decorators for enhanced functionality:
|
|
17
19
|
|
|
18
20
|
### List Decorators
|
|
21
|
+
|
|
19
22
|
- `@List`: Main list decorator for creating list views
|
|
20
23
|
- `@ImageCell`: Specialized cell for handling images in lists
|
|
21
24
|
- `@Cell`: Base cell decorator for list items
|
|
22
25
|
|
|
23
26
|
### Form Decorators
|
|
27
|
+
|
|
24
28
|
- `@Input`: Form input decorator
|
|
29
|
+
- `@SelectInput`: Select input decorator
|
|
30
|
+
- `@CustomInput`: Render your own component in place of a field
|
|
25
31
|
- `@Crud`: CRUD operations decorator
|
|
26
32
|
|
|
27
33
|
## Installation
|
|
@@ -35,7 +41,7 @@ yarn add proje-react-panel
|
|
|
35
41
|
## Usage
|
|
36
42
|
|
|
37
43
|
```typescript
|
|
38
|
-
import { Panel, ListPage, FormPage, Login, Layout } from 'proje-react-panel';
|
|
44
|
+
import { Panel, ListPage, FormPage, Login, Layout, DashboardGrid, DashboardItem } from 'proje-react-panel';
|
|
39
45
|
|
|
40
46
|
// Initialize the panel
|
|
41
47
|
const panel = new Panel({
|
|
@@ -48,8 +54,58 @@ const panel = new Panel({
|
|
|
48
54
|
<FormPage />
|
|
49
55
|
<Login />
|
|
50
56
|
</Layout>
|
|
57
|
+
|
|
58
|
+
// Dashboard example
|
|
59
|
+
<DashboardGrid columns={3}>
|
|
60
|
+
<DashboardItem>Content 1</DashboardItem>
|
|
61
|
+
<DashboardItem>Content 2</DashboardItem>
|
|
62
|
+
<DashboardItem>Content 3</DashboardItem>
|
|
63
|
+
</DashboardGrid>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Custom Form Fields
|
|
67
|
+
|
|
68
|
+
When a field needs a control the library does not ship, `@CustomInput` lets your app render
|
|
69
|
+
it. The library only wires the field into `react-hook-form` and renders the label and the
|
|
70
|
+
error message like any other field — everything inside is yours.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { CustomInput, type CustomRenderProps } from 'proje-react-panel';
|
|
74
|
+
|
|
75
|
+
class Product {
|
|
76
|
+
@Input({ label: 'Name' })
|
|
77
|
+
name: string;
|
|
78
|
+
|
|
79
|
+
@CustomInput({
|
|
80
|
+
label: 'Cover image',
|
|
81
|
+
render: ({ value, onChange, error }: CustomRenderProps) => (
|
|
82
|
+
<MyImagePicker value={value as string} onSelect={onChange} invalid={!!error} />
|
|
83
|
+
),
|
|
84
|
+
})
|
|
85
|
+
coverImage: string;
|
|
86
|
+
}
|
|
51
87
|
```
|
|
52
88
|
|
|
89
|
+
The render function receives:
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Description |
|
|
92
|
+
| ----------- | -------------------------- | --------------------------------------------------- |
|
|
93
|
+
| `fieldName` | `string` | Full form path of the field (nested paths included) |
|
|
94
|
+
| `value` | `unknown` | Current form value |
|
|
95
|
+
| `onChange` | `(value: unknown) => void` | Writes a new value into the form |
|
|
96
|
+
| `error` | `string \| undefined` | Validation message for this field, if any |
|
|
97
|
+
|
|
98
|
+
Because the value is whatever you pass to `onChange`, a custom field can hold an id, an
|
|
99
|
+
object or a file reference — validation and submit treat it like any other form value.
|
|
100
|
+
|
|
101
|
+
## Guides
|
|
102
|
+
|
|
103
|
+
- **[Dashboard Guide](./guides/DASHBOARD_GUIDE.md)** - Complete guide for using Dashboard components
|
|
104
|
+
- **[Auth Layout Guide](./guides/AUTH_LAYOUT_GUIDE.md)** - Guide for implementing authentication layouts with sidebar
|
|
105
|
+
- **[Auth Layout Example](./guides/AUTH_LAYOUT_EXAMPLE.md)** - Complete working example of AuthLayout implementation
|
|
106
|
+
- **[Color System Guide](./guides/COLOR_SYSTEM_GUIDE.md)** - Complete documentation of the color system, SCSS variables, and CSS custom properties
|
|
107
|
+
- **[Implementation Guide](./guides/IMPLEMENTATION_GUIDE.md)** - Comprehensive guide for implementing the library in your React applications
|
|
108
|
+
|
|
53
109
|
## Type Definitions
|
|
54
110
|
|
|
55
111
|
The library includes TypeScript definitions for better development experience:
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
declare let axiosInstance: AxiosInstance;
|
|
3
|
+
export interface ApiConfig {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function initApi(config: ApiConfig): void;
|
|
7
|
+
export declare function initAuthToken(): void;
|
|
8
|
+
export declare function setAuthToken(token: string): void;
|
|
9
|
+
export declare function setAuthLogout(): void;
|
|
10
|
+
export declare function getAxiosInstance(): AxiosInstance;
|
|
11
|
+
export { axiosInstance };
|
package/dist/api/AuthApi.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
}, username: string, password: string) => Promise<any>;
|
|
5
|
-
};
|
|
1
|
+
import { LoginForm, LoginResponse } from '../types/Login';
|
|
2
|
+
export declare function login<T>(data: LoginForm | FormData): Promise<LoginResponse<T>>;
|
package/dist/api/CrudApi.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export {};
|
|
1
|
+
import { GetDataForList } from '../decorators/list/List';
|
|
2
|
+
import { OnSubmitFN } from '../decorators/form/Form';
|
|
3
|
+
import { GetDetailsDataFN } from '../decorators/details/Details';
|
|
4
|
+
export declare function getAll<T>(endpoint: string): GetDataForList<T>;
|
|
5
|
+
export declare function getOne<T>(endpoint: string, key?: string): GetDetailsDataFN<T>;
|
|
6
|
+
export declare function create<T>(endpoint: string): OnSubmitFN<T>;
|
|
7
|
+
export declare function createFormData<T>(endpoint: string): OnSubmitFN<T>;
|
|
8
|
+
export declare function update<T>(endpoint: string, key?: string): OnSubmitFN<T>;
|
|
9
|
+
export declare function updateFormData<T>(endpoint: string, key?: string): OnSubmitFN<T>;
|
|
10
|
+
export declare function updateSimple<T>(endpoint: string): OnSubmitFN<T>;
|
|
11
|
+
export declare function remove<T>(endpoint: string, key?: string): (data: T) => Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DashboardGridProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
columns?: number;
|
|
5
|
+
gap?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function DashboardGrid({ children, columns, gap, className, }: DashboardGridProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DashboardItemProps {
|
|
3
|
+
targetNumber: number;
|
|
4
|
+
duration?: number;
|
|
5
|
+
image: React.ReactNode;
|
|
6
|
+
text: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function DashboardItem({ targetNumber, duration, image, text, className, }: DashboardItemProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputConfiguration } from '../../decorators/form/Input';
|
|
3
|
+
interface CustomFieldProps {
|
|
4
|
+
input: InputConfiguration;
|
|
5
|
+
fieldName: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function CustomField({ input, fieldName, error }: CustomFieldProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { AnyClass, AnyClassConstructor } from '../../types/AnyClass';
|
|
3
3
|
export type InputTypes = 'input' | 'textarea' | 'file-upload' | 'checkbox' | 'hidden' | 'nested';
|
|
4
|
-
export type ExtendedInputTypes = InputTypes | 'select';
|
|
4
|
+
export type ExtendedInputTypes = InputTypes | 'select' | 'custom';
|
|
5
5
|
export interface InputOptions {
|
|
6
6
|
type?: InputTypes;
|
|
7
7
|
inputType?: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { InputConfiguration, InputOptions } from '../Input';
|
|
3
|
+
export interface CustomRenderProps {
|
|
4
|
+
fieldName: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
onChange: (value: unknown) => void;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CustomInputOptions extends Omit<InputOptions, 'type'> {
|
|
10
|
+
render: (props: CustomRenderProps) => ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface CustomInputConfiguration extends InputConfiguration {
|
|
13
|
+
type: 'custom';
|
|
14
|
+
render: (props: CustomRenderProps) => ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare function CustomInput(options: CustomInputOptions): PropertyDecorator;
|