admin_lsac 1.3.1 → 1.4.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/.eslintrc.cjs +18 -0
- package/README.md +162 -162
- package/index.html +13 -0
- package/package.json +42 -73
- package/tsconfig.app.json +27 -0
- package/tsconfig.json +11 -31
- package/tsconfig.node.json +13 -0
- package/vite.config.ts +7 -0
- package/dist/App.d.ts +0 -76
- package/dist/App.js +0 -12
- package/dist/cjs/App.js +0 -12
- package/dist/cjs/components/GenericForm.js +0 -305
- package/dist/cjs/components/Page.js +0 -119
- package/dist/cjs/index.js +0 -18
- package/dist/cjs/pages/event.js +0 -134
- package/dist/cjs/pages/page.js +0 -375
- package/dist/cjs/reportWebVitals.js +0 -38
- package/dist/cjs/schema/schema.config.js +0 -9
- package/dist/cjs/schema/schema.js +0 -2
- package/dist/cjs/setupTests.js +0 -7
- package/dist/cjs/utils/websockets.js +0 -22
- package/dist/components/GenericForm.js +0 -305
- package/dist/components/Page.js +0 -119
- package/dist/esm/App.js +0 -10
- package/dist/esm/components/GenericForm.js +0 -275
- package/dist/esm/components/Page.js +0 -111
- package/dist/esm/index.js +0 -13
- package/dist/esm/pages/event.js +0 -128
- package/dist/esm/pages/page.js +0 -349
- package/dist/esm/reportWebVitals.js +0 -13
- package/dist/esm/schema/schema.config.js +0 -6
- package/dist/esm/schema/schema.js +0 -1
- package/dist/esm/setupTests.js +0 -5
- package/dist/esm/utils/websockets.js +0 -15
- package/dist/index.js +0 -18
- package/dist/pages/event.js +0 -134
- package/dist/pages/page.js +0 -375
- package/dist/reportWebVitals.js +0 -38
- package/dist/schema/schema.config.js +0 -9
- package/dist/schema/schema.js +0 -2
- package/dist/setupTests.js +0 -7
- package/dist/utils/websockets.js +0 -22
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/server/.env.example +0 -3
- package/server/deploy.js +0 -29
- package/server/package-lock.json +0 -712
- package/server/package.json +0 -18
- package/src/App.css +0 -38
- package/src/App.tsx +0 -50
- package/src/components/GenericForm.tsx +0 -308
- package/src/components/Page.tsx +0 -243
- package/src/index.css +0 -13
- package/src/index.tsx +0 -20
- package/src/logo.svg +0 -1
- package/src/pages/event.ts +0 -93
- package/src/pages/page.ts +0 -336
- package/src/react-app-env.d.ts +0 -1
- package/src/reportWebVitals.ts +0 -15
- package/src/schema/schema.config.ts +0 -8
- package/src/schema/schema.ts +0 -63
- package/src/setupTests.ts +0 -5
- package/src/utils/websockets.tsx +0 -17
- package/tsconfig.esm.json +0 -7
- package/webpack.config.js +0 -22
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:react-hooks/recommended',
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
plugins: ['react-refresh'],
|
|
12
|
+
rules: {
|
|
13
|
+
'react-refresh/only-export-components': [
|
|
14
|
+
'warn',
|
|
15
|
+
{ allowConstantExport: true },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
}
|
package/README.md
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
# Generic Admin Panel
|
|
2
|
-
|
|
3
|
-
For configuring your own admin panel, follow the next instructions.
|
|
4
|
-
|
|
5
|
-
### `npm install admin_lsac`
|
|
6
|
-
|
|
7
|
-
This command will download and install the specified package and its dependencies into your project's node_modules directory, making it available for use in your project.
|
|
8
|
-
|
|
9
|
-
### `npm install export-to-csv@1.2.1`
|
|
10
|
-
|
|
11
|
-
Export-to-csv package latest version is not working properly, so make sure you have the last functional version of this package install.
|
|
12
|
-
|
|
13
|
-
## What do you need to import?
|
|
14
|
-
|
|
15
|
-
### `import { ChakraProvider } from '@chakra-ui/react'`
|
|
16
|
-
|
|
17
|
-
### `import { pageToUrl } from 'admin_lsac'`
|
|
18
|
-
|
|
19
|
-
### `import { AdminPage } from 'admin_lsac'`
|
|
20
|
-
|
|
21
|
-
You can import these in App.js / App.ts. If your project is TypeScript-based, you need to write the following line as well:
|
|
22
|
-
|
|
23
|
-
### `import { PageSchema } from 'admin_lsac'`
|
|
24
|
-
|
|
25
|
-
* Import the component from above where you want to write your schemas. (See below for details about schemas)
|
|
26
|
-
|
|
27
|
-
You need to create an array of schemas for your own admin panel. You can write the following inside your Routes component from App.js / App.ts:
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
{your_array.map((page) => (
|
|
31
|
-
<Route
|
|
32
|
-
path={`${your_url_to_admin_panel}/${pageToUrl(page)}`}
|
|
33
|
-
element={
|
|
34
|
-
<AdminPage
|
|
35
|
-
pages={your_array}
|
|
36
|
-
selectedPage={page}
|
|
37
|
-
basePath={your_url_to_admin_panel}
|
|
38
|
-
/>
|
|
39
|
-
}
|
|
40
|
-
/>
|
|
41
|
-
))}
|
|
42
|
-
{your_array[0] ? (
|
|
43
|
-
<Route
|
|
44
|
-
path={`${your_url_to_admin_panel}/*`}
|
|
45
|
-
element={
|
|
46
|
-
<AdminPage
|
|
47
|
-
pages={your_array}
|
|
48
|
-
selectedPage={your_array[0]}
|
|
49
|
-
basePath={your_url_to_admin_panel}
|
|
50
|
-
/>
|
|
51
|
-
}
|
|
52
|
-
/>
|
|
53
|
-
) : null}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
#### ⚠️ Don't forget to wrap the Router component into a ChakraProvider component.
|
|
57
|
-
|
|
58
|
-
## What is a schema?
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
export interface PageSchema {
|
|
62
|
-
name: string;
|
|
63
|
-
actions: Action[];
|
|
64
|
-
rowActions: RowAction[];
|
|
65
|
-
getRequest: () => Promise<any[]>;
|
|
66
|
-
tableFields: TableField[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface TableField {
|
|
70
|
-
name: string;
|
|
71
|
-
access: (obj: any) => string | number | React.ReactElement;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface SimpleField {
|
|
75
|
-
name: string;
|
|
76
|
-
label: string;
|
|
77
|
-
type: "string" | "number" | "file";
|
|
78
|
-
validationSchema: any;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface Option {
|
|
82
|
-
value: string | number | boolean;
|
|
83
|
-
display: string;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface DropdownField {
|
|
87
|
-
name: string;
|
|
88
|
-
label: string;
|
|
89
|
-
type: "dropdown";
|
|
90
|
-
options?: Option[] | undefined;
|
|
91
|
-
getOptions: () => Promise<Option[]>;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ObjectField {
|
|
95
|
-
name: string;
|
|
96
|
-
label: string;
|
|
97
|
-
type: "object";
|
|
98
|
-
fields: FormField[];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface ArrayField {
|
|
102
|
-
name: string;
|
|
103
|
-
label: string;
|
|
104
|
-
type: "array";
|
|
105
|
-
element: Exclude<FormField, ArrayField>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
|
|
109
|
-
|
|
110
|
-
export interface Action {
|
|
111
|
-
name: string;
|
|
112
|
-
fields?: FormField[];
|
|
113
|
-
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface RowAction {
|
|
117
|
-
name: string;
|
|
118
|
-
fields?: FormField[];
|
|
119
|
-
initialise?: (obj: any) => any;
|
|
120
|
-
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
A page schema is based on these interfaces, which can be imported into your files. A page schema describes how one table of your admin panel would need to be structured to accomplish what the user needs regarding an entity. (i.e. users, teams, companies, quizzes)
|
|
125
|
-
|
|
126
|
-
#### An array of schemas would be defined as follows:
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
const your_array = [
|
|
130
|
-
{
|
|
131
|
-
// schema 1
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
// schema 2
|
|
135
|
-
},
|
|
136
|
-
...
|
|
137
|
-
];
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
* In TypeScript, it would slightly change:
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
const your_array: PageSchema[] = [
|
|
144
|
-
{
|
|
145
|
-
// schema 1
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
// schema 2
|
|
149
|
-
},
|
|
150
|
-
...
|
|
151
|
-
];
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Other Specifications
|
|
155
|
-
|
|
156
|
-
Due to some corrupt dependencies, you need a Node version >= 20.5.0 to use this package in a Vite app.
|
|
157
|
-
|
|
158
|
-
For every entity you describe through a page schema, getRequest and onSubmit functions will use routes created for the entity. `getRequest` function will make a GET request, while `onSumbit` will probably make a POST, PATCH or DELETE request.
|
|
159
|
-
|
|
160
|
-
## Learn More
|
|
161
|
-
|
|
162
|
-
For more details, especially about page schemas, contact the owner. :)
|
|
1
|
+
# Generic Admin Panel
|
|
2
|
+
|
|
3
|
+
For configuring your own admin panel, follow the next instructions.
|
|
4
|
+
|
|
5
|
+
### `npm install admin_lsac`
|
|
6
|
+
|
|
7
|
+
This command will download and install the specified package and its dependencies into your project's node_modules directory, making it available for use in your project.
|
|
8
|
+
|
|
9
|
+
### `npm install export-to-csv@1.2.1`
|
|
10
|
+
|
|
11
|
+
Export-to-csv package latest version is not working properly, so make sure you have the last functional version of this package install.
|
|
12
|
+
|
|
13
|
+
## What do you need to import?
|
|
14
|
+
|
|
15
|
+
### `import { ChakraProvider } from '@chakra-ui/react'`
|
|
16
|
+
|
|
17
|
+
### `import { pageToUrl } from 'admin_lsac'`
|
|
18
|
+
|
|
19
|
+
### `import { AdminPage } from 'admin_lsac'`
|
|
20
|
+
|
|
21
|
+
You can import these in App.js / App.ts. If your project is TypeScript-based, you need to write the following line as well:
|
|
22
|
+
|
|
23
|
+
### `import { PageSchema } from 'admin_lsac'`
|
|
24
|
+
|
|
25
|
+
* Import the component from above where you want to write your schemas. (See below for details about schemas)
|
|
26
|
+
|
|
27
|
+
You need to create an array of schemas for your own admin panel. You can write the following inside your Routes component from App.js / App.ts:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
{your_array.map((page) => (
|
|
31
|
+
<Route
|
|
32
|
+
path={`${your_url_to_admin_panel}/${pageToUrl(page)}`}
|
|
33
|
+
element={
|
|
34
|
+
<AdminPage
|
|
35
|
+
pages={your_array}
|
|
36
|
+
selectedPage={page}
|
|
37
|
+
basePath={your_url_to_admin_panel}
|
|
38
|
+
/>
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
))}
|
|
42
|
+
{your_array[0] ? (
|
|
43
|
+
<Route
|
|
44
|
+
path={`${your_url_to_admin_panel}/*`}
|
|
45
|
+
element={
|
|
46
|
+
<AdminPage
|
|
47
|
+
pages={your_array}
|
|
48
|
+
selectedPage={your_array[0]}
|
|
49
|
+
basePath={your_url_to_admin_panel}
|
|
50
|
+
/>
|
|
51
|
+
}
|
|
52
|
+
/>
|
|
53
|
+
) : null}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### ⚠️ Don't forget to wrap the Router component into a ChakraProvider component.
|
|
57
|
+
|
|
58
|
+
## What is a schema?
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
export interface PageSchema {
|
|
62
|
+
name: string;
|
|
63
|
+
actions: Action[];
|
|
64
|
+
rowActions: RowAction[];
|
|
65
|
+
getRequest: () => Promise<any[]>;
|
|
66
|
+
tableFields: TableField[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TableField {
|
|
70
|
+
name: string;
|
|
71
|
+
access: (obj: any) => string | number | React.ReactElement;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface SimpleField {
|
|
75
|
+
name: string;
|
|
76
|
+
label: string;
|
|
77
|
+
type: "string" | "number" | "file";
|
|
78
|
+
validationSchema: any;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface Option {
|
|
82
|
+
value: string | number | boolean;
|
|
83
|
+
display: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface DropdownField {
|
|
87
|
+
name: string;
|
|
88
|
+
label: string;
|
|
89
|
+
type: "dropdown";
|
|
90
|
+
options?: Option[] | undefined;
|
|
91
|
+
getOptions: () => Promise<Option[]>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ObjectField {
|
|
95
|
+
name: string;
|
|
96
|
+
label: string;
|
|
97
|
+
type: "object";
|
|
98
|
+
fields: FormField[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface ArrayField {
|
|
102
|
+
name: string;
|
|
103
|
+
label: string;
|
|
104
|
+
type: "array";
|
|
105
|
+
element: Exclude<FormField, ArrayField>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
|
|
109
|
+
|
|
110
|
+
export interface Action {
|
|
111
|
+
name: string;
|
|
112
|
+
fields?: FormField[];
|
|
113
|
+
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface RowAction {
|
|
117
|
+
name: string;
|
|
118
|
+
fields?: FormField[];
|
|
119
|
+
initialise?: (obj: any) => any;
|
|
120
|
+
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
A page schema is based on these interfaces, which can be imported into your files. A page schema describes how one table of your admin panel would need to be structured to accomplish what the user needs regarding an entity. (i.e. users, teams, companies, quizzes)
|
|
125
|
+
|
|
126
|
+
#### An array of schemas would be defined as follows:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
const your_array = [
|
|
130
|
+
{
|
|
131
|
+
// schema 1
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
// schema 2
|
|
135
|
+
},
|
|
136
|
+
...
|
|
137
|
+
];
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
* In TypeScript, it would slightly change:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
const your_array: PageSchema[] = [
|
|
144
|
+
{
|
|
145
|
+
// schema 1
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
// schema 2
|
|
149
|
+
},
|
|
150
|
+
...
|
|
151
|
+
];
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Other Specifications
|
|
155
|
+
|
|
156
|
+
Due to some corrupt dependencies, you need a Node version >= 20.5.0 to use this package in a Vite app.
|
|
157
|
+
|
|
158
|
+
For every entity you describe through a page schema, getRequest and onSubmit functions will use routes created for the entity. `getRequest` function will make a GET request, while `onSumbit` will probably make a POST, PATCH or DELETE request.
|
|
159
|
+
|
|
160
|
+
## Learn More
|
|
161
|
+
|
|
162
|
+
For more details, especially about page schemas, contact the owner. :)
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Admin Panel</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,73 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "admin_lsac",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"@
|
|
15
|
-
"@
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"react
|
|
29
|
-
"react-
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"react-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
},
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"eject": "react-scripts eject",
|
|
44
|
-
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\""
|
|
45
|
-
},
|
|
46
|
-
"eslintConfig": {
|
|
47
|
-
"extends": [
|
|
48
|
-
"react-app",
|
|
49
|
-
"react-app/jest"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
"browserslist": {
|
|
53
|
-
"production": [
|
|
54
|
-
">0.2%",
|
|
55
|
-
"not dead",
|
|
56
|
-
"not op_mini all"
|
|
57
|
-
],
|
|
58
|
-
"development": [
|
|
59
|
-
"last 1 chrome version",
|
|
60
|
-
"last 1 firefox version",
|
|
61
|
-
"last 1 safari version"
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
"devDependencies": {
|
|
65
|
-
"@types/react": "^18.2.65",
|
|
66
|
-
"@types/react-table": "^7.7.17",
|
|
67
|
-
"ts-loader": "^9.5.1",
|
|
68
|
-
"webpack-cli": "^5.1.4"
|
|
69
|
-
},
|
|
70
|
-
"main": "dist/components/Page.js",
|
|
71
|
-
"module": "dist/esm/components/Page.js",
|
|
72
|
-
"types": "dist/App.d.ts"
|
|
73
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "admin_lsac",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.4.0",
|
|
5
|
+
"description": "Generic Admin Panel created for storing events' data",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "tsc -b && vite build",
|
|
10
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
11
|
+
"preview": "vite preview"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@chakra-ui/react": "^2.8.2",
|
|
15
|
+
"@mui/material": "^5.15.20",
|
|
16
|
+
"axios": "^1.7.2",
|
|
17
|
+
"export-to-csv": "^1.3.0",
|
|
18
|
+
"formik": "^2.4.6",
|
|
19
|
+
"material-react-table": "^2.13.0",
|
|
20
|
+
"react": "^18.3.1",
|
|
21
|
+
"react-dom": "^18.3.1",
|
|
22
|
+
"react-router-dom": "^6.24.0",
|
|
23
|
+
"socket.io-client": "^4.7.5",
|
|
24
|
+
"sweetalert2": "^11.12.0",
|
|
25
|
+
"yup": "^1.4.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "^18.3.3",
|
|
29
|
+
"@types/react-dom": "^18.3.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^7.13.1",
|
|
31
|
+
"@typescript-eslint/parser": "^7.13.1",
|
|
32
|
+
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
33
|
+
"eslint": "^8.57.0",
|
|
34
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
35
|
+
"eslint-plugin-react-refresh": "^0.4.7",
|
|
36
|
+
"typescript": "^5.2.2",
|
|
37
|
+
"vite": "^5.3.1"
|
|
38
|
+
},
|
|
39
|
+
"main": "dist/components/AdminPage.js",
|
|
40
|
+
"module": "dist/esm/components/AdminPage.js",
|
|
41
|
+
"types": "dist/App.d.ts"
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"useDefineForClassFields": true,
|
|
7
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"outDir": "./dist/esm",
|
|
11
|
+
|
|
12
|
+
/* Bundler mode */
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"isolatedModules": true,
|
|
16
|
+
"moduleDetection": "force",
|
|
17
|
+
"noEmit": false,
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
|
|
20
|
+
/* Linting */
|
|
21
|
+
"strict": true,
|
|
22
|
+
"noUnusedLocals": true,
|
|
23
|
+
"noUnusedParameters": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true
|
|
25
|
+
},
|
|
26
|
+
"include": ["src"]
|
|
27
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"allowSyntheticDefaultImports": true,
|
|
13
|
-
"strict": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"noFallthroughCasesInSwitch": true,
|
|
16
|
-
"module": "commonjs",
|
|
17
|
-
"moduleResolution": "node",
|
|
18
|
-
"resolveJsonModule": true,
|
|
19
|
-
"isolatedModules": true,
|
|
20
|
-
"noEmit": false,
|
|
21
|
-
"jsx": "react-jsx",
|
|
22
|
-
"noUncheckedIndexedAccess": true,
|
|
23
|
-
"outDir": "./dist/cjs"
|
|
24
|
-
},
|
|
25
|
-
"include": [
|
|
26
|
-
"src"
|
|
27
|
-
],
|
|
28
|
-
"exclude": [
|
|
29
|
-
"node_modules"
|
|
30
|
-
]
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"files": [],
|
|
3
|
+
"references": [
|
|
4
|
+
{
|
|
5
|
+
"path": "./tsconfig.app.json"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"path": "./tsconfig.node.json"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"composite": true,
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
+
"skipLibCheck": true,
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noEmit": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["vite.config.ts"]
|
|
13
|
+
}
|
package/vite.config.ts
ADDED
package/dist/App.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
declare module "admin_lsac" {
|
|
4
|
-
export interface TableField {
|
|
5
|
-
name: string;
|
|
6
|
-
access: (obj: any) => string | number | React.ReactElement;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface SimpleField {
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
type: "string" | "number" | "file";
|
|
13
|
-
validationSchema: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface Option {
|
|
17
|
-
value: string | number | boolean;
|
|
18
|
-
display: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface DropdownField {
|
|
22
|
-
name: string;
|
|
23
|
-
label: string;
|
|
24
|
-
type: "dropdown";
|
|
25
|
-
options?: Option[] | undefined;
|
|
26
|
-
getOptions: () => Promise<Option[]>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ObjectField {
|
|
30
|
-
name: string;
|
|
31
|
-
label: string;
|
|
32
|
-
type: "object";
|
|
33
|
-
fields: FormField[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ArrayField {
|
|
37
|
-
name: string;
|
|
38
|
-
label: string;
|
|
39
|
-
type: "array";
|
|
40
|
-
element: Exclude<FormField, ArrayField>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
|
|
44
|
-
|
|
45
|
-
export interface Action {
|
|
46
|
-
name: string;
|
|
47
|
-
fields?: FormField[];
|
|
48
|
-
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface RowAction {
|
|
52
|
-
name: string;
|
|
53
|
-
fields?: FormField[];
|
|
54
|
-
initialise?: (obj: any) => any;
|
|
55
|
-
onSubmit: (obj1: any, obj2?: any) => Promise<any>;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface PageSchema {
|
|
59
|
-
name: string;
|
|
60
|
-
actions: Action[];
|
|
61
|
-
rowActions: RowAction[];
|
|
62
|
-
getRequest: () => Promise<any[]>;
|
|
63
|
-
tableFields: TableField[];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface PageProps {
|
|
67
|
-
pages: PageSchema[];
|
|
68
|
-
selectedPage: PageSchema;
|
|
69
|
-
basePath: string;
|
|
70
|
-
apiURL?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function AdminPage(props: PageProps): React.ReactElement;
|
|
74
|
-
|
|
75
|
-
export function pageToUrl(page: PageSchema): string;
|
|
76
|
-
}
|
package/dist/App.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
var react_1 = require("@chakra-ui/react");
|
|
5
|
-
var react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
var Page_1 = require("./components/Page");
|
|
7
|
-
var Page_2 = require("./components/Page");
|
|
8
|
-
function App(_a) {
|
|
9
|
-
var pages = _a.pages, basePath = _a.basePath;
|
|
10
|
-
return ((0, jsx_runtime_1.jsx)(react_1.ChakraProvider, { children: (0, jsx_runtime_1.jsx)(react_router_dom_1.BrowserRouter, { children: (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [pages.map(function (page) { return ((0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "".concat(basePath, "/").concat((0, Page_2.pageToUrl)(page)), element: (0, jsx_runtime_1.jsx)(Page_1.AdminPage, { pages: pages, selectedPage: page, basePath: basePath, apiURL: "http://localhost:3001" }) })); }), pages[0] ? ((0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "".concat(basePath, "/*"), element: (0, jsx_runtime_1.jsx)(Page_1.AdminPage, { pages: pages, selectedPage: pages[0], basePath: basePath, apiURL: "http://localhost:3001" }) })) : null] }) }) }));
|
|
11
|
-
}
|
|
12
|
-
exports.default = App;
|