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.
- package/.cursor/rules.md +122 -0
- package/.cursor/settings.json +57 -0
- package/.eslintrc.js +5 -0
- package/.eslintrc.json +26 -0
- package/.prettierrc +10 -0
- package/.vscode/launch.json +27 -0
- package/.vscode/settings.json +8 -0
- package/PTD.md +234 -0
- package/README.md +62 -28
- package/dist/api/CrudApi.d.ts +12 -0
- package/dist/components/Panel.d.ts +2 -2
- package/dist/components/components/Checkbox.d.ts +6 -0
- package/dist/components/components/Counter.d.ts +9 -0
- package/dist/components/components/FormField.d.ts +13 -0
- package/dist/components/components/ImageUploader.d.ts +15 -0
- package/dist/components/components/InnerForm.d.ts +12 -0
- package/dist/components/components/LoadingScreen.d.ts +2 -0
- package/dist/components/components/index.d.ts +8 -0
- package/dist/components/components/list/Datagrid.d.ts +13 -0
- package/dist/components/components/list/EmptyList.d.ts +2 -0
- package/dist/components/components/list/FilterPopup.d.ts +11 -0
- package/dist/components/components/list/ListPage.d.ts +22 -0
- package/dist/components/components/list/Pagination.d.ts +11 -0
- package/dist/components/components/list/index.d.ts +0 -0
- package/dist/components/layout/Layout.d.ts +2 -1
- package/dist/components/layout/SideBar.d.ts +4 -3
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/list/Datagrid.d.ts +12 -0
- package/dist/components/list/EmptyList.d.ts +2 -0
- package/dist/components/list/FilterPopup.d.ts +10 -0
- package/dist/components/list/Pagination.d.ts +11 -0
- package/dist/components/list/index.d.ts +0 -0
- package/dist/{src/screens → components/pages}/ControllerDetails.d.ts +1 -1
- package/dist/components/pages/FormPage.d.ts +12 -0
- package/dist/components/pages/ListPage.d.ts +18 -0
- package/dist/components/pages/Login.d.ts +13 -0
- package/dist/decorators/form/Form.d.ts +6 -0
- package/dist/decorators/form/FormOptions.d.ts +7 -0
- package/dist/decorators/form/Input.d.ts +17 -0
- package/dist/decorators/form/getFormFields.d.ts +3 -0
- package/dist/decorators/list/Cell.d.ts +21 -0
- package/dist/decorators/list/GetCellFields.d.ts +2 -0
- package/dist/decorators/list/ImageCell.d.ts +6 -0
- package/dist/decorators/list/List.d.ts +28 -0
- package/dist/decorators/list/ListData.d.ts +6 -0
- package/dist/decorators/list/getListFields.d.ts +2 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +20 -10
- package/dist/index.esm.js +1 -1
- package/dist/initPanel.d.ts +2 -2
- package/dist/store/store.d.ts +1 -5
- package/dist/types/AnyClass.d.ts +1 -0
- package/dist/types/ScreenCreatorData.d.ts +5 -3
- package/dist/types/initPanelOptions.d.ts +0 -6
- package/dist/utils/format.d.ts +1 -0
- package/dist/utils/getFields.d.ts +2 -1
- package/package.json +13 -6
- package/src/api/CrudApi.ts +30 -11
- package/src/assets/icons/svg/create.svg +9 -0
- package/src/assets/icons/svg/filter.svg +3 -0
- package/src/assets/icons/svg/pencil.svg +8 -0
- package/src/assets/icons/svg/search.svg +8 -0
- package/src/assets/icons/svg/trash.svg +8 -0
- package/src/components/Panel.tsx +11 -11
- package/src/components/components/Checkbox.tsx +9 -0
- package/src/components/components/Counter.tsx +51 -0
- package/src/components/components/FormField.tsx +94 -0
- package/src/components/components/ImageUploader.tsx +301 -0
- package/src/components/components/InnerForm.tsx +74 -0
- package/src/components/components/LoadingScreen.tsx +12 -0
- package/src/components/components/index.ts +8 -0
- package/src/components/components/list/Datagrid.tsx +121 -0
- package/src/components/components/list/EmptyList.tsx +26 -0
- package/src/components/components/list/FilterPopup.tsx +202 -0
- package/src/components/components/list/ListPage.tsx +178 -0
- package/src/components/components/list/Pagination.tsx +110 -0
- package/src/components/components/list/index.ts +1 -0
- package/src/components/layout/Layout.tsx +8 -1
- package/src/components/layout/SideBar.tsx +103 -31
- package/src/components/layout/index.ts +2 -0
- package/src/components/pages/ControllerDetails.tsx +37 -0
- package/src/components/pages/FormPage.tsx +34 -0
- package/src/components/pages/Login.tsx +79 -0
- package/src/decorators/form/Form.ts +18 -0
- package/src/decorators/form/FormOptions.ts +8 -0
- package/src/decorators/form/Input.ts +53 -0
- package/src/decorators/form/getFormFields.ts +13 -0
- package/src/decorators/list/Cell.ts +32 -0
- package/src/decorators/list/GetCellFields.ts +13 -0
- package/src/decorators/list/ImageCell.ts +13 -0
- package/src/decorators/list/List.ts +31 -0
- package/src/decorators/list/ListData.ts +7 -0
- package/src/decorators/list/getListFields.ts +10 -0
- package/src/index.ts +28 -10
- package/src/initPanel.ts +4 -12
- package/src/store/store.ts +23 -28
- package/src/styles/counter.scss +42 -0
- package/src/styles/filter-popup.scss +134 -0
- package/src/styles/image-uploader.scss +94 -0
- package/src/styles/index.scss +26 -7
- package/src/styles/layout.scss +1 -6
- package/src/styles/list.scss +175 -7
- package/src/styles/loading-screen.scss +42 -0
- package/src/styles/pagination.scss +66 -0
- package/src/styles/sidebar.scss +64 -0
- package/src/styles/utils/scrollbar.scss +19 -0
- package/src/types/AnyClass.ts +1 -0
- package/src/types/ScreenCreatorData.ts +5 -3
- package/src/types/initPanelOptions.ts +1 -7
- package/src/types/svg.d.ts +5 -0
- package/src/utils/format.ts +7 -0
- package/src/utils/getFields.ts +11 -9
- package/dist/api/crudApi.d.ts +0 -17
- package/dist/components/Form.d.ts +0 -6
- package/dist/components/FormField.d.ts +0 -13
- package/dist/components/list/List.d.ts +0 -10
- package/dist/components/screens/ControllerCreate.d.ts +0 -5
- package/dist/components/screens/ControllerDetails.d.ts +0 -5
- package/dist/components/screens/ControllerEdit.d.ts +0 -5
- package/dist/components/screens/ControllerList.d.ts +0 -5
- package/dist/components/screens/Login.d.ts +0 -2
- package/dist/decorators/Cell.d.ts +0 -9
- package/dist/decorators/Input.d.ts +0 -13
- package/dist/hooks/useScreens.d.ts +0 -2
- package/dist/initPanelOptions.d.ts +0 -8
- package/dist/screens/ControllerCreate.d.ts +0 -5
- package/dist/screens/ControllerDetails.d.ts +0 -5
- package/dist/screens/ControllerEdit.d.ts +0 -5
- package/dist/screens/ControllerList.d.ts +0 -5
- package/dist/screens/Form.d.ts +0 -6
- package/dist/src/api/crudApi.d.ts +0 -6
- package/dist/src/components/Panel.d.ts +0 -9
- package/dist/src/components/layout/Layout.d.ts +0 -11
- package/dist/src/components/layout/SideBar.d.ts +0 -10
- package/dist/src/components/list/List.d.ts +0 -10
- package/dist/src/decorators/Cell.d.ts +0 -10
- package/dist/src/decorators/Crud.d.ts +0 -6
- package/dist/src/index.d.ts +0 -8
- package/dist/src/screens/ControllerCreate.d.ts +0 -5
- package/dist/src/screens/ControllerEdit.d.ts +0 -5
- package/dist/src/screens/ControllerList.d.ts +0 -5
- package/dist/src/screens/Form.d.ts +0 -6
- package/dist/src/store/store.d.ts +0 -19
- package/dist/src/types/Screen.d.ts +0 -4
- package/dist/src/types/ScreenCreatorData.d.ts +0 -8
- package/dist/src/utils/createScreens.d.ts +0 -1
- package/dist/src/utils/getFields.d.ts +0 -2
- package/dist/src/utils/getScreens.d.ts +0 -2
- package/dist/utils/crudScreens.d.ts +0 -2
- package/dist/utils/getScreens.d.ts +0 -2
- package/src/api/AuthApi.ts +0 -14
- package/src/components/Form.tsx +0 -70
- package/src/components/FormField.tsx +0 -60
- package/src/components/list/List.tsx +0 -81
- package/src/components/screens/ControllerCreate.tsx +0 -7
- package/src/components/screens/ControllerDetails.tsx +0 -40
- package/src/components/screens/ControllerEdit.tsx +0 -35
- package/src/components/screens/ControllerList.tsx +0 -45
- package/src/components/screens/Login.tsx +0 -68
- package/src/decorators/Cell.ts +0 -34
- package/src/decorators/Input.ts +0 -50
- package/src/hooks/useScreens.tsx +0 -36
- /package/dist/components/{ErrorBoundary.d.ts → components/ErrorBoundary.d.ts} +0 -0
- /package/dist/components/{ErrorComponent.d.ts → components/ErrorComponent.d.ts} +0 -0
- /package/dist/components/{Label.d.ts → components/Label.d.ts} +0 -0
- /package/src/components/{ErrorBoundary.tsx → components/ErrorBoundary.tsx} +0 -0
- /package/src/components/{ErrorComponent.tsx → components/ErrorComponent.tsx} +0 -0
- /package/src/components/{Label.tsx → components/Label.tsx} +0 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
import { useParams } from 'react-router';
|
2
|
+
import React, { useEffect, useState } from 'react';
|
3
|
+
import { Screen } from '../../types/Screen';
|
4
|
+
import { ErrorComponent } from '../components/ErrorComponent';
|
5
|
+
|
6
|
+
export function ControllerDetails({ screen }: { screen: Screen }) {
|
7
|
+
const { id } = useParams();
|
8
|
+
const [data, setData] = useState<any>(null);
|
9
|
+
const [error, setError] = useState(null);
|
10
|
+
|
11
|
+
useEffect(() => {
|
12
|
+
if (screen.controller && id) {
|
13
|
+
/*
|
14
|
+
CrudApi.details({ ...fetchSettings, token }, screen.controller, id)
|
15
|
+
.then(res => {
|
16
|
+
setData(res);
|
17
|
+
})
|
18
|
+
.catch((e: any) => {
|
19
|
+
setError(e);
|
20
|
+
console.error(e);
|
21
|
+
});
|
22
|
+
*/
|
23
|
+
}
|
24
|
+
}, [id, screen]);
|
25
|
+
|
26
|
+
if (error) {
|
27
|
+
return <ErrorComponent error={error} />;
|
28
|
+
}
|
29
|
+
|
30
|
+
return (
|
31
|
+
<p
|
32
|
+
dangerouslySetInnerHTML={{
|
33
|
+
__html: JSON.stringify(data, null, ' ' + '<br/>'),
|
34
|
+
}}
|
35
|
+
/>
|
36
|
+
);
|
37
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import React, { useMemo } from 'react';
|
2
|
+
import { InnerForm } from '../components';
|
3
|
+
import { AnyClass } from '../../types/AnyClass';
|
4
|
+
import { getFormFields } from '../../decorators/form/getFormFields';
|
5
|
+
|
6
|
+
export type GetDetailsDataFN<T> = (param: Record<string, string>) => Promise<T>;
|
7
|
+
export type OnSubmitFN<T> = (data: T) => Promise<T>;
|
8
|
+
|
9
|
+
export interface FormPageProps<T extends AnyClass> {
|
10
|
+
model: T;
|
11
|
+
getDetailsData?: GetDetailsDataFN<T>;
|
12
|
+
redirect?: string;
|
13
|
+
onSubmit: OnSubmitFN<T>;
|
14
|
+
redirectBackOnSuccess?: boolean;
|
15
|
+
}
|
16
|
+
|
17
|
+
export function FormPage<T extends AnyClass>({
|
18
|
+
model,
|
19
|
+
getDetailsData,
|
20
|
+
onSubmit,
|
21
|
+
redirect,
|
22
|
+
redirectBackOnSuccess = true,
|
23
|
+
...rest
|
24
|
+
}: FormPageProps<T>) {
|
25
|
+
const formOptions = useMemo(() => getFormFields(model), [model]);
|
26
|
+
return (
|
27
|
+
<InnerForm
|
28
|
+
getDetailsData={getDetailsData}
|
29
|
+
onSubmit={onSubmit}
|
30
|
+
formOptions={formOptions}
|
31
|
+
redirectBackOnSuccess={redirectBackOnSuccess}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useForm } from 'react-hook-form';
|
3
|
+
import { FormField } from '../components/FormField';
|
4
|
+
import { useNavigate } from 'react-router';
|
5
|
+
import { useAppStore } from '../../store/store';
|
6
|
+
|
7
|
+
interface LoginFormData {
|
8
|
+
username: string;
|
9
|
+
password: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
export type OnLogin = {
|
13
|
+
login: (username: string, password: string) => Promise<LoginResponse>;
|
14
|
+
};
|
15
|
+
|
16
|
+
interface LoginResponse {
|
17
|
+
user: any; // Replace with proper user type if available
|
18
|
+
token: string;
|
19
|
+
}
|
20
|
+
|
21
|
+
interface LoginProps {
|
22
|
+
onLogin: OnLogin;
|
23
|
+
}
|
24
|
+
|
25
|
+
export function Login({ onLogin }: LoginProps) {
|
26
|
+
const {
|
27
|
+
register,
|
28
|
+
handleSubmit,
|
29
|
+
formState: { errors },
|
30
|
+
} = useForm<LoginFormData>();
|
31
|
+
const navigate = useNavigate();
|
32
|
+
const onSubmit = async (data: LoginFormData) => {
|
33
|
+
onLogin.login(data.username, data.password).then((dataInner: LoginResponse) => {
|
34
|
+
const { user, token } = dataInner;
|
35
|
+
localStorage.setItem('token', token);
|
36
|
+
useAppStore.setState({ user });
|
37
|
+
navigate('/');
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
return (
|
42
|
+
<div className="login-container">
|
43
|
+
<div className="login-panel">
|
44
|
+
<div className="login-header">
|
45
|
+
<h1>Welcome Back</h1>
|
46
|
+
<p>Please sign in to continue</p>
|
47
|
+
</div>
|
48
|
+
<form onSubmit={handleSubmit(onSubmit)} className="login-form">
|
49
|
+
<FormField
|
50
|
+
input={{
|
51
|
+
name: 'username',
|
52
|
+
label: 'Username',
|
53
|
+
placeholder: 'Enter your username',
|
54
|
+
type: 'input',
|
55
|
+
}}
|
56
|
+
register={register}
|
57
|
+
error={errors.username}
|
58
|
+
/>
|
59
|
+
<FormField
|
60
|
+
input={{
|
61
|
+
name: 'password',
|
62
|
+
label: 'Password',
|
63
|
+
inputType: 'password',
|
64
|
+
placeholder: 'Enter your password',
|
65
|
+
type: 'input',
|
66
|
+
}}
|
67
|
+
register={register}
|
68
|
+
error={errors.password}
|
69
|
+
/>
|
70
|
+
<div className="form-actions">
|
71
|
+
<button type="submit" className="submit-button">
|
72
|
+
Sign In
|
73
|
+
</button>
|
74
|
+
</div>
|
75
|
+
</form>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
);
|
79
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import "reflect-metadata";
|
2
|
+
import { AnyClass } from "../../types/AnyClass";
|
3
|
+
|
4
|
+
const FORM_METADATA_KEY = "FormMetadata"; // More descriptive name indicating it's a metadata key
|
5
|
+
|
6
|
+
export interface FormConfiguration {} // Better describes that this is configuration/options for the form
|
7
|
+
|
8
|
+
export function FormDecorator(options?: FormConfiguration): ClassDecorator {
|
9
|
+
return (target: Function) => {
|
10
|
+
if (options) {
|
11
|
+
Reflect.defineMetadata(FORM_METADATA_KEY, options, target);
|
12
|
+
}
|
13
|
+
};
|
14
|
+
}
|
15
|
+
|
16
|
+
export function getFormConfiguration(entityClass: AnyClass): FormConfiguration | undefined {
|
17
|
+
return Reflect.getMetadata(FORM_METADATA_KEY, entityClass);
|
18
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
import { AnyClass } from '../../types/AnyClass';
|
3
|
+
|
4
|
+
const INPUT_KEY = Symbol('input');
|
5
|
+
|
6
|
+
const isFieldSensitive = (fieldName: string): boolean => {
|
7
|
+
return ['password'].some(term => fieldName.toLowerCase().includes(term));
|
8
|
+
};
|
9
|
+
|
10
|
+
export interface InputOptions {
|
11
|
+
type?: 'input' | 'select' | 'textarea' | 'file-upload' | 'checkbox' | 'hidden' | 'nested';
|
12
|
+
inputType?: 'text' | 'email' | 'tel' | 'password' | 'number' | 'date';
|
13
|
+
name?: string;
|
14
|
+
label?: string;
|
15
|
+
placeholder?: string;
|
16
|
+
cancelPasswordValidationOnEdit?: boolean;
|
17
|
+
options?: { value: string; label: string }[];
|
18
|
+
nestedFields?: InputOptions[];
|
19
|
+
}
|
20
|
+
|
21
|
+
export function Input(options?: InputOptions): PropertyDecorator {
|
22
|
+
return (target, propertyKey) => {
|
23
|
+
const existingInputs: string[] = Reflect.getMetadata(INPUT_KEY, target) || [];
|
24
|
+
Reflect.defineMetadata(INPUT_KEY, [...existingInputs, propertyKey.toString()], target);
|
25
|
+
|
26
|
+
if (options) {
|
27
|
+
const keyString = `${INPUT_KEY.toString()}:${propertyKey.toString()}:options`;
|
28
|
+
Reflect.defineMetadata(keyString, options, target);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
33
|
+
export function getInputFields<T extends AnyClass>(entityClass: T): InputOptions[] {
|
34
|
+
const prototype = entityClass.prototype;
|
35
|
+
const inputFields: string[] = Reflect.getMetadata(INPUT_KEY, prototype) || [];
|
36
|
+
return inputFields.map(field => {
|
37
|
+
const fields = Reflect.getMetadata(`${INPUT_KEY.toString()}:${field}:options`, prototype) || {};
|
38
|
+
const inputType = fields?.inputType ?? (isFieldSensitive(field) ? 'password' : 'text');
|
39
|
+
return {
|
40
|
+
...fields,
|
41
|
+
editable: fields.editable ?? true,
|
42
|
+
sensitive: fields.sensitive,
|
43
|
+
name: fields?.name ?? field,
|
44
|
+
label: fields?.label ?? field,
|
45
|
+
placeholder: fields?.placeholder ?? field,
|
46
|
+
inputType: inputType,
|
47
|
+
type: fields?.type ?? 'input',
|
48
|
+
selectOptions: fields?.selectOptions ?? [],
|
49
|
+
cancelPasswordValidationOnEdit:
|
50
|
+
fields?.cancelPasswordValidationOnEdit ?? inputType === 'password',
|
51
|
+
};
|
52
|
+
});
|
53
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { AnyClass } from "../../types/AnyClass";
|
2
|
+
import { FormOptions } from "./FormOptions";
|
3
|
+
import { getInputFields } from "./Input";
|
4
|
+
import { getFormConfiguration } from "./Form";
|
5
|
+
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
|
6
|
+
|
7
|
+
export function getFormFields<T extends AnyClass>(entityClass: T): FormOptions {
|
8
|
+
return {
|
9
|
+
resolver: classValidatorResolver(entityClass as any),
|
10
|
+
form: getFormConfiguration(entityClass),
|
11
|
+
inputs: getInputFields<T>(entityClass),
|
12
|
+
};
|
13
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
|
3
|
+
export const CELL_KEY = Symbol('cell');
|
4
|
+
|
5
|
+
interface Filter {
|
6
|
+
type: 'string' | 'number' | 'date' | 'static-select';
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface StaticSelectFilter extends Filter {
|
10
|
+
type: 'static-select';
|
11
|
+
options: { value: string; label: string }[];
|
12
|
+
}
|
13
|
+
|
14
|
+
export interface CellOptions {
|
15
|
+
name?: string;
|
16
|
+
title?: string;
|
17
|
+
type?: 'string' | 'date' | 'image' | 'number';
|
18
|
+
placeHolder?: string;
|
19
|
+
filter?: Filter | StaticSelectFilter;
|
20
|
+
}
|
21
|
+
|
22
|
+
export function Cell(options?: CellOptions): PropertyDecorator {
|
23
|
+
return (target, propertyKey) => {
|
24
|
+
const existingCells: string[] = Reflect.getMetadata(CELL_KEY, target) || [];
|
25
|
+
Reflect.defineMetadata(CELL_KEY, [...existingCells, propertyKey.toString()], target);
|
26
|
+
|
27
|
+
if (options) {
|
28
|
+
const keyString = `${CELL_KEY.toString()}:${propertyKey.toString()}:options`;
|
29
|
+
Reflect.defineMetadata(keyString, options, target);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { CELL_KEY, CellOptions } from "./Cell";
|
2
|
+
|
3
|
+
export function getCellFields(entityClass: any): CellOptions[] {
|
4
|
+
const prototype = entityClass.prototype;
|
5
|
+
const cellFields: string[] = Reflect.getMetadata(CELL_KEY, prototype) || [];
|
6
|
+
return cellFields.map((field) => {
|
7
|
+
const fields = Reflect.getMetadata(`${CELL_KEY.toString()}:${field}:options`, prototype) || {};
|
8
|
+
return {
|
9
|
+
...fields,
|
10
|
+
name: fields?.name ?? field,
|
11
|
+
};
|
12
|
+
});
|
13
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import "reflect-metadata";
|
2
|
+
import { Cell, CellOptions } from "./Cell";
|
3
|
+
|
4
|
+
export interface ImageCellOptions extends CellOptions {
|
5
|
+
baseUrl: string;
|
6
|
+
}
|
7
|
+
|
8
|
+
export function ImageCell(options?: ImageCellOptions): PropertyDecorator {
|
9
|
+
return Cell({
|
10
|
+
...options,
|
11
|
+
type: "image",
|
12
|
+
});
|
13
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import 'reflect-metadata';
|
2
|
+
|
3
|
+
const LIST_KEY = 'List';
|
4
|
+
|
5
|
+
export interface ListHeaderOptions {
|
6
|
+
title?: string;
|
7
|
+
create?: { path: string; label: string };
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface ListUtilCellOptions {
|
11
|
+
details?: { path: string; label: string };
|
12
|
+
edit?: { path: string; label: string };
|
13
|
+
delete?: { path: string; label: string };
|
14
|
+
}
|
15
|
+
|
16
|
+
export interface ListOptions {
|
17
|
+
headers?: ListHeaderOptions;
|
18
|
+
utilCells?: ListUtilCellOptions;
|
19
|
+
}
|
20
|
+
|
21
|
+
export function List(options?: ListOptions): ClassDecorator {
|
22
|
+
return (target: Function) => {
|
23
|
+
if (options) {
|
24
|
+
Reflect.defineMetadata(LIST_KEY, options, target);
|
25
|
+
}
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
export function getClassListData(entityClass: any): ListOptions | undefined {
|
30
|
+
return Reflect.getMetadata(LIST_KEY, entityClass);
|
31
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { getClassListData } from "./List";
|
2
|
+
import { getCellFields } from "./GetCellFields";
|
3
|
+
import { ListData } from "./ListData";
|
4
|
+
|
5
|
+
export function getListFields<T>(entityClass: T): ListData {
|
6
|
+
return {
|
7
|
+
list: getClassListData(entityClass),
|
8
|
+
cells: getCellFields(entityClass),
|
9
|
+
};
|
10
|
+
}
|
package/src/index.ts
CHANGED
@@ -1,10 +1,28 @@
|
|
1
|
-
export {
|
2
|
-
export {
|
3
|
-
export {
|
4
|
-
export {
|
5
|
-
export {
|
6
|
-
export {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
export type { OnSubmitFN, GetDetailsDataFN } from './components/pages/FormPage';
|
2
|
+
export type { InitPanelOptions } from './types/initPanelOptions';
|
3
|
+
export type { ScreenCreatorData } from './types/ScreenCreatorData';
|
4
|
+
export type { OnLogin } from './components/pages/Login';
|
5
|
+
export type { AnyClass } from './types/AnyClass';
|
6
|
+
export type {
|
7
|
+
GetDataForList,
|
8
|
+
PaginatedResponse,
|
9
|
+
GetDataParams,
|
10
|
+
} from './components/components/list/ListPage';
|
11
|
+
|
12
|
+
export { ListPage } from './components/components/list/ListPage';
|
13
|
+
export { FormPage } from './components/pages/FormPage';
|
14
|
+
export type { FormPageProps } from './components/pages/FormPage';
|
15
|
+
export { Login } from './components/pages/Login';
|
16
|
+
export { Layout } from './components/layout/Layout';
|
17
|
+
export { Panel } from './components/Panel';
|
18
|
+
export { Counter } from './components/components/Counter';
|
19
|
+
|
20
|
+
//TODO: decerator index.ts ayır
|
21
|
+
export { List } from './decorators/list/List';
|
22
|
+
export { ImageCell } from './decorators/list/ImageCell';
|
23
|
+
export { Crud } from './decorators/Crud';
|
24
|
+
export { Cell } from './decorators/list/Cell';
|
25
|
+
export { Input } from './decorators/form/Input';
|
26
|
+
// Export page components
|
27
|
+
export { getFormFields } from './decorators/form/getFormFields';
|
28
|
+
export { getInputFields } from './decorators/form/Input';
|
package/src/initPanel.ts
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { ScreenCreatorData } from "./types/ScreenCreatorData";
|
4
|
-
import { InitPanelOptions } from "./types/initPanelOptions";
|
5
|
-
import { useAppStore } from "./store/store";
|
1
|
+
import { InitPanelOptions } from './types/initPanelOptions';
|
2
|
+
import { useAppStore } from './store/store';
|
6
3
|
|
7
|
-
export function initPanel({
|
8
|
-
|
9
|
-
Object.entries(crud).forEach(([key, value]) => {
|
10
|
-
screensCrudOptions[key] = getFields(key, value);
|
11
|
-
});
|
12
|
-
createScreens(screensCrudOptions);
|
13
|
-
useAppStore.setState({ fetchSettings: { baseUrl: fetch.baseURL }, screenPaths });
|
4
|
+
export function initPanel({ screenPaths }: InitPanelOptions) {
|
5
|
+
useAppStore.setState({ screenPaths });
|
14
6
|
}
|
package/src/store/store.ts
CHANGED
@@ -1,37 +1,32 @@
|
|
1
|
-
import { createJSONStorage, persist } from
|
2
|
-
import { createWithEqualityFn } from
|
3
|
-
import { shallow } from
|
4
|
-
import { ScreenCreatorData } from
|
1
|
+
import { createJSONStorage, persist } from 'zustand/middleware';
|
2
|
+
import { createWithEqualityFn } from 'zustand/traditional';
|
3
|
+
import { shallow } from 'zustand/vanilla/shallow';
|
4
|
+
import { ScreenCreatorData } from '../types/ScreenCreatorData';
|
5
5
|
|
6
6
|
interface User {
|
7
|
-
|
7
|
+
username: string;
|
8
8
|
}
|
9
9
|
|
10
10
|
interface AppState {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
screenPaths: Record<string, string>;
|
15
|
-
token: string | null;
|
11
|
+
user: User | null;
|
12
|
+
screens: Record<string, ScreenCreatorData> | null;
|
13
|
+
screenPaths: Record<string, string>;
|
16
14
|
}
|
17
15
|
|
18
16
|
export const useAppStore = createWithEqualityFn<AppState>()(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
35
|
-
),
|
36
|
-
shallow
|
17
|
+
persist(
|
18
|
+
_ => ({
|
19
|
+
screens: null,
|
20
|
+
user: null,
|
21
|
+
screenPaths: {},
|
22
|
+
}),
|
23
|
+
{
|
24
|
+
name: 'app-store-1',
|
25
|
+
storage: createJSONStorage(() => localStorage),
|
26
|
+
partialize: state => ({
|
27
|
+
user: state.user,
|
28
|
+
}),
|
29
|
+
}
|
30
|
+
),
|
31
|
+
shallow
|
37
32
|
);
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// Variables
|
2
|
+
$primary-color: #007bff;
|
3
|
+
$text-color: #ffffff;
|
4
|
+
$bg-color: #1a1a1a;
|
5
|
+
$shadow-color: rgba(0, 0, 0, 0.3);
|
6
|
+
|
7
|
+
// Mixins
|
8
|
+
@mixin flex-center {
|
9
|
+
display: flex;
|
10
|
+
align-items: center;
|
11
|
+
}
|
12
|
+
|
13
|
+
.counter {
|
14
|
+
&-container {
|
15
|
+
@include flex-center;
|
16
|
+
flex-direction: column;
|
17
|
+
padding: 20px;
|
18
|
+
border-radius: 8px;
|
19
|
+
box-shadow: 0 2px 4px $shadow-color;
|
20
|
+
background-color: $bg-color;
|
21
|
+
max-width: 300px;
|
22
|
+
margin: 20px auto;
|
23
|
+
}
|
24
|
+
|
25
|
+
&-image {
|
26
|
+
margin-bottom: 15px;
|
27
|
+
}
|
28
|
+
|
29
|
+
&-text {
|
30
|
+
font-size: 18px;
|
31
|
+
margin-bottom: 15px;
|
32
|
+
color: $text-color;
|
33
|
+
}
|
34
|
+
|
35
|
+
&-value {
|
36
|
+
font-size: 24px;
|
37
|
+
font-weight: bold;
|
38
|
+
min-width: 40px;
|
39
|
+
text-align: center;
|
40
|
+
color: $text-color;
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,134 @@
|
|
1
|
+
.filter-popup {
|
2
|
+
position: absolute;
|
3
|
+
top: 60px; //TODO: make this variable $list-header-height
|
4
|
+
//TODO: make this variable
|
5
|
+
left: 260px;
|
6
|
+
right: 10px;
|
7
|
+
background: #1e1e1e;
|
8
|
+
padding: 20px;
|
9
|
+
border-radius: 8px;
|
10
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
11
|
+
border: 1px solid #333;
|
12
|
+
z-index: 10;
|
13
|
+
&-header {
|
14
|
+
display: flex;
|
15
|
+
justify-content: space-between;
|
16
|
+
align-items: center;
|
17
|
+
margin-bottom: 20px;
|
18
|
+
|
19
|
+
h3 {
|
20
|
+
margin: 0;
|
21
|
+
font-size: 1.2rem;
|
22
|
+
color: #ffffff;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
&-content {
|
27
|
+
max-height: 400px;
|
28
|
+
overflow-y: auto;
|
29
|
+
|
30
|
+
&::-webkit-scrollbar {
|
31
|
+
width: 8px;
|
32
|
+
}
|
33
|
+
|
34
|
+
&::-webkit-scrollbar-track {
|
35
|
+
background: #2d2d2d;
|
36
|
+
border-radius: 4px;
|
37
|
+
}
|
38
|
+
|
39
|
+
&::-webkit-scrollbar-thumb {
|
40
|
+
background: #444;
|
41
|
+
border-radius: 4px;
|
42
|
+
|
43
|
+
&:hover {
|
44
|
+
background: #555;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
&-footer {
|
50
|
+
display: flex;
|
51
|
+
justify-content: flex-end;
|
52
|
+
gap: 10px;
|
53
|
+
margin-top: 20px;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
.close-button {
|
58
|
+
background: none;
|
59
|
+
border: none;
|
60
|
+
font-size: 1.5rem;
|
61
|
+
cursor: pointer;
|
62
|
+
padding: 0;
|
63
|
+
color: #999;
|
64
|
+
transition: color 0.2s ease;
|
65
|
+
|
66
|
+
&:hover {
|
67
|
+
color: #ffffff;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
.filter-field {
|
72
|
+
margin-bottom: 15px;
|
73
|
+
|
74
|
+
label {
|
75
|
+
display: block;
|
76
|
+
margin-bottom: 5px;
|
77
|
+
font-size: 0.9rem;
|
78
|
+
color: #bbb;
|
79
|
+
}
|
80
|
+
|
81
|
+
input {
|
82
|
+
width: 100%;
|
83
|
+
padding: 10px;
|
84
|
+
border: 1px solid #444;
|
85
|
+
border-radius: 6px;
|
86
|
+
font-size: 0.9rem;
|
87
|
+
background: #2d2d2d;
|
88
|
+
color: #ffffff;
|
89
|
+
transition: all 0.2s ease;
|
90
|
+
|
91
|
+
&:focus {
|
92
|
+
border-color: #0066cc;
|
93
|
+
outline: none;
|
94
|
+
box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
|
95
|
+
}
|
96
|
+
|
97
|
+
&::placeholder {
|
98
|
+
color: #666;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
.cancel-button,
|
104
|
+
.apply-button {
|
105
|
+
padding: 10px 20px;
|
106
|
+
border-radius: 6px;
|
107
|
+
cursor: pointer;
|
108
|
+
font-size: 0.9rem;
|
109
|
+
transition: all 0.2s ease;
|
110
|
+
}
|
111
|
+
|
112
|
+
.cancel-button {
|
113
|
+
background: #2d2d2d;
|
114
|
+
border: 1px solid #444;
|
115
|
+
color: #bbb;
|
116
|
+
|
117
|
+
&:hover {
|
118
|
+
background: #333;
|
119
|
+
border-color: #555;
|
120
|
+
color: #fff;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
.apply-button {
|
125
|
+
background: #0066cc;
|
126
|
+
border: 1px solid #0056b3;
|
127
|
+
color: white;
|
128
|
+
|
129
|
+
&:hover {
|
130
|
+
background: #0056b3;
|
131
|
+
transform: translateY(-1px);
|
132
|
+
box-shadow: 0 2px 8px rgba(0, 102, 204, 0.3);
|
133
|
+
}
|
134
|
+
}
|