@dakataa/crud-react 1.0.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.
Files changed (78) hide show
  1. package/.env +3 -0
  2. package/README.md +58 -0
  3. package/babel-plugin-macros.config.js +5 -0
  4. package/index.html +12 -0
  5. package/package.json +74 -0
  6. package/public/favicon.ico +0 -0
  7. package/public/logo192.png +0 -0
  8. package/public/logo512.png +0 -0
  9. package/public/manifest.json +25 -0
  10. package/public/robots.txt +3 -0
  11. package/src/Crud.tsx +29 -0
  12. package/src/CrudContext.tsx +21 -0
  13. package/src/CrudLoader.tsx +27 -0
  14. package/src/assets/images/alert/denied.json +1 -0
  15. package/src/assets/images/alert/info.json +1 -0
  16. package/src/assets/images/alert/success.json +1 -0
  17. package/src/assets/images/alert/warning.json +1 -0
  18. package/src/assets/style/alert.scss +97 -0
  19. package/src/component/Animation.tsx +50 -0
  20. package/src/component/BaseButton.tsx +26 -0
  21. package/src/component/Button.tsx +15 -0
  22. package/src/component/Dropdown.tsx +55 -0
  23. package/src/component/EmptyView.tsx +5 -0
  24. package/src/component/Link.tsx +11 -0
  25. package/src/component/Modal.tsx +174 -0
  26. package/src/component/ModifyForm.tsx +139 -0
  27. package/src/component/TemplateBlock.tsx +21 -0
  28. package/src/component/TemplateExtend.tsx +17 -0
  29. package/src/component/TemplateParentBlock.tsx +7 -0
  30. package/src/component/Translation.tsx +7 -0
  31. package/src/component/ViewLoader.tsx +33 -0
  32. package/src/component/crud/DynamicView.tsx +42 -0
  33. package/src/component/crud/FormView.tsx +29 -0
  34. package/src/component/crud/GridTableView.tsx +205 -0
  35. package/src/component/crud/PaginatorView.tsx +80 -0
  36. package/src/component/error/ErrorBoundary.tsx +78 -0
  37. package/src/component/error/Exception.tsx +17 -0
  38. package/src/component/error/HttpException.tsx +24 -0
  39. package/src/component/form/Choice.tsx +119 -0
  40. package/src/component/form/Form.tsx +233 -0
  41. package/src/component/form/FormAlert.tsx +19 -0
  42. package/src/component/form/FormFieldError.tsx +16 -0
  43. package/src/component/form/FormGroup.tsx +53 -0
  44. package/src/component/form/FormWidget.tsx +34 -0
  45. package/src/component/form/Input.tsx +63 -0
  46. package/src/component/form/constraint/Contraint.tsx +8 -0
  47. package/src/component/form/constraint/NotBlank.tsx +20 -0
  48. package/src/component/hooks/GetData.tsx +137 -0
  49. package/src/context/ActionContext.tsx +99 -0
  50. package/src/context/AlertContext.tsx +181 -0
  51. package/src/context/ModalContext.tsx +56 -0
  52. package/src/context/SessionContext.tsx +97 -0
  53. package/src/helper/ObjectUtils.tsx +36 -0
  54. package/src/helper/RouterUtils.tsx +24 -0
  55. package/src/helper/StingUtils.tsx +25 -0
  56. package/src/index.tsx +23 -0
  57. package/src/layout/default/Base.tsx +15 -0
  58. package/src/layout/default/Error.tsx +27 -0
  59. package/src/layout/default/Main.tsx +64 -0
  60. package/src/layout/default/component/Navigation.tsx +197 -0
  61. package/src/page/List.tsx +268 -0
  62. package/src/page/Modify.tsx +156 -0
  63. package/src/react-app-env.d.ts +2 -0
  64. package/src/setupTests.ts +5 -0
  65. package/src/type/ActionType.tsx +10 -0
  66. package/src/type/ColumnType.tsx +18 -0
  67. package/src/type/ExceptionType.tsx +7 -0
  68. package/src/type/FormType.tsx +6 -0
  69. package/src/type/FormViewType.tsx +37 -0
  70. package/src/type/ListMetaType.tsx +7 -0
  71. package/src/type/ListType.tsx +20 -0
  72. package/src/type/ModifyType.tsx +10 -0
  73. package/src/type/RedirectType.tsx +6 -0
  74. package/src/type/RouteType.tsx +5 -0
  75. package/tsconfig.app.json +46 -0
  76. package/tsconfig.json +11 -0
  77. package/tsconfig.node.json +15 -0
  78. package/vite.config.ts +33 -0
