drf-react-by-schema 0.18.0 → 0.18.2

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.
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { FieldBySchemaProps } from '../../utils';
3
- export default function FieldBySchema({ name, schema, control, errors, multiline, setValue, getValues, fieldKey, labelKey, index, optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, fieldsLayout, sx, options, isSemaphoric, label, onValueChange, decimalScale, ...other }: FieldBySchemaProps): React.JSX.Element;
3
+ export default function FieldBySchema({ name, schema, control, errors, multiline, setValue, getValues, fieldKey, labelKey, index, optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, fieldsLayout, sx, options, isSemaphoric, label, onValueChange, decimalScale, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
@@ -24,10 +24,10 @@ const BooleanFieldBySchema_1 = __importDefault(require("./inputs/BooleanFieldByS
24
24
  const FloatFieldBySchema_1 = __importDefault(require("./inputs/FloatFieldBySchema"));
25
25
  const TextFieldBySchema_1 = __importDefault(require("./inputs/TextFieldBySchema"));
26
26
  function FieldBySchema(_a) {
27
- var { name, schema, control, errors, multiline = false, setValue, getValues, fieldKey, labelKey = 'nome', index, optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, fieldsLayout, sx, options, isSemaphoric = false, label, onValueChange, decimalScale = 2 } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "setValue", "getValues", "fieldKey", "labelKey", "index", "optionsAC", "optionsModel", "getOptionLabel", "renderOption", "onEditModel", "fieldsLayout", "sx", "options", "isSemaphoric", "label", "onValueChange", "decimalScale"]);
27
+ var { name, schema, control, errors, multiline = false, setValue, getValues, fieldKey, labelKey = 'nome', index, optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, fieldsLayout, sx, options, isSemaphoric = false, label, onValueChange, decimalScale = 2, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "setValue", "getValues", "fieldKey", "labelKey", "index", "optionsAC", "optionsModel", "getOptionLabel", "renderOption", "onEditModel", "fieldsLayout", "sx", "options", "isSemaphoric", "label", "onValueChange", "decimalScale", "autoFocus"]);
28
28
  switch (schema[name].type) {
29
29
  case 'date':
30
- return (react_1.default.createElement(DesktopDatePickerBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, sx: sx, onValueChange: onValueChange }, other)));
30
+ return (react_1.default.createElement(DesktopDatePickerBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, sx: sx, onValueChange: onValueChange, autoFocus: autoFocus }, other)));
31
31
  case 'datetime':
32
32
  return (react_1.default.createElement(DesktopDateTimePickerBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, sx: sx, onValueChange: onValueChange }, other)));
33
33
  // case 'field':
@@ -46,20 +46,20 @@ function FieldBySchema(_a) {
46
46
  case 'field':
47
47
  const relatedEditable = schema[name].related_editable;
48
48
  const multiple = schema[name].many || false;
49
- return (react_1.default.createElement(EditableAutocompleteFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index, optionsAC: optionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: relatedEditable ? onEditModel : undefined, fieldsLayout: fieldsLayout, multiple: multiple, sx: sx, onValueChange: onValueChange }, other)));
49
+ return (react_1.default.createElement(EditableAutocompleteFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index, optionsAC: optionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: relatedEditable ? onEditModel : undefined, fieldsLayout: fieldsLayout, multiple: multiple, sx: sx, onValueChange: onValueChange, autoFocus: autoFocus }, other)));
50
50
  case 'choice':
51
- return (react_1.default.createElement(AutocompleteFieldBySchema_1.default, { index: index, name: name, schema: schema, control: control, errors: errors, fieldKey: fieldKey, optionIdKey: "value", optionLabelKey: "display_name", options: options, isSemaphoric: isSemaphoric, label: label, sx: sx, onValueChange: onValueChange }));
51
+ return (react_1.default.createElement(AutocompleteFieldBySchema_1.default, { index: index, name: name, schema: schema, control: control, errors: errors, fieldKey: fieldKey, optionIdKey: "value", optionLabelKey: "display_name", options: options, isSemaphoric: isSemaphoric, label: label, sx: sx, onValueChange: onValueChange, autoFocus: autoFocus }));
52
52
  case 'boolean':
53
- return (react_1.default.createElement(BooleanFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, fieldKey: fieldKey, index: index, sx: sx, onValueChange: onValueChange }, other)));
53
+ return (react_1.default.createElement(BooleanFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, fieldKey: fieldKey, index: index, sx: sx, onValueChange: onValueChange, autoFocus: autoFocus }, other)));
54
54
  case 'decimal':
