drf-react-by-schema 0.15.2 → 0.15.4

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 (55) hide show
  1. package/dist/api.d.ts +16 -22
  2. package/dist/api.js +253 -144
  3. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +1 -1
  4. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +2 -11
  5. package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +3 -12
  6. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +2 -2
  7. package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +2 -2
  8. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +2 -2
  9. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +3 -3
  10. package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +2 -2
  11. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +4 -4
  12. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +4 -19
  13. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +1 -16
  14. package/dist/components/DataGridBySchemaEditable/utils.d.ts +2 -2
  15. package/dist/components/DataGridBySchemaEditable.d.ts +8 -7
  16. package/dist/components/DataGridBySchemaEditable.js +128 -108
  17. package/dist/components/DataTotals.d.ts +2 -2
  18. package/dist/components/DataTotals.js +9 -10
  19. package/dist/components/DataTotalsServer.d.ts +2 -2
  20. package/dist/components/DialogActions.d.ts +1 -1
  21. package/dist/components/FormButtons.d.ts +1 -1
  22. package/dist/components/GenericModelList.d.ts +8 -8
  23. package/dist/components/GenericModelList.js +3 -3
  24. package/dist/components/GenericRelatedModelList.d.ts +6 -6
  25. package/dist/components/GenericRelatedModelList.js +4 -4
  26. package/dist/components/details/DetailBySchema.d.ts +2 -2
  27. package/dist/components/details/DetailFieldBySchema.d.ts +2 -2
  28. package/dist/components/forms/DialogFormBySchema.d.ts +3 -3
  29. package/dist/components/forms/FieldBySchema.d.ts +2 -2
  30. package/dist/components/forms/FieldBySchema.js +1 -1
  31. package/dist/components/forms/FormBySchema.d.ts +4 -5
  32. package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +2 -2
  33. package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +2 -2
  34. package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +2 -2
  35. package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +2 -3
  36. package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +2 -2
  37. package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts +2 -1
  38. package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +2 -2
  39. package/dist/components/forms/inputs/TextFieldBySchema.d.ts +2 -2
  40. package/dist/context/APIWrapper.d.ts +1 -1
  41. package/dist/context/APIWrapper.js +95 -50
  42. package/dist/context/APIWrapperContext.d.ts +13 -15
  43. package/dist/context/APIWrapperContext.js +1 -1
  44. package/dist/context/DRFReactBySchemaProvider.d.ts +1 -1
  45. package/dist/context/Form.d.ts +1 -1
  46. package/dist/context/FormContext.d.ts +0 -1
  47. package/dist/context/Overlays.d.ts +1 -1
  48. package/dist/index.d.ts +1 -2
  49. package/dist/index.js +2 -3
  50. package/dist/styles/layout.d.ts +1 -1
  51. package/dist/styles/theme.d.ts +1 -1
  52. package/dist/utils.d.ts +37 -14
  53. package/package.json +8 -6
  54. package/dist/components/DialogJSONSchemaForm.d.ts +0 -13
  55. package/dist/components/DialogJSONSchemaForm.js +0 -20
package/dist/utils.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  /// <reference types="react" />
2
+ import * as Yup from 'yup';
2
3
  import { CalendarPickerView } from '@mui/x-date-pickers/CalendarPicker';
3
4
  import { GridActionsColDef, GridColDef, GridFilterModel, GridSortModel } from '@mui/x-data-grid';
4
5
  import { Control, FieldValues, UseFormGetValues, UseFormSetValue } from 'react-hook-form';
5
6
  import { AutocompleteRenderOptionState, SxProps } from '@mui/material';
6
7
  import { OnEditModelType } from './context/APIWrapperContext';
