proje-react-panel 1.0.15 → 1.0.17-test-8
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/.vscode/launch.json +10 -0
- package/dist/components/components/FormField.d.ts +6 -1
- package/dist/components/components/InnerForm.d.ts +9 -4
- package/dist/components/components/Uploader.d.ts +8 -0
- package/dist/components/components/index.d.ts +1 -1
- package/dist/components/components/list/Datagrid.d.ts +9 -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 +20 -0
- package/dist/components/components/list/Pagination.d.ts +11 -0
- package/dist/components/components/list/index.d.ts +0 -0
- package/dist/components/list/Datagrid.d.ts +8 -4
- package/dist/components/list/EmptyList.d.ts +2 -0
- package/dist/components/list/FilterPopup.d.ts +10 -0
- package/dist/components/pages/FormPage.d.ts +10 -3
- package/dist/components/pages/ListPage.d.ts +2 -1
- package/dist/decorators/form/Input.d.ts +8 -3
- package/dist/decorators/list/Cell.d.ts +14 -2
- package/dist/decorators/list/List.d.ts +26 -4
- package/dist/decorators/list/ListData.d.ts +4 -4
- package/dist/decorators/list/getListFields.d.ts +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.esm.js +1 -1
- package/dist/types/AnyClass.d.ts +1 -1
- package/dist/types/ScreenCreatorData.d.ts +5 -5
- package/package.json +9 -3
- 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/components/FormField.tsx +52 -9
- package/src/components/components/InnerForm.tsx +53 -15
- package/src/components/components/Uploader.tsx +66 -0
- package/src/components/components/index.ts +2 -2
- package/src/components/components/list/Datagrid.tsx +135 -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 +176 -0
- package/src/components/pages/FormPage.tsx +12 -3
- package/src/decorators/form/Input.ts +7 -4
- package/src/decorators/form/getFormFields.ts +1 -0
- package/src/decorators/list/Cell.ts +24 -14
- package/src/decorators/list/List.ts +26 -11
- package/src/decorators/list/ListData.ts +5 -5
- package/src/decorators/list/getListFields.ts +8 -8
- package/src/index.ts +8 -3
- package/src/styles/filter-popup.scss +134 -0
- package/src/styles/form.scss +2 -4
- package/src/styles/index.scss +18 -22
- package/src/styles/list.scss +151 -8
- package/src/styles/uploader.scss +86 -0
- package/src/types/AnyClass.ts +3 -1
- package/src/types/ScreenCreatorData.ts +12 -12
- package/src/types/svg.d.ts +5 -0
- package/src/components/components/ImageUploader.tsx +0 -301
- package/src/components/list/Datagrid.tsx +0 -101
- package/src/components/pages/ListPage.tsx +0 -85
- /package/src/components/{list → components/list}/Pagination.tsx +0 -0
- /package/src/components/{list → components/list}/index.ts +0 -0
- /package/src/styles/{_scrollbar.scss → utils/scrollbar.scss} +0 -0
@@ -1,85 +0,0 @@
|
|
1
|
-
import React, { useMemo, useCallback } from 'react';
|
2
|
-
import { useEffect, useState } from 'react';
|
3
|
-
import { Link, useParams } from 'react-router';
|
4
|
-
import { Datagrid } from '../list/Datagrid';
|
5
|
-
import { ErrorComponent } from '../components/ErrorComponent';
|
6
|
-
import { LoadingScreen } from '../components/LoadingScreen';
|
7
|
-
import { AnyClass } from '../../types/AnyClass';
|
8
|
-
import { getListFields } from '../../decorators/list/getListFields';
|
9
|
-
import { Pagination } from '../list/Pagination';
|
10
|
-
|
11
|
-
export interface PaginationParams {
|
12
|
-
page?: number;
|
13
|
-
limit?: number;
|
14
|
-
}
|
15
|
-
|
16
|
-
export interface PaginatedResponse<T> {
|
17
|
-
data: T[];
|
18
|
-
total: number;
|
19
|
-
page: number;
|
20
|
-
limit: number;
|
21
|
-
}
|
22
|
-
|
23
|
-
export type GetDataForList<T> = ({
|
24
|
-
page,
|
25
|
-
}: PaginationParams) => PaginatedResponse<T> | Promise<PaginatedResponse<T>>;
|
26
|
-
|
27
|
-
export function ListPage<T extends AnyClass>({
|
28
|
-
model,
|
29
|
-
getData,
|
30
|
-
}: {
|
31
|
-
model: T;
|
32
|
-
getData: GetDataForList<T>;
|
33
|
-
}) {
|
34
|
-
const [loading, setLoading] = useState(true);
|
35
|
-
const [pagination, setPagination] = useState({ total: 0, page: 0, limit: 0 });
|
36
|
-
const [data, setData] = useState<any>(null);
|
37
|
-
const [error, setError] = useState<unknown | null>(null);
|
38
|
-
const listData = useMemo(() => getListFields(model), [model]);
|
39
|
-
const params = useParams();
|
40
|
-
|
41
|
-
const fetchData = useCallback(
|
42
|
-
async (page: number) => {
|
43
|
-
setLoading(true);
|
44
|
-
try {
|
45
|
-
const result = await getData({ page });
|
46
|
-
setData(result.data);
|
47
|
-
setPagination({
|
48
|
-
total: result.total,
|
49
|
-
page: result.page,
|
50
|
-
limit: result.limit,
|
51
|
-
});
|
52
|
-
} catch (e: unknown) {
|
53
|
-
setError(e);
|
54
|
-
console.error(e);
|
55
|
-
} finally {
|
56
|
-
setLoading(false);
|
57
|
-
}
|
58
|
-
},
|
59
|
-
[getData]
|
60
|
-
);
|
61
|
-
|
62
|
-
useEffect(() => {
|
63
|
-
fetchData(parseInt(params.page as string) || 1);
|
64
|
-
}, [fetchData, params.page]);
|
65
|
-
|
66
|
-
if (loading) return <LoadingScreen />;
|
67
|
-
if (error) return <ErrorComponent error={error} />;
|
68
|
-
|
69
|
-
return (
|
70
|
-
<div className="list">
|
71
|
-
<div className="list-header">
|
72
|
-
<Link to={'create'}>Create</Link>
|
73
|
-
</div>
|
74
|
-
<Datagrid cells={listData.cells} data={data} />
|
75
|
-
<div className="list-footer">
|
76
|
-
<Pagination
|
77
|
-
pagination={pagination}
|
78
|
-
onPageChange={(page: number) => {
|
79
|
-
fetchData(page);
|
80
|
-
}}
|
81
|
-
/>
|
82
|
-
</div>
|
83
|
-
</div>
|
84
|
-
);
|
85
|
-
}
|
File without changes
|
File without changes
|
File without changes
|