55
55
  case 'float':
56
- return (react_1.default.createElement(FloatFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, onValueChange: onValueChange, decimalScale: decimalScale, label: label, sx: sx }, other)));
56
+ return (react_1.default.createElement(FloatFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: multiline, fieldKey: fieldKey, index: index, onValueChange: onValueChange, decimalScale: decimalScale, label: label, sx: sx, autoFocus: autoFocus }, other)));
57
57
  case 'number':
58
58
  case 'integer':
59
59
  case 'password':
60
60
  default:
61
61
  const localMultiline = schema[name].model_multiline === true || multiline;
62
62
  const minRows = localMultiline ? 3 : 0;
63
- return (react_1.default.createElement(TextFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: localMultiline, minRows: minRows, fieldKey: fieldKey, index: index, sx: sx, isPassword: schema[name].type === 'password', onValueChange: onValueChange }, other)));
63
+ return (react_1.default.createElement(TextFieldBySchema_1.default, Object.assign({ name: name, schema: schema, control: control, errors: errors, multiline: localMultiline, minRows: minRows, fieldKey: fieldKey, index: index, sx: sx, isPassword: schema[name].type === 'password', onValueChange: onValueChange, autoFocus: autoFocus }, other)));
64
64
  }
65
65
  }
@@ -182,7 +182,7 @@ function FormBySchema({ schema, control, errors, register, multiline = false, se
182
182
  : undefined, fieldsLayout: customFieldFormLayouts &&
183
183
  field in customFieldFormLayouts
184
184
  ? customFieldFormLayouts[field]
185
- : undefined, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale }, fieldProps))));
185
+ : undefined, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale, autoFocus: rowIndex === 0 }, fieldProps))));
186
186
  }
187
187
  if (Array.isArray(row)) {
188
188
  return (react_1.default.createElement(Box_1.default, { sx: styles_1.Layout.inLineForm, key: `row_${rowIndex}` },
@@ -200,7 +200,8 @@ function FormBySchema({ schema, control, errors, register, multiline = false, se
200
200
  ? Object.assign(Object.assign({}, fieldProps.sx), { mr }) : {
201
201
  mr,
202
202
  };
203
- return (react_1.default.createElement(react_1.default.Fragment, { key: `field_${rowIndex}_${i}` }, typeof field === 'string' ? (react_1.default.createElement(FieldBySchema_1.default, Object.assign({ name: field, schema: schema, control: control, errors: errors, multiline: multiline, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index, optionsAC: optionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: onEditModel, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale }, fieldProps))) : (react_1.default.createElement(field.CustomElement, Object.assign({}, fieldProps)))));
203
+ return (react_1.default.createElement(react_1.default.Fragment, { key: `field_${rowIndex}_${i}` }, typeof field === 'string' ? (react_1.default.createElement(FieldBySchema_1.default, Object.assign({ name: field, schema: schema, control: control, errors: errors, multiline: multiline, setValue: setValue, getValues: getValues, fieldKey: fieldKey, labelKey: labelKey, index: index, optionsAC: optionsAC, optionsModel: optionsModel, getOptionLabel: getOptionLabel, renderOption: renderOption, onEditModel: onEditModel, options: options, isSemaphoric: isSemaphoric, label: label, decimalScale: decimalScale, autoFocus: rowIndex === 0 &&
204
+ i === 0 }, fieldProps))) : (react_1.default.createElement(field.CustomElement, Object.assign({}, fieldProps)))));
204
205
  }))));
205
206
  }
206
207
  const fieldProps = fieldsProps && fieldsProps.hasOwnProperty(row.key)
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function AutocompleteFieldBySchema({ fieldKey, index, name, schema, control, errors, optionIdKey, optionLabelKey, options, isSemaphoric, sx, onValueChange, ...other }: FieldBySchemaProps): React.JSX.Element;
3
+ export default function AutocompleteFieldBySchema({ fieldKey, index, name, schema, control, errors, optionIdKey, optionLabelKey, options, isSemaphoric, sx, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
@@ -56,7 +56,7 @@ const renderInput = (_a) => {
56
56
  return (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label || schema[model].label, required: schema[model].required, margin: "normal", error: error, helperText: helperText, sx: sx })));
