admin_lsac 1.3.2 → 1.4.1

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.
Files changed (79) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/README.md +162 -162
  3. package/dist/src/App.d.ts +7 -0
  4. package/dist/src/App.js +10 -0
  5. package/dist/src/components/AdminPage.d.ts +8 -0
  6. package/dist/{esm/components/Page.js → src/components/AdminPage.js} +35 -43
  7. package/dist/src/components/GenericForm.d.ts +8 -0
  8. package/dist/src/components/GenericForm.js +151 -0
  9. package/dist/src/main.d.ts +1 -0
  10. package/dist/src/main.js +7 -0
  11. package/dist/{App.d.ts → src/schema.d.ts} +53 -76
  12. package/dist/src/testSchemas/event.d.ts +2 -0
  13. package/dist/src/testSchemas/event.js +86 -0
  14. package/dist/src/utils/websockets.d.ts +1 -0
  15. package/dist/{esm → src}/utils/websockets.js +5 -5
  16. package/index.html +13 -0
  17. package/package.json +42 -73
  18. package/tsconfig.app.json +27 -0
  19. package/tsconfig.json +11 -31
  20. package/tsconfig.node.json +13 -0
  21. package/vite.config.ts +7 -0
  22. package/dist/App.js +0 -12
  23. package/dist/cjs/App.js +0 -12
  24. package/dist/cjs/components/GenericForm.js +0 -305
  25. package/dist/cjs/components/Page.js +0 -119
  26. package/dist/cjs/index.js +0 -18
  27. package/dist/cjs/pages/event.js +0 -134
  28. package/dist/cjs/pages/page.js +0 -375
  29. package/dist/cjs/reportWebVitals.js +0 -38
  30. package/dist/cjs/schema/schema.config.js +0 -9
  31. package/dist/cjs/schema/schema.js +0 -2
  32. package/dist/cjs/setupTests.js +0 -7
  33. package/dist/cjs/utils/websockets.js +0 -22
  34. package/dist/components/GenericForm.js +0 -305
  35. package/dist/components/Page.js +0 -119
  36. package/dist/esm/App.js +0 -10
  37. package/dist/esm/components/GenericForm.js +0 -275
  38. package/dist/esm/index.js +0 -13
  39. package/dist/esm/pages/event.js +0 -128
  40. package/dist/esm/pages/page.js +0 -349
  41. package/dist/esm/reportWebVitals.js +0 -13
  42. package/dist/esm/schema/schema.config.js +0 -6
  43. package/dist/esm/setupTests.js +0 -5
  44. package/dist/index.js +0 -18
  45. package/dist/pages/event.js +0 -134
  46. package/dist/pages/page.js +0 -375
  47. package/dist/reportWebVitals.js +0 -38
  48. package/dist/schema/schema.config.js +0 -9
  49. package/dist/schema/schema.js +0 -2
  50. package/dist/setupTests.js +0 -7
  51. package/dist/utils/websockets.js +0 -22
  52. package/public/favicon.ico +0 -0
  53. package/public/index.html +0 -43
  54. package/public/logo192.png +0 -0
  55. package/public/logo512.png +0 -0
  56. package/public/manifest.json +0 -25
  57. package/public/robots.txt +0 -3
  58. package/server/.env.example +0 -3
  59. package/server/deploy.js +0 -29
  60. package/server/package-lock.json +0 -712
  61. package/server/package.json +0 -18
  62. package/src/App.css +0 -38
  63. package/src/App.tsx +0 -50
  64. package/src/components/GenericForm.tsx +0 -308
  65. package/src/components/Page.tsx +0 -243
  66. package/src/index.css +0 -13
  67. package/src/index.tsx +0 -20
  68. package/src/logo.svg +0 -1
  69. package/src/pages/event.ts +0 -93
  70. package/src/pages/page.ts +0 -336
  71. package/src/react-app-env.d.ts +0 -1
  72. package/src/reportWebVitals.ts +0 -15
  73. package/src/schema/schema.config.ts +0 -8
  74. package/src/schema/schema.ts +0 -63
  75. package/src/setupTests.ts +0 -5
  76. package/src/utils/websockets.tsx +0 -17
  77. package/tsconfig.esm.json +0 -7
  78. package/webpack.config.js +0 -22
  79. /package/dist/{esm/schema → src}/schema.js +0 -0
