@ssplib/react-components 0.0.71 → 0.0.73

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.
@@ -57,7 +57,13 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
57
57
  });
58
58
  }
59
59
  return (react_1.default.createElement(material_1.Grid, Object.assign({ item: true }, { xs, sm, md }),
60
- react_1.default.createElement(material_1.InputLabel, { required: required }, title),
60
+ title && react_1.default.createElement(material_1.InputLabel, { required: required }, title),
61
+ react_1.default.createElement("input", Object.assign({ type: 'text' }, context === null || context === void 0 ? void 0 : context.formRegister(name, {
62
+ validate: (v, f) => {
63
+ if (v.length <= 0 && required)
64
+ return 'Este campo é obrigatório';
65
+ },
66
+ }), { hidden: true })),
61
67
  react_1.default.createElement(material_1.Autocomplete, { loading: loading, loadingText: loadingText, options: list, isOptionEqualToValue: (op, value) => op.id === value.id, onChange: (e, v) => context === null || context === void 0 ? void 0 : context.formSetValue(name, v ? v.id : ''), renderInput: (params) => react_1.default.createElement(material_1.TextField, Object.assign({}, params, { size: 'small', fullWidth: true, placeholder: title, onFocus: onFocus, required: true })), size: 'small', fullWidth: true })));
62
68
  }
63
69
  exports.default = FetchAutoComplete;
@@ -37,11 +37,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  const material_1 = require("@mui/material");
38
38
  const react_1 = __importStar(require("react"));
39
39
  const react_imask_1 = require("react-imask");
40
+ const form_1 = require("../../../context/form");
40
41
  const TextMaskCustom = react_1.default.forwardRef(function TextMaskCustom(props, ref) {
41
42
  const { onChange, maskProps, onMask, maskValue, setMaskValue } = props, prop = __rest(props, ["onChange", "maskProps", "onMask", "maskValue", "setMaskValue"]);
42
43
  const [mask, setMask] = (0, react_1.useState)(maskProps.mask);
43
44
  delete prop.value;
44
- return (react_1.default.createElement(react_imask_1.IMaskInput, Object.assign({}, prop, maskProps, { mask: mask, autoComplete: 'off', inputRef: ref, onAccept: (value) => {
45
+ return (react_1.default.createElement(react_imask_1.IMaskInput, Object.assign({}, prop, maskProps, { mask: mask, inputRef: ref, onAccept: (value) => {
45
46
  setMaskValue(value);
46
47
  if (!onMask)
47
48
  return;
@@ -49,12 +50,17 @@ const TextMaskCustom = react_1.default.forwardRef(function TextMaskCustom(props,
49
50
  } })));
50
51
  });
51
52
  function MaskInput(props) {
53
+ const context = (0, react_1.useContext)(form_1.FormContext);
52
54
  const [inputValue, setInputValue] = react_1.default.useState('');
53
55
  const [maskValue, setMaskValue] = (0, react_1.useState)('');
54
56
  const onChangeInput = (0, react_1.useCallback)((e) => {
55
57
  setInputValue(e.target.value);
56
58
  }, []);
57
- return (react_1.default.createElement(material_1.TextField, Object.assign({}, props.formConfig, { autoComplete: 'off', value: inputValue, onFocus: (e) => setMaskValue(e.target.value), onChange: onChangeInput, InputProps: {
59
+ return (react_1.default.createElement(material_1.TextField, Object.assign({}, props.formConfig, { value: inputValue, onInput: (e) => {
60
+ const name = props.formConfig.name;
61
+ const value = e.target.value;
62
+ context.formSetValue(name, value);
63
+ }, onFocus: (e) => setMaskValue(e.target.value), onChange: onChangeInput, InputProps: {
58
64
  inputComponent: TextMaskCustom,
59
65
  inputProps: { maskProps: props.maskProps, onMask: props.onMask, maskValue, setMaskValue },
60
66
  }, disabled: props.disabled, fullWidth: true })));
@@ -42,6 +42,6 @@ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = fals
42
42
  errors: errors,
43
43
  submiting: submiting,
44
44
  } },
45
- react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d, filesUid)), autoComplete: 'off' }, children)));
45
+ react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d, filesUid)) }, children)));
46
46
  }
47
47
  exports.default = FormProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",