57
57
  };
58
58
  function AutocompleteFieldBySchema(_a) {
59
- var { fieldKey, index, name, schema, control, errors, optionIdKey = 'id', optionLabelKey = 'label', options, isSemaphoric = false, sx = { mr: 2 }, onValueChange } = _a, other = __rest(_a, ["fieldKey", "index", "name", "schema", "control", "errors", "optionIdKey", "optionLabelKey", "options", "isSemaphoric", "sx", "onValueChange"]);
59
+ var { fieldKey, index, name, schema, control, errors, optionIdKey = 'id', optionLabelKey = 'label', options, isSemaphoric = false, sx = { mr: 2 }, onValueChange, autoFocus } = _a, other = __rest(_a, ["fieldKey", "index", "name", "schema", "control", "errors", "optionIdKey", "optionLabelKey", "options", "isSemaphoric", "sx", "onValueChange", "autoFocus"]);
60
60
  const model = name;
61
61
  const { theme } = (0, DRFReactBySchemaContext_1.useDRFReactBySchema)();
62
62
  if (!options) {
@@ -65,7 +65,7 @@ function AutocompleteFieldBySchema(_a) {
65
65
  if (fieldKey && index && index >= 0) {
66
66
  name = `${fieldKey}.${index}.${name}`;
67
67
  }
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 || [], selectOnFocus: true, autoHighlight: true, isOptionEqualToValue: (option, value) => {
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 || [], selectOnFocus: true, autoHighlight: true, autoFocus: autoFocus, isOptionEqualToValue: (option, value) => {
69
69
  return option[optionIdKey] === value[optionIdKey];
70
70
  }, getOptionLabel: (option) => {
71
71
  return option[optionLabelKey];
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, ...other }: FieldBySchemaProps): React.JSX.Element;
3
+ export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
@@ -20,7 +20,7 @@ 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
22
  function BooleanFieldBySchema(_a) {
23
- var { name, schema, control, fieldKey, index, sx = { mr: 2 }, onValueChange } = _a, other = __rest(_a, ["name", "schema", "control", "fieldKey", "index", "sx", "onValueChange"]);
23
+ var { name, schema, control, fieldKey, index, sx = { mr: 2 }, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "fieldKey", "index", "sx", "onValueChange", "autoFocus"]);
24
24
  const model = name;
25
25
  if (fieldKey && index && index >= 0) {
26
26
  name = `${fieldKey}.${index}.${name}`;
@@ -30,5 +30,5 @@ function BooleanFieldBySchema(_a) {
30
30
  onValueChange(e);
31
31
  }
32
32
  field.onChange(e);
33
- } })), label: schema[model].label, required: schema[model].required, sx: Object.assign({ width: '100%' }, sx) })) }));
33
+ }, autoFocus: autoFocus })), label: schema[model].label, required: schema[model].required, sx: Object.assign({ width: '100%' }, sx) })) }));
34
34
  }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import 'dayjs/locale/pt-br';
3
3
  import { FieldBySchemaProps } from '../../../utils';
4
- export default function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, }: FieldBySchemaProps): React.JSX.Element;
4
+ export default function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, }: FieldBySchemaProps): React.JSX.Element;
@@ -12,7 +12,7 @@ const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
12
12
  const dayjs_1 = __importDefault(require("dayjs"));
13
13
  require("dayjs/locale/pt-br");
14
14
  const utils_1 = require("../../../utils");
15
- function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, }) {
15
+ function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, }) {
16
16
  if (!sx) {
17
17
  sx = { minWidth: 200 };
18
18
  }
@@ -42,6 +42,7 @@ function DesktopDatePickerBySchema({ name, schema, control, errors, fieldKey, in
42
42
  helperText,
43
43
  sx,
44
44
  margin: 'normal',
45
+ autoFocus,
45
46
  },
46
47
  } })))) }));
47
48
  }
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import 'dayjs/locale/pt-br';
3
3
  import { FieldBySchemaProps } from '../../../utils';
4
- export default function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, }: FieldBySchemaProps): React.JSX.Element;
4
+ export default function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx, autoFocus, }: FieldBySchemaProps): React.JSX.Element;
@@ -12,7 +12,7 @@ const AdapterDayjs_1 = require("@mui/x-date-pickers/AdapterDayjs");
12
12
  const dayjs_1 = __importDefault(require("dayjs"));