@@ -0,0 +1,151 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Box, Button, FormControl, FormErrorMessage, FormLabel, Input, Select, } from "@chakra-ui/react";
3
+ import { Field, Form, Formik, FieldArray, getIn } from "formik";
4
+ import * as Yup from "yup";
5
+ import Swal from "sweetalert2";
6
+ import { useEffect, useState } from "react";
7
+ function parseValidation(fields) {
8
+ if (!fields) {
9
+ return {};
10
+ }
11
+ return fields.reduce((acc, field) => {
12
+ if (field.type !== "dropdown" &&
13
+ field.type !== "object" &&
14
+ field.type !== "array") {
15
+ acc[field.name] = field.validationSchema;
16
+ }
17
+ else if (field.type === "array") {
18
+ if (field.element.type === "dropdown") {
19
+ acc[field.name] = Yup.array().of(Yup.string().required());
20
+ }
21
+ else if (field.element.type === "object") {
22
+ acc[field.name] = Yup.array().of(Yup.object(parseValidation(field.element.fields)));
23
+ }
24
+ else {
25
+ acc[field.name] = Yup.array().of(field.element.validationSchema);
26
+ }
27
+ }
28
+ else if (field.type === "object") {
29
+ acc[field.name] = Yup.object(parseValidation(field.fields));
30
+ }
31
+ if (field.type === "dropdown") {
32
+ acc[field.name] = Yup.string().required();
33
+ }
34
+ return acc;
35
+ }, {});
36
+ }
37
+ function generateSingleField(formfield, fieldName, key) {
38
+ return (_jsx(Field, { name: fieldName, children: ({ field, form }) => (_jsxs(FormControl, { isInvalid: getIn(form.touched, fieldName) && getIn(form.errors, fieldName), children: [_jsx(FormLabel, { marginTop: 2, children: formfield.label }), formfield.type === "string" || formfield.type === "number" ? (_jsx(Input, { ...field, type: formfield.type === "number" ? "number" : "text", placeholder: "" })) : formfield.type === "file" ? (_jsx(Input, { type: "file", name: fieldName, onChange: (event) => {
39
+ if (event.currentTarget.files != null) {
40
+ form.setFieldValue(fieldName, event.currentTarget.files[0]);
41
+ }
42
+ } })) : (_jsxs(Select, { ...field, defaultValue: "", children: [_jsx("option", { disabled: true, value: "", children: "Select an option!" }), formfield.options?.map((option, key) => (_jsx("option", { value: `${option.value}`, children: option.display }, key)))] })), _jsx(FormErrorMessage, { children: getIn(form.errors, fieldName) })] })) }, key));
43
+ }
44
+ function parseFields(fields, previous) {
45
+ if (!fields) {
46
+ return [];
47
+ }
48
+ const computedFields = fields.map((formfield, key) => {
49
+ let fieldName = previous !== undefined ? previous + "." + formfield.name : formfield.name;
50
+ if (formfield.type === "object") {
51
+ const objectFields = parseFields(formfield.fields, fieldName);
52
+ return _jsx(FormControl, { children: objectFields }, fieldName);
53
+ }
54
+ else if (formfield.type === "array") {
55
+ return (_jsx(FieldArray, { name: fieldName, children: ({ remove, push, form }) => (_jsxs("div", { children: [_jsx(FormLabel, { marginTop: 2, children: formfield.label }), getIn(form.values, fieldName).length > 0 &&
56
+ getIn(form.values, fieldName).map((_, index) => (_jsxs(Box, { paddingLeft: 10, children: [_jsx("h4", { children: _jsx("b", { children: `${fieldName}.${index}` }) }), _jsx(Box, { paddingLeft: 10, children: formfield.element.type === "object"
57
+ ? parseFields(formfield.element.fields, `${fieldName}.${index}`)
58
+ : generateSingleField(formfield.element, `${fieldName}.${index}`, key) }), _jsxs(Button, { type: "button", colorScheme: "red", marginY: 2, onClick: () => remove(index), children: ["Remove ", `${fieldName}.${index}`] })] }))), _jsxs(Button, { type: "button", marginY: 2, colorScheme: "blue", onClick: () => {
59
+ let value = undefined;
60
+ if (formfield.element.type === "object") {
61
+ value = getCustomInitialValues(formfield.element.fields);
62
+ }
63
+ else {
64
+ value = getCustomInitialValues([formfield.element])[0];
65
+ }
66
+ push(value);
67
+ }, children: ["Add ", fieldName] })] })) }));
68
+ }
69
+ else {
70
+ return generateSingleField(formfield, fieldName, key);
71
+ }
72
+ });
73
+ return computedFields;
74
+ }
75
+ function getCustomInitialValues(fields) {
76
+ let obj = {};
77
+ if (!fields) {
78
+ return obj;
79
+ }
80
+ fields.forEach((field) => {
81
+ if (field.type === "array")
82
+ obj[field.name] = [];
83
+ else if (field.type === "object")
84
+ obj[field.name] = getCustomInitialValues(field.fields);
85
+ else if (field.type === "string")
86
+ obj[field.name] = "";
87
+ else if (field.type === "number")
88
+ obj[field.name] = 0;
89
+ else
90
+ obj[field.name] = null;
91
+ });
92
+ return obj;
93
+ }
94
+ async function getInitialValues(action, rowId) {
95
+ let obj = {};
96
+ if (action.initialise) {
97
+ obj = await action.initialise(rowId);
98
+ }
99
+ const customInitialValues = getCustomInitialValues(action.fields);
100
+ return Object.assign({}, customInitialValues, obj);
101
+ }
102
+ async function setOptions(fields) {
103
+ if (!fields) {
104
+ return;
105
+ }
106
+ const promises = fields.map(async (field) => {
107
+ if (field.type === "dropdown")
108
+ field.options = await field.getOptions();
109
+ else if (field.type === "array")
110
+ await setOptions([field.element]);
111
+ else if (field.type === "object")
112
+ await setOptions(field.fields);
113
+ });
114
+ await Promise.all(promises);
115
+ }
116
+ export function GenericForm({ action, onClose, rowId }) {
117
+ const [formFields, setFormFields] = useState(parseFields(action.fields));
118
+ const [initialValues, setInitialValues] = useState(getCustomInitialValues(action.fields));
119
+ const [validationSchema, _] = useState(parseValidation(action.fields));
120
+ useEffect(() => {
121
+ setOptions(action.fields).then(() => {
122
+ setFormFields(parseFields(action.fields));
123
+ });
124
+ }, []);
125
+ const handleFormReset = async () => {
126
+ const newInitialValues = await getInitialValues(action, rowId);
127
+ console.log(newInitialValues);
128
+ setInitialValues(newInitialValues);
129
+ };
130
+ if (!action.fields)
131
+ return _jsx(_Fragment, {});
132
+ return (_jsx(_Fragment, { children: _jsx(Formik, { enableReinitialize: true, initialValues: initialValues, validationSchema: Yup.object(validationSchema), onReset: handleFormReset, onSubmit: async (values) => {
133
+ try {
134
+ if (rowId)
135
+ await action.onSubmit(values, rowId);
136
+ else
137
+ await action.onSubmit(values);
138
+ if (onClose)
139
+ onClose();
140
+ Swal.fire("Ok");
141
+ }
142
+ catch (e) {
143
+ if (onClose)
144
+ onClose();
145
+ const err = e.request.response;
146
+ Swal.fire({
147
+ text: "Error: " + err,
148
+ });
149
+ }
150
+ }, children: ({ isSubmitting }) => (_jsxs(Form, { children: [formFields, _jsx(Button, { mt: 4, colorScheme: "teal", isLoading: isSubmitting, type: "submit", children: "Submit" }), _jsx(Button, { mt: 4, colorScheme: "teal", type: "reset", children: "Initialise Form" })] })) }) }));
151
+ }
@@ -0,0 +1 @@
1
+ import './index.css';
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom/client';
4
+ import App from './App';
5
+ import { event } from './testSchemas/event';
6
+ import './index.css';
7
+ ReactDOM.createRoot(document.getElementById('root')).render(_jsx(React.StrictMode, { children: _jsx(App, { pages: [event], basePath: '' }) }));
@@ -1,76 +1,53 @@
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
- }
1
+ import * as React from 'react';
2
+ export interface TableField {
3
+ name: string;
4
+ access: (obj: any) => string | number | React.ReactElement;
5
+ }
6
+ export interface SimpleField {
7
+ name: string;
8
+ label: string;
9
+ type: "string" | "number" | "file";
10
+ validationSchema: any;
11
+ }
12
+ export interface Option {
13
+ value: string | number | boolean;
14
+ display: string;
15
+ }
16
+ export interface DropdownField {
17
+ name: string;
18
+ label: string;
19
+ type: "dropdown";
20
+ options?: Option[] | undefined;
21
+ getOptions: () => Promise<Option[]>;
22
+ }
23
+ export interface ObjectField {
24
+ name: string;
25
+ label: string;
26
+ type: "object";
27
+ fields: FormField[];
28
+ }
29
+ export interface ArrayField {
30
+ name: string;
31
+ label: string;
32
+ type: "array";
33
+ element: Exclude<FormField, ArrayField>;
34
+ }
35
+ export type FormField = SimpleField | DropdownField | ObjectField | ArrayField;
36
+ export interface Action {
37
+ name: string;
38
+ fields?: FormField[];
39
+ onSubmit: (obj1: any, obj2?: any) => Promise<any>;
40
+ }
41
+ export interface RowAction {
42
+ name: string;
43
+ fields?: FormField[];
44
+ initialise?: (obj: any) => any;
45
+ onSubmit: (obj1: any, obj2?: any) => Promise<any>;
46
+ }
47
+ export interface PageSchema {
48
+ name: string;
49
+ actions: Action[];
50
+ rowActions: RowAction[];
51
+ getRequest: () => Promise<any[]>;
52
+ tableFields: TableField[];
53
+ }
@@ -0,0 +1,2 @@
1
+ import { PageSchema } from "../schema";
2
+ export declare const event: PageSchema;
@@ -0,0 +1,86 @@
1
+ import axios from "axios";
2
+ import React from "react";
3
+ const domain = "http://localhost:3001";
4
+ export const event = {
5
+ name: "Events",
6
+ actions: [],
7
+ rowActions: [
8
+ {
9
+ name: "Delete Event",
10
+ fields: [
11
+ {
12
+ name: "input",
13
+ label: "Mock Field",
14
+ type: "string",
15
+ validationSchema: "",
16
+ },
17
+ ],
18
+ initialise: async (eventId) => {
19
+ const res = await axios.get(domain + "/events/" + eventId);
20
+ let obj = {};
21
+ obj.input = res.data.name;
22
+ return obj;
23
+ },
24
+ onSubmit: async (_, eventId) => {
25
+ const res = await axios.delete(domain + "/events/" + eventId);
26
+ return res.data;
27
+ },
28
+ }
29
+ ],
30
+ getRequest: async () => {
31
+ const res = await axios.get(domain + "/events");
32
+ return res.data;
33
+ },
34
+ tableFields: [
35
+ {
36
+ name: "Id",
37
+ access: (obj) => obj.id,
38
+ },
39
+ {
40
+ name: "Event Name",
41
+ access: (obj) => obj.name,
42
+ },
43
+ {
44
+ name: "Description",
45
+ access: (obj) => obj.description,
46
+ },
47
+ {
48
+ name: "Category",
49
+ access: (obj) => obj.category,
50
+ },
51
+ {
52
+ name: "Ticket Type",
53
+ access: (obj) => obj.ticketType,
54
+ },
55
+ {
56
+ name: "Date",
57
+ access: (obj) => obj.date,
58
+ },
59
+ {
60
+ name: "Release",
61
+ access: (obj) => obj.release,
62
+ },
63
+ {
64
+ name: "Is Released",
65
+ access: (obj) => (obj.isReleased ? "Is Released" : "Not Released"),
66
+ },
67
+ {
68
+ name: "Available Tickets",
69
+ access: (obj) => obj.availableTickets,
70
+ },
71
+ {
72
+ name: "Max Tickets",
73
+ access: (obj) => obj.maxTickets,
74
+ },
75
+ {
76
+ name: "Image",
77
+ access: (obj) => obj.imgUrl
78
+ ? React.createElement("img", {
79
+ src: obj.imgUrl,
80
+ alt: "ERROR",
81
+ style: { width: "100px" },
82
+ })
83
+ : "No Image Available",
84
+ },
85
+ ],
86
+ };
@@ -0,0 +1 @@
1
+ export declare const newSocket: (setSocket: any, apiURL: string) => void;
@@ -1,15 +1,15 @@
1
1
  import io from "socket.io-client";
