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
@@ -1,68 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { useForm } from "react-hook-form";
|
3
|
-
import { FormField } from "../FormField";
|
4
|
-
import { AuthApi } from "../../api/AuthApi";
|
5
|
-
import { useAppStore } from "../../store/store";
|
6
|
-
import { useNavigate } from "react-router";
|
7
|
-
|
8
|
-
interface LoginFormData {
|
9
|
-
username: string;
|
10
|
-
password: string;
|
11
|
-
}
|
12
|
-
|
13
|
-
export function Login() {
|
14
|
-
const {
|
15
|
-
register,
|
16
|
-
handleSubmit,
|
17
|
-
formState: { errors },
|
18
|
-
} = useForm<LoginFormData>();
|
19
|
-
const { fetchSettings } = useAppStore((s) => ({ fetchSettings: s.fetchSettings }));
|
20
|
-
const navigate = useNavigate();
|
21
|
-
const onSubmit = async (data: LoginFormData) => {
|
22
|
-
AuthApi.login(fetchSettings!, data.username, data.password).then((dataInner) => {
|
23
|
-
const { access_token, admin } = dataInner;
|
24
|
-
useAppStore.setState({ user: admin, token: access_token });
|
25
|
-
navigate("/");
|
26
|
-
});
|
27
|
-
};
|
28
|
-
|
29
|
-
return (
|
30
|
-
<div className="login-container">
|
31
|
-
<div className="login-panel">
|
32
|
-
<div className="login-header">
|
33
|
-
<h1>Welcome Back</h1>
|
34
|
-
<p>Please sign in to continue</p>
|
35
|
-
</div>
|
36
|
-
<form onSubmit={handleSubmit(onSubmit)} className="login-form">
|
37
|
-
<FormField
|
38
|
-
input={{
|
39
|
-
name: "username",
|
40
|
-
label: "Username",
|
41
|
-
inputType: "text",
|
42
|
-
placeholder: "Enter your username",
|
43
|
-
}}
|
44
|
-
register={register}
|
45
|
-
isEditForm={false}
|
46
|
-
error={errors.username}
|
47
|
-
/>
|
48
|
-
<FormField
|
49
|
-
input={{
|
50
|
-
name: "password",
|
51
|
-
label: "Password",
|
52
|
-
inputType: "password",
|
53
|
-
placeholder: "Enter your password",
|
54
|
-
}}
|
55
|
-
register={register}
|
56
|
-
isEditForm={false}
|
57
|
-
error={errors.password}
|
58
|
-
/>
|
59
|
-
<div className="form-actions">
|
60
|
-
<button type="submit" className="submit-button">
|
61
|
-
Sign In
|
62
|
-
</button>
|
63
|
-
</div>
|
64
|
-
</form>
|
65
|
-
</div>
|
66
|
-
</div>
|
67
|
-
);
|
68
|
-
}
|
package/src/decorators/Cell.ts
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
import "reflect-metadata";
|
2
|
-
|
3
|
-
const CELL_KEY = Symbol("cell");
|
4
|
-
|
5
|
-
export interface CellOptions {
|
6
|
-
name?: string;
|
7
|
-
title?: string;
|
8
|
-
type?: "string" | "number" | "date";
|
9
|
-
placeHolder?: string;
|
10
|
-
}
|
11
|
-
|
12
|
-
export function Cell(options?: CellOptions): PropertyDecorator {
|
13
|
-
return (target, propertyKey) => {
|
14
|
-
const existingCells: string[] = Reflect.getMetadata(CELL_KEY, target) || [];
|
15
|
-
Reflect.defineMetadata(CELL_KEY, [...existingCells, propertyKey.toString()], target);
|
16
|
-
|
17
|
-
if (options) {
|
18
|
-
const keyString = `${CELL_KEY.toString()}:${propertyKey.toString()}:options`;
|
19
|
-
Reflect.defineMetadata(keyString, options, target);
|
20
|
-
}
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
export function getCellFields(entityClass: any): CellOptions[] {
|
25
|
-
const prototype = entityClass.prototype;
|
26
|
-
const cellFields: string[] = Reflect.getMetadata(CELL_KEY, prototype) || [];
|
27
|
-
return cellFields.map((field) => {
|
28
|
-
const fields = Reflect.getMetadata(`${CELL_KEY.toString()}:${field}:options`, prototype) || {};
|
29
|
-
return {
|
30
|
-
...fields,
|
31
|
-
name: fields?.name ?? field,
|
32
|
-
};
|
33
|
-
});
|
34
|
-
}
|
package/src/decorators/Input.ts
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
import "reflect-metadata";
|
2
|
-
|
3
|
-
const INPUT_KEY = Symbol("input");
|
4
|
-
|
5
|
-
const isFieldSensitive = (fieldName: string): boolean => {
|
6
|
-
return ["password"].some((term) => fieldName.toLowerCase().includes(term));
|
7
|
-
};
|
8
|
-
|
9
|
-
export interface InputOptions {
|
10
|
-
name?: string;
|
11
|
-
label?: string;
|
12
|
-
placeholder?: string;
|
13
|
-
editable?: boolean;
|
14
|
-
inputType?: "text" | "email" | "tel" | "password" | "number" | "date";
|
15
|
-
type?: "input" | "select" | "textarea";
|
16
|
-
selectOptions?: string[]; //TODO: label/value
|
17
|
-
cancelPasswordValidationOnEdit?: boolean;
|
18
|
-
}
|
19
|
-
|
20
|
-
export function Input(options?: InputOptions): PropertyDecorator {
|
21
|
-
return (target, propertyKey) => {
|
22
|
-
const existingInputs: string[] = Reflect.getMetadata(INPUT_KEY, target) || [];
|
23
|
-
Reflect.defineMetadata(INPUT_KEY, [...existingInputs, propertyKey.toString()], target);
|
24
|
-
|
25
|
-
if (options) {
|
26
|
-
const keyString = `${INPUT_KEY.toString()}:${propertyKey.toString()}:options`;
|
27
|
-
Reflect.defineMetadata(keyString, options, target);
|
28
|
-
}
|
29
|
-
};
|
30
|
-
}
|
31
|
-
|
32
|
-
export function getInputFields(entityClass: any): InputOptions[] {
|
33
|
-
const prototype = entityClass.prototype;
|
34
|
-
const inputFields: string[] = Reflect.getMetadata(INPUT_KEY, prototype) || [];
|
35
|
-
return inputFields.map((field) => {
|
36
|
-
const fields = Reflect.getMetadata(`${INPUT_KEY.toString()}:${field}:options`, prototype) || {};
|
37
|
-
const inputType = fields?.inputType ?? (isFieldSensitive(field) ? "password" : "text");
|
38
|
-
return {
|
39
|
-
...fields,
|
40
|
-
editable: fields.editable ?? true,
|
41
|
-
sensitive: fields.sensitive,
|
42
|
-
name: fields?.name ?? field,
|
43
|
-
label: fields?.label ?? field,
|
44
|
-
placeholder: fields?.placeholder ?? field,
|
45
|
-
inputType: inputType,
|
46
|
-
selectOptions: fields?.selectOptions ?? [],
|
47
|
-
cancelPasswordValidationOnEdit: fields?.cancelPasswordValidationOnEdit ?? inputType === "password",
|
48
|
-
};
|
49
|
-
});
|
50
|
-
}
|
package/src/hooks/useScreens.tsx
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import React, { useMemo } from "react";
|
2
|
-
import { Route } from "react-router";
|
3
|
-
import { ControllerCreate } from "../components/screens/ControllerCreate";
|
4
|
-
import { ControllerDetails } from "../components/screens/ControllerDetails";
|
5
|
-
import { ControllerEdit } from "../components/screens/ControllerEdit";
|
6
|
-
import { ControllerList } from "../components/screens/ControllerList";
|
7
|
-
import { Screen } from "../types/Screen";
|
8
|
-
import { useAppStore } from "../store/store";
|
9
|
-
|
10
|
-
export function useScreens() {
|
11
|
-
const screens = useAppStore((s) => s.screens ?? {});
|
12
|
-
return useMemo(
|
13
|
-
() => (
|
14
|
-
<>
|
15
|
-
{Object.entries(screens).map(([key, screenData]) => {
|
16
|
-
const controllerName = screenData.crud?.controller ?? key;
|
17
|
-
let routePath = `${screenData.path}`;
|
18
|
-
const screen: Screen = {
|
19
|
-
key,
|
20
|
-
controller: controllerName,
|
21
|
-
};
|
22
|
-
return (
|
23
|
-
<React.Fragment key={"index"}>
|
24
|
-
<Route path={routePath + "/create"} element={<ControllerCreate screen={screen} />} />
|
25
|
-
<Route path={routePath + "/details/:id"} element={<ControllerDetails screen={screen} />} />
|
26
|
-
<Route path={routePath + "/edit/:id"} element={<ControllerEdit screen={screen} />} />
|
27
|
-
<Route path={routePath} element={<ControllerList screen={screen} />} />
|
28
|
-
</React.Fragment>
|
29
|
-
);
|
30
|
-
})}
|
31
|
-
<Route path="*" element={<div>404 - Not Found</div>} />
|
32
|
-
</>
|
33
|
-
),
|
34
|
-
[screens]
|
35
|
-
);
|
36
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|