13
13
  require("dayjs/locale/pt-br");
14
14
  const utils_1 = require("../../../utils");
15
- function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, }) {
15
+ function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey, index, sx = { mr: 2, mt: 2 }, autoFocus, }) {
16
16
  const model = name;
17
17
  if (fieldKey && index && index >= 0) {
18
18
  name = `${fieldKey}.${index}.${name}`;
@@ -35,6 +35,7 @@ function DesktopDateTimePickerBySchema({ name, schema, control, errors, fieldKey
35
35
  helperText,
36
36
  sx,
37
37
  margin: 'normal',
38
+ autoFocus,
38
39
  },
39
40
  } })))) }));
40
41
  }
@@ -59,7 +59,7 @@ const DialogActions_1 = __importDefault(require("../../DialogActions"));
59
59
  const APIWrapperContext_1 = require("../../../context/APIWrapperContext");
60
60
  const filter = (0, Autocomplete_1.createFilterOptions)();
61
61
  const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, ref) => {
62
- var { control, schema, errors, setValue, getValues, fieldKey, labelKey = 'nome', index, name = 'name', optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, sx = { mr: 2 }, onValueChange, multiple = false, disabled = false, fieldsLayout } = _a, other = __rest(_a, ["control", "schema", "errors", "setValue", "getValues", "fieldKey", "labelKey", "index", "name", "optionsAC", "optionsModel", "getOptionLabel", "renderOption", "onEditModel", "sx", "onValueChange", "multiple", "disabled", "fieldsLayout"]);
62
+ var { control, schema, errors, setValue, getValues, fieldKey, labelKey = 'nome', index, name = 'name', optionsAC, optionsModel, getOptionLabel, renderOption, onEditModel, sx = { mr: 2 }, onValueChange, multiple = false, disabled = false, 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"]);
63
63
  const { setDialog } = (0, APIWrapperContext_1.useAPIWrapper)();
64
64
  const [options, setOptions] = (0, react_1.useState)(null);
65
65
  const model = name;
@@ -162,7 +162,7 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, ref) =
162
162
  if (onValueChange) {
163
163
  onValueChange(e);
164
164
  }
165
- }, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: schema[model].required, margin: "normal", error: error, helperText: helperText, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
165
+ }, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: schema[model].required, 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,
166
166
  !multiple && field.value && (react_1.default.createElement(IconButton_1.default, { size: "small", onClick: () => {
167
167
  if ((0, utils_1.isTmpId)(field.value.id)) {
168
168
  setDialog({
@@ -262,7 +262,7 @@ const EditableAutocompleteFieldBySchema = react_1.default.forwardRef((_a, ref) =
262
262
  if (onValueChange) {
263
263
  onValueChange(e);
264
264
  }
265
- }, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: schema[model].required, margin: "normal", error: error, helperText: helperText }, other))), getOptionLabel: getOptionLabel, renderOption: renderOption }))) }));
265
+ }, renderInput: (params) => (react_1.default.createElement(TextField_1.default, Object.assign({}, params, { label: label, required: schema[model].required, margin: "normal", error: error, autoFocus: autoFocus, helperText: helperText }, other))), getOptionLabel: getOptionLabel, renderOption: renderOption }))) }));
266
266
  });
267
267
  EditableAutocompleteFieldBySchema.displayName = 'EditableAutocompleteFieldBySchema';
268
268
  exports.default = EditableAutocompleteFieldBySchema;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function FloatFieldBySchema({ fieldKey, index, name, control, schema, errors, onValueChange, decimalScale, label, ...other }: Omit<FieldBySchemaProps, 'type'>): React.JSX.Element;
3
+ export default function FloatFieldBySchema({ fieldKey, index, name, control, schema, errors, onValueChange, decimalScale, label, autoFocus, ...other }: Omit<FieldBySchemaProps, 'type'>): React.JSX.Element;
@@ -21,7 +21,7 @@ const TextField_1 = __importDefault(require("@mui/material/TextField"));
21
21
  const react_hook_form_1 = require("react-hook-form");
22
22
  const utils_1 = require("../../../utils");
