drf-react-by-schema 0.1.0 → 0.2.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.
- package/.eslintrc.js +5 -2
- package/.gitlab-ci.yml +14 -0
- package/README.md +9 -82
- package/dist/index.js +57 -1
- package/package.json +39 -10
- package/src/api.ts +380 -173
- package/src/components/DataGridBySchemaEditable/ConfirmDialog.tsx +41 -0
- package/src/components/DataGridBySchemaEditable/CustomToolbar.tsx +93 -0
- package/src/components/DataGridBySchemaEditable/FooterToolbar.tsx +77 -0
- package/src/components/DataGridBySchemaEditable/GridDecimalInput.tsx +41 -0
- package/src/components/DataGridBySchemaEditable/GridPatternInput.tsx +37 -0
- package/src/components/DataGridBySchemaEditable/InputInterval.tsx +194 -0
- package/src/components/DataGridBySchemaEditable/SelectEditInputCell.tsx +153 -0
- package/src/components/DataGridBySchemaEditable/utils.ts +118 -0
- package/src/components/DataGridBySchemaEditable.md +50 -0
- package/src/components/DataGridBySchemaEditable.tsx +72 -726
- package/src/components/DataTotals.tsx +56 -0
- package/src/components/GenericModelList.tsx +155 -0
- package/src/context/DRFReactBySchemaProvider.md +50 -0
- package/src/context/DRFReactBySchemaProvider.tsx +78 -0
- package/src/index.ts +62 -1
- package/src/utils.ts +5 -5
- package/styleguide.config.js +18 -0
- package/webpack.config.js +24 -0
package/.eslintrc.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
parser: '@typescript-eslint/parser',
|
|
3
|
-
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
|
|
3
|
+
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:react-hooks/recommended'],
|
|
4
4
|
parserOptions: {
|
|
5
5
|
sourceType: 'module',
|
|
6
6
|
},
|
|
7
7
|
rules: {
|
|
8
8
|
'prettier/prettier': 'error',
|
|
9
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
10
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
11
|
+
'tsdoc/syntax': 'warn'
|
|
9
12
|
},
|
|
10
|
-
plugins: ['@typescript-eslint', 'prettier'],
|
|
13
|
+
plugins: ['@typescript-eslint', 'prettier', 'react-hooks', 'eslint-plugin-tsdoc'],
|
|
11
14
|
}
|
package/.gitlab-ci.yml
ADDED
package/README.md
CHANGED
|
@@ -1,92 +1,19 @@
|
|
|
1
1
|
# DRF and React By Schema - JS
|
|
2
2
|
|
|
3
|
+
*This Package will offer out-of-the-box Components, Providers and other tools to make it a breeze to build editable tables and complete forms, completely integrated to Django Rest Framework schemas for validations and widgets, and all CRUD operations working, based diractly, primarily and automatically on the Model, Viewsets and Serializers built in Django.*
|
|
3
4
|
|
|
5
|
+
## About
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Working with forms and CRUD operations in React having Django as the Backend Server can be too "manual" and prone for errors.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
There are no simple ways to make things more integrated among both systems.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
There will be two solutions: one for react (this very one!) and one for Django, with the same name (still not released).
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
**Warning:** This is still a work in progress! At the moment, only some of the components are built, besides the Provider Component.
|
|
12
14
|
|
|
13
|
-
-
|
|
14
|
-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
For `drf-react-by-schema` to work, you will have to install other important packages, as MUI, YUP, among others (listed as Peer Dependencies in `package.json`).
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.com/eita/drf-react-by-schema/drf-react-by-schema-js.git
|
|
19
|
-
git branch -M master
|
|
20
|
-
git push -uf origin master
|
|
21
|
-
```
|
|
17
|
+
In the next weeks, we hope to offer full Documentation, guides to install, and other useful informations for using it.
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- [ ] [Set up project integrations](https://gitlab.com/eita/drf-react-by-schema/drf-react-by-schema-js/-/settings/integrations)
|
|
26
|
-
|
|
27
|
-
## Collaborate with your team
|
|
28
|
-
|
|
29
|
-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
-
|
|
35
|
-
## Test and Deploy
|
|
36
|
-
|
|
37
|
-
Use the built-in continuous integration in GitLab.
|
|
38
|
-
|
|
39
|
-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
# Editing this README
|
|
48
|
-
|
|
49
|
-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
-
|
|
51
|
-
## Suggestions for a good README
|
|
52
|
-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
53
|
-
|
|
54
|
-
## Name
|
|
55
|
-
Choose a self-explaining name for your project.
|
|
56
|
-
|
|
57
|
-
## Description
|
|
58
|
-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
59
|
-
|
|
60
|
-
## Badges
|
|
61
|
-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
62
|
-
|
|
63
|
-
## Visuals
|
|
64
|
-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
65
|
-
|
|
66
|
-
## Installation
|
|
67
|
-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
68
|
-
|
|
69
|
-
## Usage
|
|
70
|
-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
71
|
-
|
|
72
|
-
## Support
|
|
73
|
-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
74
|
-
|
|
75
|
-
## Roadmap
|
|
76
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
77
|
-
|
|
78
|
-
## Contributing
|
|
79
|
-
State if you are open to contributions and what your requirements are for accepting them.
|
|
80
|
-
|
|
81
|
-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
82
|
-
|
|
83
|
-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
84
|
-
|
|
85
|
-
## Authors and acknowledgment
|
|
86
|
-
Show your appreciation to those who have contributed to the project.
|
|
87
|
-
|
|
88
|
-
## License
|
|
89
|
-
For open source projects, say how it is licensed.
|
|
90
|
-
|
|
91
|
-
## Project status
|
|
92
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
19
|
+
For now, if you have interest in using this solution or helping to develop, send us an e-mail at dtygel@eita.org.br or create issues directly at our repository.
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DataGridBySchemaEditable = void 0;
|
|
29
|
+
exports.getPatternFormat = exports.isTmpId = exports.getTmpId = exports.errorProps = exports.buildGenericYupValidationSchema = exports.populateValues = exports.getChoiceByValue = exports.emptyByType = exports.getGenericModel = exports.getGenericModelList = exports.isLoggedIn = exports.setAuthToken = exports.loginByPayload = exports.createOrUpdateJSONSchema = exports.getJSONSchema = exports.getAutoComplete = exports.addExistingRelatedModel = exports.updateDataBySchema = exports.createOrUpdateData = exports.deleteData = exports.createData = exports.partialUpdateData = exports.updateData = exports.DataTotals = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DRFReactBySchemaContext = exports.DRFReactBySchemaProvider = void 0;
|
|
30
|
+
const api_1 = require("./api");
|
|
31
|
+
Object.defineProperty(exports, "updateData", { enumerable: true, get: function () { return api_1.updateData; } });
|
|
32
|
+
Object.defineProperty(exports, "partialUpdateData", { enumerable: true, get: function () { return api_1.partialUpdateData; } });
|
|
33
|
+
Object.defineProperty(exports, "createData", { enumerable: true, get: function () { return api_1.createData; } });
|
|
34
|
+
Object.defineProperty(exports, "deleteData", { enumerable: true, get: function () { return api_1.deleteData; } });
|
|
35
|
+
Object.defineProperty(exports, "createOrUpdateData", { enumerable: true, get: function () { return api_1.createOrUpdateData; } });
|
|
36
|
+
Object.defineProperty(exports, "updateDataBySchema", { enumerable: true, get: function () { return api_1.updateDataBySchema; } });
|
|
37
|
+
Object.defineProperty(exports, "addExistingRelatedModel", { enumerable: true, get: function () { return api_1.addExistingRelatedModel; } });
|
|
38
|
+
Object.defineProperty(exports, "getAutoComplete", { enumerable: true, get: function () { return api_1.getAutoComplete; } });
|
|
39
|
+
Object.defineProperty(exports, "getJSONSchema", { enumerable: true, get: function () { return api_1.getJSONSchema; } });
|
|
40
|
+
Object.defineProperty(exports, "createOrUpdateJSONSchema", { enumerable: true, get: function () { return api_1.createOrUpdateJSONSchema; } });
|
|
41
|
+
Object.defineProperty(exports, "loginByPayload", { enumerable: true, get: function () { return api_1.loginByPayload; } });
|
|
42
|
+
Object.defineProperty(exports, "setAuthToken", { enumerable: true, get: function () { return api_1.setAuthToken; } });
|
|
43
|
+
Object.defineProperty(exports, "isLoggedIn", { enumerable: true, get: function () { return api_1.isLoggedIn; } });
|
|
44
|
+
Object.defineProperty(exports, "getGenericModelList", { enumerable: true, get: function () { return api_1.getGenericModelList; } });
|
|
45
|
+
Object.defineProperty(exports, "getGenericModel", { enumerable: true, get: function () { return api_1.getGenericModel; } });
|
|
46
|
+
const utils_1 = require("./utils");
|
|
47
|
+
Object.defineProperty(exports, "emptyByType", { enumerable: true, get: function () { return utils_1.emptyByType; } });
|
|
48
|
+
Object.defineProperty(exports, "getChoiceByValue", { enumerable: true, get: function () { return utils_1.getChoiceByValue; } });
|
|
49
|
+
Object.defineProperty(exports, "populateValues", { enumerable: true, get: function () { return utils_1.populateValues; } });
|
|
50
|
+
Object.defineProperty(exports, "buildGenericYupValidationSchema", { enumerable: true, get: function () { return utils_1.buildGenericYupValidationSchema; } });
|
|
51
|
+
Object.defineProperty(exports, "errorProps", { enumerable: true, get: function () { return utils_1.errorProps; } });
|
|
52
|
+
Object.defineProperty(exports, "getTmpId", { enumerable: true, get: function () { return utils_1.getTmpId; } });
|
|
53
|
+
Object.defineProperty(exports, "isTmpId", { enumerable: true, get: function () { return utils_1.isTmpId; } });
|
|
54
|
+
Object.defineProperty(exports, "getPatternFormat", { enumerable: true, get: function () { return utils_1.getPatternFormat; } });
|
|
55
|
+
// Components:
|
|
56
|
+
const DRFReactBySchemaProvider_1 = __importStar(require("./context/DRFReactBySchemaProvider"));
|
|
57
|
+
exports.DRFReactBySchemaProvider = DRFReactBySchemaProvider_1.default;
|
|
58
|
+
Object.defineProperty(exports, "DRFReactBySchemaContext", { enumerable: true, get: function () { return DRFReactBySchemaProvider_1.DRFReactBySchemaContext; } });
|
|
7
59
|
const DataGridBySchemaEditable_1 = __importDefault(require("./components/DataGridBySchemaEditable"));
|
|
8
60
|
exports.DataGridBySchemaEditable = DataGridBySchemaEditable_1.default;
|
|
61
|
+
const GenericModelList_1 = __importDefault(require("./components/GenericModelList"));
|
|
62
|
+
exports.GenericModelList = GenericModelList_1.default;
|
|
63
|
+
const DataTotals_1 = __importDefault(require("./components/DataTotals"));
|
|
64
|
+
exports.DataTotals = DataTotals_1.default;
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drf-react-by-schema",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Tools for building a React App having Django Rest Framework (DRF) as server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"There are (still) no tests in this package\"",
|
|
8
|
-
"build": "tsc"
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepare": "install-peers",
|
|
11
|
+
"styleguide": "styleguidist server",
|
|
12
|
+
"styleguide:build": "styleguidist build"
|
|
9
13
|
},
|
|
10
14
|
"repository": {
|
|
11
15
|
"type": "git",
|
|
@@ -14,7 +18,12 @@
|
|
|
14
18
|
"keywords": [
|
|
15
19
|
"react",
|
|
16
20
|
"drf",
|
|
17
|
-
"django"
|
|
21
|
+
"django",
|
|
22
|
+
"django rest framework",
|
|
23
|
+
"schema based forms",
|
|
24
|
+
"MUI",
|
|
25
|
+
"MUI DataGrid",
|
|
26
|
+
"yup"
|
|
18
27
|
],
|
|
19
28
|
"author": "Coletivo EITA",
|
|
20
29
|
"license": "MIT",
|
|
@@ -23,17 +32,29 @@
|
|
|
23
32
|
},
|
|
24
33
|
"homepage": "https://gitlab.com/eita/drf-react-by-schema/drf-react-by-schema-js#readme",
|
|
25
34
|
"devDependencies": {
|
|
35
|
+
"@babel/core": "^7.20.7",
|
|
36
|
+
"@babel/preset-env": "^7.20.2",
|
|
37
|
+
"@babel/preset-react": "^7.18.6",
|
|
38
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
39
|
+
"@emotion/react": "^11.10.5",
|
|
40
|
+
"@emotion/styled": "^11.10.5",
|
|
26
41
|
"@types/react": "^18.0.26",
|
|
27
42
|
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
28
43
|
"@typescript-eslint/parser": "^5.47.0",
|
|
29
44
|
"eslint": "^8.30.0",
|
|
30
45
|
"eslint-config-prettier": "^8.5.0",
|
|
31
46
|
"eslint-plugin-prettier": "^4.2.1",
|
|
32
|
-
"react": "^
|
|
33
|
-
"
|
|
34
|
-
"
|
|
47
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
48
|
+
"eslint-plugin-tsdoc": "^0.2.17",
|
|
49
|
+
"install-peers-cli": "^2.2.0",
|
|
50
|
+
"react-docgen-typescript": "^2.2.2",
|
|
51
|
+
"react-styleguidist": "^13.0.0",
|
|
52
|
+
"ts-loader": "^9.4.2",
|
|
53
|
+
"typedoc": "^0.23.23",
|
|
54
|
+
"typescript": "^4.9.4",
|
|
55
|
+
"webpack": "^5.75.0"
|
|
35
56
|
},
|
|
36
|
-
"
|
|
57
|
+
"peerDependencies": {
|
|
37
58
|
"@mui/icons-material": "^5.11.0",
|
|
38
59
|
"@mui/lab": "^5.0.0-alpha.112",
|
|
39
60
|
"@mui/material": "^5.11.0",
|
|
@@ -42,11 +63,19 @@
|
|
|
42
63
|
"@types/jest": "^29.2.4",
|
|
43
64
|
"@types/node": "^18.11.15",
|
|
44
65
|
"@types/react-dom": "^18.0.9",
|
|
45
|
-
"axios": "^
|
|
66
|
+
"axios": "^0.27.2",
|
|
46
67
|
"moment": "^2.29.4",
|
|
68
|
+
"react": "^18.2.0",
|
|
69
|
+
"react-dom": "^18.2.0",
|
|
47
70
|
"react-number-format": "^5.1.2",
|
|
48
|
-
"react-router-dom": "^6.4.5",
|
|
49
71
|
"string-mask": "^0.3.0",
|
|
50
72
|
"yup": "^0.32.11"
|
|
51
|
-
}
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {},
|
|
75
|
+
"browserslist": [
|
|
76
|
+
">1%",
|
|
77
|
+
"last 1 version",
|
|
78
|
+
"Firefox ESR",
|
|
79
|
+
"not dead"
|
|
80
|
+
]
|
|
52
81
|
}
|