@ssplib/react-components 0.0.155 → 0.0.157

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.
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const material_1 = require("@mui/material");
30
+ const lodash_get_1 = __importDefault(require("lodash.get"));
30
31
  const react_1 = __importStar(require("react"));
31
- const form_1 = require("../../../context/form");
32
32
  const auth_1 = require("../../../context/auth");
33
- const lodash_get_1 = __importDefault(require("lodash.get"));
33
+ const form_1 = require("../../../context/form");
34
34
  function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch = true, required = false, defaultValue, onChange = () => { }, xs = 12, sm, md, }) {
35
35
  const context = (0, react_1.useContext)(form_1.FormContext);
36
36
  const [loading, setLoading] = (0, react_1.useState)(true);
@@ -90,6 +90,9 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
90
90
  });
91
91
  }
92
92
  function handleAutoCompleteChange(element, value) {
93
+ if (context) {
94
+ context.formRA = element.textContent;
95
+ }
93
96
  context === null || context === void 0 ? void 0 : context.formSetValue(name, value ? value.id : '');
94
97
  onChange(value ? value.id : -1);
95
98
  }
@@ -106,11 +109,7 @@ function FetchAutoComplete({ name, url, title, customLoadingText, shouldRefetch
106
109
  }), { hidden: true })),
107
110
  react_1.default.createElement(material_1.Autocomplete, { loading: loading, loadingText: loadingText, options: list, defaultValue: dValue, isOptionEqualToValue: (op, value) => op.id === value.id, onChange: (e, v) => handleAutoCompleteChange(e.currentTarget, v), renderInput: (params) => {
108
111
  var _a;
109
- return (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { size: 'small', fullWidth: true, placeholder: title, onFocus: onFocus, required: true, error: (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name) ? true : false, helperText: (_a = (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name)) === null || _a === void 0 ? void 0 : _a.message, onChange: (e) => {
110
- if (context) {
111
- context.formRA = e.currentTarget.value;
112
- }
113
- } })));
112
+ return (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { size: 'small', fullWidth: true, placeholder: title, onFocus: onFocus, required: true, error: (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name) ? true : false, helperText: (_a = (0, lodash_get_1.default)(context === null || context === void 0 ? void 0 : context.errors, name)) === null || _a === void 0 ? void 0 : _a.message })));
114
113
  }, size: 'small', fullWidth: true })));
115
114
  }
116
115
  exports.default = FetchAutoComplete;
@@ -42,6 +42,7 @@ function FormProvider({ children, onSubmit, formMethod = 'GET', submiting = fals
42
42
  setFilesUid: setFilesUid,
43
43
  errors: errors,
44
44
  submiting: submiting,
45
+ formRA: '',
45
46
  } },
46
47
  react_1.default.createElement("form", { method: formMethod, onSubmit: handleSubmit((d) => onSubmit(d, filesUid)) }, children)));
47
48
  }
package/context/form.d.ts CHANGED
@@ -17,5 +17,5 @@ export declare const FormContext: import("react").Context<{
17
17
  }[]>>;
18
18
  errors: FieldErrors<FieldValues>;
19
19
  submiting: boolean;
20
- formRA?: string | undefined;
20
+ formRA: string;
21
21
  } | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssplib/react-components",
3
- "version": "0.0.155",
3
+ "version": "0.0.157",
4
4
  "description": "SSP React Components",
5
5
  "main": "index.js",
6
6
  "author": "Pedro Henrique <sr.hudrick@gmail.com>",