drf-react-by-schema 0.24.2 → 0.24.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/GridActionsCellItemLink.d.ts +18 -0
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts.map +1 -0
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.js +24 -0
- package/dist/components/forms/Form.d.ts +5 -2
- package/dist/components/forms/Form.d.ts.map +1 -1
- package/dist/components/forms/Form.js +37 -7
- package/dist/components/forms/FormWatcher.d.ts +7 -0
- package/dist/components/forms/FormWatcher.d.ts.map +1 -0
- package/dist/components/forms/FormWatcher.js +21 -0
- package/dist/context/APIWrapper.d.ts.map +1 -1
- package/dist/context/APIWrapper.js +19 -21
- package/dist/context/APIWrapperContext.d.ts +11 -4
- package/dist/context/APIWrapperContext.d.ts.map +1 -1
- package/dist/context/APIWrapperContext.js +2 -2
- package/dist/context/DRFReactBySchemaContext.d.ts +13 -1
- package/dist/context/DRFReactBySchemaContext.d.ts.map +1 -1
- package/dist/context/DRFReactBySchemaContext.js +5 -0
- package/dist/context/DRFReactBySchemaProvider.d.ts +1 -10
- package/dist/context/DRFReactBySchemaProvider.d.ts.map +1 -1
- package/dist/context/DRFReactBySchemaProvider.js +31 -7
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridActionsCellItemProps } from '@mui/x-data-grid';
|
|
3
|
+
import { LinkComponentType } from '../../@types';
|
|
4
|
+
/**
|
|
5
|
+
* A type-safe wrapper for GridActionsCellItem that properly handles custom props
|
|
6
|
+
* for link components (like React Router's Link).
|
|
7
|
+
*
|
|
8
|
+
* This component solves the TypeScript issue where GridActionsCellItem doesn't
|
|
9
|
+
* natively accept custom props like 'to' and 'state' that are needed for routing.
|
|
10
|
+
*/
|
|
11
|
+
interface GridActionsCellItemLinkProps extends Omit<GridActionsCellItemProps, 'component'> {
|
|
12
|
+
component: LinkComponentType;
|
|
13
|
+
to: string | object;
|
|
14
|
+
state?: object;
|
|
15
|
+
}
|
|
16
|
+
export declare const GridActionsCellItemLink: React.FC<GridActionsCellItemLinkProps>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=GridActionsCellItemLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridActionsCellItemLink.d.ts","sourceRoot":"","sources":["../../../src/components/DataGridBySchemaEditable/GridActionsCellItemLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAuB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AAEH,UAAU,4BAA6B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,WAAW,CAAC;IACtF,SAAS,EAAE,iBAAiB,CAAC;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAa1E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.GridActionsCellItemLink = void 0;
|
|
18
|
+
const react_1 = __importDefault(require("react"));
|
|
19
|
+
const x_data_grid_1 = require("@mui/x-data-grid");
|
|
20
|
+
const GridActionsCellItemLink = (_a) => {
|
|
21
|
+
var { component, to, state } = _a, rest = __rest(_a, ["component", "to", "state"]);
|
|
22
|
+
return (react_1.default.createElement(x_data_grid_1.GridActionsCellItem, Object.assign({}, rest, { component: component }, { to, state })));
|
|
23
|
+
};
|
|
24
|
+
exports.GridActionsCellItemLink = GridActionsCellItemLink;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AxiosError } from 'axios';
|
|
3
3
|
import { UseFormRegister } from 'react-hook-form';
|
|
4
|
-
import { AutocompleteItem, CommonFieldProps, ExtraSxCommonFieldProps, FormFieldLayout, GenericValue, Id, Item, OptionsAC } from '../../@types';
|
|
4
|
+
import { AutocompleteItem, CommonFieldProps, ExtraSxCommonFieldProps, ExtraValidators, FormFieldLayout, GenericValue, Id, Item, OptionsAC } from '../../@types';
|
|
5
5
|
import { FormActionsProps } from './FormActions';
|
|
6
6
|
interface FormProps extends CommonFieldProps {
|
|
7
7
|
model: string;
|
|
@@ -32,7 +32,10 @@ interface FormProps extends CommonFieldProps {
|
|
|
32
32
|
autoFocusField?: string;
|
|
33
33
|
elevation?: number;
|
|
34
34
|
CustomFormActions?: (props: FormActionsProps) => React.JSX.Element;
|
|
35
|
+
extraValidators?: ExtraValidators;
|
|
35
36
|
}
|
|
36
|
-
export default function Form({ model, objId, basePath, defaults, objTitleField, onCancel, onSave, onSaveExit, onSaveCreateNew, onDelete, saveAndContinue, title, labelSave, labelSaveAndContinue, labelSaveAndCreateNew, labelCancel, labelRemove, multiline, fieldKey, labelKey, optionsAC, setOptionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, options, isSemaphoric, label, decimalScale, fieldsLayout, customFieldFormLayouts, fieldsProps, hiddenFields, isolatedGetAutoComplete, relatedEditable, autoFocusField, elevation, CustomFormActions, sxRow, sxRowMultiple, sxSection, sxSectionTitle, }: FormProps & Omit<ExtraSxCommonFieldProps, 'sx' | 'sxField' | 'sxLabel' | 'sxValue' | 'sxValueList' | 'sxValueListItem' | 'sxValueListItemText'>
|
|
37
|
+
export default function Form({ model, objId, basePath, defaults, objTitleField, onCancel, onSave, onSaveExit, onSaveCreateNew, onDelete, saveAndContinue, title, labelSave, labelSaveAndContinue, labelSaveAndCreateNew, labelCancel, labelRemove, multiline, fieldKey, labelKey, optionsAC, setOptionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, options, isSemaphoric, label, decimalScale, fieldsLayout, customFieldFormLayouts, fieldsProps, hiddenFields, isolatedGetAutoComplete, relatedEditable, autoFocusField, elevation, CustomFormActions, extraValidators, sxRow, sxRowMultiple, sxSection, sxSectionTitle, children, }: FormProps & Omit<ExtraSxCommonFieldProps, 'sx' | 'sxField' | 'sxLabel' | 'sxValue' | 'sxValueList' | 'sxValueListItem' | 'sxValueListItemText'> & {
|
|
38
|
+
children?: React.ReactNode;
|
|
39
|
+
}): React.JSX.Element;
|
|
37
40
|
export {};
|
|
38
41
|
//# sourceMappingURL=Form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/forms/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAwB,eAAe,
|
|
1
|
+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B,WAAW,EACX,YAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,SAAS,EAET,iBAAiB,EACjB,eAAe,EAEf,KAAK,EACL,aAAa,EACb,SAAS,EACT,cAAc,EAEd,QAAQ,GACT,EAAE,SAAS,GACV,IAAI,CACF,uBAAuB,EACrB,IAAI,GACJ,SAAS,GACT,SAAS,GACT,SAAS,GACT,aAAa,GACb,iBAAiB,GACjB,qBAAqB,CACxB,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAgOnC"}
|
|
@@ -54,12 +54,15 @@ const APIWrapperContext_1 = require("../../context/APIWrapperContext");
|
|
|
54
54
|
const utils_1 = require("../../utils");
|
|
55
55
|
const FormBySchema_1 = __importDefault(require("./FormBySchema"));
|
|
56
56
|
const FormActions_1 = __importDefault(require("./FormActions"));
|
|
57
|
-
|
|
57
|
+
const DRFReactBySchemaContext_1 = require("../../context/DRFReactBySchemaContext");
|
|
58
|
+
function Form({ model, objId, basePath, defaults, objTitleField, onCancel, onSave, onSaveExit, onSaveCreateNew, onDelete, saveAndContinue, title, labelSave, labelSaveAndContinue, labelSaveAndCreateNew, labelCancel, labelRemove, multiline, fieldKey, labelKey, optionsAC, setOptionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, options, isSemaphoric, label, decimalScale, fieldsLayout, customFieldFormLayouts, fieldsProps, hiddenFields = [], isolatedGetAutoComplete, relatedEditable, autoFocusField, elevation, CustomFormActions, extraValidators, sxRow, sxRowMultiple, sxSection, sxSectionTitle, children, }) {
|
|
59
|
+
const { formTools, setFormTools } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
58
60
|
const { pageForm, loadSinglePageData, onSubmit } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
59
|
-
const
|
|
61
|
+
const methods = (0, react_hook_form_1.useForm)({
|
|
60
62
|
mode: 'onBlur',
|
|
61
63
|
resolver: (pageForm === null || pageForm === void 0 ? void 0 : pageForm.validationSchema) ? (0, yup_1.yupResolver)(pageForm.validationSchema) : undefined,
|
|
62
64
|
});
|
|
65
|
+
const { control, handleSubmit, reset, getValues, setValue, formState: { errors, isDirty }, register, watch, } = methods;
|
|
63
66
|
const conditionalVisible = (0, react_1.useMemo)(() => {
|
|
64
67
|
const fields = [];
|
|
65
68
|
if (!(pageForm === null || pageForm === void 0 ? void 0 : pageForm.schema)) {
|
|
@@ -119,13 +122,38 @@ function Form({ model, objId, basePath, defaults, objTitleField, onCancel, onSav
|
|
|
119
122
|
defaults,
|
|
120
123
|
basePath,
|
|
121
124
|
objTitleField,
|
|
125
|
+
extraValidators,
|
|
122
126
|
});
|
|
123
127
|
if (values && !axios_1.default.isAxiosError(values)) {
|
|
124
128
|
reset(values);
|
|
129
|
+
setFormTools({
|
|
130
|
+
errors,
|
|
131
|
+
reset,
|
|
132
|
+
getValues,
|
|
133
|
+
setValue,
|
|
134
|
+
isDirty,
|
|
135
|
+
});
|
|
125
136
|
}
|
|
126
137
|
});
|
|
127
138
|
loadData();
|
|
128
|
-
}, [model, objId, defaults, basePath, objTitleField]);
|
|
139
|
+
}, [model, objId, defaults, basePath, objTitleField, extraValidators]);
|
|
140
|
+
(0, react_1.useEffect)(() => {
|
|
141
|
+
if (formTools) {
|
|
142
|
+
if (formTools.errors !== errors ||
|
|
143
|
+
formTools.isDirty !== isDirty ||
|
|
144
|
+
formTools.reset !== reset ||
|
|
145
|
+
formTools.getValues !== getValues ||
|
|
146
|
+
formTools.setValue !== setValue) {
|
|
147
|
+
setFormTools({
|
|
148
|
+
errors,
|
|
149
|
+
reset,
|
|
150
|
+
getValues,
|
|
151
|
+
setValue,
|
|
152
|
+
isDirty,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}, [errors, isDirty, reset, getValues, setValue, formTools]);
|
|
129
157
|
(0, react_1.useEffect)(() => {
|
|
130
158
|
if (errors && Object.keys(errors).length > 0) {
|
|
131
159
|
console.log({ errors });
|
|
@@ -147,8 +175,10 @@ function Form({ model, objId, basePath, defaults, objTitleField, onCancel, onSav
|
|
|
147
175
|
if (!(pageForm === null || pageForm === void 0 ? void 0 : pageForm.schema) || (pageForm === null || pageForm === void 0 ? void 0 : pageForm.model) !== model) {
|
|
148
176
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
149
177
|
}
|
|
150
|
-
return (react_1.default.createElement(
|
|
151
|
-
react_1.default.createElement(
|
|
152
|
-
|
|
153
|
-
|
|
178
|
+
return (react_1.default.createElement(react_hook_form_1.FormProvider, Object.assign({}, methods),
|
|
179
|
+
react_1.default.createElement("form", { onSubmit: handleSubmit(localOnSubmit) },
|
|
180
|
+
react_1.default.createElement(FinalFormActions, { formDisabled: !isDirty, model: model, objId: objId, saveAndContinue: saveAndContinue, onCancel: onCancel, onDelete: onDelete, title: title, labelSave: labelSave, labelSaveAndContinue: labelSaveAndContinue, labelSaveAndCreateNew: labelSaveAndCreateNew, labelCancel: labelCancel, labelRemove: labelRemove }),
|
|
181
|
+
react_1.default.createElement(FormBySchema_1.default, { fieldsLayout: fieldsLayout, hiddenFields: hiddenFields, control: control, register: register, errors: errors, schema: pageForm.schema, getValues: getValues, setValue: setValue, multiline: multiline, fieldKey: fieldKey, labelKey: labelKey, optionsAC: optionsAC, setOptionsAC: setOptionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: onEditModel, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale, customFieldFormLayouts: customFieldFormLayouts, fieldsProps: fieldsProps, isolatedGetAutoComplete: isolatedGetAutoComplete, relatedEditable: relatedEditable, autoFocusField: autoFocusField, elevation: elevation, sxRow: sxRow, sxRowMultiple: sxRowMultiple, sxSection: sxSection, sxSectionTitle: sxSectionTitle, conditionalVisible: conditionalVisible, watchedValues: watchedValues }),
|
|
182
|
+
children,
|
|
183
|
+
react_1.default.createElement(FinalFormActions, { formDisabled: !isDirty, model: model, objId: objId, saveAndContinue: saveAndContinue, onCancel: onCancel, onDelete: onDelete, title: title, labelSave: labelSave, labelSaveAndContinue: labelSaveAndContinue, labelSaveAndCreateNew: labelSaveAndCreateNew, labelCancel: labelCancel, labelRemove: labelRemove, bottom: true }))));
|
|
154
184
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormWatcher.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormWatcher.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACrC;AAED,QAAA,MAAM,WAAW,GAAI,qBAAqB,gBAAgB,SAgBzD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const FormWatcher = ({ watch, onChange }) => {
|
|
7
|
+
const { control } = (0, react_hook_form_1.useFormContext)();
|
|
8
|
+
const values = (0, react_hook_form_1.useWatch)({
|
|
9
|
+
control,
|
|
10
|
+
name: watch,
|
|
11
|
+
});
|
|
12
|
+
const previousValues = (0, react_1.useRef)(null);
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (!(0, utils_1.deepEqual)(values, previousValues.current)) {
|
|
15
|
+
previousValues.current = values;
|
|
16
|
+
onChange(values);
|
|
17
|
+
}
|
|
18
|
+
}, [values, onChange]);
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
exports.default = FormWatcher;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIWrapper.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAiD7F,OAAO,EAEL,UAAU,
|
|
1
|
+
{"version":3,"file":"APIWrapper.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAC;AAiD7F,OAAO,EAEL,UAAU,EAOV,YAAY,EACb,MAAM,qBAAqB,CAAC;AAG7B,UAAU,eAAe;IACvB,aAAa,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAChD,SAAS,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACxE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,iBAAS,UAAU,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,qBAysBvF;;AAED,wBAAsC"}
|
|
@@ -65,22 +65,11 @@ const DRFReactBySchemaContext_1 = require("./DRFReactBySchemaContext");
|
|
|
65
65
|
const api_1 = require("../api");
|
|
66
66
|
const APIWrapperContext_1 = require("./APIWrapperContext");
|
|
67
67
|
const DialogFormBySchema_1 = __importDefault(require("../components/forms/DialogFormBySchema"));
|
|
68
|
-
const initialPageForm = {
|
|
69
|
-
id: '',
|
|
70
|
-
model: null,
|
|
71
|
-
modelVerboseName: null,
|
|
72
|
-
modelVerboseNamePlural: null,
|
|
73
|
-
schema: null,
|
|
74
|
-
columns: null,
|
|
75
|
-
initialValues: null,
|
|
76
|
-
validationSchema: null,
|
|
77
|
-
};
|
|
78
68
|
function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
79
|
-
const { serverEndPoint, theme, schemas } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
69
|
+
const { serverEndPoint, theme, schemas, formTools, pageForm, setPageForm, resetPageForm } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
80
70
|
const isMobile = (0, useMediaQuery_1.default)(theme.breakpoints.down('md'));
|
|
81
71
|
const [usuaria, setUsuaria] = (0, react_1.useState)(null);
|
|
82
72
|
const [optionsAC, setOptionsAC] = (0, react_1.useReducer)((utils_1.reducer), null);
|
|
83
|
-
const [pageForm, setPageForm] = (0, react_1.useReducer)((utils_1.reducer), initialPageForm);
|
|
84
73
|
const editModel = (0, react_1.useRef)({});
|
|
85
74
|
// BASIC OPERATIONS DEPENDING DIRECTLY ON SERVER_ENDPOINT:
|
|
86
75
|
const localGetRawData = (0, react_1.useCallback)((route) => {
|
|
@@ -91,10 +80,10 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
91
80
|
}, [serverEndPoint]);
|
|
92
81
|
const localGetGenericModelList = (0, react_1.useCallback)((params) => {
|
|
93
82
|
return (0, api_1.getGenericModelList)(Object.assign(Object.assign({}, params), { serverEndPoint, schemas }));
|
|
94
|
-
}, [serverEndPoint]);
|
|
83
|
+
}, [serverEndPoint, schemas]);
|
|
95
84
|
const localGetGenericModel = (0, react_1.useCallback)((params) => {
|
|
96
85
|
return (0, api_1.getGenericModel)(Object.assign(Object.assign({}, params), { serverEndPoint, schemas }));
|
|
97
|
-
}, [serverEndPoint]);
|
|
86
|
+
}, [serverEndPoint, schemas]);
|
|
98
87
|
const localGetAllModels = (0, react_1.useCallback)(() => __awaiter(this, void 0, void 0, function* () {
|
|
99
88
|
const response = yield (0, api_1.getAllModels)(serverEndPoint);
|
|
100
89
|
if (axios_1.default.isAxiosError(response)) {
|
|
@@ -210,7 +199,7 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
210
199
|
schemas,
|
|
211
200
|
});
|
|
212
201
|
if (axios_1.default.isAxiosError(object)) {
|
|
213
|
-
|
|
202
|
+
resetPageForm();
|
|
214
203
|
console.log('Houve um erro ao tentar carregar os dados!');
|
|
215
204
|
return object;
|
|
216
205
|
}
|
|
@@ -235,7 +224,14 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
235
224
|
data: object.data,
|
|
236
225
|
});
|
|
237
226
|
return values;
|
|
238
|
-
}), [
|
|
227
|
+
}), [
|
|
228
|
+
handleLoading,
|
|
229
|
+
populateInitialValues,
|
|
230
|
+
populateOptionsAC,
|
|
231
|
+
serverEndPoint,
|
|
232
|
+
resetPageForm,
|
|
233
|
+
schemas,
|
|
234
|
+
]);
|
|
239
235
|
const onSubmit = (0, react_1.useCallback)((model, id, data) => __awaiter(this, void 0, void 0, function* () {
|
|
240
236
|
if (!pageForm || !pageForm.schema) {
|
|
241
237
|
console.log('there must be a pageForm!');
|
|
@@ -385,7 +381,7 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
385
381
|
schema: result.schema,
|
|
386
382
|
};
|
|
387
383
|
});
|
|
388
|
-
}, [localGetAutoComplete, onEditModelSave, optionsAC, serverEndPoint, setDialog]);
|
|
384
|
+
}, [localGetAutoComplete, onEditModelSave, optionsAC, serverEndPoint, setDialog, schemas]);
|
|
389
385
|
const onDeleteModelSave = (0, react_1.useCallback)((model, id, onSuccess, event) => __awaiter(this, void 0, void 0, function* () {
|
|
390
386
|
setDialog({ open: false });
|
|
391
387
|
handleLoading(true);
|
|
@@ -468,7 +464,7 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
468
464
|
schema,
|
|
469
465
|
path: updateUrl,
|
|
470
466
|
});
|
|
471
|
-
if (
|
|
467
|
+
if (axios_1.default.isAxiosError(response)) {
|
|
472
468
|
onTriggerSnackBar({
|
|
473
469
|
msg: 'Não foi possível salvar os dados. Confira os erros.',
|
|
474
470
|
severity: 'error',
|
|
@@ -510,7 +506,7 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
510
506
|
}), [onTriggerSnackBar, serverEndPoint]);
|
|
511
507
|
(0, react_1.useEffect)(() => {
|
|
512
508
|
updateUsuaria();
|
|
513
|
-
|
|
509
|
+
resetPageForm();
|
|
514
510
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
515
511
|
}, []);
|
|
516
512
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
@@ -523,9 +519,9 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
523
519
|
optionsACState: [optionsAC, setOptionsAC],
|
|
524
520
|
optionsAC,
|
|
525
521
|
setOptionsAC,
|
|
526
|
-
pageFormState: [pageForm, setPageForm],
|
|
527
522
|
pageForm,
|
|
528
|
-
|
|
523
|
+
resetPageForm,
|
|
524
|
+
formTools,
|
|
529
525
|
onEditModel,
|
|
530
526
|
onEditModelSave,
|
|
531
527
|
onEditModelDataGridSave,
|
|
@@ -579,6 +575,8 @@ function APIWrapper({ handleLoading, setSnackBar, setDialog, children }) {
|
|
|
579
575
|
onTriggerSnackBar,
|
|
580
576
|
optionsAC,
|
|
581
577
|
pageForm,
|
|
578
|
+
resetPageForm,
|
|
579
|
+
formTools,
|
|
582
580
|
populateOptionsAC,
|
|
583
581
|
postData,
|
|
584
582
|
setDialog,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { ActionDispatch } from 'react';
|
|
2
|
-
import { FieldValues, SubmitHandler, UseFormGetValues, UseFormSetValue } from 'react-hook-form';
|
|
2
|
+
import { FieldErrors, FieldValues, SubmitHandler, UseFormGetValues, UseFormReset, UseFormSetValue } from 'react-hook-form';
|
|
3
3
|
import { AlertColor, AlertPropsColorOverrides } from '@mui/material/Alert';
|
|
4
4
|
import { OverridableStringUnion } from '@mui/types';
|
|
5
|
-
import { ObjectSchema } from 'yup';
|
|
6
5
|
import { AxiosError } from 'axios';
|
|
6
|
+
import { ObjectSchema } from 'yup';
|
|
7
7
|
import { ItemSchemaColumnsType, Id, Item, SchemaType, DataSchemaColumnsType, OnSuccessEvent, OptionsAC, GenericValue, FormFieldLayout, TargetApiParamsLocal, TargetApiPostParamsLocal, GetGenericModelListPropsLocal, GridEnrichedBySchemaColDef, ExtraValidators, GetGenericModelPropsLocal, UpdateDataBySchema, AutocompleteItem } from '../@types';
|
|
8
8
|
export interface LoadSinglePageDataProps {
|
|
9
9
|
model: string;
|
|
@@ -28,6 +28,13 @@ export interface PageFormType {
|
|
|
28
28
|
forceReload?: boolean;
|
|
29
29
|
objTitleField?: string;
|
|
30
30
|
}
|
|
31
|
+
export interface FormTools {
|
|
32
|
+
errors: FieldErrors<FieldValues>;
|
|
33
|
+
reset: UseFormReset<FieldValues>;
|
|
34
|
+
getValues: UseFormGetValues<FieldValues>;
|
|
35
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
36
|
+
isDirty: boolean;
|
|
37
|
+
}
|
|
31
38
|
export interface OnEditModelType {
|
|
32
39
|
fieldKey?: string;
|
|
33
40
|
index?: number;
|
|
@@ -83,9 +90,9 @@ export interface APIWrapperContextType {
|
|
|
83
90
|
optionsACState: (OptionsAC | ActionDispatch<[newState: Partial<OptionsAC> | null]> | null)[];
|
|
84
91
|
optionsAC: OptionsAC | null;
|
|
85
92
|
setOptionsAC: (x: Partial<OptionsAC>) => void;
|
|
86
|
-
pageFormState: (PageFormType | ActionDispatch<[newState: Partial<PageFormType> | null]> | null)[];
|
|
87
93
|
pageForm: PageFormType | null;
|
|
88
|
-
|
|
94
|
+
resetPageForm: () => void;
|
|
95
|
+
formTools?: FormTools;
|
|
89
96
|
onEditModel: (p: OnEditModelType) => void;
|
|
90
97
|
onEditModelDataGridSave: (p: onEditModelDataGridSaveType) => Promise<Item | AxiosError>;
|
|
91
98
|
onEditModelSave: (p: Item) => Promise<boolean | AxiosError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIWrapperContext.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapperContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC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Q,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,sCAwC5B,CAAC;AAEH,eAAO,MAAM,aAAa,6BAGzB,CAAC"}
|
|
@@ -23,9 +23,9 @@ exports.APIWrapperContext = react_1.default.createContext({
|
|
|
23
23
|
optionsACState: [null, () => undefined],
|
|
24
24
|
optionsAC: null,
|
|
25
25
|
setOptionsAC: () => undefined,
|
|
26
|
-
pageFormState: [null, () => undefined],
|
|
27
26
|
pageForm: null,
|
|
28
|
-
|
|
27
|
+
resetPageForm: () => undefined,
|
|
28
|
+
formTools: undefined,
|
|
29
29
|
onEditModel: () => undefined,
|
|
30
30
|
onEditModelDataGridSave: () => __awaiter(void 0, void 0, void 0, function* () { return ({}); }),
|
|
31
31
|
onEditModelSave: () => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Theme } from '@mui/material/styles';
|
|
3
3
|
import { SchemasType } from '../@types';
|
|
4
|
+
import { FormTools, PageFormType } from './APIWrapperContext';
|
|
4
5
|
export interface ServerEndPoint {
|
|
5
6
|
url: string;
|
|
6
7
|
apiTokenUrl: string;
|
|
@@ -12,13 +13,24 @@ export interface ServerEndPoint {
|
|
|
12
13
|
verifyToken?: string;
|
|
13
14
|
media?: string;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
interface DRFReactBySchemaComonProps {
|
|
16
17
|
serverEndPoint: ServerEndPoint | null;
|
|
17
18
|
theme: Theme;
|
|
18
19
|
isInBatches?: boolean;
|
|
19
20
|
firstBatchLength?: number;
|
|
20
21
|
schemas?: SchemasType;
|
|
21
22
|
}
|
|
23
|
+
export interface DRFReactBySchemaContextType extends DRFReactBySchemaComonProps {
|
|
24
|
+
pageForm: PageFormType | null;
|
|
25
|
+
setPageForm: (x: Partial<PageFormType>) => void;
|
|
26
|
+
resetPageForm: () => void;
|
|
27
|
+
formTools?: FormTools;
|
|
28
|
+
setFormTools: (x: FormTools) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface DRFReactBySchemaProviderProps extends DRFReactBySchemaComonProps {
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}
|
|
22
33
|
export declare const DRFReactBySchemaContext: React.Context<DRFReactBySchemaContextType>;
|
|
23
34
|
export declare const useDRFReactBySchema: () => DRFReactBySchemaContextType;
|
|
35
|
+
export {};
|
|
24
36
|
//# sourceMappingURL=DRFReactBySchemaContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DRFReactBySchemaContext.d.ts","sourceRoot":"","sources":["../../src/context/DRFReactBySchemaContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"DRFReactBySchemaContext.d.ts","sourceRoot":"","sources":["../../src/context/DRFReactBySchemaContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAI7C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,0BAA0B;IAClC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,2BAA4B,SAAQ,0BAA0B;IAC7E,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAChD,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,6BAA8B,SAAQ,0BAA0B;IAC/E,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,uBAAuB,4CAWlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,mCAG/B,CAAC"}
|
|
@@ -12,6 +12,11 @@ exports.DRFReactBySchemaContext = react_1.default.createContext({
|
|
|
12
12
|
isInBatches: true,
|
|
13
13
|
firstBatchLength: 100,
|
|
14
14
|
schemas: undefined,
|
|
15
|
+
pageForm: null,
|
|
16
|
+
setPageForm: () => undefined,
|
|
17
|
+
resetPageForm: () => undefined,
|
|
18
|
+
formTools: undefined,
|
|
19
|
+
setFormTools: () => undefined,
|
|
15
20
|
});
|
|
16
21
|
const useDRFReactBySchema = () => {
|
|
17
22
|
const context = react_1.default.useContext(exports.DRFReactBySchemaContext);
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface DRFReactBySchemaProviderProps extends DRFReactBySchemaContextType {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {*} props
|
|
10
|
-
* @returns {*}
|
|
11
|
-
*/
|
|
2
|
+
import { DRFReactBySchemaProviderProps } from './DRFReactBySchemaContext';
|
|
12
3
|
declare const DRFReactBySchemaProvider: ({ serverEndPoint, theme, isInBatches, firstBatchLength, schemas, children, }: DRFReactBySchemaProviderProps) => React.JSX.Element;
|
|
13
4
|
export default DRFReactBySchemaProvider;
|
|
14
5
|
//# sourceMappingURL=DRFReactBySchemaProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DRFReactBySchemaProvider.d.ts","sourceRoot":"","sources":["../../src/context/DRFReactBySchemaProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"DRFReactBySchemaProvider.d.ts","sourceRoot":"","sources":["../../src/context/DRFReactBySchemaProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAOpD,OAAO,EAGL,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AAenC,QAAA,MAAM,wBAAwB,GAAI,8EAO/B,6BAA6B,sBA+E/B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -43,13 +43,20 @@ const utils_1 = require("@mui/utils");
|
|
|
43
43
|
const theme_1 = __importDefault(require("../styles/theme"));
|
|
44
44
|
const Overlays_1 = __importDefault(require("./Overlays"));
|
|
45
45
|
const DRFReactBySchemaContext_1 = require("./DRFReactBySchemaContext");
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const utils_2 = require("../utils");
|
|
47
|
+
const initialPageForm = {
|
|
48
|
+
id: '',
|
|
49
|
+
model: null,
|
|
50
|
+
modelVerboseName: null,
|
|
51
|
+
modelVerboseNamePlural: null,
|
|
52
|
+
schema: null,
|
|
53
|
+
columns: null,
|
|
54
|
+
initialValues: null,
|
|
55
|
+
validationSchema: null,
|
|
56
|
+
};
|
|
52
57
|
const DRFReactBySchemaProvider = ({ serverEndPoint, theme, isInBatches, firstBatchLength, schemas, children, }) => {
|
|
58
|
+
const [pageForm, setPageForm] = react_1.default.useReducer((utils_2.reducer), initialPageForm);
|
|
59
|
+
const [formTools, setFormTools] = react_1.default.useState();
|
|
53
60
|
const newServerEndPoint = (0, react_1.useMemo)(() => {
|
|
54
61
|
if (!serverEndPoint) {
|
|
55
62
|
return null;
|
|
@@ -84,13 +91,30 @@ const DRFReactBySchemaProvider = ({ serverEndPoint, theme, isInBatches, firstBat
|
|
|
84
91
|
return theme_1.default;
|
|
85
92
|
return (0, utils_1.deepmerge)(theme_1.default, theme);
|
|
86
93
|
}, [theme]);
|
|
94
|
+
const resetPageForm = (0, react_1.useCallback)(() => {
|
|
95
|
+
setPageForm(initialPageForm);
|
|
96
|
+
}, []);
|
|
87
97
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
88
98
|
serverEndPoint: newServerEndPoint,
|
|
89
99
|
theme: mergedTheme,
|
|
90
100
|
isInBatches,
|
|
91
101
|
firstBatchLength,
|
|
92
102
|
schemas,
|
|
93
|
-
|
|
103
|
+
pageForm,
|
|
104
|
+
setPageForm,
|
|
105
|
+
resetPageForm,
|
|
106
|
+
formTools,
|
|
107
|
+
setFormTools,
|
|
108
|
+
}), [
|
|
109
|
+
firstBatchLength,
|
|
110
|
+
isInBatches,
|
|
111
|
+
mergedTheme,
|
|
112
|
+
newServerEndPoint,
|
|
113
|
+
schemas,
|
|
114
|
+
formTools,
|
|
115
|
+
pageForm,
|
|
116
|
+
resetPageForm,
|
|
117
|
+
]);
|
|
94
118
|
return (react_1.default.createElement(styles_1.ThemeProvider, { theme: mergedTheme },
|
|
95
119
|
react_1.default.createElement(CssBaseline_1.default, null),
|
|
96
120
|
react_1.default.createElement(DRFReactBySchemaContext_1.DRFReactBySchemaContext.Provider, { value: contextValue },
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { updateData, partialUpdateData, createData, deleteData, createOrUpdateData, updateDataBySchema, addExistingRelatedModel, getAutoComplete, loginByPayload, setAuthToken, isLoggedIn, getGenericModelList, getGenericModel, hasJWT, clearJWT } from './api';
|
|
2
2
|
import { emptyByType, getChoiceByValue, populateValues, buildGenericYupValidationSchema, errorProps, getTmpId, isTmpId, getPatternFormat, slugToCamelCase } from './utils';
|
|
3
3
|
import DRFReactBySchemaProvider from './context/DRFReactBySchemaProvider';
|
|
4
|
-
import { useDRFReactBySchema } from './context/DRFReactBySchemaContext';
|
|
5
4
|
import { useAPIWrapper } from './context/APIWrapperContext';
|
|
6
|
-
import
|
|
5
|
+
import Form from './components/forms/Form';
|
|
7
6
|
import DialogFormBySchema from './components/forms/DialogFormBySchema';
|
|
8
7
|
import DataGridBySchemaEditable from './components/DataGridBySchemaEditable';
|
|
9
8
|
import GenericModelList from './components/GenericModelList';
|
|
@@ -15,6 +14,8 @@ import { GridDateInput } from './components/DataGridBySchemaEditable/GridDateInp
|
|
|
15
14
|
import { GridDecimalInput } from './components/DataGridBySchemaEditable/GridDecimalInput';
|
|
16
15
|
import { GridPatternInput } from './components/DataGridBySchemaEditable/GridPatternInput';
|
|
17
16
|
import { BooleanInputCell } from './components/DataGridBySchemaEditable/BooleanInputCell';
|
|
17
|
+
import FormWatcher from './components/forms/FormWatcher';
|
|
18
|
+
import FormBySchema from './components/forms/FormBySchema';
|
|
18
19
|
import FieldBySchema from './components/forms/FieldBySchema';
|
|
19
20
|
import TextFieldBySchema from './components/forms/inputs/TextFieldBySchema';
|
|
20
21
|
import BooleanFieldBySchema from './components/forms/inputs/BooleanFieldBySchema';
|
|
@@ -25,7 +26,6 @@ import AutocompleteFieldBySchema from './components/forms/inputs/AutocompleteFie
|
|
|
25
26
|
import FloatFieldBySchema from './components/forms/inputs/FloatFieldBySchema';
|
|
26
27
|
import DetailBySchema from './components/details/DetailBySchema';
|
|
27
28
|
import DetailFieldBySchema from './components/details/DetailFieldBySchema';
|
|
28
|
-
|
|
29
|
-
export { DRFReactBySchemaProvider, useAPIWrapper, useDRFReactBySchema, Form, 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, };
|
|
29
|
+
export { DRFReactBySchemaProvider, useAPIWrapper, Form, DialogFormBySchema, DataGridBySchemaEditable, GenericModelList, GenericRelatedModelList, DataTotals, DialogActions, SelectEditInputCell, GridDateInput, GridDecimalInput, GridPatternInput, BooleanInputCell, FormWatcher, FormBySchema, 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, };
|
|
30
30
|
export * from './@types/index';
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAGjB,OAAO,wBAAwB,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5D,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAC3C,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAGvE,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAGv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,EACd,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,+BAA+B,EAC/B,UAAU,EACV,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,eAAe,GAChB,CAAC;AAEF,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
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.
|
|
20
|
+
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.FormBySchema = exports.FormWatcher = exports.BooleanInputCell = exports.GridPatternInput = exports.GridDecimalInput = exports.GridDateInput = exports.SelectEditInputCell = exports.DialogActions = exports.DataTotals = exports.GenericRelatedModelList = exports.GenericModelList = exports.DataGridBySchemaEditable = exports.DialogFormBySchema = exports.Form = exports.useAPIWrapper = exports.DRFReactBySchemaProvider = void 0;
|
|
21
21
|
// Methods:
|
|
22
22
|
const api_1 = require("./api");
|
|
23
23
|
Object.defineProperty(exports, "updateData", { enumerable: true, get: function () { return api_1.updateData; } });
|
|
@@ -45,17 +45,15 @@ Object.defineProperty(exports, "getTmpId", { enumerable: true, get: function ()
|
|
|
45
45
|
Object.defineProperty(exports, "isTmpId", { enumerable: true, get: function () { return utils_1.isTmpId; } });
|
|
46
46
|
Object.defineProperty(exports, "getPatternFormat", { enumerable: true, get: function () { return utils_1.getPatternFormat; } });
|
|
47
47
|
Object.defineProperty(exports, "slugToCamelCase", { enumerable: true, get: function () { return utils_1.slugToCamelCase; } });
|
|
48
|
-
//
|
|
48
|
+
// Overall Provider:
|
|
49
49
|
const DRFReactBySchemaProvider_1 = __importDefault(require("./context/DRFReactBySchemaProvider"));
|
|
50
50
|
exports.DRFReactBySchemaProvider = DRFReactBySchemaProvider_1.default;
|
|
51
|
-
|
|
52
|
-
Object.defineProperty(exports, "useDRFReactBySchema", { enumerable: true, get: function () { return DRFReactBySchemaContext_1.useDRFReactBySchema; } });
|
|
51
|
+
// APIWrapper Context:
|
|
53
52
|
const APIWrapperContext_1 = require("./context/APIWrapperContext");
|
|
54
53
|
Object.defineProperty(exports, "useAPIWrapper", { enumerable: true, get: function () { return APIWrapperContext_1.useAPIWrapper; } });
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
exports.FormBySchema = FormBySchema_1.default;
|
|
54
|
+
// Form:
|
|
55
|
+
const Form_1 = __importDefault(require("./components/forms/Form"));
|
|
56
|
+
exports.Form = Form_1.default;
|
|
59
57
|
const DialogFormBySchema_1 = __importDefault(require("./components/forms/DialogFormBySchema"));
|
|
60
58
|
exports.DialogFormBySchema = DialogFormBySchema_1.default;
|
|
61
59
|
// Components:
|
|
@@ -81,6 +79,10 @@ Object.defineProperty(exports, "GridPatternInput", { enumerable: true, get: func
|
|
|
81
79
|
const BooleanInputCell_1 = require("./components/DataGridBySchemaEditable/BooleanInputCell");
|
|
82
80
|
Object.defineProperty(exports, "BooleanInputCell", { enumerable: true, get: function () { return BooleanInputCell_1.BooleanInputCell; } });
|
|
83
81
|
// FormComponents
|
|
82
|
+
const FormWatcher_1 = __importDefault(require("./components/forms/FormWatcher"));
|
|
83
|
+
exports.FormWatcher = FormWatcher_1.default;
|
|
84
|
+
const FormBySchema_1 = __importDefault(require("./components/forms/FormBySchema"));
|
|
85
|
+
exports.FormBySchema = FormBySchema_1.default;
|
|
84
86
|
const FieldBySchema_1 = __importDefault(require("./components/forms/FieldBySchema"));
|
|
85
87
|
exports.FieldBySchema = FieldBySchema_1.default;
|
|
86
88
|
const TextFieldBySchema_1 = __importDefault(require("./components/forms/inputs/TextFieldBySchema"));
|
|
@@ -102,6 +104,4 @@ const DetailBySchema_1 = __importDefault(require("./components/details/DetailByS
|
|
|
102
104
|
exports.DetailBySchema = DetailBySchema_1.default;
|
|
103
105
|
const DetailFieldBySchema_1 = __importDefault(require("./components/details/DetailFieldBySchema"));
|
|
104
106
|
exports.DetailFieldBySchema = DetailFieldBySchema_1.default;
|
|
105
|
-
const Form_1 = __importDefault(require("./components/forms/Form"));
|
|
106
|
-
exports.Form = Form_1.default;
|
|
107
107
|
__exportStar(require("./@types/index"), exports);
|
package/dist/utils.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare function initViewColumns({ schema, columns, customColumnOperation
|
|
|
36
36
|
columns: GridEnrichedBySchemaColDef[];
|
|
37
37
|
customColumnOperations?: (p: GridEnrichedBySchemaColDef) => GridEnrichedBySchemaColDef | Promise<GridEnrichedBySchemaColDef>;
|
|
38
38
|
}): Promise<any>;
|
|
39
|
+
export declare function deepEqual(a: unknown, b: unknown, maxIterations?: number): boolean;
|
|
39
40
|
export declare function shouldMemoUpdate<T extends object>(prevProps: Readonly<T>, nextProps: Readonly<T>): boolean;
|
|
40
41
|
export declare const convertToFormData: (data: Item) => FormData;
|
|
41
42
|
export declare function formatFileSize(bytes: number): string;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EACL,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,KAAK,EACL,eAAe,EACf,YAAY,EAEZ,0BAA0B,EAC1B,IAAI,EACJ,UAAU,EACX,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,WAAW,EAAE,YA2BzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,8BASrF,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,kBAAkB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,SA8ClF,CAAC;AA6DF,wBAAgB,+BAA+B,CAAC,EAC9C,IAAI,EACJ,MAAM,EACN,IAAY,EACZ,UAAe,EACf,eAAe,EACf,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,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AAY,EAAE,eAAe,EAAE,YAwBxE;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,OAAO,WAerE;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,MAAM,GAAG,eAAe,EAC/B,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,EACzC,MAAM,CAAC,EAAE,YAAY,EAAE,WA+BxB"}
|
package/dist/utils.js
CHANGED
|
@@ -51,6 +51,7 @@ exports.reducer = reducer;
|
|
|
51
51
|
exports.buildDateFormatBySchema = buildDateFormatBySchema;
|
|
52
52
|
exports.mergeFilterItems = mergeFilterItems;
|
|
53
53
|
exports.initViewColumns = initViewColumns;
|
|
54
|
+
exports.deepEqual = deepEqual;
|
|
54
55
|
exports.shouldMemoUpdate = shouldMemoUpdate;
|
|
55
56
|
exports.formatFileSize = formatFileSize;
|
|
56
57
|
exports.getFieldsFromFieldsLayout = getFieldsFromFieldsLayout;
|
package/package.json
CHANGED