23
23
  function FloatFieldBySchema(_a) {
24
- var { fieldKey, index, name, control, schema, errors, onValueChange, decimalScale, label } = _a, other = __rest(_a, ["fieldKey", "index", "name", "control", "schema", "errors", "onValueChange", "decimalScale", "label"]);
24
+ var { fieldKey, index, name, control, schema, errors, onValueChange, decimalScale, label, autoFocus } = _a, other = __rest(_a, ["fieldKey", "index", "name", "control", "schema", "errors", "onValueChange", "decimalScale", "label", "autoFocus"]);
25
25
  const model = name;
26
26
  if (!label) {
27
27
  label = schema[model].label;
@@ -55,6 +55,6 @@ function FloatFieldBySchema(_a) {
55
55
  if (onValueChange) {
56
56
  onValueChange(values.floatValue);
57
57
  }
58
- }, thousandSeparator: ".", decimalSeparator: ",", decimalScale: decimals, fixedDecimalScale: true, valueIsNumericString: true, prefix: prefix, suffix: suffix, error: error, helperText: helperText, margin: "normal", customInput: TextField_1.default })));
58
+ }, thousandSeparator: ".", decimalSeparator: ",", decimalScale: decimals, fixedDecimalScale: true, valueIsNumericString: true, prefix: prefix, suffix: suffix, error: error, helperText: helperText, margin: "normal", customInput: TextField_1.default, autoFocus: autoFocus })));
59
59
  } }));
60
60
  }
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, isPassword, type, autocomplete, disabled, onValueChange, ...other }: FieldBySchemaProps): React.JSX.Element;
3
+ export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, isPassword, type, autocomplete, disabled, onValueChange, autoFocus, ...other }: FieldBySchemaProps): React.JSX.Element;
@@ -20,7 +20,7 @@ const react_hook_form_1 = require("react-hook-form");
20
20
  const TextField_1 = __importDefault(require("@mui/material/TextField"));
21
21
  const utils_1 = require("../../../utils");
22
22
  function TextFieldBySchema(_a) {
23
- var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, isPassword = false, type, autocomplete, disabled, onValueChange } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "isPassword", "type", "autocomplete", "disabled", "onValueChange"]);
23
+ var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, isPassword = false, type, autocomplete, disabled, onValueChange, autoFocus } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "isPassword", "type", "autocomplete", "disabled", "onValueChange", "autoFocus"]);
24
24
  const model = name;
25
25
  if (fieldKey && index && index >= 0) {
26
26
  name = `${fieldKey}.${index}.${name}`;
@@ -45,5 +45,5 @@ function TextFieldBySchema(_a) {
45
45
  if (onValueChange) {
46
46
  onValueChange(e);
47
47
  }
48
- }, margin: "normal", fullWidth: true, multiline: multiline, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autocomplete, minRows: minRows }))) }));
48
+ }, margin: "normal", fullWidth: true, multiline: multiline, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autocomplete, minRows: minRows, autoFocus: autoFocus }))) }));
49
49
  }
@@ -88,7 +88,7 @@ function Overlays({ children }) {
88
88
  setSnackBar({ open: false });
89
89
  }, anchorOrigin: { vertical: 'top', horizontal: 'right' } },
90
90
  react_1.default.createElement(Alert_1.default, { severity: snackBar.severity }, snackBar.msg))),
91
- dialog && (react_1.default.createElement(Dialog_1.default, { open: dialog.open, onClose: handleDialogClose, disableEscapeKeyDown: !dialog.isCancelDisabled },
91
+ dialog && (react_1.default.createElement(Dialog_1.default, { open: dialog.open, onClose: handleDialogClose, disableEscapeKeyDown: dialog.isCancelDisabled },
92
92
  react_1.default.createElement(DialogTitle_1.default, null, dialog.loading ? 'Carregando...' : dialog.title),
93
93
  react_1.default.createElement(DialogContent_1.default, null, dialog.loading ? (react_1.default.createElement(Box_1.default, { sx: { display: 'flex' } },
94
94
  react_1.default.createElement(CircularProgress_1.default, null))) : (react_1.default.createElement(react_1.default.Fragment, null, dialog.Body))),
package/dist/utils.d.ts CHANGED
@@ -135,6 +135,7 @@ export interface FieldBySchemaProps extends Omit<CommonFieldProps, 'value'> {
135
135
  schema: SchemaType;
136
136
  control: Control;
137
137
  errors: Item;
138
+ autoFocus?: boolean;
138
139
  }
139
140
  export interface DetailFieldBySchemaProps {
140
141
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drf-react-by-schema",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "Components and Tools for building a React App having Django Rest Framework (DRF) as server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",