drf-react-by-schema 0.28.5 → 0.28.7
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/README.md +11 -0
- package/package.json +8 -21
- package/dist/@types/index.d.ts +0 -408
- package/dist/@types/index.d.ts.map +0 -1
- package/dist/@types/index.js +0 -9
- package/dist/@types/string-mask.d.ts +0 -10
- package/dist/@types/string-mask.d.ts.map +0 -1
- package/dist/@types/string-mask.js +0 -1
- package/dist/api.d.ts +0 -78
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -1058
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts +0 -8
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/BooleanInputCell.js +0 -86
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts +0 -12
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/ConditionalEditWrapper.js +0 -71
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +0 -9
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +0 -21
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +0 -26
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +0 -146
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts +0 -72
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +0 -416
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts +0 -18
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +0 -105
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts +0 -11
- package/dist/components/DataGridBySchemaEditable/FileInputCell.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/FileInputCell.js +0 -155
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +0 -12
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +0 -36
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts +0 -10
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GeoEditCell.js +0 -85
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts +0 -11
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GeoThumbCell.js +0 -87
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts +0 -18
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridActionsCellItemLink.js +0 -24
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts +0 -8
- package/dist/components/DataGridBySchemaEditable/GridDateInput.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridDateInput.js +0 -166
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts +0 -6
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridDateTimeInput.js +0 -154
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +0 -10
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +0 -78
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts +0 -8
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridGenericInput.js +0 -30
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +0 -7
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +0 -74
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +0 -21
- package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/InputInterval.js +0 -131
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts +0 -9
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/MobileSearchBar.js +0 -70
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts +0 -7
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/RowEditingWatcher.js +0 -41
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +0 -24
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +0 -259
- package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts +0 -5
- package/dist/components/DataGridBySchemaEditable/geoConstants.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/geoConstants.js +0 -6
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts +0 -33
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/hooks/useDataGridActions.js +0 -161
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts +0 -14
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/hooks/useOptionsAC.js +0 -69
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts +0 -9
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/hooks/usePreparedColumns.js +0 -73
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts +0 -30
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/hooks/useProcessRowUpdate.js +0 -199
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts +0 -33
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/utils/columnFactory.js +0 -270
- package/dist/components/DataGridBySchemaEditable/utils.d.ts +0 -40
- package/dist/components/DataGridBySchemaEditable/utils.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable/utils.js +0 -181
- package/dist/components/DataGridBySchemaEditable.d.ts +0 -63
- package/dist/components/DataGridBySchemaEditable.d.ts.map +0 -1
- package/dist/components/DataGridBySchemaEditable.js +0 -172
- package/dist/components/DataTotals.d.ts +0 -12
- package/dist/components/DataTotals.d.ts.map +0 -1
- package/dist/components/DataTotals.js +0 -32
- package/dist/components/DataTotalsServer.d.ts +0 -10
- package/dist/components/DataTotalsServer.d.ts.map +0 -1
- package/dist/components/DataTotalsServer.js +0 -18
- package/dist/components/DialogActions.d.ts +0 -11
- package/dist/components/DialogActions.d.ts.map +0 -1
- package/dist/components/DialogActions.js +0 -20
- package/dist/components/FileTypeIcon.d.ts +0 -18
- package/dist/components/FileTypeIcon.d.ts.map +0 -1
- package/dist/components/FileTypeIcon.js +0 -48
- package/dist/components/GenericModelList.d.ts +0 -52
- package/dist/components/GenericModelList.d.ts.map +0 -1
- package/dist/components/GenericModelList.js +0 -194
- package/dist/components/GenericRelatedModelList.d.ts +0 -54
- package/dist/components/GenericRelatedModelList.d.ts.map +0 -1
- package/dist/components/GenericRelatedModelList.js +0 -181
- package/dist/components/GenericRelatedModelListTable.d.ts +0 -55
- package/dist/components/GenericRelatedModelListTable.d.ts.map +0 -1
- package/dist/components/GenericRelatedModelListTable.js +0 -31
- package/dist/components/Image.d.ts +0 -10
- package/dist/components/Image.d.ts.map +0 -1
- package/dist/components/Image.js +0 -111
- package/dist/components/details/DetailBySchema.d.ts +0 -4
- package/dist/components/details/DetailBySchema.d.ts.map +0 -1
- package/dist/components/details/DetailBySchema.js +0 -175
- package/dist/components/details/DetailFieldBySchema.d.ts +0 -4
- package/dist/components/details/DetailFieldBySchema.d.ts.map +0 -1
- package/dist/components/details/DetailFieldBySchema.js +0 -88
- package/dist/components/forms/DialogFormBySchema.d.ts +0 -22
- package/dist/components/forms/DialogFormBySchema.d.ts.map +0 -1
- package/dist/components/forms/DialogFormBySchema.js +0 -97
- package/dist/components/forms/FieldBySchema.d.ts +0 -4
- package/dist/components/forms/FieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/FieldBySchema.js +0 -80
- package/dist/components/forms/Form.d.ts +0 -61
- package/dist/components/forms/Form.d.ts.map +0 -1
- package/dist/components/forms/Form.js +0 -264
- package/dist/components/forms/FormActions.d.ts +0 -20
- package/dist/components/forms/FormActions.d.ts.map +0 -1
- package/dist/components/forms/FormActions.js +0 -55
- package/dist/components/forms/FormBySchema.d.ts +0 -21
- package/dist/components/forms/FormBySchema.d.ts.map +0 -1
- package/dist/components/forms/FormBySchema.js +0 -280
- package/dist/components/forms/FormWatcher.d.ts +0 -10
- package/dist/components/forms/FormWatcher.d.ts.map +0 -1
- package/dist/components/forms/FormWatcher.js +0 -25
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +0 -13
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.js +0 -133
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +0 -4
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/BooleanFieldBySchema.js +0 -39
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +0 -5
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +0 -54
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +0 -5
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.js +0 -47
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts +0 -14
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.js +0 -272
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts +0 -4
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/FileFieldBySchema.js +0 -144
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +0 -4
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/FloatFieldBySchema.js +0 -64
- package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts +0 -8
- package/dist/components/forms/inputs/GeometryFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/GeometryFieldBySchema.js +0 -57
- package/dist/components/forms/inputs/MapGeometryPicker.d.ts +0 -19
- package/dist/components/forms/inputs/MapGeometryPicker.d.ts.map +0 -1
- package/dist/components/forms/inputs/MapGeometryPicker.js +0 -322
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts +0 -4
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/PatternFieldBySchema.js +0 -56
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts +0 -4
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts.map +0 -1
- package/dist/components/forms/inputs/TextFieldBySchema.js +0 -56
- package/dist/components/forms/inputs/leafletMarker.d.ts +0 -12
- package/dist/components/forms/inputs/leafletMarker.d.ts.map +0 -1
- package/dist/components/forms/inputs/leafletMarker.js +0 -52
- package/dist/context/APIWrapper.d.ts +0 -18
- package/dist/context/APIWrapper.d.ts.map +0 -1
- package/dist/context/APIWrapper.js +0 -584
- package/dist/context/APIWrapperContext.d.ts +0 -129
- package/dist/context/APIWrapperContext.d.ts.map +0 -1
- package/dist/context/APIWrapperContext.js +0 -60
- package/dist/context/DRFReactBySchemaContext.d.ts +0 -28
- package/dist/context/DRFReactBySchemaContext.d.ts.map +0 -1
- package/dist/context/DRFReactBySchemaContext.js +0 -20
- package/dist/context/DRFReactBySchemaProvider.d.ts +0 -5
- package/dist/context/DRFReactBySchemaProvider.d.ts.map +0 -1
- package/dist/context/DRFReactBySchemaProvider.js +0 -93
- package/dist/context/Overlays.d.ts +0 -5
- package/dist/context/Overlays.d.ts.map +0 -1
- package/dist/context/Overlays.js +0 -114
- package/dist/context/PrivateContext.d.ts +0 -10
- package/dist/context/PrivateContext.d.ts.map +0 -1
- package/dist/context/PrivateContext.js +0 -16
- package/dist/hooks/useDeepMemo.d.ts +0 -2
- package/dist/hooks/useDeepMemo.d.ts.map +0 -1
- package/dist/hooks/useDeepMemo.js +0 -13
- package/dist/hooks/useWhyDidYouUpdate.d.ts +0 -4
- package/dist/hooks/useWhyDidYouUpdate.d.ts.map +0 -1
- package/dist/hooks/useWhyDidYouUpdate.js +0 -26
- package/dist/index.d.ts +0 -35
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -104
- package/dist/styles/grid.d.ts +0 -3
- package/dist/styles/grid.d.ts.map +0 -1
- package/dist/styles/grid.js +0 -38
- package/dist/styles/index.d.ts +0 -3
- package/dist/styles/index.d.ts.map +0 -1
- package/dist/styles/index.js +0 -38
- package/dist/styles/layout.d.ts +0 -23
- package/dist/styles/layout.d.ts.map +0 -1
- package/dist/styles/layout.js +0 -71
- package/dist/styles/texts.d.ts +0 -48
- package/dist/styles/texts.d.ts.map +0 -1
- package/dist/styles/texts.js +0 -55
- package/dist/styles/theme.d.ts +0 -29
- package/dist/styles/theme.d.ts.map +0 -1
- package/dist/styles/theme.js +0 -226
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -17
- package/dist/utils/utils.d.ts +0 -107
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js +0 -957
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Autocomplete from '@mui/material/Autocomplete';
|
|
3
|
-
declare const EditableAutocompleteFieldBySchema: React.ForwardRefExoticComponent<Omit<import("../../../@types").CommonFieldProps<void>, "value" | "onEditModel"> & {
|
|
4
|
-
onEditModel?: <U extends import("../../../@types").TField = void>(x: import("../../../@types").OnEditModelType<U>) => void;
|
|
5
|
-
name: string;
|
|
6
|
-
schema: {
|
|
7
|
-
[x: string]: import("../../../@types").Field;
|
|
8
|
-
};
|
|
9
|
-
control: import("react-hook-form").Control<Record<string, any>, any, Record<string, any>>;
|
|
10
|
-
errors: import("react-hook-form").FieldErrors<Record<string, any>>;
|
|
11
|
-
autoFocus?: boolean;
|
|
12
|
-
} & React.RefAttributes<typeof Autocomplete>>;
|
|
13
|
-
export default EditableAutocompleteFieldBySchema;
|
|
14
|
-
//# sourceMappingURL=EditableAutocompleteFieldBySchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EditableAutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/EditableAutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAO,YAAqC,MAAM,4BAA4B,CAAC;AAY/E,QAAA,MAAM,iCAAiC;;;;;;;;;6CA6WtC,CAAC;AAGF,eAAe,iCAAiC,CAAC"}
|
|
@@ -1,272 +0,0 @@
|
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
-
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
39
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
43
|
-
}
|
|
44
|
-
return t;
|
|
45
|
-
};
|
|
46
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
const react_1 = __importStar(require("react"));
|
|
51
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
52
|
-
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
53
|
-
const Autocomplete_1 = __importStar(require("@mui/material/Autocomplete"));
|
|
54
|
-
const Edit_1 = __importDefault(require("@mui/icons-material/Edit"));
|
|
55
|
-
const IconButton_1 = __importDefault(require("@mui/material/IconButton"));
|
|
56
|
-
const Chip_1 = __importDefault(require("@mui/material/Chip"));
|
|
57
|
-
const utils_1 = require("../../../utils");
|
|
58
|
-
const DialogActions_1 = __importDefault(require("../../DialogActions"));
|
|
59
|
-
const APIWrapperContext_1 = require("../../../context/APIWrapperContext");
|
|
60
|
-
const filter = (0, Autocomplete_1.createFilterOptions)();
|
|
61
|
-
const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) => {
|
|
62
|
-
var _b;
|
|
63
|
-
var { control, schema, errors, setValue, getValues, fieldKey, labelKey = 'nome', index, name = 'name', optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, sx = { mr: 2 }, onValueChange, multiple = false, disabled, fieldsLayout, autoFocus } = _a, other = __rest(_a, ["control", "schema", "errors", "setValue", "getValues", "fieldKey", "labelKey", "index", "name", "optionsAC", "optionsModel", "getOptionLabel", "renderOption", "onEditModel", "sx", "onValueChange", "multiple", "disabled", "fieldsLayout", "autoFocus"]);
|
|
64
|
-
const { setDialog } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
65
|
-
const [options, setOptions] = (0, react_1.useState)(null);
|
|
66
|
-
const model = name;
|
|
67
|
-
(0, react_1.useEffect)(() => {
|
|
68
|
-
if (optionsAC && optionsModel && optionsAC[optionsModel]) {
|
|
69
|
-
setOptions(optionsAC[optionsModel]);
|
|
70
|
-
}
|
|
71
|
-
}, [optionsAC, optionsModel]);
|
|
72
|
-
(0, react_1.useEffect)(() => {
|
|
73
|
-
if (!getValues || !setValue || !options) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const valuesInitial = getValues(model);
|
|
77
|
-
if (!valuesInitial) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (multiple) {
|
|
81
|
-
const harmonizedValues = [];
|
|
82
|
-
for (const valueInitial of valuesInitial) {
|
|
83
|
-
const harmonizedValue = options.find((option) => option.id === valueInitial.id);
|
|
84
|
-
if (harmonizedValue) {
|
|
85
|
-
harmonizedValues.push(harmonizedValue);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
setValue(model, harmonizedValues);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const harmonizedValues = options.find((option) => option.id === valuesInitial.id);
|
|
92
|
-
setValue(model, harmonizedValues);
|
|
93
|
-
}, [options, setValue, getValues, model, multiple]);
|
|
94
|
-
if (!(name in schema)) {
|
|
95
|
-
console.error(`EditableAutocompleteFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const fieldSchema = schema[name];
|
|
99
|
-
const label = fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.label;
|
|
100
|
-
if (!optionsModel) {
|
|
101
|
-
optionsModel = model;
|
|
102
|
-
}
|
|
103
|
-
if (fieldKey && index && index >= 0) {
|
|
104
|
-
name = `${fieldKey}.${index}.${name}`;
|
|
105
|
-
}
|
|
106
|
-
const { error, helperText } = fieldKey && index && index >= 0
|
|
107
|
-
? (0, utils_1.errorProps)({
|
|
108
|
-
fieldKey,
|
|
109
|
-
index,
|
|
110
|
-
fieldKeyProp: name,
|
|
111
|
-
errors,
|
|
112
|
-
})
|
|
113
|
-
: {
|
|
114
|
-
error: errors && Boolean(errors[name]),
|
|
115
|
-
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.help_text) || '',
|
|
116
|
-
};
|
|
117
|
-
if (!options) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
if (!disabled &&
|
|
121
|
-
!(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.disabled) &&
|
|
122
|
-
fieldSchema.related_editable !== false &&
|
|
123
|
-
onEditModel &&
|
|
124
|
-
optionsModel) {
|
|
125
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { control: control, name: name, render: ({ field }) => (react_1.default.createElement(Autocomplete_1.default, Object.assign({ key: name }, field, { id: name, options: options, disabled: (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.disabled) === true, autoHighlight: true, isOptionEqualToValue: (option, value) => option.id === value.id, fullWidth: true, multiple: multiple, sx: sx, onChange: (e, value) => {
|
|
126
|
-
let valueAr = value || '';
|
|
127
|
-
if (!multiple) {
|
|
128
|
-
valueAr = [value];
|
|
129
|
-
}
|
|
130
|
-
const newValueAr = [];
|
|
131
|
-
if (valueAr) {
|
|
132
|
-
for (let newValue of valueAr) {
|
|
133
|
-
if (typeof newValue === 'string') {
|
|
134
|
-
const tmpId = (0, utils_1.getTmpId)();
|
|
135
|
-
newValue = {
|
|
136
|
-
id: tmpId,
|
|
137
|
-
label: newValue,
|
|
138
|
-
[labelKey]: newValue,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
if (newValue && newValue.inputValue) {
|
|
142
|
-
const tmpId = (0, utils_1.getTmpId)();
|
|
143
|
-
if (onEditModel) {
|
|
144
|
-
// Open modal to save new item:
|
|
145
|
-
onEditModel({
|
|
146
|
-
fieldKey,
|
|
147
|
-
index,
|
|
148
|
-
model: optionsModel,
|
|
149
|
-
id: tmpId,
|
|
150
|
-
labelKey,
|
|
151
|
-
setValue,
|
|
152
|
-
getValues,
|
|
153
|
-
fieldsLayout,
|
|
154
|
-
initialValuesPartial: {
|
|
155
|
-
[labelKey]: newValue.inputValue,
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// Define new Item as an "optimistic response"
|
|
160
|
-
newValue = {
|
|
161
|
-
id: tmpId,
|
|
162
|
-
label: newValue.inputValue,
|
|
163
|
-
[labelKey]: newValue.inputValue,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
newValueAr.push(newValue);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
field.onChange(multiple ? newValueAr : newValueAr[0]);
|
|
170
|
-
if (onValueChange) {
|
|
171
|
-
onValueChange(e);
|
|
172
|
-
}
|
|
173
|
-
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: (0, utils_1.isFieldRequired)(fieldSchema) && !multiple, margin: "normal", error: error, autoFocus: autoFocus, helperText: helperText, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
174
|
-
!multiple && field.value && (react_1.default.createElement(IconButton_1.default, { size: "small", "aria-label": "Editar", onClick: () => {
|
|
175
|
-
if ((0, utils_1.isTmpId)(field.value.id)) {
|
|
176
|
-
setDialog({
|
|
177
|
-
open: true,
|
|
178
|
-
loading: false,
|
|
179
|
-
title: 'Item sendo criado',
|
|
180
|
-
Body: 'Este item está sendo criado agora por você. Para editar suas propriedades, salve antes, e depois você poderá editar!',
|
|
181
|
-
Actions: (react_1.default.createElement(DialogActions_1.default, { setDialog: setDialog, btnCancel: "Entendi" })),
|
|
182
|
-
});
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
if (optionsModel) {
|
|
186
|
-
onEditModel({
|
|
187
|
-
fieldKey,
|
|
188
|
-
index,
|
|
189
|
-
model: optionsModel,
|
|
190
|
-
id: field.value.id,
|
|
191
|
-
labelKey,
|
|
192
|
-
setValue,
|
|
193
|
-
getValues,
|
|
194
|
-
fieldsLayout,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
} },
|
|
198
|
-
react_1.default.createElement(Edit_1.default, null))),
|
|
199
|
-
params.InputProps.endAdornment)) }) }, other))), freeSolo: true, filterOptions: (filteredOptions, params) => {
|
|
200
|
-
let filtered = filter(filteredOptions, params);
|
|
201
|
-
const { inputValue } = params;
|
|
202
|
-
const inputValueSlug = (0, utils_1.slugify)(inputValue);
|
|
203
|
-
const inputValueLength = inputValueSlug.length;
|
|
204
|
-
// Suggest the creation of a new value
|
|
205
|
-
const isExisting = filteredOptions.find((option) => inputValueSlug === (0, utils_1.slugify)(option.label));
|
|
206
|
-
if (inputValue !== '' && !isExisting) {
|
|
207
|
-
filtered.push({
|
|
208
|
-
inputValue,
|
|
209
|
-
label: `Criar "${inputValue}"`,
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
// Show first the exact match:
|
|
213
|
-
if (isExisting) {
|
|
214
|
-
filtered = [
|
|
215
|
-
isExisting,
|
|
216
|
-
...filtered.filter((option) => isExisting.id !== option.id),
|
|
217
|
-
];
|
|
218
|
-
}
|
|
219
|
-
// Show first the options that start with inputValue:
|
|
220
|
-
const startsWith = filtered.filter((option) => inputValueSlug === (0, utils_1.slugify)(option.label).substring(0, inputValueLength));
|
|
221
|
-
if (startsWith.length > 0) {
|
|
222
|
-
const startsWithIds = startsWith.map((option) => option.id);
|
|
223
|
-
filtered = [
|
|
224
|
-
...startsWith,
|
|
225
|
-
...filtered.filter((option) => !startsWithIds.includes(option.id)),
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
return filtered;
|
|
229
|
-
}, handleHomeEndKeys: true, getOptionKey: ({ id }) => id, getOptionLabel: getOptionLabel
|
|
230
|
-
? getOptionLabel
|
|
231
|
-
: (option) => {
|
|
232
|
-
// Value selected with enter, right from the input
|
|
233
|
-
if (typeof option === 'string') {
|
|
234
|
-
return option;
|
|
235
|
-
}
|
|
236
|
-
// Criar "xxx" option created dynamically
|
|
237
|
-
if (option.inputValue) {
|
|
238
|
-
return option.inputValue;
|
|
239
|
-
}
|
|
240
|
-
// Regular option
|
|
241
|
-
return option.label;
|
|
242
|
-
}, renderOption: renderOption ? renderOption : (props, option) => react_1.default.createElement("li", Object.assign({}, props), option.label), renderTags: multiple
|
|
243
|
-
? (tagValue, getTagProps) => {
|
|
244
|
-
return tagValue.map((option, index) => (
|
|
245
|
-
// eslint-disable-next-line react/jsx-key
|
|
246
|
-
react_1.default.createElement(Chip_1.default, Object.assign({}, getTagProps({ index }), { label: option.label, icon: (0, utils_1.isTmpId)(option.id) ? (react_1.default.createElement(react_1.default.Fragment, null)) : (react_1.default.createElement(IconButton_1.default, { size: "small", "aria-label": "Editar", onClick: () => {
|
|
247
|
-
if (optionsModel) {
|
|
248
|
-
onEditModel({
|
|
249
|
-
fieldKey,
|
|
250
|
-
index,
|
|
251
|
-
model: optionsModel,
|
|
252
|
-
id: option.id,
|
|
253
|
-
labelKey,
|
|
254
|
-
setValue,
|
|
255
|
-
getValues,
|
|
256
|
-
fieldsLayout,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
} },
|
|
260
|
-
react_1.default.createElement(Edit_1.default, null))) }))));
|
|
261
|
-
}
|
|
262
|
-
: undefined }))) }));
|
|
263
|
-
}
|
|
264
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { control: control, name: name, render: ({ field }) => (react_1.default.createElement(Autocomplete_1.default, Object.assign({ key: name }, field, { id: name, options: options, disabled: (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.disabled) === true || disabled === true, autoHighlight: true, isOptionEqualToValue: (option, value) => option.id === value.id, fullWidth: true, multiple: multiple, sx: sx, onChange: (e, value) => {
|
|
265
|
-
field.onChange(value);
|
|
266
|
-
if (onValueChange) {
|
|
267
|
-
onValueChange(e);
|
|
268
|
-
}
|
|
269
|
-
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: (0, utils_1.isFieldRequired)(fieldSchema) && !multiple, margin: "normal", error: error, autoFocus: autoFocus, helperText: helperText }, other))), getOptionKey: ({ id }) => id, getOptionLabel: getOptionLabel, renderOption: renderOption }))) }));
|
|
270
|
-
});
|
|
271
|
-
EditableAutocompleteFieldBySchema.displayName = 'EditableAutocompleteFieldBySchema';
|
|
272
|
-
exports.default = EditableAutocompleteFieldBySchema;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function FileFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, onValueChange, autoFocus, disabled, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
|
-
//# sourceMappingURL=FileFieldBySchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/FileFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAc1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAgBrD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,kBAAkB,iCAgJpB"}
|
|
@@ -1,144 +0,0 @@
|
|
|
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.default = FileFieldBySchema;
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
20
|
-
const styles_1 = require("@mui/material/styles");
|
|
21
|
-
const Button_1 = __importDefault(require("@mui/material/Button"));
|
|
22
|
-
const FormControlLabel_1 = __importDefault(require("@mui/material/FormControlLabel"));
|
|
23
|
-
const FormControl_1 = __importDefault(require("@mui/material/FormControl"));
|
|
24
|
-
const FormLabel_1 = __importDefault(require("@mui/material/FormLabel"));
|
|
25
|
-
const FormHelperText_1 = __importDefault(require("@mui/material/FormHelperText"));
|
|
26
|
-
const Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
27
|
-
const Box_1 = __importDefault(require("@mui/material/Box"));
|
|
28
|
-
const CloudUpload_1 = __importDefault(require("@mui/icons-material/CloudUpload"));
|
|
29
|
-
const utils_1 = require("../../../utils");
|
|
30
|
-
const DRFReactBySchemaContext_1 = require("../../../context/DRFReactBySchemaContext");
|
|
31
|
-
const VisuallyHiddenInput = (0, styles_1.styled)('input')({
|
|
32
|
-
clip: 'rect(0 0 0 0)',
|
|
33
|
-
clipPath: 'inset(50%)',
|
|
34
|
-
height: 1,
|
|
35
|
-
overflow: 'hidden',
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
bottom: 0,
|
|
38
|
-
left: 0,
|
|
39
|
-
whiteSpace: 'nowrap',
|
|
40
|
-
width: 1,
|
|
41
|
-
});
|
|
42
|
-
function FileFieldBySchema(_a) {
|
|
43
|
-
var _b;
|
|
44
|
-
var { name, schema, control, errors, fieldKey, index, sx = { mr: 2 }, onValueChange, autoFocus, disabled } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "sx", "onValueChange", "autoFocus", "disabled"]);
|
|
45
|
-
const { serverEndPoint } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
46
|
-
if (!(name in schema)) {
|
|
47
|
-
console.error(`FileFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const fieldSchema = schema[name];
|
|
51
|
-
if (fieldKey && index && index >= 0) {
|
|
52
|
-
name = `${fieldKey}.${index}.${name}`;
|
|
53
|
-
}
|
|
54
|
-
const { error, helperText } = fieldKey && index && index >= 0
|
|
55
|
-
? (0, utils_1.errorProps)({
|
|
56
|
-
fieldKey,
|
|
57
|
-
index,
|
|
58
|
-
fieldKeyProp: name,
|
|
59
|
-
errors,
|
|
60
|
-
})
|
|
61
|
-
: {
|
|
62
|
-
error: errors && Boolean(errors[name]),
|
|
63
|
-
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : fieldSchema.help_text || '',
|
|
64
|
-
};
|
|
65
|
-
const fileTypeStr = fieldSchema.type === 'image upload' ? 'imagem' : 'documento';
|
|
66
|
-
const accept = fieldSchema.allowed_mime_types
|
|
67
|
-
? fieldSchema.allowed_mime_types.join(', ')
|
|
68
|
-
: fieldSchema.type === 'image upload'
|
|
69
|
-
? '/image*'
|
|
70
|
-
: '*';
|
|
71
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
72
|
-
var _a, _b, _c, _d;
|
|
73
|
-
return (react_1.default.createElement(Box_1.default, { sx: Object.assign({ width: '100%' }, sx) },
|
|
74
|
-
react_1.default.createElement(FormControl_1.default, { component: "fieldset", sx: { width: '100%' } },
|
|
75
|
-
react_1.default.createElement(FormLabel_1.default, { component: "legend" }, fieldSchema.label),
|
|
76
|
-
react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Box_1.default, { sx: {
|
|
77
|
-
display: 'flex',
|
|
78
|
-
flexDirection: 'column',
|
|
79
|
-
alignItems: 'center',
|
|
80
|
-
width: '100%',
|
|
81
|
-
} },
|
|
82
|
-
(((_a = field.value) === null || _a === void 0 ? void 0 : _a.url) || ((_b = field.value) === null || _b === void 0 ? void 0 : _b.src)) &&
|
|
83
|
-
fieldSchema.type === 'image upload' && (react_1.default.createElement("img", { src: field.value.url
|
|
84
|
-
? `${serverEndPoint === null || serverEndPoint === void 0 ? void 0 : serverEndPoint.url}${field.value.url}`
|
|
85
|
-
: field.value.src, alt: field.value.name, title: field.value.name, style: {
|
|
86
|
-
width: '100%',
|
|
87
|
-
maxHeight: '200px',
|
|
88
|
-
objectFit: 'cover',
|
|
89
|
-
maxWidth: '450px',
|
|
90
|
-
} })),
|
|
91
|
-
((_c = field.value) === null || _c === void 0 ? void 0 : _c.name) && (react_1.default.createElement(Typography_1.default, { variant: "body2", sx: { mb: 1 } },
|
|
92
|
-
field.value.name.split('/').pop(),
|
|
93
|
-
" (",
|
|
94
|
-
(0, utils_1.formatFileSize)(field.value.size),
|
|
95
|
-
")")),
|
|
96
|
-
react_1.default.createElement(Button_1.default, { component: "label", variant: "outlined", startIcon: react_1.default.createElement(CloudUpload_1.default, null), disabled: fieldSchema.disabled === true || disabled === true, color: error ? 'error' : 'primary' },
|
|
97
|
-
field.value ? `Trocar ${fileTypeStr}` : `Enviar ${fileTypeStr}`,
|
|
98
|
-
react_1.default.createElement(VisuallyHiddenInput, Object.assign({ type: "file", onChange: (e) => {
|
|
99
|
-
var _a;
|
|
100
|
-
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
101
|
-
if (file) {
|
|
102
|
-
if (file.type.startsWith('image/')) {
|
|
103
|
-
const reader = new FileReader();
|
|
104
|
-
reader.onload = (event) => {
|
|
105
|
-
const src = event.target ? event.target.result : undefined;
|
|
106
|
-
const newValue = {
|
|
107
|
-
name: file.name,
|
|
108
|
-
size: file.size,
|
|
109
|
-
type: file.type,
|
|
110
|
-
src,
|
|
111
|
-
file,
|
|
112
|
-
};
|
|
113
|
-
field.onChange(newValue);
|
|
114
|
-
if (onValueChange) {
|
|
115
|
-
onValueChange(newValue);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
reader.readAsDataURL(file);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const newValue = {
|
|
122
|
-
name: file.name,
|
|
123
|
-
size: file.size,
|
|
124
|
-
type: file.type,
|
|
125
|
-
file,
|
|
126
|
-
};
|
|
127
|
-
field.onChange(newValue);
|
|
128
|
-
if (onValueChange) {
|
|
129
|
-
onValueChange(newValue);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, accept: accept, autoFocus: autoFocus }, other)))), label: '',
|
|
133
|
-
// labelPlacement="top"
|
|
134
|
-
required: (0, utils_1.isFieldRequired)(fieldSchema), sx: {
|
|
135
|
-
width: '100%',
|
|
136
|
-
alignItems: 'flex-start',
|
|
137
|
-
marginLeft: 0,
|
|
138
|
-
} }),
|
|
139
|
-
react_1.default.createElement(FormHelperText_1.default, { error: error, sx: {
|
|
140
|
-
ml: 'calc(14px + 1em)',
|
|
141
|
-
mt: ((_d = field.value) === null || _d === void 0 ? void 0 : _d.name) ? 0 : 1, // Adjust spacing if no file is selected
|
|
142
|
-
} }, helperText))));
|
|
143
|
-
} }));
|
|
144
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function FloatFieldBySchema({ name, schema, control, errors, fieldKey, index, onValueChange, decimalScale, label, autoFocus, disabled, ...other }: Omit<FieldBySchemaProps, 'type'>): React.JSX.Element | undefined;
|
|
4
|
-
//# sourceMappingURL=FloatFieldBySchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FloatFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/FloatFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,aAAa,EACb,YAAY,EACZ,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,iCA0ElC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
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.default = FloatFieldBySchema;
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
20
|
-
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
21
|
-
const react_number_format_1 = require("react-number-format");
|
|
22
|
-
const utils_1 = require("../../../utils");
|
|
23
|
-
function FloatFieldBySchema(_a) {
|
|
24
|
-
var _b;
|
|
25
|
-
var { name, schema, control, errors, fieldKey, index, onValueChange, decimalScale, label, autoFocus, disabled } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "onValueChange", "decimalScale", "label", "autoFocus", "disabled"]);
|
|
26
|
-
if (!(name in schema)) {
|
|
27
|
-
console.error(`FloatFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const fieldSchema = schema[name];
|
|
31
|
-
if (!label) {
|
|
32
|
-
label = fieldSchema.label;
|
|
33
|
-
}
|
|
34
|
-
if (fieldKey && index && index >= 0) {
|
|
35
|
-
name = `${fieldKey}.${index}.${name}`;
|
|
36
|
-
}
|
|
37
|
-
const { error, helperText } = fieldKey && index && index >= 0
|
|
38
|
-
? (0, utils_1.errorProps)({
|
|
39
|
-
fieldKey,
|
|
40
|
-
index,
|
|
41
|
-
fieldKeyProp: name,
|
|
42
|
-
errors,
|
|
43
|
-
})
|
|
44
|
-
: {
|
|
45
|
-
error: errors && Boolean(errors[name]),
|
|
46
|
-
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : fieldSchema.help_text || '',
|
|
47
|
-
};
|
|
48
|
-
const prefix = fieldSchema.is_currency
|
|
49
|
-
? 'R$ '
|
|
50
|
-
: fieldSchema.prefix !== ''
|
|
51
|
-
? `${fieldSchema.prefix} `
|
|
52
|
-
: '';
|
|
53
|
-
const suffix = fieldSchema.suffix !== '' ? ` ${fieldSchema.suffix}` : '';
|
|
54
|
-
const decimals = decimalScale || fieldSchema.decimal_places || 2;
|
|
55
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
56
|
-
const moedaInputProps = Object.assign(Object.assign({}, field), { ref: undefined, onChange: undefined });
|
|
57
|
-
return (react_1.default.createElement(react_number_format_1.NumericFormat, Object.assign({}, moedaInputProps, other, { label: label, disabled: fieldSchema.disabled === true || disabled === true, required: (0, utils_1.isFieldRequired)(fieldSchema), onValueChange: (values) => {
|
|
58
|
-
field.onChange(values.floatValue);
|
|
59
|
-
if (onValueChange) {
|
|
60
|
-
onValueChange(values.floatValue);
|
|
61
|
-
}
|
|
62
|
-
}, style: { width: '100%' }, thousandSeparator: ".", decimalSeparator: ",", decimalScale: decimals, fixedDecimalScale: true, valueIsNumericString: true, prefix: prefix, suffix: suffix, error: error, helperText: helperText, margin: "normal", customInput: TextField_1.default, autoFocus: autoFocus })));
|
|
63
|
-
} }));
|
|
64
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FieldBySchemaProps, GeometryFieldType, TField } from '../../../@types';
|
|
3
|
-
export interface GeometryFieldBySchemaProps<T extends TField = void> extends FieldBySchemaProps<T> {
|
|
4
|
-
geometry: GeometryFieldType;
|
|
5
|
-
height?: number;
|
|
6
|
-
}
|
|
7
|
-
export default function GeometryFieldBySchema({ name, schema, control, errors, geometry, fieldKey, index, sx, autoFocus, disabled, height, onValueChange, ...other }: GeometryFieldBySchemaProps): React.JSX.Element | undefined;
|
|
8
|
-
//# sourceMappingURL=GeometryFieldBySchema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GeometryFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/GeometryFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGhF,MAAM,WAAW,0BAA0B,CAAC,CAAC,SAAS,MAAM,GAAG,IAAI,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IAChG,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,EAAc,EACd,SAAS,EACT,QAAQ,EACR,MAAM,EACN,aAAa,EACb,GAAG,KAAK,EACT,EAAE,0BAA0B,iCAqE5B"}
|
|
@@ -1,57 +0,0 @@
|
|
|
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.default = GeometryFieldBySchema;
|
|
18
|
-
const react_1 = __importDefault(require("react"));
|
|
19
|
-
const react_hook_form_1 = require("react-hook-form");
|
|
20
|
-
const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
21
|
-
const utils_1 = require("../../../utils");
|
|
22
|
-
const MapGeometryPicker_1 = __importDefault(require("./MapGeometryPicker"));
|
|
23
|
-
function GeometryFieldBySchema(_a) {
|
|
24
|
-
var _b;
|
|
25
|
-
var { name, schema, control, errors, geometry, fieldKey, index, sx = { mr: 2 }, autoFocus, disabled, height, onValueChange } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "geometry", "fieldKey", "index", "sx", "autoFocus", "disabled", "height", "onValueChange"]);
|
|
26
|
-
if (!(name in schema)) {
|
|
27
|
-
console.error(`GeometryFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const fieldSchema = schema[name];
|
|
31
|
-
if (fieldKey && index && index >= 0) {
|
|
32
|
-
name = `${fieldKey}.${index}.${name}`;
|
|
33
|
-
}
|
|
34
|
-
const { error, helperText } = fieldKey && index && index >= 0
|
|
35
|
-
? (0, utils_1.errorProps)({ fieldKey, index, fieldKeyProp: name, errors })
|
|
36
|
-
: {
|
|
37
|
-
error: errors && Boolean(errors[name]),
|
|
38
|
-
helperText: errors && errors[name] ? (_b = errors[name]) === null || _b === void 0 ? void 0 : _b.message : fieldSchema.help_text || '',
|
|
39
|
-
};
|
|
40
|
-
const mapAvailable = Boolean((0, utils_1.getMapLibraries)());
|
|
41
|
-
const multiline = geometry !== 'point';
|
|
42
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
43
|
-
const currentValue = (0, utils_1.geometryValueToString)(field.value);
|
|
44
|
-
if (mapAvailable) {
|
|
45
|
-
return (react_1.default.createElement(MapGeometryPicker_1.default, { geometry: geometry, value: currentValue, onChange: (geoJSON) => {
|
|
46
|
-
field.onChange(geoJSON);
|
|
47
|
-
if (onValueChange)
|
|
48
|
-
onValueChange(geoJSON);
|
|
49
|
-
}, label: fieldSchema.label, error: error, helperText: helperText, height: height }));
|
|
50
|
-
}
|
|
51
|
-
return (react_1.default.createElement(TextField_1.default, Object.assign({}, other, { id: name, value: currentValue, label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), disabled: fieldSchema.disabled === true || disabled, onChange: (e) => {
|
|
52
|
-
field.onChange(e.target.value);
|
|
53
|
-
if (onValueChange)
|
|
54
|
-
onValueChange(e);
|
|
55
|
-
}, margin: "normal", fullWidth: true, multiline: multiline, minRows: multiline ? 4 : 0, error: error, helperText: helperText, sx: sx, autoFocus: autoFocus })));
|
|
56
|
-
} }));
|
|
57
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
-
import 'leaflet/dist/leaflet.css';
|
|
4
|
-
import 'leaflet-draw';
|
|
5
|
-
import 'leaflet-draw/dist/leaflet.draw.css';
|
|
6
|
-
import { GeometryFieldType } from '../../../@types';
|
|
7
|
-
interface MapGeometryPickerProps {
|
|
8
|
-
geometry: GeometryFieldType;
|
|
9
|
-
value: string;
|
|
10
|
-
label?: string;
|
|
11
|
-
onChange: (geoJSON: string | null) => void;
|
|
12
|
-
error?: boolean;
|
|
13
|
-
helperText?: string;
|
|
14
|
-
sx?: SxProps<Theme>;
|
|
15
|
-
height?: number;
|
|
16
|
-
}
|
|
17
|
-
export default function MapGeometryPicker({ geometry, value, label, onChange, error, helperText, sx, height, }: MapGeometryPickerProps): React.JSX.Element;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=MapGeometryPicker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MapGeometryPicker.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/MapGeometryPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,sBAAsB,CAAC;AAGhE,OAAO,0BAA0B,CAAC;AAElC,OAAO,cAAc,CAAC;AACtB,OAAO,oCAAoC,CAAC;AAI5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMpD,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgQD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,EACR,KAAK,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,EAAE,EACF,MAAY,GACb,EAAE,sBAAsB,qBAuDxB"}
|