drf-react-by-schema 0.20.10 → 0.21.1
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/@types/index.d.ts +4 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +2 -9
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/DataGridDesktop.js +27 -29
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable/DataGridMobile.js +1 -3
- package/dist/components/DataGridBySchemaEditable.d.ts.map +1 -1
- package/dist/components/DataGridBySchemaEditable.js +1 -0
- package/dist/components/GenericModelList.js +7 -7
- package/dist/components/GenericRelatedModelList.d.ts.map +1 -1
- package/dist/components/GenericRelatedModelList.js +6 -15
- package/dist/components/details/DetailBySchema.d.ts.map +1 -1
- package/dist/components/details/DetailBySchema.js +2 -2
- package/dist/components/details/DetailFieldBySchema.d.ts +1 -1
- package/dist/components/details/DetailFieldBySchema.d.ts.map +1 -1
- package/dist/components/details/DetailFieldBySchema.js +5 -1
- package/dist/components/forms/DialogFormBySchema.d.ts +1 -1
- package/dist/components/forms/DialogFormBySchema.d.ts.map +1 -1
- package/dist/components/forms/DialogFormBySchema.js +1 -1
- package/dist/components/forms/FieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/FieldBySchema.js +4 -2
- package/dist/components/forms/FormBySchema.d.ts.map +1 -1
- package/dist/components/forms/FormBySchema.js +3 -3
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/AutocompleteFieldBySchema.js +10 -6
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/BooleanFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/BooleanFieldBySchema.js +8 -3
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/DesktopDatePickerBySchema.js +9 -4
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/DesktopDateTimePickerBySchema.js +8 -3
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/EditableAutocompleteFieldBySchema.js +19 -14
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/FileFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/FileFieldBySchema.js +14 -10
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/FloatFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/FloatFieldBySchema.js +13 -9
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/PatternFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/PatternFieldBySchema.js +8 -4
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts +1 -1
- package/dist/components/forms/inputs/TextFieldBySchema.d.ts.map +1 -1
- package/dist/components/forms/inputs/TextFieldBySchema.js +8 -4
- package/dist/context/APIWrapper.d.ts +1 -1
- package/dist/context/APIWrapper.d.ts.map +1 -1
- package/dist/context/APIWrapper.js +175 -144
- package/dist/context/APIWrapperContext.d.ts +7 -8
- package/dist/context/APIWrapperContext.d.ts.map +1 -1
- package/dist/context/APIWrapperContext.js +1 -1
- package/dist/context/DRFReactBySchemaProvider.d.ts.map +1 -1
- package/dist/context/DRFReactBySchemaProvider.js +56 -15
- package/dist/context/Overlays.d.ts.map +1 -1
- package/dist/context/Overlays.js +4 -4
- package/dist/hooks/useWhyDidYouUpdate.d.ts +4 -0
- package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
- package/dist/hooks/useWhyDidYouUpdate.js +26 -0
- package/dist/utils.d.ts +5 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +64 -25
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormBySchema.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAWlD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,IAAI,EACJ,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,UAAU,iBAAkB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAClE,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"FormBySchema.d.ts","sourceRoot":"","sources":["../../../src/components/forms/FormBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAWlD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,IAAI,EACJ,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,UAAU,iBAAkB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAClE,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,CAAC;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAiB,EACjB,KAAK,EACL,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EACP,YAAY,EACZ,KAAK,EACL,YAAgB,EAEhB,YAAY,EAAE,mBAAmB,EACjC,sBAAsB,EAEtB,WAAW,EACX,YAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,SAAS,EAKT,KAAK,EACL,aAAa,EACb,SAAS,EACT,cAAc,GAKf,EAAE,iBAAiB,GAClB,IAAI,CACF,uBAAuB,EACrB,IAAI,GACJ,SAAS,GACT,SAAS,GACT,SAAS,GACT,aAAa,GACb,iBAAiB,GACjB,qBAAqB,CACxB,qBAmRF"}
|
|
@@ -55,7 +55,7 @@ const CircularProgress_1 = __importDefault(require("@mui/material/CircularProgre
|
|
|
55
55
|
const FieldBySchema_1 = __importDefault(require("./FieldBySchema"));
|
|
56
56
|
const styles_1 = require("../../styles");
|
|
57
57
|
const APIWrapperContext_1 = require("../../context/APIWrapperContext");
|
|
58
|
-
function FormBySchema({ schema, control, errors, register, multiline
|
|
58
|
+
function FormBySchema({ schema, control, errors, register, multiline, setValue, getValues, fieldKey, labelKey = 'nome', index, optionsAC, setOptionsAC, optionsModel, getOptionLabel, renderOption, onEditModel: customOnEditModel, options, isSemaphoric, label, decimalScale = 2, fieldsLayout: fieldsLayoutInitial, customFieldFormLayouts, fieldsProps, hiddenFields = [], isolatedGetAutoComplete, relatedEditable, autoFocusField, elevation,
|
|
59
59
|
// sx,
|
|
60
60
|
// sxField,
|
|
61
61
|
// sxLabel,
|
|
@@ -66,8 +66,8 @@ sxRow, sxRowMultiple, sxSection, sxSectionTitle,
|
|
|
66
66
|
// sxValueListItemText,
|
|
67
67
|
}) {
|
|
68
68
|
const { getAutoComplete: defaulGetAutoComplete, onEditModel: defaultOnEditModel } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
69
|
-
const getAutoComplete = isolatedGetAutoComplete || defaulGetAutoComplete;
|
|
70
|
-
const onEditModel = relatedEditable === false ? undefined : customOnEditModel || defaultOnEditModel;
|
|
69
|
+
const getAutoComplete = (0, react_1.useMemo)(() => isolatedGetAutoComplete || defaulGetAutoComplete, [defaulGetAutoComplete, isolatedGetAutoComplete]);
|
|
70
|
+
const onEditModel = (0, react_1.useMemo)(() => (relatedEditable === false ? undefined : customOnEditModel || defaultOnEditModel), [customOnEditModel, defaultOnEditModel, relatedEditable]);
|
|
71
71
|
const [localOptionsAC, setLocalOptionsAC] = (0, react_1.useState)(undefined);
|
|
72
72
|
const defaultSx = { mr: 0 };
|
|
73
73
|
const { fieldsLayout, optionsACModels } = (0, react_1.useMemo)(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function AutocompleteFieldBySchema({ fieldKey, index, name, schema, control, errors, optionIdKey, optionLabelKey, options, isSemaphoric, sx, onValueChange, autoFocus, disabled, autoComplete: _, ...other }: FieldBySchemaProps): React.JSX.Element;
|
|
3
|
+
export default function AutocompleteFieldBySchema({ fieldKey, index, name, schema, control, errors, optionIdKey, optionLabelKey, options, isSemaphoric, sx, onValueChange, autoFocus, disabled, autoComplete: _, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
4
|
//# sourceMappingURL=AutocompleteFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/AutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA8DrD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,WAAkB,EAClB,cAAwB,EACxB,OAAO,EACP,YAAoB,EACpB,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,CAAC,EACf,GAAG,KAAK,EACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"AutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/AutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AA8DrD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,WAAkB,EAClB,cAAwB,EACxB,OAAO,EACP,YAAoB,EACpB,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,CAAC,EACf,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA6DpB"}
|
|
@@ -23,7 +23,7 @@ const utils_1 = require("../../../utils");
|
|
|
23
23
|
const DRFReactBySchemaContext_1 = require("../../../context/DRFReactBySchemaContext");
|
|
24
24
|
const renderInput = (_a) => {
|
|
25
25
|
var { control: _, options, optionLabelKey, schema, name, errors, fieldKey, index, isSemaphoric, label, theme } = _a, params = __rest(_a, ["control", "options", "optionLabelKey", "schema", "name", "errors", "fieldKey", "index", "isSemaphoric", "label", "theme"]);
|
|
26
|
-
const
|
|
26
|
+
const fieldSchema = schema[name];
|
|
27
27
|
const { error, helperText } = fieldKey && index && index >= 0
|
|
28
28
|
? (0, utils_1.errorProps)({
|
|
29
29
|
fieldKey,
|
|
@@ -33,7 +33,7 @@ const renderInput = (_a) => {
|
|
|
33
33
|
})
|
|
34
34
|
: {
|
|
35
35
|
error: errors && Boolean(errors[name]),
|
|
36
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
36
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
37
37
|
};
|
|
38
38
|
let sx = undefined;
|
|
39
39
|
if (isSemaphoric && options && optionLabelKey) {
|
|
@@ -53,19 +53,23 @@ const renderInput = (_a) => {
|
|
|
53
53
|
sx = { backgroundColor: theme.palette[tipo].semaphoric };
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label ||
|
|
56
|
+
return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label || fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), margin: "normal", error: error, helperText: helperText, sx: sx })));
|
|
57
57
|
};
|
|
58
58
|
function AutocompleteFieldBySchema(_a) {
|
|
59
59
|
var { fieldKey, index, name, schema, control, errors, optionIdKey = 'id', optionLabelKey = 'label', options, isSemaphoric = false, sx = { mr: 2 }, onValueChange, autoFocus, disabled, autoComplete: _ } = _a, other = __rest(_a, ["fieldKey", "index", "name", "schema", "control", "errors", "optionIdKey", "optionLabelKey", "options", "isSemaphoric", "sx", "onValueChange", "autoFocus", "disabled", "autoComplete"]);
|
|
60
|
-
const model = name;
|
|
61
60
|
const { theme } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
61
|
+
const fieldSchema = schema[name];
|
|
62
|
+
if (!(name in schema)) {
|
|
63
|
+
console.error(`AutocompleteFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
62
66
|
if (!options) {
|
|
63
|
-
options =
|
|
67
|
+
options = fieldSchema.choices;
|
|
64
68
|
}
|
|
65
69
|
if (fieldKey && index && index >= 0) {
|
|
66
70
|
name = `${fieldKey}.${index}.${name}`;
|
|
67
71
|
}
|
|
68
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(Autocomplete_1.default, Object.assign({}, field, { key: name, id: name, options: options || [], disabled:
|
|
72
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(Autocomplete_1.default, Object.assign({}, field, { key: name, id: name, options: options || [], disabled: fieldSchema.disabled === true || disabled === true, selectOnFocus: true, autoHighlight: true, autoFocus: autoFocus, isOptionEqualToValue: (option, value) => {
|
|
69
73
|
return option[optionIdKey] === value[optionIdKey];
|
|
70
74
|
}, getOptionLabel: (option) => {
|
|
71
75
|
return option[optionLabelKey];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, autoFocus, disabled, ...other }: FieldBySchemaProps): React.JSX.Element;
|
|
3
|
+
export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, autoFocus, disabled, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
4
|
//# sourceMappingURL=BooleanFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/BooleanFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"BooleanFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/BooleanFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,EAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,kBAAkB,iCAwCpB"}
|
|
@@ -19,16 +19,21 @@ const react_1 = __importDefault(require("react"));
|
|
|
19
19
|
const react_hook_form_1 = require("react-hook-form");
|
|
20
20
|
const Checkbox_1 = __importDefault(require("@mui/material/Checkbox"));
|
|
21
21
|
const FormControlLabel_1 = __importDefault(require("@mui/material/FormControlLabel"));
|
|
22
|
+
const utils_1 = require("../../../utils");
|
|
22
23
|
function BooleanFieldBySchema(_a) {
|
|
23
24
|
var { name, schema, control, fieldKey, index, sx = { mr: 2 }, onValueChange, autoFocus, disabled } = _a, other = __rest(_a, ["name", "schema", "control", "fieldKey", "index", "sx", "onValueChange", "autoFocus", "disabled"]);
|
|
24
|
-
|
|
25
|
+
if (!(name in schema)) {
|
|
26
|
+
console.error(`BooleanFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const fieldSchema = schema[name];
|
|
25
30
|
if (fieldKey && index && index >= 0) {
|
|
26
31
|
name = `${fieldKey}.${index}.${name}`;
|
|
27
32
|
}
|
|
28
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Checkbox_1.default, Object.assign({}, field, other, { value: field.value || false, checked: field.value || false, disabled:
|
|
33
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Checkbox_1.default, Object.assign({}, field, other, { value: field.value || false, checked: field.value || false, disabled: fieldSchema.disabled === true || disabled === true, inputProps: { 'aria-label': 'controlled' }, onChange: (e) => {
|
|
29
34
|
if (onValueChange) {
|
|
30
35
|
onValueChange(e);
|
|
31
36
|
}
|
|
32
37
|
field.onChange(e);
|
|
33
|
-
}, autoFocus: autoFocus })), label:
|
|
38
|
+
}, autoFocus: autoFocus })), label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), sx: Object.assign({ width: '100%' }, sx) })) }));
|
|
34
39
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'dayjs/locale/pt-br';
|
|
3
3
|
import { FieldBySchemaProps } from '../../../@types';
|
|
4
|
-
export default function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element;
|
|
4
|
+
export default function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
5
5
|
//# sourceMappingURL=DesktopDatePickerBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DesktopDatePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDatePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DesktopDatePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDatePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,iCA2DpB"}
|
|
@@ -13,17 +13,21 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
13
13
|
require("dayjs/locale/pt-br");
|
|
14
14
|
const utils_1 = require("../../../utils");
|
|
15
15
|
function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, disabled, }) {
|
|
16
|
+
if (!(name in schema)) {
|
|
17
|
+
console.error(`DesktopDatePickerBySchema: could not find schema for ${name}! Not rendering`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const fieldSchema = schema[name];
|
|
16
21
|
if (!sx) {
|
|
17
22
|
sx = { minWidth: 200 };
|
|
18
23
|
}
|
|
19
24
|
if (!('minWidth' in sx)) {
|
|
20
25
|
sx = Object.assign(Object.assign({}, sx), { minWidth: 200 });
|
|
21
26
|
}
|
|
22
|
-
const model = name;
|
|
23
27
|
if (fieldKey && index && index >= 0) {
|
|
24
28
|
name = `${fieldKey}.${index}.${name}`;
|
|
25
29
|
}
|
|
26
|
-
const inputFormat = (0, utils_1.buildDateFormatBySchema)(
|
|
30
|
+
const inputFormat = (0, utils_1.buildDateFormatBySchema)(fieldSchema.date_views);
|
|
27
31
|
const { error, helperText } = fieldKey && index && index >= 0
|
|
28
32
|
? (0, utils_1.errorProps)({
|
|
29
33
|
fieldKey,
|
|
@@ -33,16 +37,17 @@ function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, in
|
|
|
33
37
|
})
|
|
34
38
|
: {
|
|
35
39
|
error: errors && Boolean(errors[name]),
|
|
36
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
40
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
37
41
|
};
|
|
38
42
|
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDayjs_1.AdapterDayjs, adapterLocale: "pt-br" },
|
|
39
|
-
react_1.default.createElement(DesktopDatePicker_1.DesktopDatePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label:
|
|
43
|
+
react_1.default.createElement(DesktopDatePicker_1.DesktopDatePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label: fieldSchema.label, disabled: fieldSchema.disabled === true || disabled === true, views: fieldSchema.date_views, format: inputFormat, sx: Object.assign({ mt: 2, mb: 1 }, sx), slotProps: {
|
|
40
44
|
textField: {
|
|
41
45
|
error,
|
|
42
46
|
helperText,
|
|
43
47
|
sx,
|
|
44
48
|
margin: 'normal',
|
|
45
49
|
autoFocus,
|
|
50
|
+
required: (0, utils_1.isFieldRequired)(fieldSchema),
|
|
46
51
|
},
|
|
47
52
|
} })))) }));
|
|
48
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'dayjs/locale/pt-br';
|
|
3
3
|
import { FieldBySchemaProps } from '../../../@types';
|
|
4
|
-
export default function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element;
|
|
4
|
+
export default function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, disabled, }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
5
5
|
//# sourceMappingURL=DesktopDateTimePickerBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DesktopDateTimePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDateTimePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,EACpD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DesktopDateTimePickerBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/DesktopDateTimePickerBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,6BAA6B,CAAC,EACpD,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAqB,EACrB,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,iCAqDpB"}
|
|
@@ -13,7 +13,11 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
13
13
|
require("dayjs/locale/pt-br");
|
|
14
14
|
const utils_1 = require("../../../utils");
|
|
15
15
|
function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, disabled, }) {
|
|
16
|
-
|
|
16
|
+
if (!(name in schema)) {
|
|
17
|
+
console.error(`DesktopDateTimePickerBySchema: could not find schema for ${name}! Not rendering`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const fieldSchema = schema[name];
|
|
17
21
|
if (fieldKey && index && index >= 0) {
|
|
18
22
|
name = `${fieldKey}.${index}.${name}`;
|
|
19
23
|
}
|
|
@@ -26,16 +30,17 @@ function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey
|
|
|
26
30
|
})
|
|
27
31
|
: {
|
|
28
32
|
error: errors && Boolean(errors[name]),
|
|
29
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
33
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
30
34
|
};
|
|
31
35
|
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterDayjs_1.AdapterDayjs, adapterLocale: "pt-br" },
|
|
32
|
-
react_1.default.createElement(DesktopDateTimePicker_1.DesktopDateTimePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label:
|
|
36
|
+
react_1.default.createElement(DesktopDateTimePicker_1.DesktopDateTimePicker, Object.assign({}, field, { value: (0, dayjs_1.default)(field.value), label: fieldSchema.label, disabled: fieldSchema.disabled === true || disabled === true, format: "DD/MM/YYYY HH:mm", sx: Object.assign({ mt: 2, mb: 1 }, sx), slotProps: {
|
|
33
37
|
textField: {
|
|
34
38
|
error,
|
|
35
39
|
helperText,
|
|
36
40
|
sx,
|
|
37
41
|
margin: 'normal',
|
|
38
42
|
autoFocus,
|
|
43
|
+
required: (0, utils_1.isFieldRequired)(fieldSchema),
|
|
39
44
|
},
|
|
40
45
|
} })))) }));
|
|
41
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditableAutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/EditableAutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAQnD,OAAO,EAAQ,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAO3D,QAAA,MAAM,iCAAiC,
|
|
1
|
+
{"version":3,"file":"EditableAutocompleteFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/EditableAutocompleteFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAQnD,OAAO,EAAQ,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAO3D,QAAA,MAAM,iCAAiC,gFAkWtC,CAAC;AAGF,eAAe,iCAAiC,CAAC"}
|
|
@@ -63,13 +63,6 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) =>
|
|
|
63
63
|
const { setDialog } = (0, APIWrapperContext_1.useAPIWrapper)();
|
|
64
64
|
const [options, setOptions] = (0, react_1.useState)(null);
|
|
65
65
|
const model = name;
|
|
66
|
-
const label = schema[model].label;
|
|
67
|
-
if (!optionsModel) {
|
|
68
|
-
optionsModel = model;
|
|
69
|
-
}
|
|
70
|
-
if (fieldKey && index && index >= 0) {
|
|
71
|
-
name = `${fieldKey}.${index}.${name}`;
|
|
72
|
-
}
|
|
73
66
|
(0, react_1.useEffect)(() => {
|
|
74
67
|
if (optionsAC && optionsModel && optionsAC[optionsModel]) {
|
|
75
68
|
setOptions(optionsAC[optionsModel]);
|
|
@@ -97,6 +90,18 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) =>
|
|
|
97
90
|
const harmonizedValues = options.find((option) => option.id === valuesInitial.id);
|
|
98
91
|
setValue(model, harmonizedValues);
|
|
99
92
|
}, [options, setValue, getValues, model, multiple]);
|
|
93
|
+
if (!(name in schema)) {
|
|
94
|
+
console.error(`EditableAutocompleteFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const fieldSchema = schema[name];
|
|
98
|
+
const label = fieldSchema.label;
|
|
99
|
+
if (!optionsModel) {
|
|
100
|
+
optionsModel = model;
|
|
101
|
+
}
|
|
102
|
+
if (fieldKey && index && index >= 0) {
|
|
103
|
+
name = `${fieldKey}.${index}.${name}`;
|
|
104
|
+
}
|
|
100
105
|
const { error, helperText } = fieldKey && index && index >= 0
|
|
101
106
|
? (0, utils_1.errorProps)({
|
|
102
107
|
fieldKey,
|
|
@@ -106,14 +111,14 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) =>
|
|
|
106
111
|
})
|
|
107
112
|
: {
|
|
108
113
|
error: errors && Boolean(errors[name]),
|
|
109
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
114
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
110
115
|
};
|
|
111
116
|
if (options === null) {
|
|
112
117
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
113
118
|
}
|
|
114
|
-
if (!disabled && !
|
|
115
|
-
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:
|
|
116
|
-
let valueAr = value;
|
|
119
|
+
if (!disabled && !fieldSchema.disabled && onEditModel && optionsModel) {
|
|
120
|
+
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.disabled === true, autoHighlight: true, isOptionEqualToValue: (option, value) => option.id === value.id, fullWidth: true, multiple: multiple, sx: sx, onChange: (e, value) => {
|
|
121
|
+
let valueAr = value || '';
|
|
117
122
|
if (!multiple) {
|
|
118
123
|
valueAr = [value];
|
|
119
124
|
}
|
|
@@ -160,7 +165,7 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) =>
|
|
|
160
165
|
if (onValueChange) {
|
|
161
166
|
onValueChange(e);
|
|
162
167
|
}
|
|
163
|
-
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required:
|
|
168
|
+
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: (0, utils_1.isFieldRequired)(fieldSchema), 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,
|
|
164
169
|
!multiple && field.value && (react_1.default.createElement(IconButton_1.default, { size: "small", onClick: () => {
|
|
165
170
|
if ((0, utils_1.isTmpId)(field.value.id)) {
|
|
166
171
|
setDialog({
|
|
@@ -251,12 +256,12 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, _) =>
|
|
|
251
256
|
}
|
|
252
257
|
: undefined }))) }));
|
|
253
258
|
}
|
|
254
|
-
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:
|
|
259
|
+
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.disabled === true || disabled === true, autoHighlight: true, isOptionEqualToValue: (option, value) => option.id === value.id, fullWidth: true, multiple: multiple, sx: sx, onChange: (e, value) => {
|
|
255
260
|
field.onChange(value);
|
|
256
261
|
if (onValueChange) {
|
|
257
262
|
onValueChange(e);
|
|
258
263
|
}
|
|
259
|
-
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required:
|
|
264
|
+
}, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: (0, utils_1.isFieldRequired)(fieldSchema), margin: "normal", error: error, autoFocus: autoFocus, helperText: helperText }, other))), getOptionLabel: getOptionLabel, renderOption: renderOption }))) }));
|
|
260
265
|
});
|
|
261
266
|
EditableAutocompleteFieldBySchema.displayName = 'EditableAutocompleteFieldBySchema';
|
|
262
267
|
exports.default = EditableAutocompleteFieldBySchema;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
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;
|
|
3
|
+
export default function FileFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, onValueChange, autoFocus, disabled, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
4
|
//# sourceMappingURL=FileFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -42,7 +42,11 @@ const VisuallyHiddenInput = (0, styles_1.styled)('input')({
|
|
|
42
42
|
function FileFieldBySchema(_a) {
|
|
43
43
|
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"]);
|
|
44
44
|
const { serverEndPoint } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
|
|
45
|
-
|
|
45
|
+
if (!(name in schema)) {
|
|
46
|
+
console.error(`FileFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const fieldSchema = schema[name];
|
|
46
50
|
if (fieldKey && index && index >= 0) {
|
|
47
51
|
name = `${fieldKey}.${index}.${name}`;
|
|
48
52
|
}
|
|
@@ -55,19 +59,19 @@ function FileFieldBySchema(_a) {
|
|
|
55
59
|
})
|
|
56
60
|
: {
|
|
57
61
|
error: errors && Boolean(errors[name]),
|
|
58
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
62
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
59
63
|
};
|
|
60
|
-
const fileTypeStr =
|
|
61
|
-
const accept =
|
|
62
|
-
?
|
|
63
|
-
:
|
|
64
|
+
const fileTypeStr = fieldSchema.type === 'image upload' ? 'imagem' : 'documento';
|
|
65
|
+
const accept = fieldSchema.allowed_mime_types
|
|
66
|
+
? fieldSchema.allowed_mime_types.join(', ')
|
|
67
|
+
: fieldSchema.type === 'image upload'
|
|
64
68
|
? '/image*'
|
|
65
69
|
: '*';
|
|
66
70
|
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
67
71
|
var _a, _b, _c, _d;
|
|
68
72
|
return (react_1.default.createElement(Box_1.default, { sx: Object.assign({ width: '100%' }, sx) },
|
|
69
73
|
react_1.default.createElement(FormControl_1.default, { component: "fieldset", sx: { width: '100%' } },
|
|
70
|
-
react_1.default.createElement(FormLabel_1.default, { component: "legend" },
|
|
74
|
+
react_1.default.createElement(FormLabel_1.default, { component: "legend" }, fieldSchema.label),
|
|
71
75
|
react_1.default.createElement(FormControlLabel_1.default, { control: react_1.default.createElement(Box_1.default, { sx: {
|
|
72
76
|
display: 'flex',
|
|
73
77
|
flexDirection: 'column',
|
|
@@ -75,7 +79,7 @@ function FileFieldBySchema(_a) {
|
|
|
75
79
|
width: '100%',
|
|
76
80
|
} },
|
|
77
81
|
(((_a = field.value) === null || _a === void 0 ? void 0 : _a.url) || ((_b = field.value) === null || _b === void 0 ? void 0 : _b.src)) &&
|
|
78
|
-
|
|
82
|
+
fieldSchema.type === 'image upload' && (react_1.default.createElement("img", { src: field.value.url
|
|
79
83
|
? `${serverEndPoint === null || serverEndPoint === void 0 ? void 0 : serverEndPoint.url}${field.value.url}`
|
|
80
84
|
: field.value.src, alt: field.value.name, title: field.value.name, style: {
|
|
81
85
|
width: '100%',
|
|
@@ -88,7 +92,7 @@ function FileFieldBySchema(_a) {
|
|
|
88
92
|
" (",
|
|
89
93
|
(0, utils_1.formatFileSize)(field.value.size),
|
|
90
94
|
")")),
|
|
91
|
-
react_1.default.createElement(Button_1.default, { component: "label", variant: "outlined", startIcon: react_1.default.createElement(CloudUpload_1.default, null), disabled:
|
|
95
|
+
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' },
|
|
92
96
|
field.value ? `Trocar ${fileTypeStr}` : `Enviar ${fileTypeStr}`,
|
|
93
97
|
react_1.default.createElement(VisuallyHiddenInput, Object.assign({ type: "file", onChange: (e) => {
|
|
94
98
|
var _a;
|
|
@@ -126,7 +130,7 @@ function FileFieldBySchema(_a) {
|
|
|
126
130
|
}
|
|
127
131
|
}, accept: accept, autoFocus: autoFocus }, other)))), label: '',
|
|
128
132
|
// labelPlacement="top"
|
|
129
|
-
required:
|
|
133
|
+
required: (0, utils_1.isFieldRequired)(fieldSchema), sx: {
|
|
130
134
|
width: '100%',
|
|
131
135
|
alignItems: 'flex-start',
|
|
132
136
|
marginLeft: 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
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;
|
|
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
4
|
//# sourceMappingURL=FloatFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,iCAyElC"}
|
|
@@ -22,9 +22,13 @@ const react_number_format_1 = require("react-number-format");
|
|
|
22
22
|
const utils_1 = require("../../../utils");
|
|
23
23
|
function FloatFieldBySchema(_a) {
|
|
24
24
|
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"]);
|
|
25
|
-
|
|
25
|
+
if (!(name in schema)) {
|
|
26
|
+
console.error(`FloatFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const fieldSchema = schema[name];
|
|
26
30
|
if (!label) {
|
|
27
|
-
label =
|
|
31
|
+
label = fieldSchema.label;
|
|
28
32
|
}
|
|
29
33
|
if (fieldKey && index && index >= 0) {
|
|
30
34
|
name = `${fieldKey}.${index}.${name}`;
|
|
@@ -38,18 +42,18 @@ function FloatFieldBySchema(_a) {
|
|
|
38
42
|
})
|
|
39
43
|
: {
|
|
40
44
|
error: errors && Boolean(errors[name]),
|
|
41
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
45
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
42
46
|
};
|
|
43
|
-
const prefix =
|
|
47
|
+
const prefix = fieldSchema.is_currency
|
|
44
48
|
? 'R$ '
|
|
45
|
-
:
|
|
46
|
-
? `${
|
|
49
|
+
: fieldSchema.prefix !== ''
|
|
50
|
+
? `${fieldSchema.prefix} `
|
|
47
51
|
: '';
|
|
48
|
-
const suffix =
|
|
49
|
-
const decimals = decimalScale ||
|
|
52
|
+
const suffix = fieldSchema.suffix !== '' ? ` ${fieldSchema.suffix}` : '';
|
|
53
|
+
const decimals = decimalScale || fieldSchema.decimal_places || 2;
|
|
50
54
|
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => {
|
|
51
55
|
const moedaInputProps = Object.assign(Object.assign({}, field), { ref: undefined, onChange: undefined });
|
|
52
|
-
return (react_1.default.createElement(react_number_format_1.NumericFormat, Object.assign({}, moedaInputProps, other, { label: label, disabled:
|
|
56
|
+
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) => {
|
|
53
57
|
field.onChange(values.floatValue);
|
|
54
58
|
if (onValueChange) {
|
|
55
59
|
onValueChange(values.floatValue);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function PatternFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
|
|
3
|
+
export default function PatternFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
4
|
//# sourceMappingURL=PatternFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PatternFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/PatternFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"PatternFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/PatternFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA0DpB"}
|
|
@@ -22,7 +22,11 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
|
22
22
|
const utils_1 = require("../../../utils");
|
|
23
23
|
function PatternFieldBySchema(_a) {
|
|
24
24
|
var { name, schema, control, errors, fieldKey, index, sx = { mr: 2 }, type, autoComplete, disabled, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "sx", "type", "autoComplete", "disabled", "onValueChange", "autoFocus"]);
|
|
25
|
-
|
|
25
|
+
if (!(name in schema)) {
|
|
26
|
+
console.error(`PatternFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const fieldSchema = schema[name];
|
|
26
30
|
if (fieldKey && index && index >= 0) {
|
|
27
31
|
name = `${fieldKey}.${index}.${name}`;
|
|
28
32
|
}
|
|
@@ -35,14 +39,14 @@ function PatternFieldBySchema(_a) {
|
|
|
35
39
|
})
|
|
36
40
|
: {
|
|
37
41
|
error: errors && Boolean(errors[name]),
|
|
38
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
42
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
39
43
|
};
|
|
40
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(react_number_format_1.PatternFormat, Object.assign({}, field, other, { id: name, key: name, label:
|
|
44
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(react_number_format_1.PatternFormat, Object.assign({}, field, other, { id: name, key: name, label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), disabled: fieldSchema.disabled === true || disabled, onChange: undefined, onValueChange: (values) => {
|
|
41
45
|
field.onChange(values.value);
|
|
42
46
|
if (onValueChange) {
|
|
43
47
|
onValueChange(values.value);
|
|
44
48
|
}
|
|
45
49
|
}, margin: "normal", fullWidth: true, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autoComplete, autoFocus: autoFocus,
|
|
46
50
|
// valueIsNumericString
|
|
47
|
-
format:
|
|
51
|
+
format: fieldSchema.pattern_format || '', mask: "_", customInput: TextField_1.default }))) }));
|
|
48
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldBySchemaProps } from '../../../@types';
|
|
3
|
-
export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
|
|
3
|
+
export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, type, autoComplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element | undefined;
|
|
4
4
|
//# sourceMappingURL=TextFieldBySchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/TextFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAiB,EACjB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"TextFieldBySchema.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/inputs/TextFieldBySchema.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAiB,EACjB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,EAAc,EACd,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,iCA6DpB"}
|
|
@@ -21,11 +21,15 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
|
|
|
21
21
|
const utils_1 = require("../../../utils");
|
|
22
22
|
function TextFieldBySchema(_a) {
|
|
23
23
|
var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, type, autoComplete, disabled, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "type", "autoComplete", "disabled", "onValueChange", "autoFocus"]);
|
|
24
|
-
|
|
24
|
+
if (!(name in schema)) {
|
|
25
|
+
console.error(`TextFieldBySchema: could not find schema for ${name}! Not rendering`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const fieldSchema = schema[name];
|
|
25
29
|
if (fieldKey && index && index >= 0) {
|
|
26
30
|
name = `${fieldKey}.${index}.${name}`;
|
|
27
31
|
}
|
|
28
|
-
if (
|
|
32
|
+
if (fieldSchema.type === 'password') {
|
|
29
33
|
type = 'password';
|
|
30
34
|
}
|
|
31
35
|
if (type === 'password') {
|
|
@@ -40,9 +44,9 @@ function TextFieldBySchema(_a) {
|
|
|
40
44
|
})
|
|
41
45
|
: {
|
|
42
46
|
error: errors && Boolean(errors[name]),
|
|
43
|
-
helperText: errors && errors[name] ? errors[name].message :
|
|
47
|
+
helperText: errors && errors[name] ? errors[name].message : fieldSchema.help_text || '',
|
|
44
48
|
};
|
|
45
|
-
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(TextField_1.default, Object.assign({}, field, other, { id: name, key: name, label:
|
|
49
|
+
return (react_1.default.createElement(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => (react_1.default.createElement(TextField_1.default, Object.assign({}, field, other, { id: name, key: name, label: fieldSchema.label, required: (0, utils_1.isFieldRequired)(fieldSchema), disabled: fieldSchema.disabled === true || disabled, onChange: (e) => {
|
|
46
50
|
field.onChange(e.target.value);
|
|
47
51
|
if (onValueChange) {
|
|
48
52
|
onValueChange(e);
|
|
@@ -3,7 +3,7 @@ import { DialogType, SnackBarType } from './APIWrapperContext';
|
|
|
3
3
|
interface APIWrapperProps {
|
|
4
4
|
handleLoading: (x: boolean) => void;
|
|
5
5
|
setSnackBar: (x: Partial<SnackBarType>) => void;
|
|
6
|
-
setDialog:
|
|
6
|
+
setDialog: React.ActionDispatch<[newState: Partial<DialogType> | null]>;
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}
|
|
9
9
|
declare function APIWrapper({ handleLoading, setSnackBar, setDialog, children }: APIWrapperProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"APIWrapper.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"APIWrapper.d.ts","sourceRoot":"","sources":["../../src/context/APIWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAC;AA4C7F,OAAO,EAEL,UAAU,EAQV,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;AASD,iBAAS,UAAU,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,eAAe,qBA+oBvF;;AAED,wBAAsC"}
|