7
- export type Id = string | number;
8
- export type Item = Record<string, any>;
8
+ import { serverEndPointType } from './context/DRFReactBySchemaContext';
9
+ export type Id = string | number | null;
10
+ export type GenericValue = any;
11
+ export type Item = Record<string, GenericValue>;
12
+ export type OptionsAC = Record<string, Item[]>;
9
13
  export type PaginatedResult = {
10
14
  count: number;
11
15
  next: number;
@@ -20,9 +24,21 @@ export interface PaginationModel {
20
24
  sort?: GridSortModel;
21
25
  }
22
26
  export type SchemaType = Record<string, Field>;
23
- export type modelOptionsType = Record<string, string>;
27
+ export type SchemaOptionsType = {
28
+ name: string;
29
+ description: string;
30
+ actions: {
31
+ POST: SchemaType;
32
+ };
33
+ renders: string[];
34
+ parses: string[];
35
+ verbose_name: string;
36
+ verbose_name_plural: string;
37
+ };
38
+ export type modelOptionsType = Omit<SchemaOptionsType, 'actions' | 'renders' | 'parses'>;
39
+ export type ChoiceValue = string | number;
24
40
  export interface Choice {
25
- value: string | number;
41
+ value: ChoiceValue;
26
42
  display_name: string;
27
43
  }
28
44
  type FieldChild = Record<string, SchemaType>;
@@ -30,7 +46,7 @@ export interface Field {
30
46
  type: string;
31
47
  child?: FieldChild;
32
48
  children?: SchemaType;
33
- model_default?: any;
49
+ model_default?: GenericValue;
34
50
  model_required?: boolean;
35
51
  choices?: Choice[];
36
52
  max_length?: number | string;
@@ -81,14 +97,14 @@ export interface ItemSchemaColumnsType {
81
97
  columns?: GridEnrichedBySchemaColDef[];
82
98
  }
83
99
  export interface CommonFieldProps {
84
- value?: any;
100
+ value?: GenericValue;
85
101
  multiline?: boolean;
86
102
  setValue?: UseFormSetValue<FieldValues>;
87
103
  getValues?: UseFormGetValues<FieldValues>;
88
104
  fieldKey?: string;
89
105
  labelKey?: string;
90
106
  index?: number;
91
- optionsAC?: Record<string, Item[]>;
107
+ optionsAC?: OptionsAC;
92
108
  optionsModel?: string;
93
109
  getOptionLabel?: (option: Item | string) => string;
94
110
  renderOption?: (props: React.HTMLAttributes<HTMLLIElement>, option: Item, state: AutocompleteRenderOptionState) => React.ReactNode;
@@ -98,7 +114,7 @@ export interface CommonFieldProps {
98
114
  options?: Item[];
99
115
  isSemaphoric?: boolean;
100
116
  label?: string;
101
- onValueChange?: (x: any) => void;
117
+ onValueChange?: (x: GenericValue) => void;
102
118
  decimalScale?: number;
103
119
  isPassword?: boolean;
104
120
  type?: React.HTMLInputTypeAttribute;
@@ -117,7 +133,7 @@ export interface FieldBySchemaProps extends Omit<CommonFieldProps, 'value'> {
117
133
  export interface DetailFieldBySchemaProps {
118
134
  name: string;
119
135
  schema: SchemaType;
120
- value: any;
136
+ value: GenericValue;
121
137
  labelKey?: string;
122
138
  decimalScale?: number;
123
139
  optionIdKey?: string;
@@ -129,19 +145,19 @@ export interface DetailFieldBySchemaProps {
129
145
  sxValueListItem?: SxProps;
130
146
  sxValueListItemText?: SxProps;
131
147
  }
132
- export declare const emptyByType: any;
133
- export declare const getChoiceByValue: (value: number | string, choices: Choice[] | undefined) => string | null | undefined;
148
+ export declare const emptyByType: GenericValue;
149
+ export declare const getChoiceByValue: (value: ChoiceValue, choices: Choice[] | undefined) => string | null | undefined;
134
150
  export declare const populateValues: ({ data, schema }: {
135
151
  data: Item;
136
152
  schema: SchemaType;
137
- }) => Record<string, any>;
153
+ }) => Item;
138
154
  export declare const buildGenericYupValidationSchema: ({ data, schema, many, skipFields, extraValidators, }: {
139
155
  data: Item;
140
156
  schema: SchemaType;
141
157
  many?: boolean | undefined;
142
158
  skipFields?: string[] | undefined;
143
159
  extraValidators?: Item | undefined;
144
- }) => any;
160
+ }) => Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>> | Yup.ArraySchema<Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, Item>>[] | undefined>;
145
161
  export declare const errorProps: ({ errors, fieldKey, fieldKeyProp, index, }: {
146
162
  errors: Item;
147
163
  fieldKey: string;
@@ -159,7 +175,7 @@ export type AddParametersToEnd<TFunction extends (...args: any) => any, TParamet
159
175
  export declare function buildDateFormatBySchema(dateViews: string[] | null | undefined): "DD/MM/yyyy" | "MM/yyyy" | "yyyy" | "MM" | "DD";
160
176
  export declare const slugToCamelCase: (str: string) => string;
161
177
  export declare const slugify: (text: string) => string;
162
- export declare function mergeFilterItems(defaultFilter: GridFilterModel | undefined, filter: GridFilterModel | undefined): any;
178
+ export declare function mergeFilterItems(defaultFilter: GridFilterModel | undefined, filter: GridFilterModel | undefined): GridFilterModel | undefined;
163
179
  export type ActionType = 'editInline' | 'remove' | 'edit' | 'view';
164
180
  export type BulkUpdateData = (newData: Item[]) => Promise<{
165
181
  id: Id;
@@ -214,4 +230,11 @@ export interface DetailBySchemaProps extends ExtraSxCommonFieldProps {
214
230
  fieldsLayout?: DetailFieldLayout[];
215
231
  fieldsProps?: Record<string, DetailCommonFieldProps>;
216
232
  }
233
+ export type OnSuccessEvent = (e: React.BaseSyntheticEvent) => any;
234
+ export interface TargetApiParams {
235
+ path: string;
236
+ serverEndPoint: serverEndPointType | null;
237
+ data: Item;
238
+ id: Id;
239
+ }
217
240
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drf-react-by-schema",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "description": "Components and Tools for building a React App having Django Rest Framework (DRF) as server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,8 +42,8 @@
42
42
  "@emotion/styled": "^11.10.5",
43
43
  "@types/jest": "^29.2.4",
44
44
  "@types/node": "^18.11.15",
45
- "@types/react": "^18.0.26",
46
- "@types/react-dom": "^18.0.9",
45
+ "@types/react": "^18.2.25",
46
+ "@types/react-dom": "^18.2.0",
47
47
  "@typescript-eslint/eslint-plugin": "^5.47.0",
48
48
  "@typescript-eslint/parser": "^5.47.0",
49
49
  "eslint": "^8.30.0",
@@ -51,6 +51,7 @@
51
51
  "eslint-plugin-prettier": "^5.0.0",
52
52
  "eslint-plugin-react-hooks": "^4.6.0",
53
53
  "eslint-plugin-tsdoc": "^0.2.17",
54
+ "install-peers": "^1.0.4",
54
55
  "install-peers-cli": "^2.2.0",
55
56
  "prettier": "^3.0.0",
56
57
  "react-docgen-typescript": "^2.2.2",
@@ -66,14 +67,15 @@
66
67
  "@mui/icons-material": "^5.11.0",
67
68
  "@mui/lab": "^5.0.0-alpha.112",
68
69
  "@mui/material": "^5.11.0",
69
- "@mui/x-data-grid": "^5.17.14",
70
- "@mui/x-date-pickers": "^5.0.11",
70
+ "@mui/x-data-grid": "^5.17.26",
71
+ "@mui/x-date-pickers": "^5.0.20",
71
72
  "axios": "^0.27.2",
73
+ "dayjs": "^1.11.10",
72
74
  "moment": "^2.29.4",
73
75
  "react": "^18.2.0",
74
76
  "react-dom": "^18.2.0",
75
77
  "react-hook-form": "^7.41.3",
76
- "react-number-format": "^5.1.2",
78
+ "react-number-format": "^5.3.2",
77
79
  "string-mask": "^0.3.0",
78
80
  "yup": "^0.32.11"
79
81
  },
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import { Item, SchemaType } from '../utils';
3
- interface DialogJSONSchemaFormProps {
4
- jsonSchemaFormRef: any;
5
- schema: SchemaType;
6
- uiSchema: SchemaType;
7
- formData: Item;
8
- onSubmit: ({ formData }: {
9
- formData: Item;
10
- }) => void;
11
- }
12
- export default function DialogJSONSchemaForm({ jsonSchemaFormRef, schema, uiSchema, formData, onSubmit }: DialogJSONSchemaFormProps): JSX.Element;
13
- export {};
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
7
- const Button_1 = __importDefault(require("@mui/material/Button"));
8
- const validator_ajv8_1 = __importDefault(require("@rjsf/validator-ajv8"));
9
- const mui_1 = __importDefault(require("@rjsf/mui"));
10
- ;
11
- function DialogJSONSchemaForm({ jsonSchemaFormRef, schema, uiSchema, formData, onSubmit }) {
12
- return (react_1.default.createElement(mui_1.default
13
- // @ts-ignore
14
- , {
15
- // @ts-ignore
16
- ref: jsonSchemaFormRef, schema: schema, uiSchema: uiSchema, validator: validator_ajv8_1.default, formData: formData, onSubmit: onSubmit },
17
- react_1.default.createElement(Button_1.default, { type: "submit", sx: { display: 'none' } }, "Salvar")));
18
- }
19
- exports.default = DialogJSONSchemaForm;
20
- ;