2
2
  import { useEffect } from "react";
3
- var Socket = function (setSocket, apiURL) {
4
- useEffect(function () {
5
- var socketRef = io(apiURL, {
3
+ const Socket = (setSocket, apiURL) => {
4
+ useEffect(() => {
5
+ const socketRef = io(apiURL, {
6
6
  transports: ["websocket"],
7
7
  });
8
8
  setSocket(socketRef);
9
- return function () {
9
+ return () => {
10
10
  socketRef.removeAllListeners();
11
11
  socketRef.disconnect();
12
12
  };
13
13
  }, []);
14
14
  };
15
- export var newSocket = function (setSocket, apiURL) { return Socket(setSocket, apiURL); };
15
+ export const newSocket = (setSocket, apiURL) => Socket(setSocket, apiURL);
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
- "version": "1.3.2",
4
- "description": "Generic Admin Panel created for storing events' data",
5
- "private": false,
6
- "dependencies": {
7
- "@chakra-ui/react": "^2.5.5",
8
- "@emotion/react": "^11.10.6",
9
- "@emotion/styled": "^11.10.6",
10
- "@tanstack/match-sorter-utils": "^8.8.4",
11
- "@tanstack/react-table": "^8.10.7",
12
- "@tanstack/react-virtual": "^3.0.0-beta.68",
13
- "@testing-library/jest-dom": "^5.16.5",
14
- "@testing-library/react": "^13.4.0",
15
- "@testing-library/user-event": "^13.5.0",
16
- "@types/jest": "^27.5.2",
17
- "@types/node": "^16.18.23",
18
- "@types/react-dom": "^18.0.11",
19
- "axios": "^1.3.5",
20
- "export-to-csv": "^1.2.1",
21
- "formik": "^2.2.9",
22
- "framer-motion": "^10.11.6",
23
- "material-react-table": "^2.0.2",
24
- "nth-check": "^2.1.1",
25
- "postcss": "^8.4.35",
26
- "prettier": "^2.8.7",
27
- "react": "^18.2.0",
28
- "react-dom": "^18.2.0",
29
- "react-router": "^6.10.0",
30
- "react-router-dom": "^6.10.0",
31
- "react-scripts": "^5.0.1",
32
- "react-table": "^7.8.0",
33
- "socket.io-client": "^4.7.5",
34
- "sweetalert2": "^11.6.13",
35
- "typescript": "^4.9.5",
36
- "web-vitals": "^2.1.4",
37
- "yup": "^1.0.2"
38
- },
39
- "scripts": {
40
- "start": "react-scripts start",
41
- "build": "react-scripts build",
42
- "test": "react-scripts test",
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.1",
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/src/components/AdminPage.js",
40
+ "module": "dist/src/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
- "compilerOptions": {
3
- "target": "es5",
4
- "lib": [
5
- "dom",
6
- "dom.iterable",
7
- "esnext"
8
- ],
9
- "allowJs": true,
10
- "skipLibCheck": true,
11
- "esModuleInterop": true,
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
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react-swc'
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ })
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;