drf-react-by-schema 0.15.3 → 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.
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +4 -19
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +1 -16
- package/dist/components/forms/FieldBySchema.js +1 -1
- package/dist/components/forms/FormBySchema.d.ts +2 -3
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +2 -3
- package/dist/context/APIWrapperContext.d.ts +3 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -3
- package/package.json +2 -1
|
@@ -1,34 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SxProps } from '@mui/material';
|
|
3
|
+
import { GenericValue, OptionsAC } from '../../utils';
|
|
3
4
|
import { GridEnrichedBySchemaColDef } from '../../utils';
|
|
4
|
-
import {
|
|
5
|
+
import { OnEditModelType } from '../../context/APIWrapperContext';
|
|
5
6
|
interface SelectEditInputCellProps {
|
|
6
7
|
field: string;
|
|
7
8
|
id: number | string;
|
|
8
|
-
value?:
|
|
9
|
+
value?: GenericValue;
|
|
9
10
|
column: GridEnrichedBySchemaColDef;
|
|
10
11
|
type: string;
|
|
11
|
-
optionsAC:
|
|
12
|
+
optionsAC: OptionsAC | null;
|
|
12
13
|
isIndexField: boolean;
|
|
13
14
|
multiple?: boolean;
|
|
14
15
|
onEditModel?: (x: OnEditModelType) => void;
|
|
15
16
|
sx?: SxProps;
|
|
16
17
|
}
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param {SelectEditInputCellProps} {
|
|
21
|
-
* field,
|
|
22
|
-
* id,
|
|
23
|
-
* value,
|
|
24
|
-
* column,
|
|
25
|
-
* type,
|
|
26
|
-
* optionsAC,
|
|
27
|
-
* isIndexField,
|
|
28
|
-
* multiple = false,
|
|
29
|
-
* sx = {}
|
|
30
|
-
* }
|
|
31
|
-
* @returns {*} {JSX.Element}
|
|
32
|
-
*/
|
|
33
18
|
export declare function SelectEditInputCell({ field, id, value, column, type, optionsAC, isIndexField, multiple, onEditModel, sx, }: SelectEditInputCellProps): JSX.Element;
|
|
34
19
|
export {};
|
|
@@ -44,22 +44,6 @@ const Edit_1 = __importDefault(require("@mui/icons-material/Edit"));
|
|
|
44
44
|
const Autocomplete_1 = __importStar(require("@mui/material/Autocomplete"));
|
|
45
45
|
const utils_1 = require("../../utils");
|
|
46
46
|
const filter = (0, Autocomplete_1.createFilterOptions)();
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @param {SelectEditInputCellProps} {
|
|
51
|
-
* field,
|
|
52
|
-
* id,
|
|
53
|
-
* value,
|
|
54
|
-
* column,
|
|
55
|
-
* type,
|
|
56
|
-
* optionsAC,
|
|
57
|
-
* isIndexField,
|
|
58
|
-
* multiple = false,
|
|
59
|
-
* sx = {}
|
|
60
|
-
* }
|
|
61
|
-
* @returns {*} {JSX.Element}
|
|
62
|
-
*/
|
|
63
47
|
function SelectEditInputCell({ field, id, value, column, type, optionsAC, isIndexField, multiple = false, onEditModel, sx = {}, }) {
|
|
64
48
|
// TODO: allow edit option label, as in formautocomplete!
|
|
65
49
|
const apiRef = (0, x_data_grid_1.useGridApiContext)();
|
|
@@ -101,6 +85,7 @@ function SelectEditInputCell({ field, id, value, column, type, optionsAC, isInde
|
|
|
101
85
|
// Regular option
|
|
102
86
|
return option[labelKey];
|
|
103
87
|
},
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
89
|
renderOption: (props, option) => {
|
|
105
90
|
return (react_1.default.createElement("li", Object.assign({ key: option[valueKey] }, props), option[labelKey]));
|
|
106
91
|
},
|
|
@@ -23,7 +23,7 @@ const BooleanFieldBySchema_1 = __importDefault(require("./inputs/BooleanFieldByS
|
|
|
23
23
|
const FloatFieldBySchema_1 = __importDefault(require("./inputs/FloatFieldBySchema"));
|
|
24
24
|
const TextFieldBySchema_1 = __importDefault(require("./inputs/TextFieldBySchema"));
|
|
25
25
|
function FieldBySchema(_a) {
|
|
26
|
-
var { name, schema, control, errors, multiline = false, setValue
|
|
26
|
+
var { name, schema, control, errors, multiline = false, setValue, getValues, fieldKey, labelKey = 'nome', index, optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, sx, options, isSemaphoric = false, label, onValueChange, decimalScale = 2 } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "setValue", "getValues", "fieldKey", "labelKey", "index", "optionsAC", "optionsModel", "getOptionLabel", "renderOption", "onEditModel", "sx", "options", "isSemaphoric", "label", "onValueChange", "decimalScale"]);
|
|
27
27
|
switch (schema[name].type) {
|
|
28
28
|
case 'date':
|
|
29
29
|
return (react_1.default.createElement(DesktopDatePickerBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, sx: sx }, other)));
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UseFormRegister } from 'react-hook-form';
|
|
3
|
-
import { CommonFieldProps, FieldBySchemaProps, FormFieldLayout, Item } from '../../utils';
|
|
4
|
-
import { OptionsACType } from '../../context/APIWrapperContext';
|
|
3
|
+
import { CommonFieldProps, FieldBySchemaProps, FormFieldLayout, Item, OptionsAC } from '../../utils';
|
|
5
4
|
interface FormBySchemaProps extends Omit<FieldBySchemaProps, 'name'> {
|
|
6
5
|
fieldsLayout?: FormFieldLayout[];
|
|
7
6
|
hiddenFields?: string[];
|
|
8
7
|
register?: UseFormRegister<Item>;
|
|
9
|
-
setOptionsAC?: (x:
|
|
8
|
+
setOptionsAC?: (x: OptionsAC) => void;
|
|
10
9
|
forceReload?: boolean;
|
|
11
10
|
isolatedGetAutoComplete?: (model: string) => Promise<false | Item[]>;
|
|
12
11
|
fieldsProps?: Record<string, CommonFieldProps>;
|
|
@@ -18,12 +18,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
18
18
|
const react_hook_form_1 = require("react-hook-form");
|
|
19
19
|
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
20
20
|
const DesktopDatePicker_1 = require("@mui/x-date-pickers/DesktopDatePicker");
|
|
21
|
-
const utils_1 = require("drf-react-by-schema/dist/utils");
|
|
22
21
|
const LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
23
22
|
const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
|
|
24
23
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
25
24
|
require("dayjs/locale/pt-br");
|
|
26
|
-
const
|
|
25
|
+
const utils_1 = require("../../../utils");
|
|
27
26
|
function DesktopDatePickerBySchema(_a) {
|
|
28
27
|
var { name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 } } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "sx"]);
|
|
29
28
|
if (!sx) {
|
|
@@ -38,7 +37,7 @@ function DesktopDatePickerBySchema(_a) {
|
|
|
38
37
|
}
|
|
39
38
|
const inputFormat = (0, utils_1.buildDateFormatBySchema)(schema[model].date_views);
|
|
40
39
|
const { error, helperText } = fieldKey && index && index >= 0
|
|
41
|
-
? (0,
|
|
40
|
+
? (0, utils_1.errorProps)({
|
|
42
41
|
fieldKey,
|
|
43
42
|
index,
|
|
44
43
|
fieldKeyProp: name,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldValues, SubmitHandler, UseFormGetValues, UseFormSetValue } from 'react-hook-form';
|
|
3
|
+
import { AlertColor, AlertPropsColorOverrides } from '@mui/material/Alert';
|
|
4
|
+
import { OverridableStringUnion } from '@mui/types';
|
|
3
5
|
import { ItemSchemaColumnsType, Id, Item, SchemaType, DataSchemaColumnsType, OnSuccessEvent, OptionsAC, GenericValue, TargetApiParams } from '../utils';
|
|
4
6
|
import { GetGenericModelListProps } from '../api';
|
|
5
7
|
import { serverEndPointType } from './DRFReactBySchemaContext';
|
|
@@ -53,7 +55,7 @@ export interface OnDeleteRelatedModelType {
|
|
|
53
55
|
export interface SnackBarType {
|
|
54
56
|
open?: boolean;
|
|
55
57
|
msg?: string;
|
|
56
|
-
severity?:
|
|
58
|
+
severity?: OverridableStringUnion<AlertColor, AlertPropsColorOverrides>;
|
|
57
59
|
}
|
|
58
60
|
export interface DialogType {
|
|
59
61
|
open: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { emptyByType, getChoiceByValue, populateValues, buildGenericYupValidatio
|
|
|
3
3
|
import DRFReactBySchemaProvider from './context/DRFReactBySchemaProvider';
|
|
4
4
|
import { useDRFReactBySchema } from './context/DRFReactBySchemaContext';
|
|
5
5
|
import { useAPIWrapper } from './context/APIWrapperContext';
|
|
6
|
-
import Form from './context/Form';
|
|
7
6
|
import FormBySchema from './components/forms/FormBySchema';
|
|
8
7
|
import DialogFormBySchema from './components/forms/DialogFormBySchema';
|
|
9
8
|
import DataGridBySchemaEditable from './components/DataGridBySchemaEditable';
|
|
@@ -26,4 +25,4 @@ import AutocompleteFieldBySchema from './components/forms/inputs/AutocompleteFie
|
|
|
26
25
|
import FloatFieldBySchema from './components/forms/inputs/FloatFieldBySchema';
|
|
27
26
|
import DetailBySchema from './components/details/DetailBySchema';
|
|
28
27
|
import DetailFieldBySchema from './components/details/DetailFieldBySchema';
|
|
29
|
-
export { DRFReactBySchemaProvider, useAPIWrapper, useDRFReactBySchema,
|
|
28
|
+
export { DRFReactBySchemaProvider, useAPIWrapper, useDRFReactBySchema, FormBySchema, DialogFormBySchema, DataGridBySchemaEditable, GenericModelList, GenericRelatedModelList, DataTotals, DialogActions, SelectEditInputCell, GridDateInput, GridDecimalInput, GridPatternInput, BooleanInputCell, FieldBySchema, TextFieldBySchema, BooleanFieldBySchema, DesktopDatePickerBySchema, DesktopDateTimePickerBySchema, EditableAutocompleteFieldBySchema, AutocompleteFieldBySchema, FloatFieldBySchema, DetailBySchema, DetailFieldBySchema, updateData, partialUpdateData, createData, deleteData, createOrUpdateData, updateDataBySchema, addExistingRelatedModel, getAutoComplete, loginByPayload, setAuthToken, isLoggedIn, getGenericModelList, getGenericModel, emptyByType, getChoiceByValue, populateValues, buildGenericYupValidationSchema, errorProps, getTmpId, isTmpId, getPatternFormat, clearJWT, hasJWT, slugToCamelCase, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.slugToCamelCase = exports.hasJWT = exports.clearJWT = 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.getAutoComplete = exports.addExistingRelatedModel = exports.updateDataBySchema = exports.createOrUpdateData = exports.deleteData = exports.createData = exports.partialUpdateData = exports.updateData = exports.DetailFieldBySchema = exports.DetailBySchema = exports.FloatFieldBySchema = exports.AutocompleteFieldBySchema = exports.EditableAutocompleteFieldBySchema = exports.DesktopDateTimePickerBySchema = exports.DesktopDatePickerBySchema = exports.BooleanFieldBySchema = exports.TextFieldBySchema = exports.FieldBySchema = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DialogFormBySchema = exports.FormBySchema = exports.
|
|
6
|
+
exports.slugToCamelCase = exports.hasJWT = exports.clearJWT = 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.getAutoComplete = exports.addExistingRelatedModel = exports.updateDataBySchema = exports.createOrUpdateData = exports.deleteData = exports.createData = exports.partialUpdateData = exports.updateData = exports.DetailFieldBySchema = exports.DetailBySchema = exports.FloatFieldBySchema = exports.AutocompleteFieldBySchema = exports.EditableAutocompleteFieldBySchema = exports.DesktopDateTimePickerBySchema = exports.DesktopDatePickerBySchema = exports.BooleanFieldBySchema = exports.TextFieldBySchema = exports.FieldBySchema = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DialogFormBySchema = exports.FormBySchema = exports.useDRFReactBySchema = exports.useAPIWrapper = exports.DRFReactBySchemaProvider = void 0;
|
|
7
7
|
// Methods:
|
|
8
8
|
const api_1 = require("./api");
|
|
9
9
|
Object.defineProperty(exports, "updateData", { enumerable: true, get: function () { return api_1.updateData; } });
|
|
@@ -39,8 +39,7 @@ Object.defineProperty(exports, "useDRFReactBySchema", { enumerable: true, get: f
|
|
|
39
39
|
const APIWrapperContext_1 = require("./context/APIWrapperContext");
|
|
40
40
|
Object.defineProperty(exports, "useAPIWrapper", { enumerable: true, get: function () { return APIWrapperContext_1.useAPIWrapper; } });
|
|
41
41
|
// Forms:
|
|
42
|
-
|
|
43
|
-
exports.Form = Form_1.default;
|
|
42
|
+
// import Form from './context/Form';
|
|
44
43
|
const FormBySchema_1 = __importDefault(require("./components/forms/FormBySchema"));
|
|
45
44
|
exports.FormBySchema = FormBySchema_1.default;
|
|
46
45
|
const DialogFormBySchema_1 = __importDefault(require("./components/forms/DialogFormBySchema"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drf-react-by-schema",
|
|
3
|
-
"version": "0.15.
|
|
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",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@mui/x-data-grid": "^5.17.26",
|
|
71
71
|
"@mui/x-date-pickers": "^5.0.20",
|
|
72
72
|
"axios": "^0.27.2",
|
|
73
|
+
"dayjs": "^1.11.10",
|
|
73
74
|
"moment": "^2.29.4",
|
|
74
75
|
"react": "^18.2.0",
|
|
75
76
|
"react-dom": "^18.2.0",
|