@@ -0,0 +1,37 @@
1
+ export type FormViewType = {
2
+ id: string;
3
+ name: string;
4
+ full_name: string
5
+ label: string | undefined;
6
+ label_attr?: { [key: string]: string } | Function;
7
+ label_html?: boolean;
8
+ placeholder?: string | undefined;
9
+ placeholder_attr?: { [key: string]: string } | Function;
10
+ placeholder_in_choices?: boolean;
11
+ help?: string | null | undefined;
12
+ help_attr?: { [key: string]: string } | Function;
13
+ help_html?: boolean;
14
+ disabled?: boolean;
15
+ required?: boolean;
16
+ submitted?: boolean;
17
+ expanded?: boolean;
18
+ multiple?: boolean;
19
+ checked?: boolean;
20
+ priority?: number;
21
+ type: 'form' | string;
22
+ valid?: boolean;
23
+ errors?: string[];
24
+ children?: { [key: string]: FormViewType };
25
+ choices?: ChoiceType[];
26
+ choice_attr?: {[key: string]: {[key: string]: string}} | Function
27
+ preferred_choices?: { [key: string]: any };
28
+ attr?: { [key: string]: string } | Function;
29
+ data?: any;
30
+ rendered?: boolean;
31
+ }
32
+
33
+ export type ChoiceType = {
34
+ value: string | number | null | Function;
35
+ label: string | (() => string);
36
+ attr?: {[key: string]: {[key: string]: string}} | Function;
37
+ }
@@ -0,0 +1,7 @@
1
+ export type ListMetaType = {
2
+ links: number[];
3
+ maxResults: number;
4
+ page: number;
5
+ totalPages: number;
6
+ totalResults: number;
7
+ }
@@ -0,0 +1,20 @@
1
+ import {ColumnType} from "@src/type/ColumnType";
2
+ import {ActionType} from "@src/type/ActionType";
3
+ import {ListMetaType} from "@src/type/ListMetaType";
4
+ import {FormType} from "@src/type/FormType";
5
+
6
+ export type ListType = {
7
+ title: string | null;
8
+ entity: {
9
+ name: string;
10
+ columns: ColumnType[];
11
+ primaryColumn: ColumnType;
12
+ data: {
13
+ items: [{ [key: string]: any }],
14
+ meta: ListMetaType
15
+ }
16
+ },
17
+ form: { [key: string]: FormType, filter: FormType, batch: FormType },
18
+ sort: { [key: string]: 'ASC' | 'DESC' | null },
19
+ action: { [key: string]: ActionType }
20
+ }
@@ -0,0 +1,10 @@
1
+ import {FormType} from "@src/type/FormType";
2
+ import {RedirectType} from "@src/type/RedirectType";
3
+
4
+ export type ModifyType = {
5
+ title: string | null;
6
+ object: { [key: string]: any } | null,
7
+ form: { [key: string]: FormType },
8
+ messages: { [key: string]: string[] },
9
+ redirect?: RedirectType
10
+ }
@@ -0,0 +1,6 @@
1
+ import {RouteType} from "@src/type/RouteType";
2
+
3
+ export type RedirectType = {
4
+ route: RouteType;
5
+ parameters: {[key: string]: string};
6
+ }
@@ -0,0 +1,5 @@
1
+ export type RouteType = {
2
+ path: string;
3
+ defaults?: {[key:string]: string};
4
+ methods?: string[];
5
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5
+ "target": "ES2020",
6
+ "useDefineForClassFields": true,
7
+ "lib": [
8
+ "ESNext",
9
+ "DOM",
10
+ "DOM.Iterable"
11
+ ],
12
+ "module": "ESNext",
13
+ "skipLibCheck": true,
14
+ "types": [
15
+ "react",
16
+ "vite/client"
17
+ ],
18
+
19
+ /* Bundler mode */
20
+ "moduleResolution": "bundler",
21
+ "allowImportingTsExtensions": true,
22
+ "resolveJsonModule": true,
23
+ "isolatedModules": true,
24
+ "moduleDetection": "force",
25
+ "noEmit": true,
26
+ "jsx": "react-jsx",
27
+
28
+ /* Linting */
29
+ "strict": true,
30
+ "noUnusedLocals": false,
31
+ "noUnusedParameters": false,
32
+ "noFallthroughCasesInSwitch": true,
33
+ /* Paths */
34
+ "baseUrl": ".",
35
+ "paths": {
36
+ "@src/*": [
37
+ "./src/*"
38
+ ]
39
+ },
40
+ "allowSyntheticDefaultImports": true
41
+ },
42
+ "include": [
43
+ "src",
44
+ "crud"
45
+ ]
46
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.app.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.node.json"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,15 @@
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": [
13
+ "vite.config.ts"
14
+ ]
15
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import tsconfigPaths from 'vite-tsconfig-paths'
4
+ import path, {join} from "path";
5
+
6
+ export default defineConfig(() => {
7
+ return {
8
+ build: {
9
+ outDir: 'build',
10
+ },
11
+ plugins: [react(), tsconfigPaths()],
12
+ envPrefix: 'CRUD_',
13
+ resolve: {
14
+ alias: [
15
+ {
16
+ find: /~(.+)/,
17
+ replacement: join(process.cwd(), 'node_modules/$1'),
18
+ },
19
+ {
20
+ find: /^@crud\/(.+)/,
21
+ replacement: join(process.cwd(), '/crud/$1'),
22
+ },
23
+ {
24
+ find: /^@src\/(.+)/,
25
+ replacement: join(process.cwd(), '/src/$1'),
26
+ }
27
+ ]
28
+ },
29
+ optimizeDeps: {
30
+ exclude: ['@dakataa/requester']
31
+ }
32
+ };
33
+ });