drf-react-by-schema 0.14.2 → 0.14.3

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
  /// <reference types="react" />
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function BooleanFieldBySchema({ name, schema, control, errors, fieldKey, index, sx, onValueChange, ...other }: FieldBySchemaProps): JSX.Element;
3
+ export default function BooleanFieldBySchema({ name, schema, control, fieldKey, index, sx, onValueChange, ...other }: FieldBySchemaProps): JSX.Element;
@@ -19,28 +19,16 @@ const react_hook_form_1 = require("react-hook-form");
19
19
  const Checkbox_1 = __importDefault(require("@mui/material/Checkbox"));
20
20
  const FormControlLabel_1 = __importDefault(require("@mui/material/FormControlLabel"));
21
21
  function BooleanFieldBySchema(_a) {
22
- var { name, schema, control, errors, fieldKey, index, sx = { mr: 2 }, onValueChange } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "fieldKey", "index", "sx", "onValueChange"]);
22
+ var { name, schema, control, fieldKey, index, sx = { mr: 2 }, onValueChange } = _a, other = __rest(_a, ["name", "schema", "control", "fieldKey", "index", "sx", "onValueChange"]);
23
23
  const model = name;
24
24
  if (fieldKey && index && index >= 0) {
25
25
  name = `${fieldKey}.${index}.${name}`;
26
26
  }
27
- // const { error, helperText } =
28
- // fieldKey && index >= 0
29
- // ? errorProps({
30
- // fieldKey,
31
- // index,
32
- // fieldKeyProp: name,
33
- // errors,
34
- // })
35
- // : {
36
- // error: errors && Boolean(errors[name]),
37
- // helperText: errors && errors[name] ? errors[name].message : schema[name].help_text || '',
38
- // };
39
27
  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, inputProps: { 'aria-label': 'controlled' }, onChange: (e) => {
40
28
  if (onValueChange) {
41
29
  onValueChange(e);
42
30
  }
43
31
  field.onChange(e);
44
- } })), label: schema[model].label, required: schema[model].required })) }));
32
+ }, sx: sx })), label: schema[model].label, required: schema[model].required })) }));
45
33
  }
46
34
  exports.default = BooleanFieldBySchema;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { FieldBySchemaProps } from '../../../utils';
3
- export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, isPassword, type, autocomplete, ...other }: FieldBySchemaProps): JSX.Element;
3
+ export default function TextFieldBySchema({ name, schema, control, errors, multiline, minRows, fieldKey, index, sx, isPassword, type, autocomplete, disabled, ...other }: FieldBySchemaProps): JSX.Element;
@@ -19,7 +19,7 @@ const react_hook_form_1 = require("react-hook-form");
19
19
  const TextField_1 = __importDefault(require("@mui/material/TextField"));
20
20
  const utils_1 = require("../../../utils");
21
21
  function TextFieldBySchema(_a) {
22
- var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, isPassword = false, type, autocomplete } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "isPassword", "type", "autocomplete"]);
22
+ var { name, schema, control, errors, multiline = false, minRows, fieldKey, index, sx = { mr: 2 }, isPassword = false, type, autocomplete, disabled } = _a, other = __rest(_a, ["name", "schema", "control", "errors", "multiline", "minRows", "fieldKey", "index", "sx", "isPassword", "type", "autocomplete", "disabled"]);
23
23
  const model = name;
24
24
  if (fieldKey && index && index >= 0) {
25
25
  name = `${fieldKey}.${index}.${name}`;
@@ -39,6 +39,6 @@ function TextFieldBySchema(_a) {
39
39
  error: errors && Boolean(errors[name]),
40
40
  helperText: errors && errors[name] ? errors[name].message : schema[name].help_text || '',
41
41
  };
42
- 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: schema[model].label, required: schema[model].required, disabled: schema[model].disabled === true, margin: "normal", fullWidth: true, multiline: multiline, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autocomplete, minRows: minRows }))) }));
42
+ 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: schema[model].label, required: schema[model].required, disabled: schema[model].disabled === true || disabled, margin: "normal", fullWidth: true, multiline: multiline, error: error, helperText: helperText, sx: sx, type: type, autoComplete: autocomplete, minRows: minRows }))) }));
43
43
  }
44
44
  exports.default = TextFieldBySchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drf-react-by-schema",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
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",